本文整理汇总了C++中QSystemTrayIcon类的典型用法代码示例。如果您正苦于以下问题:C++ QSystemTrayIcon类的具体用法?C++ QSystemTrayIcon怎么用?C++ QSystemTrayIcon使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QSystemTrayIcon类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QSystemTrayIcon
void QMainWidget::createTrayIcon()
{
QSystemTrayIcon *trayIcon = new QSystemTrayIcon(this);
QMenu *menu = new QMenu(this);
QAction *windowAction = new QAction("Controller Window", this);
QAction *quitAction = new QAction("Shutdown xboxToVJoy", this);
enableAction = new QAction("Disable", this);
connect(enableAction, SIGNAL(triggered()), this, SLOT(toggleEnabled()));
connect(windowAction, SIGNAL(triggered()), this, SLOT(showControllerWindow()));
connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
menu->addAction(windowAction);
menu->addSeparator();
menu->addAction(enableAction);
menu->addSeparator();
menu->addAction(quitAction);
trayIcon->setContextMenu(menu);
QIcon icon(":/icons/icon.png");
trayIcon->setIcon(icon);
trayIcon->show();
}
示例2: QMainWindow
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
setWindowIcon(QIcon(":icons/icon.png"));
setWindowTitle("quickly translate");
QSystemTrayIcon * trayIcon = new QSystemTrayIcon(this);
mNetManager = new QNetworkAccessManager(this);
mLangageModel = new LanguageModel;
trayIcon->setIcon(QIcon(":icons/icon.png"));
trayIcon->setContextMenu(ui->menuFile);
trayIcon->show();
ui->dockWidget->hide();
ui->sourceComboBox->setModel(mLangageModel);
ui->targetComboBox->setModel(mLangageModel);
QDesktopWidget * desktop = new QDesktopWidget;
QPoint startPos = QPoint(desktop->geometry().bottomRight() );
QPoint finalPos = desktop->geometry().center() - QPoint(width()/2,height()/2);
move(finalPos);
connect(trayIcon,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this,SLOT(trayActivated(QSystemTrayIcon::ActivationReason)));
connect(ui->actionExit,SIGNAL(triggered()),this,SLOT(exit()));
connect(ui->translateButton,SIGNAL(clicked()),this,SLOT(translate()));
connect(ui->sourceTextEdit,SIGNAL(returnPressed()),this,SLOT(translate()));
connect(ui->swapButton,SIGNAL(clicked()),this,SLOT(swapLangages()));
connect(ui->actionCopy,SIGNAL(triggered()),this,SLOT(copy()));
connect(ui->actionCut,SIGNAL(triggered()),this,SLOT(cut()));
connect(ui->actionPast,SIGNAL(triggered()),this,SLOT(past()));
connect(ui->actionPreferences,SIGNAL(triggered()),this,SLOT(showPreferences()));
connect(ui->actionAboutQt,SIGNAL(triggered()),this,SLOT(showAboutQt()));
connect(ui->actionAbout,SIGNAL(triggered()),this,SLOT(showAbout()));
connect(ui->actionTTS,SIGNAL(triggered()),this,SLOT(showTextTTS()));
connect(ui->sourceSoundButton,SIGNAL(clicked()),this,SLOT(textToSpeak()));
connect(ui->targetSoundButton,SIGNAL(clicked()),this,SLOT(textToSpeak()));
// mPropertyAnimation = new QPropertyAnimation(this, "pos");
// mPropertyAnimation->setDuration(800);
// mPropertyAnimation->setStartValue(startPos);
// mPropertyAnimation->setEndValue(finalPos);
//load default langage
QSettings settings;
QString sourceId = settings.value("source").toString();
QString targetId = settings.value("target").toString();
ui->sourceComboBox->setCurrentIndex(mLangageModel->findLangageId(sourceId));
ui->targetComboBox->setCurrentIndex(mLangageModel->findLangageId(targetId));
}
示例3: sipKeepReference
static PyObject *meth_QSystemTrayIcon_setContextMenu(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
QMenu * a0;
PyObject *a0Keep;
QSystemTrayIcon *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "[email protected]", &sipSelf, sipType_QSystemTrayIcon, &sipCpp, &a0Keep, sipType_QMenu, &a0))
{
Py_BEGIN_ALLOW_THREADS
sipCpp->setContextMenu(a0);
Py_END_ALLOW_THREADS
sipKeepReference(sipSelf, -60, a0Keep);
Py_INCREF(Py_None);
return Py_None;
}
}
/* Raise an exception if the arguments couldn't be parsed. */
sipNoMethod(sipParseErr, sipName_QSystemTrayIcon, sipName_setContextMenu, NULL);
return NULL;
}
示例4: main
int main(int argv, char **args)
{
QApplication app(argv, args);
app.setApplicationName("Munt mt32emu-qt");
app.setQuitOnLastWindowClosed(false);
QProcessEnvironment::systemEnvironment().insert("PA_ALSA_PLUGHW", "1");
Master *master = Master::getInstance();
QSystemTrayIcon *trayIcon = NULL;
if (QSystemTrayIcon::isSystemTrayAvailable()) {
trayIcon = new QSystemTrayIcon(QIcon(":/images/note.gif"));
trayIcon->setToolTip("Munt: MT-32 Emulator");
trayIcon->show();
master->setTrayIcon(trayIcon);
}
MainWindow mainWindow(master);
if (trayIcon == NULL || !master->getSettings()->value("Master/startIconized", "0").toBool()) mainWindow.show();
master->startPinnedSynthRoute();
master->startMidiProcessing();
master->processCommandLine(app.arguments());
app.exec();
master->setTrayIcon(NULL);
delete trayIcon;
return 0;
}
示例5: switch
void CNotificationManager::showStateNotificationBySender(libnutcommon::DeviceState state) {
if (!m_NotificationsEnabled)
return;
CUIDevice * uiDevice = qobject_cast<CUIDevice *>(sender());
if (!uiDevice)
return;
QString message;
switch (state) {
case libnutcommon::DeviceState::UP:
message = tr("%2 is now up and running on network: %1")
.arg(currentNetwork(uiDevice->device()));
break;
case libnutcommon::DeviceState::UNCONFIGURED:
message = tr("%2 got carrier (to network: %1) but needs configuration.\n\nClick here to open the device details.")
.arg(currentNetwork(uiDevice->device()));
break;
case libnutcommon::DeviceState::ACTIVATED:
message = tr("%1 is now activated and waits for carrier.");
break;
case libnutcommon::DeviceState::DEACTIVATED:
message = tr("%1 is now deactivated");
break;
default:
return;
}
{
QSystemTrayIcon * trayIcon = m_UIDeviceIcons.value(uiDevice, NULL);
message = message.arg(trayIcon && trayIcon->isVisible() ? tr("Device") : uiDevice->device()->getName());
}
showDeviceMessage(QString(), message, uiDevice);
}
示例6: showHide
// Testing get/set functions
void tst_QSystemTrayIcon::showHide()
{
QSystemTrayIcon icon;
icon.setIcon(QIcon("icons/icon.png"));
icon.show();
icon.setIcon(QIcon("icons/icon.png"));
icon.hide();
}
示例7: Q_UNUSED
/**
* @brief Send a popup through Growl.
* @param icon The icon inside the notification. Currently ignored.
* @param timeout The time in ms to show the notification.
* @param title The title displayed inside the notification.
* @param message The message displayed inside the notification.
*/
void NotifyByPopupGrowl::popup( const QPixmap *icon, int timeout,
const QString &title, const QString &message )
{
Q_UNUSED( icon );
QSystemTrayIcon i;
i.show();
i.showMessage( title, message,
QSystemTrayIcon::Information, timeout );
i.hide();
}
示例8: QMenu
TrayIconManager::TrayIconManager(QMainWindow* p_main)
{
QMenu *trayMenu = new QMenu(p_main);
trayMenu->addAction(new QAction("Dodaj wpis...", p_main)); // dummy action
trayMenu->addSeparator();
trayMenu->addAction(new QAction("Drukuj...", p_main)); // dummy action
// set up and show the system tray icon
QSystemTrayIcon *trayIcon = new QSystemTrayIcon(p_main);
trayIcon->setIcon(QIcon("heart.ico"));
trayIcon->setContextMenu(trayMenu);
trayIcon->show();
}
示例9: main
int main(int argc, char *argv[])
{
#ifdef WIN32
redirectCout();
#endif
// If there is a set up white list and the
// user is not in the white list then we need
// to simply close this program down. Otherwise
// show the interface to the user.
if (doesWhiteListExist())
{
cout << "White list exists" << endl;
if (!isUserInWhiteList())
{
cout << getUserName() << " doesn't exist in white list. Program terminating."<< endl;
exit(0);
return 0;
}
else
{
cout << getUserName() << " is in white list."<< endl;
}
}
else
{
cout << "White list does not exist." << endl;
}
int tray_tries = 30;
int available;
StatusUpdate *status;
QApplication app(argc, argv);
QSystemTrayIcon *trayIcon;
QIcon icon(":images/disconnect.svg");
available = QSystemTrayIcon::isSystemTrayAvailable();
while(!available)
{
sleep(1);
tray_tries--;
if(tray_tries <= 0)
{
QMessageBox::critical(NULL, QObject::tr("System Tray"), QObject::tr("The system tray is not supported on your system."));
return -1;
}
available = QSystemTrayIcon::isSystemTrayAvailable();
}
trayIcon = new QSystemTrayIcon(NULL);
trayIcon->setIcon(icon);
trayIcon->show();
status = new StatusUpdate(trayIcon);
return app.exec();
}
示例10: spy
void tst_QSystemTrayIcon::lastWindowClosed()
{
QSignalSpy spy(qApp, SIGNAL(lastWindowClosed()));
QWidget window;
QSystemTrayIcon icon;
icon.setIcon(QIcon("whatever.png"));
icon.show();
window.show();
QTimer::singleShot(2500, &window, SLOT(close()));
QTimer::singleShot(20000, qApp, SLOT(quit())); // in case the test fails
qApp->exec();
QVERIFY(spy.count() == 1);
}
示例11: getSetCheck
// Testing get/set functions
void tst_QSystemTrayIcon::getSetCheck()
{
QSystemTrayIcon icon;
QCOMPARE(true, icon.toolTip().isEmpty());
icon.setToolTip("testToolTip");
QCOMPARE(true, "testToolTip" == icon.toolTip());
QCOMPARE(true, icon.icon().isNull());
icon.setIcon(QIcon("icons/icon.png"));
QCOMPARE(false, icon.icon().isNull());
QMenu menu;
QCOMPARE(true, icon.contextMenu() == 0);
icon.setContextMenu(&menu);
QCOMPARE(false, icon.contextMenu() == 0);
}
示例12: sipConvertFromType
static PyObject *meth_QSystemTrayIcon_contextMenu(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
QSystemTrayIcon *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QSystemTrayIcon, &sipCpp))
{
QMenu *sipRes;
Py_BEGIN_ALLOW_THREADS
sipRes = sipCpp->contextMenu();
Py_END_ALLOW_THREADS
return sipConvertFromType(sipRes,sipType_QMenu,NULL);
}
}
示例13: switch
bool QSystemTrayIconSys::winEvent( MSG *m, long *result )
{
switch(m->message) {
case WM_CREATE:
SetWindowLong(winId(), GWL_USERDATA, (LONG)((CREATESTRUCTW*)m->lParam)->lpCreateParams);
break;
case MYWM_NOTIFYICON:
{
QPoint gpos = QCursor::pos();
switch (m->lParam) {
case WM_LBUTTONUP:
if (ignoreNextMouseRelease)
ignoreNextMouseRelease = false;
else
emit q->activated(QSystemTrayIcon::Trigger);
break;
case WM_LBUTTONDBLCLK:
ignoreNextMouseRelease = true; // Since DBLCLICK Generates a second mouse
// release we must ignore it
emit q->activated(QSystemTrayIcon::DoubleClick);
break;
case WM_RBUTTONUP:
if (q->contextMenu()) {
q->contextMenu()->popup(gpos);
// We must ensure that the popup menu doesn't show up behind the task bar.
QRect desktopRect = qApp->desktop()->availableGeometry();
int maxY = desktopRect.y() + desktopRect.height() - q->contextMenu()->height();
if (gpos.y() > maxY) {
gpos.ry() = maxY;
q->contextMenu()->move(gpos);
}
}
emit q->activated(QSystemTrayIcon::Context);
break;
case WM_MBUTTONUP:
emit q->activated(QSystemTrayIcon::MiddleClick);
break;
default:
break;
}
break;
}
default:
return QWidget::winEvent(m, result);
}
return 0;
}
示例14: QSystemTrayIcon
void CNotificationManager::registerUIDevice(CUIDevice * uiDevice) {
QSystemTrayIcon * newTrayIcon = new QSystemTrayIcon(this);
m_UIDeviceIcons.insert(uiDevice, newTrayIcon);
newTrayIcon->setContextMenu(uiDevice->deviceMenu());
m_MainIcon->contextMenu()->insertMenu(m_InsertMarker, uiDevice->deviceMenu());
updateDeviceIcon(uiDevice);
setIconVisible(uiDevice->m_ShowTrayIcon, uiDevice);
connect(uiDevice, SIGNAL(showNotificationRequested(libnutcommon::DeviceState)),
this, SLOT(showStateNotification(libnutcommon::DeviceState)));
connect(uiDevice, SIGNAL(updateTrayIconRequested(libnutcommon::DeviceState)),
this, SLOT(updateDeviceIcon()));
connect(uiDevice, SIGNAL(showTrayIconRequested(bool)),
this, SLOT(setIconVisible(bool)));
connect(newTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
this, SLOT(handleDeviceIconActivated(QSystemTrayIcon::ActivationReason)));
}
示例15: QSystemTrayIcon
void CNotificationManager::registerUIDevice(CUIDevice * uiDevice) {
QSystemTrayIcon * newTrayIcon = new QSystemTrayIcon(this);
m_UIDeviceIcons.insert(uiDevice, newTrayIcon);
newTrayIcon->setContextMenu(uiDevice->deviceMenu());
m_MainIcon->contextMenu()->insertMenu(m_InsertMarker, uiDevice->deviceMenu());
updateDeviceIcon(uiDevice);
setIconVisible(uiDevice->m_ShowTrayIcon, uiDevice);
connect(uiDevice, &CUIDevice::showNotificationRequested,
this, &CNotificationManager::showStateNotificationBySender);
connect(uiDevice, &CUIDevice::updateTrayIconRequested,
this, &CNotificationManager::updateDeviceIconBySender);
connect(uiDevice, &CUIDevice::showTrayIconRequested,
this, &CNotificationManager::setIconVisibleBySender);
connect(newTrayIcon, &QSystemTrayIcon::activated,
this, &CNotificationManager::handleDeviceIconActivated);
}