refactor: MainWindow setupTrayIcon in method
remove unused MainWindow::createStatusBar and MainWinow::createTrayIcon
This commit is contained in:
parent
d5e651bae9
commit
f505bfd3e7
2 changed files with 23 additions and 22 deletions
|
|
@ -136,7 +136,7 @@ MainWindow::MainWindow(ConfigScopes &configScopes, AppConfig &appConfig)
|
||||||
setupControls();
|
setupControls();
|
||||||
connectSlots();
|
connectSlots();
|
||||||
|
|
||||||
setIcon();
|
setupTrayIcon();
|
||||||
|
|
||||||
m_ConfigScopes.signalReady();
|
m_ConfigScopes.signalReady();
|
||||||
|
|
||||||
|
|
@ -568,25 +568,6 @@ void MainWindow::moveEvent(QMoveEvent *event)
|
||||||
|
|
||||||
void MainWindow::open()
|
void MainWindow::open()
|
||||||
{
|
{
|
||||||
auto trayMenu = new QMenu(this);
|
|
||||||
trayMenu->addActions({m_actionStartCore, m_actionStopCore, m_actionQuit});
|
|
||||||
trayMenu->insertSeparator(m_actionQuit);
|
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
|
||||||
// Duplicate quit needed for mac os tray menu
|
|
||||||
QAction *actionTrayQuit = new QAction(tr("Quit Deskflow"), this);
|
|
||||||
actionTrayQuit->setShortcut(QKeySequence::Quit);
|
|
||||||
connect(actionTrayQuit, &QAction::triggered, this, &MainWindow::close);
|
|
||||||
|
|
||||||
m_actionRestore->setText(tr("Open Deskflow"));
|
|
||||||
trayMenu->addActions({m_actionRestore, actionTrayQuit});
|
|
||||||
trayMenu->insertSeparator(actionTrayQuit);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
m_trayIcon->setContextMenu(trayMenu);
|
|
||||||
// Show will show the tray when it can (if it can)
|
|
||||||
m_trayIcon->show();
|
|
||||||
|
|
||||||
if (!m_AppConfig.enableUpdateCheck().has_value()) {
|
if (!m_AppConfig.enableUpdateCheck().has_value()) {
|
||||||
m_AppConfig.setEnableUpdateCheck(messages::showUpdateCheckOption(this));
|
m_AppConfig.setEnableUpdateCheck(messages::showUpdateCheckOption(this));
|
||||||
m_ConfigScopes.save();
|
m_ConfigScopes.save();
|
||||||
|
|
@ -663,6 +644,27 @@ void MainWindow::createMenuBar()
|
||||||
setMenuBar(menuBar);
|
setMenuBar(menuBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::setupTrayIcon()
|
||||||
|
{
|
||||||
|
auto trayMenu = new QMenu(this);
|
||||||
|
trayMenu->addActions({m_actionStartCore, m_actionStopCore, m_actionQuit});
|
||||||
|
trayMenu->insertSeparator(m_actionQuit);
|
||||||
|
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
// Duplicate quit needed for mac os tray menu
|
||||||
|
QAction *actionTrayQuit = new QAction(tr("Quit Deskflow"), this);
|
||||||
|
actionTrayQuit->setShortcut(QKeySequence::Quit);
|
||||||
|
connect(actionTrayQuit, &QAction::triggered, this, &MainWindow::close);
|
||||||
|
|
||||||
|
m_actionRestore->setText(tr("Open Deskflow"));
|
||||||
|
trayMenu->addActions({m_actionRestore, actionTrayQuit});
|
||||||
|
trayMenu->insertSeparator(actionTrayQuit);
|
||||||
|
#endif
|
||||||
|
setIcon();
|
||||||
|
m_trayIcon->setContextMenu(trayMenu);
|
||||||
|
m_trayIcon->show();
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::applyConfig()
|
void MainWindow::applyConfig()
|
||||||
{
|
{
|
||||||
enableServer(m_AppConfig.serverGroupChecked());
|
enableServer(m_AppConfig.serverGroupChecked());
|
||||||
|
|
|
||||||
|
|
@ -156,8 +156,7 @@ private:
|
||||||
return m_AppConfig;
|
return m_AppConfig;
|
||||||
}
|
}
|
||||||
void createMenuBar();
|
void createMenuBar();
|
||||||
void createStatusBar();
|
void setupTrayIcon();
|
||||||
void createTrayIcon();
|
|
||||||
void applyConfig();
|
void applyConfig();
|
||||||
void setIcon();
|
void setIcon();
|
||||||
bool checkForApp(int which, QString &app);
|
bool checkForApp(int which, QString &app);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue