Changeset 188 for smplayer/trunk/src/basegui.cpp
- Timestamp:
- Jan 24, 2017, 12:41:54 PM (8 years ago)
- Location:
- smplayer/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
smplayer/trunk
- Property svn:mergeinfo changed
/smplayer/vendor/current merged: 186
- Property svn:mergeinfo changed
-
smplayer/trunk/src/basegui.cpp
r182 r188 1 1 /* smplayer, GUI front-end for mplayer. 2 Copyright (C) 2006-201 6Ricardo Villalba <rvm@users.sourceforge.net>2 Copyright (C) 2006-2017 Ricardo Villalba <rvm@users.sourceforge.net> 3 3 4 4 This program is free software; you can redistribute it and/or modify … … 42 42 #include <QDesktopWidget> 43 43 44 #include < cmath>44 #include <QtCore/qmath.h> 45 45 46 46 #include "mplayerwindow.h" … … 261 261 #endif 262 262 263 #if defined(SHARE_ACTIONS) && !defined(SHARE_WIDGET)263 #ifdef DONATE_REMINDER 264 264 QTimer::singleShot(1000, this, SLOT(checkReminder())); 265 265 #endif … … 907 907 this, SLOT(helpShowConfig()) ); 908 908 909 #ifdef SHARE_ACTIONS910 909 donateAct = new MyAction( this, "donate" ); 911 910 connect( donateAct, SIGNAL(triggered()), 912 911 this, SLOT(helpDonate()) ); 913 #endif914 912 915 913 aboutThisAct = new MyAction( this, "about_smplayer" ); … … 1068 1066 core, SLOT(nextWheelFunction()) ); 1069 1067 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"); 1071 1069 connect( showFilenameAct, SIGNAL(triggered()), core, SLOT(showFilenameOnOSD()) ); 1072 1070 … … 1482 1480 1483 1481 // Screenshot option 1482 /* 1484 1483 bool screenshots_enabled = ( (pref->use_screenshot) && 1485 1484 (!pref->screenshot_directory.isEmpty()) && … … 1488 1487 screenshotAct->setEnabled( screenshots_enabled ); 1489 1488 screenshotsAct->setEnabled( screenshots_enabled ); 1489 */ 1490 1490 1491 1491 #ifdef CAPTURE_STREAM … … 1568 1568 // Disable video filters if using vdpau 1569 1569 if ((pref->vdpau.disable_video_filters) && (pref->vo.startsWith("vdpau"))) { 1570 /* 1570 1571 screenshotAct->setEnabled(false); 1571 1572 screenshotsAct->setEnabled(false); 1573 */ 1572 1574 flipAct->setEnabled(false); 1573 1575 mirrorAct->setEnabled(false); … … 1844 1846 #ifdef SHARE_ACTIONS 1845 1847 donateAct->change( Images::icon("donate"), tr("&Donate / Share with your friends") ); 1848 #else 1849 donateAct->change( Images::icon("donate"), tr("&Donate") ); 1846 1850 #endif 1847 1851 aboutThisAct->change( Images::icon("logo"), tr("About &SMPlayer") ); … … 1899 1903 nextWheelFunctionAct->change( Images::icon("next_wheel_function"), tr("Next wheel function") ); 1900 1904 1901 showFilenameAct->change( tr("Show filenameon OSD") );1905 showFilenameAct->change( tr("Show &info on OSD") ); 1902 1906 showTimeAct->change( tr("Show playback time on OSD") ); 1907 1903 1908 toggleDeinterlaceAct->change( tr("Toggle deinterlacing") ); 1904 1909 … … 2320 2325 sharewidget = new ShareWidget(Global::settings, mplayerwindow); 2321 2326 mplayerwindow->setCornerWidget(sharewidget); 2322 #ifdef SHARE_ACTIONS2327 //#ifdef SHARE_ACTIONS 2323 2328 connect(sharewidget, SIGNAL(supportClicked()), this, SLOT(helpDonate())); 2324 #endif2329 //#endif 2325 2330 #endif 2326 2331 … … 2434 2439 core, SLOT(open(const QString &, int))); 2435 2440 2441 connect(playlist, SIGNAL(requestToPlayStream(const QString &, QStringList)), 2442 core, SLOT(openStream(const QString &, QStringList))); 2443 2436 2444 connect(playlist, SIGNAL(requestToAddCurrentFile()), this, SLOT(addToPlaylistCurrentFile())); 2437 2445 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 2441 2448 connect( core, SIGNAL(mplayerFailed(QProcess::ProcessError)), playlist, SLOT(playerFailed(QProcess::ProcessError)) ); 2442 2449 connect( core, SIGNAL(mplayerFinishedWithError(int)), playlist, SLOT(playerFinishedWithError(int)) ); … … 2696 2703 osd_menu->menuAction()->setObjectName("osd_menu"); 2697 2704 osd_menu->addActions(osdGroup->actions()); 2705 osd_menu->addSeparator(); 2706 osd_menu->addAction(showFilenameAct); 2698 2707 osd_menu->addSeparator(); 2699 2708 osd_menu->addAction(decOSDScaleAct); … … 2985 2994 helpMenu->addSeparator(); 2986 2995 } 2987 #ifdef SHARE_ACTIONS2988 2996 helpMenu->addAction(donateAct); 2989 2997 helpMenu->addSeparator(); 2990 #endif2991 2998 helpMenu->addAction(aboutThisAct); 2992 2999 … … 3107 3114 pl->setSavePlaylistOnExit(playlist->savePlaylistOnExit()); 3108 3115 pl->setPlayFilesFromStart(playlist->playFilesFromStart()); 3116 pl->setPlayOnLoad(playlist->startPlayOnLoad()); 3117 pl->setPlayNextAutomatically(playlist->automaticallyPlayNext()); 3109 3118 pl->setIgnorePlayerErrors(playlist->ignorePlayerErrors()); 3119 pl->setAutoSort(playlist->autoSort()); 3120 pl->setFilterCaseSensitive(playlist->filterCaseSensitive()); 3110 3121 3111 3122 pref_dialog->show(); … … 3117 3128 3118 3129 bool need_update_language = false; 3130 bool need_apply_styles = false; 3119 3131 3120 3132 PlayerID::Player old_player_type = PlayerID::player(pref->mplayer_bin); … … 3124 3136 // Setup proxy 3125 3137 setupNetworkProxy(); 3126 3127 // Change application font3128 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 }3136 3138 3137 3139 PrefGeneral *_general = pref_dialog->mod_general(); … … 3150 3152 // Stylesheet 3151 3153 #if ALLOW_CHANGE_STYLESHEET 3152 if (!_interface->guiChanged()) applyStyles();3154 if (!_interface->guiChanged()) need_apply_styles = true; 3153 3155 #endif 3154 3156 } 3157 3158 if (_interface->fontChanged()) need_apply_styles = true; 3155 3159 3156 3160 #ifndef MOUSE_GESTURES … … 3199 3203 playlist->setSavePlaylistOnExit(pl->savePlaylistOnExit()); 3200 3204 playlist->setPlayFilesFromStart(pl->playFilesFromStart()); 3205 playlist->setStartPlayOnLoad(pl->playOnLoad()); 3206 playlist->setAutomaticallyPlayNext(pl->playNextAutomatically()); 3201 3207 playlist->setIgnorePlayerErrors(pl->ignorePlayerErrors()); 3208 playlist->setAutoSort(pl->autoSort()); 3209 playlist->setFilterCaseSensitive(pl->filterCaseSensitive()); 3202 3210 3203 3211 #ifdef PLAYLIST_DOWNLOAD … … 3214 3222 #if STYLE_SWITCHING 3215 3223 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 3221 3231 if (pref_dialog->requiresRestart()) 3222 3232 core->restart(); … … 4092 4102 qDebug("BaseGui::openFavorite"); 4093 4103 4104 QUrl url(file); 4105 if (url.isValid() && url.scheme().toLower() == "file") { 4106 file = url.toLocalFile(); 4107 } 4108 4094 4109 openFiles(QStringList() << file); 4095 4110 } … … 4157 4172 4158 4173 void BaseGui::openFile() { 4159 qDebug("BaseGui:: fileOpen");4174 qDebug("BaseGui::openFile"); 4160 4175 4161 4176 exitFullscreenIfNeeded(); … … 4176 4191 4177 4192 void BaseGui::openFile(QString file) { 4178 qDebug( "BaseGui::openFile: '%s'", file.toUtf8().data());4193 qDebug() << "BaseGui::openFile:" << file; 4179 4194 4180 4195 if ( !file.isEmpty() ) { 4181 4196 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 4182 4205 //playlist->clear(); 4183 4206 //playlistdock->hide(); … … 4465 4488 #endif 4466 4489 } 4490 } 4491 #else 4492 void 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 4508 void 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; 4467 4531 } 4468 4532 #endif … … 4652 4716 updateWidgets(); 4653 4717 4718 #ifdef ADD_BLACKBORDERS_FS 4654 4719 if ((pref->add_blackborders_on_fullscreen) && 4655 4720 (!core->mset.add_letterbox)) … … 4658 4723 /* core->restart(); */ 4659 4724 } 4725 #endif 4660 4726 4661 4727 setFocus(); // Fixes bug #2493415 … … 4890 4956 #endif 4891 4957 4892 #if defined(SHARE_ACTIONS) && !defined(SHARE_WIDGET)4958 #ifdef DONATE_REMINDER 4893 4959 void BaseGui::checkReminder() { 4894 4960 qDebug("BaseGui::checkReminder"); … … 4912 4978 #endif 4913 4979 4980 #ifdef SHARE_ACTIONS 4914 4981 ShareDialog d(this); 4915 4982 //d.showRemindCheck(false); … … 4923 4990 set->endGroup(); 4924 4991 } 4992 #else 4993 action = 0; 4994 bool accepted; 4995 showHelpDonateDialog(&accepted); 4996 if (accepted) action = 1; 4997 #endif 4925 4998 4926 4999 if (action > 0) { … … 5222 5295 if (!core->mdat.filename.isEmpty()) { 5223 5296 playlist->addItem(core->mdat.filename, "", 0); 5297 playlist->setModified(true); 5224 5298 playlist->getMediaInfo(core->mdat); 5225 5299 } … … 5260 5334 5261 5335 void BaseGui::gotCurrentTime(double sec) { 5262 //qDebug( "DefaultGui::displayTime: %f", sec);5336 //qDebug() << "BaseGui::gotCurrentTime:" << sec; 5263 5337 5264 5338 static int last_second = 0; 5265 5339 5266 if ( floor(sec)==last_second) return; // Update only once per second5267 last_second = (int) floor(sec);5340 if (qFloor(sec) == last_second) return; // Update only once per second 5341 last_second = qFloor(sec); 5268 5342 5269 5343 QString time = Helper::formatTime( (int) sec ) + " / " + 5270 5344 Helper::formatTime( (int) core->mdat.duration ); 5271 5272 //qDebug( " duration: %f, current_sec: %f", core->mdat.duration, core->mset.current_sec);5273 5345 5274 5346 emit timeChanged(sec); … … 5401 5473 5402 5474 if (panel->isVisible()) { 5475 if (isMaximized()) showNormal(); 5476 5403 5477 // Exit from fullscreen mode 5404 5478 if (pref->fullscreen) { toggleFullscreen(false); update(); } … … 5628 5702 } 5629 5703 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 } 5630 5713 //qDebug() << "BaseGui::changeStyleSheet: styleSheet:" << stylesheet; 5631 5714 qApp->setStyleSheet(stylesheet); … … 5635 5718 void BaseGui::applyStyles() { 5636 5719 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 5637 5731 5638 5732 #if ALLOW_CHANGE_STYLESHEET … … 5652 5746 } 5653 5747 #endif 5748 5654 5749 } 5655 5750
Note:
See TracChangeset
for help on using the changeset viewer.