Changeset 118 for smplayer/vendor/current/src/basegui.cpp
- Timestamp:
- Dec 22, 2011, 6:27:52 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
smplayer/vendor/current/src/basegui.cpp
r90 r118 1 1 /* smplayer, GUI front-end for mplayer. 2 Copyright (C) 2006-201 0Ricardo Villalba <rvm@escomposlinux.org>2 Copyright (C) 2006-2011 Ricardo Villalba <rvm@escomposlinux.org> 3 3 4 4 This program is free software; you can redistribute it and/or modify … … 85 85 #include "prefinput.h" 86 86 #include "prefadvanced.h" 87 #include "prefplaylist.h" 87 88 88 89 #include "myaction.h" 89 90 #include "myactiongroup.h" 91 #include "playlist.h" 90 92 91 93 #include "constants.h" … … 95 97 #ifdef Q_OS_WIN 96 98 #include "deviceinfo.h" 99 #include <QSysInfo> 97 100 #endif 98 101 … … 104 107 near_bottom(false) 105 108 { 106 #if def Q_OS_WIN109 #if defined(Q_OS_WIN) || defined(Q_OS_OS2) 107 110 /* Disable screensaver by event */ 108 111 just_stopped = false; … … 208 211 connect(server, SIGNAL(receivedLoadSubtitle(QString)), 209 212 this, SLOT(remoteLoadSubtitle(QString))); 213 connect(server, SIGNAL(receivedPlayItem(int)), 214 this, SLOT(remotePlayItem(int))); 215 connect(server, SIGNAL(receivedRemoveItem(int)), 216 this, SLOT(remoteRemoveItem(int))); 217 connect(server, SIGNAL(receivedViewPlaylist(QString*)), 218 this, SLOT(remoteViewPlaylist(QString*))); 219 connect(server, SIGNAL(receivedViewStatus(QString*)), 220 this, SLOT(remoteViewStatus(QString*))); 221 connect(server, SIGNAL(receivedViewClipInfo(QString*)), 222 this, SLOT(remoteViewClipInfo(QString*))); 223 connect(server, SIGNAL(receivedSeek(double)), 224 this, SLOT(remoteSeek(double))); 225 connect(server, SIGNAL(receivedGetChecked(QString,QString*)), 226 this, SLOT(remoteGetChecked(QString,QString*))); 227 connect(server, SIGNAL(receivedMoveItem(int,int)), 228 this, SLOT(remoteMoveItem(int,int))); 229 connect(server, SIGNAL(receivedGetVolume(int*)), 230 this, SLOT(remoteGetVolume(int*))); 231 connect(server, SIGNAL(receivedSetVolume(int)), 232 core, SLOT(setVolume(int))); 210 233 211 234 if (pref->use_single_instance) { … … 222 245 } 223 246 247 void BaseGui::remotePlayItem(int index){ 248 qDebug("BaseGui::remotePlay: '%s'", QString::number((index)).toUtf8().data()); 249 if (isMinimized()) showNormal(); 250 if (!isVisible()) show(); 251 raise(); 252 activateWindow(); 253 playlist->playItem(index); 254 } 255 256 void BaseGui::remoteRemoveItem(int index){ 257 qDebug("BaseGui::remoteRemove: '%s'", QString::number((index)).toUtf8().data()); 258 if (isMinimized()) showNormal(); 259 if (!isVisible()) show(); 260 raise(); 261 activateWindow(); 262 263 if(index == -1) 264 playlist->removeAll(); 265 else 266 playlist->remove(index); 267 } 268 269 void BaseGui::remoteMoveItem(int index, int shift){ 270 qDebug("BaseGui::remoteRemove: '%s'", QString::number((index)).toUtf8().data()); 271 if (isMinimized()) showNormal(); 272 if (!isVisible()) show(); 273 raise(); 274 activateWindow(); 275 276 int step = shift / abs(shift); 277 for(int i = index; i != (index + shift); i += step){ 278 if(step == -1 && index == 0) break; 279 if(step == +1 && index == (playlist->count() - 1)) break; 280 281 if(step == -1) playlist->moveItemUp(index); 282 if(step == +1) playlist->moveItemDown(index); 283 } //end for 284 } 285 224 286 void BaseGui::remoteOpen(QString file) { 225 287 qDebug("BaseGui::remoteOpen: '%s'", file.toUtf8().data()); … … 259 321 core->loadSub(file); 260 322 } 323 } 324 325 void BaseGui::remoteViewPlaylist(QString * output){ 326 qDebug("BaseGui::remoteViewPlaylist"); 327 *output += playlist->print("\t"); 328 } 329 330 void BaseGui::remoteViewStatus(QString * output){ 331 qDebug("BaseGui::remoteViewStatus"); 332 *output = core->stateToString(); 333 } 334 335 void BaseGui::remoteViewClipInfo(QString * output){ 336 qDebug("BaseGui::remoteViewClipInfo"); 337 338 *output += QString("%1\t%2\r\n").arg("Filename", core->mdat.filename); 339 *output += QString("%1\t%2\r\n").arg("Position", QString::number(core->mset.current_sec)); 340 *output += QString("%1\t%2\r\n").arg("Duration", QString::number(core->mdat.duration)); 341 342 *output += QString("%1\t%2\r\n").arg("Title", core->mdat.clip_name); 343 *output += QString("%1\t%2\r\n").arg("Artist", core->mdat.clip_artist); 344 *output += QString("%1\t%2\r\n").arg("Author", core->mdat.clip_author); 345 *output += QString("%1\t%2\r\n").arg("Album", core->mdat.clip_album); 346 *output += QString("%1\t%2\r\n").arg("Genre", core->mdat.clip_genre); 347 *output += QString("%1\t%2\r\n").arg("Date", core->mdat.clip_date); 348 *output += QString("%1\t%2\r\n").arg("Track", core->mdat.clip_track); 349 *output += QString("%1\t%2\r\n").arg("Copyright", core->mdat.clip_copyright); 350 *output += QString("%1\t%2\r\n").arg("Comment", core->mdat.clip_comment); 351 *output += QString("%1\t%2\r\n").arg("Software", core->mdat.clip_software); 352 } 353 354 void BaseGui::remoteSeek(double sec){ 355 qDebug("BaseGui::remoteSeek"); 356 core->goToSec(sec); 357 } 358 359 void BaseGui::remoteGetChecked(QString function, QString* output){ 360 qDebug("BaseGui::remoteGet"); 361 362 QAction* action = ActionsEditor::findAction(this, function); 363 if(! action) action = ActionsEditor::findAction(playlist, function); 364 if(! action) return; 365 366 bool value = (action->isCheckable() ? action->isChecked() : action->isEnabled()); 367 *output = (value ? "true" : "false"); 368 } 369 370 void BaseGui::remoteGetVolume(int *vol){ 371 *vol = (pref->global_volume ? pref->volume : core->mset.volume); 261 372 } 262 373 … … 512 623 core, SLOT(toggleMirror(bool)) ); 513 624 514 motionVectorsAct = new MyAction( this, "motion_vectors" );515 motionVectorsAct->setCheckable( true );516 connect( motionVectorsAct, SIGNAL(toggled(bool)),517 core, SLOT(visualizeMotionVectors(bool)) );518 519 625 520 626 // Submenu filter … … 670 776 connect( useAssAct, SIGNAL(toggled(bool)), core, SLOT(changeUseAss(bool)) ); 671 777 672 useClosedCaptionAct = new MyAction(this, "use_closed_caption");673 useClosedCaptionAct->setCheckable(true);674 connect( useClosedCaptionAct, SIGNAL(toggled(bool)), core, SLOT(toggleClosedCaption(bool)) );675 676 778 useForcedSubsOnlyAct = new MyAction(this, "use_forced_subs_only"); 677 779 useForcedSubsOnlyAct->setCheckable(true); … … 726 828 connect( showTipsAct, SIGNAL(triggered()), 727 829 this, SLOT(helpTips()) ); 830 831 donateAct = new MyAction( this, "donate" ); 832 connect( donateAct, SIGNAL(triggered()), 833 this, SLOT(helpDonate()) ); 728 834 729 835 aboutQtAct = new MyAction( this, "about_qt" ); … … 1026 1132 core, SLOT(changeSubtitle(int)) ); 1027 1133 1134 ccGroup = new MyActionGroup(this); 1135 ccNoneAct = new MyActionGroupItem(this, ccGroup, "cc_none", 0); 1136 ccChannel1Act = new MyActionGroupItem(this, ccGroup, "cc_ch_1", 1); 1137 ccChannel2Act = new MyActionGroupItem(this, ccGroup, "cc_ch_2", 2); 1138 ccChannel3Act = new MyActionGroupItem(this, ccGroup, "cc_ch_3", 3); 1139 ccChannel4Act = new MyActionGroupItem(this, ccGroup, "cc_ch_4", 4); 1140 connect( ccGroup, SIGNAL(activated(int)), 1141 core, SLOT(changeClosedCaptionChannel(int)) ); 1142 1028 1143 // Titles 1029 1144 titleGroup = new MyActionGroup(this); … … 1278 1393 #ifndef Q_OS_WIN 1279 1394 // Disable video filters if using vdpau 1280 if ((pref-> disable_video_filters_with_vdpau) && (pref->vo.startsWith("vdpau"))) {1395 if ((pref->vdpau.disable_video_filters) && (pref->vo.startsWith("vdpau"))) { 1281 1396 screenshotAct->setEnabled(false); 1282 1397 screenshotsAct->setEnabled(false); … … 1408 1523 flipAct->change( Images::icon("flip"), tr("Fli&p image") ); 1409 1524 mirrorAct->change( Images::icon("mirror"), tr("Mirr&or image") ); 1410 motionVectorsAct->change( Images::icon("motion_vectors"),1411 tr("Visualize &motion vectors") );1412 1525 1413 1526 decZoomAct->change( tr("Zoom &-") ); … … 1469 1582 tr("N&ext line in subtitles") ); 1470 1583 useAssAct->change( Images::icon("use_ass_lib"), tr("Use SSA/&ASS library") ); 1471 useClosedCaptionAct->change( Images::icon("closed_caption"), tr("Enable &closed caption") );1472 1584 useForcedSubsOnlyAct->change( Images::icon("forced_subs"), tr("&Forced subtitles only") ); 1473 1585 … … 1476 1588 showFindSubtitlesDialogAct->change( Images::icon("download_subs"), tr("Find subtitles on &OpenSubtitles.org...") ); 1477 1589 openUploadSubtitlesPageAct->change( Images::icon("upload_subs"), tr("Upload su&btitles to OpenSubtitles.org...") ); 1590 1591 ccNoneAct->change( tr("&Off") ); 1592 ccChannel1Act->change( "&1" ); 1593 ccChannel2Act->change( "&2" ); 1594 ccChannel3Act->change( "&3" ); 1595 ccChannel4Act->change( "&4" ); 1478 1596 1479 1597 // Menu Options … … 1490 1608 showCLOptionsAct->change( Images::icon("cl_help"), tr("&Command line options") ); 1491 1609 showTipsAct->change( Images::icon("tips"), tr("&Tips") ); 1610 donateAct->change( Images::icon("donate"), tr("&Donate") ); 1492 1611 aboutQtAct->change( QPixmap(":/icons-png/qt.png"), tr("About &Qt") ); 1493 1612 aboutThisAct->change( Images::icon("logo_small"), tr("About &SMPlayer") ); … … 1691 1810 subtitlestrack_menu->menuAction()->setIcon( Images::icon("sub") ); 1692 1811 1812 closed_captions_menu->menuAction()->setText( tr("&Closed captions") ); 1813 closed_captions_menu->menuAction()->setIcon( Images::icon("closed_caption") ); 1814 1693 1815 // Menu Browse 1694 1816 titles_menu->menuAction()->setText( tr("&Title") ); … … 2181 2303 videoMenu->addSeparator(); 2182 2304 videoMenu->addAction(videoPreviewAct); 2183 videoMenu->addSeparator();2184 videoMenu->addAction(motionVectorsAct);2185 2305 2186 2306 … … 2241 2361 subtitlesMenu->addAction(unloadSubsAct); 2242 2362 subtitlesMenu->addSeparator(); 2363 2364 closed_captions_menu = new QMenu(this); 2365 closed_captions_menu->menuAction()->setObjectName("closed_captions_menu"); 2366 closed_captions_menu->addAction( ccNoneAct); 2367 closed_captions_menu->addAction( ccChannel1Act); 2368 closed_captions_menu->addAction( ccChannel2Act); 2369 closed_captions_menu->addAction( ccChannel3Act); 2370 closed_captions_menu->addAction( ccChannel4Act); 2371 subtitlesMenu->addMenu(closed_captions_menu); 2372 subtitlesMenu->addSeparator(); 2373 2243 2374 subtitlesMenu->addAction(decSubDelayAct); 2244 2375 subtitlesMenu->addAction(incSubDelayAct); … … 2255 2386 subtitlesMenu->addAction(incSubStepAct); 2256 2387 subtitlesMenu->addSeparator(); 2257 subtitlesMenu->addAction(useClosedCaptionAct);2258 2388 subtitlesMenu->addAction(useForcedSubsOnlyAct); 2259 2389 subtitlesMenu->addSeparator(); … … 2329 2459 helpMenu->addAction(showCLOptionsAct); 2330 2460 helpMenu->addAction(showTipsAct); 2461 helpMenu->addAction(donateAct); 2331 2462 helpMenu->addSeparator(); 2332 2463 helpMenu->addAction(aboutQtAct); … … 2440 2571 pref_dialog->mod_input()->actions_editor->addActions(playlist); 2441 2572 #endif 2573 2574 // Set playlist preferences 2575 PrefPlaylist * pl = pref_dialog->mod_playlist(); 2576 pl->setDirectoryRecursion(playlist->directoryRecursion()); 2577 pl->setAutoGetInfo(playlist->autoGetInfo()); 2578 pl->setSavePlaylistOnExit(playlist->savePlaylistOnExit()); 2579 pl->setPlayFilesFromStart(playlist->playFilesFromStart()); 2580 2442 2581 pref_dialog->show(); 2443 2582 } … … 2516 2655 } 2517 2656 2657 // Update playlist preferences 2658 PrefPlaylist * pl = pref_dialog->mod_playlist(); 2659 playlist->setDirectoryRecursion(pl->directoryRecursion()); 2660 playlist->setAutoGetInfo(pl->autoGetInfo()); 2661 playlist->setSavePlaylistOnExit(pl->savePlaylistOnExit()); 2662 playlist->setPlayFilesFromStart(pl->playFilesFromStart()); 2663 2664 2518 2665 if (need_update_language) { 2519 2666 translator->load(pref->language); … … 2647 2794 } 2648 2795 2649 setWindowCaption( core->mdat.displayName( ) + " - SMPlayer" );2796 setWindowCaption( core->mdat.displayName(pref->show_tag_in_window_title) + " - SMPlayer" ); 2650 2797 2651 2798 emit videoInfoChanged(core->mdat.video_width, core->mdat.video_height, core->mdat.video_fps.toDouble()); … … 2961 3108 // Disable the unload subs action if there's no external subtitles 2962 3109 unloadSubsAct->setEnabled( !core->mset.external_subtitles.isEmpty() ); 3110 3111 // Closed caption menu 3112 ccGroup->setChecked( core->mset.closed_caption_channel ); 2963 3113 2964 3114 // Audio menu … … 3084 3234 #endif 3085 3235 3086 // Motion vectors3087 motionVectorsAct->setChecked( pref->show_motion_vectors );3088 3089 3236 // Compact mode 3090 3237 compactAct->setChecked( pref->compact_mode ); … … 3102 3249 useAssAct->setChecked( pref->use_ass_subtitles ); 3103 3250 3104 // Closed caption and forces subs 3105 useClosedCaptionAct->setChecked( pref->use_closed_caption_subs ); 3251 // Forced subs 3106 3252 useForcedSubsOnlyAct->setChecked( pref->use_forced_subs_only ); 3107 3253 … … 3113 3259 (core->mset.current_sub_id != MediaSettings::NoneSelected)); 3114 3260 3115 if ( pref->use_closed_caption_subs) e = true; // Enable if using closed captions3261 if (core->mset.closed_caption_channel !=0 ) e = true; // Enable if using closed captions 3116 3262 3117 3263 decSubDelayAct->setEnabled(e); … … 3514 3660 3515 3661 void BaseGui::helpTips() { 3516 QDesktopServices::openUrl( QUrl("http://smplayer.berlios.de/forum/viewforum.php?f=12") ); 3662 QDesktopServices::openUrl( QUrl("http://smplayer.sf.net/forum/viewforum.php?f=12") ); 3663 } 3664 3665 void BaseGui::helpDonate() { 3666 QMessageBox d(QMessageBox::NoIcon, tr("Donate"), 3667 tr("If you like SMPlayer, a really good way to support it is by sending a donation, even the smallest one is highly appreciated.") + "<br>" + 3668 tr("You can send your donation using %1.").arg("<a href=\"https://sourceforge.net/donate/index.php?group_id=185512\">"+tr("this form")), 3669 QMessageBox::Ok, this); 3670 d.setIconPixmap( Images::icon("logo", 64) ); 3671 d.exec(); 3517 3672 } 3518 3673 … … 3603 3758 3604 3759 #ifdef Q_OS_WIN 3605 // Avoid the video to pause 3606 if (!pref->pause_when_hidden) hide(); 3760 // Hack to avoid the windows taskbar to be visible on Windows XP 3761 if (QSysInfo::WindowsVersion < QSysInfo::WV_VISTA) { 3762 if (!pref->pause_when_hidden) hide(); 3763 } 3607 3764 #endif 3608 3765 … … 3610 3767 3611 3768 } else { 3612 #ifdef Q_OS_WIN3613 // Avoid the video to pause3614 if (!pref->pause_when_hidden) hide();3615 #endif3616 3617 3769 showNormal(); 3618 3770 … … 3707 3859 qDebug("BaseGui::processFunction: '%s'", function.toUtf8().data()); 3708 3860 3861 //parse args for checkable actions 3862 QRegExp func_rx("(.*) (true|false)"); 3863 bool value = false; 3864 bool checkableFunction = false; 3865 3866 if(func_rx.indexIn(function) > -1){ 3867 function = func_rx.cap(1); 3868 value = (func_rx.cap(2) == "true"); 3869 checkableFunction = true; 3870 } //end if 3871 3709 3872 QAction * action = ActionsEditor::findAction(this, function); 3710 3873 if (!action) action = ActionsEditor::findAction(playlist, function); … … 3712 3875 if (action) { 3713 3876 qDebug("BaseGui::processFunction: action found"); 3714 if (action->isCheckable()) 3715 //action->toggle(); 3877 3878 if (!action->isEnabled()) { 3879 qDebug("BaseGui::processFunction: action is disabled, doing nothing"); 3880 return; 3881 } 3882 3883 if (action->isCheckable()){ 3884 if(checkableFunction) 3885 action->setChecked(value); 3886 else 3887 //action->toggle(); 3888 action->trigger(); 3889 }else{ 3716 3890 action->trigger(); 3717 else 3718 action->trigger(); 3891 } 3719 3892 } 3720 3893 } … … 3726 3899 3727 3900 QAction * action; 3728 QStringList l = actions.split(" "); 3729 3730 for (int n = 0; n < l.count(); n++) { 3731 QString a = l[n]; 3732 QString par = ""; 3733 3734 if ( (n+1) < l.count() ) { 3735 if ( (l[n+1].toLower() == "true") || (l[n+1].toLower() == "false") ) { 3736 par = l[n+1].toLower(); 3901 QStringList actionsList = actions.split(" "); 3902 3903 for (int n = 0; n < actionsList.count(); n++) { 3904 QString actionStr = actionsList[n]; 3905 QString par = ""; //the parameter which the action takes 3906 3907 //set par if the next word is a boolean value 3908 if ( (n+1) < actionsList.count() ) { 3909 if ( (actionsList[n+1].toLower() == "true") || (actionsList[n+1].toLower() == "false") ) { 3910 par = actionsList[n+1].toLower(); 3737 3911 n++; 3738 } 3739 } 3740 3741 action = ActionsEditor::findAction(this, a );3742 if (!action) action = ActionsEditor::findAction(playlist, a );3912 } //end if 3913 } //end if 3914 3915 action = ActionsEditor::findAction(this, actionStr); 3916 if (!action) action = ActionsEditor::findAction(playlist, actionStr); 3743 3917 3744 3918 if (action) { 3745 3919 qDebug("BaseGui::runActions: running action: '%s' (par: '%s')", 3746 a.toUtf8().data(), par.toUtf8().data() );3920 actionStr.toUtf8().data(), par.toUtf8().data() ); 3747 3921 3748 3922 if (action->isCheckable()) { … … 3752 3926 } else { 3753 3927 action->setChecked( (par == "true") ); 3754 } 3755 } 3756 else { 3928 } //end if 3929 } else { 3757 3930 action->trigger(); 3758 } 3931 } //end if 3759 3932 } else { 3760 qWarning("BaseGui::runActions: action: '%s' not found",a .toUtf8().data());3761 } 3762 } 3933 qWarning("BaseGui::runActions: action: '%s' not found",actionStr.toUtf8().data()); 3934 } //end if 3935 } //end for 3763 3936 } 3764 3937 … … 3983 4156 if (state == Core::Stopped) setWindowCaption( "SMPlayer" ); 3984 4157 3985 #if def Q_OS_WIN4158 #if defined(Q_OS_WIN) || defined(Q_OS_OS2) 3986 4159 /* Disable screensaver by event */ 3987 4160 just_stopped = false; … … 4498 4671 return false; 4499 4672 } 4500 4673 #endif 4674 4675 #if defined(Q_OS_WIN) || defined(Q_OS_OS2) 4501 4676 void BaseGui::clear_just_stopped() { 4502 4677 qDebug("BaseGui::clear_just_stopped");
Note:
See TracChangeset
for help on using the changeset viewer.