Ignore:
Timestamp:
Jan 24, 2017, 12:41:54 PM (8 years ago)
Author:
Silvan Scherrer
Message:

SMPlayer: update trunk to version 17.1.0

Location:
smplayer/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • smplayer/trunk

  • smplayer/trunk/src/basegui.cpp

    r182 r188  
    11/*  smplayer, GUI front-end for mplayer.
    2     Copyright (C) 2006-2016 Ricardo Villalba <rvm@users.sourceforge.net>
     2    Copyright (C) 2006-2017 Ricardo Villalba <rvm@users.sourceforge.net>
    33
    44    This program is free software; you can redistribute it and/or modify
     
    4242#include <QDesktopWidget>
    4343
    44 #include <cmath>
     44#include <QtCore/qmath.h>
    4545
    4646#include "mplayerwindow.h"
     
    261261#endif
    262262
    263 #if defined(SHARE_ACTIONS) && !defined(SHARE_WIDGET)
     263#ifdef DONATE_REMINDER
    264264        QTimer::singleShot(1000, this, SLOT(checkReminder()));
    265265#endif
     
    907907             this, SLOT(helpShowConfig()) );
    908908
    909 #ifdef SHARE_ACTIONS
    910909        donateAct = new MyAction( this, "donate" );
    911910        connect( donateAct, SIGNAL(triggered()),
    912911             this, SLOT(helpDonate()) );
    913 #endif
    914912
    915913        aboutThisAct = new MyAction( this, "about_smplayer" );
     
    10681066                         core, SLOT(nextWheelFunction()) );
    10691067
    1070         showFilenameAct = new MyAction(Qt::SHIFT | Qt::Key_I, this, "show_filename");
     1068        showFilenameAct = new MyAction(Qt::SHIFT | Qt::Key_I, this, "show_info_osd");
    10711069        connect( showFilenameAct, SIGNAL(triggered()), core, SLOT(showFilenameOnOSD()) );
    10721070
     
    14821480
    14831481        // Screenshot option
     1482        /*
    14841483        bool screenshots_enabled = ( (pref->use_screenshot) &&
    14851484                                 (!pref->screenshot_directory.isEmpty()) &&
     
    14881487        screenshotAct->setEnabled( screenshots_enabled );
    14891488        screenshotsAct->setEnabled( screenshots_enabled );
     1489        */
    14901490
    14911491#ifdef CAPTURE_STREAM
     
    15681568        // Disable video filters if using vdpau
    15691569        if ((pref->vdpau.disable_video_filters) && (pref->vo.startsWith("vdpau"))) {
     1570                /*
    15701571                screenshotAct->setEnabled(false);
    15711572                screenshotsAct->setEnabled(false);
     1573                */
    15721574                flipAct->setEnabled(false);
    15731575                mirrorAct->setEnabled(false);
     
    18441846#ifdef SHARE_ACTIONS
    18451847        donateAct->change( Images::icon("donate"), tr("&Donate / Share with your friends") );
     1848#else
     1849        donateAct->change( Images::icon("donate"), tr("&Donate") );
    18461850#endif
    18471851        aboutThisAct->change( Images::icon("logo"), tr("About &SMPlayer") );
     
    18991903        nextWheelFunctionAct->change( Images::icon("next_wheel_function"), tr("Next wheel function") );
    19001904
    1901         showFilenameAct->change( tr("Show filename on OSD") );
     1905        showFilenameAct->change( tr("Show &info on OSD") );
    19021906        showTimeAct->change( tr("Show playback time on OSD") );
     1907
    19031908        toggleDeinterlaceAct->change( tr("Toggle deinterlacing") );
    19041909
     
    23202325        sharewidget = new ShareWidget(Global::settings, mplayerwindow);
    23212326        mplayerwindow->setCornerWidget(sharewidget);
    2322         #ifdef SHARE_ACTIONS
     2327        //#ifdef SHARE_ACTIONS
    23232328        connect(sharewidget, SIGNAL(supportClicked()), this, SLOT(helpDonate()));
    2324         #endif
     2329        //#endif
    23252330#endif
    23262331
     
    24342439            core, SLOT(open(const QString &, int)));
    24352440
     2441        connect(playlist, SIGNAL(requestToPlayStream(const QString &, QStringList)),
     2442            core, SLOT(openStream(const QString &, QStringList)));
     2443
    24362444        connect(playlist, SIGNAL(requestToAddCurrentFile()), this, SLOT(addToPlaylistCurrentFile()));
    24372445
    2438         if (playlist->automaticallyPlayNext()) {
    2439                 connect( core, SIGNAL(mediaFinished()), playlist, SLOT(playNext()), Qt::QueuedConnection );
    2440         }
     2446        connect( core, SIGNAL(mediaFinished()), playlist, SLOT(playNextAuto()), Qt::QueuedConnection );
     2447
    24412448        connect( core, SIGNAL(mplayerFailed(QProcess::ProcessError)), playlist, SLOT(playerFailed(QProcess::ProcessError)) );
    24422449        connect( core, SIGNAL(mplayerFinishedWithError(int)), playlist, SLOT(playerFinishedWithError(int)) );
     
    26962703        osd_menu->menuAction()->setObjectName("osd_menu");
    26972704        osd_menu->addActions(osdGroup->actions());
     2705        osd_menu->addSeparator();
     2706        osd_menu->addAction(showFilenameAct);
    26982707        osd_menu->addSeparator();
    26992708        osd_menu->addAction(decOSDScaleAct);
     
    29852994                helpMenu->addSeparator();
    29862995        }
    2987         #ifdef SHARE_ACTIONS
    29882996        helpMenu->addAction(donateAct);
    29892997        helpMenu->addSeparator();
    2990         #endif
    29912998        helpMenu->addAction(aboutThisAct);
    29922999
     
    31073114        pl->setSavePlaylistOnExit(playlist->savePlaylistOnExit());
    31083115        pl->setPlayFilesFromStart(playlist->playFilesFromStart());
     3116        pl->setPlayOnLoad(playlist->startPlayOnLoad());
     3117        pl->setPlayNextAutomatically(playlist->automaticallyPlayNext());
    31093118        pl->setIgnorePlayerErrors(playlist->ignorePlayerErrors());
     3119        pl->setAutoSort(playlist->autoSort());
     3120        pl->setFilterCaseSensitive(playlist->filterCaseSensitive());
    31103121
    31113122        pref_dialog->show();
     
    31173128
    31183129        bool need_update_language = false;
     3130        bool need_apply_styles = false;
    31193131
    31203132        PlayerID::Player old_player_type = PlayerID::player(pref->mplayer_bin);
     
    31243136        // Setup proxy
    31253137        setupNetworkProxy();
    3126 
    3127         // Change application font
    3128         if (!pref->default_font.isEmpty()) {
    3129                 QFont f;
    3130                 f.fromString( pref->default_font );
    3131                 if (QApplication::font() != f) {
    3132                         qDebug("BaseGui::applyNewPreferences: setting new font: %s", pref->default_font.toLatin1().constData());
    3133                         QApplication::setFont(f);
    3134                 }
    3135         }
    31363138
    31373139        PrefGeneral *_general = pref_dialog->mod_general();
     
    31503152                // Stylesheet
    31513153                #if ALLOW_CHANGE_STYLESHEET
    3152                 if (!_interface->guiChanged()) applyStyles();
     3154                if (!_interface->guiChanged()) need_apply_styles = true;
    31533155                #endif
    31543156        }
     3157
     3158        if (_interface->fontChanged()) need_apply_styles = true;
    31553159
    31563160#ifndef MOUSE_GESTURES
     
    31993203        playlist->setSavePlaylistOnExit(pl->savePlaylistOnExit());
    32003204        playlist->setPlayFilesFromStart(pl->playFilesFromStart());
     3205        playlist->setStartPlayOnLoad(pl->playOnLoad());
     3206        playlist->setAutomaticallyPlayNext(pl->playNextAutomatically());
    32013207        playlist->setIgnorePlayerErrors(pl->ignorePlayerErrors());
     3208        playlist->setAutoSort(pl->autoSort());
     3209        playlist->setFilterCaseSensitive(pl->filterCaseSensitive());
    32023210
    32033211#ifdef PLAYLIST_DOWNLOAD
     
    32143222#if STYLE_SWITCHING
    32153223        if (_interface->styleChanged()) {
    3216                 applyStyles();
    3217         }
    3218 #endif
    3219 
    3220     // Restart the video if needed
     3224                need_apply_styles = true;
     3225        }
     3226#endif
     3227
     3228        if (need_apply_styles) applyStyles();
     3229
     3230        // Restart the video if needed
    32213231        if (pref_dialog->requiresRestart())
    32223232                core->restart();
     
    40924102        qDebug("BaseGui::openFavorite");
    40934103
     4104        QUrl url(file);
     4105        if (url.isValid() && url.scheme().toLower() == "file") {
     4106                file = url.toLocalFile();
     4107        }
     4108
    40944109        openFiles(QStringList() << file);
    40954110}
     
    41574172
    41584173void BaseGui::openFile() {
    4159         qDebug("BaseGui::fileOpen");
     4174        qDebug("BaseGui::openFile");
    41604175
    41614176        exitFullscreenIfNeeded();
     
    41764191
    41774192void BaseGui::openFile(QString file) {
    4178         qDebug("BaseGui::openFile: '%s'", file.toUtf8().data());
     4193        qDebug() << "BaseGui::openFile:" << file;
    41794194
    41804195   if ( !file.isEmpty() ) {
    41814196
     4197                #ifdef Q_OS_WIN
     4198                // Check for Windows shortcuts
     4199                QFileInfo fi(file);
     4200                if (fi.isSymLink()) {
     4201                        file = fi.symLinkTarget();
     4202                }
     4203                #endif
     4204       
    41824205                //playlist->clear();
    41834206                //playlistdock->hide();
     
    44654488                #endif
    44664489        }
     4490}
     4491#else
     4492void BaseGui::helpDonate() {
     4493        qDebug("BaseGui::helpDonate");
     4494
     4495        int action = 0;
     4496        bool accepted;
     4497        showHelpDonateDialog(&accepted);
     4498        if (accepted) action = 1;
     4499
     4500        if (action > 0) {
     4501                QSettings * set = Global::settings;
     4502                set->beginGroup("reminder");
     4503                set->setValue("action", action);
     4504                set->endGroup();
     4505        }
     4506}
     4507
     4508void BaseGui::showHelpDonateDialog(bool * accepted) {
     4509        bool result = false;
     4510
     4511        QMessageBox d(this);
     4512        d.setIconPixmap(Images::icon("donate"));
     4513        d.setWindowTitle(tr("Support SMPlayer"));
     4514
     4515        QPushButton * ok_button = d.addButton(tr("Donate"), QMessageBox::YesRole);
     4516        d.addButton(tr("No"), QMessageBox::NoRole);
     4517        d.setDefaultButton(ok_button);
     4518
     4519        d.setText("<h1>" + tr("SMPlayer needs you") + "</h1><p>" +
     4520                tr("SMPlayer is free software. However the development requires a lot of time and a lot of work.") + "<p>" +
     4521                tr("In order to keep developing SMPlayer with new features we need your help.") + "<p>" +
     4522                tr("Please consider to support the SMPlayer project by sending a donation.") + " " +
     4523                tr("Even the smallest amount will help a lot.")
     4524        );
     4525        d.exec();
     4526        if (d.clickedButton() == ok_button) {
     4527                QDesktopServices::openUrl(QUrl(URL_DONATE));
     4528                result = true;
     4529        }
     4530        if (accepted != 0) *accepted = result;
    44674531}
    44684532#endif
     
    46524716        updateWidgets();
    46534717
     4718#ifdef ADD_BLACKBORDERS_FS
    46544719        if ((pref->add_blackborders_on_fullscreen) &&
    46554720        (!core->mset.add_letterbox))
     
    46584723                /* core->restart(); */
    46594724        }
     4725#endif
    46604726
    46614727        setFocus(); // Fixes bug #2493415
     
    48904956#endif
    48914957
    4892 #if defined(SHARE_ACTIONS) && !defined(SHARE_WIDGET)
     4958#ifdef DONATE_REMINDER
    48934959void BaseGui::checkReminder() {
    48944960        qDebug("BaseGui::checkReminder");
     
    49124978#endif
    49134979
     4980#ifdef SHARE_ACTIONS
    49144981        ShareDialog d(this);
    49154982        //d.showRemindCheck(false);
     
    49234990                set->endGroup();
    49244991        }
     4992#else
     4993        action = 0;
     4994        bool accepted;
     4995        showHelpDonateDialog(&accepted);
     4996        if (accepted) action = 1;
     4997#endif
    49254998
    49264999        if (action > 0) {
     
    52225295        if (!core->mdat.filename.isEmpty()) {
    52235296                playlist->addItem(core->mdat.filename, "", 0);
     5297                playlist->setModified(true);
    52245298                playlist->getMediaInfo(core->mdat);
    52255299        }
     
    52605334
    52615335void BaseGui::gotCurrentTime(double sec) {
    5262         //qDebug( "DefaultGui::displayTime: %f", sec);
     5336        //qDebug() << "BaseGui::gotCurrentTime:" << sec;
    52635337
    52645338        static int last_second = 0;
    52655339
    5266         if (floor(sec)==last_second) return; // Update only once per second
    5267         last_second = (int) floor(sec);
     5340        if (qFloor(sec) == last_second) return; // Update only once per second
     5341        last_second = qFloor(sec);
    52685342
    52695343        QString time = Helper::formatTime( (int) sec ) + " / " +
    52705344                           Helper::formatTime( (int) core->mdat.duration );
    5271 
    5272         //qDebug( " duration: %f, current_sec: %f", core->mdat.duration, core->mset.current_sec);
    52735345
    52745346        emit timeChanged(sec);
     
    54015473
    54025474        if (panel->isVisible()) {
     5475                if (isMaximized()) showNormal();
     5476
    54035477                // Exit from fullscreen mode
    54045478                if (pref->fullscreen) { toggleFullscreen(false); update(); }
     
    56285702        }
    56295703
     5704        // Use the user specified font
     5705        if (!pref->default_font.isEmpty()) {
     5706                QFont f;
     5707                f.fromString( pref->default_font );
     5708                QString fstyle = QString("QWidget { font: %1 %2 %3pt %4; }")
     5709                        .arg(f.bold() ? "bold" :"").arg(f.italic() ? "italic" : "")
     5710                        .arg(f.pointSize()).arg(f.family());
     5711                stylesheet = fstyle + stylesheet;
     5712        }
    56305713        //qDebug() << "BaseGui::changeStyleSheet: styleSheet:" << stylesheet;
    56315714        qApp->setStyleSheet(stylesheet);
     
    56355718void BaseGui::applyStyles() {
    56365719        qDebug("BaseGui::applyStyles");
     5720
     5721#if !ALLOW_CHANGE_STYLESHEET
     5722        if (!pref->default_font.isEmpty()) {
     5723                QFont f;
     5724                f.fromString( pref->default_font );
     5725                if (QApplication::font() != f) {
     5726                        qDebug() << "BaseGui::applyStyles: setting new font:" << pref->default_font;
     5727                        QApplication::setFont(f);
     5728                }
     5729        }
     5730#endif
    56375731
    56385732#if ALLOW_CHANGE_STYLESHEET
     
    56525746        }
    56535747#endif
     5748
    56545749}
    56555750
Note: See TracChangeset for help on using the changeset viewer.