]> git.sur5r.net Git - minitube/blobdiff - src/mainwindow.h
Upload 3.9.3-2 to unstable
[minitube] / src / mainwindow.h
index 159ffb6f75bcac02bf94e35cc9a8c0af380291ca..e4627e2458bd0bcf2cf6c240161931dc27262d4d 100644 (file)
@@ -21,134 +21,160 @@ $END_LICENSE */
 #ifndef MAINWINDOW_H
 #define MAINWINDOW_H
 
-#include <QtGui>
-#include <phonon/audiooutput.h>
-#include <phonon/volumeslider.h>
-#include <phonon/mediaobject.h>
-#include <phonon/seekslider.h>
-#include "view.h"
+#include <QtWidgets>
 
+#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();
-    ~MainWindow();
-#ifdef APP_PHONON_SEEK
-    Phonon::SeekSlider* getSeekSlider() { return seekSlider; }
-#endif
-    QSlider* getSlider() { return slider; }
+
+    QSlider *getSeekSlider() { return seekSlider; }
+    QSlider *getVolumeSlider() { return volumeSlider; }
+
+    QLabel *getCurrentTimeLabel() { return currentTimeLabel; }
     void readSettings();
     void writeSettings();
     static void printHelp();
-    MediaView* getMediaView() { return mediaView; }
-    QToolButton* getRegionButton() { return regionButton; }
-    QAction* getRegionAction() { return regionAction; }
-    void showActionInStatusBar(QAction*, bool show);
+    QStackedWidget *getViews() { return views; }
+    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 showActionsInStatusBar(const QVector<QAction *> &actions, bool show);
+    void setStatusBarVisibility(bool show);
+    void adjustStatusBarVisibility();
+
+    void hideToolbar();
+    void showToolbar();
+
+#ifdef APP_ACTIVATION
+    void showActivationView();
+#endif
 
 public slots:
-    void showHome(bool transition = true);
+    void showHome();
     void showMedia(SearchParams *params);
     void showMedia(VideoSource *videoSource);
     void showRegionsView();
     void restore();
     void messageReceived(const QString &message);
     void quit();
-    void startToolbarSearch(QString query);
+    void suggestionAccepted(Suggestion *suggestion);
+    void search(const QString &query);
+    bool canGoBack() { return history.size() > 1; }
     void goBack();
-    void showMessage(QString message);
-#ifdef APP_ACTIVATION
-    void showActivationView(bool transition = true);
-    void showActivationDialog();
-    void buy();
-    void hideBuyAction();
-#endif
+    void showMessage(const QString &message);
+    void hideMessage();
+    void handleError(const QString &message);
     bool isReallyFullScreen();
-    bool isCompact() { return m_compact; }
+    bool isCompact() { return compactModeActive; }
+    void missingKeyWarning();
+    void visitSite();
+    void setDefinitionMode(const QString &definitionName);
+
+signals:
+    void currentTimeChanged(const QString &s);
+    void viewChanged();
 
 protected:
-    void changeEvent(QEvent *);
-    void closeEvent(QCloseEvent *);
-    bool eventFilter(QObject *obj, QEvent *event);
-    void dragEnterEvent(QDragEnterEvent *event);
-    void dropEvent(QDropEvent *event);
-    void resizeEvent(QResizeEvent *);
+    void changeEvent(QEvent *e);
+    void closeEvent(QCloseEvent *e);
+    void showEvent(QShowEvent *e);
+    bool eventFilter(QObject *obj, QEvent *e);
+    void dragEnterEvent(QDragEnterEvent *e);
+    void dropEvent(QDropEvent *e);
+    void resizeEvent(QResizeEvent *e);
+    void leaveEvent(QEvent *e);
+    void enterEvent(QEvent *e);
 
 private slots:
     void lazyInit();
-    void checkForUpdate();
-    void gotNewVersion(QString version);
-    void visitSite();
     void donate();
     void reportIssue();
     void about();
