Skip to content

Commit

Permalink
fix: don't show tray message twice
Browse files Browse the repository at this point in the history
  • Loading branch information
FrzMtrsprt committed Feb 25, 2023
1 parent e981a17 commit 880f383
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
13 changes: 9 additions & 4 deletions QtScrcpy/ui/dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,15 @@ void Dialog::slotActivated(QSystemTrayIcon::ActivationReason reason)
void Dialog::closeEvent(QCloseEvent *event)
{
this->hide();
m_hideIcon->showMessage(tr("Notice"),
tr("Hidden here!"),
QSystemTrayIcon::Information,
3000);
UserBootConfig config = Config::getInstance().getUserBootConfig();
if (!config.trayMessageShown) {
config.trayMessageShown = true;
m_hideIcon->showMessage(tr("Notice"),
tr("Hidden here!"),
QSystemTrayIcon::Information,
3000);
}
Config::getInstance().setUserBootConfig(config);
event->ignore();
}

Expand Down
5 changes: 5 additions & 0 deletions QtScrcpy/util/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@
#define COMMON_AUTO_UPDATE_DEVICE_KEY "AutoUpdateDevice"
#define COMMON_AUTO_UPDATE_DEVICE_DEF true

#define COMMON_TRAY_MESSAGE_SHOWN_KEY "TrayMessageShown"
#define COMMON_TRAY_MESSAGE_SHOWN_DEF false

// device config
#define SERIAL_WINDOW_RECT_KEY_X "WindowRectX"
#define SERIAL_WINDOW_RECT_KEY_Y "WindowRectY"
Expand Down Expand Up @@ -160,6 +163,7 @@ void Config::setUserBootConfig(const UserBootConfig &config)
m_userData->setValue(COMMON_KEEP_ALIVE_KEY, config.keepAlive);
m_userData->setValue(COMMON_SIMPLE_MODE_KEY, config.simpleMode);
m_userData->setValue(COMMON_AUTO_UPDATE_DEVICE_KEY, config.autoUpdateDevice);
m_userData->setValue(COMMON_TRAY_MESSAGE_SHOWN_KEY, config.trayMessageShown);
m_userData->endGroup();
m_userData->sync();
}
Expand All @@ -183,6 +187,7 @@ UserBootConfig Config::getUserBootConfig()
config.keepAlive = m_userData->value(COMMON_KEEP_ALIVE_KEY, COMMON_KEEP_ALIVE_DEF).toBool();
config.simpleMode = m_userData->value(COMMON_SIMPLE_MODE_KEY, COMMON_SIMPLE_MODE_DEF).toBool();
config.autoUpdateDevice = m_userData->value(COMMON_AUTO_UPDATE_DEVICE_KEY, COMMON_AUTO_UPDATE_DEVICE_DEF).toBool();
config.trayMessageShown = m_userData->value(COMMON_TRAY_MESSAGE_SHOWN_KEY, COMMON_TRAY_MESSAGE_SHOWN_DEF).toBool();
m_userData->endGroup();
return config;
}
Expand Down
1 change: 1 addition & 0 deletions QtScrcpy/util/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ struct UserBootConfig
bool keepAlive = false;
bool simpleMode = false;
bool autoUpdateDevice = true;
bool trayMessageShown = false;
};

class QSettings;
Expand Down

0 comments on commit 880f383

Please sign in to comment.