Skip to content

Commit

Permalink
fix bugs when close window
Browse files Browse the repository at this point in the history
  • Loading branch information
renhaofan committed Jan 15, 2022
1 parent 3a0257a commit 29ff94b
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions imageviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ ImageViewer::ImageViewer(QWidget *parent) :
trayMenu = new QMenu;
systemTray = new QSystemTrayIcon;
systemTray->setIcon(*icon);
systemTray->setToolTip("Rangemap Visualization"); // context help
systemTray->setToolTip("RangeMap Visualization"); // context help
minimumAct = new QAction("Minimum Window");
maximumAct = new QAction("Maximum Window");
restoreAct = new QAction("Display");
Expand All @@ -90,7 +90,7 @@ ImageViewer::ImageViewer(QWidget *parent) :
systemTray->show();

setWindowIcon(*icon);
setWindowTitle(tr("Rangemap Visualization"));
setWindowTitle(tr("RangeMap Visualization"));
resize(1000, 400);


Expand Down Expand Up @@ -485,16 +485,12 @@ void ImageViewer::wheelEvent(QWheelEvent *event)

void ImageViewer::closeEvent(QCloseEvent *event)
{
//! if menu bar exit triggered, exit program, not hide
if (exitAct->isChecked())
if (systemTray->isVisible())
{
if (systemTray->isVisible())
{
hide();
// display 3 seconds
systemTray->showMessage(QString("Tray mode"), QString("Running in tray mode"), QSystemTrayIcon::Information, 3000);
event->ignore();
}
hide();
// display 500ms
systemTray->showMessage(QString("Tray mode"), QString("Running in tray mode"), QSystemTrayIcon::Information, 500);
event->ignore();
}
}

Expand Down Expand Up @@ -562,6 +558,7 @@ void ImageViewer::on_actionSaveAs_triggered()
void ImageViewer::on_actionAbout_triggered() {
// text with html, <br> instead of \n
QString info;
info += "Version: 2.1<br>";
info += "Author: Steve Canvas<br>";
info += "Emails: [email protected]<br>";
info += "<a href='https://github.com/renhaofan/colormap/'>Github Repo</a>";
Expand Down

0 comments on commit 29ff94b

Please sign in to comment.