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

Last change on this file since 100 was 93, checked in by Silvan Scherrer, 15 years ago

smplayer: 0.6.9

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