X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2FMainWindow.cpp;h=a7621f19ab5785848048526a2384240cebb9d9bd;hb=0817201dd8aa205f3532c3d850e63786b728e649;hp=d19c080f1bb64220dc5fb1ac38011ec14efbc257;hpb=c2f60ab20223d156dd784513c0e095806b081493;p=minitube diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index d19c080..a7621f1 100755 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -5,6 +5,7 @@ #include "global.h" MainWindow::MainWindow() { + m_fullscreen = false; mediaObject = 0; audioOutput = 0; @@ -75,20 +76,20 @@ void MainWindow::createActions() { stopAct = new QAction(QtIconLoader::icon("media-stop", QIcon(":/images/stop.png")), tr("&Stop"), this); stopAct->setStatusTip(tr("Stop playback and go back to the search view")); - stopAct->setShortcut(QKeySequence(Qt::Key_Escape)); + stopAct->setShortcuts(QList() << QKeySequence(Qt::Key_Escape) << QKeySequence(Qt::Key_MediaStop)); actions->insert("stop", stopAct); connect(stopAct, SIGNAL(triggered()), this, SLOT(stop())); skipAct = new QAction(QtIconLoader::icon("media-skip-forward", QIcon(":/images/skip.png")), tr("S&kip"), this); skipAct->setStatusTip(tr("Skip to the next video")); - skipAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Right)); + skipAct->setShortcuts(QList() << QKeySequence(Qt::CTRL + Qt::Key_Right) << QKeySequence(Qt::Key_MediaNext)); skipAct->setEnabled(false); actions->insert("skip", skipAct); connect(skipAct, SIGNAL(triggered()), mediaView, SLOT(skip())); pauseAct = new QAction(QtIconLoader::icon("media-pause", QIcon(":/images/pause.png")), tr("&Pause"), this); pauseAct->setStatusTip(tr("Pause playback")); - pauseAct->setShortcut(QKeySequence(Qt::Key_Space)); + pauseAct->setShortcuts(QList() << QKeySequence(Qt::Key_Space) << QKeySequence(Qt::Key_MediaPlay)); pauseAct->setEnabled(false); actions->insert("pause", pauseAct); connect(pauseAct, SIGNAL(triggered()), mediaView, SLOT(pause())); @@ -109,6 +110,7 @@ void MainWindow::createActions() { actions->insert("compactView", compactViewAct); connect(compactViewAct, SIGNAL(toggled(bool)), this, SLOT(compactView(bool))); + /* // icon should be document-save but it is ugly downloadAct = new QAction(QtIconLoader::icon("go-down", QIcon(":/images/go-down.png")), tr("&Download"), this); downloadAct->setStatusTip(tr("Download this video")); @@ -116,6 +118,7 @@ void MainWindow::createActions() { downloadAct->setEnabled(false); actions->insert("download", downloadAct); connect(downloadAct, SIGNAL(triggered()), this, SLOT(download())); + */ webPageAct = new QAction(QtIconLoader::icon("internet-web-browser", QIcon(":/images/internet-web-browser.png")), tr("&YouTube"), this); webPageAct->setStatusTip(tr("Open the YouTube video page")); @@ -126,9 +129,7 @@ void MainWindow::createActions() { removeAct = new QAction(tr("&Remove"), this); removeAct->setStatusTip(tr("Remove the selected videos from the playlist")); - QList shortcuts; - shortcuts << QKeySequence("Del") << QKeySequence("Backspace"); - removeAct->setShortcuts(shortcuts); + removeAct->setShortcuts(QList() << QKeySequence("Del") << QKeySequence("Backspace")); removeAct->setEnabled(false); actions->insert("remove", removeAct); connect(removeAct, SIGNAL(triggered()), mediaView, SLOT(removeSelected())); @@ -173,24 +174,30 @@ void MainWindow::createActions() { // Invisible actions - searchFocusAct = new QAction(tr("&Search"), this); + searchFocusAct = new QAction(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 = new QAction(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 = new QAction(this); volumeDownAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Minus)); actions->insert("volume-down", volumeDownAct); connect(volumeDownAct, SIGNAL(triggered()), this, SLOT(volumeDown())); addAction(volumeDownAct); + volumeMuteAct = new QAction(this); + volumeMuteAct->setShortcut(tr("Ctrl+M")); + actions->insert("volume-mute", volumeMuteAct); + connect(volumeMuteAct, SIGNAL(triggered()), this, SLOT(volumeMute())); + addAction(volumeMuteAct); + // common action properties foreach (QAction *action, actions->values()) { @@ -203,6 +210,10 @@ void MainWindow::createActions() { action->setAutoRepeat(false); action->setToolTip(action->statusTip()); + // show keyboard shortcuts in the status bar + if (!action->shortcut().isEmpty()) + action->setStatusTip(action->statusTip() + " (" + action->shortcut().toString() + ")"); + // make the actions work when video is fullscreen action->setShortcutContext(Qt::ApplicationShortcut); @@ -221,10 +232,8 @@ void MainWindow::createMenus() { fileMenu = menuBar()->addMenu(tr("&Application")); // menus->insert("file", fileMenu); - /* - fileMenu->addAction(settingsAct); + // fileMenu->addAction(settingsAct); fileMenu->addSeparator(); - */ fileMenu->addAction(quitAct); playlistMenu = menuBar()->addMenu(tr("&Playlist")); @@ -243,7 +252,7 @@ void MainWindow::createMenus() { viewMenu->addSeparator(); viewMenu->addAction(webPageAct); viewMenu->addSeparator(); - viewMenu->addAction(downloadAct); + // viewMenu->addAction(downloadAct); viewMenu->addAction(compactViewAct); viewMenu->addAction(fullscreenAct); @@ -352,9 +361,12 @@ void MainWindow::showWidget ( QWidget* widget ) { compactViewAct->setEnabled(widget == mediaView); webPageAct->setEnabled(widget == mediaView); aboutAct->setEnabled(widget != aboutView); + + /* // this is not the best place to enable downloads, but the user is informed // if there really is no video is playing downloadAct->setEnabled(widget == mediaView); + */ // cool toolbar on the Mac // setUnifiedTitleAndToolBarOnMac(widget == mediaView); @@ -454,7 +466,7 @@ void MainWindow::stateChanged(Phonon::State newState, Phonon::State /* oldState pauseAct->setEnabled(true); pauseAct->setIcon(QtIconLoader::icon("media-pause", QIcon(":/images/pause.png"))); pauseAct->setText(tr("&Pause")); - pauseAct->setStatusTip(tr("Pause playback")); + pauseAct->setStatusTip(tr("Pause playback") + " (" + pauseAct->shortcut().toString() + ")"); skipAct->setEnabled(true); break; @@ -468,7 +480,7 @@ void MainWindow::stateChanged(Phonon::State newState, Phonon::State /* oldState pauseAct->setEnabled(true); pauseAct->setIcon(QtIconLoader::icon("media-play", QIcon(":/images/play.png"))); pauseAct->setText(tr("&Play")); - pauseAct->setStatusTip(tr("Resume playback")); + pauseAct->setStatusTip(tr("Resume playback") + " (" + pauseAct->shortcut().toString() + ")"); break; case Phonon::BufferingState: @@ -496,19 +508,14 @@ void MainWindow::fullscreen() { if (m_fullscreen) { // use setShortucs instead of setShortcut // the latter seems not to work - QList shortcuts; - shortcuts << QKeySequence(Qt::ALT + Qt::Key_Return); - fullscreenAct->setShortcuts(shortcuts); + fullscreenAct->setShortcuts(QList() << QKeySequence(Qt::ALT + Qt::Key_Return)); fullscreenAct->setText(tr("&Full Screen")); - stopAct->setShortcut(QKeySequence(Qt::Key_Escape)); + stopAct->setShortcuts(QList() << QKeySequence(Qt::Key_Escape) << QKeySequence(Qt::Key_MediaStop)); if (m_maximized) showMaximized(); else showNormal(); } else { - stopAct->setShortcut(QString("")); - QList shortcuts; - // for some reason it is important that ESC comes first - shortcuts << QKeySequence(Qt::Key_Escape) << QKeySequence(Qt::ALT + Qt::Key_Return); - fullscreenAct->setShortcuts(shortcuts); + stopAct->setShortcuts(QList() << QKeySequence(Qt::Key_MediaStop)); + fullscreenAct->setShortcuts(QList() << QKeySequence(Qt::Key_Escape) << QKeySequence(Qt::ALT + Qt::Key_Return)); fullscreenAct->setText(tr("Exit &Full Screen")); m_maximized = isMaximized(); @@ -589,7 +596,7 @@ void MainWindow::initPhonon() { void MainWindow::tick(qint64 time) { if (time <= 0) { - totalTime->clear(); + currentTime->clear(); return; } QTime displayTime(0, (time / 60000) % 60, (time / 1000) % 60); @@ -639,6 +646,7 @@ void MainWindow::volumeMutedChanged(bool muted) { statusBar()->showMessage(tr("Volume is unmuted")); } +/* void MainWindow::abortDownload() { QProgressDialog* dlg = dynamic_cast(this->sender()); QMap::iterator cur; @@ -721,3 +729,5 @@ void MainWindow::replyMetaDataChanged() { m_downloads.remove(r); } } + +*/