summaryrefslogtreecommitdiff
path: root/src/basegui.cpp
diff options
context:
space:
mode:
authorMateusz Łukasik <mati75@linuxmint.pl>2015-04-26 20:41:29 +0200
committerMateusz Łukasik <mati75@linuxmint.pl>2015-04-26 20:41:29 +0200
commit6027a8ff2d6ae4eba912427c30c58208009c1ebc (patch)
tree756eddd2fc9e7a9943b43e6ff3f9e92cbd4c3352 /src/basegui.cpp
parent45ee5ac6dc2159352596ce8e8ec744e0c864d492 (diff)
Imported Upstream version 14.9.0.6887~ds0
Diffstat (limited to 'src/basegui.cpp')
-rw-r--r--src/basegui.cpp162
1 files changed, 112 insertions, 50 deletions
diff --git a/src/basegui.cpp b/src/basegui.cpp
index f843374..c616fe2 100644
--- a/src/basegui.cpp
+++ b/src/basegui.cpp
@@ -67,6 +67,7 @@
#include "about.h"
#include "errordialog.h"
#include "timedialog.h"
+#include "stereo3ddialog.h"
#include "clhelp.h"
#include "mplayerversion.h"
@@ -98,6 +99,10 @@
#include "constants.h"
+#ifdef MPRIS2
+#include "mpris2/mpris2.h"
+#endif
+
#include "extensions.h"
#include "version.h"
@@ -106,7 +111,9 @@
#include <QSysInfo>
#endif
+#ifdef UPDATE_CHECKER
#include "updatechecker.h"
+#endif
#ifdef YOUTUBE_SUPPORT
#ifdef YT_USE_SCRIPT
@@ -118,6 +125,10 @@
#include "sharedialog.h"
#endif
+#ifdef SHAREWIDGET
+#include "sharewidget.h"
+#endif
+
#ifdef AUTO_SHUTDOWN_PC
#include "shutdowndialog.h"
#include "shutdown.h"
@@ -130,6 +141,9 @@ BaseGui::BaseGui( QWidget* parent, Qt::WindowFlags flags )
#if QT_VERSION >= 0x050000
, was_minimized(false)
#endif
+#ifdef UPDATE_CHECKER
+ , update_checker(0)
+#endif
{
#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
#ifdef AVOID_SCREENSAVER
@@ -225,27 +239,25 @@ BaseGui::BaseGui( QWidget* parent, Qt::WindowFlags flags )
#ifdef UPDATE_CHECKER
update_checker = new UpdateChecker(this, &pref->update_checker_data);
- connect(update_checker, SIGNAL(newVersionFound(QString)),
- this, SLOT(reportNewVersionAvailable(QString)));
#endif
#ifdef CHECK_UPGRADED
QTimer::singleShot(2000, this, SLOT(checkIfUpgraded()));
#endif
-#ifdef REMINDER_ACTIONS
+#if defined(REMINDER_ACTIONS) && !defined(SHAREWIDGET)
QTimer::singleShot(1000, this, SLOT(checkReminder()));
#endif
+
+#ifdef MPRIS2
+ new Mpris2(this, this);
+#endif
}
void BaseGui::initializeGui() {
if (pref->compact_mode) toggleCompactMode(true);
changeStayOnTop(pref->stay_on_top);
-#if ALLOW_CHANGE_STYLESHEET
- changeStyleSheet(pref->iconset);
-#endif
-
updateRecents();
// Call loadActions() outside initialization of the class.
@@ -482,7 +494,7 @@ void BaseGui::createActions() {
connect( frameStepAct, SIGNAL(triggered()),
core, SLOT(frameStep()) );
- frameBackStepAct = new MyAction( Qt::Key_Colon, this, "frame_back_step" );
+ frameBackStepAct = new MyAction( Qt::Key_Comma, this, "frame_back_step" );
connect( frameBackStepAct, SIGNAL(triggered()),
core, SLOT(frameBackStep()) );
@@ -614,6 +626,9 @@ void BaseGui::createActions() {
connect( mirrorAct, SIGNAL(toggled(bool)),
core, SLOT(toggleMirror(bool)) );
+ stereo3dAct = new MyAction( this, "stereo_3d_filter" );
+ connect( stereo3dAct, SIGNAL(triggered()),
+ this, SLOT(showStereo3dDialog()) );
// Submenu filter
postProcessingAct = new MyAction( this, "postprocessing" );
@@ -1018,6 +1033,9 @@ void BaseGui::createActions() {
showFilenameAct = new MyAction(Qt::SHIFT | Qt::Key_I, this, "show_filename");
connect( showFilenameAct, SIGNAL(triggered()), core, SLOT(showFilenameOnOSD()) );
+ showTimeAct = new MyAction(Qt::Key_I, this, "show_time");
+ connect( showTimeAct, SIGNAL(triggered()), core, SLOT(showTimeOnOSD()) );
+
toggleDeinterlaceAct = new MyAction(Qt::Key_D, this, "toggle_deinterlacing");
connect( toggleDeinterlaceAct, SIGNAL(triggered()), core, SLOT(toggleDeinterlace()) );
@@ -1292,6 +1310,7 @@ void BaseGui::setActionsEnabled(bool b) {
screenshotsAct->setEnabled(b);
flipAct->setEnabled(b);
mirrorAct->setEnabled(b);
+ stereo3dAct->setEnabled(b);
postProcessingAct->setEnabled(b);
phaseAct->setEnabled(b);
deblockAct->setEnabled(b);
@@ -1431,6 +1450,7 @@ void BaseGui::enableActionsOnPlaying() {
screenshotsAct->setEnabled(false);
flipAct->setEnabled(false);
mirrorAct->setEnabled(false);
+ stereo3dAct->setEnabled(false);
postProcessingAct->setEnabled(false);
phaseAct->setEnabled(false);
deblockAct->setEnabled(false);
@@ -1475,6 +1495,7 @@ void BaseGui::enableActionsOnPlaying() {
screenshotsAct->setEnabled(false);
flipAct->setEnabled(false);
mirrorAct->setEnabled(false);
+ stereo3dAct->setEnabled(false);
postProcessingAct->setEnabled(false);
phaseAct->setEnabled(false);
deblockAct->setEnabled(false);
@@ -1516,15 +1537,18 @@ void BaseGui::disableActionsOnStop() {
playOrPauseAct->setEnabled(true);
stopAct->setEnabled(true);
}
+#endif // AUTODISABLE_ACTIONS
void BaseGui::togglePlayAction(Core::State state) {
qDebug("BaseGui::togglePlayAction");
+
+#if AUTODISABLE_ACTIONS
if (state == Core::Playing)
playAct->setEnabled(false);
else
playAct->setEnabled(true);
+#endif
}
-#endif // AUTODISABLE_ACTIONS
void BaseGui::retranslateStrings() {
setWindowIcon( Images::icon("logo", 64) );
@@ -1612,6 +1636,7 @@ void BaseGui::retranslateStrings() {
#endif
flipAct->change( Images::icon("flip"), tr("Fli&p image") );
mirrorAct->change( Images::icon("mirror"), tr("Mirr&or image") );
+ stereo3dAct->change( Images::icon("stereo3d"), tr("Stereo &3D filter") );
decZoomAct->change( tr("Zoom &-") );
incZoomAct->change( tr("Zoom &+") );
@@ -1775,6 +1800,7 @@ void BaseGui::retranslateStrings() {
nextWheelFunctionAct->change( Images::icon("next_wheel_function"), tr("Next wheel function") );
showFilenameAct->change( tr("Show filename on OSD") );
+ showTimeAct->change( tr("Show playback time on OSD") );
toggleDeinterlaceAct->change( tr("Toggle deinterlacing") );
@@ -2160,6 +2186,14 @@ void BaseGui::createMplayerWindow() {
mplayerwindow->setAnimatedLogo( pref->animated_logo);
#endif
+#ifdef SHAREWIDGET
+ sharewidget = new ShareWidget(Global::settings, mplayerwindow);
+ mplayerwindow->setCornerWidget(sharewidget);
+ #ifdef REMINDER_ACTIONS
+ connect(sharewidget, SIGNAL(supportClicked()), this, SLOT(helpDonate()));
+ #endif
+#endif
+
QVBoxLayout * layout = new QVBoxLayout;
layout->setSpacing(0);
layout->setMargin(0);
@@ -2504,6 +2538,7 @@ void BaseGui::createMenus() {
videoMenu->addAction(flipAct);
videoMenu->addAction(mirrorAct);
+ videoMenu->addAction(stereo3dAct);
videoMenu->addSeparator();
videoMenu->addAction(videoEqualizerAct);
videoMenu->addAction(screenshotAct);
@@ -2864,6 +2899,7 @@ void BaseGui::showPreferencesDialog() {
pl->setAutoGetInfo(playlist->autoGetInfo());
pl->setSavePlaylistOnExit(playlist->savePlaylistOnExit());
pl->setPlayFilesFromStart(playlist->playFilesFromStart());
+ pl->setIgnorePlayerErrors(playlist->ignorePlayerErrors());
pref_dialog->show();
}
@@ -2907,9 +2943,9 @@ void BaseGui::applyNewPreferences() {
if (_interface->iconsetChanged()) {
need_update_language = true;
// Stylesheet
-#if ALLOW_CHANGE_STYLESHEET
- changeStyleSheet(pref->iconset);
-#endif
+ #if ALLOW_CHANGE_STYLESHEET
+ if (!_interface->guiChanged()) changeStyleSheet(pref->iconset);
+ #endif
}
mplayerwindow->activateMouseDragTracking(pref->move_when_dragging);
@@ -2955,6 +2991,7 @@ void BaseGui::applyNewPreferences() {
playlist->setAutoGetInfo(pl->autoGetInfo());
playlist->setSavePlaylistOnExit(pl->savePlaylistOnExit());
playlist->setPlayFilesFromStart(pl->playFilesFromStart());
+ playlist->setIgnorePlayerErrors(pl->ignorePlayerErrors());
if (need_update_language) {
@@ -4126,9 +4163,12 @@ void BaseGui::helpCLOptions() {
}
void BaseGui::helpCheckUpdates() {
- QString url = "http://smplayer.sourceforge.net/changes.php";
- /* if (!pref->language.isEmpty()) url += QString("?tr_lang=%1").arg(pref->language); */
+#ifdef UPDATE_CHECKER
+ update_checker->check();
+#else
+ QString url = QString("http://smplayer.sourceforge.net/changes.php?version=%1").arg(Version::with_revision());
QDesktopServices::openUrl( QUrl(url) );
+#endif
}
void BaseGui::helpShowConfig() {
@@ -4139,15 +4179,24 @@ void BaseGui::helpShowConfig() {
void BaseGui::helpDonate() {
ShareDialog d(this);
d.showRemindCheck(false);
+
+ #ifdef SHAREWIDGET
+ d.setActions(sharewidget->actions());
+ #endif
+
d.exec();
int action = d.actions();
qDebug("BaseGui::helpDonate: action: %d", action);
if (action > 0) {
+ #ifdef SHAREWIDGET
+ sharewidget->setActions(action);
+ #else
QSettings * set = Global::settings;
set->beginGroup("reminder");
set->setValue("action", action);
set->endGroup();
+ #endif
}
}
#endif
@@ -4234,6 +4283,16 @@ void BaseGui::showSubDelayDialog() {
}
}
+void BaseGui::showStereo3dDialog() {
+ Stereo3dDialog d(this);
+ d.setInputFormat(core->mset.stereo3d_in);
+ d.setOutputFormat(core->mset.stereo3d_out);
+
+ if (d.exec() == QDialog::Accepted) {
+ core->changeStereo3d(d.inputFormat(), d.outputFormat());
+ }
+}
+
void BaseGui::exitFullscreen() {
if (pref->fullscreen) {
toggleFullscreen(false);
@@ -4308,7 +4367,8 @@ void BaseGui::toggleFullscreen(bool b) {
if ((pref->add_blackborders_on_fullscreen) &&
(!core->mset.add_letterbox))
{
- core->restart();
+ core->changeLetterboxOnFullscreen(b);
+ /* core->restart(); */
}
setFocus(); // Fixes bug #2493415
@@ -4511,23 +4571,6 @@ 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(Version::with_revision()) + "<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
-
#ifdef CHECK_UPGRADED
void BaseGui::checkIfUpgraded() {
qDebug("BaseGui::checkIfUpgraded");
@@ -4548,7 +4591,7 @@ void BaseGui::checkIfUpgraded() {
}
#endif
-#ifdef REMINDER_ACTIONS
+#if defined(REMINDER_ACTIONS) && !defined(SHAREWIDGET)
void BaseGui::checkReminder() {
qDebug("BaseGui::checkReminder");
@@ -4597,7 +4640,7 @@ void BaseGui::YTNoSslSupport() {
qDebug("BaseGui::YTNoSslSupport");
QMessageBox::warning(this, tr("Connection failed"),
tr("The video you requested needs to open a HTTPS connection.") +"<br>"+
- tr("Unfortunately the openssl component, required for it, it's not available in your system.") +"<br>"+
+ tr("Unfortunately the OpenSSL component, required for it, is not available in your system.") +"<br>"+
tr("Please, visit %1 to know how to fix this problem.")
.arg("<a href=\"http://smplayer.sourceforge.net/openssl.php\">" + tr("this link") + "</a>") );
}
@@ -4643,6 +4686,12 @@ void BaseGui::YTUpdateScript() {
void BaseGui::gotForbidden() {
qDebug("BaseGui::gotForbidden");
+
+ if (!pref->report_mplayer_crashes) {
+ qDebug("BaseGui::gotForbidden: not displaying error dialog");
+ return;
+ }
+
static bool busy = false;
if (busy) return;
@@ -5113,10 +5162,10 @@ void BaseGui::exitFullscreenIfNeeded() {
}
#if ALLOW_CHANGE_STYLESHEET
-void BaseGui::loadQss(QString filename) {
+QString BaseGui::loadQss(QString filename) {
QFile file( filename );
file.open(QFile::ReadOnly);
- QString styleSheet = QLatin1String(file.readAll());
+ QString stylesheet = QLatin1String(file.readAll());
#ifdef USE_RESOURCES
Images::setTheme(pref->iconset);
@@ -5133,29 +5182,42 @@ void BaseGui::loadQss(QString filename) {
QString td = Images::themesDirectory();
QString path = current.relativeFilePath(td);
#endif
- styleSheet.replace(QRegExp("url\\s*\\(\\s*([^\\);]+)\\s*\\)", Qt::CaseSensitive, QRegExp::RegExp2),
+ stylesheet.replace(QRegExp("url\\s*\\(\\s*([^\\);]+)\\s*\\)", Qt::CaseSensitive, QRegExp::RegExp2),
QString("url(%1\\1)").arg(path + "/"));
- //qDebug("BaseGui::loadQss: styeSheet: %s", styleSheet.toUtf8().constData());
- qApp->setStyleSheet(styleSheet);
+ //qDebug("BaseGui::loadQss: styleSheet: %s", stylesheet.toUtf8().constData());
+ return stylesheet;
}
void BaseGui::changeStyleSheet(QString style) {
- if (style.isEmpty()) {
- qApp->setStyleSheet("");
- }
- else {
- QString qss_file = Paths::configPath() + "/themes/" + pref->iconset +"/style.qss";
- //qDebug("BaseGui::changeStyleSheet: '%s'", qss_file.toUtf8().data());
+ qDebug("BaseGui::changeStyleSheet: %s", style.toUtf8().constData());
+
+ // Load default stylesheet
+ QString stylesheet = loadQss(":/default-theme/style.qss");
+
+ if (!style.isEmpty()) {
+ // Check main.css
+ QString qss_file = Paths::configPath() + "/themes/" + pref->iconset + "/main.css";
+ if (!QFile::exists(qss_file)) {
+ qss_file = Paths::themesPath() +"/"+ pref->iconset + "/main.css";
+ }
+
+ // Check style.qss
if (!QFile::exists(qss_file)) {
- qss_file = Paths::themesPath() +"/"+ pref->iconset +"/style.qss";
+ qss_file = Paths::configPath() + "/themes/" + pref->iconset + "/style.qss";
+ if (!QFile::exists(qss_file)) {
+ qss_file = Paths::themesPath() +"/"+ pref->iconset + "/style.qss";
+ }
}
+
+ // Load style file
if (QFile::exists(qss_file)) {
qDebug("BaseGui::changeStyleSheet: '%s'", qss_file.toUtf8().data());
- loadQss(qss_file);
- } else {
- qApp->setStyleSheet("");
+ stylesheet += loadQss(qss_file);
}
}
+
+ //qDebug("BaseGui::changeStyleSheet: styleSheet: %s", stylesheet.toUtf8().constData());
+ qApp->setStyleSheet(stylesheet);
}
#endif
@@ -5311,7 +5373,7 @@ void BaseGui::showErrorFromMplayer(QProcess::ProcessError e) {
qDebug("BaseGui::showErrorFromMplayer");
if (!pref->report_mplayer_crashes) {
- qDebug("showErrorFromMplayer: not displaying error dialog");
+ qDebug("BaseGui::showErrorFromMplayer: not displaying error dialog");
return;
}