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)); }
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; }
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(); }
// 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(); }
/** * @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(); }
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(); }
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(); }
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); }
// Testing get/set functions void tst_QSystemTrayIcon::showMessage() { QSystemTrayIcon icon; icon.setIcon(QIcon("icons/icon.png")); icon.showMessage("Title", "Messagecontents"); icon.showMessage("Title", "Messagecontents", QSystemTrayIcon::NoIcon); icon.showMessage("Title", "Messagecontents", QSystemTrayIcon::Warning); icon.showMessage("Title", "Messagecontents", QSystemTrayIcon::Critical); icon.show(); icon.showMessage("Title", "Messagecontents"); icon.showMessage("Title", "Messagecontents", QSystemTrayIcon::NoIcon); icon.showMessage("Title", "Messagecontents", QSystemTrayIcon::Warning); icon.showMessage("Title", "Messagecontents", QSystemTrayIcon::Critical); }
/*! * \brief main * \param argc * \param argv * \return */ int main(int argc, char* argv[]) { QApplication a(argc, argv); a.setQuitOnLastWindowClosed(false); a.processEvents(); Dialog *d = new Dialog; d->setWindowIcon(QIcon(":/ops.png")); d->show(); QSystemTrayIcon * qsti = new QSystemTrayIcon(d); QMenu *trayIconMenu; QAction *minimizeAction; QAction *restoreAction; QAction *quitAction; minimizeAction = new QAction("Minimize", d); restoreAction = new QAction("Restore", d); quitAction = new QAction("Quit", d); QObject::connect(minimizeAction, SIGNAL(triggered()), d, SLOT(hide())); QObject::connect(restoreAction, SIGNAL(triggered()), d,SLOT(showNormal())); QObject::connect(quitAction, SIGNAL(triggered()), &a, SLOT(quit())); QObject::connect(d, SIGNAL(destroyed()), &a, SLOT(quit())); trayIconMenu = new QMenu(d); trayIconMenu->addAction (minimizeAction); trayIconMenu->addAction (restoreAction); trayIconMenu->addAction (quitAction); qsti->setContextMenu(trayIconMenu); qsti->setIcon(QIcon(":/ops.png")); qsti->show(); QObject::connect(qsti, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), d, SLOT(trayHandle(QSystemTrayIcon::ActivationReason))); return a.exec(); }
ADM_qtray::ADM_qtray(const void* parent) : ADM_tray(parent) { _parent = parent; lastIcon = 0; maxIcons = 12; pixmap = new QIcon[maxIcons]; pixmap[0] = QIcon(QPixmap(xpm_film1)); pixmap[1] = QIcon(QPixmap(xpm_film3)); pixmap[2] = QIcon(QPixmap(xpm_film5)); pixmap[3] = QIcon(QPixmap(xpm_film7)); pixmap[4] = QIcon(QPixmap(xpm_film9)); pixmap[5] = QIcon(QPixmap(xpm_film11)); pixmap[6] = QIcon(QPixmap(xpm_film13)); pixmap[7] = QIcon(QPixmap(xpm_film15)); pixmap[8] = QIcon(QPixmap(xpm_film17)); pixmap[9] = QIcon(QPixmap(xpm_film19)); pixmap[10] = QIcon(QPixmap(xpm_film21)); pixmap[11] = QIcon(QPixmap(xpm_film23)); signalReceiver = new ADM_qtray_signalReceiver(); signalReceiver->parent = (QDialog*)parent; QSystemTrayIcon* trayIcon = new QSystemTrayIcon(pixmap[0], (QObject*)parent); sys = trayIcon; trayIcon->setToolTip("Avidemux"); openAction = new QAction(QT_TR_NOOP("Open Avidemux"), (QObject*)parent); QObject::connect(openAction, SIGNAL(triggered()), signalReceiver, SLOT(restore())); QObject::connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), signalReceiver, SLOT(iconActivated(QSystemTrayIcon::ActivationReason))); trayIconMenu = new QMenu((QWidget*)parent); trayIconMenu->addAction(openAction); trayIcon->setContextMenu(trayIconMenu); trayIcon->show(); }
int main(int argv, char **args) { QApplication app(argv, args); app.setApplicationName("Munt mt32emu-qt"); app.setQuitOnLastWindowClosed(false); { Master master; 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", false).toBool()) mainWindow.show(); if (argv > 1) master.processCommandLine(app.arguments()); master.startPinnedSynthRoute(); master.startMidiProcessing(); app.exec(); master.setTrayIcon(NULL); delete trayIcon; } return 0; }
int main(int argc, char *argv[]) { QApplication app(argc, argv); const QString app_name("timecop"); const QString app_version("1.1"); const QString app_settings_dir(QDir::home().filePath(".timecop")); app.setOrganizationName("Daimler AG RD-DDA"); app.setApplicationName(app_name); QSettings::setDefaultFormat(QSettings::IniFormat); QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, app_settings_dir); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); QObject *root = 0; QWidget *rootWindow = 0; SystrayHelper systrayHelper; engine.rootContext()->setContextProperty("systrayHelper", &systrayHelper); engine.rootContext()->setContextProperty("app_name", app_name); engine.rootContext()->setContextProperty("app_version", app_version); engine.rootContext()->setContextProperty("app_settings_dir", app_settings_dir); if (engine.rootObjects().size() > 0) { root = engine.rootObjects().at(0); systrayHelper.setRootWindow(root); if(root->isWindowType()){ rootWindow = qobject_cast<QWidget*>(root); QApplication::setQuitOnLastWindowClosed(false); QAction *minimizeAction = new QAction(QObject::tr("Mi&nimize"), rootWindow); rootWindow->connect(minimizeAction, SIGNAL(triggered()), root, SLOT(hide())); QAction *maximizeAction = new QAction(QObject::tr("Ma&ximize"), rootWindow); rootWindow->connect(maximizeAction, SIGNAL(triggered()), root, SLOT(showMaximized())); QAction *restoreAction = new QAction(QObject::tr("&Restore"), rootWindow); rootWindow->connect(restoreAction, SIGNAL(triggered()), root, SLOT(showNormal())); QAction *quitAction = new QAction(QObject::tr("&Quit"), rootWindow); rootWindow->connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); QMenu *trayIconMenu = new QMenu(rootWindow); trayIconMenu->addAction(minimizeAction); trayIconMenu->addAction(maximizeAction); trayIconMenu->addAction(restoreAction); trayIconMenu->addSeparator(); trayIconMenu->addAction(quitAction); QSystemTrayIcon *trayIcon = new QSystemTrayIcon(rootWindow); QIcon icon(":/trayicon.png"); icon.setIsMask(true); //trayIcon->setContextMenu(trayIconMenu); trayIcon->setIcon(icon); trayIcon->setToolTip("Click to open"); trayIcon->setVisible(true); systrayHelper.setTrayIcon(trayIcon); QObject::connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), &systrayHelper, SLOT(activatedSystray(QSystemTrayIcon::ActivationReason))); trayIcon->show(); } } return app.exec(); }
MainForm::MainForm(QWidget *parent) : QMainWindow(parent) { ui.setupUi(this); setWindowIcon(QIcon(":/icons/logo.ico")); log = findChild<LogWidget *>("log"); qInstallMessageHandler(messageHandler); // Switch to correct tab tabs = findChild<QTabWidget *>("tabs"); tabs->setCurrentIndex(Tabs::GRABBER); tabs->tabBar()->setTabEnabled(Tabs::STREAM, false); connect(tabs, &QTabWidget::currentChanged, this, &MainForm::trySaveSettings); tabs->tabBar()->setExpanding(true); // Connect start button start_button = findChild<QPushButton *>("start"); start_button->setObjectName("no_disable"); connect(start_button, &QPushButton::clicked, this, &MainForm::startStream); stop_button = findChild<QPushButton *>("stop"); stop_button->setObjectName("no_disable"); connect(stop_button, &QPushButton::clicked, this, &MainForm::completeStream); QPushButton *add = findChild<QPushButton *>("add"); connect(add, &QPushButton::clicked, this, &MainForm::setPlaylist); start_button->setHidden(false); stop_button->setHidden(true); progress = findChild<QProgressBar *>("progress"); // Connect donation button QPushButton *donate_button = findChild<QPushButton *>("donate"); connect(donate_button, &QPushButton::clicked, this, &MainForm::donateMessage); // Setup table links = findChild<LinkWidget *>("links"); links->header()->resizeSection(Columns::NAME, width() / 2); links->header()->resizeSection(Columns::SIZE, width() / 4); play_list = findChild<QListWidget *>("play_list"); QPushButton *open_container = findChild<QPushButton *>("open_container"); connect(open_container, SIGNAL(clicked()), this, SLOT(openDLC())); QPushButton *text = findChild<QPushButton *>("text"); connect(text, &QPushButton::clicked, this, &MainForm::openLinkInput); QPushButton *about = findChild<QPushButton *>("about"); connect(about, &QPushButton::clicked, this, &MainForm::showAbout); clicknload_switch = findChild<QCheckBox *>("clicknload_switch"); connect(clicknload_switch, &QCheckBox::clicked, this, &MainForm::switchClickNLoad); QSystemTrayIcon *trayIcon = new QSystemTrayIcon(this);; trayIcon->setIcon(this->windowIcon()); trayIcon->show(); // connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(messageClicked())); connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason))); // Setup settings QTabWidget *settings_tabs = findChild<QTabWidget *>("settings_tabs"); settings_tabs->setCurrentIndex(Tabs::STREAM); // Setup highlighter mpv_settings = findChild<QPlainTextEdit *>("mpv_settings"); new Highlighter(mpv_settings->document()); archive_directory = findChild<FilePickerWidget *>("archive_directory"); download_directory = findChild<FilePickerWidget *>("download_directory"); edit_memory = findChild<QDoubleSpinBox *>("edit_memory"); edit_down_speed = findChild<QDoubleSpinBox *>("edit_down_speed"); combo_hoster = findChild<QComboBox *>("combo_hoster"); combo_hoster->addItem("uploaded.to"); edit_password = findChild<QLineEdit *>("edit_password"); edit_username = findChild<QLineEdit *>("edit_username"); if (load_settings()) { std::list<std::string> demo{"http://ul.to/a2os4kd5", "http://ul.to/ev8156dc"}; links->appendLinks("demo", demo); } else { links->load(); } server = std::make_shared<clicknload::Server>( [this](std::string name, std::list<std::string> urls) { clicknload_background(name, urls); }); switchClickNLoad(true); connect(this, &MainForm::linksAdded, this, &MainForm::activlyAppendLinks); links->startAggregator(options); }