#include "theme_factory.h" #include "icon_utils.h" struct ToolbarParams { ToolbarThemeTemplates t; QColor iconColor; QColor iconDisabledColor; QColor iconCheckedColor; QColor backgroundColor; QColor separatorColor; QColor checkedButtonColor; QColor menuIndicatorColor; }; struct ViewerParams { ViewerThemeTemplates t; QColor defaultBackgroundColor; QColor defaultTextColor; QColor infoBackgroundColor; QColor infoTextColor; }; struct ThemeParams { QString themeName; ToolbarParams toolbarParams; ViewerParams viewerParams; }; void setToolbarIconPair(QIcon &icon, QIcon &icon18, const QString &basePath, const QColor &iconColor, const QColor &disabledColor, const QColor &checkedColor, const QString &themeName) { QString path18 = basePath; if (path18.endsWith(".svg")) path18.insert(path18.size() - 4, "_18x18"); else path18.append("_18x18"); // Normal const QString normalPath = recoloredSvgToThemeFile(basePath, iconColor, themeName); const QString normalPath18 = recoloredSvgToThemeFile(path18, iconColor, themeName); // Disabled const QString disabledPath = recoloredSvgToThemeFile(basePath, disabledColor, themeName, "_disabled"); const QString disabledPath18 = recoloredSvgToThemeFile(path18, disabledColor, themeName, "_disabled"); // Checked (On state) const QString checkedPath = recoloredSvgToThemeFile(basePath, checkedColor, themeName, "_checked"); const QString checkedPath18 = recoloredSvgToThemeFile(path18, checkedColor, themeName, "_checked"); icon.addFile(normalPath, QSize(), QIcon::Normal, QIcon::Off); icon.addFile(disabledPath, QSize(), QIcon::Disabled, QIcon::Off); icon.addFile(checkedPath, QSize(), QIcon::Normal, QIcon::On); icon.addFile(disabledPath, QSize(), QIcon::Disabled, QIcon::On); icon18.addFile(normalPath18, QSize(), QIcon::Normal, QIcon::Off); icon18.addFile(disabledPath18, QSize(), QIcon::Disabled, QIcon::Off); icon18.addFile(checkedPath18, QSize(), QIcon::Normal, QIcon::On); icon18.addFile(disabledPath18, QSize(), QIcon::Disabled, QIcon::On); } Theme makeTheme(const ThemeParams ¶ms) { Theme theme; // Toolbar & actions theme.toolbar.toolbarQSS = params.toolbarParams.t.toolbarQSS.arg(params.toolbarParams.backgroundColor.name(), params.toolbarParams.separatorColor.name(), params.toolbarParams.checkedButtonColor.name(), recoloredSvgToThemeFile(params.toolbarParams.t.menuArrowPath, params.toolbarParams.menuIndicatorColor, params.themeName)); auto setToolbarIconPairT = [&](QIcon &icon, QIcon &icon18, const QString &basePath) { setToolbarIconPair(icon, icon18, basePath, params.toolbarParams.iconColor, params.toolbarParams.iconDisabledColor, params.toolbarParams.iconCheckedColor, params.themeName); }; setToolbarIconPairT(theme.toolbar.openAction, theme.toolbar.openAction18x18, ":/images/viewer_toolbar/open.svg"); setToolbarIconPairT(theme.toolbar.openFolderAction, theme.toolbar.openFolderAction18x18, ":/images/viewer_toolbar/openFolder.svg"); setToolbarIconPairT(theme.toolbar.openLatestComicAction, theme.toolbar.openLatestComicAction18x18, ":/images/viewer_toolbar/openNext.svg"); setToolbarIconPairT(theme.toolbar.saveImageAction, theme.toolbar.saveImageAction18x18, ":/images/viewer_toolbar/save.svg"); setToolbarIconPairT(theme.toolbar.openComicOnTheLeftAction, theme.toolbar.openComicOnTheLeftAction18x18, ":/images/viewer_toolbar/openPrevious.svg"); setToolbarIconPairT(theme.toolbar.openComicOnTheRightAction, theme.toolbar.openComicOnTheRightAction18x18, ":/images/viewer_toolbar/openNext.svg"); setToolbarIconPairT(theme.toolbar.goToPageOnTheLeftAction, theme.toolbar.goToPageOnTheLeftAction18x18, ":/images/viewer_toolbar/previous.svg"); setToolbarIconPairT(theme.toolbar.goToPageOnTheRightAction, theme.toolbar.goToPageOnTheRightAction18x18, ":/images/viewer_toolbar/next.svg"); setToolbarIconPairT(theme.toolbar.adjustHeightAction, theme.toolbar.adjustHeightAction18x18, ":/images/viewer_toolbar/toHeight.svg"); setToolbarIconPairT(theme.toolbar.adjustWidthAction, theme.toolbar.adjustWidthAction18x18, ":/images/viewer_toolbar/toWidth.svg"); setToolbarIconPairT(theme.toolbar.leftRotationAction, theme.toolbar.leftRotationAction18x18, ":/images/viewer_toolbar/rotateL.svg"); setToolbarIconPairT(theme.toolbar.rightRotationAction, theme.toolbar.rightRotationAction18x18, ":/images/viewer_toolbar/rotateR.svg"); setToolbarIconPairT(theme.toolbar.doublePageAction, theme.toolbar.doublePageAction18x18, ":/images/viewer_toolbar/doublePage.svg"); setToolbarIconPairT(theme.toolbar.doubleMangaPageAction, theme.toolbar.doubleMangaPageAction18x18, ":/images/viewer_toolbar/doubleMangaPage.svg"); setToolbarIconPairT(theme.toolbar.showZoomSliderlAction, theme.toolbar.showZoomSliderlAction18x18, ":/images/viewer_toolbar/zoom.svg"); setToolbarIconPairT(theme.toolbar.goToPageAction, theme.toolbar.goToPageAction18x18, ":/images/viewer_toolbar/goto.svg"); setToolbarIconPairT(theme.toolbar.optionsAction, theme.toolbar.optionsAction18x18, ":/images/viewer_toolbar/options.svg"); setToolbarIconPairT(theme.toolbar.helpAboutAction, theme.toolbar.helpAboutAction18x18, ":/images/viewer_toolbar/help.svg"); setToolbarIconPairT(theme.toolbar.showMagnifyingGlassAction, theme.toolbar.showMagnifyingGlassAction18x18, ":/images/viewer_toolbar/magnifyingGlass.svg"); setToolbarIconPairT(theme.toolbar.setBookmarkAction, theme.toolbar.setBookmarkAction18x18, ":/images/viewer_toolbar/bookmark.svg"); setToolbarIconPairT(theme.toolbar.showBookmarksAction, theme.toolbar.showBookmarksAction18x18, ":/images/viewer_toolbar/showBookmarks.svg"); setToolbarIconPairT(theme.toolbar.showShorcutsAction, theme.toolbar.showShorcutsAction18x18, ":/images/viewer_toolbar/shortcuts.svg"); setToolbarIconPairT(theme.toolbar.showInfoAction, theme.toolbar.showInfoAction18x18, ":/images/viewer_toolbar/info.svg"); setToolbarIconPairT(theme.toolbar.closeAction, theme.toolbar.closeAction18x18, ":/images/viewer_toolbar/close.svg"); setToolbarIconPairT(theme.toolbar.showDictionaryAction, theme.toolbar.showDictionaryAction18x18, ":/images/viewer_toolbar/translator.svg"); setToolbarIconPairT(theme.toolbar.adjustToFullSizeAction, theme.toolbar.adjustToFullSizeAction18x18, ":/images/viewer_toolbar/full.svg"); setToolbarIconPairT(theme.toolbar.fitToPageAction, theme.toolbar.fitToPageAction18x18, ":/images/viewer_toolbar/fitToPage.svg"); setToolbarIconPairT(theme.toolbar.showFlowAction, theme.toolbar.showFlowAction18x18, ":/images/viewer_toolbar/flow.svg"); // end Toolbar & actions // Viewer theme.viewer.defaultBackgroundColor = params.viewerParams.defaultBackgroundColor; theme.viewer.defaultTextColor = params.viewerParams.defaultTextColor; theme.viewer.infoBackgroundColor = params.viewerParams.infoBackgroundColor; theme.viewer.infoLabelQSS = params.viewerParams.t.infoLabelQSS.arg(params.viewerParams.infoTextColor.name()); // end Viewer return theme; } ThemeParams classicThemeParams(); ThemeParams lightThemeParams(); ThemeParams darkThemeParams(); Theme makeTheme(ThemeId themeId) { switch (themeId) { case ThemeId::Classic: return makeTheme(classicThemeParams()); case ThemeId::Light: return makeTheme(lightThemeParams()); case ThemeId::Dark: return makeTheme(darkThemeParams()); } } ThemeParams classicThemeParams() { ThemeParams params; params.themeName = "classic"; ToolbarParams toolbarParams; toolbarParams.iconColor = QColor(0x404040); toolbarParams.iconDisabledColor = QColor(0x858585); toolbarParams.iconCheckedColor = QColor(0x5A5A5A); toolbarParams.backgroundColor = QColor(0xF3F3F3); toolbarParams.separatorColor = QColor(0xCCCCCC); toolbarParams.checkedButtonColor = QColor(0xCCCCCC); toolbarParams.menuIndicatorColor = QColor(0x404040); params.toolbarParams = toolbarParams; ViewerParams viewerParams; viewerParams.defaultBackgroundColor = QColor(0x282828); viewerParams.defaultTextColor = Qt::white; viewerParams.infoBackgroundColor = QColor::fromRgba(0xBB000000); viewerParams.infoTextColor = Qt::white; viewerParams.t = ViewerThemeTemplates(); params.viewerParams = viewerParams; return params; } ThemeParams lightThemeParams() { ThemeParams params; params.themeName = "light"; ToolbarParams toolbarParams; toolbarParams.iconColor = QColor(0x404040); toolbarParams.iconDisabledColor = QColor(0xB0B0B0); toolbarParams.iconCheckedColor = QColor(0x5A5A5A); toolbarParams.backgroundColor = QColor(0xF3F3F3); toolbarParams.separatorColor = QColor(0xCCCCCC); toolbarParams.checkedButtonColor = QColor(0xCCCCCC); toolbarParams.menuIndicatorColor = QColor(0x404040); params.toolbarParams = toolbarParams; ViewerParams viewerParams; viewerParams.defaultBackgroundColor = QColor(0xF6F6F6); viewerParams.defaultTextColor = QColor(0x202020); viewerParams.infoBackgroundColor = QColor::fromRgba(0xBBFFFFFF); viewerParams.infoTextColor = QColor(0x404040); viewerParams.t = ViewerThemeTemplates(); params.viewerParams = viewerParams; return params; } ThemeParams darkThemeParams() { ThemeParams params; params.themeName = "dark"; ToolbarParams toolbarParams; toolbarParams.iconColor = QColor(0xCCCCCC); toolbarParams.iconDisabledColor = QColor(0x444444); toolbarParams.iconCheckedColor = QColor(0xDADADA); toolbarParams.backgroundColor = QColor(0x202020); toolbarParams.separatorColor = QColor(0x444444); toolbarParams.checkedButtonColor = QColor(0x3A3A3A); toolbarParams.menuIndicatorColor = QColor(0xCCCCCC); params.toolbarParams = toolbarParams; ViewerParams viewerParams; viewerParams.defaultBackgroundColor = QColor(40, 40, 40); viewerParams.defaultTextColor = Qt::white; viewerParams.infoBackgroundColor = QColor::fromRgba(0xBB000000); viewerParams.infoTextColor = QColor(0xB0B0B0); viewerParams.t = ViewerThemeTemplates(); params.viewerParams = viewerParams; return params; } // TODO ThemeParams paramsFromFile(const QString &filePath) { return {}; }