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