From e587f59ddbdf6a12aa8f82a64ebef537a58f4ad7 Mon Sep 17 00:00:00 2001 From: Felix Kauselmann Date: Sat, 26 May 2018 16:20:24 +0200 Subject: [PATCH 01/19] Add support for minimize and start to tray. --- YACReaderLibrary/YACReaderLibrary.pro | 5 +++ YACReaderLibrary/library_window.cpp | 53 ++++++++++++++++----------- YACReaderLibrary/library_window.h | 5 +-- YACReaderLibrary/main.cpp | 42 ++++++++++++--------- YACReaderLibrary/options_dialog.cpp | 8 ++++ YACReaderLibrary/options_dialog.h | 31 +++++++--------- YACReaderLibrary/trayhandler.h | 7 ++++ YACReaderLibrary/trayhandler.mm | 11 ++++++ common/yacreader_global_gui.h | 2 + 9 files changed, 103 insertions(+), 61 deletions(-) create mode 100644 YACReaderLibrary/trayhandler.h create mode 100644 YACReaderLibrary/trayhandler.mm diff --git a/YACReaderLibrary/YACReaderLibrary.pro b/YACReaderLibrary/YACReaderLibrary.pro index f8460faf..c1365c47 100644 --- a/YACReaderLibrary/YACReaderLibrary.pro +++ b/YACReaderLibrary/YACReaderLibrary.pro @@ -221,6 +221,11 @@ SOURCES += comic_flow.cpp \ SOURCES += ../common/gl/yacreader_flow_gl.cpp } +macx { + HEADERS += trayhandler.h + OBJECTIVE_SOURCES += trayhandler.mm +} + include(./server/server.pri) include(../custom_widgets/custom_widgets_yacreaderlibrary.pri) diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index eae3f19e..b19d1832 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -86,6 +86,9 @@ #ifdef Q_OS_WIN #include #endif +#ifdef Q_OS_MACOS + #include "trayhandler.h" +#endif LibraryWindow::LibraryWindow() : QMainWindow(), fullscreen(false), previousFilter(""), fetching(false), status(LibraryWindow::Normal), removeError(false) @@ -139,35 +142,41 @@ void LibraryWindow::setupUI() } /* //disabled until icons are ready and macos native code is done trayIcon.setIcon(QApplication::windowIcon()); - trayIcon.show(); - connect(&trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), - this, SLOT(trayActivation(QSystemTrayIcon::ActivationReason))); } -} + else + { + // TODO: Luis: This is a placeholder. Add MacOS, Windows and maybe a fallback + // for other systems here. + trayIcon.setIcon(QIcon(":/images/iconLibrary.png")); + } -void LibraryWindow::trayActivation(QSystemTrayIcon::ActivationReason reason) -{ - if (reason == QSystemTrayIcon::Trigger) - { - setWindowState((windowState() & ~Qt::WindowMinimized)); - show(); - activateWindow(); - raise(); - } + connect(&trayIcon, &QSystemTrayIcon::activated, + [=] (QSystemTrayIcon::ActivationReason reason) { + if (reason == QSystemTrayIcon::Trigger) + { + #ifdef Q_OS_MACOS + OSXShowDockIcon(); + #endif + setWindowState((windowState() & ~Qt::WindowMinimized) | Qt::WindowActive); + show(); + } + }); + trayIcon.setVisible(settings->value(MINIMIZE_TO_TRAY, true).toBool()); } - void LibraryWindow::changeEvent(QEvent *event) { - if (event->type() == QEvent::WindowStateChange && isMinimized()) - { - hide(); - } - else - { + if (event->type() == QEvent::WindowStateChange && isMinimized() && + trayIcon.isVisible()) + { + #ifdef Q_OS_MACOS + OSXHideDockIcon(); + #endif + hide(); + return; + } QMainWindow::changeEvent(event); - } -}*/ +} void LibraryWindow::doLayout() { diff --git a/YACReaderLibrary/library_window.h b/YACReaderLibrary/library_window.h index 1f2bc896..c934946e 100644 --- a/YACReaderLibrary/library_window.h +++ b/YACReaderLibrary/library_window.h @@ -385,7 +385,7 @@ public slots: void checkMaxNumLibraries(); void showErrorUpgradingLibrary(const QString &path); - //void changeEvent(QEvent *event); + void changeEvent(QEvent *event); private: //fullscreen mode in Windows for preventing this bug: QTBUG-41309 https://bugreports.qt.io/browse/QTBUG-41309 @@ -394,9 +394,6 @@ private: QSize previousSize; std::future upgradeLibraryFuture; QSystemTrayIcon trayIcon; - -private slots: - //void trayActivation(QSystemTrayIcon::ActivationReason reason); }; #endif diff --git a/YACReaderLibrary/main.cpp b/YACReaderLibrary/main.cpp index 8501179d..c65fc245 100644 --- a/YACReaderLibrary/main.cpp +++ b/YACReaderLibrary/main.cpp @@ -20,6 +20,9 @@ #include "yacreader_libraries.h" #include "exit_check.h" #include "opengl_checker.h" +#ifdef Q_OS_MACOS + #include "trayhandler.h" +#endif #include "QsLog.h" #include "QsLogDest.h" @@ -127,9 +130,12 @@ int main(int argc, char **argv) app.setApplicationVersion(VERSION); app.setAttribute(Qt::AA_UseHighDpiPixmaps); - if (QIcon::hasThemeIcon("YACReaderLibrary")) { - app.setWindowIcon(QIcon::fromTheme("YACReaderLibrary")); - } + // Set window icon according to Freedesktop icon specification + // This is mostly relevant for Linux and other Unix systems + if (QIcon::hasThemeIcon("YACReaderLibrary")) { + app.setWindowIcon(QIcon::fromTheme("YACReaderLibrary")); + } + // TODO: We might want to add a fallback icon here. QString destLog = YACReader::getSettingsPath() + "/yacreaderlibrary.log"; QDir().mkpath(YACReader::getSettingsPath()); @@ -210,18 +216,18 @@ int main(int argc, char **argv) } #ifdef SERVER_RELEASE - QSettings *settings = new QSettings(YACReader::getSettingsPath() + "/YACReaderLibrary.ini", QSettings::IniFormat); //TODO unificar la creaci�n del fichero de config con el servidor - settings->beginGroup("libraryConfig"); + QSettings * settings = new QSettings(YACReader::getSettingsPath()+"/YACReaderLibrary.ini",QSettings::IniFormat); //TODO unificar la creaci�n del fichero de config con el servidor + settings->beginGroup("libraryConfig"); - s = new Startup(); + s = new Startup(); if (settings->value(SERVER_ON, true).toBool()) { s->start(); } #endif - QLOG_INFO() << "YACReaderLibrary attempting to start"; + QLOG_INFO() << "YACReaderLibrary attempting to start"; - logSystemAndConfig(); + logSystemAndConfig(); if (YACReaderLocalServer::isRunning()) //s�lo se permite una instancia de YACReaderLibrary { @@ -235,24 +241,24 @@ int main(int argc, char **argv) auto mw = new LibraryWindow(); - mw->connect(localServer, SIGNAL(comicUpdated(quint64, const ComicDB &)), mw, SLOT(updateComicsView(quint64, const ComicDB &)), Qt::QueuedConnection); + mw->connect(localServer,SIGNAL(comicUpdated(quint64, const ComicDB &)),mw,SLOT(updateComicsView(quint64, const ComicDB &)), Qt::QueuedConnection); - //connections to localServer + //connections to localServer - mw->show(); + mw->show(); - int ret = app.exec(); + int ret = app.exec(); QLOG_INFO() << "YACReaderLibrary closed with exit code :" << ret; YACReader::exitCheck(ret); - //shutdown - s->stop(); - delete s; - localServer->close(); - delete localServer; - delete mw; + //shutdown + s->stop(); + delete s; + localServer->close(); + delete localServer; + delete mw; QsLogging::Logger::destroyInstance(); diff --git a/YACReaderLibrary/options_dialog.cpp b/YACReaderLibrary/options_dialog.cpp index 5667ff73..cfe04926 100644 --- a/YACReaderLibrary/options_dialog.cpp +++ b/YACReaderLibrary/options_dialog.cpp @@ -43,6 +43,9 @@ OptionsDialog::OptionsDialog(QWidget *parent) #ifndef NO_OPENGL sw->hide(); #endif + // Tray icon settings + QGroupBox * trayIconBox = new QGroupBox(tr("Tray icon settings")); + QVBoxLayout * trayLayout = new QVBoxLayout(); auto apiKeyLayout = new QVBoxLayout(); auto apiKeyButton = new QPushButton(tr("Edit Comic Vine API key")); @@ -115,6 +118,7 @@ OptionsDialog::OptionsDialog(QWidget *parent) auto generalW = new QWidget; generalW->setLayout(generalLayout); + generalLayout->addWidget(trayIconBox); generalLayout->addWidget(shortcutsBox); generalLayout->addWidget(apiKeyBox); generalLayout->addStretch(); @@ -146,6 +150,10 @@ void OptionsDialog::restoreOptions(QSettings *settings) { YACReaderOptionsDialog::restoreOptions(settings); + trayIconCheckbox->setChecked(settings->value(MINIMIZE_TO_TRAY, true).toBool()); + startToTrayCheckbox->setChecked(settings->value(START_TO_TRAY, false).toBool()); + startToTrayCheckbox->setEnabled(trayIconCheckbox->isChecked()); + bool useBackgroundImage = settings->value(USE_BACKGROUND_IMAGE_IN_GRID_VIEW, true).toBool(); useBackgroundImageCheck->setChecked(useBackgroundImage); diff --git a/YACReaderLibrary/options_dialog.h b/YACReaderLibrary/options_dialog.h index 20c542a1..39e8fb9f 100644 --- a/YACReaderLibrary/options_dialog.h +++ b/YACReaderLibrary/options_dialog.h @@ -19,23 +19,20 @@ public slots: void editApiKey(); void restoreOptions(QSettings *settings) override; -private slots: - void useBackgroundImageCheckClicked(bool checked); - void backgroundImageOpacitySliderChanged(int value); - void backgroundImageBlurRadiusSliderChanged(int value); - void useCurrentComicCoverCheckClicked(bool checked); - void resetToDefaults(); - -private: - QCheckBox *useBackgroundImageCheck; - QCheckBox *useCurrentComicCoverCheck; - QSlider *backgroundImageOpacitySlider; - QSlider *backgroundImageBlurRadiusSlider; - QLabel *opacityLabel; - QLabel *blurLabel; - QPushButton *resetButton; - - QCheckBox *displayContinueReadingBannerCheck; + private slots: + void useBackgroundImageCheckClicked(bool checked); + void backgroundImageOpacitySliderChanged(int value); + void backgroundImageBlurRadiusSliderChanged(int value); + void useCurrentComicCoverCheckClicked(bool checked); + void resetToDefaults(); + private: + QCheckBox * useBackgroundImageCheck; + QCheckBox * useCurrentComicCoverCheck; + QSlider * backgroundImageOpacitySlider; + QSlider * backgroundImageBlurRadiusSlider; + QLabel * opacityLabel; + QLabel * blurLabel; + QPushButton * resetButton; }; #endif diff --git a/YACReaderLibrary/trayhandler.h b/YACReaderLibrary/trayhandler.h new file mode 100644 index 00000000..ce898a0e --- /dev/null +++ b/YACReaderLibrary/trayhandler.h @@ -0,0 +1,7 @@ +#ifndef TRAY_HANDLER +#define TRAY_HANDLER + +void OSXShowDockIcon(); +void OSXHideDockIcon(); + +#endif \ No newline at end of file diff --git a/YACReaderLibrary/trayhandler.mm b/YACReaderLibrary/trayhandler.mm new file mode 100644 index 00000000..9c3cce37 --- /dev/null +++ b/YACReaderLibrary/trayhandler.mm @@ -0,0 +1,11 @@ +#import +#include "trayhandler.h" + +void OSXShowDockIcon() +{ + [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; +} +void OSXHideDockIcon() +{ + [NSApp setActivationPolicy:NSApplicationActivationPolicyAccessory]; +} \ No newline at end of file diff --git a/common/yacreader_global_gui.h b/common/yacreader_global_gui.h index 0ec4ab1b..df8af780 100644 --- a/common/yacreader_global_gui.h +++ b/common/yacreader_global_gui.h @@ -17,6 +17,8 @@ #define FULLSCREEN "FULLSCREEN" #define Y_WINDOW_GEOMETRY "GEOMETRY" #define MAXIMIZED "MAXIMIZED" +#define MINIMIZE_TO_TRAY "MINIMIZE_TO_TRAY" +#define START_TO_TRAY "START_TO_TRAY" #define DOUBLE_PAGE "DOUBLE_PAGE" #define DOUBLE_MANGA_PAGE "DOUBLE_MANGA_PAGE" #define BACKGROUND_COLOR "BACKGROUND_COLOR" From a6324804222350db9bc97bd8fefc3ad0ffa63872 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 19 Sep 2019 21:16:56 +0200 Subject: [PATCH 02/19] Format --- YACReaderLibrary/library_window.cpp | 372 ++++++++++++++-------------- YACReaderLibrary/main.cpp | 44 ++-- YACReaderLibrary/options_dialog.cpp | 4 +- YACReaderLibrary/options_dialog.h | 29 +-- 4 files changed, 225 insertions(+), 224 deletions(-) diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index b19d1832..46cbfd9d 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -87,7 +87,7 @@ #include #endif #ifdef Q_OS_MACOS - #include "trayhandler.h" +#include "trayhandler.h" #endif LibraryWindow::LibraryWindow() @@ -531,229 +531,229 @@ void LibraryWindow::createActions() setAllAsNonReadAction->setToolTip(tr("Set all comics as unread")); setAllAsNonReadAction->setIcon(QIcon(":/images/comics_view_toolbar/setAllUnread.png"));*/ - showHideMarksAction = new QAction(tr("Show/Hide marks"), this); - showHideMarksAction->setToolTip(tr("Show or hide read marks")); - showHideMarksAction->setData(SHOW_HIDE_MARKS_ACTION_YL); - showHideMarksAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_HIDE_MARKS_ACTION_YL)); - showHideMarksAction->setCheckable(true); - showHideMarksAction->setIcon(QIcon(":/images/comics_view_toolbar/showMarks.png")); - showHideMarksAction->setChecked(true); +showHideMarksAction = new QAction(tr("Show/Hide marks"), this); +showHideMarksAction->setToolTip(tr("Show or hide read marks")); +showHideMarksAction->setData(SHOW_HIDE_MARKS_ACTION_YL); +showHideMarksAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_HIDE_MARKS_ACTION_YL)); +showHideMarksAction->setCheckable(true); +showHideMarksAction->setIcon(QIcon(":/images/comics_view_toolbar/showMarks.png")); +showHideMarksAction->setChecked(true); #ifndef Q_OS_MAC - toggleFullScreenAction = new QAction(tr("Fullscreen mode on/off"), this); - toggleFullScreenAction->setToolTip(tr("Fullscreen mode on/off")); - toggleFullScreenAction->setData(TOGGLE_FULL_SCREEN_ACTION_YL); - toggleFullScreenAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(TOGGLE_FULL_SCREEN_ACTION_YL)); - QIcon icoFullscreenButton; - icoFullscreenButton.addPixmap(QPixmap(":/images/main_toolbar/fullscreen.png"), QIcon::Normal); - toggleFullScreenAction->setIcon(icoFullscreenButton); +toggleFullScreenAction = new QAction(tr("Fullscreen mode on/off"), this); +toggleFullScreenAction->setToolTip(tr("Fullscreen mode on/off")); +toggleFullScreenAction->setData(TOGGLE_FULL_SCREEN_ACTION_YL); +toggleFullScreenAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(TOGGLE_FULL_SCREEN_ACTION_YL)); +QIcon icoFullscreenButton; +icoFullscreenButton.addPixmap(QPixmap(":/images/main_toolbar/fullscreen.png"), QIcon::Normal); +toggleFullScreenAction->setIcon(icoFullscreenButton); #endif - helpAboutAction = new QAction(this); - helpAboutAction->setToolTip(tr("Help, About YACReader")); - helpAboutAction->setData(HELP_ABOUT_ACTION_YL); - helpAboutAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(HELP_ABOUT_ACTION_YL)); - QIcon icoHelpButton; - icoHelpButton.addFile(":/images/main_toolbar/help.png", QSize(), QIcon::Normal); - helpAboutAction->setIcon(icoHelpButton); +helpAboutAction = new QAction(this); +helpAboutAction->setToolTip(tr("Help, About YACReader")); +helpAboutAction->setData(HELP_ABOUT_ACTION_YL); +helpAboutAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(HELP_ABOUT_ACTION_YL)); +QIcon icoHelpButton; +icoHelpButton.addFile(":/images/main_toolbar/help.png", QSize(), QIcon::Normal); +helpAboutAction->setIcon(icoHelpButton); - addFolderAction = new QAction(tr("Add new folder"), this); - addFolderAction->setData(ADD_FOLDER_ACTION_YL); - addFolderAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ADD_FOLDER_ACTION_YL)); - addFolderAction->setToolTip(tr("Add new folder to the current library")); - addFolderAction->setIcon(QIcon(":/images/sidebar/addNew_sidebar.png")); +addFolderAction = new QAction(tr("Add new folder"), this); +addFolderAction->setData(ADD_FOLDER_ACTION_YL); +addFolderAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ADD_FOLDER_ACTION_YL)); +addFolderAction->setToolTip(tr("Add new folder to the current library")); +addFolderAction->setIcon(QIcon(":/images/sidebar/addNew_sidebar.png")); - deleteFolderAction = new QAction(tr("Delete folder"), this); - deleteFolderAction->setData(REMOVE_FOLDER_ACTION_YL); - deleteFolderAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(REMOVE_FOLDER_ACTION_YL)); - deleteFolderAction->setToolTip(tr("Delete current folder from disk")); - deleteFolderAction->setIcon(QIcon(":/images/sidebar/delete_sidebar.png")); +deleteFolderAction = new QAction(tr("Delete folder"), this); +deleteFolderAction->setData(REMOVE_FOLDER_ACTION_YL); +deleteFolderAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(REMOVE_FOLDER_ACTION_YL)); +deleteFolderAction->setToolTip(tr("Delete current folder from disk")); +deleteFolderAction->setIcon(QIcon(":/images/sidebar/delete_sidebar.png")); - setRootIndexAction = new QAction(this); - setRootIndexAction->setData(SET_ROOT_INDEX_ACTION_YL); - setRootIndexAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_ROOT_INDEX_ACTION_YL)); - setRootIndexAction->setToolTip(tr("Select root node")); - setRootIndexAction->setIcon(QIcon(":/images/sidebar/setRoot.png")); +setRootIndexAction = new QAction(this); +setRootIndexAction->setData(SET_ROOT_INDEX_ACTION_YL); +setRootIndexAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_ROOT_INDEX_ACTION_YL)); +setRootIndexAction->setToolTip(tr("Select root node")); +setRootIndexAction->setIcon(QIcon(":/images/sidebar/setRoot.png")); - expandAllNodesAction = new QAction(this); - expandAllNodesAction->setToolTip(tr("Expand all nodes")); - expandAllNodesAction->setData(EXPAND_ALL_NODES_ACTION_YL); - expandAllNodesAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(EXPAND_ALL_NODES_ACTION_YL)); - expandAllNodesAction->setIcon(QIcon(":/images/sidebar/expand.png")); +expandAllNodesAction = new QAction(this); +expandAllNodesAction->setToolTip(tr("Expand all nodes")); +expandAllNodesAction->setData(EXPAND_ALL_NODES_ACTION_YL); +expandAllNodesAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(EXPAND_ALL_NODES_ACTION_YL)); +expandAllNodesAction->setIcon(QIcon(":/images/sidebar/expand.png")); - colapseAllNodesAction = new QAction(this); - colapseAllNodesAction->setToolTip(tr("Collapse all nodes")); - colapseAllNodesAction->setData(COLAPSE_ALL_NODES_ACTION_YL); - colapseAllNodesAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(COLAPSE_ALL_NODES_ACTION_YL)); - colapseAllNodesAction->setIcon(QIcon(":/images/sidebar/colapse.png")); +colapseAllNodesAction = new QAction(this); +colapseAllNodesAction->setToolTip(tr("Collapse all nodes")); +colapseAllNodesAction->setData(COLAPSE_ALL_NODES_ACTION_YL); +colapseAllNodesAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(COLAPSE_ALL_NODES_ACTION_YL)); +colapseAllNodesAction->setIcon(QIcon(":/images/sidebar/colapse.png")); - optionsAction = new QAction(this); - optionsAction->setToolTip(tr("Show options dialog")); - optionsAction->setData(OPTIONS_ACTION_YL); - optionsAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPTIONS_ACTION_YL)); - QIcon icoSettingsButton; - icoSettingsButton.addFile(":/images/main_toolbar/settings.png", QSize(), QIcon::Normal); - optionsAction->setIcon(icoSettingsButton); +optionsAction = new QAction(this); +optionsAction->setToolTip(tr("Show options dialog")); +optionsAction->setData(OPTIONS_ACTION_YL); +optionsAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPTIONS_ACTION_YL)); +QIcon icoSettingsButton; +icoSettingsButton.addFile(":/images/main_toolbar/settings.png", QSize(), QIcon::Normal); +optionsAction->setIcon(icoSettingsButton); - serverConfigAction = new QAction(this); - serverConfigAction->setToolTip(tr("Show comics server options dialog")); - serverConfigAction->setData(SERVER_CONFIG_ACTION_YL); - serverConfigAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SERVER_CONFIG_ACTION_YL)); - QIcon icoServerButton; - icoServerButton.addFile(":/images/main_toolbar/server.png", QSize(), QIcon::Normal); - serverConfigAction->setIcon(icoServerButton); +serverConfigAction = new QAction(this); +serverConfigAction->setToolTip(tr("Show comics server options dialog")); +serverConfigAction->setData(SERVER_CONFIG_ACTION_YL); +serverConfigAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SERVER_CONFIG_ACTION_YL)); +QIcon icoServerButton; +icoServerButton.addFile(":/images/main_toolbar/server.png", QSize(), QIcon::Normal); +serverConfigAction->setIcon(icoServerButton); - toggleComicsViewAction = new QAction(tr("Change between comics views"), this); - toggleComicsViewAction->setToolTip(tr("Change between comics views")); - QIcon icoViewsButton; +toggleComicsViewAction = new QAction(tr("Change between comics views"), this); +toggleComicsViewAction->setToolTip(tr("Change between comics views")); +QIcon icoViewsButton; - if (!settings->contains(COMICS_VIEW_STATUS) || settings->value(COMICS_VIEW_STATUS) == Flow) - icoViewsButton.addFile(":/images/main_toolbar/grid.png", QSize(), QIcon::Normal); - else if (settings->value(COMICS_VIEW_STATUS) == Grid) - icoViewsButton.addFile(":/images/main_toolbar/info.png", QSize(), QIcon::Normal); - else - icoViewsButton.addFile(":/images/main_toolbar/flow.png", QSize(), QIcon::Normal); +if (!settings->contains(COMICS_VIEW_STATUS) || settings->value(COMICS_VIEW_STATUS) == Flow) + icoViewsButton.addFile(":/images/main_toolbar/grid.png", QSize(), QIcon::Normal); +else if (settings->value(COMICS_VIEW_STATUS) == Grid) + icoViewsButton.addFile(":/images/main_toolbar/info.png", QSize(), QIcon::Normal); +else + icoViewsButton.addFile(":/images/main_toolbar/flow.png", QSize(), QIcon::Normal); - toggleComicsViewAction->setData(TOGGLE_COMICS_VIEW_ACTION_YL); - toggleComicsViewAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(TOGGLE_COMICS_VIEW_ACTION_YL)); - toggleComicsViewAction->setIcon(icoViewsButton); - //socialAction = new QAction(this); +toggleComicsViewAction->setData(TOGGLE_COMICS_VIEW_ACTION_YL); +toggleComicsViewAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(TOGGLE_COMICS_VIEW_ACTION_YL)); +toggleComicsViewAction->setIcon(icoViewsButton); +//socialAction = new QAction(this); - openContainingFolderAction = new QAction(this); - openContainingFolderAction->setText(tr("Open folder...")); - openContainingFolderAction->setData(OPEN_CONTAINING_FOLDER_ACTION_YL); - openContainingFolderAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_CONTAINING_FOLDER_ACTION_YL)); - openContainingFolderAction->setIcon(QIcon(":/images/menus_icons/open.png")); +openContainingFolderAction = new QAction(this); +openContainingFolderAction->setText(tr("Open folder...")); +openContainingFolderAction->setData(OPEN_CONTAINING_FOLDER_ACTION_YL); +openContainingFolderAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_CONTAINING_FOLDER_ACTION_YL)); +openContainingFolderAction->setIcon(QIcon(":/images/menus_icons/open.png")); - setFolderAsNotCompletedAction = new QAction(this); - setFolderAsNotCompletedAction->setText(tr("Set as uncompleted")); - setFolderAsNotCompletedAction->setData(SET_FOLDER_AS_NOT_COMPLETED_ACTION_YL); - setFolderAsNotCompletedAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_FOLDER_AS_NOT_COMPLETED_ACTION_YL)); +setFolderAsNotCompletedAction = new QAction(this); +setFolderAsNotCompletedAction->setText(tr("Set as uncompleted")); +setFolderAsNotCompletedAction->setData(SET_FOLDER_AS_NOT_COMPLETED_ACTION_YL); +setFolderAsNotCompletedAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_FOLDER_AS_NOT_COMPLETED_ACTION_YL)); - setFolderAsCompletedAction = new QAction(this); - setFolderAsCompletedAction->setText(tr("Set as completed")); - setFolderAsCompletedAction->setData(SET_FOLDER_AS_COMPLETED_ACTION_YL); - setFolderAsCompletedAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_FOLDER_AS_COMPLETED_ACTION_YL)); +setFolderAsCompletedAction = new QAction(this); +setFolderAsCompletedAction->setText(tr("Set as completed")); +setFolderAsCompletedAction->setData(SET_FOLDER_AS_COMPLETED_ACTION_YL); +setFolderAsCompletedAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_FOLDER_AS_COMPLETED_ACTION_YL)); - setFolderAsReadAction = new QAction(this); - setFolderAsReadAction->setText(tr("Set as read")); - setFolderAsReadAction->setData(SET_FOLDER_AS_READ_ACTION_YL); - setFolderAsReadAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_FOLDER_AS_READ_ACTION_YL)); +setFolderAsReadAction = new QAction(this); +setFolderAsReadAction->setText(tr("Set as read")); +setFolderAsReadAction->setData(SET_FOLDER_AS_READ_ACTION_YL); +setFolderAsReadAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_FOLDER_AS_READ_ACTION_YL)); - setFolderAsUnreadAction = new QAction(this); - setFolderAsUnreadAction->setText(tr("Set as unread")); - setFolderAsUnreadAction->setData(SET_FOLDER_AS_UNREAD_ACTION_YL); - setFolderAsUnreadAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_FOLDER_AS_UNREAD_ACTION_YL)); +setFolderAsUnreadAction = new QAction(this); +setFolderAsUnreadAction->setText(tr("Set as unread")); +setFolderAsUnreadAction->setData(SET_FOLDER_AS_UNREAD_ACTION_YL); +setFolderAsUnreadAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_FOLDER_AS_UNREAD_ACTION_YL)); - openContainingFolderComicAction = new QAction(this); - openContainingFolderComicAction->setText(tr("Open containing folder...")); - openContainingFolderComicAction->setData(OPEN_CONTAINING_FOLDER_COMIC_ACTION_YL); - openContainingFolderComicAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_CONTAINING_FOLDER_COMIC_ACTION_YL)); - openContainingFolderComicAction->setIcon(QIcon(":/images/menus_icons/open.png")); +openContainingFolderComicAction = new QAction(this); +openContainingFolderComicAction->setText(tr("Open containing folder...")); +openContainingFolderComicAction->setData(OPEN_CONTAINING_FOLDER_COMIC_ACTION_YL); +openContainingFolderComicAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_CONTAINING_FOLDER_COMIC_ACTION_YL)); +openContainingFolderComicAction->setIcon(QIcon(":/images/menus_icons/open.png")); - resetComicRatingAction = new QAction(this); - resetComicRatingAction->setText(tr("Reset comic rating")); - resetComicRatingAction->setData(RESET_COMIC_RATING_ACTION_YL); - resetComicRatingAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(RESET_COMIC_RATING_ACTION_YL)); +resetComicRatingAction = new QAction(this); +resetComicRatingAction->setText(tr("Reset comic rating")); +resetComicRatingAction->setData(RESET_COMIC_RATING_ACTION_YL); +resetComicRatingAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(RESET_COMIC_RATING_ACTION_YL)); - //Edit comics actions------------------------------------------------------ - selectAllComicsAction = new QAction(this); - selectAllComicsAction->setText(tr("Select all comics")); - selectAllComicsAction->setData(SELECT_ALL_COMICS_ACTION_YL); - selectAllComicsAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SELECT_ALL_COMICS_ACTION_YL)); - selectAllComicsAction->setIcon(QIcon(":/images/comics_view_toolbar/selectAll.png")); +//Edit comics actions------------------------------------------------------ +selectAllComicsAction = new QAction(this); +selectAllComicsAction->setText(tr("Select all comics")); +selectAllComicsAction->setData(SELECT_ALL_COMICS_ACTION_YL); +selectAllComicsAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SELECT_ALL_COMICS_ACTION_YL)); +selectAllComicsAction->setIcon(QIcon(":/images/comics_view_toolbar/selectAll.png")); - editSelectedComicsAction = new QAction(this); - editSelectedComicsAction->setText(tr("Edit")); - editSelectedComicsAction->setData(EDIT_SELECTED_COMICS_ACTION_YL); - editSelectedComicsAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(EDIT_SELECTED_COMICS_ACTION_YL)); - editSelectedComicsAction->setIcon(QIcon(":/images/comics_view_toolbar/editComic.png")); +editSelectedComicsAction = new QAction(this); +editSelectedComicsAction->setText(tr("Edit")); +editSelectedComicsAction->setData(EDIT_SELECTED_COMICS_ACTION_YL); +editSelectedComicsAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(EDIT_SELECTED_COMICS_ACTION_YL)); +editSelectedComicsAction->setIcon(QIcon(":/images/comics_view_toolbar/editComic.png")); - asignOrderAction = new QAction(this); - asignOrderAction->setText(tr("Assign current order to comics")); - asignOrderAction->setData(ASIGN_ORDER_ACTION_YL); - asignOrderAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ASIGN_ORDER_ACTION_YL)); - asignOrderAction->setIcon(QIcon(":/images/comics_view_toolbar/asignNumber.png")); +asignOrderAction = new QAction(this); +asignOrderAction->setText(tr("Assign current order to comics")); +asignOrderAction->setData(ASIGN_ORDER_ACTION_YL); +asignOrderAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ASIGN_ORDER_ACTION_YL)); +asignOrderAction->setIcon(QIcon(":/images/comics_view_toolbar/asignNumber.png")); - forceCoverExtractedAction = new QAction(this); - forceCoverExtractedAction->setText(tr("Update cover")); - forceCoverExtractedAction->setData(FORCE_COVER_EXTRACTED_ACTION_YL); - forceCoverExtractedAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(FORCE_COVER_EXTRACTED_ACTION_YL)); - forceCoverExtractedAction->setIcon(QIcon(":/images/importCover.png")); +forceCoverExtractedAction = new QAction(this); +forceCoverExtractedAction->setText(tr("Update cover")); +forceCoverExtractedAction->setData(FORCE_COVER_EXTRACTED_ACTION_YL); +forceCoverExtractedAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(FORCE_COVER_EXTRACTED_ACTION_YL)); +forceCoverExtractedAction->setIcon(QIcon(":/images/importCover.png")); - deleteComicsAction = new QAction(this); - deleteComicsAction->setText(tr("Delete selected comics")); - deleteComicsAction->setData(DELETE_COMICS_ACTION_YL); - deleteComicsAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(DELETE_COMICS_ACTION_YL)); - deleteComicsAction->setIcon(QIcon(":/images/comics_view_toolbar/trash.png")); +deleteComicsAction = new QAction(this); +deleteComicsAction->setText(tr("Delete selected comics")); +deleteComicsAction->setData(DELETE_COMICS_ACTION_YL); +deleteComicsAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(DELETE_COMICS_ACTION_YL)); +deleteComicsAction->setIcon(QIcon(":/images/comics_view_toolbar/trash.png")); - getInfoAction = new QAction(this); - getInfoAction->setData(GET_INFO_ACTION_YL); - getInfoAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(GET_INFO_ACTION_YL)); - getInfoAction->setText(tr("Download tags from Comic Vine")); - getInfoAction->setIcon(QIcon(":/images/comics_view_toolbar/getInfo.png")); - //------------------------------------------------------------------------- +getInfoAction = new QAction(this); +getInfoAction->setData(GET_INFO_ACTION_YL); +getInfoAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(GET_INFO_ACTION_YL)); +getInfoAction->setText(tr("Download tags from Comic Vine")); +getInfoAction->setIcon(QIcon(":/images/comics_view_toolbar/getInfo.png")); +//------------------------------------------------------------------------- - showEditShortcutsAction = new QAction(tr("Edit shortcuts"), this); - showEditShortcutsAction->setData(SHOW_EDIT_SHORTCUTS_ACTION_YL); - showEditShortcutsAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_EDIT_SHORTCUTS_ACTION_YL)); - showEditShortcutsAction->setShortcutContext(Qt::ApplicationShortcut); - addAction(showEditShortcutsAction); +showEditShortcutsAction = new QAction(tr("Edit shortcuts"), this); +showEditShortcutsAction->setData(SHOW_EDIT_SHORTCUTS_ACTION_YL); +showEditShortcutsAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_EDIT_SHORTCUTS_ACTION_YL)); +showEditShortcutsAction->setShortcutContext(Qt::ApplicationShortcut); +addAction(showEditShortcutsAction); - updateFolderAction = new QAction(tr("Update folder"), this); - updateFolderAction->setIcon(QIcon(":/images/menus_icons/updateLibraryIcon.png")); +updateFolderAction = new QAction(tr("Update folder"), this); +updateFolderAction->setIcon(QIcon(":/images/menus_icons/updateLibraryIcon.png")); - updateCurrentFolderAction = new QAction(tr("Update current folder"), this); - updateCurrentFolderAction->setData(UPDATE_CURRENT_FOLDER_ACTION_YL); - updateCurrentFolderAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(UPDATE_CURRENT_FOLDER_ACTION_YL)); - updateCurrentFolderAction->setIcon(QIcon(":/images/menus_icons/updateLibraryIcon.png")); +updateCurrentFolderAction = new QAction(tr("Update current folder"), this); +updateCurrentFolderAction->setData(UPDATE_CURRENT_FOLDER_ACTION_YL); +updateCurrentFolderAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(UPDATE_CURRENT_FOLDER_ACTION_YL)); +updateCurrentFolderAction->setIcon(QIcon(":/images/menus_icons/updateLibraryIcon.png")); - addReadingListAction = new QAction(tr("Add new reading list"), this); - addReadingListAction->setData(ADD_READING_LIST_ACTION_YL); - addReadingListAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ADD_READING_LIST_ACTION_YL)); - addReadingListAction->setToolTip(tr("Add a new reading list to the current library")); - addReadingListAction->setIcon(QIcon(":/images/sidebar/addNew_sidebar.png")); +addReadingListAction = new QAction(tr("Add new reading list"), this); +addReadingListAction->setData(ADD_READING_LIST_ACTION_YL); +addReadingListAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ADD_READING_LIST_ACTION_YL)); +addReadingListAction->setToolTip(tr("Add a new reading list to the current library")); +addReadingListAction->setIcon(QIcon(":/images/sidebar/addNew_sidebar.png")); - deleteReadingListAction = new QAction(tr("Remove reading list"), this); - deleteReadingListAction->setData(REMOVE_READING_LIST_ACTION_YL); - deleteReadingListAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(REMOVE_READING_LIST_ACTION_YL)); - deleteReadingListAction->setToolTip(tr("Remove current reading list from the library")); - deleteReadingListAction->setIcon(QIcon(":/images/sidebar/delete_sidebar.png")); +deleteReadingListAction = new QAction(tr("Remove reading list"), this); +deleteReadingListAction->setData(REMOVE_READING_LIST_ACTION_YL); +deleteReadingListAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(REMOVE_READING_LIST_ACTION_YL)); +deleteReadingListAction->setToolTip(tr("Remove current reading list from the library")); +deleteReadingListAction->setIcon(QIcon(":/images/sidebar/delete_sidebar.png")); - addLabelAction = new QAction(tr("Add new label"), this); - addLabelAction->setData(ADD_LABEL_ACTION_YL); - addLabelAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ADD_LABEL_ACTION_YL)); - addLabelAction->setToolTip(tr("Add a new label to this library")); - addLabelAction->setIcon(QIcon(":/images/sidebar/addLabelIcon.png")); +addLabelAction = new QAction(tr("Add new label"), this); +addLabelAction->setData(ADD_LABEL_ACTION_YL); +addLabelAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ADD_LABEL_ACTION_YL)); +addLabelAction->setToolTip(tr("Add a new label to this library")); +addLabelAction->setIcon(QIcon(":/images/sidebar/addLabelIcon.png")); - renameListAction = new QAction(tr("Rename selected list"), this); - renameListAction->setData(RENAME_LIST_ACTION_YL); - renameListAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(RENAME_LIST_ACTION_YL)); - renameListAction->setToolTip(tr("Rename any selected labels or lists")); - renameListAction->setIcon(QIcon(":/images/sidebar/renameListIcon.png")); +renameListAction = new QAction(tr("Rename selected list"), this); +renameListAction->setData(RENAME_LIST_ACTION_YL); +renameListAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(RENAME_LIST_ACTION_YL)); +renameListAction->setToolTip(tr("Rename any selected labels or lists")); +renameListAction->setIcon(QIcon(":/images/sidebar/renameListIcon.png")); - //-- - addToMenuAction = new QAction(tr("Add to..."), this); +//-- +addToMenuAction = new QAction(tr("Add to..."), this); - addToFavoritesAction = new QAction(tr("Favorites"), this); - addToFavoritesAction->setData(ADD_TO_FAVORITES_ACTION_YL); - addToFavoritesAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ADD_TO_FAVORITES_ACTION_YL)); - addToFavoritesAction->setToolTip(tr("Add selected comics to favorites list")); - addToFavoritesAction->setIcon(QIcon(":/images/lists/default_1.png")); +addToFavoritesAction = new QAction(tr("Favorites"), this); +addToFavoritesAction->setData(ADD_TO_FAVORITES_ACTION_YL); +addToFavoritesAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ADD_TO_FAVORITES_ACTION_YL)); +addToFavoritesAction->setToolTip(tr("Add selected comics to favorites list")); +addToFavoritesAction->setIcon(QIcon(":/images/lists/default_1.png")); - //actions not asigned to any widget - this->addAction(saveCoversToAction); - this->addAction(openContainingFolderAction); - this->addAction(updateCurrentFolderAction); - this->addAction(resetComicRatingAction); - this->addAction(setFolderAsCompletedAction); - this->addAction(setFolderAsNotCompletedAction); - this->addAction(setFolderAsReadAction); - this->addAction(setFolderAsUnreadAction); +//actions not asigned to any widget +this->addAction(saveCoversToAction); +this->addAction(openContainingFolderAction); +this->addAction(updateCurrentFolderAction); +this->addAction(resetComicRatingAction); +this->addAction(setFolderAsCompletedAction); +this->addAction(setFolderAsNotCompletedAction); +this->addAction(setFolderAsReadAction); +this->addAction(setFolderAsUnreadAction); #ifndef Q_OS_MAC - this->addAction(toggleFullScreenAction); +this->addAction(toggleFullScreenAction); #endif - //disable actions - disableAllActions(); +//disable actions +disableAllActions(); } void LibraryWindow::disableComicsActions(bool disabled) { diff --git a/YACReaderLibrary/main.cpp b/YACReaderLibrary/main.cpp index c65fc245..966e6efc 100644 --- a/YACReaderLibrary/main.cpp +++ b/YACReaderLibrary/main.cpp @@ -21,7 +21,7 @@ #include "exit_check.h" #include "opengl_checker.h" #ifdef Q_OS_MACOS - #include "trayhandler.h" +#include "trayhandler.h" #endif #include "QsLog.h" @@ -130,12 +130,12 @@ int main(int argc, char **argv) app.setApplicationVersion(VERSION); app.setAttribute(Qt::AA_UseHighDpiPixmaps); - // Set window icon according to Freedesktop icon specification - // This is mostly relevant for Linux and other Unix systems - if (QIcon::hasThemeIcon("YACReaderLibrary")) { - app.setWindowIcon(QIcon::fromTheme("YACReaderLibrary")); - } - // TODO: We might want to add a fallback icon here. + // Set window icon according to Freedesktop icon specification + // This is mostly relevant for Linux and other Unix systems + if (QIcon::hasThemeIcon("YACReaderLibrary")) { + app.setWindowIcon(QIcon::fromTheme("YACReaderLibrary")); + } + // TODO: We might want to add a fallback icon here. QString destLog = YACReader::getSettingsPath() + "/yacreaderlibrary.log"; QDir().mkpath(YACReader::getSettingsPath()); @@ -216,18 +216,18 @@ int main(int argc, char **argv) } #ifdef SERVER_RELEASE - QSettings * settings = new QSettings(YACReader::getSettingsPath()+"/YACReaderLibrary.ini",QSettings::IniFormat); //TODO unificar la creaci�n del fichero de config con el servidor - settings->beginGroup("libraryConfig"); + QSettings *settings = new QSettings(YACReader::getSettingsPath() + "/YACReaderLibrary.ini", QSettings::IniFormat); //TODO unificar la creaci�n del fichero de config con el servidor + settings->beginGroup("libraryConfig"); - s = new Startup(); + s = new Startup(); if (settings->value(SERVER_ON, true).toBool()) { s->start(); } #endif - QLOG_INFO() << "YACReaderLibrary attempting to start"; + QLOG_INFO() << "YACReaderLibrary attempting to start"; - logSystemAndConfig(); + logSystemAndConfig(); if (YACReaderLocalServer::isRunning()) //s�lo se permite una instancia de YACReaderLibrary { @@ -241,24 +241,24 @@ int main(int argc, char **argv) auto mw = new LibraryWindow(); - mw->connect(localServer,SIGNAL(comicUpdated(quint64, const ComicDB &)),mw,SLOT(updateComicsView(quint64, const ComicDB &)), Qt::QueuedConnection); + mw->connect(localServer, SIGNAL(comicUpdated(quint64, const ComicDB &)), mw, SLOT(updateComicsView(quint64, const ComicDB &)), Qt::QueuedConnection); - //connections to localServer + //connections to localServer - mw->show(); + mw->show(); - int ret = app.exec(); + int ret = app.exec(); QLOG_INFO() << "YACReaderLibrary closed with exit code :" << ret; YACReader::exitCheck(ret); - //shutdown - s->stop(); - delete s; - localServer->close(); - delete localServer; - delete mw; + //shutdown + s->stop(); + delete s; + localServer->close(); + delete localServer; + delete mw; QsLogging::Logger::destroyInstance(); diff --git a/YACReaderLibrary/options_dialog.cpp b/YACReaderLibrary/options_dialog.cpp index cfe04926..c5a46960 100644 --- a/YACReaderLibrary/options_dialog.cpp +++ b/YACReaderLibrary/options_dialog.cpp @@ -44,8 +44,8 @@ OptionsDialog::OptionsDialog(QWidget *parent) sw->hide(); #endif // Tray icon settings - QGroupBox * trayIconBox = new QGroupBox(tr("Tray icon settings")); - QVBoxLayout * trayLayout = new QVBoxLayout(); + QGroupBox *trayIconBox = new QGroupBox(tr("Tray icon settings")); + QVBoxLayout *trayLayout = new QVBoxLayout(); auto apiKeyLayout = new QVBoxLayout(); auto apiKeyButton = new QPushButton(tr("Edit Comic Vine API key")); diff --git a/YACReaderLibrary/options_dialog.h b/YACReaderLibrary/options_dialog.h index 39e8fb9f..575a0090 100644 --- a/YACReaderLibrary/options_dialog.h +++ b/YACReaderLibrary/options_dialog.h @@ -19,20 +19,21 @@ public slots: void editApiKey(); void restoreOptions(QSettings *settings) override; - private slots: - void useBackgroundImageCheckClicked(bool checked); - void backgroundImageOpacitySliderChanged(int value); - void backgroundImageBlurRadiusSliderChanged(int value); - void useCurrentComicCoverCheckClicked(bool checked); - void resetToDefaults(); - private: - QCheckBox * useBackgroundImageCheck; - QCheckBox * useCurrentComicCoverCheck; - QSlider * backgroundImageOpacitySlider; - QSlider * backgroundImageBlurRadiusSlider; - QLabel * opacityLabel; - QLabel * blurLabel; - QPushButton * resetButton; +private slots: + void useBackgroundImageCheckClicked(bool checked); + void backgroundImageOpacitySliderChanged(int value); + void backgroundImageBlurRadiusSliderChanged(int value); + void useCurrentComicCoverCheckClicked(bool checked); + void resetToDefaults(); + +private: + QCheckBox *useBackgroundImageCheck; + QCheckBox *useCurrentComicCoverCheck; + QSlider *backgroundImageOpacitySlider; + QSlider *backgroundImageBlurRadiusSlider; + QLabel *opacityLabel; + QLabel *blurLabel; + QPushButton *resetButton; }; #endif From a0f682be7b94df951ac88b02baa57182cac8340f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 19 Sep 2019 22:32:07 +0200 Subject: [PATCH 03/19] Merge went bad Hopefully this is all that got messed up --- YACReaderLibrary/library_window.cpp | 418 ++++++++++++++-------------- 1 file changed, 209 insertions(+), 209 deletions(-) diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index 46cbfd9d..21c8610c 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -139,39 +139,39 @@ void LibraryWindow::setupUI() else //if(settings->value(USE_OPEN_GL).toBool() == false) showMaximized(); -} -/* //disabled until icons are ready and macos native code is done + + // If a window icon was set in main() we reuse it for the tray too. + // This allows support for third party icon themes on Freedesktop(Linux/Unix) + // systems. + // TODO: Luis, please tweak this to your liking and add OS macros if needed. + if (!QApplication::windowIcon().isNull()) { trayIcon.setIcon(QApplication::windowIcon()); - } - else - { + } else { // TODO: Luis: This is a placeholder. Add MacOS, Windows and maybe a fallback // for other systems here. trayIcon.setIcon(QIcon(":/images/iconLibrary.png")); } connect(&trayIcon, &QSystemTrayIcon::activated, - [=] (QSystemTrayIcon::ActivationReason reason) { - if (reason == QSystemTrayIcon::Trigger) - { - #ifdef Q_OS_MACOS - OSXShowDockIcon(); - #endif - setWindowState((windowState() & ~Qt::WindowMinimized) | Qt::WindowActive); - show(); - } - }); + [=](QSystemTrayIcon::ActivationReason reason) { + if (reason == QSystemTrayIcon::Trigger) { +#ifdef Q_OS_MACOS + OSXShowDockIcon(); +#endif + setWindowState((windowState() & ~Qt::WindowMinimized) | Qt::WindowActive); + show(); + } + }); trayIcon.setVisible(settings->value(MINIMIZE_TO_TRAY, true).toBool()); } void LibraryWindow::changeEvent(QEvent *event) { if (event->type() == QEvent::WindowStateChange && isMinimized() && - trayIcon.isVisible()) - { - #ifdef Q_OS_MACOS + trayIcon.isVisible()) { +#ifdef Q_OS_MACOS OSXHideDockIcon(); - #endif +#endif hide(); return; } @@ -531,229 +531,229 @@ void LibraryWindow::createActions() setAllAsNonReadAction->setToolTip(tr("Set all comics as unread")); setAllAsNonReadAction->setIcon(QIcon(":/images/comics_view_toolbar/setAllUnread.png"));*/ -showHideMarksAction = new QAction(tr("Show/Hide marks"), this); -showHideMarksAction->setToolTip(tr("Show or hide read marks")); -showHideMarksAction->setData(SHOW_HIDE_MARKS_ACTION_YL); -showHideMarksAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_HIDE_MARKS_ACTION_YL)); -showHideMarksAction->setCheckable(true); -showHideMarksAction->setIcon(QIcon(":/images/comics_view_toolbar/showMarks.png")); -showHideMarksAction->setChecked(true); + showHideMarksAction = new QAction(tr("Show/Hide marks"), this); + showHideMarksAction->setToolTip(tr("Show or hide read marks")); + showHideMarksAction->setData(SHOW_HIDE_MARKS_ACTION_YL); + showHideMarksAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_HIDE_MARKS_ACTION_YL)); + showHideMarksAction->setCheckable(true); + showHideMarksAction->setIcon(QIcon(":/images/comics_view_toolbar/showMarks.png")); + showHideMarksAction->setChecked(true); #ifndef Q_OS_MAC -toggleFullScreenAction = new QAction(tr("Fullscreen mode on/off"), this); -toggleFullScreenAction->setToolTip(tr("Fullscreen mode on/off")); -toggleFullScreenAction->setData(TOGGLE_FULL_SCREEN_ACTION_YL); -toggleFullScreenAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(TOGGLE_FULL_SCREEN_ACTION_YL)); -QIcon icoFullscreenButton; -icoFullscreenButton.addPixmap(QPixmap(":/images/main_toolbar/fullscreen.png"), QIcon::Normal); -toggleFullScreenAction->setIcon(icoFullscreenButton); + toggleFullScreenAction = new QAction(tr("Fullscreen mode on/off"), this); + toggleFullScreenAction->setToolTip(tr("Fullscreen mode on/off")); + toggleFullScreenAction->setData(TOGGLE_FULL_SCREEN_ACTION_YL); + toggleFullScreenAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(TOGGLE_FULL_SCREEN_ACTION_YL)); + QIcon icoFullscreenButton; + icoFullscreenButton.addPixmap(QPixmap(":/images/main_toolbar/fullscreen.png"), QIcon::Normal); + toggleFullScreenAction->setIcon(icoFullscreenButton); #endif -helpAboutAction = new QAction(this); -helpAboutAction->setToolTip(tr("Help, About YACReader")); -helpAboutAction->setData(HELP_ABOUT_ACTION_YL); -helpAboutAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(HELP_ABOUT_ACTION_YL)); -QIcon icoHelpButton; -icoHelpButton.addFile(":/images/main_toolbar/help.png", QSize(), QIcon::Normal); -helpAboutAction->setIcon(icoHelpButton); + helpAboutAction = new QAction(this); + helpAboutAction->setToolTip(tr("Help, About YACReader")); + helpAboutAction->setData(HELP_ABOUT_ACTION_YL); + helpAboutAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(HELP_ABOUT_ACTION_YL)); + QIcon icoHelpButton; + icoHelpButton.addFile(":/images/main_toolbar/help.png", QSize(), QIcon::Normal); + helpAboutAction->setIcon(icoHelpButton); -addFolderAction = new QAction(tr("Add new folder"), this); -addFolderAction->setData(ADD_FOLDER_ACTION_YL); -addFolderAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ADD_FOLDER_ACTION_YL)); -addFolderAction->setToolTip(tr("Add new folder to the current library")); -addFolderAction->setIcon(QIcon(":/images/sidebar/addNew_sidebar.png")); + addFolderAction = new QAction(tr("Add new folder"), this); + addFolderAction->setData(ADD_FOLDER_ACTION_YL); + addFolderAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ADD_FOLDER_ACTION_YL)); + addFolderAction->setToolTip(tr("Add new folder to the current library")); + addFolderAction->setIcon(QIcon(":/images/sidebar/addNew_sidebar.png")); -deleteFolderAction = new QAction(tr("Delete folder"), this); -deleteFolderAction->setData(REMOVE_FOLDER_ACTION_YL); -deleteFolderAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(REMOVE_FOLDER_ACTION_YL)); -deleteFolderAction->setToolTip(tr("Delete current folder from disk")); -deleteFolderAction->setIcon(QIcon(":/images/sidebar/delete_sidebar.png")); + deleteFolderAction = new QAction(tr("Delete folder"), this); + deleteFolderAction->setData(REMOVE_FOLDER_ACTION_YL); + deleteFolderAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(REMOVE_FOLDER_ACTION_YL)); + deleteFolderAction->setToolTip(tr("Delete current folder from disk")); + deleteFolderAction->setIcon(QIcon(":/images/sidebar/delete_sidebar.png")); -setRootIndexAction = new QAction(this); -setRootIndexAction->setData(SET_ROOT_INDEX_ACTION_YL); -setRootIndexAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_ROOT_INDEX_ACTION_YL)); -setRootIndexAction->setToolTip(tr("Select root node")); -setRootIndexAction->setIcon(QIcon(":/images/sidebar/setRoot.png")); + setRootIndexAction = new QAction(this); + setRootIndexAction->setData(SET_ROOT_INDEX_ACTION_YL); + setRootIndexAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_ROOT_INDEX_ACTION_YL)); + setRootIndexAction->setToolTip(tr("Select root node")); + setRootIndexAction->setIcon(QIcon(":/images/sidebar/setRoot.png")); -expandAllNodesAction = new QAction(this); -expandAllNodesAction->setToolTip(tr("Expand all nodes")); -expandAllNodesAction->setData(EXPAND_ALL_NODES_ACTION_YL); -expandAllNodesAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(EXPAND_ALL_NODES_ACTION_YL)); -expandAllNodesAction->setIcon(QIcon(":/images/sidebar/expand.png")); + expandAllNodesAction = new QAction(this); + expandAllNodesAction->setToolTip(tr("Expand all nodes")); + expandAllNodesAction->setData(EXPAND_ALL_NODES_ACTION_YL); + expandAllNodesAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(EXPAND_ALL_NODES_ACTION_YL)); + expandAllNodesAction->setIcon(QIcon(":/images/sidebar/expand.png")); -colapseAllNodesAction = new QAction(this); -colapseAllNodesAction->setToolTip(tr("Collapse all nodes")); -colapseAllNodesAction->setData(COLAPSE_ALL_NODES_ACTION_YL); -colapseAllNodesAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(COLAPSE_ALL_NODES_ACTION_YL)); -colapseAllNodesAction->setIcon(QIcon(":/images/sidebar/colapse.png")); + colapseAllNodesAction = new QAction(this); + colapseAllNodesAction->setToolTip(tr("Collapse all nodes")); + colapseAllNodesAction->setData(COLAPSE_ALL_NODES_ACTION_YL); + colapseAllNodesAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(COLAPSE_ALL_NODES_ACTION_YL)); + colapseAllNodesAction->setIcon(QIcon(":/images/sidebar/colapse.png")); -optionsAction = new QAction(this); -optionsAction->setToolTip(tr("Show options dialog")); -optionsAction->setData(OPTIONS_ACTION_YL); -optionsAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPTIONS_ACTION_YL)); -QIcon icoSettingsButton; -icoSettingsButton.addFile(":/images/main_toolbar/settings.png", QSize(), QIcon::Normal); -optionsAction->setIcon(icoSettingsButton); + optionsAction = new QAction(this); + optionsAction->setToolTip(tr("Show options dialog")); + optionsAction->setData(OPTIONS_ACTION_YL); + optionsAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPTIONS_ACTION_YL)); + QIcon icoSettingsButton; + icoSettingsButton.addFile(":/images/main_toolbar/settings.png", QSize(), QIcon::Normal); + optionsAction->setIcon(icoSettingsButton); -serverConfigAction = new QAction(this); -serverConfigAction->setToolTip(tr("Show comics server options dialog")); -serverConfigAction->setData(SERVER_CONFIG_ACTION_YL); -serverConfigAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SERVER_CONFIG_ACTION_YL)); -QIcon icoServerButton; -icoServerButton.addFile(":/images/main_toolbar/server.png", QSize(), QIcon::Normal); -serverConfigAction->setIcon(icoServerButton); + serverConfigAction = new QAction(this); + serverConfigAction->setToolTip(tr("Show comics server options dialog")); + serverConfigAction->setData(SERVER_CONFIG_ACTION_YL); + serverConfigAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SERVER_CONFIG_ACTION_YL)); + QIcon icoServerButton; + icoServerButton.addFile(":/images/main_toolbar/server.png", QSize(), QIcon::Normal); + serverConfigAction->setIcon(icoServerButton); -toggleComicsViewAction = new QAction(tr("Change between comics views"), this); -toggleComicsViewAction->setToolTip(tr("Change between comics views")); -QIcon icoViewsButton; + toggleComicsViewAction = new QAction(tr("Change between comics views"), this); + toggleComicsViewAction->setToolTip(tr("Change between comics views")); + QIcon icoViewsButton; -if (!settings->contains(COMICS_VIEW_STATUS) || settings->value(COMICS_VIEW_STATUS) == Flow) - icoViewsButton.addFile(":/images/main_toolbar/grid.png", QSize(), QIcon::Normal); -else if (settings->value(COMICS_VIEW_STATUS) == Grid) - icoViewsButton.addFile(":/images/main_toolbar/info.png", QSize(), QIcon::Normal); -else - icoViewsButton.addFile(":/images/main_toolbar/flow.png", QSize(), QIcon::Normal); + if (!settings->contains(COMICS_VIEW_STATUS) || settings->value(COMICS_VIEW_STATUS) == Flow) + icoViewsButton.addFile(":/images/main_toolbar/grid.png", QSize(), QIcon::Normal); + else if (settings->value(COMICS_VIEW_STATUS) == Grid) + icoViewsButton.addFile(":/images/main_toolbar/info.png", QSize(), QIcon::Normal); + else + icoViewsButton.addFile(":/images/main_toolbar/flow.png", QSize(), QIcon::Normal); -toggleComicsViewAction->setData(TOGGLE_COMICS_VIEW_ACTION_YL); -toggleComicsViewAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(TOGGLE_COMICS_VIEW_ACTION_YL)); -toggleComicsViewAction->setIcon(icoViewsButton); -//socialAction = new QAction(this); + toggleComicsViewAction->setData(TOGGLE_COMICS_VIEW_ACTION_YL); + toggleComicsViewAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(TOGGLE_COMICS_VIEW_ACTION_YL)); + toggleComicsViewAction->setIcon(icoViewsButton); + //socialAction = new QAction(this); -openContainingFolderAction = new QAction(this); -openContainingFolderAction->setText(tr("Open folder...")); -openContainingFolderAction->setData(OPEN_CONTAINING_FOLDER_ACTION_YL); -openContainingFolderAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_CONTAINING_FOLDER_ACTION_YL)); -openContainingFolderAction->setIcon(QIcon(":/images/menus_icons/open.png")); + openContainingFolderAction = new QAction(this); + openContainingFolderAction->setText(tr("Open folder...")); + openContainingFolderAction->setData(OPEN_CONTAINING_FOLDER_ACTION_YL); + openContainingFolderAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_CONTAINING_FOLDER_ACTION_YL)); + openContainingFolderAction->setIcon(QIcon(":/images/menus_icons/open.png")); -setFolderAsNotCompletedAction = new QAction(this); -setFolderAsNotCompletedAction->setText(tr("Set as uncompleted")); -setFolderAsNotCompletedAction->setData(SET_FOLDER_AS_NOT_COMPLETED_ACTION_YL); -setFolderAsNotCompletedAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_FOLDER_AS_NOT_COMPLETED_ACTION_YL)); + setFolderAsNotCompletedAction = new QAction(this); + setFolderAsNotCompletedAction->setText(tr("Set as uncompleted")); + setFolderAsNotCompletedAction->setData(SET_FOLDER_AS_NOT_COMPLETED_ACTION_YL); + setFolderAsNotCompletedAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_FOLDER_AS_NOT_COMPLETED_ACTION_YL)); -setFolderAsCompletedAction = new QAction(this); -setFolderAsCompletedAction->setText(tr("Set as completed")); -setFolderAsCompletedAction->setData(SET_FOLDER_AS_COMPLETED_ACTION_YL); -setFolderAsCompletedAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_FOLDER_AS_COMPLETED_ACTION_YL)); + setFolderAsCompletedAction = new QAction(this); + setFolderAsCompletedAction->setText(tr("Set as completed")); + setFolderAsCompletedAction->setData(SET_FOLDER_AS_COMPLETED_ACTION_YL); + setFolderAsCompletedAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_FOLDER_AS_COMPLETED_ACTION_YL)); -setFolderAsReadAction = new QAction(this); -setFolderAsReadAction->setText(tr("Set as read")); -setFolderAsReadAction->setData(SET_FOLDER_AS_READ_ACTION_YL); -setFolderAsReadAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_FOLDER_AS_READ_ACTION_YL)); + setFolderAsReadAction = new QAction(this); + setFolderAsReadAction->setText(tr("Set as read")); + setFolderAsReadAction->setData(SET_FOLDER_AS_READ_ACTION_YL); + setFolderAsReadAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_FOLDER_AS_READ_ACTION_YL)); -setFolderAsUnreadAction = new QAction(this); -setFolderAsUnreadAction->setText(tr("Set as unread")); -setFolderAsUnreadAction->setData(SET_FOLDER_AS_UNREAD_ACTION_YL); -setFolderAsUnreadAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_FOLDER_AS_UNREAD_ACTION_YL)); + setFolderAsUnreadAction = new QAction(this); + setFolderAsUnreadAction->setText(tr("Set as unread")); + setFolderAsUnreadAction->setData(SET_FOLDER_AS_UNREAD_ACTION_YL); + setFolderAsUnreadAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_FOLDER_AS_UNREAD_ACTION_YL)); -openContainingFolderComicAction = new QAction(this); -openContainingFolderComicAction->setText(tr("Open containing folder...")); -openContainingFolderComicAction->setData(OPEN_CONTAINING_FOLDER_COMIC_ACTION_YL); -openContainingFolderComicAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_CONTAINING_FOLDER_COMIC_ACTION_YL)); -openContainingFolderComicAction->setIcon(QIcon(":/images/menus_icons/open.png")); + openContainingFolderComicAction = new QAction(this); + openContainingFolderComicAction->setText(tr("Open containing folder...")); + openContainingFolderComicAction->setData(OPEN_CONTAINING_FOLDER_COMIC_ACTION_YL); + openContainingFolderComicAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_CONTAINING_FOLDER_COMIC_ACTION_YL)); + openContainingFolderComicAction->setIcon(QIcon(":/images/menus_icons/open.png")); -resetComicRatingAction = new QAction(this); -resetComicRatingAction->setText(tr("Reset comic rating")); -resetComicRatingAction->setData(RESET_COMIC_RATING_ACTION_YL); -resetComicRatingAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(RESET_COMIC_RATING_ACTION_YL)); + resetComicRatingAction = new QAction(this); + resetComicRatingAction->setText(tr("Reset comic rating")); + resetComicRatingAction->setData(RESET_COMIC_RATING_ACTION_YL); + resetComicRatingAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(RESET_COMIC_RATING_ACTION_YL)); -//Edit comics actions------------------------------------------------------ -selectAllComicsAction = new QAction(this); -selectAllComicsAction->setText(tr("Select all comics")); -selectAllComicsAction->setData(SELECT_ALL_COMICS_ACTION_YL); -selectAllComicsAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SELECT_ALL_COMICS_ACTION_YL)); -selectAllComicsAction->setIcon(QIcon(":/images/comics_view_toolbar/selectAll.png")); + //Edit comics actions------------------------------------------------------ + selectAllComicsAction = new QAction(this); + selectAllComicsAction->setText(tr("Select all comics")); + selectAllComicsAction->setData(SELECT_ALL_COMICS_ACTION_YL); + selectAllComicsAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SELECT_ALL_COMICS_ACTION_YL)); + selectAllComicsAction->setIcon(QIcon(":/images/comics_view_toolbar/selectAll.png")); -editSelectedComicsAction = new QAction(this); -editSelectedComicsAction->setText(tr("Edit")); -editSelectedComicsAction->setData(EDIT_SELECTED_COMICS_ACTION_YL); -editSelectedComicsAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(EDIT_SELECTED_COMICS_ACTION_YL)); -editSelectedComicsAction->setIcon(QIcon(":/images/comics_view_toolbar/editComic.png")); + editSelectedComicsAction = new QAction(this); + editSelectedComicsAction->setText(tr("Edit")); + editSelectedComicsAction->setData(EDIT_SELECTED_COMICS_ACTION_YL); + editSelectedComicsAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(EDIT_SELECTED_COMICS_ACTION_YL)); + editSelectedComicsAction->setIcon(QIcon(":/images/comics_view_toolbar/editComic.png")); -asignOrderAction = new QAction(this); -asignOrderAction->setText(tr("Assign current order to comics")); -asignOrderAction->setData(ASIGN_ORDER_ACTION_YL); -asignOrderAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ASIGN_ORDER_ACTION_YL)); -asignOrderAction->setIcon(QIcon(":/images/comics_view_toolbar/asignNumber.png")); + asignOrderAction = new QAction(this); + asignOrderAction->setText(tr("Assign current order to comics")); + asignOrderAction->setData(ASIGN_ORDER_ACTION_YL); + asignOrderAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ASIGN_ORDER_ACTION_YL)); + asignOrderAction->setIcon(QIcon(":/images/comics_view_toolbar/asignNumber.png")); -forceCoverExtractedAction = new QAction(this); -forceCoverExtractedAction->setText(tr("Update cover")); -forceCoverExtractedAction->setData(FORCE_COVER_EXTRACTED_ACTION_YL); -forceCoverExtractedAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(FORCE_COVER_EXTRACTED_ACTION_YL)); -forceCoverExtractedAction->setIcon(QIcon(":/images/importCover.png")); + forceCoverExtractedAction = new QAction(this); + forceCoverExtractedAction->setText(tr("Update cover")); + forceCoverExtractedAction->setData(FORCE_COVER_EXTRACTED_ACTION_YL); + forceCoverExtractedAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(FORCE_COVER_EXTRACTED_ACTION_YL)); + forceCoverExtractedAction->setIcon(QIcon(":/images/importCover.png")); -deleteComicsAction = new QAction(this); -deleteComicsAction->setText(tr("Delete selected comics")); -deleteComicsAction->setData(DELETE_COMICS_ACTION_YL); -deleteComicsAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(DELETE_COMICS_ACTION_YL)); -deleteComicsAction->setIcon(QIcon(":/images/comics_view_toolbar/trash.png")); + deleteComicsAction = new QAction(this); + deleteComicsAction->setText(tr("Delete selected comics")); + deleteComicsAction->setData(DELETE_COMICS_ACTION_YL); + deleteComicsAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(DELETE_COMICS_ACTION_YL)); + deleteComicsAction->setIcon(QIcon(":/images/comics_view_toolbar/trash.png")); -getInfoAction = new QAction(this); -getInfoAction->setData(GET_INFO_ACTION_YL); -getInfoAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(GET_INFO_ACTION_YL)); -getInfoAction->setText(tr("Download tags from Comic Vine")); -getInfoAction->setIcon(QIcon(":/images/comics_view_toolbar/getInfo.png")); -//------------------------------------------------------------------------- + getInfoAction = new QAction(this); + getInfoAction->setData(GET_INFO_ACTION_YL); + getInfoAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(GET_INFO_ACTION_YL)); + getInfoAction->setText(tr("Download tags from Comic Vine")); + getInfoAction->setIcon(QIcon(":/images/comics_view_toolbar/getInfo.png")); + //------------------------------------------------------------------------- -showEditShortcutsAction = new QAction(tr("Edit shortcuts"), this); -showEditShortcutsAction->setData(SHOW_EDIT_SHORTCUTS_ACTION_YL); -showEditShortcutsAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_EDIT_SHORTCUTS_ACTION_YL)); -showEditShortcutsAction->setShortcutContext(Qt::ApplicationShortcut); -addAction(showEditShortcutsAction); + showEditShortcutsAction = new QAction(tr("Edit shortcuts"), this); + showEditShortcutsAction->setData(SHOW_EDIT_SHORTCUTS_ACTION_YL); + showEditShortcutsAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_EDIT_SHORTCUTS_ACTION_YL)); + showEditShortcutsAction->setShortcutContext(Qt::ApplicationShortcut); + addAction(showEditShortcutsAction); -updateFolderAction = new QAction(tr("Update folder"), this); -updateFolderAction->setIcon(QIcon(":/images/menus_icons/updateLibraryIcon.png")); + updateFolderAction = new QAction(tr("Update folder"), this); + updateFolderAction->setIcon(QIcon(":/images/menus_icons/updateLibraryIcon.png")); -updateCurrentFolderAction = new QAction(tr("Update current folder"), this); -updateCurrentFolderAction->setData(UPDATE_CURRENT_FOLDER_ACTION_YL); -updateCurrentFolderAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(UPDATE_CURRENT_FOLDER_ACTION_YL)); -updateCurrentFolderAction->setIcon(QIcon(":/images/menus_icons/updateLibraryIcon.png")); + updateCurrentFolderAction = new QAction(tr("Update current folder"), this); + updateCurrentFolderAction->setData(UPDATE_CURRENT_FOLDER_ACTION_YL); + updateCurrentFolderAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(UPDATE_CURRENT_FOLDER_ACTION_YL)); + updateCurrentFolderAction->setIcon(QIcon(":/images/menus_icons/updateLibraryIcon.png")); -addReadingListAction = new QAction(tr("Add new reading list"), this); -addReadingListAction->setData(ADD_READING_LIST_ACTION_YL); -addReadingListAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ADD_READING_LIST_ACTION_YL)); -addReadingListAction->setToolTip(tr("Add a new reading list to the current library")); -addReadingListAction->setIcon(QIcon(":/images/sidebar/addNew_sidebar.png")); + addReadingListAction = new QAction(tr("Add new reading list"), this); + addReadingListAction->setData(ADD_READING_LIST_ACTION_YL); + addReadingListAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ADD_READING_LIST_ACTION_YL)); + addReadingListAction->setToolTip(tr("Add a new reading list to the current library")); + addReadingListAction->setIcon(QIcon(":/images/sidebar/addNew_sidebar.png")); -deleteReadingListAction = new QAction(tr("Remove reading list"), this); -deleteReadingListAction->setData(REMOVE_READING_LIST_ACTION_YL); -deleteReadingListAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(REMOVE_READING_LIST_ACTION_YL)); -deleteReadingListAction->setToolTip(tr("Remove current reading list from the library")); -deleteReadingListAction->setIcon(QIcon(":/images/sidebar/delete_sidebar.png")); + deleteReadingListAction = new QAction(tr("Remove reading list"), this); + deleteReadingListAction->setData(REMOVE_READING_LIST_ACTION_YL); + deleteReadingListAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(REMOVE_READING_LIST_ACTION_YL)); + deleteReadingListAction->setToolTip(tr("Remove current reading list from the library")); + deleteReadingListAction->setIcon(QIcon(":/images/sidebar/delete_sidebar.png")); -addLabelAction = new QAction(tr("Add new label"), this); -addLabelAction->setData(ADD_LABEL_ACTION_YL); -addLabelAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ADD_LABEL_ACTION_YL)); -addLabelAction->setToolTip(tr("Add a new label to this library")); -addLabelAction->setIcon(QIcon(":/images/sidebar/addLabelIcon.png")); + addLabelAction = new QAction(tr("Add new label"), this); + addLabelAction->setData(ADD_LABEL_ACTION_YL); + addLabelAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ADD_LABEL_ACTION_YL)); + addLabelAction->setToolTip(tr("Add a new label to this library")); + addLabelAction->setIcon(QIcon(":/images/sidebar/addLabelIcon.png")); -renameListAction = new QAction(tr("Rename selected list"), this); -renameListAction->setData(RENAME_LIST_ACTION_YL); -renameListAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(RENAME_LIST_ACTION_YL)); -renameListAction->setToolTip(tr("Rename any selected labels or lists")); -renameListAction->setIcon(QIcon(":/images/sidebar/renameListIcon.png")); + renameListAction = new QAction(tr("Rename selected list"), this); + renameListAction->setData(RENAME_LIST_ACTION_YL); + renameListAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(RENAME_LIST_ACTION_YL)); + renameListAction->setToolTip(tr("Rename any selected labels or lists")); + renameListAction->setIcon(QIcon(":/images/sidebar/renameListIcon.png")); -//-- -addToMenuAction = new QAction(tr("Add to..."), this); + //-- + addToMenuAction = new QAction(tr("Add to..."), this); -addToFavoritesAction = new QAction(tr("Favorites"), this); -addToFavoritesAction->setData(ADD_TO_FAVORITES_ACTION_YL); -addToFavoritesAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ADD_TO_FAVORITES_ACTION_YL)); -addToFavoritesAction->setToolTip(tr("Add selected comics to favorites list")); -addToFavoritesAction->setIcon(QIcon(":/images/lists/default_1.png")); + addToFavoritesAction = new QAction(tr("Favorites"), this); + addToFavoritesAction->setData(ADD_TO_FAVORITES_ACTION_YL); + addToFavoritesAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ADD_TO_FAVORITES_ACTION_YL)); + addToFavoritesAction->setToolTip(tr("Add selected comics to favorites list")); + addToFavoritesAction->setIcon(QIcon(":/images/lists/default_1.png")); -//actions not asigned to any widget -this->addAction(saveCoversToAction); -this->addAction(openContainingFolderAction); -this->addAction(updateCurrentFolderAction); -this->addAction(resetComicRatingAction); -this->addAction(setFolderAsCompletedAction); -this->addAction(setFolderAsNotCompletedAction); -this->addAction(setFolderAsReadAction); -this->addAction(setFolderAsUnreadAction); + //actions not asigned to any widget + this->addAction(saveCoversToAction); + this->addAction(openContainingFolderAction); + this->addAction(updateCurrentFolderAction); + this->addAction(resetComicRatingAction); + this->addAction(setFolderAsCompletedAction); + this->addAction(setFolderAsNotCompletedAction); + this->addAction(setFolderAsReadAction); + this->addAction(setFolderAsUnreadAction); #ifndef Q_OS_MAC -this->addAction(toggleFullScreenAction); + this->addAction(toggleFullScreenAction); #endif -//disable actions -disableAllActions(); + //disable actions + disableAllActions(); } void LibraryWindow::disableComicsActions(bool disabled) { @@ -2515,14 +2515,14 @@ void LibraryWindow::showFoldersContextMenu(const QPoint &point) /* void LibraryWindow::showSocial() { - socialDialog->move(this->mapToGlobal(QPoint(width()-socialDialog->width()-10, centralWidget()->pos().y()+10))); + socialDialog->move(this->mapToGlobal(QPoint(width()-socialDialog->width()-10, centralWidget()->pos().y()+10))); - QModelIndexList indexList = getSelectedComics(); + QModelIndexList indexList = getSelectedComics(); - ComicDB comic = dmCV->getComic(indexList.at(0)); + ComicDB comic = dmCV->getComic(indexList.at(0)); - socialDialog->setComic(comic,currentPath()); - socialDialog->setHidden(false); + socialDialog->setComic(comic,currentPath()); + socialDialog->setHidden(false); }*/ void LibraryWindow::libraryAlreadyExists(const QString &name) From 8f845727aeb15821acd3bc3dbf317b8312775006 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 19 Sep 2019 22:49:00 +0200 Subject: [PATCH 04/19] Fixed more merge problems --- YACReaderLibrary/options_dialog.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/YACReaderLibrary/options_dialog.h b/YACReaderLibrary/options_dialog.h index 575a0090..7ecc8511 100644 --- a/YACReaderLibrary/options_dialog.h +++ b/YACReaderLibrary/options_dialog.h @@ -34,6 +34,9 @@ private: QLabel *opacityLabel; QLabel *blurLabel; QPushButton *resetButton; + QCheckBox *displayContinueReadingBannerCheck; + QCheckBox *trayIconCheckbox; + QCheckBox *startToTrayCheckbox; }; #endif From 4377ad935c1bed24ec8b0b845f9e768ef6cd7c76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 19 Sep 2019 22:54:08 +0200 Subject: [PATCH 05/19] Fixed more merge problems --- YACReaderLibrary/options_dialog.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/YACReaderLibrary/options_dialog.cpp b/YACReaderLibrary/options_dialog.cpp index c5a46960..4ec85b8c 100644 --- a/YACReaderLibrary/options_dialog.cpp +++ b/YACReaderLibrary/options_dialog.cpp @@ -47,6 +47,24 @@ OptionsDialog::OptionsDialog(QWidget *parent) QGroupBox *trayIconBox = new QGroupBox(tr("Tray icon settings")); QVBoxLayout *trayLayout = new QVBoxLayout(); + trayIconCheckbox = new QCheckBox(tr("Minimize to tray")); + startToTrayCheckbox = new QCheckBox(tr("Start minimized")); + + connect(trayIconCheckbox, &QCheckBox::clicked, + [=](bool checked) { + settings->setValue(MINIMIZE_TO_TRAY, checked); + startToTrayCheckbox->setEnabled(checked); + emit optionsChanged(); + }); + connect(startToTrayCheckbox, &QCheckBox::clicked, + [=](bool checked) { + settings->setValue(START_TO_TRAY, checked); + }); + + trayLayout->addWidget(trayIconCheckbox); + trayLayout->addWidget(startToTrayCheckbox); + trayIconBox->setLayout(trayLayout); + auto apiKeyLayout = new QVBoxLayout(); auto apiKeyButton = new QPushButton(tr("Edit Comic Vine API key")); apiKeyLayout->addWidget(apiKeyButton); From 6031c81d81cb17d455aa3f72439e4dbcff67425b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 20 Sep 2019 10:07:20 +0200 Subject: [PATCH 06/19] Add better icons for the system tray in macos and windows I would like to design specific icons for the system tray at some point, but for now this is what we have. --- YACReaderLibrary/images_osx.qrc | 1 + YACReaderLibrary/images_win.qrc | 1 + YACReaderLibrary/library_window.cpp | 13 ++++++++++--- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/YACReaderLibrary/images_osx.qrc b/YACReaderLibrary/images_osx.qrc index 14398e66..804d8810 100644 --- a/YACReaderLibrary/images_osx.qrc +++ b/YACReaderLibrary/images_osx.qrc @@ -71,5 +71,6 @@ ../images/sidebar/delete_sidebar_osx@2x.png ../images/sidebar/addLabelIcon_osx@2x.png ../images/sidebar/renameListIcon_osx@2x.png + YACReaderLibrary.icns diff --git a/YACReaderLibrary/images_win.qrc b/YACReaderLibrary/images_win.qrc index fdb1ea0b..cb87e0cf 100644 --- a/YACReaderLibrary/images_win.qrc +++ b/YACReaderLibrary/images_win.qrc @@ -41,5 +41,6 @@ ../images/lists/label_yellow.png ../images/lists/list.png ../images/empty_reading_list.png + icon.ico diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index 21c8610c..46cb5cd1 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -143,13 +143,20 @@ void LibraryWindow::setupUI() // If a window icon was set in main() we reuse it for the tray too. // This allows support for third party icon themes on Freedesktop(Linux/Unix) // systems. - // TODO: Luis, please tweak this to your liking and add OS macros if needed. if (!QApplication::windowIcon().isNull()) { trayIcon.setIcon(QApplication::windowIcon()); } else { - // TODO: Luis: This is a placeholder. Add MacOS, Windows and maybe a fallback - // for other systems here. +#ifdef Q_OS_WIN + trayIcon.setIcon(QIcon(":/icon.ico")); +#else +#ifdef Q_OS_MACOS + auto icon = QIcon(":/YACReaderLibrary.icns"); + icon.setIsMask(true); + trayIcon.setIcon(icon); +#else trayIcon.setIcon(QIcon(":/images/iconLibrary.png")); +#endif +#endif } connect(&trayIcon, &QSystemTrayIcon::activated, From 403e6570626ead96167784b33e02442dca2975c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 20 Sep 2019 13:41:26 +0200 Subject: [PATCH 07/19] A new trayicon is needed for macos --- YACReaderLibrary/images_osx.qrc | 2 +- YACReaderLibrary/library_window.cpp | 2 +- YACReaderLibrary/macostrayicon.svg | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 YACReaderLibrary/macostrayicon.svg diff --git a/YACReaderLibrary/images_osx.qrc b/YACReaderLibrary/images_osx.qrc index 804d8810..60489bfb 100644 --- a/YACReaderLibrary/images_osx.qrc +++ b/YACReaderLibrary/images_osx.qrc @@ -71,6 +71,6 @@ ../images/sidebar/delete_sidebar_osx@2x.png ../images/sidebar/addLabelIcon_osx@2x.png ../images/sidebar/renameListIcon_osx@2x.png - YACReaderLibrary.icns + macostrayicon.svg diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index 46cb5cd1..1a1d51f7 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -150,7 +150,7 @@ void LibraryWindow::setupUI() trayIcon.setIcon(QIcon(":/icon.ico")); #else #ifdef Q_OS_MACOS - auto icon = QIcon(":/YACReaderLibrary.icns"); + auto icon = QIcon(":/macostrayicon.svg"); icon.setIsMask(true); trayIcon.setIcon(icon); #else diff --git a/YACReaderLibrary/macostrayicon.svg b/YACReaderLibrary/macostrayicon.svg new file mode 100644 index 00000000..bf3c3f7d --- /dev/null +++ b/YACReaderLibrary/macostrayicon.svg @@ -0,0 +1 @@ +Artboard 1 \ No newline at end of file From 63e16e44b7b868a6325729bd08378873066866e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 20 Sep 2019 16:38:11 +0200 Subject: [PATCH 08/19] Better macos tray icon --- YACReaderLibrary/macostrayicon.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YACReaderLibrary/macostrayicon.svg b/YACReaderLibrary/macostrayicon.svg index bf3c3f7d..03d3446f 100644 --- a/YACReaderLibrary/macostrayicon.svg +++ b/YACReaderLibrary/macostrayicon.svg @@ -1 +1 @@ -Artboard 1 \ No newline at end of file +macostrayicon \ No newline at end of file From 80cd4f64f8dfaa94eabaa15cbf33bd12c8971c51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sat, 21 Sep 2019 10:42:15 +0200 Subject: [PATCH 09/19] Rename setting We are going to use close to system tray instead of minimize, easier to handle it at a crossplatform level --- common/yacreader_global_gui.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/yacreader_global_gui.h b/common/yacreader_global_gui.h index df8af780..06c9e52a 100644 --- a/common/yacreader_global_gui.h +++ b/common/yacreader_global_gui.h @@ -17,7 +17,7 @@ #define FULLSCREEN "FULLSCREEN" #define Y_WINDOW_GEOMETRY "GEOMETRY" #define MAXIMIZED "MAXIMIZED" -#define MINIMIZE_TO_TRAY "MINIMIZE_TO_TRAY" +#define CLOSE_TO_TRAY "CLOSE_TO_TRAY" #define START_TO_TRAY "START_TO_TRAY" #define DOUBLE_PAGE "DOUBLE_PAGE" #define DOUBLE_MANGA_PAGE "DOUBLE_MANGA_PAGE" From 3923da2344bd3beecd13551abc0990a595167d9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sat, 21 Sep 2019 10:42:38 +0200 Subject: [PATCH 10/19] Add new define to remember if we have notified the user about close to tray --- common/yacreader_global_gui.h | 1 + 1 file changed, 1 insertion(+) diff --git a/common/yacreader_global_gui.h b/common/yacreader_global_gui.h index 06c9e52a..94a876ea 100644 --- a/common/yacreader_global_gui.h +++ b/common/yacreader_global_gui.h @@ -18,6 +18,7 @@ #define Y_WINDOW_GEOMETRY "GEOMETRY" #define MAXIMIZED "MAXIMIZED" #define CLOSE_TO_TRAY "CLOSE_TO_TRAY" +#define CLOSE_TO_TRAY_NOTIFIED "CLOSE_TO_TRAY_NOTIFIED" #define START_TO_TRAY "START_TO_TRAY" #define DOUBLE_PAGE "DOUBLE_PAGE" #define DOUBLE_MANGA_PAGE "DOUBLE_MANGA_PAGE" From b5f37997533793ae53773c58e33fa308a76bbf96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sat, 21 Sep 2019 10:44:03 +0200 Subject: [PATCH 11/19] Restore the code to start the app into the system tray --- YACReaderLibrary/main.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/YACReaderLibrary/main.cpp b/YACReaderLibrary/main.cpp index 966e6efc..62f68584 100644 --- a/YACReaderLibrary/main.cpp +++ b/YACReaderLibrary/main.cpp @@ -245,7 +245,15 @@ int main(int argc, char **argv) //connections to localServer - mw->show(); + // start as tray + if (!settings->value(START_TO_TRAY, false).toBool() || !settings->value(CLOSE_TO_TRAY, false).toBool()) { + mw->show(); + } +#ifdef Q_OS_MACOS + else { + OSXHideDockIcon(); + } +#endif int ret = app.exec(); From 5b78ef2dae5b64ccc6c4850db70b5d4d9099ded5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sat, 21 Sep 2019 10:44:28 +0200 Subject: [PATCH 12/19] Use new property name and set false as default --- YACReaderLibrary/options_dialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/YACReaderLibrary/options_dialog.cpp b/YACReaderLibrary/options_dialog.cpp index 4ec85b8c..11d4e1be 100644 --- a/YACReaderLibrary/options_dialog.cpp +++ b/YACReaderLibrary/options_dialog.cpp @@ -52,7 +52,7 @@ OptionsDialog::OptionsDialog(QWidget *parent) connect(trayIconCheckbox, &QCheckBox::clicked, [=](bool checked) { - settings->setValue(MINIMIZE_TO_TRAY, checked); + settings->setValue(CLOSE_TO_TRAY, checked); startToTrayCheckbox->setEnabled(checked); emit optionsChanged(); }); @@ -168,7 +168,7 @@ void OptionsDialog::restoreOptions(QSettings *settings) { YACReaderOptionsDialog::restoreOptions(settings); - trayIconCheckbox->setChecked(settings->value(MINIMIZE_TO_TRAY, true).toBool()); + trayIconCheckbox->setChecked(settings->value(CLOSE_TO_TRAY, false).toBool()); startToTrayCheckbox->setChecked(settings->value(START_TO_TRAY, false).toBool()); startToTrayCheckbox->setEnabled(trayIconCheckbox->isChecked()); From 3c07e7269a437fb3d31dc2fcb997be75181f1600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sat, 21 Sep 2019 10:45:34 +0200 Subject: [PATCH 13/19] Update the UI string about system tray support --- YACReaderLibrary/options_dialog.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/YACReaderLibrary/options_dialog.cpp b/YACReaderLibrary/options_dialog.cpp index 11d4e1be..432273a8 100644 --- a/YACReaderLibrary/options_dialog.cpp +++ b/YACReaderLibrary/options_dialog.cpp @@ -44,11 +44,11 @@ OptionsDialog::OptionsDialog(QWidget *parent) sw->hide(); #endif // Tray icon settings - QGroupBox *trayIconBox = new QGroupBox(tr("Tray icon settings")); + QGroupBox *trayIconBox = new QGroupBox(tr("Tray icon settings (experimental)")); QVBoxLayout *trayLayout = new QVBoxLayout(); - trayIconCheckbox = new QCheckBox(tr("Minimize to tray")); - startToTrayCheckbox = new QCheckBox(tr("Start minimized")); + trayIconCheckbox = new QCheckBox(tr("Close to tray")); + startToTrayCheckbox = new QCheckBox(tr("Start into the system tray")); connect(trayIconCheckbox, &QCheckBox::clicked, [=](bool checked) { From 8e99d9e59fa634a8743b731bb2b73b1a25695e3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sat, 21 Sep 2019 10:47:01 +0200 Subject: [PATCH 14/19] Extract the system tray functionality to its own class LibraryWindow is already a monster, so we'll try to not make it bigger. --- YACReaderLibrary/YACReaderLibrary.pro | 3 + YACReaderLibrary/library_window.cpp | 61 ++++++-------- YACReaderLibrary/library_window.h | 10 ++- YACReaderLibrary/trayicon_controller.cpp | 100 +++++++++++++++++++++++ YACReaderLibrary/trayicon_controller.h | 34 ++++++++ 5 files changed, 167 insertions(+), 41 deletions(-) create mode 100644 YACReaderLibrary/trayicon_controller.cpp create mode 100644 YACReaderLibrary/trayicon_controller.h diff --git a/YACReaderLibrary/YACReaderLibrary.pro b/YACReaderLibrary/YACReaderLibrary.pro index c1365c47..cf53e885 100644 --- a/YACReaderLibrary/YACReaderLibrary.pro +++ b/YACReaderLibrary/YACReaderLibrary.pro @@ -13,6 +13,7 @@ INCLUDEPATH += . \ ./comic_vine/model DEFINES += SERVER_RELEASE NOMINMAX YACREADER_LIBRARY +QMAKE_MAC_SDK = macosx10.15 # load default build flags include (../config.pri) @@ -115,6 +116,7 @@ HEADERS += comic_flow.h \ ../common/pdf_comic.h \ no_libraries_widget.h \ import_widget.h \ + trayicon_controller.h \ yacreader_local_server.h \ yacreader_main_toolbar.h \ comics_remover.h \ @@ -184,6 +186,7 @@ SOURCES += comic_flow.cpp \ ../common/onstart_flow_selection_dialog.cpp \ no_libraries_widget.cpp \ import_widget.cpp \ + trayicon_controller.cpp \ yacreader_local_server.cpp \ yacreader_main_toolbar.cpp \ comics_remover.cpp \ diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index 1a1d51f7..21b2e81a 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -81,14 +81,15 @@ #include "yacreader_comics_views_manager.h" +#include "trayicon_controller.h" + #include "QsLog.h" #ifdef Q_OS_WIN #include #endif -#ifdef Q_OS_MACOS -#include "trayhandler.h" -#endif + +using namespace YACReader; LibraryWindow::LibraryWindow() : QMainWindow(), fullscreen(false), previousFilter(""), fetching(false), status(LibraryWindow::Normal), removeError(false) @@ -140,50 +141,26 @@ void LibraryWindow::setupUI() //if(settings->value(USE_OPEN_GL).toBool() == false) showMaximized(); - // If a window icon was set in main() we reuse it for the tray too. - // This allows support for third party icon themes on Freedesktop(Linux/Unix) - // systems. - if (!QApplication::windowIcon().isNull()) { - trayIcon.setIcon(QApplication::windowIcon()); - } else { -#ifdef Q_OS_WIN - trayIcon.setIcon(QIcon(":/icon.ico")); -#else -#ifdef Q_OS_MACOS - auto icon = QIcon(":/macostrayicon.svg"); - icon.setIsMask(true); - trayIcon.setIcon(icon); -#else - trayIcon.setIcon(QIcon(":/images/iconLibrary.png")); -#endif -#endif - } - - connect(&trayIcon, &QSystemTrayIcon::activated, - [=](QSystemTrayIcon::ActivationReason reason) { - if (reason == QSystemTrayIcon::Trigger) { -#ifdef Q_OS_MACOS - OSXShowDockIcon(); -#endif - setWindowState((windowState() & ~Qt::WindowMinimized) | Qt::WindowActive); - show(); - } - }); - trayIcon.setVisible(settings->value(MINIMIZE_TO_TRAY, true).toBool()); + trayIconController = new TrayIconController(settings, this); } -void LibraryWindow::changeEvent(QEvent *event) +/*void LibraryWindow::changeEvent(QEvent *event) { + QMainWindow::changeEvent(event); + if (event->type() == QEvent::WindowStateChange && isMinimized() && trayIcon.isVisible()) { #ifdef Q_OS_MACOS OSXHideDockIcon(); #endif hide(); - return; + } else if (event->type() == QEvent::WindowStateChange) { +#ifdef Q_OS_MACOS + OSXShowDockIcon(); +#endif + show(); } - QMainWindow::changeEvent(event); -} +}*/ void LibraryWindow::doLayout() { @@ -2297,8 +2274,9 @@ void LibraryWindow::importLibrary(QString clc, QString destPath, QString name) void LibraryWindow::reloadOptions() { - //comicFlow->setFlowType(flowType); comicsViewsManager->comicsView->updateConfig(settings); + + trayIconController->updateIconVisibility(); } QString LibraryWindow::currentPath() @@ -2334,6 +2312,13 @@ void LibraryWindow::showImportComicsInfo() #include "startup.h" extern Startup *s; void LibraryWindow::closeEvent(QCloseEvent *event) +{ + if (!trayIconController->handleCloseToTrayIcon(event)) { + closeApp(event); + } +} + +void LibraryWindow::closeApp(QCloseEvent *event) { s->stop(); settings->setValue(MAIN_WINDOW_GEOMETRY, saveGeometry()); diff --git a/YACReaderLibrary/library_window.h b/YACReaderLibrary/library_window.h index c934946e..3d557fc3 100644 --- a/YACReaderLibrary/library_window.h +++ b/YACReaderLibrary/library_window.h @@ -5,7 +5,6 @@ #include #include #include -#include #include "yacreader_global_gui.h" #include "yacreader_libraries.h" @@ -77,6 +76,10 @@ class EmptySpecialListWidget; class EmptyReadingListWidget; class YACReaderComicsViewsManager; +namespace YACReader { +class TrayIconController; +} + #include "comic_db.h" using namespace YACReader; @@ -385,7 +388,7 @@ public slots: void checkMaxNumLibraries(); void showErrorUpgradingLibrary(const QString &path); - void changeEvent(QEvent *event); + void closeApp(QCloseEvent *event); private: //fullscreen mode in Windows for preventing this bug: QTBUG-41309 https://bugreports.qt.io/browse/QTBUG-41309 @@ -393,7 +396,8 @@ private: QPoint previousPos; QSize previousSize; std::future upgradeLibraryFuture; - QSystemTrayIcon trayIcon; + + TrayIconController *trayIconController; }; #endif diff --git a/YACReaderLibrary/trayicon_controller.cpp b/YACReaderLibrary/trayicon_controller.cpp new file mode 100644 index 00000000..208d6b1c --- /dev/null +++ b/YACReaderLibrary/trayicon_controller.cpp @@ -0,0 +1,100 @@ +#include "trayicon_controller.h" + +#include "yacreader_global_gui.h" + +#include +#include + +#ifdef Q_OS_MACOS +#include "trayhandler.h" +#endif + +using namespace YACReader; + +TrayIconController::TrayIconController(QSettings *settings, QMainWindow *window) + : QObject(nullptr), settings(settings), window(window) +{ + + // If a window icon was set in main() we reuse it for the tray too. + // This allows support for third party icon themes on Freedesktop(Linux/Unix) + // systems. + if (!QApplication::windowIcon().isNull()) { + trayIcon.setIcon(QApplication::windowIcon()); + } else { +#ifdef Q_OS_WIN + trayIcon.setIcon(QIcon(":/icon.ico")); +#else +#ifdef Q_OS_MACOS + auto icon = QIcon(":/macostrayicon.svg"); + icon.setIsMask(true); + trayIcon.setIcon(icon); +#else + trayIcon.setIcon(QIcon(":/images/iconLibrary.png")); +#endif +#endif + } + + connect(&trayIcon, &QSystemTrayIcon::activated, + [=](QSystemTrayIcon::ActivationReason reason) { + if (reason == QSystemTrayIcon::DoubleClick) { + showWindow(); + } + }); + + updateIconVisibility(); + + auto restoreAction = new QAction(tr("&Restore"), this); + connect(restoreAction, &QAction::triggered, this, &TrayIconController::showWindow); + + auto quitAction = new QAction(tr("&Quit"), this); + connect(quitAction, &QAction::triggered, window, &QMainWindow::close); + + trayIconMenu = new QMenu(this->window); + trayIconMenu->addAction(restoreAction); + trayIconMenu->addSeparator(); + trayIconMenu->addAction(quitAction); + + trayIcon.setContextMenu(trayIconMenu); +} + +void TrayIconController::updateIconVisibility() +{ + trayIcon.setVisible(settings->value(CLOSE_TO_TRAY, false).toBool()); +} + +bool TrayIconController::handleCloseToTrayIcon(QCloseEvent *event) +{ +#ifdef Q_OS_OSX + if (!event->spontaneous() || !window->isVisible()) { + return false; + } +#endif + if (trayIcon.isVisible()) { + if (!settings->value(CLOSE_TO_TRAY_NOTIFIED, false).toBool()) { + QMessageBox::information(window, tr("Systray"), + tr("YACReaderLibrary will keep running in the " + "system tray. To terminate the program, " + "choose Quit in the context menu " + "of the system tray icon.")); + settings->setValue(CLOSE_TO_TRAY_NOTIFIED, true); + } +#ifdef Q_OS_OSX + OSXHideDockIcon(); +#endif + window->hide(); + event->ignore(); + return true; + } else { + return false; + } +} + +void TrayIconController::showWindow() +{ +#ifdef Q_OS_MACOS + OSXShowDockIcon(); +#endif + window->showNormal(); + window->raise(); // for MacOS + window->activateWindow(); // for Windows +} diff --git a/YACReaderLibrary/trayicon_controller.h b/YACReaderLibrary/trayicon_controller.h new file mode 100644 index 00000000..649121ba --- /dev/null +++ b/YACReaderLibrary/trayicon_controller.h @@ -0,0 +1,34 @@ +#ifndef TRAYICON_CONTROLLER_H +#define TRAYICON_CONTROLLER_H + +#include +#include + +namespace YACReader { + +class TrayIconController : public QObject +{ + Q_OBJECT +public: + TrayIconController(QSettings *settings, + QMainWindow *window); + + void updateIconVisibility(); + + bool handleCloseToTrayIcon(QCloseEvent *event); + + QSystemTrayIcon trayIcon; + +public slots: + void showWindow(); + +private: + QSettings *settings; + QMainWindow *window; + + QMenu *trayIconMenu; +}; + +} + +#endif // TRAYICON_CONTROLLER_H From 7ac331ed419caa955a5a3a5c99877bce0dc0bbbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sat, 21 Sep 2019 11:06:51 +0200 Subject: [PATCH 15/19] Do not force macos sdk for now This was commited by mistake --- YACReaderLibrary/YACReaderLibrary.pro | 1 - 1 file changed, 1 deletion(-) diff --git a/YACReaderLibrary/YACReaderLibrary.pro b/YACReaderLibrary/YACReaderLibrary.pro index cf53e885..b39293fc 100644 --- a/YACReaderLibrary/YACReaderLibrary.pro +++ b/YACReaderLibrary/YACReaderLibrary.pro @@ -13,7 +13,6 @@ INCLUDEPATH += . \ ./comic_vine/model DEFINES += SERVER_RELEASE NOMINMAX YACREADER_LIBRARY -QMAKE_MAC_SDK = macosx10.15 # load default build flags include (../config.pri) From ef8216b338b6335bdd7e4ce5a460094ac39fb531 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sat, 21 Sep 2019 12:11:03 +0200 Subject: [PATCH 16/19] Make closeApp work with no event And exit using QApplication.exit so we don't mess with window events to exit the app --- YACReaderLibrary/library_window.cpp | 14 ++++++++++---- YACReaderLibrary/library_window.h | 3 ++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index 21b2e81a..7d6c8967 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -2314,11 +2314,12 @@ extern Startup *s; void LibraryWindow::closeEvent(QCloseEvent *event) { if (!trayIconController->handleCloseToTrayIcon(event)) { - closeApp(event); + event->accept(); + closeApp(); } } -void LibraryWindow::closeApp(QCloseEvent *event) +void LibraryWindow::prepareToCloseApp() { s->stop(); settings->setValue(MAIN_WINDOW_GEOMETRY, saveGeometry()); @@ -2327,8 +2328,13 @@ void LibraryWindow::closeApp(QCloseEvent *event) sideBar->close(); QApplication::instance()->processEvents(); - event->accept(); - QMainWindow::closeEvent(event); +} + +void LibraryWindow::closeApp() +{ + prepareToCloseApp(); + + qApp->exit(0); } void LibraryWindow::showNoLibrariesWidget() diff --git a/YACReaderLibrary/library_window.h b/YACReaderLibrary/library_window.h index 3d557fc3..993b58b9 100644 --- a/YACReaderLibrary/library_window.h +++ b/YACReaderLibrary/library_window.h @@ -388,7 +388,8 @@ public slots: void checkMaxNumLibraries(); void showErrorUpgradingLibrary(const QString &path); - void closeApp(QCloseEvent *event); + void prepareToCloseApp(); + void closeApp(); private: //fullscreen mode in Windows for preventing this bug: QTBUG-41309 https://bugreports.qt.io/browse/QTBUG-41309 From 674fa21717a3b7b925640f4fd97d7261e8af25dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sat, 21 Sep 2019 12:11:39 +0200 Subject: [PATCH 17/19] Pass a more specific instance of our main window --- YACReaderLibrary/trayicon_controller.cpp | 4 +++- YACReaderLibrary/trayicon_controller.h | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/YACReaderLibrary/trayicon_controller.cpp b/YACReaderLibrary/trayicon_controller.cpp index 208d6b1c..601b98ad 100644 --- a/YACReaderLibrary/trayicon_controller.cpp +++ b/YACReaderLibrary/trayicon_controller.cpp @@ -2,6 +2,8 @@ #include "yacreader_global_gui.h" +#include "library_window.h" + #include #include @@ -11,7 +13,7 @@ using namespace YACReader; -TrayIconController::TrayIconController(QSettings *settings, QMainWindow *window) +TrayIconController::TrayIconController(QSettings *settings, LibraryWindow *window) : QObject(nullptr), settings(settings), window(window) { diff --git a/YACReaderLibrary/trayicon_controller.h b/YACReaderLibrary/trayicon_controller.h index 649121ba..1ff9d407 100644 --- a/YACReaderLibrary/trayicon_controller.h +++ b/YACReaderLibrary/trayicon_controller.h @@ -4,6 +4,8 @@ #include #include +class LibraryWindow; + namespace YACReader { class TrayIconController : public QObject @@ -11,7 +13,7 @@ class TrayIconController : public QObject Q_OBJECT public: TrayIconController(QSettings *settings, - QMainWindow *window); + LibraryWindow *window); void updateIconVisibility(); @@ -24,7 +26,7 @@ public slots: private: QSettings *settings; - QMainWindow *window; + LibraryWindow *window; QMenu *trayIconMenu; }; From 9fafa0606364fa8b892a6742850f8b872173609d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sat, 21 Sep 2019 12:11:56 +0200 Subject: [PATCH 18/19] Move call forward --- YACReaderLibrary/trayicon_controller.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/YACReaderLibrary/trayicon_controller.cpp b/YACReaderLibrary/trayicon_controller.cpp index 601b98ad..724e6b4e 100644 --- a/YACReaderLibrary/trayicon_controller.cpp +++ b/YACReaderLibrary/trayicon_controller.cpp @@ -43,8 +43,6 @@ TrayIconController::TrayIconController(QSettings *settings, LibraryWindow *windo } }); - updateIconVisibility(); - auto restoreAction = new QAction(tr("&Restore"), this); connect(restoreAction, &QAction::triggered, this, &TrayIconController::showWindow); @@ -57,6 +55,8 @@ TrayIconController::TrayIconController(QSettings *settings, LibraryWindow *windo trayIconMenu->addAction(quitAction); trayIcon.setContextMenu(trayIconMenu); + + updateIconVisibility(); } void TrayIconController::updateIconVisibility() From fc85f77d159147c23e99fe622c2a5f1eac1d981f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sat, 21 Sep 2019 12:12:19 +0200 Subject: [PATCH 19/19] Use LibraryWindow::closeApp to exit from the system tray context menu --- YACReaderLibrary/trayicon_controller.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YACReaderLibrary/trayicon_controller.cpp b/YACReaderLibrary/trayicon_controller.cpp index 724e6b4e..b2098d9c 100644 --- a/YACReaderLibrary/trayicon_controller.cpp +++ b/YACReaderLibrary/trayicon_controller.cpp @@ -47,7 +47,7 @@ TrayIconController::TrayIconController(QSettings *settings, LibraryWindow *windo connect(restoreAction, &QAction::triggered, this, &TrayIconController::showWindow); auto quitAction = new QAction(tr("&Quit"), this); - connect(quitAction, &QAction::triggered, window, &QMainWindow::close); + connect(quitAction, &QAction::triggered, window, &LibraryWindow::closeApp); trayIconMenu = new QMenu(this->window); trayIconMenu->addAction(restoreAction);