actions->insert("about", aboutAct);
connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
+ // Invisible actions
+
searchFocusAct = new QAction(tr("&Search"), this);
searchFocusAct->setShortcut(QKeySequence::Find);
actions->insert("search", searchFocusAct);
connect(searchFocusAct, SIGNAL(triggered()), this, SLOT(searchFocus()));
addAction(searchFocusAct);
+ volumeUpAct = new QAction(tr("&Volume up"), this);
+ volumeUpAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Plus));
+ actions->insert("volume-up", volumeUpAct);
+ connect(volumeUpAct, SIGNAL(triggered()), this, SLOT(volumeUp()));
+ addAction(volumeUpAct);
+
+ volumeDownAct = new QAction(tr("&Volume down"), this);
+ volumeDownAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Minus));
+ actions->insert("volume-down", volumeDownAct);
+ connect(volumeDownAct, SIGNAL(triggered()), this, SLOT(volumeDown()));
+ addAction(volumeDownAct);
+
// common action properties
foreach (QAction *action, actions->values()) {
connect(mediaObject, SIGNAL(totalTimeChanged(qint64)), this, SLOT(totalTimeChanged(qint64)));
seekSlider->setMediaObject(mediaObject);
audioOutput = new Phonon::AudioOutput(Phonon::VideoCategory, this);
+ connect(audioOutput, SIGNAL(volumeChanged(qreal)), this, SLOT(volumeChanged(qreal)));
+ connect(audioOutput, SIGNAL(mutedChanged(bool)), this, SLOT(volumeMutedChanged(bool)));
volumeSlider->setAudioOutput(audioOutput);
Phonon::createPath(mediaObject, audioOutput);
}
// qDebug() << "totalTime" << time << displayTime.toString("mm:ss");
}
+void MainWindow::volumeUp() {
+ qreal newVolume = volumeSlider->audioOutput()->volume() + .1;
+ if (newVolume > volumeSlider->maximumVolume())
+ newVolume = volumeSlider->maximumVolume();
+ volumeSlider->audioOutput()->setVolume(newVolume);
+}
+
+void MainWindow::volumeDown() {
+ qreal newVolume = volumeSlider->audioOutput()->volume() - .1;
+ if (newVolume < 0)
+ newVolume = 0;
+ volumeSlider->audioOutput()->setVolume(newVolume);
+}
+
+void MainWindow::volumeMute() {
+ volumeSlider->audioOutput()->setMuted(!volumeSlider->audioOutput()->isMuted());
+}
+
+void MainWindow::volumeChanged(qreal newVolume) {
+ // automatically unmute when volume changes
+ if (volumeSlider->audioOutput()->isMuted())
+ volumeSlider->audioOutput()->setMuted(false);
+ statusBar()->showMessage(tr("Volume at %1%").arg(newVolume*100));
+}
+
+void MainWindow::volumeMutedChanged(bool muted) {
+ if (muted)
+ statusBar()->showMessage(tr("Volume is muted"));
+ else
+ statusBar()->showMessage(tr("Volume is unmuted"));
+}
+
void MainWindow::abortDownload() {
QProgressDialog* dlg = dynamic_cast<QProgressDialog*>(this->sender());
QMap<QNetworkReply*, DownloadResource>::iterator cur;
protected:
void closeEvent(QCloseEvent *);
- struct DownloadResource
- {
- QProgressDialog* dialog;
- QFile* file;
- };
+ struct DownloadResource
+ {
+ QProgressDialog* dialog;
+ QFile* file;
+ };
private slots:
void fadeInWidget(QWidget *oldWidget, QWidget *newWidget);
void about();
void quit();
void fullscreen();
- void compactView(bool enable);
+ void compactView(bool enable);
void stop();
void stateChanged(Phonon::State newState, Phonon::State oldState);
void searchFocus();
void tick(qint64 time);
void totalTimeChanged(qint64 time);
- // download related stuff
- void abortDownload();
- void download();
- void download(const QUrl& url, const DownloadResource& res);
- void replyReadyRead();
- void replyDownloadProgress(qint64 bytesReceived, qint64 bytesTotal);
- void replyError(QNetworkReply::NetworkError code);
- void replyFinished();
- void replyMetaDataChanged();
+
+ // volume shortcuts
+ void volumeUp();
+ void volumeDown();
+ void volumeMute();
+ void volumeChanged(qreal newVolume);
+ void volumeMutedChanged(bool muted);
+
+ // download related stuff
+ void abortDownload();
+ void download();
+ void download(const QUrl& url, const DownloadResource& res);
+ void replyReadyRead();
+ void replyDownloadProgress(qint64 bytesReceived, qint64 bytesTotal);
+ void replyError(QNetworkReply::NetworkError code);
+ void replyFinished();
+ void replyMetaDataChanged();
private:
void initPhonon();
QAction *pauseAct;
QAction *stopAct;
QAction *fullscreenAct;
- QAction *compactViewAct;
+ QAction *compactViewAct;
QAction *webPageAct;
QAction *downloadAct;
+ QAction *volumeUpAct;
+ QAction *volumeDownAct;
+ QAction *volumeMuteAct;
// playlist actions
QAction *removeAct;
bool m_fullscreen;
bool m_maximized;
- QMap<QNetworkReply*, DownloadResource> m_downloads;
+ QMap<QNetworkReply*, DownloadResource> m_downloads;
};
#endif