source: smplayer/trunk/src/basegui.h@ 133

Last change on this file since 133 was 128, checked in by Silvan Scherrer, 13 years ago

SMPlayer: trunk update to latest svn

  • Property svn:eol-style set to LF
File size: 17.7 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 helpDonate();
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
244 // Single instance stuff
245#ifdef SINGLE_INSTANCE
246 void handleMessageFromOtherInstances(const QString& message);
247#endif
248
249 //! Called when core can't parse the mplayer version and there's no
250 //! version supplied by the user
251 void askForMplayerVersion(QString);
252
253 void showExitCodeFromMplayer(int exit_code);
254 void showErrorFromMplayer(QProcess::ProcessError);
255
256 // stylesheet
257#if ALLOW_CHANGE_STYLESHEET
258 virtual void loadQss(QString filename);
259 virtual void changeStyleSheet(QString style);
260#endif
261
262#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
263 /* Disable screensaver by event */
264 void clear_just_stopped();
265#endif
266
267#ifdef LOG_MPLAYER
268 //! Clears the mplayer log
269 void clearMplayerLog();
270
271 //! Saves the line from the mplayer output
272 void recordMplayerLog(QString line);
273
274 //! Saves the mplayer log to a file every time a file is loaded
275 void autosaveMplayerLog();
276#endif
277
278signals:
279 void frameChanged(int);
280 void ABMarkersChanged(int secs_a, int secs_b);
281 void videoInfoChanged(int width, int height, double fps);
282 void timeChanged(QString time_ready_to_print);
283
284 void cursorNearTop(QPoint);
285 void cursorNearBottom(QPoint);
286 void cursorFarEdges();
287
288 void wheelUp();
289 void wheelDown();
290 /*
291 void doubleClicked();
292 void leftClicked();
293 void middleClicked();
294 */
295
296 //! Sent when the user wants to close the main window
297 void quitSolicited();
298
299#ifdef GUI_CHANGE_ON_RUNTIME
300 void guiChanged(QString gui);
301#endif
302
303protected:
304 virtual void retranslateStrings();
305 virtual void changeEvent(QEvent * event);
306 virtual void hideEvent( QHideEvent * );
307 virtual void showEvent( QShowEvent * );
308#ifdef Q_OS_WIN
309 /* Disable screensaver by event */
310 virtual bool winEvent ( MSG * m, long * result );
311#endif
312
313 virtual void aboutToEnterFullscreen();
314 virtual void aboutToExitFullscreen();
315 virtual void aboutToEnterCompactMode();
316 virtual void aboutToExitCompactMode();
317
318protected:
319 void createCore();
320 void createMplayerWindow();
321 void createVideoEqualizer();
322 void createAudioEqualizer();
323 void createPlaylist();
324 void createPanel();
325 void createPreferencesDialog();
326 void createFilePropertiesDialog();
327 void setDataToFileProperties();
328 void initializeGui();
329 void createActions();
330#if AUTODISABLE_ACTIONS
331 void setActionsEnabled(bool);
332#endif
333 void createMenus();
334 void updateRecents();
335 void configureDiscDevices();
336 /* virtual void closeEvent( QCloseEvent * e ); */
337
338protected:
339 virtual void wheelEvent( QWheelEvent * e ) ;
340
341protected:
342 QWidget * panel;
343
344 // Menu File
345 MyAction * openFileAct;
346 MyAction * openDirectoryAct;
347 MyAction * openPlaylistAct;
348 MyAction * openVCDAct;
349 MyAction * openAudioCDAct;
350 MyAction * openDVDAct;
351 MyAction * openDVDFolderAct;
352 MyAction * openURLAct;
353 MyAction * exitAct;
354 MyAction * clearRecentsAct;
355
356 // Menu Play
357 MyAction * playAct;
358 MyAction * playOrPauseAct;
359 MyAction * pauseAct;
360 MyAction * pauseAndStepAct;
361 MyAction * stopAct;
362 MyAction * frameStepAct;
363 MyAction * rewind1Act;
364 MyAction * rewind2Act;
365 MyAction * rewind3Act;
366 MyAction * forward1Act;
367 MyAction * forward2Act;
368 MyAction * forward3Act;
369 MyAction * repeatAct;
370 MyAction * setAMarkerAct;
371 MyAction * setBMarkerAct;
372 MyAction * clearABMarkersAct;
373 MyAction * gotoAct;
374
375 // Menu Speed
376 MyAction * normalSpeedAct;
377 MyAction * halveSpeedAct;
378 MyAction * doubleSpeedAct;
379 MyAction * decSpeed10Act;
380 MyAction * incSpeed10Act;
381 MyAction * decSpeed4Act;
382 MyAction * incSpeed4Act;
383 MyAction * decSpeed1Act;
384 MyAction * incSpeed1Act;
385
386 // Menu Video
387 MyAction * fullscreenAct;
388 MyAction * compactAct;
389 MyAction * videoEqualizerAct;
390 MyAction * screenshotAct;
391 MyAction * screenshotsAct;
392#ifdef VIDEOPREVIEW
393 MyAction * videoPreviewAct;
394#endif
395 MyAction * flipAct;
396 MyAction * mirrorAct;
397 MyAction * postProcessingAct;
398 MyAction * phaseAct;
399 MyAction * deblockAct;
400 MyAction * deringAct;
401 MyAction * gradfunAct;
402 MyAction * addNoiseAct;
403 MyAction * addLetterboxAct;
404 MyAction * upscaleAct;
405
406 // Menu Audio
407 MyAction * audioEqualizerAct;
408 MyAction * muteAct;
409 MyAction * decVolumeAct;
410 MyAction * incVolumeAct;
411 MyAction * decAudioDelayAct;
412 MyAction * incAudioDelayAct;
413 MyAction * audioDelayAct; // Ask for delay
414 MyAction * extrastereoAct;
415 MyAction * karaokeAct;
416 MyAction * volnormAct;
417 MyAction * loadAudioAct;
418 MyAction * unloadAudioAct;
419
420 // Menu Subtitles
421 MyAction * loadSubsAct;
422 MyAction * unloadSubsAct;
423 MyAction * decSubDelayAct;
424 MyAction * incSubDelayAct;
425 MyAction * subDelayAct; // Ask for delay
426 MyAction * decSubPosAct;
427 MyAction * incSubPosAct;
428 MyAction * incSubStepAct;
429 MyAction * decSubStepAct;
430 MyAction * incSubScaleAct;
431 MyAction * decSubScaleAct;
432 MyAction * useAssAct;
433 MyAction * useForcedSubsOnlyAct;
434 MyAction * subVisibilityAct;
435#ifdef FIND_SUBTITLES
436 MyAction * showFindSubtitlesDialogAct;
437 MyAction * openUploadSubtitlesPageAct;//turbos
438#endif
439
440 // Menu Options
441 MyAction * showPlaylistAct;
442 MyAction * showPropertiesAct;
443 MyAction * showPreferencesAct;
444 MyAction * showTubeBrowserAct;
445#ifdef LOG_MPLAYER
446 MyAction * showLogMplayerAct;
447#endif
448#ifdef LOG_SMPLAYER
449 MyAction * showLogSmplayerAct;
450#endif
451
452 // Menu Help
453 MyAction * showFAQAct;
454 MyAction * showCLOptionsAct; // Command line options
455 MyAction * showCheckUpdatesAct;
456 MyAction * donateAct;
457 MyAction * aboutQtAct;
458 MyAction * aboutThisAct;
459
460 // Playlist
461 MyAction * playPrevAct;
462 MyAction * playNextAct;
463
464 // Actions not in menus
465#if !USE_MULTIPLE_SHORTCUTS
466 MyAction * decVolume2Act;
467 MyAction * incVolume2Act;
468#endif
469 MyAction * exitFullscreenAct;
470 MyAction * nextOSDAct;
471 MyAction * decContrastAct;
472 MyAction * incContrastAct;
473 MyAction * decBrightnessAct;
474 MyAction * incBrightnessAct;
475 MyAction * decHueAct;
476 MyAction * incHueAct;
477 MyAction * decSaturationAct;
478 MyAction * incSaturationAct;
479 MyAction * decGammaAct;
480 MyAction * incGammaAct;
481 MyAction * nextVideoAct;
482 MyAction * nextAudioAct;
483 MyAction * nextSubtitleAct;
484 MyAction * nextChapterAct;
485 MyAction * prevChapterAct;
486 MyAction * doubleSizeAct;
487 MyAction * resetVideoEqualizerAct;
488 MyAction * resetAudioEqualizerAct;
489 MyAction * showContextMenuAct;
490 MyAction * nextAspectAct;
491 MyAction * nextWheelFunctionAct;
492
493 MyAction * showFilenameAct;
494 MyAction * toggleDeinterlaceAct;
495
496 // Moving and zoom
497 MyAction * moveUpAct;
498 MyAction * moveDownAct;
499 MyAction * moveLeftAct;
500 MyAction * moveRightAct;
501 MyAction * incZoomAct;
502 MyAction * decZoomAct;
503 MyAction * resetZoomAct;
504 MyAction * autoZoomAct;
505 MyAction * autoZoom169Act;
506 MyAction * autoZoom235Act;
507
508#if USE_MPLAYER_PANSCAN
509 MyAction * incPanscanAct;
510 MyAction * decPanscanAct;
511#endif
512
513 // OSD Action Group
514 MyActionGroup * osdGroup;
515 MyAction * osdNoneAct;
516 MyAction * osdSeekAct;
517 MyAction * osdTimerAct;
518 MyAction * osdTotalAct;
519
520 // Denoise Action Group
521 MyActionGroup * denoiseGroup;
522 MyAction * denoiseNoneAct;
523 MyAction * denoiseNormalAct;
524 MyAction * denoiseSoftAct;
525
526 // Blur-sharpen group
527 MyActionGroup * unsharpGroup;
528 MyAction * unsharpNoneAct;
529 MyAction * blurAct;
530 MyAction * sharpenAct;
531
532 // Window Size Action Group
533 MyActionGroup * sizeGroup;
534 MyAction * size50;
535 MyAction * size75;
536 MyAction * size100;
537 MyAction * size125;
538 MyAction * size150;
539 MyAction * size175;
540 MyAction * size200;
541 MyAction * size300;
542 MyAction * size400;
543
544 // Deinterlace Action Group
545 MyActionGroup * deinterlaceGroup;
546 MyAction * deinterlaceNoneAct;
547 MyAction * deinterlaceL5Act;
548 MyAction * deinterlaceYadif0Act;
549 MyAction * deinterlaceYadif1Act;
550 MyAction * deinterlaceLBAct;
551 MyAction * deinterlaceKernAct;
552
553 // Aspect Action Group
554 MyActionGroup * aspectGroup;
555 MyAction * aspectDetectAct;
556 MyAction * aspectNoneAct;
557 MyAction * aspect11Act; // 1:1
558 MyAction * aspect32Act; // 3:2
559 MyAction * aspect43Act; // 4:3
560 MyAction * aspect54Act; // 5:4
561 MyAction * aspect149Act; // 14:9
562 MyAction * aspect1410Act; // 14:10
563 MyAction * aspect169Act; // 16:9
564 MyAction * aspect1610Act; // 16:10
565 MyAction * aspect235Act; // 2.35:1
566
567 // Rotate Group
568 MyActionGroup * rotateGroup;
569 MyAction * rotateNoneAct;
570 MyAction * rotateClockwiseFlipAct;
571 MyAction * rotateClockwiseAct;
572 MyAction * rotateCounterclockwiseAct;
573 MyAction * rotateCounterclockwiseFlipAct;
574
575 // Menu StayOnTop
576 MyActionGroup * onTopActionGroup;
577 MyAction * onTopAlwaysAct;
578 MyAction * onTopNeverAct;
579 MyAction * onTopWhilePlayingAct;
580 MyAction * toggleStayOnTopAct;
581
582#if USE_ADAPTER
583 // Screen Group
584 MyActionGroup * screenGroup;
585 MyAction * screenDefaultAct;
586#endif
587
588 // Closed Captions Group
589 MyActionGroup * ccGroup;
590 MyAction * ccNoneAct;
591 MyAction * ccChannel1Act;
592 MyAction * ccChannel2Act;
593 MyAction * ccChannel3Act;
594 MyAction * ccChannel4Act;
595
596
597 // Audio Channels Action Group
598 MyActionGroup * channelsGroup;
599 /* MyAction * channelsDefaultAct; */
600 MyAction * channelsStereoAct;
601 MyAction * channelsSurroundAct;
602 MyAction * channelsFull51Act;
603
604 // Stereo Mode Action Group
605 MyActionGroup * stereoGroup;
606 MyAction * stereoAct;
607 MyAction * leftChannelAct;
608 MyAction * rightChannelAct;
609
610 // Other groups
611#if PROGRAM_SWITCH
612 MyActionGroup * programTrackGroup;
613#endif
614 MyActionGroup * videoTrackGroup;
615 MyActionGroup * audioTrackGroup;
616 MyActionGroup * subtitleTrackGroup;
617 MyActionGroup * titleGroup;
618 MyActionGroup * angleGroup;
619 MyActionGroup * chapterGroup;
620
621#if DVDNAV_SUPPORT
622 MyAction * dvdnavUpAct;
623 MyAction * dvdnavDownAct;
624 MyAction * dvdnavLeftAct;
625 MyAction * dvdnavRightAct;
626 MyAction * dvdnavMenuAct;
627 MyAction * dvdnavSelectAct;
628 MyAction * dvdnavPrevAct;
629 MyAction * dvdnavMouseAct;
630#endif
631
632 // MENUS
633 QMenu *openMenu;
634 QMenu *playMenu;
635 QMenu *videoMenu;
636 QMenu *audioMenu;
637 QMenu *subtitlesMenu;
638 QMenu *browseMenu;
639 QMenu *optionsMenu;
640 QMenu *helpMenu;
641
642 QMenu * disc_menu;
643 QMenu * subtitlestrack_menu;
644#if PROGRAM_SWITCH
645 QMenu * programtrack_menu;
646#endif
647 QMenu * videotrack_menu;
648 QMenu * audiotrack_menu;
649 QMenu * titles_menu;
650 QMenu * chapters_menu;
651 QMenu * angles_menu;
652 QMenu * aspect_menu;
653 QMenu * osd_menu;
654 QMenu * deinterlace_menu;
655 QMenu * denoise_menu;
656 QMenu * unsharp_menu;
657 QMenu * videosize_menu;
658 QMenu * audiochannels_menu;
659 QMenu * stereomode_menu;
660
661 QMenu * speed_menu;
662 QMenu * ab_menu; // A-B menu
663 QMenu * videofilter_menu;
664 QMenu * audiofilter_menu;
665#if defined(LOG_MPLAYER) || defined(LOG_SMPLAYER)
666 QMenu * logs_menu;
667#endif
668 QMenu * zoom_menu;
669 QMenu * rotate_menu;
670 QMenu * ontop_menu;
671#if USE_ADAPTER
672 QMenu * screen_menu;
673#endif
674 QMenu * closed_captions_menu;
675
676 QMenu * popup;
677 QMenu * recentfiles_menu;
678
679#ifdef LOG_MPLAYER
680 LogWindow * mplayer_log_window;
681#endif
682#ifdef LOG_SMPLAYER
683 LogWindow * smplayer_log_window;
684#endif
685 LogWindow * clhelp_window;
686
687 PreferencesDialog *pref_dialog;
688 FilePropertiesDialog *file_dialog;
689 Playlist * playlist;
690 VideoEqualizer * video_equalizer;
691 AudioEqualizer * audio_equalizer;
692#ifdef FIND_SUBTITLES
693 FindSubtitlesWindow * find_subs_dialog;
694#endif
695#ifdef VIDEOPREVIEW
696 VideoPreview * video_preview;
697#endif
698
699 Core * core;
700 MplayerWindow *mplayerwindow;
701
702 Favorites * favorites;
703
704 TVList * tvlist;
705 TVList * radiolist;
706
707 QStringList actions_list;
708
709 QString pending_actions_to_run;
710
711 // Force settings from command line
712 int arg_close_on_finish; // -1 = not set, 1 = true, 0 = false
713 int arg_start_in_fullscreen; // -1 = not set, 1 = true, 0 = false
714
715private:
716 QString default_style;
717
718 bool near_top;
719 bool near_bottom;
720
721 // Variables to restore pos and size of the window
722 // when exiting from fullscreen mode.
723 QPoint win_pos;
724 QSize win_size;
725 bool was_maximized;
726
727#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
728 /* Disable screensaver by event */
729 bool just_stopped;
730#endif
731
732#ifdef LOG_MPLAYER
733 QString mplayer_log;
734#endif
735#ifdef LOG_SMPLAYER
736 QString smplayer_log;
737#endif
738
739 bool ignore_show_hide_events;
740};
741
742#endif
743
Note: See TracBrowser for help on using the repository browser.