Ignore:
Timestamp:
Feb 21, 2014, 4:44:11 PM (11 years ago)
Author:
Silvan Scherrer
Message:

SMPlayer: update vendor to 0.8.6

File:
1 edited

Legend:

Unmodified
Added
Removed
  • smplayer/vendor/current/src/basegui.cpp

    r140 r154  
    108108#include "updatechecker.h"
    109109
     110#ifdef YT_USE_SCRIPT
     111#include "codedownloader.h"
     112#endif
     113
    110114using namespace Global;
    111115
     
    199203
    200204#ifdef UPDATE_CHECKER
    201         update_checker = new UpdateChecker(this, Global::settings);
     205        update_checker = new UpdateChecker(this, &pref->update_checker_data);
    202206        connect(update_checker, SIGNAL(newVersionFound(QString)),
    203207            this, SLOT(reportNewVersionAvailable(QString)));
    204208#endif
    205209
    206 #ifdef TEST_UPDATE
    207         QTimer::singleShot(2000, this, SLOT(testUpdate()));
     210#ifdef CHECK_UPGRADED
     211        QTimer::singleShot(2000, this, SLOT(checkIfUpgraded()));
     212#endif
     213
     214#ifdef REMINDER_ACTIONS
     215        QTimer::singleShot(1000, this, SLOT(checkReminder()));
    208216#endif
    209217}
     
    240248
    241249                if (command == "open_file") {
     250                        emit openFileRequested();
    242251                        open(arg);
    243252                }
     
    245254                if (command == "open_files") {
    246255                        QStringList file_list = arg.split(" <<sep>> ");
     256                        emit openFileRequested();
    247257                        openFiles(file_list);
    248258                }
     
    250260                if (command == "add_to_playlist") {
    251261                        QStringList file_list = arg.split(" <<sep>> ");
     262                        /* if (core->state() == Core::Stopped) { emit openFileRequested(); } */
    252263                        playlist->addFiles(file_list);
    253264                }
     
    258269                else
    259270                if (command == "load_sub") {
    260                         setInitialSubtitle(arg); 
     271                        setInitialSubtitle(arg);
    261272                        if (core->state() != Core::Stopped) {
    262273                                core->loadSub(arg);
     
    729740             this, SLOT(showPreferencesDialog()) );
    730741
     742#ifdef YOUTUBE_SUPPORT
    731743        showTubeBrowserAct = new MyAction( Qt::Key_F11, this, "show_tube_browser" );
    732744        connect( showTubeBrowserAct, SIGNAL(triggered()),
    733745             this, SLOT(showTubeBrowser()) );
     746#endif
    734747
    735748        // Submenu Logs
     
    763776             this, SLOT(helpCheckUpdates()) );
    764777
     778#if defined(YOUTUBE_SUPPORT) && defined(YT_USE_SCRIPT)
     779        updateYTAct = new MyAction( this, "update_youtube" );
     780        connect( updateYTAct, SIGNAL(triggered()),
     781             this, SLOT(YTUpdateScript()) );
     782#endif
     783
    765784        showConfigAct = new MyAction( this, "show_config" );
    766785        connect( showConfigAct, SIGNAL(triggered()),
    767786             this, SLOT(helpShowConfig()) );
     787
     788#ifdef REMINDER_ACTIONS
     789        donateAct = new MyAction( this, "donate" );
     790        connect( donateAct, SIGNAL(triggered()),
     791             this, SLOT(helpDonate()) );
     792#endif
    768793
    769794        aboutQtAct = new MyAction( this, "about_qt" );
     
    14651490        // Menu Play
    14661491        playAct->change( tr("P&lay") );
    1467         if (qApp->isLeftToRight())
    1468                 playAct->setIcon( Images::icon("play") );
    1469         else
    1470                 playAct->setIcon( Images::flippedIcon("play") );
     1492        playAct->setIcon( Images::icon("play") );
    14711493
    14721494        pauseAct->change( Images::icon("pause"), tr("&Pause"));
     
    14751497
    14761498        playOrPauseAct->change( tr("Play / Pause") );
    1477         if (qApp->isLeftToRight())
    1478                 playOrPauseAct->setIcon( Images::icon("play_pause") );
    1479         else
    1480                 playOrPauseAct->setIcon( Images::flippedIcon("play_pause") );
     1499        playOrPauseAct->setIcon( Images::icon("play_pause") );
    14811500
    14821501        pauseAndStepAct->change( Images::icon("pause"), tr("Pause / Frame step") );
     
    16011620        showPropertiesAct->change( Images::icon("info"), tr("View &info and properties...") );
    16021621        showPreferencesAct->change( Images::icon("prefs"), tr("P&references") );
     1622#ifdef YOUTUBE_SUPPORT
    16031623        showTubeBrowserAct->change( Images::icon("tubebrowser"), tr("&YouTube%1 browser").arg(QChar(0x2122)) );
     1624#endif
    16041625
    16051626        // Submenu Logs
     
    16161637        showCLOptionsAct->change( Images::icon("cl_help"), tr("&Command line options") );
    16171638        showCheckUpdatesAct->change( Images::icon("check_updates"), tr("Check for &updates") );
     1639
     1640#if defined(YOUTUBE_SUPPORT) && defined(YT_USE_SCRIPT)
     1641        updateYTAct->change( Images::icon("update_youtube"), tr("Update &Youtube code") );
     1642#endif
     1643
    16181644        showConfigAct->change( Images::icon("show_config"), tr("&Open configuration folder") );
     1645#ifdef REMINDER_ACTIONS
     1646        donateAct->change( Images::icon("donate"), tr("&Donate") );
     1647#endif
    16191648        aboutQtAct->change( QPixmap(":/icons-png/qt.png"), tr("About &Qt") );
    16201649        aboutThisAct->change( Images::icon("logo_small"), tr("About &SMPlayer") );
     
    16311660        playPrevAct->change( tr("Pre&vious") );
    16321661
    1633         if (qApp->isLeftToRight()) {
    1634                 playNextAct->setIcon( Images::icon("next") );
    1635                 playPrevAct->setIcon( Images::icon("previous") );
    1636         } else {
    1637                 playNextAct->setIcon( Images::flippedIcon("next") );
    1638                 playPrevAct->setIcon( Images::flippedIcon("previous") );
    1639         }
     1662        playNextAct->setIcon( Images::icon("next") );
     1663        playPrevAct->setIcon( Images::icon("previous") );
    16401664
    16411665
     
    19151939        forward3Act->change( tr("+%1").arg(Helper::timeForJumps(pref->seeking3)) );
    19161940
    1917         if (qApp->isLeftToRight()) {
    1918                 rewind1Act->setIcon( Images::icon("rewind10s") );
    1919                 rewind2Act->setIcon( Images::icon("rewind1m") );
    1920                 rewind3Act->setIcon( Images::icon("rewind10m") );
    1921 
    1922                 forward1Act->setIcon( Images::icon("forward10s") );
    1923                 forward2Act->setIcon( Images::icon("forward1m") );
    1924                 forward3Act->setIcon( Images::icon("forward10m") );
    1925         } else {
    1926                 rewind1Act->setIcon( Images::flippedIcon("rewind10s") );
    1927                 rewind2Act->setIcon( Images::flippedIcon("rewind1m") );
    1928                 rewind3Act->setIcon( Images::flippedIcon("rewind10m") );
    1929 
    1930                 forward1Act->setIcon( Images::flippedIcon("forward10s") );
    1931                 forward2Act->setIcon( Images::flippedIcon("forward1m") );
    1932                 forward3Act->setIcon( Images::flippedIcon("forward10m") );
    1933         }
     1941        rewind1Act->setIcon( Images::icon("rewind10s") );
     1942        rewind2Act->setIcon( Images::icon("rewind1m") );
     1943        rewind3Act->setIcon( Images::icon("rewind10m") );
     1944
     1945        forward1Act->setIcon( Images::icon("forward10s") );
     1946        forward2Act->setIcon( Images::icon("forward1m") );
     1947        forward3Act->setIcon( Images::icon("forward10m") );
    19341948}
    19351949
     
    19621976        connect( core, SIGNAL(needResize(int, int)),
    19631977             this, SLOT(resizeWindow(int,int)) );
     1978
     1979        connect( core, SIGNAL(showMessage(QString,int)),
     1980             this, SLOT(displayMessage(QString,int)) );
    19641981        connect( core, SIGNAL(showMessage(QString)),
    19651982             this, SLOT(displayMessage(QString)) );
     1983
    19661984        connect( core, SIGNAL(stateChanged(Core::State)),
    19671985             this, SLOT(displayState(Core::State)) );
     
    20312049        connect( core, SIGNAL(mediaLoaded()),
    20322050             this, SLOT(autosaveMplayerLog()) );
     2051#endif
     2052
     2053#ifdef YOUTUBE_SUPPORT
     2054        connect(core, SIGNAL(signatureNotFound(const QString &)),
     2055            this, SLOT(YTNoSignature(const QString &)));
    20332056#endif
    20342057}
     
    21712194
    21722195void BaseGui::createPreferencesDialog() {
     2196        QApplication::setOverrideCursor(Qt::WaitCursor);
    21732197        pref_dialog = new PreferencesDialog(this);
    21742198        pref_dialog->setModal(false);
     
    21762200        connect( pref_dialog, SIGNAL(applied()),
    21772201             this, SLOT(applyNewPreferences()) );
     2202        QApplication::restoreOverrideCursor();
    21782203}
    21792204
    21802205void BaseGui::createFilePropertiesDialog() {
     2206        QApplication::setOverrideCursor(Qt::WaitCursor);
    21812207        file_dialog = new FilePropertiesDialog(this);
    21822208        file_dialog->setModal(false);
    21832209        connect( file_dialog, SIGNAL(applied()),
    21842210             this, SLOT(applyFileProperties()) );
     2211        QApplication::restoreOverrideCursor();
    21852212}
    21862213
     
    25372564        optionsMenu->addAction(showPropertiesAct);
    25382565        optionsMenu->addAction(showPlaylistAct);
     2566#ifdef YOUTUBE_SUPPORT
    25392567        #if 0
    25402568        // Check if the smplayer youtube browser is installed
     
    25542582        optionsMenu->addAction(showTubeBrowserAct);
    25552583        #endif
     2584#endif
    25562585
    25572586        // OSD submenu
     
    25962625        helpMenu->addAction(showFAQAct);
    25972626        helpMenu->addAction(showCLOptionsAct);
     2627        helpMenu->addSeparator();
    25982628        helpMenu->addAction(showCheckUpdatesAct);
     2629#if defined(YOUTUBE_SUPPORT) && defined(YT_USE_SCRIPT)
     2630        helpMenu->addAction(updateYTAct);
     2631#endif
     2632        helpMenu->addSeparator();
    25992633        helpMenu->addAction(showConfigAct);
    26002634        helpMenu->addSeparator();
     2635#ifdef REMINDER_ACTIONS
     2636        helpMenu->addAction(donateAct);
     2637        helpMenu->addSeparator();
     2638#endif
    26012639        helpMenu->addAction(aboutQtAct);
    26022640        helpMenu->addAction(aboutThisAct);
     
    38433881
    38443882void BaseGui::helpFirstSteps() {
    3845         QDesktopServices::openUrl(QString("http://smplayer.sourceforge.net/first-steps.php?version=%1").arg(smplayerVersion()));
     3883        QDesktopServices::openUrl(QString("http://smplayer.sourceforge.net/first-steps.php?version=%1").arg(Version::printable()));
    38463884}
    38473885
     
    38713909}
    38723910
     3911#ifdef REMINDER_ACTIONS
     3912void BaseGui::helpDonate() {
     3913        QMessageBox d(QMessageBox::NoIcon, tr("Donate"),
     3914                tr("If you like SMPlayer and want to support its development, you can send a donation. Even the smallest one is highly appreciated."),
     3915                QMessageBox::Ok | QMessageBox::Cancel, this);
     3916        d.setIconPixmap( Images::icon("logo", 64) );
     3917        d.button(QMessageBox::Ok)->setText(tr("Yes, I want to donate"));
     3918        d.setDefaultButton(QMessageBox::Ok);
     3919        if ( d.exec() == QMessageBox::Ok ) {
     3920                QDesktopServices::openUrl(QUrl("http://sourceforge.net/donate/index.php?group_id=185512"));
     3921
     3922                QSettings * set = Global::settings;
     3923                set->beginGroup("reminder");
     3924                set->setValue("action", 1);
     3925                set->endGroup();
     3926        }
     3927}
     3928#endif
     3929
    38733930void BaseGui::helpAbout() {
    38743931        About d(this);
     
    39023959        if (sender() == facebookAct) {
    39033960                QDesktopServices::openUrl(QUrl("http://www.facebook.com/sharer.php?u=" + url + "&t=" + text));
     3961
     3962                #ifdef REMINDER_ACTIONS
     3963                QSettings * set = Global::settings;
     3964                set->beginGroup("reminder");
     3965                set->setValue("action", 2);
     3966                set->endGroup();
     3967                #endif
    39043968        }
    39053969}
     
    42174281        QMessageBox::StandardButton button = QMessageBox::information(this, tr("New version available"),
    42184282                tr("A new version of SMPlayer is available.") + "<br><br>" +
    4219                 tr("Installed version: %1").arg(stableVersion()) + "<br>" +
     4283                tr("Installed version: %1").arg(Version::with_revision()) + "<br>" +
    42204284                tr("Available version: %1").arg(new_version) + "<br><br>" +
    42214285                tr("Would you like to know more about this new version?"),
     
    42304294#endif
    42314295
    4232 #ifdef TEST_UPDATE
    4233 void BaseGui::testUpdate() {
    4234         qDebug("BaseGui::testUpdate");
    4235         QSettings * set = Global::settings;
    4236         set->beginGroup("smplayer");
    4237         QString version = set->value("stable_version", "").toString();
    4238         bool check_for_new_version = set->value("check_for_new_version", true).toBool();
    4239         set->setValue("stable_version", stableVersion());
    4240         set->setValue("check_for_new_version", check_for_new_version);
    4241         set->endGroup();
    4242 
    4243         if ( (check_for_new_version) && (version != stableVersion()) ) {
     4296#ifdef CHECK_UPGRADED
     4297void BaseGui::checkIfUpgraded() {
     4298        qDebug("BaseGui::checkIfUpgraded");
     4299
     4300        if ( (pref->check_if_upgraded) && (pref->smplayer_stable_version != Version::stable()) ) {
    42444301                // Running a new version
    4245                 qDebug("BaseGui::testUpdate: running a new version: %s", stableVersion().toUtf8().constData());
     4302                qDebug("BaseGui::checkIfUpgraded: running a new version: %s", Version::stable().toUtf8().constData());
    42464303                QString os = "other";
    42474304                #ifdef Q_OS_WIN
     
    42514308                os = "linux";
    42524309                #endif
    4253                 QDesktopServices::openUrl(QString("http://smplayer.sourceforge.net/thank-you.php?version=%1&so=%2").arg(smplayerVersion()).arg(os));
    4254         }
    4255 }
    4256 #endif
     4310                QDesktopServices::openUrl(QString("http://smplayer.sourceforge.net/thank-you.php?version=%1&so=%2").arg(Version::printable()).arg(os));
     4311        }
     4312        pref->smplayer_stable_version = Version::stable();
     4313}
     4314#endif
     4315
     4316#ifdef REMINDER_ACTIONS
     4317void BaseGui::checkReminder() {
     4318        qDebug("BaseGui::checkReminder");
     4319
     4320        if (core->state() == Core::Playing) return;
     4321
     4322        QSettings * set = Global::settings;
     4323        set->beginGroup("reminder");
     4324        int count = set->value("count", 0).toInt();
     4325        count++;
     4326        set->setValue("count", count);
     4327        int action = set->value("action", 0).toInt();
     4328        set->endGroup();
     4329
     4330        if (action != 0) return;
     4331        if ((count != 25) && (count != 45)) return;
     4332
     4333        QMessageBox box(this);
     4334        box.setIcon(QMessageBox::Question);
     4335        box.setIconPixmap( Images::icon("donate_big") );
     4336        box.setWindowTitle(tr("Help SMPlayer"));
     4337        box.setText(
     4338                tr("If you like SMPlayer and want to support its development, you can send a donation. Even the smallest one is highly appreciated.") + "<br>"+
     4339                tr("Or you maybe you want to share SMPlayer with your friends in Facebook.") + "<br>" +
     4340                tr("What would you like to do?") );
     4341        QPushButton * donate_button = box.addButton(tr("&Donate"), QMessageBox::ActionRole);
     4342        QPushButton * facebook_button = box.addButton(tr("&Share with my friends"), QMessageBox::ActionRole);
     4343        QPushButton * cancel_button = box.addButton(QMessageBox::Cancel);
     4344
     4345        box.exec();
     4346        if (box.clickedButton() == donate_button) {
     4347                QDesktopServices::openUrl(QUrl("http://sourceforge.net/donate/index.php?group_id=185512"));
     4348                action = 1;
     4349        }
     4350        else
     4351        if (box.clickedButton() == facebook_button) {
     4352                QString text = QString("SMPlayer - Free Media Player with built-in codecs that can play and download Youtube videos").replace(" ","+");
     4353                QString url = "http://smplayer.sourceforge.net";
     4354                QDesktopServices::openUrl(QUrl("http://www.facebook.com/sharer.php?u=" + url + "&t=" + text));
     4355                action = 2;
     4356        }
     4357        else
     4358        if (box.clickedButton() == cancel_button) {
     4359        }
     4360
     4361        if (action > 0) {
     4362                set->beginGroup("reminder");
     4363                set->setValue("action", action);
     4364                set->endGroup();
     4365        }
     4366}
     4367#endif
     4368
     4369#ifdef YOUTUBE_SUPPORT
     4370void BaseGui::YTNoSignature(const QString & title) {
     4371        qDebug("BaseGui::YTNoSignature: %s", title.toUtf8().constData());
     4372
     4373        QString t = title;
     4374        t.replace(" - YouTube", "");
     4375
     4376        #ifdef YT_USE_SCRIPT
     4377        int ret = QMessageBox::question(this, tr("Problems with Youtube"),
     4378                                tr("Unfortunately due to changes in the Youtube page, the video '%1' can't be played.").arg(t) + "<br><br>" +
     4379                                tr("Do you want to update the Youtube code? This may fix the problem."),
     4380                                QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
     4381        if (ret == QMessageBox::Yes) {
     4382                YTUpdateScript();
     4383        }
     4384        #else
     4385        QMessageBox::warning(this, tr("Problems with Youtube"),
     4386                tr("Unfortunately due to changes in the Youtube page, the video '%1' can't be played.").arg(t) + "<br><br>" +
     4387                tr("Maybe updating SMPlayer could fix the problem."));
     4388        #endif
     4389}
     4390
     4391#ifdef YT_USE_SCRIPT
     4392void BaseGui::YTUpdateScript() {
     4393        static CodeDownloader * downloader = 0;
     4394        if (!downloader) downloader = new CodeDownloader(this);
     4395        downloader->saveAs(Paths::configPath() + "/ytcode.script");
     4396        downloader->show();
     4397        downloader->download(QUrl("http://updates.smplayer.info/ytcode.script"));
     4398}
     4399#endif // YT_USE_SCRIPT
     4400#endif //YOUTUBE_SUPPORT
    42574401
    42584402void BaseGui::dragEnterEvent( QDragEnterEvent *e ) {
     
    44374581}
    44384582
     4583void BaseGui::displayMessage(QString message, int time) {
     4584        statusBar()->showMessage(message, time);
     4585}
     4586
    44394587void BaseGui::displayMessage(QString message) {
    4440         statusBar()->showMessage(message, 2000);
     4588        displayMessage(message, 2000);
    44414589}
    44424590
     
    49315079#endif
    49325080
     5081#ifdef YOUTUBE_SUPPORT
    49335082void BaseGui::showTubeBrowser() {
    49345083        qDebug("BaseGui::showTubeBrowser");
     
    49415090        }
    49425091}
     5092#endif
    49435093
    49445094// Language change stuff
Note: See TracChangeset for help on using the changeset viewer.