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