From: Flavio Tordini Date: Wed, 11 Nov 2009 20:27:41 +0000 (+0100) Subject: new icons, refined HD mode, init Phonon once, unified toolbar, better X-Git-Tag: 0.8~19 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c78deb3c4d4e733480d62465047a9ab4f4cdf121;p=minitube new icons, refined HD mode, init Phonon once, unified toolbar, better views crossfade --- diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index f59f483..e155e51 100755 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -4,50 +4,51 @@ #include "iconloader/qticonloader.h" #include "global.h" -MainWindow::MainWindow() { - +MainWindow::MainWindow() : + mediaObject(0), + audioOutput(0), + aboutView(0) { + m_fullscreen = false; - mediaObject = 0; - audioOutput = 0; - + // views mechanism history = new QStack(); views = new QStackedWidget(this); - + // views searchView = new SearchView(this); connect(searchView, SIGNAL(search(QString)), this, SLOT(showMedia(QString))); views->addWidget(searchView); + mediaView = new MediaView(this); views->addWidget(mediaView); - - // lazily initialized views - aboutView = 0; - // settingsView = 0; - + toolbarSearch = new SearchLineEdit(this); toolbarSearch->setFont(qApp->font()); toolbarSearch->setMinimumWidth(toolbarSearch->fontInfo().pixelSize()*15); connect(toolbarSearch, SIGNAL(search(const QString&)), searchView, SLOT(watch(const QString&))); - + // build ui createActions(); createMenus(); createToolBars(); createStatusBar(); - + + initPhonon(); + mediaView->setMediaObject(mediaObject); + // remove that useless menu/toolbar context menu this->setContextMenuPolicy(Qt::NoContextMenu); - + // mediaView init stuff thats needs actions mediaView->initialize(); - + // restore window position readSettings(); - + // show the initial view showWidget(searchView); - + setCentralWidget(views); } @@ -56,9 +57,9 @@ MainWindow::~MainWindow() { } void MainWindow::createActions() { - + QMap *actions = The::globalActions(); - + /* settingsAct = new QAction(tr("&Preferences..."), this); settingsAct->setStatusTip(tr(QString("Configure ").append(Constants::APP_NAME).toUtf8())); @@ -74,34 +75,34 @@ void MainWindow::createActions() { backAct->setStatusTip(tr("Go to the previous view")); actions->insert("back", backAct); connect(backAct, SIGNAL(triggered()), this, SLOT(goBack())); - - stopAct = new QAction(QtIconLoader::icon("media-playback-stop", QIcon(":/images/stop.png")), tr("&Stop"), this); + + stopAct = new QAction(QtIconLoader::icon("media-playback-stop", QIcon(":/images/media-playback-stop.png")), tr("&Stop"), this); stopAct->setStatusTip(tr("Stop playback and go back to the search view")); 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 = new QAction(QtIconLoader::icon("media-skip-forward", QIcon(":/images/media-skip-forward.png")), tr("S&kip"), this); skipAct->setStatusTip(tr("Skip to the next video")); 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-playback-pause", QIcon(":/images/pause.png")), tr("&Pause"), this); + + pauseAct = new QAction(QtIconLoader::icon("media-playback-pause", QIcon(":/images/media-playback-pause.png")), tr("&Pause"), this); pauseAct->setStatusTip(tr("Pause playback")); 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())); - + fullscreenAct = new QAction(QtIconLoader::icon("view-fullscreen", QIcon(":/images/view-fullscreen.png")), tr("&Full Screen"), this); fullscreenAct->setStatusTip(tr("Go full screen")); fullscreenAct->setShortcut(QKeySequence(Qt::ALT + Qt::Key_Return)); fullscreenAct->setShortcutContext(Qt::ApplicationShortcut); actions->insert("fullscreen", fullscreenAct); connect(fullscreenAct, SIGNAL(triggered()), this, SLOT(fullscreen())); - + compactViewAct = new QAction(tr("&Compact mode"), this); compactViewAct->setStatusTip(tr("Hide the playlist and the toolbar")); compactViewAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Return)); @@ -110,7 +111,7 @@ void MainWindow::createActions() { compactViewAct->setEnabled(false); 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); @@ -120,130 +121,129 @@ void MainWindow::createActions() { actions->insert("download", downloadAct); connect(downloadAct, SIGNAL(triggered()), this, SLOT(download())); */ - + webPageAct = new QAction(tr("&YouTube"), this); webPageAct->setStatusTip(tr("Open the YouTube video page")); webPageAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Y)); webPageAct->setEnabled(false); actions->insert("webpage", webPageAct); connect(webPageAct, SIGNAL(triggered()), mediaView, SLOT(openWebPage())); - + removeAct = new QAction(tr("&Remove"), this); removeAct->setStatusTip(tr("Remove the selected videos from the playlist")); removeAct->setShortcuts(QList() << QKeySequence("Del") << QKeySequence("Backspace")); removeAct->setEnabled(false); actions->insert("remove", removeAct); connect(removeAct, SIGNAL(triggered()), mediaView, SLOT(removeSelected())); - + moveUpAct = new QAction(tr("Move &Up"), this); moveUpAct->setStatusTip(tr("Move up the selected videos in the playlist")); moveUpAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Up)); moveUpAct->setEnabled(false); actions->insert("moveUp", moveUpAct); connect(moveUpAct, SIGNAL(triggered()), mediaView, SLOT(moveUpSelected())); - + moveDownAct = new QAction(tr("Move &Down"), this); moveDownAct->setStatusTip(tr("Move down the selected videos in the playlist")); moveDownAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Down)); moveDownAct->setEnabled(false); actions->insert("moveDown", moveDownAct); connect(moveDownAct, SIGNAL(triggered()), mediaView, SLOT(moveDownSelected())); - + quitAct = new QAction(tr("&Quit"), this); quitAct->setMenuRole(QAction::QuitRole); quitAct->setShortcuts(QList() << QKeySequence(tr("Ctrl+Q")) << QKeySequence(Qt::CTRL + Qt::Key_W)); quitAct->setStatusTip(tr("Bye")); actions->insert("quit", quitAct); connect(quitAct, SIGNAL(triggered()), this, SLOT(quit())); - + siteAct = new QAction(tr("&Website"), this); siteAct->setShortcut(QKeySequence::HelpContents); siteAct->setStatusTip(tr("%1 on the Web").arg(Constants::APP_NAME)); actions->insert("site", siteAct); connect(siteAct, SIGNAL(triggered()), this, SLOT(visitSite())); - + donateAct = new QAction(tr("&Donate via PayPal"), this); donateAct->setStatusTip(tr("Please support the continued development of %1").arg(Constants::APP_NAME)); actions->insert("donate", donateAct); connect(donateAct, SIGNAL(triggered()), this, SLOT(donate())); - + aboutAct = new QAction(tr("&About"), this); aboutAct->setMenuRole(QAction::AboutRole); aboutAct->setStatusTip(tr("Info about %1").arg(Constants::APP_NAME)); actions->insert("about", aboutAct); connect(aboutAct, SIGNAL(triggered()), this, SLOT(about())); - + // Invisible actions - + searchFocusAct = new QAction(this); searchFocusAct->setShortcut(QKeySequence::Find); searchFocusAct->setStatusTip(tr("Search")); actions->insert("search", searchFocusAct); connect(searchFocusAct, SIGNAL(triggered()), this, SLOT(searchFocus())); addAction(searchFocusAct); - + volumeUpAct = new QAction(this); volumeUpAct->setShortcuts(QList() << QKeySequence(Qt::CTRL + Qt::Key_Plus) << QKeySequence(Qt::Key_VolumeUp)); actions->insert("volume-up", volumeUpAct); connect(volumeUpAct, SIGNAL(triggered()), this, SLOT(volumeUp())); addAction(volumeUpAct); - + volumeDownAct = new QAction(this); volumeDownAct->setShortcuts(QList() << QKeySequence(Qt::CTRL + Qt::Key_Minus) << QKeySequence(Qt::Key_VolumeDown)); actions->insert("volume-down", volumeDownAct); connect(volumeDownAct, SIGNAL(triggered()), this, SLOT(volumeDown())); addAction(volumeDownAct); - + volumeMuteAct = new QAction(this); volumeMuteAct->setStatusTip(tr("Mute volume")); volumeMuteAct->setShortcuts(QList() << QKeySequence(tr("Ctrl+M")) << QKeySequence(Qt::Key_VolumeMute)); actions->insert("volume-mute", volumeMuteAct); connect(volumeMuteAct, SIGNAL(triggered()), this, SLOT(volumeMute())); addAction(volumeMuteAct); - + QAction *hdAct = new QAction(this); hdAct->setShortcuts(QList() << QKeySequence(Qt::CTRL + Qt::Key_D)); hdAct->setIcon(createHDIcon()); hdAct->setCheckable(true); actions->insert("hd", hdAct); - QSettings settings; - connect(hdAct, SIGNAL(toggled(bool)), this, SLOT(saveHdSetting(bool))); + connect(hdAct, SIGNAL(toggled(bool)), this, SLOT(hdMode(bool))); addAction(hdAct); - + // common action properties foreach (QAction *action, actions->values()) { - + // add actions to the MainWindow so that they work // when the menu is hidden addAction(action); - + // never autorepeat. // unexperienced users tend to keep keys pressed for a "long" time action->setAutoRepeat(false); - + // set to something more meaningful then the toolbar text // HELP! how to remove tooltips altogether?! if (!action->statusTip().isEmpty()) action->setToolTip(action->statusTip()); - + // show keyboard shortcuts in the status bar if (!action->shortcut().isEmpty()) action->setStatusTip(action->statusTip() + " (" + action->shortcut().toString(QKeySequence::NativeText) + ")"); - + // make the actions work when video is fullscreen action->setShortcutContext(Qt::ApplicationShortcut); - + // no icons in menus action->setIconVisibleInMenu(false); - + } - + } void MainWindow::createMenus() { - + QMap *menus = The::globalMenus(); - + /* fileMenu = menuBar()->addMenu(tr("&Application")); // menus->insert("file", fileMenu); @@ -251,14 +251,14 @@ void MainWindow::createMenus() { fileMenu->addSeparator(); fileMenu->addAction(quitAct); */ - + playlistMenu = menuBar()->addMenu(tr("&Playlist")); menus->insert("playlist", playlistMenu); playlistMenu->addAction(removeAct); playlistMenu->addSeparator(); playlistMenu->addAction(moveUpAct); playlistMenu->addAction(moveDownAct); - + viewMenu = menuBar()->addMenu(tr("&Video")); menus->insert("video", viewMenu); // viewMenu->addAction(backAct); @@ -271,7 +271,7 @@ void MainWindow::createMenus() { // viewMenu->addAction(downloadAct); viewMenu->addAction(compactViewAct); viewMenu->addAction(fullscreenAct); - + helpMenu = menuBar()->addMenu(tr("&Help")); helpMenu->addAction(siteAct); helpMenu->addAction(donateAct); @@ -279,12 +279,14 @@ void MainWindow::createMenus() { } void MainWindow::createToolBars() { - + mainToolBar = new QToolBar(this); mainToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); mainToolBar->setFloatable(false); mainToolBar->setMovable(false); - + // cool toolbar on the Mac + setUnifiedTitleAndToolBarOnMac(true); + QFont smallerFont; smallerFont.setPointSize(smallerFont.pointSize()*.85); QFontInfo fontInfo(smallerFont); @@ -292,20 +294,20 @@ void MainWindow::createToolBars() { smallerFont.setPixelSize(10); } mainToolBar->setFont(smallerFont); - + mainToolBar->setIconSize(QSize(32,32)); // mainToolBar->addAction(backAct); mainToolBar->addAction(stopAct); mainToolBar->addAction(pauseAct); mainToolBar->addAction(skipAct); mainToolBar->addAction(fullscreenAct); - + seekSlider = new Phonon::SeekSlider(this); seekSlider->setIconVisible(false); Spacer *seekSliderSpacer = new Spacer(mainToolBar, seekSlider); seekSliderSpacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); mainToolBar->addWidget(seekSliderSpacer); - + volumeSlider = new Phonon::VolumeSlider(this); // qDebug() << volumeSlider->children(); // status tip for the volume slider @@ -320,26 +322,26 @@ void MainWindow::createToolBars() { // this makes the volume slider smaller volumeSlider->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); mainToolBar->addWidget(new Spacer(mainToolBar, volumeSlider)); - + toolbarSearch->setStatusTip(searchFocusAct->statusTip()); mainToolBar->addWidget(new Spacer(mainToolBar, toolbarSearch)); - + addToolBar(mainToolBar); } void MainWindow::createStatusBar() { currentTime = new QLabel(this); statusBar()->addPermanentWidget(currentTime); - + totalTime = new QLabel(this); statusBar()->addPermanentWidget(totalTime); - + // remove ugly borders on OSX // and remove some excessive padding statusBar()->setStyleSheet("::item{border:0 solid} " "QStatusBar, QToolBar, QToolButton {spacing:0;padding:0;margin:0} " - ); - + ); + QToolBar *toolBar = new QToolBar(this); int iconHeight = 24; // statusBar()->height(); int iconWidth = 36; // iconHeight * 3 / 2; @@ -347,14 +349,16 @@ void MainWindow::createStatusBar() { toolBar->setToolButtonStyle(Qt::ToolButtonIconOnly); toolBar->addAction(The::globalActions()->value("hd")); statusBar()->addPermanentWidget(toolBar); - + statusBar()->show(); } void MainWindow::readSettings() { QSettings settings; restoreGeometry(settings.value("geometry").toByteArray()); - The::globalActions()->value("hd")->setChecked(settings.value("hd").toBool()); + hdMode(settings.value("hd").toBool()); + audioOutput->setVolume(settings.value("volume", 1).toDouble()); + audioOutput->setMuted(settings.value("volumeMute").toBool()); } void MainWindow::writeSettings() { @@ -363,6 +367,9 @@ void MainWindow::writeSettings() { return; QSettings settings; settings.setValue("geometry", saveGeometry()); + settings.setValue("hd", The::globalActions()->value("hd")->isChecked()); + settings.setValue("volume", audioOutput->volume()); + settings.setValue("volumeMute", audioOutput->isMuted()); mediaView->saveSplitterState(); } @@ -375,18 +382,18 @@ void MainWindow::goBack() { } void MainWindow::showWidget ( QWidget* widget ) { - + setUpdatesEnabled(false); - + // call hide method on the current view View* oldView = dynamic_cast (views->currentWidget()); - if (oldView != NULL) { + if (oldView) { oldView->disappear(); } - + // call show method on the new view View* newView = dynamic_cast (widget); - if (newView != NULL) { + if (newView) { newView->appear(); QMap metadata = newView->metadata(); QString windowTitle = metadata.value("title").toString(); @@ -394,49 +401,47 @@ void MainWindow::showWidget ( QWidget* widget ) { windowTitle += " - "; setWindowTitle(windowTitle + Constants::APP_NAME); statusBar()->showMessage((metadata.value("description").toString())); - } - + // backAct->setEnabled(history->size() > 1); // settingsAct->setEnabled(widget != settingsView); stopAct->setEnabled(widget == mediaView); fullscreenAct->setEnabled(widget == mediaView); compactViewAct->setEnabled(widget == mediaView); - webPageAct->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); - + // toolbar only for the mediaView mainToolBar->setVisible(widget == mediaView && !compactViewAct->isChecked()); setUpdatesEnabled(true); - - history->push(widget); - + + QWidget *oldWidget = views->currentWidget(); + views->setCurrentWidget(widget); + #ifdef Q_WS_MAC // crossfade only on OSX // where we can be sure of video performance - fadeInWidget(views->currentWidget(), widget); + fadeInWidget(oldWidget, widget); #endif - - views->setCurrentWidget(widget); - + + history->push(widget); } void MainWindow::fadeInWidget(QWidget *oldWidget, QWidget *newWidget) { if (faderWidget) faderWidget->close(); - if (oldWidget == mediaView || newWidget == mediaView) return; - QPixmap frozenView = QPixmap::grabWidget(oldWidget); + if (!oldWidget || !newWidget) { + qDebug() << "no widgets"; + return; + } faderWidget = new FaderWidget(newWidget); - faderWidget->start(frozenView); + faderWidget->start(QPixmap::grabWidget(oldWidget)); } void MainWindow::about() { @@ -485,8 +490,6 @@ void MainWindow::showSearch() { } void MainWindow::showMedia(QString query) { - initPhonon(); - mediaView->setMediaObject(mediaObject); SearchParams *searchParams = new SearchParams(); searchParams->setKeywords(query); mediaView->search(searchParams); @@ -494,11 +497,11 @@ void MainWindow::showMedia(QString query) { } void MainWindow::stateChanged(Phonon::State newState, Phonon::State /* oldState */) { - + // qDebug() << "Phonon state: " << newState; - + switch (newState) { - + case Phonon::ErrorState: if (mediaObject->errorType() == Phonon::FatalError) { statusBar()->showMessage(tr("Fatal error: %1").arg(mediaObject->errorString())); @@ -506,28 +509,28 @@ void MainWindow::stateChanged(Phonon::State newState, Phonon::State /* oldState statusBar()->showMessage(tr("Error: %1").arg(mediaObject->errorString())); } break; - + case Phonon::PlayingState: pauseAct->setEnabled(true); - pauseAct->setIcon(QtIconLoader::icon("media-playback-pause", QIcon(":/images/pause.png"))); + pauseAct->setIcon(QtIconLoader::icon("media-playback-pause", QIcon(":/images/media-playback-pause.png"))); pauseAct->setText(tr("&Pause")); pauseAct->setStatusTip(tr("Pause playback") + " (" + pauseAct->shortcut().toString(QKeySequence::NativeText) + ")"); skipAct->setEnabled(true); break; - + case Phonon::StoppedState: pauseAct->setEnabled(false); skipAct->setEnabled(false); break; - + case Phonon::PausedState: skipAct->setEnabled(true); pauseAct->setEnabled(true); - pauseAct->setIcon(QtIconLoader::icon("media-playback-start", QIcon(":/images/play.png"))); + pauseAct->setIcon(QtIconLoader::icon("media-playback-start", QIcon(":/images/media-playback-start.png"))); pauseAct->setText(tr("&Play")); pauseAct->setStatusTip(tr("Resume playback") + " (" + pauseAct->shortcut().toString(QKeySequence::NativeText) + ")"); break; - + case Phonon::BufferingState: case Phonon::LoadingState: skipAct->setEnabled(true); @@ -535,7 +538,7 @@ void MainWindow::stateChanged(Phonon::State newState, Phonon::State /* oldState currentTime->clear(); totalTime->clear(); break; - + default: ; } @@ -547,9 +550,9 @@ void MainWindow::stop() { } void MainWindow::fullscreen() { - + setUpdatesEnabled(false); - + if (m_fullscreen) { // use setShortucs instead of setShortcut // the latter seems not to work @@ -565,52 +568,50 @@ void MainWindow::fullscreen() { fullscreenAct->setShortcuts(QList() << QKeySequence(Qt::Key_Escape) << QKeySequence(Qt::ALT + Qt::Key_Return)); fullscreenAct->setText(tr("Exit &Full Screen")); m_maximized = isMaximized(); - + // save geometry now, if the user quits when in full screen // geometry won't be saved writeSettings(); - + showFullScreen(); } - + // No compact view action when in full screen compactViewAct->setVisible(m_fullscreen); + compactViewAct->setChecked(false); + // Also no Youtube action since it opens a new window webPageAct->setVisible(m_fullscreen); - + // Hide anything but the video mediaView->setPlaylistVisible(m_fullscreen); mainToolBar->setVisible(m_fullscreen); statusBar()->setVisible(m_fullscreen); menuBar()->setVisible(m_fullscreen); - + // workaround: prevent focus on the search bar // it steals the Space key needed for Play/Pause mainToolBar->setEnabled(m_fullscreen); - + m_fullscreen = !m_fullscreen; - + setUpdatesEnabled(true); } void MainWindow::compactView(bool enable) { - + setUpdatesEnabled(false); - + // setUnifiedTitleAndToolBarOnMac(!enable); mediaView->setPlaylistVisible(!enable); mainToolBar->setVisible(!enable); statusBar()->setVisible(!enable); - - -#ifndef Q_WS_MAC menuBar()->setVisible(!enable); -#endif // ensure focus does not end up to the search box // as it would steal the Space shortcut toolbarSearch->setEnabled(!enable); - + if (enable) { stopAct->setShortcut(QString("")); QList shortcuts; @@ -658,12 +659,12 @@ void MainWindow::tick(qint64 time) { } QTime displayTime(0, (time / 60000) % 60, (time / 1000) % 60); currentTime->setText(displayTime.toString("mm:ss")); - + // remaining time tooltip int remainingTimeInt = mediaObject->remainingTime(); QTime remainingTime(0, (remainingTimeInt / 60000) % 60, (remainingTimeInt / 1000) % 60); currentTime->setStatusTip(tr("Remaining time: %1").arg(remainingTime.toString("mm:ss"))); - + // qDebug() << "currentTime" << time << displayTime.toString("mm:ss"); } @@ -801,14 +802,14 @@ QPixmap MainWindow::createHDPixmap(bool enabled) { pixmap.fill(Qt::transparent); QPainter painter(&pixmap); painter.setRenderHints(QPainter::Antialiasing, true); - + QRect rect(0, 3, 24, 18); - + QPen pen; pen.setColor(Qt::black); pen.setWidth(1); painter.setPen(pen); - + if (enabled) { painter.setBrush(palette().highlight()); } else { @@ -818,20 +819,20 @@ QPixmap MainWindow::createHDPixmap(bool enabled) { painter.setBrush(QBrush(gradient)); } painter.drawRoundedRect(rect, 5, 5); - + if (enabled) { pen.setColor(palette().highlightedText().color()); } else { pen.setColor(Qt::white); } painter.setPen(pen); - + QFont font; font.setPixelSize(12); font.setBold(true); painter.setFont(font); painter.drawText(rect, Qt::AlignCenter, "HD"); - + return pixmap; } @@ -839,22 +840,22 @@ static QIcon hdOnIcon; static QIcon hdOffIcon; QIcon MainWindow::createHDIcon() { - // QIcon icon; hdOffIcon.addPixmap(createHDPixmap(false)); hdOnIcon.addPixmap(createHDPixmap(true)); return hdOffIcon; } -void MainWindow::saveHdSetting(bool enabled) { - QSettings settings; - settings.setValue("hd", enabled); +void MainWindow::hdMode(bool enabled) { QAction *hdAct = The::globalActions()->value("hd"); + hdAct->setChecked(enabled); if (enabled) { hdAct->setStatusTip(tr("High Definition video is enabled") + " (" + hdAct->shortcut().toString(QKeySequence::NativeText) + ")"); } else { hdAct->setStatusTip(tr("High Definition video is not enabled") + " (" + hdAct->shortcut().toString(QKeySequence::NativeText) + ")"); } statusBar()->showMessage(hdAct->statusTip()); + QSettings settings; + settings.setValue("hd", enabled); } void MainWindow::hdIndicator(bool isHd) { diff --git a/src/MainWindow.h b/src/MainWindow.h index eb0cd69..6ffc83f 100755 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -54,7 +54,7 @@ private slots: void searchFocus(); void tick(qint64 time); void totalTimeChanged(qint64 time); - void saveHdSetting(bool enabled); + void hdMode(bool enabled); // volume shortcuts void volumeUp(); diff --git a/src/faderwidget/FaderWidget.cpp b/src/faderwidget/FaderWidget.cpp index 6963a8c..f2634ba 100644 --- a/src/faderwidget/FaderWidget.cpp +++ b/src/faderwidget/FaderWidget.cpp @@ -3,8 +3,8 @@ // http://labs.trolltech.com/blogs/2007/08/21/fade-effects-a-blast-from-the-past/ FaderWidget::FaderWidget(QWidget *parent) : QWidget(parent) { - timeLine = new QTimeLine(333, this); - timeLine->setFrameRange(500, 0); + timeLine = new QTimeLine(250, this); + timeLine->setFrameRange(1000, 0); connect(timeLine, SIGNAL(frameChanged(int)), this, SLOT(update())); setAttribute(Qt::WA_DeleteOnClose); resize(parent->size()); @@ -17,10 +17,11 @@ void FaderWidget::start(QPixmap frozenView) { } void FaderWidget::paintEvent(QPaintEvent *) { - const qreal opacity = timeLine->currentFrame() / 500.; + const qreal opacity = timeLine->currentFrame() / 1000.; QPainter painter(this); painter.setOpacity(opacity); painter.drawPixmap(0, 0, frozenView); + // qDebug() << opacity; if (opacity <= 0.) close();