source: smplayer/vendor/0.8.2/src/basegui.h

Last change on this file was 137, checked in by Silvan Scherrer, 13 years ago

SMPlayer: updated vendor to 0.8.2

File size: 17.8 KB
Line 
1/* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2012 Ricardo Villalba <rvm@users.sourceforge.net>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/
18
19#ifndef _BASEGUI_H_
20#define _BASEGUI_H_
21
22#include <QMainWindow>
23#include <QNetworkProxy>
24#include "mediadata.h"
25#include "mediasettings.h"
26#include "preferences.h"
27#include "core.h"
28#include "config.h"
29#include "guiconfig.h"
30
31#ifdef Q_OS_WIN
32/* Disable screensaver by event */
33#include <windows.h>
34#endif
35
36class QWidget;
37class QMenu;
38class LogWindow;
39class MplayerWindow;
40
41class QLabel;
42class FilePropertiesDialog;
43class VideoEqualizer;
44class AudioEqualizer;
45class Playlist;
46#ifdef FIND_SUBTITLES
47class FindSubtitlesWindow;
48#endif
49
50#ifdef VIDEOPREVIEW
51class VideoPreview;
52#endif
53
54
55class MyAction;
56class MyActionGroup;
57
58class PreferencesDialog;
59
60class Favorites;
61class TVList;
62
63class BaseGui : public QMainWindow
64{
65 Q_OBJECT
66
67public:
68 BaseGui( QWidget* parent = 0, Qt::WindowFlags flags = 0 );
69 ~BaseGui();
70
71 /* Return true if the window shouldn't show on startup */
72 virtual bool startHidden() { return false; };
73
74 //! Execute all actions in \a actions. The actions should be
75 //! separated by spaces. Checkable actions could have a parameter:
76 //! true or false.
77 void runActions(QString actions);
78
79 //! Execute all the actions after the video has started to play
80 void runActionsLater(QString actions) { pending_actions_to_run = actions; };
81
82#ifdef LOG_SMPLAYER
83 //! Saves the line from the smplayer output
84 void recordSmplayerLog(QString line);
85#endif
86
87public slots:
88 virtual void open(QString file); // Generic open, autodetect type.
89 virtual void openFile();
90 virtual void openFile(QString file);
91 virtual void openFiles(QStringList files);
92 virtual void openFavorite(QString file);
93 virtual void openURL();
94 virtual void openURL(QString url);
95 virtual void openVCD();
96 virtual void openAudioCD();
97 virtual void openDVD();
98 virtual void openDVDFromFolder();
99 virtual void openDVDFromFolder(QString directory);
100 virtual void openDirectory();
101 virtual void openDirectory(QString directory);
102
103 virtual void helpFAQ();
104 virtual void helpCLOptions();
105 virtual void helpCheckUpdates();
106 virtual void helpShowConfig();
107 virtual void helpAbout();
108 virtual void helpAboutQt();
109
110 virtual void loadSub();
111 virtual void loadAudioFile(); // Load external audio file
112
113 void setInitialSubtitle(const QString & subtitle_file);
114
115#ifdef FIND_SUBTITLES
116 virtual void showFindSubtitlesDialog();
117 virtual void openUploadSubtitlesPage(); //turbos
118#endif
119
120#ifdef VIDEOPREVIEW
121 virtual void showVideoPreviewDialog();
122#endif
123
124 virtual void showTubeBrowser();
125
126 virtual void showPlaylist();
127 virtual void showPlaylist(bool b);
128 virtual void showVideoEqualizer();
129 virtual void showVideoEqualizer(bool b);
130 virtual void showAudioEqualizer();
131 virtual void showAudioEqualizer(bool b);
132#ifdef LOG_MPLAYER
133 virtual void showMplayerLog();
134#endif
135#ifdef LOG_SMPLAYER
136 virtual void showLog();
137#endif
138 virtual void showPreferencesDialog();
139 virtual void showFilePropertiesDialog();
140
141 virtual void showGotoDialog();
142 virtual void showSubDelayDialog();
143 virtual void showAudioDelayDialog();
144
145 virtual void exitFullscreen();
146 virtual void toggleFullscreen();
147 virtual void toggleFullscreen(bool);
148
149 virtual void toggleCompactMode();
150 virtual void toggleCompactMode(bool);
151
152 void setStayOnTop(bool b);
153 virtual void changeStayOnTop(int);
154 virtual void checkStayOnTop(Core::State);
155 void toggleStayOnTop();
156
157 void setForceCloseOnFinish(int n) { arg_close_on_finish = n; };
158 int forceCloseOnFinish() { return arg_close_on_finish; };
159
160 void setForceStartInFullscreen(int n) { arg_start_in_fullscreen = n; };
161 int forceStartInFullscreen() { return arg_start_in_fullscreen; };
162
163
164protected slots:
165 virtual void closeWindow();
166
167 virtual void setJumpTexts();
168
169 // Replace for setCaption (in Qt 4 it's not virtual)
170 virtual void setWindowCaption(const QString & title);
171
172 //virtual void openRecent(int item);
173 virtual void openRecent();
174 virtual void enterFullscreenOnPlay();
175 virtual void exitFullscreenOnStop();
176 virtual void exitFullscreenIfNeeded();
177 virtual void playlistHasFinished();
178
179 virtual void displayState(Core::State state);
180 virtual void displayMessage(QString message);
181 virtual void gotCurrentTime(double);
182
183 virtual void initializeMenus();
184 virtual void updateWidgets();
185 virtual void updateVideoEqualizer();
186 virtual void updateAudioEqualizer();
187
188 virtual void newMediaLoaded();
189 virtual void updateMediaInfo();
190
191 void checkPendingActionsToRun();
192
193#if REPORT_OLD_MPLAYER
194 void checkMplayerVersion();
195 void displayWarningAboutOldMplayer();
196#endif
197
198#if AUTODISABLE_ACTIONS
199 virtual void enableActionsOnPlaying();
200 virtual void disableActionsOnStop();
201 virtual void togglePlayAction(Core::State);
202#endif
203
204 virtual void resizeWindow(int w, int h);
205 virtual void hidePanel();
206
207 /* virtual void playlistVisibilityChanged(); */
208
209 virtual void displayGotoTime(int);
210 //! You can call this slot to jump to the specified percentage in the video, while dragging the slider.
211 virtual void goToPosOnDragging(int);
212
213 virtual void showPopupMenu();
214 virtual void showPopupMenu( QPoint p );
215 /*
216 virtual void mouseReleaseEvent( QMouseEvent * e );
217 virtual void mouseDoubleClickEvent( QMouseEvent * e );
218 */
219
220 virtual void leftClickFunction();
221 virtual void rightClickFunction();
222 virtual void doubleClickFunction();
223 virtual void middleClickFunction();
224 virtual void xbutton1ClickFunction();
225 virtual void xbutton2ClickFunction();
226 virtual void processFunction(QString function);
227
228 virtual void dragEnterEvent( QDragEnterEvent * ) ;
229 virtual void dropEvent ( QDropEvent * );
230
231 virtual void applyNewPreferences();
232 virtual void applyFileProperties();
233
234 virtual void clearRecentsList();
235
236 virtual void loadActions();
237 virtual void saveActions();
238
239 // Check the mouse pos in fullscreen mode, to
240 // show the controlwidget if it's moved to
241 // the bottom area.
242 virtual void checkMousePos( QPoint );
243 virtual void moveWindow(QPoint diff);
244
245 // Single instance stuff
246#ifdef SINGLE_INSTANCE
247 void handleMessageFromOtherInstances(const QString& message);
248#endif
249
250 //! Called when core can't parse the mplayer version and there's no
251 //! version supplied by the user
252 void askForMplayerVersion(QString);
253
254 void showExitCodeFromMplayer(int exit_code);
255 void showErrorFromMplayer(QProcess::ProcessError);
256
257 // stylesheet
258#if ALLOW_CHANGE_STYLESHEET
259 virtual void loadQss(QString filename);
260 virtual void changeStyleSheet(QString style);
261#endif
262
263#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
264 /* Disable screensaver by event */
265 void clear_just_stopped();
266#endif
267
268#ifdef LOG_MPLAYER
269 //! Clears the mplayer log
270 void clearMplayerLog();
271
272 //! Saves the line from the mplayer output
273 void recordMplayerLog(QString line);
274
275 //! Saves the mplayer log to a file every time a file is loaded
276 void autosaveMplayerLog();
277#endif
278
279signals:
280 void frameChanged(int);
281 void ABMarkersChanged(int secs_a, int secs_b);
282 void videoInfoChanged(int width, int height, double fps);
283 void timeChanged(QString time_ready_to_print);
284
285 void cursorNearTop(QPoint);
286 void cursorNearBottom(QPoint);
287 void cursorFarEdges();
288
289 void wheelUp();
290 void wheelDown();
291 /*
292 void doubleClicked();
293 void leftClicked();
294 void middleClicked();
295 */
296
297 //! Sent when the user wants to close the main window
298 void quitSolicited();
299
300#ifdef GUI_CHANGE_ON_RUNTIME
301 void guiChanged(QString gui);
302#endif
303
304protected:
305 virtual void retranslateStrings();
306 virtual void changeEvent(QEvent * event);
307 virtual void hideEvent( QHideEvent * );
308 virtual void showEvent( QShowEvent * );
309#ifdef Q_OS_WIN
310 /* Disable screensaver by event */
311 virtual bool winEvent ( MSG * m, long * result );
312#endif
313
314 virtual void aboutToEnterFullscreen();
315 virtual void aboutToExitFullscreen();
316 virtual void aboutToEnterCompactMode();
317 virtual void aboutToExitCompactMode();
318
319protected:
320 void createCore();
321 void createMplayerWindow();
322 void createVideoEqualizer();
323 void createAudioEqualizer();
324 void createPlaylist();
325 void createPanel();
326 void createPreferencesDialog();
327 void createFilePropertiesDialog();
328 void setDataToFileProperties();
329 void initializeGui();
330 void createActions();
331#if AUTODISABLE_ACTIONS
332 void setActionsEnabled(bool);
333#endif
334 void createMenus();
335 void updateRecents();
336 void configureDiscDevices();
337 /* virtual void closeEvent( QCloseEvent * e ); */
338
339protected:
340 virtual void wheelEvent( QWheelEvent * e ) ;
341
342protected:
343 QWidget * panel;
344
345 // Menu File
346 MyAction * openFileAct;
347 MyAction * openDirectoryAct;
348 MyAction * openPlaylistAct;
349 MyAction * openVCDAct;
350 MyAction * openAudioCDAct;
351 MyAction * openDVDAct;
352 MyAction * openDVDFolderAct;
353 MyAction * openURLAct;
354 MyAction * exitAct;
355 MyAction * clearRecentsAct;
356
357 // Menu Play
358 MyAction * playAct;
359 MyAction * playOrPauseAct;
360 MyAction * pauseAct;
361 MyAction * pauseAndStepAct;
362 MyAction * stopAct;
363 MyAction * frameStepAct;
364 MyAction * rewind1Act;
365 MyAction * rewind2Act;
366 MyAction * rewind3Act;
367 MyAction * forward1Act;
368 MyAction * forward2Act;
369 MyAction * forward3Act;
370 MyAction * repeatAct;
371 MyAction * setAMarkerAct;
372 MyAction * setBMarkerAct;
373 MyAction * clearABMarkersAct;
374 MyAction * gotoAct;
375
376 // Menu Speed
377 MyAction * normalSpeedAct;
378 MyAction * halveSpeedAct;
379 MyAction * doubleSpeedAct;
380 MyAction * decSpeed10Act;
381 MyAction * incSpeed10Act;
382 MyAction * decSpeed4Act;
383 MyAction * incSpeed4Act;
384 MyAction * decSpeed1Act;
385 MyAction * incSpeed1Act;
386
387 // Menu Video
388 MyAction * fullscreenAct;
389 MyAction * compactAct;
390 MyAction * videoEqualizerAct;
391 MyAction * screenshotAct;
392 MyAction * screenshotsAct;
393#ifdef VIDEOPREVIEW
394 MyAction * videoPreviewAct;
395#endif
396 MyAction * flipAct;
397 MyAction * mirrorAct;
398 MyAction * postProcessingAct;
399 MyAction * phaseAct;
400 MyAction * deblockAct;
401 MyAction * deringAct;
402 MyAction * gradfunAct;
403 MyAction * addNoiseAct;
404 MyAction * addLetterboxAct;
405 MyAction * upscaleAct;
406
407 // Menu Audio
408 MyAction * audioEqualizerAct;
409 MyAction * muteAct;
410 MyAction * decVolumeAct;
411 MyAction * incVolumeAct;
412 MyAction * decAudioDelayAct;
413 MyAction * incAudioDelayAct;
414 MyAction * audioDelayAct; // Ask for delay
415 MyAction * extrastereoAct;
416 MyAction * karaokeAct;
417 MyAction * volnormAct;
418 MyAction * loadAudioAct;
419 MyAction * unloadAudioAct;
420
421 // Menu Subtitles
422 MyAction * loadSubsAct;
423 MyAction * unloadSubsAct;
424 MyAction * decSubDelayAct;
425 MyAction * incSubDelayAct;
426 MyAction * subDelayAct; // Ask for delay
427 MyAction * decSubPosAct;
428 MyAction * incSubPosAct;
429 MyAction * incSubStepAct;
430 MyAction * decSubStepAct;
431 MyAction * incSubScaleAct;
432 MyAction * decSubScaleAct;
433 MyAction * useAssAct;
434 MyAction * useForcedSubsOnlyAct;
435 MyAction * subVisibilityAct;
436#ifdef FIND_SUBTITLES
437 MyAction * showFindSubtitlesDialogAct;
438 MyAction * openUploadSubtitlesPageAct;//turbos
439#endif
440
441 // Menu Options
442 MyAction * showPlaylistAct;
443 MyAction * showPropertiesAct;
444 MyAction * showPreferencesAct;
445 MyAction * showTubeBrowserAct;
446#ifdef LOG_MPLAYER
447 MyAction * showLogMplayerAct;
448#endif
449#ifdef LOG_SMPLAYER
450 MyAction * showLogSmplayerAct;
451#endif
452
453 // Menu Help
454 MyAction * showFAQAct;
455 MyAction * showCLOptionsAct; // Command line options
456 MyAction * showCheckUpdatesAct;
457 MyAction * showConfigAct;
458 MyAction * aboutQtAct;
459 MyAction * aboutThisAct;
460
461 // Playlist
462 MyAction * playPrevAct;
463 MyAction * playNextAct;
464
465 // Actions not in menus
466#if !USE_MULTIPLE_SHORTCUTS
467 MyAction * decVolume2Act;
468 MyAction * incVolume2Act;
469#endif
470 MyAction * exitFullscreenAct;
471 MyAction * nextOSDAct;
472 MyAction * decContrastAct;
473 MyAction * incContrastAct;
474 MyAction * decBrightnessAct;
475 MyAction * incBrightnessAct;
476 MyAction * decHueAct;
477 MyAction * incHueAct;
478 MyAction * decSaturationAct;
479 MyAction * incSaturationAct;
480 MyAction * decGammaAct;
481 MyAction * incGammaAct;
482 MyAction * nextVideoAct;
483 MyAction * nextAudioAct;
484 MyAction * nextSubtitleAct;
485 MyAction * nextChapterAct;
486 MyAction * prevChapterAct;
487 MyAction * doubleSizeAct;
488 MyAction * resetVideoEqualizerAct;
489 MyAction * resetAudioEqualizerAct;
490 MyAction * showContextMenuAct;
491 MyAction * nextAspectAct;
492 MyAction * nextWheelFunctionAct;
493
494 MyAction * showFilenameAct;
495 MyAction * toggleDeinterlaceAct;
496
497 // Moving and zoom
498 MyAction * moveUpAct;
499 MyAction * moveDownAct;
500 MyAction * moveLeftAct;
501 MyAction * moveRightAct;
502 MyAction * incZoomAct;
503 MyAction * decZoomAct;
504 MyAction * resetZoomAct;
505 MyAction * autoZoomAct;
506 MyAction * autoZoom169Act;
507 MyAction * autoZoom235Act;
508
509#if USE_MPLAYER_PANSCAN
510 MyAction * incPanscanAct;
511 MyAction * decPanscanAct;
512#endif
513
514 // OSD Action Group
515 MyActionGroup * osdGroup;
516 MyAction * osdNoneAct;
517 MyAction * osdSeekAct;
518 MyAction * osdTimerAct;
519 MyAction * osdTotalAct;
520
521 // Denoise Action Group
522 MyActionGroup * denoiseGroup;
523 MyAction * denoiseNoneAct;
524 MyAction * denoiseNormalAct;
525 MyAction * denoiseSoftAct;
526
527 // Blur-sharpen group
528 MyActionGroup * unsharpGroup;
529 MyAction * unsharpNoneAct;
530 MyAction * blurAct;
531 MyAction * sharpenAct;
532
533 // Window Size Action Group
534 MyActionGroup * sizeGroup;
535 MyAction * size50;
536 MyAction * size75;
537 MyAction * size100;
538 MyAction * size125;
539 MyAction * size150;
540 MyAction * size175;
541 MyAction * size200;
542 MyAction * size300;
543 MyAction * size400;
544
545 // Deinterlace Action Group
546 MyActionGroup * deinterlaceGroup;
547 MyAction * deinterlaceNoneAct;
548 MyAction * deinterlaceL5Act;
549 MyAction * deinterlaceYadif0Act;
550 MyAction * deinterlaceYadif1Act;
551 MyAction * deinterlaceLBAct;
552 MyAction * deinterlaceKernAct;
553
554 // Aspect Action Group
555 MyActionGroup * aspectGroup;
556 MyAction * aspectDetectAct;
557 MyAction * aspectNoneAct;
558 MyAction * aspect11Act; // 1:1
559 MyAction * aspect32Act; // 3:2
560 MyAction * aspect43Act; // 4:3
561 MyAction * aspect54Act; // 5:4
562 MyAction * aspect149Act; // 14:9
563 MyAction * aspect1410Act; // 14:10
564 MyAction * aspect169Act; // 16:9
565 MyAction * aspect1610Act; // 16:10
566 MyAction * aspect235Act; // 2.35:1
567
568 // Rotate Group
569 MyActionGroup * rotateGroup;
570 MyAction * rotateNoneAct;
571 MyAction * rotateClockwiseFlipAct;
572 MyAction * rotateClockwiseAct;
573 MyAction * rotateCounterclockwiseAct;
574 MyAction * rotateCounterclockwiseFlipAct;
575
576 // Menu StayOnTop
577 MyActionGroup * onTopActionGroup;
578 MyAction * onTopAlwaysAct;
579 MyAction * onTopNeverAct;
580 MyAction * onTopWhilePlayingAct;
581 MyAction * toggleStayOnTopAct;
582
583#if USE_ADAPTER
584 // Screen Group
585 MyActionGroup * screenGroup;
586 MyAction * screenDefaultAct;
587#endif
588
589 // Closed Captions Group
590 MyActionGroup * ccGroup;
591 MyAction * ccNoneAct;
592 MyAction * ccChannel1Act;
593 MyAction * ccChannel2Act;
594 MyAction * ccChannel3Act;
595 MyAction * ccChannel4Act;
596
597
598 // Audio Channels Action Group
599 MyActionGroup * channelsGroup;
600 /* MyAction * channelsDefaultAct; */
601 MyAction * channelsStereoAct;
602 MyAction * channelsSurroundAct;
603 MyAction * channelsFull51Act;
604 MyAction * channelsFull61Act;
605 MyAction * channelsFull71Act;
606
607 // Stereo Mode Action Group
608 MyActionGroup * stereoGroup;
609 MyAction * stereoAct;
610 MyAction * leftChannelAct;
611 MyAction * rightChannelAct;
612
613 // Other groups
614#if PROGRAM_SWITCH
615 MyActionGroup * programTrackGroup;
616#endif
617 MyActionGroup * videoTrackGroup;
618 MyActionGroup * audioTrackGroup;
619 MyActionGroup * subtitleTrackGroup;
620 MyActionGroup * titleGroup;
621 MyActionGroup * angleGroup;
622 MyActionGroup * chapterGroup;
623
624#if DVDNAV_SUPPORT
625 MyAction * dvdnavUpAct;
626 MyAction * dvdnavDownAct;
627 MyAction * dvdnavLeftAct;
628 MyAction * dvdnavRightAct;
629 MyAction * dvdnavMenuAct;
630 MyAction * dvdnavSelectAct;
631 MyAction * dvdnavPrevAct;
632 MyAction * dvdnavMouseAct;
633#endif
634
635 // MENUS
636 QMenu *openMenu;
637 QMenu *playMenu;
638 QMenu *videoMenu;
639 QMenu *audioMenu;
640 QMenu *subtitlesMenu;
641 QMenu *browseMenu;
642 QMenu *optionsMenu;
643 QMenu *helpMenu;
644
645 QMenu * disc_menu;
646 QMenu * subtitlestrack_menu;
647#if PROGRAM_SWITCH
648 QMenu * programtrack_menu;
649#endif
650 QMenu * videotrack_menu;
651 QMenu * audiotrack_menu;
652 QMenu * titles_menu;
653 QMenu * chapters_menu;
654 QMenu * angles_menu;
655 QMenu * aspect_menu;
656 QMenu * osd_menu;
657 QMenu * deinterlace_menu;
658 QMenu * denoise_menu;
659 QMenu * unsharp_menu;
660 QMenu * videosize_menu;
661 QMenu * audiochannels_menu;
662 QMenu * stereomode_menu;
663
664 QMenu * speed_menu;
665 QMenu * ab_menu; // A-B menu
666 QMenu * videofilter_menu;
667 QMenu * audiofilter_menu;
668#if defined(LOG_MPLAYER) || defined(LOG_SMPLAYER)
669 QMenu * logs_menu;
670#endif
671 QMenu * zoom_menu;
672 QMenu * rotate_menu;
673 QMenu * ontop_menu;
674#if USE_ADAPTER
675 QMenu * screen_menu;
676#endif
677 QMenu * closed_captions_menu;
678
679 QMenu * popup;
680 QMenu * recentfiles_menu;
681
682#ifdef LOG_MPLAYER
683 LogWindow * mplayer_log_window;
684#endif
685#ifdef LOG_SMPLAYER
686 LogWindow * smplayer_log_window;
687#endif
688 LogWindow * clhelp_window;
689
690 PreferencesDialog *pref_dialog;
691 FilePropertiesDialog *file_dialog;
692 Playlist * playlist;
693 VideoEqualizer * video_equalizer;
694 AudioEqualizer * audio_equalizer;
695#ifdef FIND_SUBTITLES
696 FindSubtitlesWindow * find_subs_dialog;
697#endif
698#ifdef VIDEOPREVIEW
699 VideoPreview * video_preview;
700#endif
701
702 Core * core;
703 MplayerWindow *mplayerwindow;
704
705 Favorites * favorites;
706
707 TVList * tvlist;
708 TVList * radiolist;
709
710 QStringList actions_list;
711
712 QString pending_actions_to_run;
713
714 // Force settings from command line
715 int arg_close_on_finish; // -1 = not set, 1 = true, 0 = false
716 int arg_start_in_fullscreen; // -1 = not set, 1 = true, 0 = false
717
718private:
719 QString default_style;
720
721 bool near_top;
722 bool near_bottom;
723
724 // Variables to restore pos and size of the window
725 // when exiting from fullscreen mode.
726 QPoint win_pos;
727 QSize win_size;
728 bool was_maximized;
729
730#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
731 /* Disable screensaver by event */
732 bool just_stopped;
733#endif
734
735#ifdef LOG_MPLAYER
736 QString mplayer_log;
737#endif
738#ifdef LOG_SMPLAYER
739 QString smplayer_log;
740#endif
741
742 bool ignore_show_hide_events;
743};
744
745#endif
746
Note: See TracBrowser for help on using the repository browser.