diff --git a/Pdf4QtDiff/main.cpp b/Pdf4QtDiff/main.cpp index 2110a20..8d1dd23 100644 --- a/Pdf4QtDiff/main.cpp +++ b/Pdf4QtDiff/main.cpp @@ -24,6 +24,7 @@ #include "pdfdocumentreader.h" #include "pdfsecurityhandler.h" #include "pdfapplicationtranslator.h" +#include "pdfwidgetutils.h" #include "mainwindow.h" #include @@ -40,10 +41,14 @@ int main(int argc, char *argv[]) QApplication::setApplicationDisplayName(QApplication::translate("Application", "PDF4QT Diff")); 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; parser.setApplicationDescription(QCoreApplication::applicationName()); parser.addOption(noDrm); + parser.addOption(lightGui); + parser.addOption(darkGui); parser.addHelpOption(); parser.addVersionOption(); parser.addPositionalArgument("file1", "The PDF file to be compared."); @@ -55,6 +60,8 @@ int main(int argc, char *argv[]) pdf::PDFSecurityHandler::setNoDRMMode(); } + pdf::PDFWidgetUtils::setDarkTheme(parser.isSet(lightGui), parser.isSet(darkGui)); + pdf::PDFApplicationTranslator translator; translator.installTranslator(); diff --git a/Pdf4QtLibWidgets/sources/pdfdrawspacecontroller.cpp b/Pdf4QtLibWidgets/sources/pdfdrawspacecontroller.cpp index 16ba44e..c5bc157 100644 --- a/Pdf4QtLibWidgets/sources/pdfdrawspacecontroller.cpp +++ b/Pdf4QtLibWidgets/sources/pdfdrawspacecontroller.cpp @@ -30,6 +30,7 @@ #include "pdfdrawwidget.h" #include "pdfwidgetannotation.h" #include "pdfpainterutils.h" +#include "pdfwidgetutils.h" #include #include @@ -785,7 +786,10 @@ QColor PDFDrawWidgetProxy::getPaperColor() 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(); // Use current paper color (it can be a bit different from white) diff --git a/Pdf4QtLibWidgets/sources/pdfwidgetutils.cpp b/Pdf4QtLibWidgets/sources/pdfwidgetutils.cpp index b8e6ee5..8a7e990 100644 --- a/Pdf4QtLibWidgets/sources/pdfwidgetutils.cpp +++ b/Pdf4QtLibWidgets/sources/pdfwidgetutils.cpp @@ -196,11 +196,10 @@ void PDFWidgetUtils::setDarkTheme(bool isLightTheme, bool isDarkTheme) { QPalette darkPalette = QApplication::palette(); -#ifdef Q_OS_WIN QApplication::setStyle(QStyleFactory::create("Fusion")); // 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::Light, QColor(70, 70, 70)); 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)); // Background - darkPalette.setColor(QPalette::Base, QColor(42, 42, 42)); - darkPalette.setColor(QPalette::Window, QColor(53, 53, 53)); + darkPalette.setColor(QPalette::Base, QColor(13, 17, 23)); + darkPalette.setColor(QPalette::Window, QColor(1, 4, 9)); darkPalette.setColor(QPalette::Shadow, QColor(20, 20, 20)); // Highlight @@ -245,7 +244,6 @@ void PDFWidgetUtils::setDarkTheme(bool isLightTheme, bool isDarkTheme) currentColor = currentColor.lighter(150); darkPalette.setColor(QPalette::Current, static_cast(i), currentColor); } -#endif // Placeholder text (Qt 5.12+) darkPalette.setColor(QPalette::PlaceholderText, QColor(150, 150, 150));