Changeset 154 for smplayer/vendor/current/src/basegui.cpp
- Timestamp:
- Feb 21, 2014, 4:44:11 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
smplayer/vendor/current/src/basegui.cpp
r140 r154 108 108 #include "updatechecker.h" 109 109 110 #ifdef YT_USE_SCRIPT 111 #include "codedownloader.h" 112 #endif 113 110 114 using namespace Global; 111 115 … … 199 203 200 204 #ifdef UPDATE_CHECKER 201 update_checker = new UpdateChecker(this, Global::settings);205 update_checker = new UpdateChecker(this, &pref->update_checker_data); 202 206 connect(update_checker, SIGNAL(newVersionFound(QString)), 203 207 this, SLOT(reportNewVersionAvailable(QString))); 204 208 #endif 205 209 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())); 208 216 #endif 209 217 } … … 240 248 241 249 if (command == "open_file") { 250 emit openFileRequested(); 242 251 open(arg); 243 252 } … … 245 254 if (command == "open_files") { 246 255 QStringList file_list = arg.split(" <<sep>> "); 256 emit openFileRequested(); 247 257 openFiles(file_list); 248 258 } … … 250 260 if (command == "add_to_playlist") { 251 261 QStringList file_list = arg.split(" <<sep>> "); 262 /* if (core->state() == Core::Stopped) { emit openFileRequested(); } */ 252 263 playlist->addFiles(file_list); 253 264 } … … 258 269 else 259 270 if (command == "load_sub") { 260 setInitialSubtitle(arg); 271 setInitialSubtitle(arg); 261 272 if (core->state() != Core::Stopped) { 262 273 core->loadSub(arg); … … 729 740 this, SLOT(showPreferencesDialog()) ); 730 741 742 #ifdef YOUTUBE_SUPPORT 731 743 showTubeBrowserAct = new MyAction( Qt::Key_F11, this, "show_tube_browser" ); 732 744 connect( showTubeBrowserAct, SIGNAL(triggered()), 733 745 this, SLOT(showTubeBrowser()) ); 746 #endif 734 747 735 748 // Submenu Logs … … 763 776 this, SLOT(helpCheckUpdates()) ); 764 777 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 765 784 showConfigAct = new MyAction( this, "show_config" ); 766 785 connect( showConfigAct, SIGNAL(triggered()), 767 786 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 768 793 769 794 aboutQtAct = new MyAction( this, "about_qt" ); … … 1465 1490 // Menu Play 1466 1491 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") ); 1471 1493 1472 1494 pauseAct->change( Images::icon("pause"), tr("&Pause")); … … 1475 1497 1476 1498 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") ); 1481 1500 1482 1501 pauseAndStepAct->change( Images::icon("pause"), tr("Pause / Frame step") ); … … 1601 1620 showPropertiesAct->change( Images::icon("info"), tr("View &info and properties...") ); 1602 1621 showPreferencesAct->change( Images::icon("prefs"), tr("P&references") ); 1622 #ifdef YOUTUBE_SUPPORT 1603 1623 showTubeBrowserAct->change( Images::icon("tubebrowser"), tr("&YouTube%1 browser").arg(QChar(0x2122)) ); 1624 #endif 1604 1625 1605 1626 // Submenu Logs … … 1616 1637 showCLOptionsAct->change( Images::icon("cl_help"), tr("&Command line options") ); 1617 1638 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 1618 1644 showConfigAct->change( Images::icon("show_config"), tr("&Open configuration folder") ); 1645 #ifdef REMINDER_ACTIONS 1646 donateAct->change( Images::icon("donate"), tr("&Donate") ); 1647 #endif 1619 1648 aboutQtAct->change( QPixmap(":/icons-png/qt.png"), tr("About &Qt") ); 1620 1649 aboutThisAct->change( Images::icon("logo_small"), tr("About &SMPlayer") ); … … 1631 1660 playPrevAct->change( tr("Pre&vious") ); 1632 1661 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") ); 1640 1664 1641 1665 … … 1915 1939 forward3Act->change( tr("+%1").arg(Helper::timeForJumps(pref->seeking3)) ); 1916 1940 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") ); 1934 1948 } 1935 1949 … … 1962 1976 connect( core, SIGNAL(needResize(int, int)), 1963 1977 this, SLOT(resizeWindow(int,int)) ); 1978 1979 connect( core, SIGNAL(showMessage(QString,int)), 1980 this, SLOT(displayMessage(QString,int)) ); 1964 1981 connect( core, SIGNAL(showMessage(QString)), 1965 1982 this, SLOT(displayMessage(QString)) ); 1983 1966 1984 connect( core, SIGNAL(stateChanged(Core::State)), 1967 1985 this, SLOT(displayState(Core::State)) ); … … 2031 2049 connect( core, SIGNAL(mediaLoaded()), 2032 2050 this, SLOT(autosaveMplayerLog()) ); 2051 #endif 2052 2053 #ifdef YOUTUBE_SUPPORT 2054 connect(core, SIGNAL(signatureNotFound(const QString &)), 2055 this, SLOT(YTNoSignature(const QString &))); 2033 2056 #endif 2034 2057 } … … 2171 2194 2172 2195 void BaseGui::createPreferencesDialog() { 2196 QApplication::setOverrideCursor(Qt::WaitCursor); 2173 2197 pref_dialog = new PreferencesDialog(this); 2174 2198 pref_dialog->setModal(false); … … 2176 2200 connect( pref_dialog, SIGNAL(applied()), 2177 2201 this, SLOT(applyNewPreferences()) ); 2202 QApplication::restoreOverrideCursor(); 2178 2203 } 2179 2204 2180 2205 void BaseGui::createFilePropertiesDialog() { 2206 QApplication::setOverrideCursor(Qt::WaitCursor); 2181 2207 file_dialog = new FilePropertiesDialog(this); 2182 2208 file_dialog->setModal(false); 2183 2209 connect( file_dialog, SIGNAL(applied()), 2184 2210 this, SLOT(applyFileProperties()) ); 2211 QApplication::restoreOverrideCursor(); 2185 2212 } 2186 2213 … … 2537 2564 optionsMenu->addAction(showPropertiesAct); 2538 2565 optionsMenu->addAction(showPlaylistAct); 2566 #ifdef YOUTUBE_SUPPORT 2539 2567 #if 0 2540 2568 // Check if the smplayer youtube browser is installed … … 2554 2582 optionsMenu->addAction(showTubeBrowserAct); 2555 2583 #endif 2584 #endif 2556 2585 2557 2586 // OSD submenu … … 2596 2625 helpMenu->addAction(showFAQAct); 2597 2626 helpMenu->addAction(showCLOptionsAct); 2627 helpMenu->addSeparator(); 2598 2628 helpMenu->addAction(showCheckUpdatesAct); 2629 #if defined(YOUTUBE_SUPPORT) && defined(YT_USE_SCRIPT) 2630 helpMenu->addAction(updateYTAct); 2631 #endif 2632 helpMenu->addSeparator(); 2599 2633 helpMenu->addAction(showConfigAct); 2600 2634 helpMenu->addSeparator(); 2635 #ifdef REMINDER_ACTIONS 2636 helpMenu->addAction(donateAct); 2637 helpMenu->addSeparator(); 2638 #endif 2601 2639 helpMenu->addAction(aboutQtAct); 2602 2640 helpMenu->addAction(aboutThisAct); … … 3843 3881 3844 3882 void 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())); 3846 3884 } 3847 3885 … … 3871 3909 } 3872 3910 3911 #ifdef REMINDER_ACTIONS 3912 void 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 3873 3930 void BaseGui::helpAbout() { 3874 3931 About d(this); … … 3902 3959 if (sender() == facebookAct) { 3903 3960 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 3904 3968 } 3905 3969 } … … 4217 4281 QMessageBox::StandardButton button = QMessageBox::information(this, tr("New version available"), 4218 4282 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>" + 4220 4284 tr("Available version: %1").arg(new_version) + "<br><br>" + 4221 4285 tr("Would you like to know more about this new version?"), … … 4230 4294 #endif 4231 4295 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 4297 void BaseGui::checkIfUpgraded() { 4298 qDebug("BaseGui::checkIfUpgraded"); 4299 4300 if ( (pref->check_if_upgraded) && (pref->smplayer_stable_version != Version::stable()) ) { 4244 4301 // 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()); 4246 4303 QString os = "other"; 4247 4304 #ifdef Q_OS_WIN … … 4251 4308 os = "linux"; 4252 4309 #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 4317 void 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 4370 void 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 4392 void 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 4257 4401 4258 4402 void BaseGui::dragEnterEvent( QDragEnterEvent *e ) { … … 4437 4581 } 4438 4582 4583 void BaseGui::displayMessage(QString message, int time) { 4584 statusBar()->showMessage(message, time); 4585 } 4586 4439 4587 void BaseGui::displayMessage(QString message) { 4440 statusBar()->showMessage(message, 2000);4588 displayMessage(message, 2000); 4441 4589 } 4442 4590 … … 4931 5079 #endif 4932 5080 5081 #ifdef YOUTUBE_SUPPORT 4933 5082 void BaseGui::showTubeBrowser() { 4934 5083 qDebug("BaseGui::showTubeBrowser"); … … 4941 5090 } 4942 5091 } 5092 #endif 4943 5093 4944 5094 // Language change stuff
Note:
See TracChangeset
for help on using the changeset viewer.