add automatic op reloading when opening tray menu

main
Joel Smith 2020-07-27 11:22:09 -07:00
parent e07cff2521
commit 2d1c1ae273
2 changed files with 4 additions and 9 deletions

View File

@ -90,7 +90,6 @@ TrayManager::~TrayManager() {
cleanChooseOpSubmenu(); // must be done before deleting chooseOpSubmenu/action
delete chooseOpStatusAction;
delete refreshOperationListAction;
delete chooseOpSubmenu;
delete trayIconMenu;
@ -171,14 +170,7 @@ void TrayManager::createActions() {
chooseOpStatusAction = new QAction("Loading operations...", chooseOpSubmenu);
chooseOpStatusAction->setEnabled(false);
refreshOperationListAction = new QAction(tr("Refresh Operations"), chooseOpSubmenu);
connect(refreshOperationListAction, &QAction::triggered, [this] {
chooseOpStatusAction->setText("Loading operations...");
NetMan::getInstance().refreshOperationsList();
});
chooseOpSubmenu->addAction(chooseOpStatusAction);
chooseOpSubmenu->addAction(refreshOperationListAction);
chooseOpSubmenu->addSeparator();
}
@ -256,6 +248,10 @@ void TrayManager::createTrayMenu() {
trayIcon = new QSystemTrayIcon(this);
trayIcon->setContextMenu(trayIconMenu);
connect(trayIcon, &QSystemTrayIcon::activated, [this]{
chooseOpStatusAction->setText("Loading operations...");
NetMan::getInstance().refreshOperationsList();
});
}
void TrayManager::onScreenshotCaptured(const QString& path) {

View File

@ -74,7 +74,6 @@ class TrayManager : public QDialog {
void cleanChooseOpSubmenu();
QMenu *chooseOpSubmenu;
QAction *chooseOpStatusAction;
QAction *refreshOperationListAction;
QAction *selectedAction = nullptr; // note: do not delete; for reference only
std::vector<QAction *> allOperationActions;