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