mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-06-05 21:59:17 +02:00
Issue #283: icons hard to see in dark mode
This commit is contained in:
@ -24,6 +24,7 @@
|
|||||||
#include "pdfdocumentreader.h"
|
#include "pdfdocumentreader.h"
|
||||||
#include "pdfsecurityhandler.h"
|
#include "pdfsecurityhandler.h"
|
||||||
#include "pdfapplicationtranslator.h"
|
#include "pdfapplicationtranslator.h"
|
||||||
|
#include "pdfwidgetutils.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
@ -40,10 +41,14 @@ int main(int argc, char *argv[])
|
|||||||
QApplication::setApplicationDisplayName(QApplication::translate("Application", "PDF4QT Diff"));
|
QApplication::setApplicationDisplayName(QApplication::translate("Application", "PDF4QT Diff"));
|
||||||
|
|
||||||
QCommandLineOption noDrm("no-drm", "Disable DRM settings of documents.");
|
QCommandLineOption noDrm("no-drm", "Disable DRM settings of documents.");
|
||||||
|
QCommandLineOption lightGui("theme-light", "Use a light theme for the GUI.");
|
||||||
|
QCommandLineOption darkGui("theme-dark", "Use a dark theme for the GUI.");
|
||||||
|
|
||||||
QCommandLineParser parser;
|
QCommandLineParser parser;
|
||||||
parser.setApplicationDescription(QCoreApplication::applicationName());
|
parser.setApplicationDescription(QCoreApplication::applicationName());
|
||||||
parser.addOption(noDrm);
|
parser.addOption(noDrm);
|
||||||
|
parser.addOption(lightGui);
|
||||||
|
parser.addOption(darkGui);
|
||||||
parser.addHelpOption();
|
parser.addHelpOption();
|
||||||
parser.addVersionOption();
|
parser.addVersionOption();
|
||||||
parser.addPositionalArgument("file1", "The PDF file to be compared.");
|
parser.addPositionalArgument("file1", "The PDF file to be compared.");
|
||||||
@ -55,6 +60,8 @@ int main(int argc, char *argv[])
|
|||||||
pdf::PDFSecurityHandler::setNoDRMMode();
|
pdf::PDFSecurityHandler::setNoDRMMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pdf::PDFWidgetUtils::setDarkTheme(parser.isSet(lightGui), parser.isSet(darkGui));
|
||||||
|
|
||||||
pdf::PDFApplicationTranslator translator;
|
pdf::PDFApplicationTranslator translator;
|
||||||
translator.installTranslator();
|
translator.installTranslator();
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include "pdfdrawwidget.h"
|
#include "pdfdrawwidget.h"
|
||||||
#include "pdfwidgetannotation.h"
|
#include "pdfwidgetannotation.h"
|
||||||
#include "pdfpainterutils.h"
|
#include "pdfpainterutils.h"
|
||||||
|
#include "pdfwidgetutils.h"
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
@ -785,7 +786,10 @@ QColor PDFDrawWidgetProxy::getPaperColor()
|
|||||||
|
|
||||||
void PDFDrawWidgetProxy::drawPages(QPainter* painter, QRect rect, PDFRenderer::Features features)
|
void PDFDrawWidgetProxy::drawPages(QPainter* painter, QRect rect, PDFRenderer::Features features)
|
||||||
{
|
{
|
||||||
painter->fillRect(rect, Qt::lightGray);
|
const bool darkScheme = PDFWidgetUtils::isDarkTheme();
|
||||||
|
QColor backgroundColor = darkScheme ? QColor(34, 34, 34) : QColor(Qt::lightGray);
|
||||||
|
|
||||||
|
painter->fillRect(rect, backgroundColor);
|
||||||
QTransform baseMatrix = painter->worldTransform();
|
QTransform baseMatrix = painter->worldTransform();
|
||||||
|
|
||||||
// Use current paper color (it can be a bit different from white)
|
// Use current paper color (it can be a bit different from white)
|
||||||
|
@ -196,11 +196,10 @@ void PDFWidgetUtils::setDarkTheme(bool isLightTheme, bool isDarkTheme)
|
|||||||
{
|
{
|
||||||
QPalette darkPalette = QApplication::palette();
|
QPalette darkPalette = QApplication::palette();
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
QApplication::setStyle(QStyleFactory::create("Fusion"));
|
QApplication::setStyle(QStyleFactory::create("Fusion"));
|
||||||
|
|
||||||
// Basic colors
|
// Basic colors
|
||||||
darkPalette.setColor(QPalette::WindowText, QColor(220, 220, 220));
|
darkPalette.setColor(QPalette::WindowText, QColor(240, 246, 252));
|
||||||
darkPalette.setColor(QPalette::Button, QColor(53, 53, 53));
|
darkPalette.setColor(QPalette::Button, QColor(53, 53, 53));
|
||||||
darkPalette.setColor(QPalette::Light, QColor(70, 70, 70));
|
darkPalette.setColor(QPalette::Light, QColor(70, 70, 70));
|
||||||
darkPalette.setColor(QPalette::Midlight, QColor(60, 60, 60));
|
darkPalette.setColor(QPalette::Midlight, QColor(60, 60, 60));
|
||||||
@ -213,8 +212,8 @@ void PDFWidgetUtils::setDarkTheme(bool isLightTheme, bool isDarkTheme)
|
|||||||
darkPalette.setColor(QPalette::ButtonText, QColor(220, 220, 220));
|
darkPalette.setColor(QPalette::ButtonText, QColor(220, 220, 220));
|
||||||
|
|
||||||
// Background
|
// Background
|
||||||
darkPalette.setColor(QPalette::Base, QColor(42, 42, 42));
|
darkPalette.setColor(QPalette::Base, QColor(13, 17, 23));
|
||||||
darkPalette.setColor(QPalette::Window, QColor(53, 53, 53));
|
darkPalette.setColor(QPalette::Window, QColor(1, 4, 9));
|
||||||
darkPalette.setColor(QPalette::Shadow, QColor(20, 20, 20));
|
darkPalette.setColor(QPalette::Shadow, QColor(20, 20, 20));
|
||||||
|
|
||||||
// Highlight
|
// Highlight
|
||||||
@ -245,7 +244,6 @@ void PDFWidgetUtils::setDarkTheme(bool isLightTheme, bool isDarkTheme)
|
|||||||
currentColor = currentColor.lighter(150);
|
currentColor = currentColor.lighter(150);
|
||||||
darkPalette.setColor(QPalette::Current, static_cast<QPalette::ColorRole>(i), currentColor);
|
darkPalette.setColor(QPalette::Current, static_cast<QPalette::ColorRole>(i), currentColor);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// Placeholder text (Qt 5.12+)
|
// Placeholder text (Qt 5.12+)
|
||||||
darkPalette.setColor(QPalette::PlaceholderText, QColor(150, 150, 150));
|
darkPalette.setColor(QPalette::PlaceholderText, QColor(150, 150, 150));
|
||||||
|
Reference in New Issue
Block a user