From 8f1c63fcf02de0bc7df957bcb76e87460d502e10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sat, 22 Oct 2022 11:40:16 +0200 Subject: [PATCH] Move functions --- YACReader/main_window_viewer.cpp | 31 -------------------------- common/yacreader_global_gui.cpp | 38 ++++++++++++++++++++++++++++++++ common/yacreader_global_gui.h | 3 +++ 3 files changed, 41 insertions(+), 31 deletions(-) diff --git a/YACReader/main_window_viewer.cpp b/YACReader/main_window_viewer.cpp index 329aafb9..46008b6b 100644 --- a/YACReader/main_window_viewer.cpp +++ b/YACReader/main_window_viewer.cpp @@ -36,37 +36,6 @@ #include #include -// TODO there are no SVG assets in macos yet -// we need two sets of icons, one for the toolbar and one for the context menu because of this bug (QTBUG-96553): https://bugreports.qt.io/browse/QTBUG-96553 - -QString addExtensionToIconPath(const QString &path) -{ - - return path + ".svg"; -} - -QString addExtensionToIconPathInToolbar(const QString &path) -{ - return path + "_18x18.svg"; -} - -QAction *actionWithCustomIcon(const QIcon &icon, QAction *action) -{ - auto a = new QAction(icon, action->text()); - - a->setEnabled(action->isEnabled()); - a->setCheckable(action->isCheckable()); - - a->setChecked(action->isChecked()); - - QObject::connect(a, &QAction::triggered, action, &QAction::triggered); - QObject::connect(action, &QAction::enabledChanged, a, &QAction::setEnabled); - QObject::connect(a, &QAction::toggled, action, &QAction::setChecked); - QObject::connect(action, &QAction::toggled, a, &QAction::setChecked); - - return a; -} - MainWindowViewer::MainWindowViewer() : QMainWindow(), fullscreen(false), toolbars(true), currentDirectory("."), currentDirectoryImgDest("."), isClient(false) { diff --git a/common/yacreader_global_gui.cpp b/common/yacreader_global_gui.cpp index 5865218a..3eed2c5b 100644 --- a/common/yacreader_global_gui.cpp +++ b/common/yacreader_global_gui.cpp @@ -49,3 +49,41 @@ QList YACReader::mimeDataToComicsIds(const QMimeData *data) in >> comicIds; // deserialize the list of indentifiers return comicIds; } + +// TODO some SVG assets are missing in macos (WIP) +// we need two sets of icons, one for the toolbar and one for the context menu because of this bug (QTBUG-96553): https://bugreports.qt.io/browse/QTBUG-96553 + +QString YACReader::addExtensionToIconPath(const QString &path) +{ +#ifdef YACREADER_LIBRARY +#ifdef Q_OS_MAC + return path + ".png"; +#else + return path + ".svg"; +#endif +#else + return path + ".svg"; +#endif +} + +QString YACReader::addExtensionToIconPathInToolbar(const QString &path) +{ + return path + "_18x18.svg"; +} + +QAction *YACReader::actionWithCustomIcon(const QIcon &icon, QAction *action) +{ + auto a = new QAction(icon, action->text()); + + a->setEnabled(action->isEnabled()); + a->setCheckable(action->isCheckable()); + + a->setChecked(action->isChecked()); + + QObject::connect(a, &QAction::triggered, action, &QAction::triggered); + QObject::connect(action, &QAction::enabledChanged, a, &QAction::setEnabled); + QObject::connect(a, &QAction::toggled, action, &QAction::setChecked); + QObject::connect(action, &QAction::toggled, a, &QAction::setChecked); + + return a; +} diff --git a/common/yacreader_global_gui.h b/common/yacreader_global_gui.h index 330ff3ac..a15fa71a 100644 --- a/common/yacreader_global_gui.h +++ b/common/yacreader_global_gui.h @@ -110,6 +110,9 @@ QAction *createSeparator(); QIcon noHighlightedIcon(const QString &path); void colorize(QImage &img, QColor &col); QList mimeDataToComicsIds(const QMimeData *data); +QString addExtensionToIconPath(const QString &path); +QString addExtensionToIconPathInToolbar(const QString &path); +QAction *actionWithCustomIcon(const QIcon &icon, QAction *action); } #endif