]> git.sur5r.net Git - minitube/blob - src/mainwindow.h
Imported Upstream version 2.5.1
[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 #ifdef APP_PHONON_SEEK
52     Phonon::SeekSlider* getSeekSlider() { return seekSlider; }
53 #else
54     QSlider* getSlider() { return slider; }
55 #endif
56 #ifdef APP_PHONON
57     Phonon::AudioOutput* getAudioOutput() { return audioOutput; }
58     Phonon::VolumeSlider *getVolumeSlider() { return volumeSlider; }
59 #endif
60     QLabel *getCurrentTimeLabel() { return currentTime; }
61     void readSettings();
62     void writeSettings();
63     static void printHelp();
64     MediaView* getMediaView() { return mediaView; }
65     QToolButton* getRegionButton() { return regionButton; }
66     QAction* getRegionAction() { return regionAction; }
67     SearchLineEdit *getToolbarSearch() { return toolbarSearch; }
68
69     void showActionInStatusBar(QAction*, bool show);
70     void setStatusBarVisibility(bool show);
71     void adjustStatusBarVisibility();
72
73 public slots:
74     void showHome(bool transition = true);
75     void showMedia(SearchParams *params);
76     void showMedia(VideoSource *videoSource);
77     void showRegionsView();
78     void restore();
79     void messageReceived(const QString &message);
80     void quit();
81     void suggestionAccepted(Suggestion *suggestion);
82     void search(const QString &query);
83     void goBack();
84     void showMessage(const QString &message);
85 #ifdef APP_ACTIVATION
86     void showActivationView(bool transition = true);
87     void showActivationDialog();
88     void buy();
89     void hideBuyAction();
90 #endif
91     bool isReallyFullScreen();
92     bool isCompact() { return m_compact; }
93
94 signals:
95     void currentTimeChanged(const QString &s);
96
97 protected:
98     void changeEvent(QEvent *e);
99     void closeEvent(QCloseEvent *e);
100     void showEvent(QShowEvent *e);
101     bool eventFilter(QObject *obj, QEvent *e);
102     void dragEnterEvent(QDragEnterEvent *e);
103     void dropEvent(QDropEvent *e);
104     void resizeEvent(QResizeEvent *e);
105     void moveEvent(QMoveEvent *e);
106
107 private slots:
108     void lazyInit();
109     void checkForUpdate();
110     void gotNewVersion(const QString &version);
111     void visitSite();
112     void donate();
113     void reportIssue();
114     void about();
115     void fullscreen();
116     void updateUIForFullscreen();
117     void compactView(bool enable);
118     void stop();
119 #ifdef APP_PHONON
120     void stateChanged(Phonon::State newState, Phonon::State oldState);
121 #endif
122     void searchFocus();
123     void tick(qint64 time);
124     void totalTimeChanged(qint64 time);
125     void setDefinitionMode(const QString &definitionName);
126     void toggleDefinitionMode();
127     void clearRecentKeywords();
128
129     // volume shortcuts
130     void volumeUp();
131     void volumeDown();
132     void volumeMute();
133     void volumeChanged(qreal newVolume);
134     void volumeMutedChanged(bool muted);
135
136     // fullscreen toolbar
137     void showFullscreenToolbar(bool show);
138     void showFullscreenPlaylist(bool show);
139
140     void setManualPlay(bool enabled);
141     void updateDownloadMessage(const QString &);
142     void downloadsFinished();
143     void toggleDownloads(bool show);
144
145     void floatOnTop(bool, bool showAction = true);
146     void adjustWindowSizeChanged(bool enabled);
147
148     void showStopAfterThisInStatusBar(bool show);
149
150     void hideMouse();
151
152 #ifdef APP_MAC_STORE
153     void rateOnAppStore();
154 #endif
155
156 private:
157 #ifdef APP_PHONON
158     void initPhonon();
159 #endif
160     void createActions();
161     void createMenus();
162     void createToolBars();
163     void createStatusBar();
164     void showWidget(QWidget*, bool transition = true);
165     static QString formatTime(qint64 duration);
166     bool confirmQuit();
167     void simpleUpdateDialog(const QString &version);
168     bool needStatusBar();
169     void adjustMessageLabelPosition();
170
171     UpdateChecker *updateChecker;
172
173     // view mechanism
174     QStackedWidget *views;
175     QStack<QWidget*> history;
176     QList<QAction*> viewActions;
177
178     // view widgets
179     HomeView *homeView;
180     MediaView *mediaView;
181     QWidget *aboutView;
182     QWidget *downloadView;
183     QWidget *regionsView;
184
185     // actions
186     QAction *backAct;
187     QAction *quitAct;
188     QAction *siteAct;
189     QAction *donateAct;
190     QAction *aboutAct;
191     QAction *searchFocusAct;
192
193     // media actions
194     QAction *skipBackwardAct;
195     QAction *skipAct;
196     QAction *pauseAct;
197     QAction *stopAct;
198     QAction *fullscreenAct;
199     QAction *compactViewAct;
200     QAction *webPageAct;
201     QAction *copyPageAct;
202     QAction *copyLinkAct;
203     QAction *volumeUpAct;
204     QAction *volumeDownAct;
205     QAction *volumeMuteAct;
206     QAction *findVideoPartsAct;
207
208     // playlist actions
209     QAction *removeAct;
210     QAction *moveDownAct;
211     QAction *moveUpAct;
212     QAction *fetchMoreAct;
213     QAction *clearAct;
214
215     // menus
216     QMenu *fileMenu;
217     QMenu *viewMenu;
218     QMenu *playlistMenu;
219     QMenu *helpMenu;
220
221     // toolbar & statusbar
222     QToolBar *mainToolBar;
223     SearchLineEdit *toolbarSearch;
224     QToolBar *statusToolBar;
225     QToolButton *regionButton;
226     QAction *regionAction;
227
228     // phonon
229 #ifdef APP_PHONON
230 #ifdef APP_PHONON_SEEK
231     Phonon::SeekSlider *seekSlider;
232 #else
233     QSlider *slider;
234 #endif
235     Phonon::VolumeSlider *volumeSlider;
236     Phonon::MediaObject *mediaObject;
237     Phonon::AudioOutput *audioOutput;
238 #endif
239     QLabel *currentTime;
240     // QLabel *totalTime;
241
242     bool fullscreenFlag;
243     bool m_maximized;
244     QTimer *mouseTimer;
245     bool m_compact;
246     bool initialized;
247
248     QLabel *messageLabel;
249     QTimer *messageTimer;
250
251 };
252
253 #endif