void Window::closeEvent(QCloseEvent *e) { if (MTP::authedId() && minimizeToTray()) { e->ignore(); } else { App::quit(); } }
void Window::toggleTray(QSystemTrayIcon::ActivationReason reason) { if (reason != QSystemTrayIcon::Context) { if (psIsActive()) { minimizeToTray(); } else { showFromTray(reason); } } }
void MainWindow::handleStateChanged(Qt::WindowState state) { stateChangedHook(state); updateIsActive((state == Qt::WindowMinimized) ? Global::OfflineBlurTimeout() : Global::OnlineFocusTimeout()); psUserActionDone(); if (state == Qt::WindowMinimized && Global::WorkMode().value() == dbiwmTrayOnly) { minimizeToTray(); } savePosition(state); }
void Window::updateTrayMenu(bool force) { if (!trayIconMenu || (cPlatform() == dbipWindows && !force)) return; bool active = isActive(false); if (cPlatform() == dbipWindows || cPlatform() == dbipMac) { QAction *first = trayIconMenu->actions().at(0); first->setText(lang(active ? lng_minimize_to_tray : lng_open_from_tray)); disconnect(first, SIGNAL(triggered(bool)), 0, 0); connect(first, SIGNAL(triggered(bool)), this, active ? SLOT(minimizeToTray()) : SLOT(showFromTray())); } else {
void Window::firstShow() { #ifdef Q_OS_WIN trayIconMenu = new ContextMenu(this); #else trayIconMenu = new QMenu(this); trayIconMenu->setFont(QFont("Tahoma")); #endif if (cPlatform() == dbipWindows || cPlatform() == dbipMac) { trayIconMenu->addAction(lang(lng_minimize_to_tray), this, SLOT(minimizeToTray()))->setEnabled(true); trayIconMenu->addAction(lang(lng_quit_from_tray), this, SLOT(quitFromTray()))->setEnabled(true); } else { trayIconMenu->addAction(lang(lng_open_from_tray), this, SLOT(showFromTray()))->setEnabled(true); trayIconMenu->addAction(lang(lng_minimize_to_tray), this, SLOT(minimizeToTray()))->setEnabled(true); trayIconMenu->addAction(lang(lng_quit_from_tray), this, SLOT(quitFromTray()))->setEnabled(true); } psFirstShow(); updateTrayMenu(); }
void Window::toggleTray(QSystemTrayIcon::ActivationReason reason) { if (cPlatform() == dbipMac && psIsActive()) return; if (reason == QSystemTrayIcon::Context) { updateTrayMenu(true); QTimer::singleShot(1, this, SLOT(psShowTrayMenu())); } else { if (psIsActive()) { minimizeToTray(); } else { showFromTray(reason); } } }
void Window::updateTrayMenu(bool force) { if (!trayIconMenu || (cPlatform() == dbipWindows && !force) || cPlatform() == dbipLinux32 || cPlatform() == dbipLinux64) return; bool active = psIsActive(); QAction *first = trayIconMenu->actions().at(0); first->setText(lang(active ? lng_minimize_to_tray : lng_open_from_tray)); disconnect(first, SIGNAL(triggered(bool)), 0, 0); connect(first, SIGNAL(triggered(bool)), this, active ? SLOT(minimizeToTray()) : SLOT(showFromTray())); #ifndef Q_OS_WIN if (trayIcon) { trayIcon->setContextMenu((active || cPlatform() != dbipMac) ? trayIconMenu : 0); } #endif }
void Window::firstShow() { #ifdef Q_OS_WIN trayIconMenu = new ContextMenu(this); #else trayIconMenu = new QMenu(this); trayIconMenu->setFont(QFont("Tahoma")); #endif trayIconMenu->addAction(lang(lng_minimize_to_tray), this, SLOT(minimizeToTray()))->setEnabled(true); trayIconMenu->addAction(lang(lng_quit_from_tray), this, SLOT(quitFromTray()))->setEnabled(true); psFirstShow(); updateTrayMenu(); }
bool MainWindow::hideNoQuit() { if (App::quitting()) { return false; } if (Global::WorkMode().value() == dbiwmTrayOnly || Global::WorkMode().value() == dbiwmWindowAndTray) { if (minimizeToTray()) { Ui::showChatsList(); return true; } } else if (cPlatform() == dbipMac || cPlatform() == dbipMacOld) { closeWithoutDestroy(); updateIsActive(Global::OfflineBlurTimeout()); updateGlobalMenu(); Ui::showChatsList(); return true; } return false; }
void MainWindow::changeEvent(QEvent* _event) { QMainWindow::changeEvent(_event); if (!QSystemTrayIcon::isSystemTrayAvailable()) { QMainWindow::changeEvent(_event); return; } switch (_event->type()) { case QEvent::WindowStateChange: if(Settings::instance().isMinimizeToTrayEnabled()) { minimizeToTray(isMinimized()); } break; default: break; } QMainWindow::changeEvent(_event); }
void ManagerWindow::connectSlots() { // connect(ui->callButton, SIGNAL(clicked()), // this, SLOT(placeCall())); connect(this->ui->aboutButton, SIGNAL(clicked()), this, SLOT(about())); connect(this->ui->minimizeButton, SIGNAL(clicked()), this, SLOT(minimizeToTray())); connect(this->ui->maximizeButton, SIGNAL(clicked()), this, SLOT(showMaxRestore())); connect(this->ui->startPauseButton, SIGNAL(clicked()), this, SLOT(agentStartPause())); // connect(this->ui->passwordButton, SIGNAL(clicked()), // this, SIGNAL(changePassword())); connect(this->ui->closeButton, SIGNAL(clicked(bool)), this, SLOT(quit(bool))); connect(this->trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason))); connect(this->ui->accountsTabWidget, SIGNAL(currentChanged(int)), this, SLOT(switchAccount(int))); }
void MainWindow::closeEvent(QCloseEvent* _event) { #ifdef Q_OS_WIN if (m_isAboutToQuit) { QMainWindow::closeEvent(_event); return; } else if (Settings::instance().isCloseToTrayEnabled()) { minimizeToTray(true); _event->ignore(); } else { QApplication::quit(); return; } #elif defined(Q_OS_LINUX) if (!m_isAboutToQuit) { QApplication::quit(); return; } #endif QMainWindow::closeEvent(_event); }