diff options
author | Mateusz Łukasik <mati75@linuxmint.pl> | 2016-01-21 21:34:24 +0100 |
---|---|---|
committer | Mateusz Łukasik <mati75@linuxmint.pl> | 2016-01-21 21:34:24 +0100 |
commit | ba0162e8cb8a12c90ef9775f5a20a6da095a0b35 (patch) | |
tree | 5ff6c7b940c8b260fa15bc6c951486e3f5a971ec /src/basegui.cpp | |
parent | ef3806d30c06fc3b5c2910ef4faebef27bbd6bad (diff) |
Imported Upstream version 16.1.0~ds0
Diffstat (limited to 'src/basegui.cpp')
-rw-r--r-- | src/basegui.cpp | 116 |
1 files changed, 78 insertions, 38 deletions
diff --git a/src/basegui.cpp b/src/basegui.cpp index aa89453..5e23449 100644 --- a/src/basegui.cpp +++ b/src/basegui.cpp @@ -1,5 +1,5 @@ /* smplayer, GUI front-end for mplayer. - Copyright (C) 2006-2015 Ricardo Villalba <rvm@users.sourceforge.net> + Copyright (C) 2006-2016 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 @@ -200,20 +200,11 @@ BaseGui::BaseGui( QWidget* parent, Qt::WindowFlags flags ) connect( mplayerwindow, SIGNAL(wheelDown()), core, SLOT(wheelDown()) ); - // Set style before changing color of widgets: - // Set style #if STYLE_SWITCHING - /* - qDebug("BaseGui::BaseGui: style name: '%s'", qApp->style()->objectName().toUtf8().data()); - qDebug("BaseGui::BaseGui: style class name: '%s'", qApp->style()->metaObject()->className()); - qDebug("BaseGui::BaseGui: pref->style: '%s'", pref->style.toUtf8().constData()); - */ - + qApp->setStyleSheet(""); default_style = qApp->style()->objectName(); - if (!pref->style.isEmpty()) { - qApp->setStyleSheet(""); // Remove a previous stylesheet to prevent a crash - qApp->setStyle( pref->style ); - } + qDebug() << "BaseGui::BaseGui: default_style:" << default_style; + //qDebug() << "BaseGui::BaseGui: qApp->style:" << qApp->style(); #endif #ifdef LOG_MPLAYER @@ -1289,7 +1280,7 @@ void BaseGui::createActions() { connect( bookmarkGroup, SIGNAL(activated(int)), core, SLOT(goToSec(int)) ); - addBookmarkAct = new MyAction(this, "add_bookmark"); + addBookmarkAct = new MyAction(Qt::CTRL | Qt::Key_A, this, "add_bookmark"); connect(addBookmarkAct, SIGNAL(triggered()), this, SLOT(showAddBookmarkDialog())); editBookmarksAct = new MyAction(this, "edit_bookmarks"); @@ -1600,6 +1591,17 @@ void BaseGui::enableActionsOnPlaying() { dvdnavMouseAct->setEnabled(false); } #endif + + +#ifdef BOOKMARKS + if (pref->dont_remember_media_settings || core->mdat.type != TYPE_FILE) { + addBookmarkAct->setEnabled(false); + editBookmarksAct->setEnabled(false); + } else { + addBookmarkAct->setEnabled(true); + editBookmarksAct->setEnabled(true); + } +#endif } void BaseGui::disableActionsOnStop() { @@ -2050,7 +2052,11 @@ void BaseGui::retranslateStrings() { reverseAct->change( tr("Re&verse") ); // Menu Subtitle +#ifdef MPV_SUPPORT + subtitles_track_menu->menuAction()->setText( tr("Prim&ary track") ); +#else subtitles_track_menu->menuAction()->setText( tr("&Select") ); +#endif subtitles_track_menu->menuAction()->setIcon( Images::icon("sub") ); #ifdef MPV_SUPPORT @@ -3064,7 +3070,7 @@ void BaseGui::applyNewPreferences() { need_update_language = true; // Stylesheet #if ALLOW_CHANGE_STYLESHEET - if (!_interface->guiChanged()) changeStyleSheet(pref->iconset); + if (!_interface->guiChanged()) applyStyles(); #endif } @@ -3123,13 +3129,7 @@ void BaseGui::applyNewPreferences() { #if STYLE_SWITCHING if (_interface->styleChanged()) { - qDebug( "selected style: '%s'", pref->style.toUtf8().data() ); - if ( !pref->style.isEmpty()) { - qApp->setStyle( pref->style ); - } else { - qDebug("setting default style: '%s'", default_style.toUtf8().data() ); - qApp->setStyle( default_style ); - } + applyStyles(); } #endif @@ -3716,9 +3716,6 @@ void BaseGui::updateWidgets() { // Titles titleGroup->setChecked( core->mset.current_title_id ); - // Chapters - chapterGroup->setChecked( core->mset.current_chapter_id ); - // Angles angleGroup->setChecked( core->mset.current_angle_id ); @@ -4563,6 +4560,10 @@ void BaseGui::toggleFullscreen(bool b) { void BaseGui::aboutToEnterFullscreen() { + if (pref->stay_on_top == Preferences::WhilePlayingOnTop && core->state() == Core::Playing) { + setStayOnTop(false); + } + if (!pref->compact_mode) { menuBar()->hide(); statusBar()->hide(); @@ -4574,6 +4575,15 @@ void BaseGui::aboutToExitFullscreen() { menuBar()->show(); statusBar()->show(); } + + if (pref->stay_on_top == Preferences::WhilePlayingOnTop) { + qApp->processEvents(); + #if QT_VERSION < 0x050000 + setStayOnTop(core->state() == Core::Playing); + #else + QTimer::singleShot(100, this, SLOT(updateStayOnTop())); + #endif + } } @@ -5218,19 +5228,21 @@ void BaseGui::resizeMainWindow(int w, int h) { mplayerwindow->size().width(), mplayerwindow->size().height() ); -#ifdef Q_OS_WIN // Check if a part of the window is outside of the desktop - QRect screen_rect = QApplication::desktop()->screenGeometry(this); - QPoint right_bottom = QPoint(this->pos().x() + this->width(), this->pos().y() + this->height()); - qDebug("BaseGui::resizeWindow: right bottom point: %d, %d", right_bottom.x(), right_bottom.y());; - if (!screen_rect.contains(right_bottom) || !screen_rect.contains(this->pos())) { - qDebug("BaseGui::resizeWindow: the window is outside of the desktop, it will be moved"); - //move(screen_rect.x(), screen_rect.y()); - int x = screen_rect.x() + ((screen_rect.width() - width()) / 2); - int y = screen_rect.y() + ((screen_rect.height() - height()) / 2); - move(x, y); + // and center the window in that case + if ((pref->center_window_if_outside) && (!core->mdat.novideo)) { + QRect screen_rect = QApplication::desktop()->screenGeometry(this); + QPoint right_bottom = QPoint(this->pos().x() + this->width(), this->pos().y() + this->height()); + qDebug("BaseGui::resizeWindow: right bottom point: %d, %d", right_bottom.x(), right_bottom.y());; + if (!screen_rect.contains(right_bottom) || !screen_rect.contains(this->pos())) { + qDebug("BaseGui::resizeWindow: the window is outside of the desktop, it will be moved"); + //move(screen_rect.x(), screen_rect.y()); + int x = screen_rect.x() + ((screen_rect.width() - width()) / 2); + int y = screen_rect.y() + ((screen_rect.height() - height()) / 2); + move(x, y); + } } -#endif + } void BaseGui::hidePanel() { @@ -5238,7 +5250,7 @@ void BaseGui::hidePanel() { if (panel->isVisible()) { // Exit from fullscreen mode - if (pref->fullscreen) { toggleFullscreen(false); update(); } + if (pref->fullscreen) { toggleFullscreen(false); update(); } // Exit from compact mode first if (pref->compact_mode) toggleCompactMode(false); @@ -5373,11 +5385,20 @@ void BaseGui::changeStayOnTop(int stay_on_top) { void BaseGui::checkStayOnTop(Core::State state) { qDebug("BaseGui::checkStayOnTop"); - if ((!pref->fullscreen) && (pref->stay_on_top == Preferences::WhilePlayingOnTop)) { + if ((!pref->fullscreen) && (pref->stay_on_top == Preferences::WhilePlayingOnTop)) { setStayOnTop((state == Core::Playing)); } } +#if QT_VERSION >= 0x050000 +void BaseGui::updateStayOnTop() { + qDebug("BaseGui::updateStayOnTop"); + if (pref->stay_on_top == Preferences::WhilePlayingOnTop) { + setStayOnTop(core->state() == Core::Playing); + } +} +#endif + void BaseGui::toggleStayOnTop() { if (pref->stay_on_top == Preferences::AlwaysOnTop) changeStayOnTop(Preferences::NeverOnTop); @@ -5397,6 +5418,8 @@ void BaseGui::exitFullscreenIfNeeded() { #if ALLOW_CHANGE_STYLESHEET QString BaseGui::loadQss(QString filename) { + qDebug("BaseGui::loadQss: %s", filename.toUtf8().constData()); + QFile file( filename ); file.open(QFile::ReadOnly); QString stylesheet = QLatin1String(file.readAll()); @@ -5455,6 +5478,23 @@ void BaseGui::changeStyleSheet(QString style) { } #endif +void BaseGui::applyStyles() { + qDebug("BaseGui::applyStyles"); + +#if ALLOW_CHANGE_STYLESHEET + qDebug() << "BaseGui::applyStyles: stylesheet:" << pref->iconset; + changeStyleSheet(pref->iconset); +#endif + +#if STYLE_SWITCHING + QString style = pref->style; + if (style.isEmpty()) style = default_style; + qDebug() << "BaseGui::applyStyles: style:" << style; + if (!style.isEmpty()) qApp->setStyle(style); +#endif + +} + void BaseGui::loadActions() { qDebug("BaseGui::loadActions"); ActionsEditor::loadFromConfig(this, settings); |