]> git.sur5r.net Git - minitube/blobdiff - src/mainwindow.h
New upstream version 3.1
[minitube] / src / mainwindow.h
index e377a2fe3fd5bd8bec8af55161382a42c8a5bd77..e7d80b67f2e5857dc8028347c69a4dfbe1a6ba3c 100644 (file)
@@ -22,56 +22,47 @@ $END_LICENSE */
 #define MAINWINDOW_H
 
 #include <QtWidgets>
-#ifdef APP_PHONON
-#include <phonon/audiooutput.h>
-#include <phonon/volumeslider.h>
-#include <phonon/mediaobject.h>
-#include <phonon/seekslider.h>
-#endif
 
+#include "media.h"
+
+class View;
 class HomeView;
 class MediaView;
 class DownloadView;
 
 class SearchLineEdit;
-class UpdateChecker;
 class SearchParams;
 class VideoSource;
 class Suggestion;
 class ToolbarMenu;
 
 class MainWindow : public QMainWindow {
-
     Q_OBJECT
 
 public:
-    static MainWindowinstance();
+    static MainWindow *instance();
     MainWindow();
-#ifdef APP_PHONON_SEEK
-    Phonon::SeekSlider* getSeekSlider() { return seekSlider; }
-#else
-    QSlider* getSlider() { return slider; }
-#endif
-#ifdef APP_PHONON
-    Phonon::AudioOutput* getAudioOutput() { return audioOutput; }
-    Phonon::VolumeSlider *getVolumeSlider() { return volumeSlider; }
-#endif
+
+    QSlider *getSeekSlider() { return seekSlider; }
+    QSlider *getVolumeSlider() { return volumeSlider; }
+
     QLabel *getCurrentTimeLabel() { return currentTimeLabel; }
     void readSettings();
     void writeSettings();
     static void printHelp();
     QStackedWidget *getViews() { return views; }
-    MediaViewgetMediaView() { return mediaView; }
-    HomeViewgetHomeView() { return homeView; }
-    QActiongetRegionAction() { return regionAction; }
+    MediaView *getMediaView() { return mediaView; }
+    HomeView *getHomeView() { return homeView; }
+    QAction *getRegionAction() { return regionAction; }
     SearchLineEdit *getToolbarSearch() { return toolbarSearch; }
 
+    void setupAction(QAction *action);
     QAction *getAction(const char *name);
     void addNamedAction(const QByteArray &name, QAction *action);
 
     QMenu *getMenu(const char *name);
 
-    void showActionInStatusBar(QAction*, bool show);
+    void showActionsInStatusBar(const QVector<QAction *> &actions, bool show);
     void setStatusBarVisibility(bool show);
     void adjustStatusBarVisibility();
 
@@ -96,10 +87,12 @@ public slots:
     void goBack();
     void showMessage(const QString &message);
     void hideMessage();
+    void handleError(const QString &message);
     bool isReallyFullScreen();
     bool isCompact() { return compactModeActive; }
     void missingKeyWarning();
     void visitSite();
+    void setDefinitionMode(const QString &definitionName);
 
 signals:
     void currentTimeChanged(const QString &s);
@@ -113,14 +106,12 @@ protected:
     void dragEnterEvent(QDragEnterEvent *e);
     void dropEvent(QDropEvent *e);
     void resizeEvent(QResizeEvent *e);
-    void moveEvent(QMoveEvent *e);
     void leaveEvent(QEvent *e);
     void enterEvent(QEvent *e);
 
 private slots:
     void lazyInit();
     void checkForUpdate();
-    void gotNewVersion(const QString &version);
     void donate();
     void reportIssue();
     void about();
@@ -128,19 +119,18 @@ private slots:
     void updateUIForFullscreen();
     void compactView(bool enable);
     void stop();
-#ifdef APP_PHONON
-    void stateChanged(Phonon::State newState, Phonon::State oldState);
-#endif
     void searchFocus();
-    void tick(qint64 time);
-    void totalTimeChanged(qint64 time);
-    void setDefinitionMode(const QString &definitionName);
     void toggleDefinitionMode();
     void clearRecentKeywords();
 
+    // media
+    void stateChanged(Media::State state);
+    void tick(qint64 time);
+
     void volumeUp();
     void volumeDown();
-    void volumeMute();
+    void toggleVolumeMute();
+    void volumeChanged(qreal newVolume);
     void volumeMutedChanged(bool muted);
 
     void updateDownloadMessage(const QString &);
@@ -161,36 +151,31 @@ private slots:
 #endif
 
 private:
-#ifdef APP_PHONON
-    void initPhonon();
-#endif
+    void initMedia();
     void createActions();
     void createMenus();
-    void createToolBars();
+    void createToolBar();
     void createStatusBar();
-    void showWidget(QWidget*, bool transition = true);
+    void showView(View *view, bool transition = false);
     static QString formatTime(qint64 duration);
     bool confirmQuit();
     void simpleUpdateDialog(const QString &version);
     bool needStatusBar();
     void adjustMessageLabelPosition();
 
-    UpdateChecker *updateChecker;
-
-    QHash<QByteArray, QAction*> actionMap;
-    QHash<QByteArray, QMenu*> menuMap;
+    QHash<QByteArray, QAction *> actionMap;
+    QHash<QByteArray, QMenu *> menuMap;
 
     // view mechanism
     QStackedWidget *views;
-    QStack<QWidget*> history;
-    // QVector<QAction*> viewActions;
+    QStack<View *> history;
 
     // view widgets
     HomeView *homeView;
     MediaView *mediaView;
-    QWidget *aboutView;
-    QWidget *downloadView;
-    QWidget *regionsView;
+    View *aboutView;
+    View *downloadView;
+    View *regionsView;
 
     // actions
     QAction *backAct;
@@ -233,18 +218,8 @@ private:
     SearchLineEdit *toolbarSearch;
     QToolBar *statusToolBar;
     QAction *regionAction;
-
-    // phonon
-#ifdef APP_PHONON
-#ifdef APP_PHONON_SEEK
-    Phonon::SeekSlider *seekSlider;
-#else
-    QSlider *slider;
-#endif
-    Phonon::VolumeSlider *volumeSlider;
-    Phonon::MediaObject *mediaObject;
-    Phonon::AudioOutput *audioOutput;
-#endif
+    QSlider *seekSlider;
+    QSlider *volumeSlider;
     QLabel *currentTimeLabel;
 
     bool fullScreenActive;
@@ -260,6 +235,8 @@ private:
 
     ToolbarMenu *toolbarMenu;
     QToolButton *toolbarMenuButton;
+
+    Media *media;
 };
 
 #endif