diff options
author | Mateusz Łukasik <mati75@linuxmint.pl> | 2015-12-06 19:08:44 +0100 |
---|---|---|
committer | Mateusz Łukasik <mati75@linuxmint.pl> | 2015-12-06 19:08:44 +0100 |
commit | ef3806d30c06fc3b5c2910ef4faebef27bbd6bad (patch) | |
tree | eacad504d5240c2354c1801d88542efc6ceccc2c /src/basegui.cpp | |
parent | d21eb029cb664abe3893776c8345b300c084fe31 (diff) |
Imported Upstream version 15.11.0~ds0
Diffstat (limited to 'src/basegui.cpp')
-rw-r--r-- | src/basegui.cpp | 223 |
1 files changed, 219 insertions, 4 deletions
diff --git a/src/basegui.cpp b/src/basegui.cpp index 9651d10..aa89453 100644 --- a/src/basegui.cpp +++ b/src/basegui.cpp @@ -39,6 +39,7 @@ #include <QInputDialog> #include <QClipboard> #include <QMimeData> +#include <QDesktopWidget> #include <cmath> @@ -68,6 +69,12 @@ #include "errordialog.h" #include "timedialog.h" #include "stereo3ddialog.h" + +#ifdef BOOKMARKS +#include "inputbookmark.h" +#include "bookmarkdialog.h" +#endif + #include "clhelp.h" #include "mplayerversion.h" @@ -196,11 +203,15 @@ BaseGui::BaseGui( QWidget* parent, Qt::WindowFlags flags ) // Set style before changing color of widgets: // Set style #if STYLE_SWITCHING - qDebug( "Style name: '%s'", qApp->style()->objectName().toUtf8().data() ); - qDebug( "Style class name: '%s'", qApp->style()->metaObject()->className() ); + /* + 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()); + */ default_style = qApp->style()->objectName(); if (!pref->style.isEmpty()) { + qApp->setStyleSheet(""); // Remove a previous stylesheet to prevent a crash qApp->setStyle( pref->style ); } #endif @@ -616,6 +627,12 @@ void BaseGui::createActions() { connect( screenshotsAct, SIGNAL(triggered()), core, SLOT(screenshots()) ); +#ifdef CAPTURE_STREAM + capturingAct = new MyAction( /*Qt::Key_C,*/ this, "capture_stream"); + connect( capturingAct, SIGNAL(triggered()), + core, SLOT(switchCapturing()) ); +#endif + #ifdef VIDEOPREVIEW videoPreviewAct = new MyAction( this, "video_preview" ); connect( videoPreviewAct, SIGNAL(triggered()), @@ -733,6 +750,7 @@ void BaseGui::createActions() { // Submenu Filters +#ifdef MPLAYER_SUPPORT extrastereoAct = new MyAction( this, "extrastereo_filter" ); extrastereoAct->setCheckable( true ); connect( extrastereoAct, SIGNAL(toggled(bool)), @@ -742,6 +760,7 @@ void BaseGui::createActions() { karaokeAct->setCheckable( true ); connect( karaokeAct, SIGNAL(toggled(bool)), core, SLOT(toggleKaraoke(bool)) ); +#endif volnormAct = new MyAction( this, "volnorm_filter" ); volnormAct->setCheckable( true ); @@ -784,7 +803,7 @@ void BaseGui::createActions() { incSubScaleAct = new MyAction( Qt::SHIFT | Qt::Key_T, this, "inc_sub_scale" ); connect( incSubScaleAct, SIGNAL(triggered()), core, SLOT(incSubScale()) ); - + decSubStepAct = new MyAction( Qt::Key_G, this, "dec_sub_step" ); connect( decSubStepAct, SIGNAL(triggered()), core, SLOT(decSubStep()) ); @@ -793,6 +812,16 @@ void BaseGui::createActions() { connect( incSubStepAct, SIGNAL(triggered()), core, SLOT(incSubStep()) ); +#ifdef MPV_SUPPORT + seekNextSubAct = new MyAction(Qt::CTRL | Qt::Key_Right, this, "seek_next_sub"); + connect(seekNextSubAct, SIGNAL(triggered()), + core, SLOT(seekToNextSub())); + + seekPrevSubAct = new MyAction(Qt::CTRL | Qt::Key_Left, this, "seek_prev_sub"); + connect(seekPrevSubAct, SIGNAL(triggered()), + core, SLOT(seekToPrevSub())); +#endif + useCustomSubStyleAct = new MyAction(this, "use_custom_sub_style"); useCustomSubStyleAct->setCheckable(true); connect( useCustomSubStyleAct, SIGNAL(toggled(bool)), core, SLOT(changeUseCustomSubStyle(bool)) ); @@ -1254,6 +1283,25 @@ void BaseGui::createActions() { connect( chapterGroup, SIGNAL(activated(int)), core, SLOT(changeChapter(int)) ); +#ifdef BOOKMARKS + // Bookmarks + bookmarkGroup = new MyActionGroup(this); + connect( bookmarkGroup, SIGNAL(activated(int)), + core, SLOT(goToSec(int)) ); + + addBookmarkAct = new MyAction(this, "add_bookmark"); + connect(addBookmarkAct, SIGNAL(triggered()), this, SLOT(showAddBookmarkDialog())); + + editBookmarksAct = new MyAction(this, "edit_bookmarks"); + connect(editBookmarksAct, SIGNAL(triggered()), this, SLOT(showBookmarkDialog())); + + prevBookmarkAct = new MyAction(Qt::CTRL | Qt::Key_B, this, "prev_bookmark"); + connect(prevBookmarkAct, SIGNAL(triggered()), core, SLOT(prevBookmark())); + + nextBookmarkAct = new MyAction(Qt::CTRL | Qt::Key_N, this, "next_bookmark"); + connect(nextBookmarkAct, SIGNAL(triggered()), core, SLOT(nextBookmark())); +#endif + #if DVDNAV_SUPPORT dvdnavUpAct = new MyAction(Qt::SHIFT | Qt::Key_Up, this, "dvdnav_up"); connect( dvdnavUpAct, SIGNAL(triggered()), core, SLOT(dvdnavUp()) ); @@ -1316,6 +1364,9 @@ void BaseGui::setActionsEnabled(bool b) { videoEqualizerAct->setEnabled(b); screenshotAct->setEnabled(b); screenshotsAct->setEnabled(b); +#ifdef CAPTURE_STREAM + capturingAct->setEnabled(b); +#endif flipAct->setEnabled(b); mirrorAct->setEnabled(b); stereo3dAct->setEnabled(b); @@ -1336,8 +1387,10 @@ void BaseGui::setActionsEnabled(bool b) { decAudioDelayAct->setEnabled(b); incAudioDelayAct->setEnabled(b); audioDelayAct->setEnabled(b); +#ifdef MPLAYER_SUPPORT extrastereoAct->setEnabled(b); karaokeAct->setEnabled(b); +#endif volnormAct->setEnabled(b); loadAudioAct->setEnabled(b); //unloadAudioAct->setEnabled(b); @@ -1354,6 +1407,10 @@ void BaseGui::setActionsEnabled(bool b) { decSubStepAct->setEnabled(b); incSubScaleAct->setEnabled(b); decSubScaleAct->setEnabled(b); +#ifdef MPV_SUPPORT + seekNextSubAct->setEnabled(b); + seekPrevSubAct->setEnabled(b); +#endif // Actions not in menus #if !USE_MULTIPLE_SHORTCUTS @@ -1429,6 +1486,10 @@ void BaseGui::enableActionsOnPlaying() { screenshotAct->setEnabled( screenshots_enabled ); screenshotsAct->setEnabled( screenshots_enabled ); +#ifdef CAPTURE_STREAM + capturingAct->setEnabled(!pref->capture_directory.isEmpty() && QFileInfo(pref->capture_directory).isDir()); +#endif + // Disable the compact action if not using video window compactAct->setEnabled( panel->isVisible() ); @@ -1444,8 +1505,10 @@ void BaseGui::enableActionsOnPlaying() { decAudioDelayAct->setEnabled(false); incAudioDelayAct->setEnabled(false); audioDelayAct->setEnabled(false); +#ifdef MPLAYER_SUPPORT extrastereoAct->setEnabled(false); karaokeAct->setEnabled(false); +#endif volnormAct->setEnabled(false); channelsGroup->setActionsEnabled(false); stereoGroup->setActionsEnabled(false); @@ -1456,6 +1519,9 @@ void BaseGui::enableActionsOnPlaying() { videoEqualizerAct->setEnabled(false); screenshotAct->setEnabled(false); screenshotsAct->setEnabled(false); +#ifdef CAPTURE_STREAM + capturingAct->setEnabled(false); +#endif flipAct->setEnabled(false); mirrorAct->setEnabled(false); stereo3dAct->setEnabled(false); @@ -1639,6 +1705,9 @@ void BaseGui::retranslateStrings() { videoEqualizerAct->change( Images::icon("equalizer"), tr("&Equalizer") ); screenshotAct->change( Images::icon("screenshot"), tr("&Screenshot") ); screenshotsAct->change( Images::icon("screenshots"), tr("Start/stop takin&g screenshots") ); +#ifdef CAPTURE_STREAM + capturingAct->change(Images::icon("record"), tr("Start/stop capturing stream")); +#endif #ifdef VIDEOPREVIEW videoPreviewAct->change( Images::icon("video_preview"), tr("Thumb&nail Generator...") ); #endif @@ -1681,8 +1750,10 @@ void BaseGui::retranslateStrings() { unloadAudioAct->change( Images::icon("unload"), tr("U&nload") ); // Submenu Filters +#ifdef MPLAYER_SUPPORT extrastereoAct->change( tr("&Extrastereo") ); karaokeAct->change( tr("&Karaoke") ); +#endif volnormAct->change( tr("Volume &normalization") ); // Menu Subtitles @@ -1699,6 +1770,10 @@ void BaseGui::retranslateStrings() { tr("&Previous line in subtitles") ); incSubStepAct->change( Images::icon("inc_sub_step"), tr("N&ext line in subtitles") ); +#ifdef MPV_SUPPORT + seekNextSubAct->change(Images::icon("seek_next_sub"), tr("Seek to next subtitle")); + seekPrevSubAct->change(Images::icon("seek_prev_sub"), tr("Seek to previous subtitle")); +#endif useCustomSubStyleAct->change( Images::icon("use_custom_sub_style"), tr("Use custo&m style") ); useForcedSubsOnlyAct->change( Images::icon("forced_subs"), tr("&Forced subtitles only") ); @@ -1999,11 +2074,22 @@ void BaseGui::retranslateStrings() { angles_menu->menuAction()->setText( tr("&Angle") ); angles_menu->menuAction()->setIcon( Images::icon("angle") ); +#ifdef BOOKMARKS + bookmark_menu->menuAction()->setText( tr("&Bookmarks") ); + bookmark_menu->menuAction()->setIcon( Images::icon("bookmarks") ); +#endif + #if PROGRAM_SWITCH programtrack_menu->menuAction()->setText( tr("P&rogram", "program") ); programtrack_menu->menuAction()->setIcon( Images::icon("program_track") ); #endif +#ifdef BOOKMARKS + addBookmarkAct->change(Images::icon("add_bookmark"), tr("&Add new bookmark")); + editBookmarksAct->change(Images::icon("edit_bookmarks"), tr("&Edit bookmarks")); + prevBookmarkAct->change(Images::icon("prev_bookmark"), tr("Previous bookmark")); + nextBookmarkAct->change(Images::icon("next_bookmark"), tr("Next bookmark")); +#endif #if DVDNAV_SUPPORT dvdnavUpAct->change(Images::icon("dvdnav_up"), tr("DVD menu, move up")); @@ -2097,6 +2183,9 @@ void BaseGui::createCore() { connect( core, SIGNAL(needResize(int, int)), this, SLOT(resizeWindow(int,int)) ); + connect( core, SIGNAL(needResize(int, int)), + this, SLOT(centerWindow()) ); + connect( core, SIGNAL(showMessage(QString,int)), this, SLOT(displayMessage(QString,int)) ); connect( core, SIGNAL(showMessage(QString)), @@ -2583,8 +2672,10 @@ void BaseGui::createMenus() { // Filter submenu audiofilter_menu = new QMenu(this); audiofilter_menu->menuAction()->setObjectName("audiofilter_menu"); +#ifdef MPLAYER_SUPPORT audiofilter_menu->addAction(extrastereoAct); audiofilter_menu->addAction(karaokeAct); +#endif audiofilter_menu->addAction(volnormAct); audioMenu->addMenu(audiofilter_menu); @@ -2669,6 +2760,11 @@ void BaseGui::createMenus() { subtitlesMenu->addSeparator(); subtitlesMenu->addAction(decSubStepAct); subtitlesMenu->addAction(incSubStepAct); +#ifdef MPV_SUPPORT + subtitlesMenu->addSeparator(); + subtitlesMenu->addAction(seekPrevSubAct); + subtitlesMenu->addAction(seekNextSubAct); +#endif subtitlesMenu->addSeparator(); subtitlesMenu->addAction(useForcedSubsOnlyAct); subtitlesMenu->addSeparator(); @@ -2700,6 +2796,14 @@ void BaseGui::createMenus() { browseMenu->addMenu(angles_menu); +#ifdef BOOKMARKS + // Bookmarks submenu + bookmark_menu = new QMenu(this); + bookmark_menu->menuAction()->setObjectName("bookmarks_menu"); + + browseMenu->addMenu(bookmark_menu); +#endif + #if DVDNAV_SUPPORT browseMenu->addSeparator(); browseMenu->addAction(dvdnavMenuAct); @@ -3464,7 +3568,44 @@ void BaseGui::initializeMenus() { a->setEnabled(false); } angles_menu->addActions( angleGroup->actions() ); + +#ifdef BOOKMARKS + updateBookmarks(); +#endif +} + +#ifdef BOOKMARKS +void BaseGui::updateBookmarks() { + qDebug("BaseGui::updateBookmarks"); + + // Bookmarks + bookmarkGroup->clear(true); + int n_bookmarks = core->mset.bookmarks.size(); + if (n_bookmarks > 0) { + QMap<int, QString>::const_iterator i = core->mset.bookmarks.constBegin(); + while (i != core->mset.bookmarks.constEnd()) { + QString name = i.value(); + int time = i.key(); + QAction *a = new QAction(bookmarkGroup); + QString text; + if (name.isEmpty()) { + text = Helper::formatTime(time); + } else { + text = QString("%1 (%2)").arg(name).arg(Helper::formatTime(time)); + } + a->setCheckable(false); + a->setText(text); + a->setData(time); + i++; + } + } + bookmark_menu->clear(); + bookmark_menu->addAction(addBookmarkAct); + bookmark_menu->addAction(editBookmarksAct); + bookmark_menu->addSeparator(); + bookmark_menu->addActions(bookmarkGroup->actions()); } +#endif void BaseGui::updateRecents() { qDebug("BaseGui::updateRecents"); @@ -3636,11 +3777,13 @@ void BaseGui::updateWidgets() { // Mute menu option muteAct->setChecked( (pref->global_volume ? pref->mute : core->mset.mute) ); +#ifdef MPLAYER_SUPPORT // Karaoke menu option karaokeAct->setChecked( core->mset.karaoke_filter ); // Extrastereo menu option extrastereoAct->setChecked( core->mset.extrastereo_filter ); +#endif // Volnorm menu option volnormAct->setChecked( core->mset.volnorm_filter ); @@ -3709,6 +3852,10 @@ void BaseGui::updateWidgets() { incSubScaleAct->setEnabled(e); decSubStepAct->setEnabled(e); incSubStepAct->setEnabled(e); +#ifdef MPV_SUPPORT + seekNextSubAct->setEnabled(e); + seekPrevSubAct->setEnabled(e); +#endif } void BaseGui::updateVideoEqualizer() { @@ -4312,6 +4459,27 @@ void BaseGui::showStereo3dDialog() { } } +#ifdef BOOKMARKS +void BaseGui::showAddBookmarkDialog() { + InputBookmark d(this); + d.setTime( (int) core->mset.current_sec); + if (d.exec() == QDialog::Accepted) { + core->mset.bookmarks.insert(d.time(), d.name()); + updateBookmarks(); + } +} + +void BaseGui::showBookmarkDialog() { + qDebug("BaseGui::showBookmarkDialog"); + BookmarkDialog d(this); + d.setBookmarks(core->mset.bookmarks); + if (d.exec() == QDialog::Accepted) { + core->mset.bookmarks = d.bookmarks(); + updateBookmarks(); + } +} +#endif + void BaseGui::exitFullscreen() { if (pref->fullscreen) { toggleFullscreen(false); @@ -5019,6 +5187,27 @@ void BaseGui::resizeMainWindow(int w, int h) { } #endif + qDebug("BaseGui::resizeWindow: new_width: %d new_height: %d", new_width, new_height); + +#if 0 + QSize desktop_size = DesktopInfo::desktop_size(this); + //desktop_size.setWidth(1000); desktop_size.setHeight(1000); // test + if (new_width > desktop_size.width()) { + double aspect = (double) new_width / new_height; + qDebug("BaseGui::resizeWindow: width (%d) is larger than desktop width (%d)", new_width, desktop_size.width()); + new_width = desktop_size.width(); + /* + new_height = new_width / aspect; + qDebug() << "BaseGui::resizeWindow: aspect:" << aspect; + qDebug("BaseGui::resizeWindow: height: %d", new_height); + */ + } + if (new_height > desktop_size.height()) { + qDebug("BaseGui::resizeWindow: height (%d) is larger than desktop height (%d)", new_height, desktop_size.height()); + new_height = desktop_size.height(); + } +#endif + resize(new_width, new_height); qDebug("BaseGui::resizeWindow: done: window size: %d, %d", this->width(), this->height()); @@ -5026,8 +5215,22 @@ void BaseGui::resizeMainWindow(int w, int h) { panel->size().width(), panel->size().height() ); qDebug("BaseGui::resizeWindow: done: mplayerwindow->size: %d, %d", - mplayerwindow->size().width(), + 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); + } +#endif } void BaseGui::hidePanel() { @@ -5051,6 +5254,18 @@ void BaseGui::hidePanel() { } } +void BaseGui::centerWindow() { + qDebug("BaseGui::centerWindow"); + if (pref->center_window && !pref->fullscreen && isVisible()) { + QRect r = QApplication::desktop()->screenGeometry(this); + // r.setX(500); r.setY(150); // Test + qDebug() << "BaseGui::centerWindow: desktop rect:" << r; + int x = r.x() + ((r.width() - width()) / 2); + int y = r.y() + ((r.height() - height()) / 2); + move(x, y); + } +} + void BaseGui::displayGotoTime(int t) { #ifdef SEEKBAR_RESOLUTION int jump_time = (int)core->mdat.duration * t / SEEKBAR_RESOLUTION; |