Skip to content

Commit

Permalink
Fix HideToTray checkbox not being synced properly with database at bo…
Browse files Browse the repository at this point in the history
…ot (#691)
  • Loading branch information
zjeffer committed Sep 1, 2024
1 parent bf09354 commit c0b68c2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ MainWindow::MainWindow(QWidget *parent)
m_userLicenseKey(QStringLiteral("")),
m_mainMenu(nullptr),
m_buyOrManageSubscriptionAction(new QAction(this)),
m_hideToTrayAction(nullptr),
m_checkUpdatesTimer(new QTimer(this))
{
ui->setupUi(this);
Expand Down Expand Up @@ -1790,6 +1791,7 @@ void MainWindow::restoreStates()
.toBool());

setHideToTray(m_settingsDatabase->value(QStringLiteral("hideToTray"), true).toBool());
m_hideToTrayAction->setChecked(m_hideToTray);
if (m_hideToTray) {
setupTrayIcon();
}
Expand Down Expand Up @@ -2177,13 +2179,9 @@ void MainWindow::setupGlobalSettingsMenu()
autostartAction->setChecked(m_autostart.isAutostart());

// hide to tray
QAction *hideToTrayAction = m_mainMenu.addAction(tr("&Hide to tray"));
connect(hideToTrayAction, &QAction::triggered, this, [=]() {
m_settingsDatabase->setValue(QStringLiteral("hideToTray"), hideToTrayAction->isChecked());
});
hideToTrayAction->setCheckable(true);
hideToTrayAction->setChecked(m_hideToTray);
connect(hideToTrayAction, &QAction::triggered, this, [this]() {
m_hideToTrayAction = m_mainMenu.addAction(tr("&Hide to tray"));
m_hideToTrayAction->setCheckable(true);
connect(m_hideToTrayAction, &QAction::triggered, this, [this]() {
setHideToTray(!m_hideToTray);
if (m_hideToTray) {
setupTrayIcon();
Expand Down
1 change: 1 addition & 0 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ public slots:
QString m_userLicenseKey;
QMenu m_mainMenu;
QAction *m_buyOrManageSubscriptionAction;
QAction *m_hideToTrayAction;
QTimer m_checkUpdatesTimer;

bool alreadyAppliedFormat(const QString &formatChars);
Expand Down

0 comments on commit c0b68c2

Please sign in to comment.