-    void fullscreen();
+    void toggleFullscreen();
     void updateUIForFullscreen();
     void compactView(bool enable);
     void stop();
-    void stateChanged(Phonon::State newState, Phonon::State oldState);
     void searchFocus();
-    void tick(qint64 time);
-    void totalTimeChanged(qint64 time);
-    void setDefinitionMode(QString definitionName);
     void toggleDefinitionMode();
     void clearRecentKeywords();
 
-    // volume shortcuts
+    // 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);
 
-    // fullscreen toolbar
-    void showFullscreenToolbar(bool show);
-    void showFullscreenPlaylist(bool show);
-
-    void setManualPlay(bool enabled);
-    void updateDownloadMessage(QString);
+    void updateDownloadMessage(const QString &);
     void downloadsFinished();
     void toggleDownloads(bool show);
 
-    void floatOnTop(bool);
+    void setManualPlay(bool enabled);
+    void floatOnTop(bool, bool showAction = true);
     void showStopAfterThisInStatusBar(bool show);
+    void hideFullscreenUI();
 
-    void hideMouse();
+    void toggleMenuVisibility();
+    void toggleMenuVisibilityWithMessage();
+    void toggleToolbarMenu();
+
+#ifdef APP_MAC_STORE
+    void rateOnAppStore();
+#endif
 
 private:
-    void initPhonon();
+    void initMedia();
     void createActions();
     void createMenus();
-    void createToolBars();
+    void createToolBar();
     void createStatusBar();
-    void showWidget(QWidget*, bool transition = true);
-    static QString formatTime(qint64 time);
+    void showView(View *view, bool transition = false);
+    static QString formatTime(qint64 duration);
     bool confirmQuit();
-    void simpleUpdateDialog(QString version);
+    bool needStatusBar();
+    void adjustMessageLabelPosition();
 
-    UpdateChecker *updateChecker;
+    QHash<QByteArray, QAction *> actionMap;
+    QHash<QByteArray, QMenu *> menuMap;
 
     // view mechanism
     QStackedWidget *views;
-    QStack<QWidget*> *history;
-    QList<QAction*> viewActions;
+    QStack<View *> history;
 
     // view widgets
     HomeView *homeView;
     MediaView *mediaView;
-    QWidget *aboutView;
-    QWidget *downloadView;
-    QWidget *regionsView;
+    View *aboutView;
+    View *downloadView;
+    View *regionsView;
+    View *subscriptionImportView = nullptr;
 
     // actions
     QAction *backAct;
@@ -190,26 +216,26 @@ private:
     QToolBar *mainToolBar;
     SearchLineEdit *toolbarSearch;
     QToolBar *statusToolBar;
-    QToolButton *regionButton;
     QAction *regionAction;
+    QSlider *seekSlider;
+    QSlider *volumeSlider;
+    QLabel *currentTimeLabel;
 
-    // phonon
-    QSlider *slider;
-#ifdef APP_PHONON_SEEK
-    Phonon::SeekSlider *seekSlider;
-#endif
-    Phonon::VolumeSlider *volumeSlider;
-    Phonon::MediaObject *mediaObject;
-    Phonon::AudioOutput *audioOutput;
-    QLabel *currentTime;
-    QLabel *totalTime;
-
-    // fullscreen
-    bool m_fullscreen;
-    bool m_maximized;
-    QTimer *mouseTimer;
-    bool m_compact;
+    bool fullScreenActive;
+    bool maximizedBeforeFullScreen;
+    bool menuVisibleBeforeFullScreen;
+    QTimer *fullscreenTimer;
+    bool compactModeActive;
+    bool menuVisibleBeforeCompactMode;
+    bool initialized;
+
+    QLabel *messageLabel;
+    QTimer *messageTimer;
+
+    ToolbarMenu *toolbarMenu;
+    QToolButton *toolbarMenuButton;
 
+    Media *media;
 };
 
 #endif