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

Last change on this file since 121 was 119, checked in by Silvan Scherrer, 14 years ago

SMPlayer: latest svn update

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