Esempio n. 1
0
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);
	}
	psUpdateWorkmode();

	psFirstShow();
	updateTrayMenu();
}
Esempio n. 2
0
void Window::setupTrayIcon() {
	if (!trayIcon) {
		if (trayIcon) trayIcon->deleteLater();
		trayIcon = new QSystemTrayIcon(this);
#ifdef Q_OS_MAC
		QIcon icon(QPixmap::fromImage(psTrayIcon()));
		icon.addPixmap(QPixmap::fromImage(psTrayIcon(true)), QIcon::Selected);
#else
		QIcon icon(QPixmap::fromImage(iconLarge()));
#endif

		trayIcon->setIcon(icon);
		trayIcon->setToolTip(QString::fromStdWString(AppName));
		connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(toggleTray(QSystemTrayIcon::ActivationReason)), Qt::UniqueConnection);
		if (cPlatform() != dbipMac) {
			connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(showFromTray()));
		}
		updateTrayMenu();
	}
	psUpdateCounter();

	trayIcon->show();
	psUpdateDelegate();
}
Esempio n. 3
0
void Window::checkHistoryActivation(int state) {
	if (main && MTP::authedId() && historyIsActive(state)) {
		main->historyWasRead();
	}
	QTimer::singleShot(1, this, SLOT(updateTrayMenu()));
}