Issue #99: Icons for dark mode

This commit is contained in:
Jakub Melka
2023-11-26 19:15:20 +01:00
parent f5cb2a17af
commit 1c5c7da5ba
8 changed files with 110 additions and 0 deletions

View File

@@ -27,6 +27,7 @@
#include "pdfdocumentbuilder.h"
#include "pdfdbgheap.h"
#include "pdfcertificatemanagerdialog.h"
#include "pdfwidgetutils.h"
#include "pdfviewersettings.h"
#include "pdfundoredomanager.h"
@@ -292,6 +293,20 @@ void PDFActionManager::initActions(QSize iconSize, bool initializeStampActions)
createCreateStampAction(CreateStampSold, pdf::Stamp::Sold);
createCreateStampAction(CreateStampTopSecret, pdf::Stamp::TopSecret);
}
m_iconSize = iconSize;
}
void PDFActionManager::styleActions()
{
if (pdf::PDFWidgetUtils::isDarkTheme())
{
qreal devicePixelRatio = qGuiApp->devicePixelRatio();
// Convert icons to dark theme icons
pdf::PDFWidgetUtils::convertActionsForDarkTheme(m_actions, m_iconSize, devicePixelRatio);
pdf::PDFWidgetUtils::convertActionsForDarkTheme(m_additionalActions, m_iconSize, devicePixelRatio);
}
}
bool PDFActionManager::hasActions(const std::initializer_list<Action>& actionTypes) const

View File

@@ -230,6 +230,7 @@ public:
void addAdditionalAction(QAction* action);
void initActions(QSize iconSize, bool initializeStampActions);
void styleActions();
private:
bool hasActions(const std::initializer_list<Action>& actionTypes) const;
@@ -238,6 +239,7 @@ private:
std::array<QAction*, LastAction> m_actions;
std::array<QActionGroup*, LastActionGroup> m_actionGroups;
std::vector<QAction*> m_additionalActions;
QSize m_iconSize;
};
class PDF4QTVIEWERLIBSHARED_EXPORT PDFProgramController : public QObject, public pdf::IPluginDataExchange

View File

@@ -301,6 +301,8 @@ PDFViewerMainWindow::PDFViewerMainWindow(QWidget* parent) :
{
connect(toolManager, &pdf::PDFToolManager::messageDisplayRequest, statusBar(), &QStatusBar::showMessage);
}
m_actionManager->styleActions();
}
PDFViewerMainWindow::~PDFViewerMainWindow()

View File

@@ -218,6 +218,8 @@ PDFViewerMainWindowLite::PDFViewerMainWindowLite(QWidget* parent) :
{
connect(toolManager, &pdf::PDFToolManager::messageDisplayRequest, statusBar(), &QStatusBar::showMessage);
}
m_actionManager->styleActions();
}
PDFViewerMainWindowLite::~PDFViewerMainWindowLite()