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

@ -20,6 +20,7 @@
#include "pdfglobal.h"
#include <QIcon>
#include <QWidget>
namespace pdf
@ -57,6 +58,35 @@ public:
/// Apply style to the widget
static void style(QWidget* widget);
/// Vrátí true, pokud je aktuálně nastavená dark theme
/// pro aplikaci.
static bool isDarkTheme();
/// Converts an action's icon for use in a dark theme.
/// \param action Pointer to the QAction to be converted.
/// \param iconSize The size of the action's icon.
/// \param devicePixelRatioF The device pixel ratio factor.
static void convertActionForDarkTheme(QAction* action, QSize iconSize, qreal devicePixelRatioF);
/// Converts an icon for use in a dark theme.
/// \param icon The icon to be converted.
/// \param iconSize The size of the icon.
/// \param devicePixelRatioF The device pixel ratio factor.
static QIcon convertIconForDarkTheme(QIcon icon, QSize iconSize, qreal devicePixelRatioF);
/// Converts an action's icon for use in a dark theme.
/// \param action Pointer to the QAction to be converted.
/// \param iconSize The size of the action's icon.
/// \param devicePixelRatioF The device pixel ratio factor.
template<typename Container>
static void convertActionsForDarkTheme(const Container& actions, QSize iconSize, qreal devicePixelRatioF)
{
for (QAction* action : actions)
{
convertActionForDarkTheme(action, iconSize, devicePixelRatioF);
}
}
};
} // namespace pdf