17 : showAction(nullptr), hideAction(nullptr), minimizeAction(nullptr),
18 maximizeAction(nullptr), restoreAction(nullptr), quitAction(nullptr),
19 sysTrayIcon(nullptr), trayIconMenu(nullptr), isAllocated(false) {
22 if (QSystemTrayIcon::isSystemTrayAvailable()) {
27 QIcon::fromTheme(
"qtpass-tray", QIcon(
":/artwork/icon.png")));
31 QObject::connect(sysTrayIcon, &QSystemTrayIcon::activated,
this,
38 dbg() <<
"No tray icon for this OS possibly also not show options?";
62void TrayIcon::createActions() {
63 showAction =
new QAction(tr(
"&Show"),
this);
64 connect(showAction, &QAction::triggered, parentwin, &QWidget::show);
65 hideAction =
new QAction(tr(
"&Hide"),
this);
66 connect(hideAction, &QAction::triggered, parentwin, &QWidget::hide);
68 minimizeAction =
new QAction(tr(
"Mi&nimize"),
this);
69 connect(minimizeAction, &QAction::triggered, parentwin,
70 &QWidget::showMinimized);
71 maximizeAction =
new QAction(tr(
"Ma&ximize"),
this);
72 connect(maximizeAction, &QAction::triggered, parentwin,
73 &QWidget::showMaximized);
74 restoreAction =
new QAction(tr(
"&Restore"),
this);
75 connect(restoreAction, &QAction::triggered, parentwin, &QWidget::showNormal);
77 quitAction =
new QAction(tr(
"&Quit"),
this);
78 connect(quitAction, &QAction::triggered, qApp, &QApplication::quit);
84void TrayIcon::createTrayIcon() {
85 trayIconMenu =
new QMenu(
this);
86 trayIconMenu->addAction(showAction);
87 trayIconMenu->addAction(hideAction);
88 trayIconMenu->addAction(minimizeAction);
89 trayIconMenu->addAction(maximizeAction);
90 trayIconMenu->addAction(restoreAction);
91 trayIconMenu->addSeparator();
92 trayIconMenu->addAction(quitAction);
94 sysTrayIcon =
new QSystemTrayIcon(
this);
95 sysTrayIcon->setContextMenu(trayIconMenu);
102 if (parentwin->isVisible())
114 case QSystemTrayIcon::Trigger:
115 case QSystemTrayIcon::DoubleClick:
118 case QSystemTrayIcon::MiddleClick:
133 sysTrayIcon->showMessage(title, msg, QSystemTrayIcon::Information, time);
void showHideParent()
TrayIcon::showHideParent toggle app visibility.
void iconActivated(QSystemTrayIcon::ActivationReason reason)
TrayIcon::iconActivated you clicked on the trayicon.
void showMessage(const QString &title, const QString &msg, int time)
TrayIcon::showMessage show a systray message for notification.
TrayIcon(QMainWindow *parent)
TrayIcon::TrayIcon use a (system) tray icon with a nice QtPass logo on it (currently) only Quits.
bool getIsAllocated()
TrayIcon::getIsAllocated return if TrayIcon is allocated.
void setVisible(bool visible)
TrayIcon::setVisible show or hide the icon.