mirror of
https://github.com/YACReader/yacreader
synced 2026-04-12 15:49:53 -04:00
Initial implementation of theming
This commit is contained in:
@ -18,8 +18,6 @@ class QKeyEvent;
|
||||
class GoToFlowWidget : public QWidget, protected Themable
|
||||
{
|
||||
Q_OBJECT
|
||||
protected:
|
||||
void applyTheme(const Theme &theme) override;
|
||||
|
||||
public:
|
||||
GoToFlowWidget(QWidget *parent = nullptr, FlowType flowType = CoverFlowLike);
|
||||
@ -42,6 +40,7 @@ signals:
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
void applyTheme(const Theme &theme) override;
|
||||
|
||||
private:
|
||||
QVBoxLayout *mainLayout;
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
#include "yacreader_global.h"
|
||||
#include "edit_shortcuts_dialog.h"
|
||||
#include "shortcuts_manager.h"
|
||||
#include "theme_manager.h"
|
||||
|
||||
#include "whats_new_controller.h"
|
||||
|
||||
@ -186,7 +187,7 @@ void MainWindowViewer::setupUI()
|
||||
void MainWindowViewer::createActions()
|
||||
{
|
||||
openAction = new QAction(tr("&Open"), this);
|
||||
openAction->setIcon(QIcon(addExtensionToIconPath(":/images/viewer_toolbar/open")));
|
||||
openAction->setIcon(QIcon(":/images/viewer_toolbar/open.svg"));
|
||||
openAction->setToolTip(tr("Open a comic"));
|
||||
openAction->setData(OPEN_ACTION_Y);
|
||||
openAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_ACTION_Y));
|
||||
@ -213,7 +214,7 @@ void MainWindowViewer::createActions()
|
||||
#endif
|
||||
|
||||
openFolderAction = new QAction(tr("Open Folder"), this);
|
||||
openFolderAction->setIcon(QIcon(addExtensionToIconPath(":/images/viewer_toolbar/openFolder")));
|
||||
openFolderAction->setIcon(QIcon(":/images/viewer_toolbar/openFolder.svg"));
|
||||
openFolderAction->setToolTip(tr("Open image folder"));
|
||||
openFolderAction->setData(OPEN_FOLDER_ACTION_Y);
|
||||
openFolderAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_FOLDER_ACTION_Y));
|
||||
@ -237,28 +238,28 @@ void MainWindowViewer::createActions()
|
||||
connect(clearRecentFilesAction, &QAction::triggered, this, &MainWindowViewer::clearRecentFiles);
|
||||
|
||||
saveImageAction = new QAction(tr("Save"), this);
|
||||
saveImageAction->setIcon(QIcon(addExtensionToIconPath(":/images/viewer_toolbar/save")));
|
||||
saveImageAction->setIcon(QIcon(":/images/viewer_toolbar/save.svg"));
|
||||
saveImageAction->setToolTip(tr("Save current page"));
|
||||
saveImageAction->setData(SAVE_IMAGE_ACTION_Y);
|
||||
saveImageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SAVE_IMAGE_ACTION_Y));
|
||||
connect(saveImageAction, &QAction::triggered, this, &MainWindowViewer::saveImage);
|
||||
|
||||
openComicOnTheLeftAction = new QAction(tr("Previous Comic"), this);
|
||||
openComicOnTheLeftAction->setIcon(QIcon(addExtensionToIconPath(":/images/viewer_toolbar/openPrevious")));
|
||||
openComicOnTheLeftAction->setIcon(QIcon(":/images/viewer_toolbar/openPrevious.svg"));
|
||||
openComicOnTheLeftAction->setToolTip(tr("Open previous comic"));
|
||||
openComicOnTheLeftAction->setData(OPEN_PREVIOUS_COMIC_ACTION_Y);
|
||||
openComicOnTheLeftAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_PREVIOUS_COMIC_ACTION_Y));
|
||||
connect(openComicOnTheLeftAction, &QAction::triggered, this, &MainWindowViewer::openLeftComic);
|
||||
|
||||
openComicOnTheRightAction = new QAction(tr("Next Comic"), this);
|
||||
openComicOnTheRightAction->setIcon(QIcon(addExtensionToIconPath(":/images/viewer_toolbar/openNext")));
|
||||
openComicOnTheRightAction->setIcon(QIcon(":/images/viewer_toolbar/openNext.svg"));
|
||||
openComicOnTheRightAction->setToolTip(tr("Open next comic"));
|
||||
openComicOnTheRightAction->setData(OPEN_NEXT_COMIC_ACTION_Y);
|
||||
openComicOnTheRightAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_NEXT_COMIC_ACTION_Y));
|
||||
connect(openComicOnTheRightAction, &QAction::triggered, this, &MainWindowViewer::openRightComic);
|
||||
|
||||
goToPageOnTheLeftAction = new QAction(tr("&Previous"), this);
|
||||
goToPageOnTheLeftAction->setIcon(QIcon(addExtensionToIconPath(":/images/viewer_toolbar/previous")));
|
||||
goToPageOnTheLeftAction->setIcon(QIcon(":/images/viewer_toolbar/previous.svg"));
|
||||
goToPageOnTheLeftAction->setShortcutContext(Qt::WidgetShortcut);
|
||||
goToPageOnTheLeftAction->setToolTip(tr("Go to previous page"));
|
||||
goToPageOnTheLeftAction->setData(PREV_ACTION_Y);
|
||||
@ -266,7 +267,7 @@ void MainWindowViewer::createActions()
|
||||
connect(goToPageOnTheLeftAction, &QAction::triggered, viewer, &Viewer::left);
|
||||
|
||||
goToPageOnTheRightAction = new QAction(tr("&Next"), this);
|
||||
goToPageOnTheRightAction->setIcon(QIcon(addExtensionToIconPath(":/images/viewer_toolbar/next")));
|
||||
goToPageOnTheRightAction->setIcon(QIcon(":/images/viewer_toolbar/next.svg"));
|
||||
goToPageOnTheRightAction->setShortcutContext(Qt::WidgetShortcut);
|
||||
goToPageOnTheRightAction->setToolTip(tr("Go to next page"));
|
||||
goToPageOnTheRightAction->setData(NEXT_ACTION_Y);
|
||||
@ -274,7 +275,7 @@ void MainWindowViewer::createActions()
|
||||
connect(goToPageOnTheRightAction, &QAction::triggered, viewer, &Viewer::right);
|
||||
|
||||
adjustHeightAction = new QAction(tr("Fit Height"), this);
|
||||
adjustHeightAction->setIcon(QIcon(addExtensionToIconPath(":/images/viewer_toolbar/toHeight")));
|
||||
adjustHeightAction->setIcon(QIcon(":/images/viewer_toolbar/toHeight.svg"));
|
||||
// adjustWidth->setCheckable(true);
|
||||
adjustHeightAction->setToolTip(tr("Fit image to height"));
|
||||
// adjustWidth->setIcon(QIcon(":/images/fitWidth.svg"));
|
||||
@ -284,7 +285,7 @@ void MainWindowViewer::createActions()
|
||||
connect(adjustHeightAction, &QAction::triggered, this, &MainWindowViewer::fitToHeight);
|
||||
|
||||
adjustWidthAction = new QAction(tr("Fit Width"), this);
|
||||
adjustWidthAction->setIcon(QIcon(addExtensionToIconPath(":/images/viewer_toolbar/toWidth")));
|
||||
adjustWidthAction->setIcon(QIcon(":/images/viewer_toolbar/toWidth.svg"));
|
||||
// adjustWidth->setCheckable(true);
|
||||
adjustWidthAction->setToolTip(tr("Fit image to width"));
|
||||
// adjustWidth->setIcon(QIcon(":/images/fitWidth.svg"));
|
||||
@ -294,7 +295,7 @@ void MainWindowViewer::createActions()
|
||||
connect(adjustWidthAction, &QAction::triggered, this, &MainWindowViewer::fitToWidth);
|
||||
|
||||
adjustToFullSizeAction = new QAction(tr("Show full size"), this);
|
||||
adjustToFullSizeAction->setIcon(QIcon(addExtensionToIconPath(":/images/viewer_toolbar/full")));
|
||||
adjustToFullSizeAction->setIcon(QIcon(":/images/viewer_toolbar/full.svg"));
|
||||
adjustToFullSizeAction->setCheckable(false);
|
||||
adjustToFullSizeAction->setData(ADJUST_TO_FULL_SIZE_ACTION_Y);
|
||||
adjustToFullSizeAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ADJUST_TO_FULL_SIZE_ACTION_Y));
|
||||
@ -302,7 +303,7 @@ void MainWindowViewer::createActions()
|
||||
connect(adjustToFullSizeAction, &QAction::triggered, this, &MainWindowViewer::adjustToFullSizeSwitch);
|
||||
|
||||
fitToPageAction = new QAction(tr("Fit to page"), this);
|
||||
fitToPageAction->setIcon(QIcon(addExtensionToIconPath(":/images/viewer_toolbar/fitToPage")));
|
||||
fitToPageAction->setIcon(QIcon(":/images/viewer_toolbar/fitToPage.svg"));
|
||||
fitToPageAction->setData(FIT_TO_PAGE_ACTION_Y);
|
||||
fitToPageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(FIT_TO_PAGE_ACTION_Y));
|
||||
fitToPageAction->setCheckable(true);
|
||||
@ -338,7 +339,7 @@ void MainWindowViewer::createActions()
|
||||
connect(resetZoomAction, &QAction::triggered, this, &MainWindowViewer::resetZoomLevel);
|
||||
|
||||
showZoomSliderlAction = new QAction(tr("Show zoom slider"), this);
|
||||
showZoomSliderlAction->setIcon(QIcon(addExtensionToIconPath(":/images/viewer_toolbar/zoom")));
|
||||
showZoomSliderlAction->setIcon(QIcon(":/images/viewer_toolbar/zoom.svg"));
|
||||
|
||||
increasePageZoomAction = new QAction(tr("Zoom+"), this);
|
||||
increasePageZoomAction->setData(ZOOM_PLUS_ACTION_Y);
|
||||
@ -351,20 +352,20 @@ void MainWindowViewer::createActions()
|
||||
connect(decreasePageZoomAction, &QAction::triggered, this, &MainWindowViewer::decreasePageZoomLevel);
|
||||
|
||||
leftRotationAction = new QAction(tr("Rotate image to the left"), this);
|
||||
leftRotationAction->setIcon(QIcon(addExtensionToIconPath(":/images/viewer_toolbar/rotateL")));
|
||||
leftRotationAction->setIcon(QIcon(":/images/viewer_toolbar/rotateL.svg"));
|
||||
leftRotationAction->setData(LEFT_ROTATION_ACTION_Y);
|
||||
leftRotationAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(LEFT_ROTATION_ACTION_Y));
|
||||
connect(leftRotationAction, &QAction::triggered, viewer, &Viewer::rotateLeft);
|
||||
|
||||
rightRotationAction = new QAction(tr("Rotate image to the right"), this);
|
||||
rightRotationAction->setIcon(QIcon(addExtensionToIconPath(":/images/viewer_toolbar/rotateR")));
|
||||
rightRotationAction->setIcon(QIcon(":/images/viewer_toolbar/rotateR.svg"));
|
||||
rightRotationAction->setData(RIGHT_ROTATION_ACTION_Y);
|
||||
rightRotationAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(RIGHT_ROTATION_ACTION_Y));
|
||||
connect(rightRotationAction, &QAction::triggered, viewer, &Viewer::rotateRight);
|
||||
|
||||
doublePageAction = new QAction(tr("Double page mode"), this);
|
||||
doublePageAction->setToolTip(tr("Switch to double page mode"));
|
||||
doublePageAction->setIcon(QIcon(addExtensionToIconPath(":/images/viewer_toolbar/doublePage")));
|
||||
doublePageAction->setIcon(QIcon(":/images/viewer_toolbar/doublePage.svg"));
|
||||
doublePageAction->setCheckable(true);
|
||||
doublePageAction->setChecked(Configuration::getConfiguration().getDoublePage());
|
||||
doublePageAction->setData(DOUBLE_PAGE_ACTION_Y);
|
||||
@ -374,7 +375,7 @@ void MainWindowViewer::createActions()
|
||||
// inversed pictures mode
|
||||
doubleMangaPageAction = new QAction(tr("Double page manga mode"), this);
|
||||
doubleMangaPageAction->setToolTip(tr("Reverse reading order in double page mode"));
|
||||
doubleMangaPageAction->setIcon(QIcon(addExtensionToIconPath(":/images/viewer_toolbar/doubleMangaPage")));
|
||||
doubleMangaPageAction->setIcon(QIcon(":/images/viewer_toolbar/doubleMangaPage.svg"));
|
||||
doubleMangaPageAction->setCheckable(true);
|
||||
doubleMangaPageAction->setChecked(Configuration::getConfiguration().getDoubleMangaPage());
|
||||
doubleMangaPageAction->setData(DOUBLE_MANGA_PAGE_ACTION_Y);
|
||||
@ -383,7 +384,7 @@ void MainWindowViewer::createActions()
|
||||
connect(doubleMangaPageAction, &QAction::triggered, this, &MainWindowViewer::doubleMangaPageSwitch);
|
||||
|
||||
goToPageAction = new QAction(tr("Go To"), this);
|
||||
goToPageAction->setIcon(QIcon(addExtensionToIconPath(":/images/viewer_toolbar/goto")));
|
||||
goToPageAction->setIcon(QIcon(":/images/viewer_toolbar/goto.svg"));
|
||||
goToPageAction->setToolTip(tr("Go to page ..."));
|
||||
goToPageAction->setData(GO_TO_PAGE_ACTION_Y);
|
||||
goToPageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(GO_TO_PAGE_ACTION_Y));
|
||||
@ -393,20 +394,20 @@ void MainWindowViewer::createActions()
|
||||
optionsAction->setToolTip(tr("YACReader options"));
|
||||
optionsAction->setData(OPTIONS_ACTION_Y);
|
||||
optionsAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPTIONS_ACTION_Y));
|
||||
optionsAction->setIcon(QIcon(addExtensionToIconPath(":/images/viewer_toolbar/options")));
|
||||
optionsAction->setIcon(QIcon(":/images/viewer_toolbar/options.svg"));
|
||||
|
||||
connect(optionsAction, &QAction::triggered, optionsDialog, &OptionsDialog::show);
|
||||
|
||||
helpAboutAction = new QAction(tr("Help"), this);
|
||||
helpAboutAction->setToolTip(tr("Help, About YACReader"));
|
||||
helpAboutAction->setIcon(QIcon(addExtensionToIconPath(":/images/viewer_toolbar/help")));
|
||||
helpAboutAction->setIcon(QIcon(":/images/viewer_toolbar/help.svg"));
|
||||
helpAboutAction->setData(HELP_ABOUT_ACTION_Y);
|
||||
helpAboutAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(HELP_ABOUT_ACTION_Y));
|
||||
connect(helpAboutAction, &QAction::triggered, had, &QWidget::show);
|
||||
|
||||
showMagnifyingGlassAction = new QAction(tr("Magnifying glass"), this);
|
||||
showMagnifyingGlassAction->setToolTip(tr("Switch Magnifying glass"));
|
||||
showMagnifyingGlassAction->setIcon(QIcon(addExtensionToIconPath(":/images/viewer_toolbar/magnifyingGlass")));
|
||||
showMagnifyingGlassAction->setIcon(QIcon(":/images/viewer_toolbar/magnifyingGlass.svg"));
|
||||
showMagnifyingGlassAction->setCheckable(true);
|
||||
showMagnifyingGlassAction->setData(SHOW_MAGNIFYING_GLASS_ACTION_Y);
|
||||
showMagnifyingGlassAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_MAGNIFYING_GLASS_ACTION_Y));
|
||||
@ -414,7 +415,7 @@ void MainWindowViewer::createActions()
|
||||
|
||||
setBookmarkAction = new QAction(tr("Set bookmark"), this);
|
||||
setBookmarkAction->setToolTip(tr("Set a bookmark on the current page"));
|
||||
setBookmarkAction->setIcon(QIcon(addExtensionToIconPath(":/images/viewer_toolbar/bookmark")));
|
||||
setBookmarkAction->setIcon(QIcon(":/images/viewer_toolbar/bookmark.svg"));
|
||||
setBookmarkAction->setCheckable(true);
|
||||
setBookmarkAction->setData(SET_BOOKMARK_ACTION_Y);
|
||||
setBookmarkAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_BOOKMARK_ACTION_Y));
|
||||
@ -424,38 +425,38 @@ void MainWindowViewer::createActions()
|
||||
|
||||
showBookmarksAction = new QAction(tr("Show bookmarks"), this);
|
||||
showBookmarksAction->setToolTip(tr("Show the bookmarks of the current comic"));
|
||||
showBookmarksAction->setIcon(QIcon(addExtensionToIconPath(":/images/viewer_toolbar/showBookmarks")));
|
||||
showBookmarksAction->setIcon(QIcon(":/images/viewer_toolbar/showBookmarks.svg"));
|
||||
showBookmarksAction->setData(SHOW_BOOKMARKS_ACTION_Y);
|
||||
showBookmarksAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_BOOKMARKS_ACTION_Y));
|
||||
connect(showBookmarksAction, &QAction::triggered, viewer->getBookmarksDialog(), &QWidget::show);
|
||||
|
||||
showShorcutsAction = new QAction(tr("Show keyboard shortcuts"), this);
|
||||
showShorcutsAction->setIcon(QIcon(addExtensionToIconPath(":/images/viewer_toolbar/shortcuts")));
|
||||
showShorcutsAction->setIcon(QIcon(":/images/viewer_toolbar/shortcuts.svg"));
|
||||
showShorcutsAction->setData(SHOW_SHORCUTS_ACTION_Y);
|
||||
showShorcutsAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_SHORCUTS_ACTION_Y));
|
||||
connect(showShorcutsAction, &QAction::triggered, editShortcutsDialog, &QWidget::show);
|
||||
|
||||
showInfoAction = new QAction(tr("Show Info"), this);
|
||||
showInfoAction->setIcon(QIcon(addExtensionToIconPath(":/images/viewer_toolbar/info")));
|
||||
showInfoAction->setIcon(QIcon(":/images/viewer_toolbar/info.svg"));
|
||||
showInfoAction->setData(SHOW_INFO_ACTION_Y);
|
||||
showInfoAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_INFO_ACTION_Y));
|
||||
connect(showInfoAction, &QAction::triggered, viewer, &Viewer::informationSwitch);
|
||||
|
||||
closeAction = new QAction(tr("Close"), this);
|
||||
closeAction->setIcon(QIcon(addExtensionToIconPath(":/images/viewer_toolbar/close")));
|
||||
closeAction->setIcon(QIcon(":/images/viewer_toolbar/close.svg"));
|
||||
closeAction->setData(CLOSE_ACTION_Y);
|
||||
closeAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(CLOSE_ACTION_Y));
|
||||
connect(closeAction, &QAction::triggered, this, &QWidget::close);
|
||||
|
||||
showDictionaryAction = new QAction(tr("Show Dictionary"), this);
|
||||
showDictionaryAction->setIcon(QIcon(addExtensionToIconPath(":/images/viewer_toolbar/translator")));
|
||||
showDictionaryAction->setIcon(QIcon(":/images/viewer_toolbar/translator.svg"));
|
||||
// showDictionaryAction->setCheckable(true);
|
||||
showDictionaryAction->setData(SHOW_DICTIONARY_ACTION_Y);
|
||||
showDictionaryAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_DICTIONARY_ACTION_Y));
|
||||
connect(showDictionaryAction, &QAction::triggered, viewer, &Viewer::translatorSwitch);
|
||||
|
||||
showFlowAction = new QAction(tr("Show go to flow"), this);
|
||||
showFlowAction->setIcon(QIcon(addExtensionToIconPath(":/images/viewer_toolbar/flow")));
|
||||
showFlowAction->setIcon(QIcon(":/images/viewer_toolbar/flow.svg"));
|
||||
showFlowAction->setData(SHOW_FLOW_ACTION_Y);
|
||||
showFlowAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_FLOW_ACTION_Y));
|
||||
connect(showFlowAction, &QAction::triggered, viewer, &Viewer::goToFlowSwitch);
|
||||
@ -1159,10 +1160,22 @@ void MainWindowViewer::processReset()
|
||||
|
||||
void MainWindowViewer::setUpShortcutsManagement()
|
||||
{
|
||||
// Set up icon mapping for theme changes
|
||||
QMap<QString, std::function<QIcon(const Theme &)>> iconMapping;
|
||||
iconMapping[tr("Comics")] = [](const Theme &t) { return t.shortcutsIcons.comicsIcon; };
|
||||
iconMapping[tr("General")] = [](const Theme &t) { return t.shortcutsIcons.generalIcon; };
|
||||
iconMapping[tr("Magnifiying glass")] = [](const Theme &t) { return t.shortcutsIcons.magnifyingGlassIcon; };
|
||||
iconMapping[tr("Page adjustement")] = [](const Theme &t) { return t.shortcutsIcons.pageIcon; };
|
||||
iconMapping[tr("Reading")] = [](const Theme &t) { return t.shortcutsIcons.readingIcon; };
|
||||
editShortcutsDialog->setGroupIconMapping(iconMapping);
|
||||
|
||||
QList<QAction *> allActions;
|
||||
QList<QAction *> tmpList;
|
||||
|
||||
editShortcutsDialog->addActionsGroup(tr("Comics"), QIcon(":/images/shortcuts/shortcuts_group_comics.svg"),
|
||||
// Get current theme for initial icons
|
||||
const auto &theme = ThemeManager::instance().getCurrentTheme();
|
||||
|
||||
editShortcutsDialog->addActionsGroup(tr("Comics"), theme.shortcutsIcons.comicsIcon,
|
||||
tmpList = { openAction,
|
||||
openLatestComicAction,
|
||||
openFolderAction,
|
||||
@ -1178,7 +1191,7 @@ void MainWindowViewer::setUpShortcutsManagement()
|
||||
auto *const toggleToolbarsAction = addActionWithShortcut(tr("Hide/show toolbar"), TOGGLE_TOOL_BARS_ACTION_Y);
|
||||
connect(toggleToolbarsAction, &QAction::triggered, this, &MainWindowViewer::toggleToolBars);
|
||||
|
||||
editShortcutsDialog->addActionsGroup(tr("General"), QIcon(":/images/shortcuts/shortcuts_group_general.svg"),
|
||||
editShortcutsDialog->addActionsGroup(tr("General"), theme.shortcutsIcons.generalIcon,
|
||||
tmpList = QList<QAction *>()
|
||||
<< optionsAction
|
||||
<< helpAboutAction
|
||||
@ -1216,7 +1229,7 @@ void MainWindowViewer::setUpShortcutsManagement()
|
||||
zoomInMglassAction, zoomOutMglassAction,
|
||||
resetMglassAction };
|
||||
|
||||
editShortcutsDialog->addActionsGroup(tr("Magnifiying glass"), QIcon(":/images/shortcuts/shortcuts_group_mglass.svg"),
|
||||
editShortcutsDialog->addActionsGroup(tr("Magnifiying glass"), theme.shortcutsIcons.magnifyingGlassIcon,
|
||||
tmpList = QList<QAction *>()
|
||||
<< showMagnifyingGlassAction
|
||||
<< mglassActions);
|
||||
@ -1227,7 +1240,7 @@ void MainWindowViewer::setUpShortcutsManagement()
|
||||
CHANGE_FIT_ACTION_Y);
|
||||
connect(toggleFitToScreenAction, &QAction::triggered, this, &MainWindowViewer::toggleWidthHeight);
|
||||
|
||||
editShortcutsDialog->addActionsGroup(tr("Page adjustement"), QIcon(":/images/shortcuts/shortcuts_group_page.svg"),
|
||||
editShortcutsDialog->addActionsGroup(tr("Page adjustement"), theme.shortcutsIcons.pageIcon,
|
||||
tmpList = QList<QAction *>()
|
||||
<< adjustHeightAction
|
||||
<< adjustWidthAction
|
||||
@ -1304,7 +1317,7 @@ void MainWindowViewer::setUpShortcutsManagement()
|
||||
offsetDoublePageToTheLeft,
|
||||
offsetDoublePageToTheRight };
|
||||
|
||||
editShortcutsDialog->addActionsGroup(tr("Reading"), QIcon(":/images/shortcuts/shortcuts_group_reading.svg"),
|
||||
editShortcutsDialog->addActionsGroup(tr("Reading"), theme.shortcutsIcons.readingIcon,
|
||||
tmpList = QList<QAction *>()
|
||||
<< goToPageOnTheRightAction
|
||||
<< goToPageOnTheLeftAction
|
||||
|
||||
@ -174,8 +174,6 @@ private:
|
||||
void setMglassActionsEnabled(bool enabled);
|
||||
void setLoadedComicActionsEnabled(bool enabled);
|
||||
|
||||
void applyTheme(const Theme &theme) override;
|
||||
|
||||
//! Manejadores de evento:
|
||||
// void resizeEvent(QResizeEvent * event);
|
||||
void mouseDoubleClickEvent(QMouseEvent *event) override;
|
||||
@ -201,6 +199,7 @@ protected:
|
||||
void sendComic();
|
||||
void updatePrevNextActions(bool thereIsPrevious, bool thereIsNext);
|
||||
void afterLaunchTasks();
|
||||
void applyTheme(const Theme &theme) override;
|
||||
|
||||
public:
|
||||
MainWindowViewer();
|
||||
|
||||
@ -33,7 +33,7 @@ OptionsDialog::OptionsDialog(QWidget *parent)
|
||||
|
||||
auto path = new QHBoxLayout();
|
||||
path->addWidget(pathEdit = new QLineEdit());
|
||||
path->addWidget(pathFindButton = new QPushButton(QIcon(":/images/find_folder.png"), ""));
|
||||
path->addWidget(pathFindButton = new QPushButton(""));
|
||||
pathBox->setLayout(path);
|
||||
|
||||
QGroupBox *displayBox = new QGroupBox(tr("Display"));
|
||||
@ -223,6 +223,13 @@ OptionsDialog::OptionsDialog(QWidget *parent)
|
||||
setWindowTitle(tr("Options"));
|
||||
|
||||
this->layout()->setSizeConstraint(QLayout::SetFixedSize);
|
||||
|
||||
initTheme(this);
|
||||
}
|
||||
|
||||
void OptionsDialog::applyTheme(const Theme &theme)
|
||||
{
|
||||
pathFindButton->setIcon(theme.dialogIcons.findFolderIcon);
|
||||
}
|
||||
|
||||
void OptionsDialog::findFolder()
|
||||
@ -247,7 +254,7 @@ void OptionsDialog::saveOptions()
|
||||
|
||||
Configuration::getConfiguration().setShowTimeInInformation(showTimeInInformationLabel->isChecked());
|
||||
|
||||
if (currentColor != ThemeManager::instance().getCurrentTheme().viewer.defaultBackgroundColor) {
|
||||
if (currentColor != theme.viewer.defaultBackgroundColor) {
|
||||
settings->setValue(BACKGROUND_COLOR, currentColor);
|
||||
} else {
|
||||
settings->remove(BACKGROUND_COLOR);
|
||||
@ -285,7 +292,7 @@ void OptionsDialog::restoreOptions(QSettings *settings)
|
||||
|
||||
showTimeInInformationLabel->setChecked(Configuration::getConfiguration().getShowTimeInInformation());
|
||||
|
||||
updateColor(settings->value(BACKGROUND_COLOR, ThemeManager::instance().getCurrentTheme().viewer.defaultBackgroundColor).value<QColor>());
|
||||
updateColor(settings->value(BACKGROUND_COLOR, theme.viewer.defaultBackgroundColor).value<QColor>());
|
||||
// fitToWidthRatioS->setSliderPosition(settings->value(FIT_TO_WIDTH_RATIO).toFloat()*100);
|
||||
|
||||
quickNavi->setChecked(settings->value(QUICK_NAVI_MODE).toBool());
|
||||
@ -402,5 +409,5 @@ void OptionsDialog::clearBackgroundColor()
|
||||
{
|
||||
settings->remove(BACKGROUND_COLOR);
|
||||
|
||||
updateColor(ThemeManager::instance().getCurrentTheme().viewer.defaultBackgroundColor);
|
||||
updateColor(theme.viewer.defaultBackgroundColor);
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#define __OPTIONS_DIALOG_H
|
||||
|
||||
#include "yacreader_options_dialog.h"
|
||||
#include "themable.h"
|
||||
|
||||
class QDialog;
|
||||
class QLabel;
|
||||
@ -12,12 +13,15 @@ class QPushButton;
|
||||
class QRadioButton;
|
||||
class YACReaderSpinSliderWidget;
|
||||
|
||||
class OptionsDialog : public YACReaderOptionsDialog
|
||||
class OptionsDialog : public YACReaderOptionsDialog, protected Themable
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
OptionsDialog(QWidget *parent = nullptr);
|
||||
|
||||
protected:
|
||||
void applyTheme(const Theme &theme) override;
|
||||
|
||||
private:
|
||||
// QLabel * pathLabel;
|
||||
QLineEdit *pathEdit;
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
#include <QtGui>
|
||||
|
||||
#include "help_about_dialog_theme.h"
|
||||
#include "whats_new_dialog_theme.h"
|
||||
|
||||
struct ToolbarThemeTemplates {
|
||||
QString toolbarQSS = "QToolBar { border: none; background: %1; }\n"
|
||||
@ -126,11 +127,26 @@ struct GoToFlowWidgetTheme {
|
||||
QIcon goToIcon;
|
||||
};
|
||||
|
||||
struct ShortcutsIconsTheme {
|
||||
QIcon comicsIcon;
|
||||
QIcon generalIcon;
|
||||
QIcon magnifyingGlassIcon;
|
||||
QIcon pageIcon;
|
||||
QIcon readingIcon;
|
||||
};
|
||||
|
||||
struct DialogIconsTheme {
|
||||
QIcon findFolderIcon;
|
||||
};
|
||||
|
||||
struct Theme {
|
||||
ToolbarTheme toolbar;
|
||||
ViewerTheme viewer;
|
||||
GoToFlowWidgetTheme goToFlowWidget;
|
||||
HelpAboutDialogTheme helpAboutDialog;
|
||||
WhatsNewDialogTheme whatsNewDialog;
|
||||
ShortcutsIconsTheme shortcutsIcons;
|
||||
DialogIconsTheme dialogIcons;
|
||||
};
|
||||
|
||||
#endif // THEME_H
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
#include "theme_factory.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#include "icon_utils.h"
|
||||
|
||||
struct ToolbarParams {
|
||||
@ -39,6 +41,20 @@ struct GoToFlowWidgetParams {
|
||||
QColor iconColor;
|
||||
};
|
||||
|
||||
struct WhatsNewDialogParams {
|
||||
QColor backgroundColor;
|
||||
QColor headerTextColor;
|
||||
QColor versionTextColor;
|
||||
QColor contentTextColor;
|
||||
QColor linkColor;
|
||||
QColor closeButtonColor;
|
||||
QColor headerDecorationColor;
|
||||
};
|
||||
|
||||
struct ShortcutsIconsParams {
|
||||
QColor iconColor; // Main icon color (replaces #f0f)
|
||||
};
|
||||
|
||||
struct ThemeParams {
|
||||
QString themeName;
|
||||
|
||||
@ -46,6 +62,8 @@ struct ThemeParams {
|
||||
ViewerParams viewerParams;
|
||||
GoToFlowWidgetParams goToFlowWidgetParams;
|
||||
HelpAboutDialogTheme helpAboutDialogParams;
|
||||
WhatsNewDialogParams whatsNewDialogParams;
|
||||
ShortcutsIconsParams shortcutsIconsParams;
|
||||
};
|
||||
|
||||
void setToolbarIconPair(QIcon &icon,
|
||||
@ -157,6 +175,38 @@ Theme makeTheme(const ThemeParams ¶ms)
|
||||
theme.helpAboutDialog = params.helpAboutDialogParams;
|
||||
// end HelpAboutDialog
|
||||
|
||||
// WhatsNewDialog
|
||||
const auto &wn = params.whatsNewDialogParams;
|
||||
theme.whatsNewDialog.backgroundColor = wn.backgroundColor;
|
||||
theme.whatsNewDialog.headerTextColor = wn.headerTextColor;
|
||||
theme.whatsNewDialog.versionTextColor = wn.versionTextColor;
|
||||
theme.whatsNewDialog.contentTextColor = wn.contentTextColor;
|
||||
theme.whatsNewDialog.linkColor = wn.linkColor;
|
||||
theme.whatsNewDialog.closeButtonIcon = QPixmap(recoloredSvgToThemeFile(":/images/custom_dialog/custom_close_button.svg", wn.closeButtonColor, params.themeName));
|
||||
theme.whatsNewDialog.headerDecoration = QPixmap(recoloredSvgToThemeFile(":/images/whats_new/whatsnew_header.svg", wn.headerDecorationColor, params.themeName));
|
||||
// end WhatsNewDialog
|
||||
|
||||
// ShortcutsIcons
|
||||
const auto &sci = params.shortcutsIconsParams;
|
||||
auto makeShortcutsIcon = [&](const QString &basePath) {
|
||||
const QString path = recoloredSvgToThemeFile(basePath, sci.iconColor, params.themeName);
|
||||
return QIcon(path);
|
||||
};
|
||||
|
||||
theme.shortcutsIcons.comicsIcon = makeShortcutsIcon(":/images/shortcuts/shortcuts_group_comics.svg");
|
||||
theme.shortcutsIcons.generalIcon = makeShortcutsIcon(":/images/shortcuts/shortcuts_group_general.svg");
|
||||
theme.shortcutsIcons.magnifyingGlassIcon = makeShortcutsIcon(":/images/shortcuts/shortcuts_group_mglass.svg");
|
||||
theme.shortcutsIcons.pageIcon = makeShortcutsIcon(":/images/shortcuts/shortcuts_group_page.svg");
|
||||
theme.shortcutsIcons.readingIcon = makeShortcutsIcon(":/images/shortcuts/shortcuts_group_reading.svg");
|
||||
// end ShortcutsIcons
|
||||
|
||||
// FindFolder icon (used in OptionsDialog)
|
||||
{
|
||||
const QString path = recoloredSvgToThemeFile(":/images/find_folder.svg", params.toolbarParams.iconColor, params.themeName);
|
||||
const qreal dpr = qApp->devicePixelRatio();
|
||||
theme.dialogIcons.findFolderIcon = QIcon(renderSvgToPixmap(path, 13, 13, dpr));
|
||||
}
|
||||
|
||||
return theme;
|
||||
}
|
||||
|
||||
@ -220,6 +270,19 @@ ThemeParams classicThemeParams()
|
||||
params.helpAboutDialogParams.headingColor = QColor(0x302f2d);
|
||||
params.helpAboutDialogParams.linkColor = QColor(0xC19441);
|
||||
|
||||
params.whatsNewDialogParams.backgroundColor = QColor(0xFFFFFF);
|
||||
params.whatsNewDialogParams.headerTextColor = QColor(0x0A0A0A);
|
||||
params.whatsNewDialogParams.versionTextColor = QColor(0x858585);
|
||||
params.whatsNewDialogParams.contentTextColor = QColor(0x0A0A0A);
|
||||
params.whatsNewDialogParams.linkColor = QColor(0xE8B800);
|
||||
params.whatsNewDialogParams.closeButtonColor = QColor(0x444444);
|
||||
params.whatsNewDialogParams.headerDecorationColor = QColor(0xE8B800);
|
||||
|
||||
// ShortcutsIcons
|
||||
ShortcutsIconsParams sci;
|
||||
sci.iconColor = QColor(0x404040); // Dark icons for light background
|
||||
params.shortcutsIconsParams = sci;
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
@ -267,6 +330,19 @@ ThemeParams lightThemeParams()
|
||||
params.helpAboutDialogParams.headingColor = QColor(0x302f2d);
|
||||
params.helpAboutDialogParams.linkColor = QColor(0xC19441);
|
||||
|
||||
params.whatsNewDialogParams.backgroundColor = QColor(0xFFFFFF);
|
||||
params.whatsNewDialogParams.headerTextColor = QColor(0x0A0A0A);
|
||||
params.whatsNewDialogParams.versionTextColor = QColor(0x858585);
|
||||
params.whatsNewDialogParams.contentTextColor = QColor(0x0A0A0A);
|
||||
params.whatsNewDialogParams.linkColor = QColor(0xE8B800);
|
||||
params.whatsNewDialogParams.closeButtonColor = QColor(0x444444);
|
||||
params.whatsNewDialogParams.headerDecorationColor = QColor(0xE8B800);
|
||||
|
||||
// ShortcutsIcons
|
||||
ShortcutsIconsParams sci;
|
||||
sci.iconColor = QColor(0x606060); // Dark icons for light background
|
||||
params.shortcutsIconsParams = sci;
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
@ -314,6 +390,19 @@ ThemeParams darkThemeParams()
|
||||
params.helpAboutDialogParams.headingColor = QColor(0xE0E0E0);
|
||||
params.helpAboutDialogParams.linkColor = QColor(0xD4A84B);
|
||||
|
||||
params.whatsNewDialogParams.backgroundColor = QColor(0x2A2A2A);
|
||||
params.whatsNewDialogParams.headerTextColor = QColor(0xE0E0E0);
|
||||
params.whatsNewDialogParams.versionTextColor = QColor(0x858585);
|
||||
params.whatsNewDialogParams.contentTextColor = QColor(0xE0E0E0);
|
||||
params.whatsNewDialogParams.linkColor = QColor(0xE8B800);
|
||||
params.whatsNewDialogParams.closeButtonColor = QColor(0xDDDDDD);
|
||||
params.whatsNewDialogParams.headerDecorationColor = QColor(0xE8B800);
|
||||
|
||||
// ShortcutsIcons
|
||||
ShortcutsIconsParams sci;
|
||||
sci.iconColor = QColor(0xD0D0D0); // Light icons for dark background
|
||||
params.shortcutsIconsParams = sci;
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
<qresource>
|
||||
<file>../images/icon-new.svg</file>
|
||||
<file>../images/goto.png</file>
|
||||
<file>../images/find_folder.png</file>
|
||||
<file>../images/find_folder.svg</file>
|
||||
<file>../images/flow1.png</file>
|
||||
<file>../images/flow2.png</file>
|
||||
<file>../images/flow3.png</file>
|
||||
@ -19,8 +19,8 @@
|
||||
<file>../images/dropDownArrow.png</file>
|
||||
<file>../images/translatorSearch.png</file>
|
||||
<file>../images/speaker.png</file>
|
||||
<file>../images/clear_shortcut.svg</file>
|
||||
<file>../images/accept_shortcut.svg</file>
|
||||
<file>../images/shortcuts/clear_shortcut.svg</file>
|
||||
<file>../images/shortcuts/accept_shortcut.svg</file>
|
||||
<file>../images/shortcuts/shortcuts_group_comics.svg</file>
|
||||
<file>../images/shortcuts/shortcuts_group_folders.svg</file>
|
||||
<file>../images/shortcuts/shortcuts_group_general.svg</file>
|
||||
|
||||
Reference in New Issue
Block a user