MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { this->ui->setupUi(this); this->_statusLabel = new QLabel(this); this->ui->statusBar->addWidget(this->_statusLabel); this->showContests(); this->_dataSource = new DataSource(); this->connect(this->_dataSource, SIGNAL(currentFinished()), this, SLOT(loadCurrentFinished())); this->loadCurrentInfo(); }
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())); }