]> git.sur5r.net Git - minitube/blob - src/mainwindow.h
9cd0b4b46975542b1a5a69773220c132d894e408
[minitube] / src / mainwindow.h
1 /* $BEGIN_LICENSE
2
3 This file is part of Minitube.
4 Copyright 2009, Flavio Tordini <flavio.tordini@gmail.com>
5
6 Minitube is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 Minitube is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Minitube.  If not, see <http://www.gnu.org/licenses/>.
18
19 $END_LICENSE */
20
21 #ifndef MAINWINDOW_H
22 #define MAINWINDOW_H
23
24 #include <QtGui>
25 #if QT_VERSION >= 0x050000
26 #include <QtWidgets>
27 #endif
28 #ifdef APP_PHONON
29 #include <phonon/audiooutput.h>
30 #include <phonon/volumeslider.h>
31 #include <phonon/mediaobject.h>
32 #include <phonon/seekslider.h>
33 #endif
34
35 class HomeView;
36 class MediaView;
37 class DownloadView;
38 class SearchLineEdit;
39 class UpdateChecker;
40 class SearchParams;
41 class VideoSource;
42 class Suggestion;
43
44 class MainWindow : public QMainWindow {
45
46     Q_OBJECT
47
48 public:
49     static MainWindow* instance();
50     MainWindow();
51     ~MainWindow();
52 #ifdef APP_PHONON_SEEK
53     Phonon::SeekSlider* getSeekSlider() { return seekSlider; }
54 #else
55     QSlider* getSlider() { return slider; }
56 #endif
57 #ifdef APP_PHONON
58     Phonon::AudioOutput* getAudioOutput() { return audioOutput; }
59     Phonon::VolumeSlider *getVolumeSlider() { return volumeSlider; }
60 #endif
61     QLabel *getCurrentTimeLabel() { return currentTime; }
62     void readSettings();
63     void writeSettings();
64     static void printHelp();
65     MediaView* getMediaView() { return mediaView; }
66     QToolButton* getRegionButton() { return regionButton; }
67     QAction* getRegionAction() { return regionAction; }
68     void showActionInStatusBar(QAction*, bool show);
69     void setStatusBarVisibility(bool show);
70     void adjustStatusBarVisibility();
71
72 public slots:
73     void showHome(bool transition = true);
74     void showMedia(SearchParams *params);
75     void showMedia(VideoSource *videoSource);
76     void showRegionsView();
77     void restore();
78     void messageReceived(const QString &message);
79     void quit();
80     void suggestionAccepted(Suggestion *suggestion);
81     void search(const QString &query);
82     void goBack();
83     void showMessage(const QString &message);
84 #ifdef APP_ACTIVATION
85     void showActivationView(bool transition = true);
86     void showActivationDialog();
87     void buy();
88     void hideBuyAction();
89 #endif
90     bool isReallyFullScreen();
91     bool isCompact() { return m_compact; }
92
93 signals:
94     void currentTimeChanged(const QString &s);
95
96 protected:
97     void changeEvent(QEvent *e);
98     void closeEvent(QCloseEvent *e);
99     void showEvent(QShowEvent *e);
100     bool eventFilter(QObject *obj, QEvent *e);
101     void dragEnterEvent(QDragEnterEvent *e);
102     void dropEvent(QDropEvent *e);
103     void resizeEvent(QResizeEvent *e);
104     void moveEvent(QMoveEvent *e);
105
106 private slots:
107     void lazyInit();
108     void checkForUpdate();
109     void gotNewVersion(const QString &version);
110     void visitSite();
111     void donate();
112     void reportIssue();
113     void about();
114     void fullscreen();
115     void updateUIForFullscreen();
116     void compactView(bool enable);
117     void stop();
118 #ifdef APP_PHONON
119     void stateChanged(Phonon::State newState, Phonon::State oldState);
120 #endif
121     void searchFocus();
122     void tick(qint64 time);
123     void totalTimeChanged(qint64 time);
124     void setDefinitionMode(const QString &definitionName);
125     void toggleDefinitionMode();
126     void clearRecentKeywords();
127
128     // volume shortcuts
129     void volumeUp();
130     void volumeDown();
131     void volumeMute();
132     void volumeChanged(qreal newVolume);
133     void volumeMutedChanged(bool muted);
134
135     // fullscreen toolbar
136     void showFullscreenToolbar(bool show);
137     void showFullscreenPlaylist(bool show);
138
139     void setManualPlay(bool enabled);
140     void updateDownloadMessage(const QString &);
141     void downloadsFinished();
142     void toggleDownloads(bool show);
143
144     void floatOnTop(bool, bool showAction = true);
145     void adjustWindowSizeChanged(bool enabled);
146
147     void showStopAfterThisInStatusBar(bool show);
148
149     void hideMouse();
150
151 #ifdef APP_MAC_STORE
152     void rateOnAppStore();
153 #endif
154
155 private:
156 #ifdef APP_PHONON
157     void initPhonon();
158 #endif
159     void createActions();
160     void createMenus();
161     void createToolBars();
162     void createStatusBar();
163     void showWidget(QWidget*, bool transition = true);
164     static QString formatTime(qint64 duration);
165     bool confirmQuit();
166     void simpleUpdateDialog(const QString &version);
167     bool needStatusBar();
168     void adjustMessageLabelPosition();
169
170     UpdateChecker *updateChecker;
171
172     // view mechanism
173     QStackedWidget *views;
174     QStack<QWidget*> *history;
175     QList<QAction*> viewActions;
176
177     // view widgets
178     HomeView *homeView;
179     MediaView *mediaView;
180     QWidget *aboutView;
181     QWidget *downloadView;
182     QWidget *regionsView;
183
184     // actions
185     QAction *backAct;
186     QAction *quitAct;
187     QAction *siteAct;
188     QAction *donateAct;
189     QAction *aboutAct;
190     QAction *searchFocusAct;
191
192     // media actions
193     QAction *skipBackwardAct;
194     QAction *skipAct;
195     QAction *pauseAct;
196     QAction *stopAct;
197     QAction *fullscreenAct;
198     QAction *compactViewAct;
199     QAction *webPageAct;
200     QAction *copyPageAct;
201     QAction *copyLinkAct;
202     QAction *volumeUpAct;
203     QAction *volumeDownAct;
204     QAction *volumeMuteAct;
205     QAction *findVideoPartsAct;
206
207     // playlist actions
208     QAction *removeAct;
209     QAction *moveDownAct;
210     QAction *moveUpAct;
211     QAction *fetchMoreAct;
212     QAction *clearAct;
213
214     // menus
215     QMenu *fileMenu;
216     QMenu *viewMenu;
217     QMenu *playlistMenu;
218     QMenu *helpMenu;
219
220     // toolbar & statusbar
221     QToolBar *mainToolBar;
222     SearchLineEdit *toolbarSearch;
223     QToolBar *statusToolBar;
224     QToolButton *regionButton;
225     QAction *regionAction;
226
227     // phonon
228 #ifdef APP_PHONON
229 #ifdef APP_PHONON_SEEK
230     Phonon::SeekSlider *seekSlider;
231 #else
232     QSlider *slider;
233 #endif
234     Phonon::VolumeSlider *volumeSlider;
235     Phonon::MediaObject *mediaObject;
236     Phonon::AudioOutput *audioOutput;
237 #endif
238     QLabel *currentTime;
239     // QLabel *totalTime;
240
241     // fullscreen
242     bool m_fullscreen;
243     bool m_maximized;
244     QTimer *mouseTimer;
245     bool m_compact;
246
247     QLabel *messageLabel;
248     QTimer *messageTimer;
249
250 };
251
252 #endif