/*添加系统托盘*/ void MainWindow::addSystemTray() { this->createTrayIcon(); systemTrayIcon = new QSystemTrayIcon(this); systemTrayIcon->setContextMenu(systemTrayMenu); systemTrayIcon->setToolTip(SYSTEM_NAME); systemTrayIcon->setIcon(QIcon(SYSTEM_ICON)); systemTrayIcon->show(); connect(systemTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(systemTrayIconActivated(QSystemTrayIcon::ActivationReason))); }
systemTrayIcon::systemTrayIcon(QObject *parent) : QSystemTrayIcon(parent) { connect(this, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(systemTrayIconActivated(QSystemTrayIcon::ActivationReason))); connect(&m_timer, SIGNAL(timeout()), this, SLOT(changeIcon())); m_bMouseHorer = false; m_timerCheckMousePos.start(300); connect(&m_timerCheckMousePos, SIGNAL(timeout()), this, SLOT(checkMousePos())); }
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), m_view(0) { m_hostInfoManager = new HostInfoManager; m_monitor = new Monitor(m_hostInfoManager, this); m_viewMode = new QActionGroup(this); QMenu* fileMenu = menuBar()->addMenu(tr("&File")); QAction* quitAction = fileMenu->addAction(tr("&Quit")); quitAction->setShortcut(QKeySequence::Quit); connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); QMenu* viewMenu = menuBar()->addMenu(tr("&View")); QMenu* modeMenu = viewMenu->addMenu(tr("&Mode")); m_listView = modeMenu->addAction(tr("&List View")); m_listView->setCheckable(true); m_viewMode->addAction(m_listView); connect(m_listView, SIGNAL(triggered()), this, SLOT(setupListView())); m_starView = modeMenu->addAction(tr("&Star View")); m_starView->setCheckable(true); m_viewMode->addAction(m_starView); connect(m_starView, SIGNAL(triggered()), this, SLOT(setupStarView())); m_detailedView = modeMenu->addAction(tr("&Detailed Host View")); m_detailedView->setCheckable(true); m_viewMode->addAction(m_detailedView); connect(m_detailedView, SIGNAL(triggered()), this, SLOT(setupDetailedHostView())); QAction* actionStart = viewMenu->addAction(tr("&Start")); connect(actionStart, SIGNAL(triggered()), this, SLOT(startView())); QAction* actionStop = viewMenu->addAction(tr("Stop")); connect(actionStop, SIGNAL(triggered()), this, SLOT(stopView())); viewMenu->addSeparator(); QAction* actionCheckNodes = viewMenu->addAction(tr("Check Nodes")); connect(actionCheckNodes, SIGNAL(triggered()), this, SLOT(checkNodes())); viewMenu->addSeparator(); m_configView = viewMenu->addAction(tr("Configure View...")); connect(m_configView, SIGNAL(triggered()), this, SLOT( configureView())); m_systrayAction = viewMenu->addAction(tr("System Tray")); m_systrayAction->setCheckable(true); QMenu* helpMenu = menuBar()->addMenu(tr("&Help")); helpMenu->addAction(tr("About..."), this, SLOT(showAboutDialog())); readSettings(); // Avoid useless creation and connection if the system does not have a systray if (QSystemTrayIcon::isSystemTrayAvailable()) { m_systemTrayIcon = new QSystemTrayIcon(this); m_systemTrayIcon->setIcon(QIcon(":bigIcon.png")); m_systemTrayMenu = new QMenu(this); m_systemTrayMenu->addAction(quitAction); m_systemTrayIcon->setContextMenu(m_systemTrayMenu); connect(m_systemTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(systemTrayIconActivated(QSystemTrayIcon::ActivationReason))); connect(m_systrayAction, SIGNAL(triggered(bool)), m_systemTrayIcon, SLOT(setVisible(bool))); // Only show the systray if enabled if (m_systrayAction->isChecked()) m_systemTrayIcon->show(); } else { m_systrayAction->setEnabled(false); } setWindowIcon(QIcon(":bigIcon.png")); m_monitor->checkScheduler(); }
void MainWindow::init() { //* //* Adding version info to the footer //* this->ui.label->setText(ui.label->text().replace("%version", "ClipGrab " + QCoreApplication::applicationVersion())); //* //* Tray Icon //* systemTrayIcon.setIcon(QIcon(":/img/icon.png")); systemTrayIcon.show(); connect(&systemTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(systemTrayIconActivated(QSystemTrayIcon::ActivationReason))); connect(&systemTrayIcon, SIGNAL(messageClicked()), this, SLOT(systemTrayMessageClicked())); //* //* Clipboard Handling //* connect(cg, SIGNAL(compatiblePortalFound(bool, video*)), this, SLOT(compatiblePortalFound(bool, video*))); connect(cg, SIGNAL(compatibleUrlFoundInClipboard(QString)), this, SLOT(compatibleUrlFoundInClipBoard(QString))); //* //* Download Tab //* connect(ui.downloadStart, SIGNAL(clicked()), this, SLOT(startDownload())); connect(ui.downloadLineEdit, SIGNAL(textChanged(QString)), cg, SLOT(determinePortal(QString))); connect(this, SIGNAL(itemToCancel(int)), cg, SLOT(cancelDownload(int))); //connect(ui.downloadTree, SIGNAL(doubleClicked(QModelIndex)), this, openFinishedVideo(QModelIndex)); ui.downloadTree->header()->setResizeMode(1, QHeaderView::Stretch); ui.downloadTree->header()->setStretchLastSection(false); ui.downloadTree->header()->setResizeMode(3, QHeaderView::ResizeToContents); ui.downloadLineEdit->setFocus(Qt::OtherFocusReason); int lastFormat = cg->settings.value("LastFormat", 0).toInt(); for (int i = 0; i < this->cg->formats.size(); ++i) { this->ui.downloadComboFormat->addItem(this->cg->formats.at(i)._name); } //"Fix" for Meego: this->ui.downloadComboFormat->addItem(this->cg->formats.at(0)._name); this->ui.downloadComboFormat->setCurrentIndex(lastFormat); ui.downloadPause->hide(); //Qt does currently not handle throttling downloads properly //* //* Search Tab //* this->ui.searchWebView->setContextMenuPolicy(Qt::NoContextMenu); this->searchNam = new QNetworkAccessManager(); //* //* Settings Tab //* connect(this->ui.settingsRadioClipboardAlways, SIGNAL(toggled(bool)), this, SLOT(settingsClipboard_toggled(bool))); connect(this->ui.settingsRadioClipboardNever, SIGNAL(toggled(bool)), this, SLOT(settingsClipboard_toggled(bool))); connect(this->ui.settingsRadioClipboardAsk, SIGNAL(toggled(bool)), this, SLOT(settingsClipboard_toggled(bool))); connect(this->ui.settingsRadioNotificationsAlways, SIGNAL(toggled(bool)), this, SLOT(settingsNotifications_toggled(bool))); connect(this->ui.settingsRadioNotificationsFinish, SIGNAL(toggled(bool)), this, SLOT(settingsNotifications_toggled(bool))); connect(this->ui.settingsRadioNotificationsNever, SIGNAL(toggled(bool)), this, SLOT(settingsNotifications_toggled(bool))); this->ui.settingsSavedPath->setText(cg->settings.value("savedPath", QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)).toString()); this->ui.settingsSaveLastPath->setChecked(cg->settings.value("saveLastPath", true).toBool()); ui.settingsNeverAskForPath->setChecked(cg->settings.value("NeverAskForPath", false).toBool()); ui.settingsUseMetadata->setChecked(cg->settings.value("UseMetadata", false).toBool()); connect(this->ui.settingsUseMetadata, SIGNAL(stateChanged(int)), this, SLOT(on_settingsUseMetadata_stateChanged(int))); ui.settingsUseProxy->setChecked(cg->settings.value("UseProxy", false).toBool()); ui.settingsProxyAuthenticationRequired->setChecked(cg->settings.value("ProxyAuthenticationRequired", false).toBool()); ui.settingsProxyHost->setText(cg->settings.value("ProxyHost", "").toString()); ui.settingsProxyPassword->setText(cg->settings.value("ProxyPassword", "").toString()); ui.settingsProxyPort->setValue(cg->settings.value("ProxyPort", "").toInt()); ui.settingsProxyUsername->setText(cg->settings.value("ProxyUsername", "").toString()); ui.settingsProxyType->setCurrentIndex(cg->settings.value("ProxyType", 0).toInt()); connect(this->ui.settingsUseProxy, SIGNAL(toggled(bool)), this, SLOT(settingsProxyChanged())); connect(this->ui.settingsProxyAuthenticationRequired, SIGNAL(toggled(bool)), this, SLOT(settingsProxyChanged())); connect(this->ui.settingsProxyHost, SIGNAL(textChanged(QString)), this, SLOT(settingsProxyChanged())); connect(this->ui.settingsProxyPassword, SIGNAL(textChanged(QString)), this, SLOT(settingsProxyChanged())); connect(this->ui.settingsProxyPort, SIGNAL(valueChanged(int)), this, SLOT(settingsProxyChanged())); connect(this->ui.settingsProxyUsername, SIGNAL(textChanged(QString)), this, SLOT(settingsProxyChanged())); connect(this->ui.settingsProxyType, SIGNAL(currentIndexChanged(int)), this, SLOT(settingsProxyChanged())); settingsProxyChanged(); ui.settingsMinimizeToTray->setChecked(cg->settings.value("MinimizeToTray", false).toBool()); if (cg->settings.value("Clipboard", "ask") == "always") { ui.settingsRadioClipboardAlways->setChecked(true); } else if (cg->settings.value("Clipboard", "ask") == "never") { ui.settingsRadioClipboardNever->setChecked(true); } else { ui.settingsRadioClipboardAsk->setChecked(true); } if (cg->settings.value("Notifications", "finish") == "finish") { ui.settingsRadioNotificationsFinish->setChecked(true); } else if (cg->settings.value("Notifications", "finish") == "always") { ui.settingsRadioNotificationsAlways->setChecked(true); } else { ui.settingsRadioNotificationsNever->setChecked(true); } ui.settingsUseWebM->setChecked(cg->settings.value("UseWebM", false).toBool()); ui.settingsRemoveFinishedDownloads->setChecked(cg->settings.value("RemoveFinishedDownloads", false).toBool()); int langIndex = 0; for (int i=0; i < cg->languages.count(); i++) { if (cg->languages.at(i).code == cg->settings.value("Language", "auto").toString()) { langIndex = i; } } for (int i=0; i < cg->languages.count(); i++) { ui.settingsLanguage->addItem(cg->languages.at(i).name, cg->languages.at(i).code); } ui.settingsLanguage->setCurrentIndex(langIndex); this->ui.tabWidget->removeTab(2); //fixme! startTimer(500); //* //* About Tab //* #ifdef Q_WS_MAC this->ui.downloadOpen->hide(); this->cg->settings.setValue("Clipboard", "always"); this->ui.generalSettingsTabWidget->removeTab(2); this->setStyleSheet("#label_4{padding-top:25px}#label{font-size:10px}#centralWidget{background:#fff};#mainTab{margin-top;-20px};#label_4{padding:10px}#downloadInfoBox, #settingsGeneralInfoBox, #settingsLanguageInfoBox, #aboutInfoBox, #searchInfoBox{color: background: #00B4DE;}"); this->ui.label_4->setMinimumHeight(120); #endif on_searchLineEdit_textChanged(""); this->ui.mainTab->setCurrentIndex(cg->settings.value("MainTab", 0).toInt()); }