Changeset 163 for smplayer/vendor/current/src/basegui.cpp
- Timestamp:
- May 15, 2014, 7:53:54 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
smplayer/vendor/current/src/basegui.cpp
r154 r163 1 1 /* smplayer, GUI front-end for mplayer. 2 Copyright (C) 2006-201 3Ricardo Villalba <rvm@users.sourceforge.net>2 Copyright (C) 2006-2014 Ricardo Villalba <rvm@users.sourceforge.net> 3 3 4 4 This program is free software; you can redistribute it and/or modify … … 39 39 #include <QInputDialog> 40 40 #include <QClipboard> 41 #include <QMimeData> 41 42 42 43 #include <cmath> … … 57 58 #include "filepropertiesdialog.h" 58 59 #include "eqslider.h" 59 #include "videoequalizer 2.h"60 #include "videoequalizer.h" 60 61 #include "audioequalizer.h" 61 62 #include "inputdvddirectory.h" … … 112 113 #endif 113 114 115 #ifdef REMINDER_ACTIONS 116 #include "sharedialog.h" 117 #endif 118 114 119 using namespace Global; 115 120 116 121 BaseGui::BaseGui( QWidget* parent, Qt::WindowFlags flags ) 117 : QMainWindow( parent, flags ), 118 near_top(false), 119 near_bottom(false) 122 : QMainWindow( parent, flags ) 120 123 { 121 124 #if defined(Q_OS_WIN) || defined(Q_OS_OS2) … … 153 156 154 157 // Mouse Wheel 158 /* 155 159 connect( this, SIGNAL(wheelUp()), 156 160 core, SLOT(wheelUp()) ); 157 161 connect( this, SIGNAL(wheelDown()), 158 162 core, SLOT(wheelDown()) ); 163 */ 159 164 connect( mplayerwindow, SIGNAL(wheelUp()), 160 165 core, SLOT(wheelUp()) ); … … 185 190 #if AUTODISABLE_ACTIONS 186 191 setActionsEnabled(false); 192 if (playlist->count() > 0) { 193 playAct->setEnabled(true); 194 playOrPauseAct->setEnabled(true); 195 } 187 196 #endif 188 197 … … 218 227 219 228 void BaseGui::initializeGui() { 220 if (pref->compact_mode) toggleCompactMode( TRUE);229 if (pref->compact_mode) toggleCompactMode(true); 221 230 changeStayOnTop(pref->stay_on_top); 222 231 … … 342 351 this, SLOT(openDVDFromFolder()) ); 343 352 353 // Bluray section. 354 #ifdef BLURAY_SUPPORT 355 openBluRayAct = new MyAction( this, "open_bluray" ); 356 connect( openBluRayAct, SIGNAL(triggered()), 357 this, SLOT(openBluRay())); 358 359 openBluRayFolderAct = new MyAction( this, "open_bluray_folder" ); 360 connect( openBluRayFolderAct, SIGNAL(triggered()), 361 this, SLOT(openBluRayFromFolder())); 362 #endif 363 344 364 openURLAct = new MyAction( QKeySequence("Ctrl+U"), this, "open_url" ); 345 365 connect( openURLAct, SIGNAL(triggered()), … … 405 425 406 426 playOrPauseAct = new MyAction( Qt::Key_MediaPlay, this, "play_or_pause" ); 427 playOrPauseAct->addShortcut(QKeySequence("Toggle Media Play/Pause")); // MCE remote key 407 428 connect( playOrPauseAct, SIGNAL(triggered()), 408 429 core, SLOT(play_or_pause()) ); 409 430 410 431 pauseAct = new MyAction( Qt::Key_Space, this, "pause" ); 432 pauseAct->addShortcut(QKeySequence("Media Pause")); // MCE remote key 411 433 connect( pauseAct, SIGNAL(triggered()), 412 434 core, SLOT(pause()) ); … … 425 447 426 448 rewind1Act = new MyAction( Qt::Key_Left, this, "rewind1" ); 449 rewind1Act->addShortcut(QKeySequence("Shift+Ctrl+B")); // MCE remote key 427 450 connect( rewind1Act, SIGNAL(triggered()), 428 451 core, SLOT(srewind()) ); … … 437 460 438 461 forward1Act = new MyAction( Qt::Key_Right, this, "forward1" ); 462 forward1Act->addShortcut(QKeySequence("Shift+Ctrl+F")); // MCE remote key 439 463 connect( forward1Act, SIGNAL(triggered()), 440 464 core, SLOT(sforward()) ); … … 509 533 // Menu Video 510 534 fullscreenAct = new MyAction( Qt::Key_F, this, "fullscreen" ); 535 fullscreenAct->addShortcut(QKeySequence("Ctrl+T")); // MCE remote key 511 536 fullscreenAct->setCheckable( true ); 512 537 connect( fullscreenAct, SIGNAL(toggled(bool)), … … 600 625 601 626 muteAct = new MyAction( Qt::Key_M, this, "mute" ); 627 muteAct->addShortcut(Qt::Key_VolumeMute); // MCE remote key 602 628 muteAct->setCheckable( true ); 603 629 connect( muteAct, SIGNAL(toggled(bool)), … … 607 633 decVolumeAct = new MyAction( this, "decrease_volume" ); 608 634 decVolumeAct->setShortcuts( ActionsEditor::stringToShortcuts("9,/") ); 635 decVolumeAct->addShortcut(Qt::Key_VolumeDown); // MCE remote key 609 636 #else 610 637 decVolumeAct = new MyAction( Qt::Key_9, this, "dec_volume" ); … … 616 643 incVolumeAct = new MyAction( this, "increase_volume" ); 617 644 incVolumeAct->setShortcuts( ActionsEditor::stringToShortcuts("0,*") ); 645 incVolumeAct->addShortcut(Qt::Key_VolumeUp); // MCE remote key 618 646 #else 619 647 incVolumeAct = new MyAction( Qt::Key_0, this, "inc_volume" ); … … 792 820 #endif 793 821 794 aboutQtAct = new MyAction( this, "about_qt" );795 connect( aboutQtAct, SIGNAL(triggered()),796 this, SLOT(helpAboutQt()) );797 798 822 aboutThisAct = new MyAction( this, "about_smplayer" ); 799 823 connect( aboutThisAct, SIGNAL(triggered()), 800 824 this, SLOT(helpAbout()) ); 801 825 826 #ifdef SHARE_MENU 802 827 facebookAct = new MyAction (this, "facebook"); 803 828 twitterAct = new MyAction (this, "twitter"); … … 816 841 connect( yahooAct, SIGNAL(triggered()), 817 842 this, SLOT(shareSMPlayer()) ); 818 843 #endif 819 844 820 845 // Playlist 821 846 playNextAct = new MyAction(Qt::Key_Greater, this, "play_next"); 847 playNextAct->addShortcut(Qt::Key_MediaNext); // MCE remote key 822 848 connect( playNextAct, SIGNAL(triggered()), playlist, SLOT(playNext()) ); 823 849 824 850 playPrevAct = new MyAction(Qt::Key_Less, this, "play_prev"); 851 playPrevAct->addShortcut(Qt::Key_MediaPrevious); // MCE remote key 825 852 connect( playPrevAct, SIGNAL(triggered()), playlist, SLOT(playPrev()) ); 826 853 … … 931 958 932 959 resetVideoEqualizerAct = new MyAction( this, "reset_video_equalizer"); 933 connect( resetVideoEqualizerAct, SIGNAL(triggered()), video_equalizer 2, SLOT(reset()) );960 connect( resetVideoEqualizerAct, SIGNAL(triggered()), video_equalizer, SLOT(reset()) ); 934 961 935 962 resetAudioEqualizerAct = new MyAction( this, "reset_audio_equalizer"); … … 1035 1062 aspectDetectAct = new MyActionGroupItem(this, aspectGroup, "aspect_detect", MediaSettings::AspectAuto); 1036 1063 aspect11Act = new MyActionGroupItem(this, aspectGroup, "aspect_1:1", MediaSettings::Aspect11 ); 1064 aspect54Act = new MyActionGroupItem(this, aspectGroup, "aspect_5:4", MediaSettings::Aspect54 ); 1065 aspect43Act = new MyActionGroupItem(this, aspectGroup, "aspect_4:3", MediaSettings::Aspect43); 1066 aspect118Act = new MyActionGroupItem(this, aspectGroup, "aspect_11:8", MediaSettings::Aspect118 ); 1067 aspect1410Act = new MyActionGroupItem(this, aspectGroup, "aspect_14:10", MediaSettings::Aspect1410 ); 1037 1068 aspect32Act = new MyActionGroupItem(this, aspectGroup, "aspect_3:2", MediaSettings::Aspect32); 1038 aspect43Act = new MyActionGroupItem(this, aspectGroup, "aspect_4:3", MediaSettings::Aspect43);1039 aspect54Act = new MyActionGroupItem(this, aspectGroup, "aspect_5:4", MediaSettings::Aspect54 );1040 1069 aspect149Act = new MyActionGroupItem(this, aspectGroup, "aspect_14:9", MediaSettings::Aspect149 ); 1041 aspect1 410Act = new MyActionGroupItem(this, aspectGroup, "aspect_14:10", MediaSettings::Aspect1410 );1070 aspect1610Act = new MyActionGroupItem(this, aspectGroup, "aspect_16:10", MediaSettings::Aspect1610 ); 1042 1071 aspect169Act = new MyActionGroupItem(this, aspectGroup, "aspect_16:9", MediaSettings::Aspect169 ); 1043 aspect1610Act = new MyActionGroupItem(this, aspectGroup, "aspect_16:10", MediaSettings::Aspect1610 );1044 1072 aspect235Act = new MyActionGroupItem(this, aspectGroup, "aspect_2.35:1", MediaSettings::Aspect235 ); 1045 1073 { … … 1077 1105 screenGroup = new MyActionGroup(this); 1078 1106 screenDefaultAct = new MyActionGroupItem(this, screenGroup, "screen_default", -1); 1079 #ifdef Q_OS_WIN1107 #ifdef Q_OS_WIN 1080 1108 DeviceList display_devices = DeviceInfo::displayDevices(); 1081 1109 if (!display_devices.isEmpty()) { … … 1083 1111 int id = display_devices[n].ID().toInt(); 1084 1112 QString desc = display_devices[n].desc(); 1085 MyAction * screen_item = new MyActionGroupItem(this, screenGroup, QString("screen_%1").arg(n).to Ascii().constData(), id);1113 MyAction * screen_item = new MyActionGroupItem(this, screenGroup, QString("screen_%1").arg(n).toLatin1().constData(), id); 1086 1114 screen_item->change( "&"+QString::number(n) + " - " + desc); 1087 1115 } 1088 1116 } 1089 1117 else 1090 #endif // Q_OS_WIN1118 #endif // Q_OS_WIN 1091 1119 for (int n = 1; n <= 4; n++) { 1092 MyAction * screen_item = new MyActionGroupItem(this, screenGroup, QString("screen_%1").arg(n).to Ascii().constData(), n);1120 MyAction * screen_item = new MyActionGroupItem(this, screenGroup, QString("screen_%1").arg(n).toLatin1().constData(), n); 1093 1121 screen_item->change( "&"+QString::number(n) ); 1094 1122 } … … 1465 1493 openDVDAct->change( Images::icon("dvd"), tr("&DVD from drive") ); 1466 1494 openDVDFolderAct->change( Images::icon("dvd_hd"), tr("D&VD from folder...") ); 1495 #ifdef BLURAY_SUPPORT 1496 openBluRayAct->change( Images::icon("bluray"), tr("&Blu-ray from drive") ); 1497 openBluRayFolderAct->change( Images::icon("bluray_hd"), tr("Blu-&ray from folder...") ); 1498 #endif 1467 1499 openURLAct->change( Images::icon("url"), tr("&URL...") ); 1468 1500 exitAct->change( Images::icon("close"), tr("C&lose") ); … … 1513 1545 // Submenu speed 1514 1546 normalSpeedAct->change( tr("&Normal speed") ); 1515 halveSpeedAct->change( tr("&Hal vespeed") );1547 halveSpeedAct->change( tr("&Half speed") ); 1516 1548 doubleSpeedAct->change( tr("&Double speed") ); 1517 1549 decSpeed10Act->change( tr("Speed &-10%") ); … … 1529 1561 screenshotsAct->change( Images::icon("screenshots"), tr("Start/stop takin&g screenshots") ); 1530 1562 #ifdef VIDEOPREVIEW 1531 videoPreviewAct->change( Images::icon("video_preview"), tr(" Pre&view...") );1563 videoPreviewAct->change( Images::icon("video_preview"), tr("Thumb&nail Generator...") ); 1532 1564 #endif 1533 1565 flipAct->change( Images::icon("flip"), tr("Fli&p image") ); … … 1598 1630 1599 1631 #ifdef FIND_SUBTITLES 1600 showFindSubtitlesDialogAct->change( Images::icon("download_subs"), tr("Find subtitles on&OpenSubtitles.org...") );1632 showFindSubtitlesDialogAct->change( Images::icon("download_subs"), tr("Find subtitles at &OpenSubtitles.org...") ); 1601 1633 openUploadSubtitlesPageAct->change( Images::icon("upload_subs"), tr("Upload su&btitles to OpenSubtitles.org...") ); 1602 1634 #endif … … 1646 1678 donateAct->change( Images::icon("donate"), tr("&Donate") ); 1647 1679 #endif 1648 aboutQtAct->change( QPixmap(":/icons-png/qt.png"), tr("About &Qt") );1649 1680 aboutThisAct->change( Images::icon("logo_small"), tr("About &SMPlayer") ); 1650 1681 1682 #ifdef SHARE_MENU 1651 1683 facebookAct->change("&Facebook"); 1652 1684 twitterAct->change("&Twitter"); … … 1654 1686 hotmailAct->change("&Hotmail"); 1655 1687 yahooAct->change("&Yahoo!"); 1656 1688 #endif 1657 1689 1658 1690 // Playlist … … 1797 1829 aspect32Act->change( "&3:2" ); 1798 1830 aspect43Act->change( "&4:3" ); 1831 aspect118Act->change( "11:&8" ); 1799 1832 aspect54Act->change( "&5:4" ); 1800 1833 aspect149Act->change( "&14:9" ); … … 1902 1935 osd_menu->menuAction()->setIcon( Images::icon("osd") ); 1903 1936 1937 #ifdef SHARE_MENU 1904 1938 share_menu->menuAction()->setText( tr("S&hare SMPlayer with your friends") ); 1905 1939 share_menu->menuAction()->setIcon( Images::icon("share") ); 1940 #endif 1906 1941 1907 1942 #if defined(LOG_MPLAYER) || defined(LOG_SMPLAYER) … … 1997 2032 connect( core, SIGNAL(mediaLoaded()), 1998 2033 this, SLOT(enableActionsOnPlaying()) ); 2034 2035 connect( core, SIGNAL(noFileToPlay()), this, SLOT(gotNoFileToPlay()) ); 2036 1999 2037 #if NOTIFY_AUDIO_CHANGES 2000 2038 connect( core, SIGNAL(audioTracksChanged()), … … 2055 2093 this, SLOT(YTNoSignature(const QString &))); 2056 2094 #endif 2095 connect(core, SIGNAL(receivedForbidden()), this, SLOT(gotForbidden())); 2057 2096 } 2058 2097 … … 2064 2103 #endif 2065 2104 mplayerwindow->allowVideoMovement( pref->allow_video_movement ); 2105 mplayerwindow->delayLeftClick(pref->delay_left_click); 2066 2106 2067 2107 #if LOGO_ANIMATION … … 2094 2134 connect( mplayerwindow, SIGNAL(xbutton2Clicked()), 2095 2135 this, SLOT(xbutton2ClickFunction()) ); 2096 connect( mplayerwindow, SIGNAL(mouseMoved(QPoint)), 2097 this, SLOT(checkMousePos(QPoint)) ); 2098 2099 if (pref->move_when_dragging) { 2100 connect( mplayerwindow, SIGNAL(mouseMovedDiff(QPoint)), 2101 this, SLOT(moveWindow(QPoint))); 2102 } 2136 2137 connect( mplayerwindow, SIGNAL(mouseMovedDiff(QPoint)), 2138 this, SLOT(moveWindowDiff(QPoint)), Qt::QueuedConnection ); 2139 mplayerwindow->activateMouseDragTracking(pref->move_when_dragging); 2103 2140 } 2104 2141 2105 2142 void BaseGui::createVideoEqualizer() { 2106 2143 // Equalizer 2107 video_equalizer 2 = new VideoEqualizer2(this);2108 connect( video_equalizer 2, SIGNAL(contrastChanged(int)),2144 video_equalizer = new VideoEqualizer(this); 2145 connect( video_equalizer, SIGNAL(contrastChanged(int)), 2109 2146 core, SLOT(setContrast(int)) ); 2110 connect( video_equalizer 2, SIGNAL(brightnessChanged(int)),2147 connect( video_equalizer, SIGNAL(brightnessChanged(int)), 2111 2148 core, SLOT(setBrightness(int)) ); 2112 connect( video_equalizer 2, SIGNAL(hueChanged(int)),2149 connect( video_equalizer, SIGNAL(hueChanged(int)), 2113 2150 core, SLOT(setHue(int)) ); 2114 connect( video_equalizer 2, SIGNAL(saturationChanged(int)),2151 connect( video_equalizer, SIGNAL(saturationChanged(int)), 2115 2152 core, SLOT(setSaturation(int)) ); 2116 connect( video_equalizer 2, SIGNAL(gammaChanged(int)),2153 connect( video_equalizer, SIGNAL(gammaChanged(int)), 2117 2154 core, SLOT(setGamma(int)) ); 2118 2155 2119 connect( video_equalizer 2, SIGNAL(visibilityChanged()),2156 connect( video_equalizer, SIGNAL(visibilityChanged()), 2120 2157 this, SLOT(updateWidgets()) ); 2121 connect( video_equalizer 2, SIGNAL(requestToChangeDefaultValues()),2158 connect( video_equalizer, SIGNAL(requestToChangeDefaultValues()), 2122 2159 this, SLOT(setDefaultValuesFromVideoEqualizer()) ); 2123 connect( video_equalizer 2, SIGNAL(bySoftwareChanged(bool)),2160 connect( video_equalizer, SIGNAL(bySoftwareChanged(bool)), 2124 2161 this, SLOT(changeVideoEqualizerBySoftware(bool)) ); 2125 2162 } … … 2189 2226 2190 2227 // panel 2191 panel->setAutoFillBackground(TRUE); 2228 /* 2229 panel->setAutoFillBackground(true); 2192 2230 ColorUtils::setBackgroundColor( panel, QColor(0,0,0) ); 2231 */ 2193 2232 } 2194 2233 … … 2242 2281 disc_menu->addAction(openDVDAct); 2243 2282 disc_menu->addAction(openDVDFolderAct); 2283 #ifdef BLURAY_SUPPORT 2284 disc_menu->addAction(openBluRayAct); 2285 disc_menu->addAction(openBluRayFolderAct); 2286 #endif 2244 2287 disc_menu->addAction(openVCDAct); 2245 2288 disc_menu->addAction(openAudioCDAct); … … 2613 2656 // HELP MENU 2614 2657 // Share submenu 2658 #ifdef SHARE_MENU 2615 2659 share_menu = new QMenu(this); 2616 2660 share_menu->addAction(facebookAct); … … 2622 2666 helpMenu->addMenu(share_menu); 2623 2667 helpMenu->addSeparator(); 2668 #endif 2669 2624 2670 helpMenu->addAction(showFirstStepsAct); 2625 2671 helpMenu->addAction(showFAQAct); … … 2637 2683 helpMenu->addSeparator(); 2638 2684 #endif 2639 helpMenu->addAction(aboutQtAct);2640 2685 helpMenu->addAction(aboutThisAct); 2641 2686 … … 2703 2748 2704 2749 void BaseGui::showVideoEqualizer() { 2705 showVideoEqualizer( !video_equalizer 2->isVisible() );2750 showVideoEqualizer( !video_equalizer->isVisible() ); 2706 2751 } 2707 2752 2708 2753 void BaseGui::showVideoEqualizer(bool b) { 2709 2754 if (!b) { 2710 video_equalizer 2->hide();2755 video_equalizer->hide(); 2711 2756 } else { 2712 2757 // Exit fullscreen, otherwise dialog is not visible 2713 2758 exitFullscreenIfNeeded(); 2714 video_equalizer 2->show();2759 video_equalizer->show(); 2715 2760 } 2716 2761 updateWidgets(); … … 2767 2812 pref_dialog->getData(pref); 2768 2813 2814 // Change application font 2769 2815 if (!pref->default_font.isEmpty()) { 2770 2816 QFont f; 2771 2817 f.fromString( pref->default_font ); 2772 qApp->setFont(f); 2818 if (QApplication::font() != f) { 2819 qDebug("BaseGui::applyNewPreferences: setting new font: %s", pref->default_font.toLatin1().constData()); 2820 QApplication::setFont(f); 2821 } 2773 2822 } 2774 2823 … … 2794 2843 } 2795 2844 2796 if (pref->move_when_dragging) { 2797 connect( mplayerwindow, SIGNAL(mouseMovedDiff(QPoint)), this, SLOT(moveWindow(QPoint))); 2798 } else { 2799 disconnect( mplayerwindow, SIGNAL(mouseMovedDiff(QPoint)), this, SLOT(moveWindow(QPoint))); 2800 } 2845 mplayerwindow->activateMouseDragTracking(pref->move_when_dragging); 2846 mplayerwindow->delayLeftClick(pref->delay_left_click); 2801 2847 2802 2848 #if ALLOW_TO_HIDE_VIDEO_WINDOW_ON_AUDIO_FILES … … 2828 2874 mplayerwindow->setMonitorAspect( pref->monitor_aspect_double() ); 2829 2875 } 2876 if (advanced->lavfDemuxerChanged()) { 2877 core->mset.forced_demuxer = pref->use_lavf_demuxer ? "lavf" : ""; 2878 } 2830 2879 2831 2880 // Update playlist preferences … … 2934 2983 #undef TEST_AND_SET 2935 2984 #define TEST_AND_SET( Pref, Dialog ) \ 2936 if ( Pref != Dialog ) { Pref = Dialog; need_restart = TRUE; }2985 if ( Pref != Dialog ) { Pref = Dialog; need_restart = true; } 2937 2986 2938 2987 QString prev_demuxer = core->mset.forced_demuxer; … … 3030 3079 }*/ 3031 3080 3032 if ((core->mdat.type == TYPE_FILE) && (pref->auto_add_to_playlist) && (pref->add_to_playlist_consecutive_files)) { 3033 // Look for consecutive files 3034 QStringList files_to_add = Helper::searchForConsecutiveFiles(core->mdat.filename); 3081 // Automatically add files to playlist 3082 if ((core->mdat.type == TYPE_FILE) && (pref->auto_add_to_playlist)) { 3083 //qDebug("BaseGui::newMediaLoaded: playlist count: %d", playlist->count()); 3084 QStringList files_to_add; 3085 if (playlist->count() == 1) { 3086 files_to_add = Helper::filesForPlaylist(core->mdat.filename, pref->media_to_add_to_playlist); 3087 } 3035 3088 if (!files_to_add.empty()) playlist->addFiles(files_to_add); 3036 3089 } 3090 } 3091 3092 void BaseGui::gotNoFileToPlay() { 3093 //qDebug("BaseGui::gotNoFileToPlay"); 3094 playlist->resumePlay(); 3037 3095 } 3038 3096 … … 3422 3480 3423 3481 // Video equalizer 3424 videoEqualizerAct->setChecked( video_equalizer 2->isVisible() );3425 video_equalizer 2->setBySoftware( pref->use_soft_video_eq );3482 videoEqualizerAct->setChecked( video_equalizer->isVisible() ); 3483 video_equalizer->setBySoftware( pref->use_soft_video_eq ); 3426 3484 3427 3485 // Audio equalizer … … 3477 3535 void BaseGui::updateVideoEqualizer() { 3478 3536 // Equalizer 3479 video_equalizer 2->setContrast( core->mset.contrast );3480 video_equalizer 2->setBrightness( core->mset.brightness );3481 video_equalizer 2->setHue( core->mset.hue );3482 video_equalizer 2->setSaturation( core->mset.saturation );3483 video_equalizer 2->setGamma( core->mset.gamma );3537 video_equalizer->setContrast( core->mset.contrast ); 3538 video_equalizer->setBrightness( core->mset.brightness ); 3539 video_equalizer->setHue( core->mset.hue ); 3540 video_equalizer->setSaturation( core->mset.saturation ); 3541 video_equalizer->setGamma( core->mset.gamma ); 3484 3542 } 3485 3543 3486 3544 void BaseGui::updateAudioEqualizer() { 3487 3545 // Audio Equalizer 3488 for (int n = 0; n < 10; n++) { 3489 audio_equalizer->eq[n]->setValue( core->mset.audio_equalizer[n].toInt() ); 3490 } 3546 AudioEqualizerList l = pref->global_audio_equalizer ? pref->audio_equalizer : core->mset.audio_equalizer; 3547 audio_equalizer->setEqualizer(l); 3491 3548 } 3492 3549 … … 3494 3551 qDebug("BaseGui::setDefaultValuesFromVideoEqualizer"); 3495 3552 3496 pref->initial_contrast = video_equalizer 2->contrast();3497 pref->initial_brightness = video_equalizer 2->brightness();3498 pref->initial_hue = video_equalizer 2->hue();3499 pref->initial_saturation = video_equalizer 2->saturation();3500 pref->initial_gamma = video_equalizer 2->gamma();3553 pref->initial_contrast = video_equalizer->contrast(); 3554 pref->initial_brightness = video_equalizer->brightness(); 3555 pref->initial_hue = video_equalizer->hue(); 3556 pref->initial_saturation = video_equalizer->saturation(); 3557 pref->initial_gamma = video_equalizer->gamma(); 3501 3558 3502 3559 QMessageBox::information(this, tr("Information"), … … 3586 3643 qDebug("BaseGui::openFiles"); 3587 3644 if (files.empty()) return; 3645 3646 #ifdef Q_OS_WIN 3647 files = Helper::resolveSymlinks(files); // Check for Windows shortcuts 3648 #endif 3588 3649 3589 3650 if (files.count()==1) { … … 3813 3874 } 3814 3875 3876 #ifdef BLURAY_SUPPORT 3877 /** 3878 * Minimal BaseGui abstraction for calling openBluRay. It's called from 3879 * OpenBluRayFromFolder() 3880 */ 3881 void BaseGui::openBluRayFromFolder(QString directory) { 3882 pref->last_dvd_directory = directory; 3883 core->openBluRay( DiscName::join(DiscName::BLURAY, 1, directory) ); 3884 } 3885 3886 /** 3887 * Attempts to open a bluray from pref->bluray_device. If not set, calls configureDiscDevices. 3888 * If successful, calls Core::OpenBluRay(QString) 3889 */ 3890 void BaseGui::openBluRay() { 3891 qDebug("BaseGui::openBluRay"); 3892 3893 if ( (pref->dvd_device.isEmpty()) || 3894 (pref->cdrom_device.isEmpty()) || pref->bluray_device.isEmpty()) 3895 { 3896 configureDiscDevices(); 3897 } else { 3898 core->openBluRay( DiscName::join(DiscName::BLURAY, 1, pref->bluray_device) ); 3899 } 3900 } 3901 3902 void BaseGui::openBluRayFromFolder() { 3903 qDebug("BaseGui::openBluRayFromFolder"); 3904 3905 if (playlist->maybeSave()) { 3906 QString dir = QFileDialog::getExistingDirectory(this, tr("Select the Blu-ray folder"), 3907 pref->last_dvd_directory, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); 3908 if (!dir.isEmpty()) { 3909 openBluRayFromFolder(dir); 3910 } 3911 } 3912 } 3913 #endif 3914 3815 3915 void BaseGui::openDirectory() { 3816 3916 qDebug("BaseGui::openDirectory"); … … 3911 4011 #ifdef REMINDER_ACTIONS 3912 4012 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 4013 ShareDialog d(this); 4014 d.showRemindCheck(false); 4015 d.exec(); 4016 int action = d.actions(); 4017 qDebug("BaseGui::helpDonate: action: %d", action); 4018 4019 if (action > 0) { 3922 4020 QSettings * set = Global::settings; 3923 4021 set->beginGroup("reminder"); 3924 set->setValue("action", 1);4022 set->setValue("action", action); 3925 4023 set->endGroup(); 3926 4024 } … … 3933 4031 } 3934 4032 3935 void BaseGui::helpAboutQt() { 3936 QMessageBox::aboutQt(this, tr("About Qt") ); 3937 } 3938 4033 #ifdef SHARE_MENU 3939 4034 void BaseGui::shareSMPlayer() { 3940 4035 QString text = QString("SMPlayer - Free Media Player with built-in codecs that can play and download Youtube videos").replace(" ","+"); … … 3968 4063 } 3969 4064 } 4065 #endif 3970 4066 3971 4067 void BaseGui::showGotoDialog() { … … 3982 4078 void BaseGui::showAudioDelayDialog() { 3983 4079 bool ok; 4080 #if QT_VERSION >= 0x050000 4081 int delay = QInputDialog::getInt(this, tr("SMPlayer - Audio delay"), 4082 tr("Audio delay (in milliseconds):"), core->mset.audio_delay, 4083 -3600000, 3600000, 1, &ok); 4084 #else 3984 4085 int delay = QInputDialog::getInteger(this, tr("SMPlayer - Audio delay"), 3985 4086 tr("Audio delay (in milliseconds):"), core->mset.audio_delay, 3986 4087 -3600000, 3600000, 1, &ok); 4088 #endif 3987 4089 if (ok) { 3988 4090 core->setAudioDelay(delay); … … 3992 4094 void BaseGui::showSubDelayDialog() { 3993 4095 bool ok; 4096 #if QT_VERSION >= 0x050000 4097 int delay = QInputDialog::getInt(this, tr("SMPlayer - Subtitle delay"), 4098 tr("Subtitle delay (in milliseconds):"), core->mset.sub_delay, 4099 -3600000, 3600000, 1, &ok); 4100 #else 3994 4101 int delay = QInputDialog::getInteger(this, tr("SMPlayer - Subtitle delay"), 3995 4102 tr("Subtitle delay (in milliseconds):"), core->mset.sub_delay, 3996 4103 -3600000, 3600000, 1, &ok); 4104 #endif 3997 4105 if (ok) { 3998 4106 core->setSubDelay(delay); … … 4326 4434 set->setValue("count", count); 4327 4435 int action = set->value("action", 0).toInt(); 4436 bool dont_show = set->value("dont_show_anymore", false).toBool(); 4328 4437 set->endGroup(); 4438 4439 #if 1 4440 if (dont_show) return; 4329 4441 4330 4442 if (action != 0) return; 4331 4443 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) { 4444 #endif 4445 4446 ShareDialog d(this); 4447 //d.showRemindCheck(false); 4448 d.exec(); 4449 action = d.actions(); 4450 qDebug("BaseGui::checkReminder: action: %d", action); 4451 4452 if (!d.isRemindChecked()) { 4453 set->beginGroup("reminder"); 4454 set->setValue("dont_show_anymore", true); 4455 set->endGroup(); 4359 4456 } 4360 4457 … … 4364 4461 set->endGroup(); 4365 4462 } 4463 4464 //qDebug() << "size:" << d.size(); 4366 4465 } 4367 4466 #endif … … 4372 4471 4373 4472 QString t = title; 4374 t.replace(" - YouTube", ""); 4473 4474 QString info_text; 4475 if (title.isEmpty()) { 4476 info_text = tr("Unfortunately due to changes in the Youtube page, this video can't be played."); 4477 } else { 4478 t.replace(" - YouTube", ""); 4479 info_text = tr("Unfortunately due to changes in the Youtube page, the video '%1' can't be played.").arg(t); 4480 } 4375 4481 4376 4482 #ifdef YT_USE_SCRIPT 4377 4483 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>" +4484 info_text + "<br><br>" + 4379 4485 tr("Do you want to update the Youtube code? This may fix the problem."), 4380 4486 QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); … … 4384 4490 #else 4385 4491 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>" +4492 info_text + "<br><br>" + 4387 4493 tr("Maybe updating SMPlayer could fix the problem.")); 4388 4494 #endif … … 4393 4499 static CodeDownloader * downloader = 0; 4394 4500 if (!downloader) downloader = new CodeDownloader(this); 4395 downloader->saveAs(Paths::configPath() + "/yt code.script");4501 downloader->saveAs(Paths::configPath() + "/yt.js"); 4396 4502 downloader->show(); 4397 downloader->download(QUrl("http://updates.smplayer.info/yt code.script"));4503 downloader->download(QUrl("http://updates.smplayer.info/yt.js")); 4398 4504 } 4399 4505 #endif // YT_USE_SCRIPT 4400 4506 #endif //YOUTUBE_SUPPORT 4507 4508 void BaseGui::gotForbidden() { 4509 qDebug("BaseGui::gotForbidden"); 4510 static bool busy = false; 4511 4512 if (busy) return; 4513 4514 busy = true; 4515 #ifdef YOUTUBE_SUPPORT 4516 if (core->mdat.filename.contains("youtube.com")) { 4517 YTNoSignature(""); 4518 } else 4519 #endif 4520 { 4521 QMessageBox::warning(this, tr("Error detected"), 4522 tr("Unfortunately this video can't be played.") +"<br>"+ 4523 tr("The server returned '%1'").arg("403: Forbidden")); 4524 } 4525 busy = false; 4526 } 4401 4527 4402 4528 void BaseGui::dragEnterEvent( QDragEnterEvent *e ) { … … 4438 4564 qDebug( "BaseGui::dropEvent: count: %d", files.count()); 4439 4565 if (files.count() > 0) { 4566 #ifdef Q_OS_WIN 4567 files = Helper::resolveSymlinks(files); // Check for Windows shortcuts 4568 #endif 4569 4440 4570 if (files.count() == 1) { 4441 4571 QFileInfo fi( files[0] ); … … 4514 4644 */ 4515 4645 4646 /* 4516 4647 void BaseGui::wheelEvent( QWheelEvent * e ) { 4517 4648 qDebug("BaseGui::wheelEvent: delta: %d", e->delta()); … … 4527 4658 } 4528 4659 } 4529 4660 */ 4530 4661 4531 4662 // Called when a video has started to play … … 4535 4666 if (arg_start_in_fullscreen != 0) { 4536 4667 if ( (arg_start_in_fullscreen == 1) || (pref->start_in_fullscreen) ) { 4537 if (!pref->fullscreen) toggleFullscreen( TRUE);4668 if (!pref->fullscreen) toggleFullscreen(true); 4538 4669 } 4539 4670 } … … 4543 4674 void BaseGui::exitFullscreenOnStop() { 4544 4675 if (pref->fullscreen) { 4545 toggleFullscreen( FALSE);4676 toggleFullscreen(false); 4546 4677 } 4547 4678 } … … 4825 4956 /* 4826 4957 if (pref->fullscreen) { 4827 toggleFullscreen( FALSE);4958 toggleFullscreen(false); 4828 4959 } 4829 4960 */ 4830 }4831 4832 void BaseGui::checkMousePos(QPoint p) {4833 //qDebug("BaseGui::checkMousePos: %d, %d", p.x(), p.y());4834 4835 bool compact = (pref->floating_display_in_compact_mode && pref->compact_mode);4836 4837 if (!pref->fullscreen && !compact) return;4838 4839 #define MARGIN 704840 4841 int margin = MARGIN + pref->floating_control_margin;4842 4843 if (p.y() > mplayerwindow->height() - margin) {4844 //qDebug("BaseGui::checkMousePos: %d, %d", p.x(), p.y());4845 if (!near_bottom) {4846 emit cursorNearBottom(p);4847 near_bottom = true;4848 }4849 } else {4850 if (near_bottom) {4851 emit cursorFarEdges();4852 near_bottom = false;4853 }4854 }4855 4856 if (p.y() < margin) {4857 //qDebug("BaseGui::checkMousePos: %d, %d", p.x(), p.y());4858 if (!near_top) {4859 emit cursorNearTop(p);4860 near_top = true;4861 }4862 } else {4863 if (near_top) {4864 emit cursorFarEdges();4865 near_top = false;4866 }4867 }4868 4961 } 4869 4962 … … 4926 5019 } 4927 5020 4928 void BaseGui::moveWindow (QPoint diff) {5021 void BaseGui::moveWindowDiff(QPoint diff) { 4929 5022 if (pref->fullscreen || isMaximized()) { 4930 5023 return; 4931 5024 } 5025 5026 #if QT_VERSION >= 0x050000 5027 // Move the window with some delay. 5028 // Seems to work better with Qt 5 5029 5030 static QPoint d; 5031 static int count = 0; 5032 5033 d += diff; 5034 count++; 5035 5036 if (count > 3) { 5037 //qDebug() << "BaseGui::moveWindowDiff:" << d; 5038 QPoint new_pos = pos() + d; 5039 if (new_pos.y() < 0) new_pos.setY(0); 5040 if (new_pos.x() < 0) new_pos.setX(0); 5041 //qDebug() << "BaseGui::moveWindowDiff: new_pos:" << new_pos; 5042 move(new_pos); 5043 count = 0; 5044 d = QPoint(0,0); 5045 } 5046 #else 5047 //qDebug() << "BaseGui::moveWindowDiff:" << diff; 4932 5048 move(pos() + diff); 5049 #endif 4933 5050 } 4934 5051 … … 5036 5153 5037 5154 void BaseGui::openUploadSubtitlesPage() { 5038 //QDesktopServices::openUrl( QUrl("http://ds6.ovh.org/hashsubtitles/upload.php") ); 5039 //QDesktopServices::openUrl( QUrl("http://www.opensubtitles.com/upload") ); 5040 QDesktopServices::openUrl( QUrl("http://www.opensubtitles.org/uploadjava") ); 5155 QDesktopServices::openUrl( QUrl("http://www.opensubtitles.org/upload") ); 5041 5156 } 5042 5157 #endif … … 5102 5217 5103 5218 #ifdef Q_OS_WIN 5219 #ifdef AVOID_SCREENSAVER 5104 5220 /* Disable screensaver by event */ 5105 5221 bool BaseGui::winEvent ( MSG * m, long * result ) { … … 5131 5247 } 5132 5248 #endif 5249 #endif 5133 5250 5134 5251 #if defined(Q_OS_WIN) || defined(Q_OS_OS2)
Note:
See TracChangeset
for help on using the changeset viewer.