| 1 | /* smplayer, GUI front-end for mplayer.
|
|---|
| 2 | Copyright (C) 2006-2012 Ricardo Villalba <[email protected]>
|
|---|
| 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 |
|
|---|
| 36 | class QWidget;
|
|---|
| 37 | class QMenu;
|
|---|
| 38 | class LogWindow;
|
|---|
| 39 | class MplayerWindow;
|
|---|
| 40 |
|
|---|
| 41 | class QLabel;
|
|---|
| 42 | class FilePropertiesDialog;
|
|---|
| 43 | class VideoEqualizer;
|
|---|
| 44 | class AudioEqualizer;
|
|---|
| 45 | class Playlist;
|
|---|
| 46 | #ifdef FIND_SUBTITLES
|
|---|
| 47 | class FindSubtitlesWindow;
|
|---|
| 48 | #endif
|
|---|
| 49 |
|
|---|
| 50 | #ifdef VIDEOPREVIEW
|
|---|
| 51 | class VideoPreview;
|
|---|
| 52 | #endif
|
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 | class MyAction;
|
|---|
| 56 | class MyActionGroup;
|
|---|
| 57 |
|
|---|
| 58 | class PreferencesDialog;
|
|---|
| 59 |
|
|---|
| 60 | class Favorites;
|
|---|
| 61 | class TVList;
|
|---|
| 62 |
|
|---|
| 63 | class BaseGui : public QMainWindow
|
|---|
| 64 | {
|
|---|
| 65 | Q_OBJECT
|
|---|
| 66 |
|
|---|
| 67 | public:
|
|---|
| 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 |
|
|---|
| 87 | public 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 |
|
|---|
| 164 | protected 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 |
|
|---|
| 278 | signals:
|
|---|
| 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 |
|
|---|
| 303 | protected:
|
|---|
| 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 |
|
|---|
| 318 | protected:
|
|---|
| 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 |
|
|---|
| 338 | protected:
|
|---|
| 339 | virtual void wheelEvent( QWheelEvent * e ) ;
|
|---|
| 340 |
|
|---|
| 341 | protected:
|
|---|
| 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;
|
|---|
|
|---|