Changes: * Fix close on KDE * Replace "minimize to tray" feature to "close to tray" * Add systemtrayicon menu with "exit" item clipgrab_hu.ts | 13 +++++++++---- mainwindow.cpp | 52 ++++++++++++++++++++++++++++++++++++++-------------- mainwindow.h | 4 +++- mainwindow.ui | 2 +- 4 files changed, 51 insertions(+), 20 deletions(-) diff --git a/clipgrab_hu.ts b/clipgrab_hu.ts index 443ec2c..63b3521 100644 --- a/clipgrab_hu.ts +++ b/clipgrab_hu.ts @@ -58,6 +58,11 @@ </context> <context> <name>MainWindow</name> + <message> + <location filename="mainwindow.cpp" line="73"/> + <source>Exit</source> + <translation>Kilépés</translation> + </message> <message> <location filename="mainwindow.cpp" line="253"/> <source>Select Target</source> @@ -475,9 +480,9 @@ <translation>Befejezett letöltések eltávolítása a listáról</translation> </message> <message> - <location filename="mainwindow.ui" line="777"/> - <source>Minimize ClipGrab to the system tray</source> - <translation>ClipGrab küldése tálcára kicsinyítéskor</translation> + <location filename="mainwindow.ui" line="776"/> + <source>Hide ClipGrab to the system tray on close button</source> + <translation>ClipGrab küldése tálcára bezáráskor</translation> </message> <message> <location filename="mainwindow.ui" line="784"/> @@ -986,7 +991,7 @@ Nagy felbontású videók letöltése így nem lehetséges.</translation> <message> <location filename="video_youtube.cpp" line="163"/> <source>8K (4320p60)</source> - <translation type="unfinished"></translation> + <translation>8K (4320p60)</translation> </message> <message> <location filename="video_youtube.cpp" line="481"/> diff --git a/mainwindow.cpp b/mainwindow.cpp index dac0e92..77d9b38 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -51,6 +51,15 @@ void MainWindow::init() connect(&systemTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(systemTrayIconActivated(QSystemTrayIcon::ActivationReason))); connect(&systemTrayIcon, SIGNAL(messageClicked()), this, SLOT(systemTrayMessageClicked())); + //* + //* Tray Icon Menu + //* + trayMenu = new QMenu(this); + actionClose = new QAction(tr("Exit"), this); + connect(actionClose, SIGNAL(triggered()), this, SLOT(trayClose())); + trayMenu->addAction(actionClose); + systemTrayIcon.setContextMenu(trayMenu); + //* //* Clipboard Handling //* @@ -557,15 +566,21 @@ void MainWindow::on_settingsNeverAskForPath_stateChanged(int state) } } - void MainWindow::closeEvent(QCloseEvent *event) +void MainWindow::closeEvent(QCloseEvent *event) { - if (cg->downloadsRunning() > 0) + if (cg->settings.value("MinimizeToTray", true).toBool()) + { + QTimer::singleShot(500, this, SLOT(hide())); + event->ignore(); + } + else if (cg->downloadsRunning() > 0) { QMessageBox* exitBox; exitBox = new QMessageBox(QMessageBox::Question, tr("ClipGrab - Exit confirmation"), tr("There is still at least one download in progress.<br />If you exit the program now, all downloads will be canceled and cannot be recovered later.<br />Do you really want to quit ClipGrab now?"), QMessageBox::Yes|QMessageBox::No); if (exitBox->exec() == QMessageBox::Yes) { cg->cancelAll(); + systemTrayIcon.hide(); event->accept(); } else @@ -575,10 +590,31 @@ void MainWindow::on_settingsNeverAskForPath_stateChanged(int state) } else { + systemTrayIcon.hide(); event->accept();; } } + void MainWindow::trayClose() + { + if (cg->downloadsRunning() > 0) + { + QMessageBox* exitBox; + exitBox = new QMessageBox(QMessageBox::Question, tr("ClipGrab - Exit confirmation"), tr("There is still at least one download in progress.<br />If you exit the program now, all downloads will be canceled and cannot be recovered later.<br />Do you really want to quit ClipGrab now?"), QMessageBox::Yes|QMessageBox::No); + if (exitBox->exec() == QMessageBox::Yes) + { + cg->cancelAll(); + systemTrayIcon.hide(); + qApp->quit(); + } + } + else + { + systemTrayIcon.hide(); + qApp->quit(); + } + } + void MainWindow::settingsNotifications_toggled(bool) { if (ui.settingsRadioNotificationsAlways->isChecked()) @@ -684,18 +720,6 @@ void MainWindow::timerEvent(QTimerEvent *) } } -void MainWindow::changeEvent(QEvent* event) -{ - if (event->type() == QEvent::WindowStateChange) - { - if (isMinimized() && cg->settings.value("MinimizeToTray", false).toBool()) - { - QTimer::singleShot(500, this, SLOT(hide())); - event->ignore(); - } - } -} - void MainWindow::on_settingsMinimizeToTray_stateChanged(int state) { if (state == Qt::Checked) diff --git a/mainwindow.h b/mainwindow.h index 5beaabe..24a4cb6 100755 --- a/mainwindow.h +++ b/mainwindow.h @@ -97,7 +97,6 @@ private: void disableDownloadTreeButtons(bool disable=true); void closeEvent(QCloseEvent* event); void timerEvent(QTimerEvent*); - void changeEvent(QEvent *); QNetworkAccessManager* searchNam; QNetworkReply* searchReply; void dragEnterEvent(QDragEnterEvent *event); @@ -105,6 +104,8 @@ private: bool updatingComboQuality; SearchWebEnginePage* searchPage; SearchWebEnginePage* searchResultPage; + QAction* actionClose; + QMenu* trayMenu; private slots: void on_mainTab_currentChanged(int index); @@ -118,6 +119,7 @@ private slots: void on_settingsRemoveFinishedDownloads_stateChanged(int ); void on_downloadTree_currentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous); void systemTrayMessageClicked(); + void trayClose(); void systemTrayIconActivated(QSystemTrayIcon::ActivationReason); void on_downloadOpen_clicked(); void on_settingsSaveLastPath_stateChanged(int ); diff --git a/mainwindow.ui b/mainwindow.ui index 3e452ab..c0cf1fa 100755 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -774,7 +774,7 @@ padding: 10px; <item row="6" column="0"> <widget class="QCheckBox" name="settingsMinimizeToTray"> <property name="text"> - <string>Minimize ClipGrab to the system tray</string> + <string>Hide ClipGrab to the system tray on close button</string> </property> </widget> </item>