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

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

SMPlayer: 0.7.1 trunk update

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