void MainWindow::onTrayIconActivated( QSystemTrayIcon::ActivationReason reason ) { // typical linux behavior is single clicking tray icon toggles the main window #ifdef Q_WS_X11 if (reason == QSystemTrayIcon::Trigger) toggleWindowVisibility(); #else if (reason == QSystemTrayIcon::DoubleClick) toggleWindowVisibility(); #endif }
void NPlayer::trayIconCountClicks(int clicks) { if (clicks == 1) { m_mainWindow->show(); m_mainWindow->activateWindow(); m_mainWindow->raise(); } else if (clicks == 2) { toggleWindowVisibility(); } if (!m_settings->value("TrayIcon").toBool()) m_systemTray->setVisible(!m_mainWindow->isVisible()); }
void FacebookWidget::onSystemTrayClicked(QSystemTrayIcon::ActivationReason reason) { if (reason == QSystemTrayIcon::Trigger) toggleWindowVisibility(); }
void NPlayer::connectSignals() { connect(m_playbackEngine, SIGNAL(mediaChanged(const QString &)), this, SLOT(on_playbackEngine_mediaChanged(const QString &))); connect(m_playbackEngine, SIGNAL(mediaChanged(const QString &)), m_waveformSlider, SLOT(setMedia(const QString &))); connect(m_playbackEngine, SIGNAL(stateChanged(N::PlaybackState)), this, SLOT(on_playbackEngine_stateChanged(N::PlaybackState))); connect(m_playbackEngine, SIGNAL(aboutToFinish()), m_playlistWidget, SLOT(currentFinished()), Qt::BlockingQueuedConnection); connect(m_playbackEngine, SIGNAL(positionChanged(qreal)), m_waveformSlider, SLOT(setValue(qreal))); connect(m_playbackEngine, SIGNAL(tick(qint64)), m_trackInfoWidget, SLOT(tick(qint64))); connect(m_playbackEngine, SIGNAL(finished()), m_playlistWidget, SLOT(currentFinished())); connect(m_playbackEngine, SIGNAL(failed()), this, SLOT(on_playbackEngine_failed())); connect(m_playbackEngine, SIGNAL(message(QMessageBox::Icon, const QString &, const QString &)), m_logDialog, SLOT(showMessage(QMessageBox::Icon, const QString &, const QString &))); connect(m_mainWindow, SIGNAL(closed()), this, SLOT(on_mainWindow_closed())); connect(m_preferencesDialog, SIGNAL(settingsChanged()), this, SLOT(on_preferencesDialog_settingsChanged())); if (m_coverWidget) connect(m_playbackEngine, SIGNAL(mediaChanged(const QString &)), m_coverWidget, SLOT(setSource(const QString &))); if (QAbstractButton *playButton = qFindChild<QAbstractButton *>(m_mainWindow, "playButton")) connect(playButton, SIGNAL(clicked()), this, SLOT(on_playButton_clicked())); if (QAbstractButton *stopButton = qFindChild<QAbstractButton *>(m_mainWindow, "stopButton")) connect(stopButton, SIGNAL(clicked()), m_playbackEngine, SLOT(stop())); if (QAbstractButton *prevButton = qFindChild<QAbstractButton *>(m_mainWindow, "prevButton")) connect(prevButton, SIGNAL(clicked()), m_playlistWidget, SLOT(playPrevItem())); if (QAbstractButton *nextButton = qFindChild<QAbstractButton *>(m_mainWindow, "nextButton")) connect(nextButton, SIGNAL(clicked()), m_playlistWidget, SLOT(playNextItem())); if (QAbstractButton *closeButton = qFindChild<QAbstractButton *>(m_mainWindow, "closeButton")) connect(closeButton, SIGNAL(clicked()), m_mainWindow, SLOT(close())); if (QAbstractButton *minimizeButton = qFindChild<QAbstractButton *>(m_mainWindow, "minimizeButton")) connect(minimizeButton, SIGNAL(clicked()), m_mainWindow, SLOT(showMinimized())); if (m_volumeSlider) { connect(m_volumeSlider, SIGNAL(sliderMoved(qreal)), m_playbackEngine, SLOT(setVolume(qreal))); connect(m_playbackEngine, SIGNAL(volumeChanged(qreal)), m_volumeSlider, SLOT(setValue(qreal))); connect(m_mainWindow, SIGNAL(scrolled(int)), this, SLOT(on_mainWindow_scrolled(int))); } if (QAbstractButton *repeatButton = qFindChild<QAbstractButton *>(m_mainWindow, "repeatButton")) { connect(repeatButton, SIGNAL(clicked(bool)), m_playlistWidget, SLOT(setRepeatMode(bool))); connect(m_playlistWidget, SIGNAL(repeatModeChanged(bool)), repeatButton, SLOT(setChecked(bool))); } if (QAbstractButton *shuffleButton = qFindChild<QAbstractButton *>(m_mainWindow, "shuffleButton")) { connect(shuffleButton, SIGNAL(clicked(bool)), m_playlistWidget, SLOT(setShuffleMode(bool))); connect(m_playlistWidget, SIGNAL(shuffleModeChanged(bool)), shuffleButton, SLOT(setChecked(bool))); } connect(m_playlistWidget, SIGNAL(setMedia(const QString &)), m_playbackEngine, SLOT(setMedia(const QString &))); connect(m_playlistWidget, SIGNAL(currentActivated()), m_playbackEngine, SLOT(play())); connect(m_playlistWidget, SIGNAL(shuffleModeChanged(bool)), m_shufflePlaylistAction, SLOT(setChecked(bool))); connect(m_playlistWidget, SIGNAL(repeatModeChanged(bool)), m_repeatPlaylistAction, SLOT(setChecked(bool))); connect(m_waveformSlider, SIGNAL(filesDropped(const QStringList &)), m_playlistWidget, SLOT(playFiles(const QStringList &))); connect(m_waveformSlider, SIGNAL(sliderMoved(qreal)), m_playbackEngine, SLOT(setPosition(qreal))); connect(m_showHideAction, SIGNAL(triggered()), this, SLOT(toggleWindowVisibility())); connect(m_playAction, SIGNAL(triggered()), m_playbackEngine, SLOT(play())); connect(m_stopAction, SIGNAL(triggered()), m_playbackEngine, SLOT(stop())); connect(m_prevAction, SIGNAL(triggered()), m_playlistWidget, SLOT(playPrevItem())); connect(m_nextAction, SIGNAL(triggered()), m_playlistWidget, SLOT(playNextItem())); connect(m_preferencesAction, SIGNAL(triggered()), m_preferencesDialog, SLOT(exec())); connect(m_exitAction, SIGNAL(triggered()), this, SLOT(quit())); connect(m_addFilesAction, SIGNAL(triggered()), this, SLOT(showOpenFileDialog())); connect(m_playlistWidget, SIGNAL(activateEmptyFail()), m_addFilesAction, SLOT(trigger())); connect(m_addDirAction, SIGNAL(triggered()), this, SLOT(showOpenDirDialog())); connect(m_savePlaylistAction, SIGNAL(triggered()), this, SLOT(showSavePlaylistDialog())); connect(m_showCoverAction, SIGNAL(toggled(bool)), this, SLOT(on_showCoverAction_toggled(bool))); connect(m_aboutAction, SIGNAL(triggered()), this, SLOT(showAboutMessageBox())); connect(m_playingOnTopAction, SIGNAL(toggled(bool)), this, SLOT(on_whilePlayingOnTopAction_toggled(bool))); connect(m_alwaysOnTopAction, SIGNAL(toggled(bool)), this, SLOT(on_alwaysOnTopAction_toggled(bool))); connect(m_fullScreenAction, SIGNAL(triggered()), m_mainWindow, SLOT(toggleFullScreen())); connect(m_shufflePlaylistAction, SIGNAL(triggered(bool)), m_playlistWidget, SLOT(setShuffleMode(bool))); connect(m_repeatPlaylistAction, SIGNAL(triggered(bool)), m_playlistWidget, SLOT(setRepeatMode(bool))); connect(m_loopPlaylistAction, SIGNAL(triggered()), this, SLOT(on_playlistAction_triggered())); connect(m_nextFileEnableAction, SIGNAL(triggered()), this, SLOT(on_playlistAction_triggered())); connect(m_nextFileByNameAscdAction, SIGNAL(triggered()), this, SLOT(on_playlistAction_triggered())); connect(m_nextFileByNameDescAction, SIGNAL(triggered()), this, SLOT(on_playlistAction_triggered())); connect(m_nextFileByDateAscd, SIGNAL(triggered()), this, SLOT(on_playlistAction_triggered())); connect(m_nextFileByDateDesc, SIGNAL(triggered()), this, SLOT(on_playlistAction_triggered())); foreach (NAction *action, findChildren<NAction *>()) { if (action->objectName().startsWith("Jump")) connect(action, SIGNAL(triggered()), this, SLOT(on_jumpAction_triggered())); } connect(m_mainWindow, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint))); connect(m_systemTray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(on_trayIcon_activated(QSystemTrayIcon::ActivationReason))); connect(m_trayClickTimer, SIGNAL(timeout()), this, SLOT(on_trayClickTimer_timeout())); }
FacebookWidget::FacebookWidget(QWidget *parent) : QWidget(parent), ui(new Ui::FacebookWidget) { systemTrayIcon = new QSystemTrayIcon(QIcon(":/res/logo/Facebook-icon.png")); systemTrayMenu = new QMenu(); notificationAction = new QAction(tr("Notifications"),this); friendRequestAction = new QAction(tr("Friend requests"),this); messagesAction = new QAction(tr("Messages"),this); quitAction = new QAction(tr("Quit"),this); windowVisibilityToggleAction = new QAction(tr("Hide"),this); aboutWindow = new AboutWindow(); windowVisible = true; systemTrayMenu->addAction(windowVisibilityToggleAction); systemTrayMenu->addSeparator(); systemTrayMenu->addAction(friendRequestAction); systemTrayMenu->addAction(messagesAction); systemTrayMenu->addAction(notificationAction); systemTrayMenu->addSeparator(); systemTrayMenu->addAction(quitAction); systemTrayIcon->setContextMenu(systemTrayMenu); systemTrayIcon->show(); themeSelectorWidget = new ThemeSelectorWidget(); pressed = false; ui->setupUi(this); webView = new QWebView(); ui->mainLayout->addWidget(webView); webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); this->setLayout(ui->mainLayout); connect(webView->page()->networkAccessManager(),SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)),this,SLOT(sslErrorHandler(QNetworkReply*,QList<QSslError>))); connect(webView,SIGNAL(loadProgress(int)),ui->progressBar,SLOT(setValue(int))); connect(webView,SIGNAL(loadFinished(bool)),ui->progressBar,SLOT(reset())); connect(ui->backButton,SIGNAL(clicked()),webView,SLOT(back())); connect(ui->forwardButton,SIGNAL(clicked()),webView,SLOT(forward())); connect(ui->closeButton,SIGNAL(clicked()),this,SLOT(toggleWindowVisibility())); connect(quitAction,SIGNAL(triggered()),this,SLOT(quitActionTriggered())); #ifndef Q_OS_MAC connect(systemTrayIcon,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this,SLOT(onSystemTrayClicked(QSystemTrayIcon::ActivationReason))); #endif connect(friendRequestAction,SIGNAL(triggered()),this,SLOT(friendRequestActionTriggered())); connect(messagesAction,SIGNAL(triggered()),this,SLOT(messagesActionTriggered())); connect(notificationAction,SIGNAL(triggered()),this,SLOT(notificationActionTriggered())); connect(windowVisibilityToggleAction,SIGNAL(triggered()),this,SLOT(toggleWindowVisibility())); connect(webView->page(),SIGNAL(linkClicked(QUrl)),this,SLOT(delegateLink(QUrl))); connect(ui->aboutButton,SIGNAL(clicked()),aboutWindow,SLOT(show())); connect(ui->maximizeButton,SIGNAL(clicked()),this,SLOT(fullscreenToggle())); connect(ui->themeButton,SIGNAL(clicked()),themeSelectorWidget,SLOT(show())); connect(themeSelectorWidget,SIGNAL(applyTheme(QStringList)),this,SLOT(setTheme(QStringList))); connect(themeSelectorWidget,SIGNAL(useDefaultTheme()),this,SLOT(useDefaultTheme())); windowSizes << QRect(10,10,640,480); windowSizes << QRect(10,10,800,480); windowSizes << QRect(10,10,1030,600); windowSizes << desktopDetails.availableGeometry(); windowSizeIndex = 2; setGeometry(windowSizes.at(2)); setWindowFlags(Qt::FramelessWindowHint); themeRefreshTimer = new QTimer(); QWebSettings::globalSettings()->setAttribute(QWebSettings::PluginsEnabled,true); QDir configDir = QDir::home(); configDir.mkpath(".config/Socializer"); configDir.mkpath(".config/Socializer/LocalStorage/"); configDir.mkpath(".config/Socializer/OfflineStorage/"); configDir.mkpath(".config/Socializer/IconDatabase/"); configDir.mkpath(".config/Socializer/OfflineWebApplicationCache/"); configDir.cd(".config/Socializer"); configDir.cd("OfflineStorage"); QWebSettings::setOfflineStoragePath(configDir.absolutePath()); configDir.cdUp(); configDir.cd("IconDatabase"); QWebSettings::setIconDatabasePath(configDir.absolutePath()); configDir.cdUp(); configDir.cd("OfflineWebApplicationCache"); QWebSettings::setOfflineWebApplicationCachePath(configDir.absolutePath()); configDir.cdUp(); QWebSettings::setMaximumPagesInCache(100); QWebSettings::globalSettings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled,true); QWebSettings::globalSettings()->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled,true); QWebSettings::globalSettings()->setAttribute(QWebSettings::LocalStorageEnabled,true); cookieJar = new CookieJar; webView->page()->networkAccessManager()->setCookieJar(cookieJar); cookieJar->load(); configDir.cd("LocalStorage"); webView->page()->settings()->setLocalStoragePath(configDir.absolutePath()); webView->page()->settings()->setAttribute(QWebSettings::LocalStorageEnabled,true); configDir.cdUp(); QTimer *refreshTimer = new QTimer(); refreshTimer->setInterval(5000); connect(refreshTimer,SIGNAL(timeout()),this,SLOT(getNewStatus())); refreshTimer->start(); fullscreen = false; loadApplicationState(); }