diff options
author | Reinhard Tartler <siretart@tauware.de> | 2013-03-29 20:34:22 +0100 |
---|---|---|
committer | Reinhard Tartler <siretart@tauware.de> | 2013-03-29 20:34:22 +0100 |
commit | 228d763f5a95a2575a18e03e0ea77555106023c4 (patch) | |
tree | 1eb49f0c372de4eef020e4c7e1716248622a7f0b /src/basegui.cpp | |
parent | 038de1a143b9775f37d4848f52c59af7cee66e36 (diff) |
Imported Upstream version 0.8.4
Diffstat (limited to 'src/basegui.cpp')
-rw-r--r-- | src/basegui.cpp | 285 |
1 files changed, 249 insertions, 36 deletions
diff --git a/src/basegui.cpp b/src/basegui.cpp index f3558de..7ed7fdd 100644 --- a/src/basegui.cpp +++ b/src/basegui.cpp @@ -1,5 +1,5 @@ /* smplayer, GUI front-end for mplayer. - Copyright (C) 2006-2012 Ricardo Villalba <rvm@users.sourceforge.net> + Copyright (C) 2006-2013 Ricardo Villalba <rvm@users.sourceforge.net> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -37,6 +37,7 @@ #include <QDropEvent> #include <QDesktopServices> #include <QInputDialog> +#include <QClipboard> #include <cmath> @@ -55,7 +56,7 @@ #include "playlist.h" #include "filepropertiesdialog.h" #include "eqslider.h" -#include "videoequalizer.h" +#include "videoequalizer2.h" #include "audioequalizer.h" #include "inputdvddirectory.h" #include "inputmplayerversion.h" @@ -97,12 +98,15 @@ #include "constants.h" #include "extensions.h" +#include "version.h" #ifdef Q_OS_WIN #include "deviceinfo.h" #include <QSysInfo> #endif +#include "updatechecker.h" + using namespace Global; BaseGui::BaseGui( QWidget* parent, Qt::WindowFlags flags ) @@ -192,6 +196,16 @@ BaseGui::BaseGui( QWidget* parent, Qt::WindowFlags flags ) panel->setFocus(); initializeGui(); + +#ifdef UPDATE_CHECKER + update_checker = new UpdateChecker(this, Global::settings); + connect(update_checker, SIGNAL(newVersionFound(QString)), + this, SLOT(reportNewVersionAvailable(QString))); +#endif + +#if !defined(Q_OS_WIN) + QTimer::singleShot(2000, this, SLOT(testUpdate())); +#endif } void BaseGui::initializeGui() { @@ -732,6 +746,10 @@ void BaseGui::createActions() { #endif // Menu Help + showFirstStepsAct = new MyAction( this, "first_steps" ); + connect( showFirstStepsAct, SIGNAL(triggered()), + this, SLOT(helpFirstSteps()) ); + showFAQAct = new MyAction( this, "faq" ); connect( showFAQAct, SIGNAL(triggered()), this, SLOT(helpFAQ()) ); @@ -756,6 +774,24 @@ void BaseGui::createActions() { connect( aboutThisAct, SIGNAL(triggered()), this, SLOT(helpAbout()) ); + facebookAct = new MyAction (this, "facebook"); + twitterAct = new MyAction (this, "twitter"); + gmailAct = new MyAction (this, "gmail"); + hotmailAct = new MyAction (this, "hotmail"); + yahooAct = new MyAction (this, "yahoo"); + + connect( facebookAct, SIGNAL(triggered()), + this, SLOT(shareSMPlayer()) ); + connect( twitterAct, SIGNAL(triggered()), + this, SLOT(shareSMPlayer()) ); + connect( gmailAct, SIGNAL(triggered()), + this, SLOT(shareSMPlayer()) ); + connect( hotmailAct, SIGNAL(triggered()), + this, SLOT(shareSMPlayer()) ); + connect( yahooAct, SIGNAL(triggered()), + this, SLOT(shareSMPlayer()) ); + + // Playlist playNextAct = new MyAction(Qt::Key_Greater, this, "play_next"); connect( playNextAct, SIGNAL(triggered()), playlist, SLOT(playNext()) ); @@ -869,7 +905,7 @@ void BaseGui::createActions() { connect( doubleSizeAct, SIGNAL(triggered()), core, SLOT(toggleDoubleSize()) ); resetVideoEqualizerAct = new MyAction( this, "reset_video_equalizer"); - connect( resetVideoEqualizerAct, SIGNAL(triggered()), video_equalizer, SLOT(reset()) ); + connect( resetVideoEqualizerAct, SIGNAL(triggered()), video_equalizer2, SLOT(reset()) ); resetAudioEqualizerAct = new MyAction( this, "reset_audio_equalizer"); connect( resetAudioEqualizerAct, SIGNAL(triggered()), audio_equalizer, SLOT(reset()) ); @@ -1065,6 +1101,17 @@ void BaseGui::createActions() { connect( ccGroup, SIGNAL(activated(int)), core, SLOT(changeClosedCaptionChannel(int)) ); + subFPSGroup = new MyActionGroup(this); + subFPSNoneAct = new MyActionGroupItem(this, subFPSGroup, "sub_fps_none", MediaSettings::SFPS_None); + /* subFPS23Act = new MyActionGroupItem(this, subFPSGroup, "sub_fps_23", MediaSettings::SFPS_23); */ + subFPS23976Act = new MyActionGroupItem(this, subFPSGroup, "sub_fps_23976", MediaSettings::SFPS_23976); + subFPS24Act = new MyActionGroupItem(this, subFPSGroup, "sub_fps_24", MediaSettings::SFPS_24); + subFPS25Act = new MyActionGroupItem(this, subFPSGroup, "sub_fps_25", MediaSettings::SFPS_25); + subFPS29970Act = new MyActionGroupItem(this, subFPSGroup, "sub_fps_29970", MediaSettings::SFPS_29970); + subFPS30Act = new MyActionGroupItem(this, subFPSGroup, "sub_fps_30", MediaSettings::SFPS_30); + connect( subFPSGroup, SIGNAL(activated(int)), + core, SLOT(changeExternalSubFPS(int)) ); + // Titles titleGroup = new MyActionGroup(this); connect( titleGroup, SIGNAL(activated(int)), @@ -1539,6 +1586,14 @@ void BaseGui::retranslateStrings() { ccChannel3Act->change( "&3" ); ccChannel4Act->change( "&4" ); + subFPSNoneAct->change( tr("&Default", "subfps menu") ); + /* subFPS23Act->change( "2&3" ); */ + subFPS23976Act->change( "23.9&76" ); + subFPS24Act->change( "2&4" ); + subFPS25Act->change( "2&5" ); + subFPS29970Act->change( "29.&970" ); + subFPS30Act->change( "3&0" ); + // Menu Options showPlaylistAct->change( Images::icon("playlist"), tr("&Playlist") ); showPropertiesAct->change( Images::icon("info"), tr("View &info and properties...") ); @@ -1554,6 +1609,7 @@ void BaseGui::retranslateStrings() { #endif // Menu Help + showFirstStepsAct->change( Images::icon("guide"), tr("First Steps &Guide") ); showFAQAct->change( Images::icon("faq"), tr("&FAQ") ); showCLOptionsAct->change( Images::icon("cl_help"), tr("&Command line options") ); showCheckUpdatesAct->change( Images::icon("check_updates"), tr("Check for &updates") ); @@ -1561,6 +1617,13 @@ void BaseGui::retranslateStrings() { aboutQtAct->change( QPixmap(":/icons-png/qt.png"), tr("About &Qt") ); aboutThisAct->change( Images::icon("logo_small"), tr("About &SMPlayer") ); + facebookAct->change("&Facebook"); + twitterAct->change("&Twitter"); + gmailAct->change("&Gmail"); + hotmailAct->change("&Hotmail"); + yahooAct->change("&Yahoo!"); + + // Playlist playNextAct->change( tr("&Next") ); playPrevAct->change( tr("Pre&vious") ); @@ -1776,6 +1839,9 @@ void BaseGui::retranslateStrings() { closed_captions_menu->menuAction()->setText( tr("&Closed captions") ); closed_captions_menu->menuAction()->setIcon( Images::icon("closed_caption") ); + subfps_menu->menuAction()->setText( tr("F&rames per second") ); + subfps_menu->menuAction()->setIcon( Images::icon("subfps") ); + // Menu Browse titles_menu->menuAction()->setText( tr("&Title") ); titles_menu->menuAction()->setIcon( Images::icon("title") ); @@ -1807,6 +1873,9 @@ void BaseGui::retranslateStrings() { osd_menu->menuAction()->setText( tr("&OSD") ); osd_menu->menuAction()->setIcon( Images::icon("osd") ); + share_menu->menuAction()->setText( tr("S&hare SMPlayer with your friends") ); + share_menu->menuAction()->setIcon( Images::icon("share") ); + #if defined(LOG_MPLAYER) || defined(LOG_SMPLAYER) logs_menu->menuAction()->setText( tr("&View logs") ); logs_menu->menuAction()->setIcon( Images::icon("logs") ); @@ -1896,7 +1965,7 @@ void BaseGui::createCore() { this, SLOT(checkStayOnTop(Core::State)), Qt::QueuedConnection ); connect( core, SIGNAL(mediaStartPlay()), - this, SLOT(enterFullscreenOnPlay()) ); + this, SLOT(enterFullscreenOnPlay()), Qt::QueuedConnection ); connect( core, SIGNAL(mediaStoppedByUser()), this, SLOT(exitFullscreenOnStop()) ); @@ -1999,26 +2068,33 @@ void BaseGui::createMplayerWindow() { this, SLOT(xbutton2ClickFunction()) ); connect( mplayerwindow, SIGNAL(mouseMoved(QPoint)), this, SLOT(checkMousePos(QPoint)) ); - connect( mplayerwindow, SIGNAL(mouseMovedDiff(QPoint)), - this, SLOT(moveWindow(QPoint))); + + if (pref->move_when_dragging) { + connect( mplayerwindow, SIGNAL(mouseMovedDiff(QPoint)), + this, SLOT(moveWindow(QPoint))); + } } void BaseGui::createVideoEqualizer() { // Equalizer - video_equalizer = new VideoEqualizer(this); - - connect( video_equalizer->contrast, SIGNAL(valueChanged(int)), + video_equalizer2 = new VideoEqualizer2(this); + connect( video_equalizer2, SIGNAL(contrastChanged(int)), core, SLOT(setContrast(int)) ); - connect( video_equalizer->brightness, SIGNAL(valueChanged(int)), + connect( video_equalizer2, SIGNAL(brightnessChanged(int)), core, SLOT(setBrightness(int)) ); - connect( video_equalizer->hue, SIGNAL(valueChanged(int)), + connect( video_equalizer2, SIGNAL(hueChanged(int)), core, SLOT(setHue(int)) ); - connect( video_equalizer->saturation, SIGNAL(valueChanged(int)), + connect( video_equalizer2, SIGNAL(saturationChanged(int)), core, SLOT(setSaturation(int)) ); - connect( video_equalizer->gamma, SIGNAL(valueChanged(int)), + connect( video_equalizer2, SIGNAL(gammaChanged(int)), core, SLOT(setGamma(int)) ); - connect( video_equalizer, SIGNAL(visibilityChanged()), + + connect( video_equalizer2, SIGNAL(visibilityChanged()), this, SLOT(updateWidgets()) ); + connect( video_equalizer2, SIGNAL(requestToChangeDefaultValues()), + this, SLOT(setDefaultValuesFromVideoEqualizer()) ); + connect( video_equalizer2, SIGNAL(bySoftwareChanged(bool)), + this, SLOT(changeVideoEqualizerBySoftware(bool)) ); } void BaseGui::createAudioEqualizer() { @@ -2367,9 +2443,21 @@ void BaseGui::createMenus() { subtitlestrack_menu->menuAction()->setObjectName("subtitlestrack_menu"); subtitlesMenu->addMenu(subtitlestrack_menu); + subtitlesMenu->addSeparator(); subtitlesMenu->addAction(loadSubsAct); subtitlesMenu->addAction(unloadSubsAct); + + subfps_menu = new QMenu(this); + subfps_menu->menuAction()->setObjectName("subfps_menu"); + subfps_menu->addAction( subFPSNoneAct ); + /* subfps_menu->addAction( subFPS23Act ); */ + subfps_menu->addAction( subFPS23976Act ); + subfps_menu->addAction( subFPS24Act ); + subfps_menu->addAction( subFPS25Act ); + subfps_menu->addAction( subFPS29970Act ); + subfps_menu->addAction( subFPS30Act ); + subtitlesMenu->addMenu(subfps_menu); subtitlesMenu->addSeparator(); closed_captions_menu = new QMenu(this); @@ -2486,6 +2574,17 @@ void BaseGui::createMenus() { */ // HELP MENU + // Share submenu + share_menu = new QMenu(this); + share_menu->addAction(facebookAct); + share_menu->addAction(twitterAct); + share_menu->addAction(gmailAct); + share_menu->addAction(hotmailAct); + share_menu->addAction(yahooAct); + + helpMenu->addMenu(share_menu); + helpMenu->addSeparator(); + helpMenu->addAction(showFirstStepsAct); helpMenu->addAction(showFAQAct); helpMenu->addAction(showCLOptionsAct); helpMenu->addAction(showCheckUpdatesAct); @@ -2557,16 +2656,16 @@ void BaseGui::showPlaylist(bool b) { } void BaseGui::showVideoEqualizer() { - showVideoEqualizer( !video_equalizer->isVisible() ); + showVideoEqualizer( !video_equalizer2->isVisible() ); } void BaseGui::showVideoEqualizer(bool b) { if (!b) { - video_equalizer->hide(); + video_equalizer2->hide(); } else { // Exit fullscreen, otherwise dialog is not visible exitFullscreenIfNeeded(); - video_equalizer->show(); + video_equalizer2->show(); } updateWidgets(); } @@ -2648,6 +2747,12 @@ void BaseGui::applyNewPreferences() { #endif } + if (pref->move_when_dragging) { + connect( mplayerwindow, SIGNAL(mouseMovedDiff(QPoint)), this, SLOT(moveWindow(QPoint))); + } else { + disconnect( mplayerwindow, SIGNAL(mouseMovedDiff(QPoint)), this, SLOT(moveWindow(QPoint))); + } + #if ALLOW_TO_HIDE_VIDEO_WINDOW_ON_AUDIO_FILES if (pref->hide_video_window_on_audio_files) { connect( core, SIGNAL(noVideo()), this, SLOT(hidePanel()) ); @@ -2972,6 +3077,14 @@ void BaseGui::initializeMenus() { // Audio audioTrackGroup->clear(true); + // If using an external audio file, show the file in the menu, but disabled. + if (!core->mset.external_audio.isEmpty()) { + QAction * a = audioTrackGroup->addAction( QFileInfo(core->mset.external_audio).fileName() ); + a->setEnabled(false); + a->setCheckable(true); + a->setChecked(true); + } + else if (core->mdat.audios.numItems()==0) { QAction * a = audioTrackGroup->addAction( tr("<empty>") ); a->setEnabled(false); @@ -3120,9 +3233,15 @@ void BaseGui::updateRecents() { } void BaseGui::clearRecentsList() { - // Delete items in menu - pref->history_recents->clear(); - updateRecents(); + int ret = QMessageBox::question(this, tr("Confirm deletion - SMPlayer"), + tr("Delete the list of recent files?"), + QMessageBox::Cancel, QMessageBox::Ok); + + if (ret == QMessageBox::Ok) { + // Delete items in menu + pref->history_recents->clear(); + updateRecents(); + } } void BaseGui::updateWidgets() { @@ -3134,9 +3253,14 @@ void BaseGui::updateWidgets() { // Disable the unload subs action if there's no external subtitles unloadSubsAct->setEnabled( !core->mset.external_subtitles.isEmpty() ); + subFPSGroup->setEnabled( !core->mset.external_subtitles.isEmpty() ); + // Closed caption menu ccGroup->setChecked( core->mset.closed_caption_channel ); - + + // Subfps menu + subFPSGroup->setChecked( core->mset.external_subtitles_fps ); + // Audio menu audioTrackGroup->setChecked( core->mset.current_audio_id ); channelsGroup->setChecked( core->mset.audio_use_channels ); @@ -3251,7 +3375,8 @@ void BaseGui::updateWidgets() { } // Video equalizer - videoEqualizerAct->setChecked( video_equalizer->isVisible() ); + videoEqualizerAct->setChecked( video_equalizer2->isVisible() ); + video_equalizer2->setBySoftware( pref->use_soft_video_eq ); // Audio equalizer audioEqualizerAct->setChecked( audio_equalizer->isVisible() ); @@ -3305,11 +3430,11 @@ void BaseGui::updateWidgets() { void BaseGui::updateVideoEqualizer() { // Equalizer - video_equalizer->contrast->setValue( core->mset.contrast ); - video_equalizer->brightness->setValue( core->mset.brightness ); - video_equalizer->hue->setValue( core->mset.hue ); - video_equalizer->saturation->setValue( core->mset.saturation ); - video_equalizer->gamma->setValue( core->mset.gamma ); + video_equalizer2->setContrast( core->mset.contrast ); + video_equalizer2->setBrightness( core->mset.brightness ); + video_equalizer2->setHue( core->mset.hue ); + video_equalizer2->setSaturation( core->mset.saturation ); + video_equalizer2->setGamma( core->mset.gamma ); } void BaseGui::updateAudioEqualizer() { @@ -3319,6 +3444,29 @@ void BaseGui::updateAudioEqualizer() { } } +void BaseGui::setDefaultValuesFromVideoEqualizer() { + qDebug("BaseGui::setDefaultValuesFromVideoEqualizer"); + + pref->initial_contrast = video_equalizer2->contrast(); + pref->initial_brightness = video_equalizer2->brightness(); + pref->initial_hue = video_equalizer2->hue(); + pref->initial_saturation = video_equalizer2->saturation(); + pref->initial_gamma = video_equalizer2->gamma(); + + QMessageBox::information(this, tr("Information"), + tr("The current values have been stored to be " + "used as default.") ); +} + +void BaseGui::changeVideoEqualizerBySoftware(bool b) { + qDebug("BaseGui::changeVideoEqualizerBySoftware: %d", b); + + if (b != pref->use_soft_video_eq) { + pref->use_soft_video_eq = b; + core->restart(); + } +} + /* void BaseGui::playlistVisibilityChanged() { #if !DOCK_PLAYLIST @@ -3442,6 +3590,12 @@ void BaseGui::openURL() { InputURL d(this); + // Get url from clipboard + QString clipboard_text = QApplication::clipboard()->text(); + if ((!clipboard_text.isEmpty()) && (clipboard_text.contains("://")) /*&& (QUrl(clipboard_text).isValid())*/) { + d.setURL(clipboard_text); + } + for (int n=0; n < pref->history_urls->count(); n++) { d.setURL( pref->history_urls->url(n) ); } @@ -3679,15 +3833,13 @@ void BaseGui::loadAudioFile() { if (!s.isEmpty()) core->loadAudioFile(s); } -void BaseGui::helpFAQ() { - /* - QUrl url = QUrl::fromLocalFile(Paths::doc("faq.html", pref->language)); - qDebug("BaseGui::helpFAQ: file to open %s", url.toString().toUtf8().data()); - QDesktopServices::openUrl( url ); - */ +void BaseGui::helpFirstSteps() { + QDesktopServices::openUrl(QString("http://smplayer.sourceforge.net/guide.php?version=%1").arg(smplayerVersion())); +} +void BaseGui::helpFAQ() { QString url = "http://smplayer.sourceforge.net/faq.php"; - if (!pref->language.isEmpty()) url += QString("?tr_lang=%1").arg(pref->language); + /* if (!pref->language.isEmpty()) url += QString("?tr_lang=%1").arg(pref->language); */ QDesktopServices::openUrl( QUrl(url) ); } @@ -3701,8 +3853,8 @@ void BaseGui::helpCLOptions() { } void BaseGui::helpCheckUpdates() { - QString url = "http://smplayer.sourceforge.net/latest.php"; - if (!pref->language.isEmpty()) url += QString("?tr_lang=%1").arg(pref->language); + QString url = "http://smplayer.sourceforge.net/changes.php"; + /* if (!pref->language.isEmpty()) url += QString("?tr_lang=%1").arg(pref->language); */ QDesktopServices::openUrl( QUrl(url) ); } @@ -3719,6 +3871,31 @@ void BaseGui::helpAboutQt() { QMessageBox::aboutQt(this, tr("About Qt") ); } +void BaseGui::shareSMPlayer() { + QString text = QString("SMPlayer - Free Media Player with built-in codecs that can play and download Youtube videos").replace(" ","+"); + QString url = "http://smplayer.sourceforge.net"; + + if (sender() == twitterAct) { + QDesktopServices::openUrl(QUrl("http://twitter.com/intent/tweet?text=" + text + "&url=" + url + "/&via=smplayer_dev")); + } + else + if (sender() == gmailAct) { + QDesktopServices::openUrl(QUrl("https://mail.google.com/mail/?view=cm&fs=1&to&su=" + text + "&body=" + url + "&ui=2&tf=1&shva=1")); + } + else + if (sender() == yahooAct) { + QDesktopServices::openUrl(QUrl("http://compose.mail.yahoo.com/?To=&Subject=" + text + "&body=" + url)); + } + else + if (sender() == hotmailAct) { + QDesktopServices::openUrl(QUrl("http://www.hotmail.msn.com/secure/start?action=compose&to=&subject=" + text + "&body=" + url)); + } + else + if (sender() == facebookAct) { + QDesktopServices::openUrl(QUrl("http://www.facebook.com/sharer.php?u=" + url + "&t=" + text)); + } +} + void BaseGui::showGotoDialog() { TimeDialog d(this); d.setLabel(tr("&Jump to:")); @@ -4027,6 +4204,42 @@ void BaseGui::displayWarningAboutOldMplayer() { } #endif +#ifdef UPDATE_CHECKER +void BaseGui::reportNewVersionAvailable(QString new_version) { + QMessageBox::StandardButton button = QMessageBox::information(this, tr("New version available"), + tr("A new version of SMPlayer is available.") + "<br><br>" + + tr("Installed version: %1").arg(stableVersion()) + "<br>" + + tr("Available version: %1").arg(new_version) + "<br><br>" + + tr("Would you like to know more about this new version?"), + QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); + + if (button == QMessageBox::Yes) { + QDesktopServices::openUrl(QUrl("http://smplayer.sourceforge.net/changes.php")); + } + + update_checker->saveVersion(new_version); +} +#endif + +#if !defined(Q_OS_WIN) +void BaseGui::testUpdate() { + qDebug("BaseGui::testUpdate"); + QSettings * set = Global::settings; + set->beginGroup("smplayer"); + QString version = set->value("version", "").toString(); + bool check_for_new_version = set->value("check_for_new_version", true).toBool(); + set->setValue("version", stableVersion()); + set->setValue("check_for_new_version", check_for_new_version); + set->endGroup(); + + if ( (check_for_new_version) && (version != stableVersion()) ) { + // Running a new version + qDebug("BaseGui::testUpdate: running a new version: %s", stableVersion().toUtf8().constData()); + QDesktopServices::openUrl(QString("http://smplayer.sourceforge.net/guide.php?version=%1&so=linux").arg(smplayerVersion())); + } +} +#endif + void BaseGui::dragEnterEvent( QDragEnterEvent *e ) { qDebug("BaseGui::dragEnterEvent"); |