QlipperSystray::QlipperSystray(QObject *parent) : QSystemTrayIcon(parent) #ifndef NO_QXT , m_shortcutMenu(0) #endif { setIcon(QIcon(QlipperPreferences::Instance()->getPathToIcon())); m_model = new QlipperModel(this); m_contextMenu = new QMenu(); m_contextMenu->addAction(QIcon::fromTheme("edit-clear-hstory", QIcon(":/icons/edit-clear-history.png")), tr("C&lear clipboard history") , m_model, &QlipperModel::clearHistory); m_contextMenu->addAction(QIcon::fromTheme("configure", QIcon(":/icons/configure.png")), tr("&Configure...") , this, &QlipperSystray::editPreferences); m_contextMenu->addSeparator(); m_contextMenu->addAction(QIcon::fromTheme("help-about", QIcon(":/icons/help-about.png")), tr("&About Qlipper...") , this, &QlipperSystray::showAbout); m_contextMenu->addAction(QIcon::fromTheme("application-exit", QIcon(":/icons/application-exit.png")), tr("&Quit") , qApp, &QCoreApplication::quit); setContextMenu(m_contextMenu); #ifndef NO_QXT m_shortcutMenu = new QMenuView(); m_shortcutMenu->setModel(m_model); m_shortcutMenu->setWindowTitle(tr("Qlipper - a clipboard history applet")); // Windows API does not handle well some combinations of flags in custom widgets. #ifndef Q_OS_WIN32 // This flag is mandatory to get focus when user activates global_key. // OK, window gets a decoration but it works. Menu is displayed without the // the decoration if is the systray icon clicked. m_shortcutMenu->setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint); #endif connect(m_shortcutMenu, SIGNAL(triggered(QModelIndex)), m_model, SLOT(indexTriggered(QModelIndex))); connect(m_shortcutMenu, SIGNAL(triggered(QModelIndex)), m_shortcutMenu, SLOT(close())); m_shortcut = new QxtGlobalShortcut(this); connect(m_shortcut, SIGNAL(activated()), this, SLOT(shortcut_activated())); m_shortcut->setShortcut(QlipperPreferences::Instance()->shortcut()); #else qWarning() << "Global keyboard shortcut is not compiled in."; #endif connect(this, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(systray_activated(QSystemTrayIcon::ActivationReason))); }
PicaSysTray::PicaSysTray(QObject *parent) : QObject(parent) { systrayMenu_ = new QMenu(); systrayMenu_->addAction(action_center->AboutAct()); systrayMenu_->addSeparator(); systrayMenu_->addAction(action_center->ExitAct()); systray_ = new QSystemTrayIcon(picapica_ico_sit); systray_->setContextMenu(systrayMenu_); systray_->show(); connect(systray_, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(systray_activated(QSystemTrayIcon::ActivationReason))); connect(skynet, SIGNAL(BecameSelfAware()), this, SLOT(skynet_became_self_aware())); connect(skynet, SIGNAL(LostSelfAwareness()), this, SLOT(skynet_lost_self_awareness())); }