3 This file is part of Minitube.
4 Copyright 2009, Flavio Tordini <flavio.tordini@gmail.com>
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.
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.
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/>.
26 #include <phonon/audiooutput.h>
27 #include <phonon/volumeslider.h>
28 #include <phonon/mediaobject.h>
29 #include <phonon/seekslider.h>
43 class MainWindow : public QMainWindow {
48 static MainWindow* instance();
50 #ifdef APP_PHONON_SEEK
51 Phonon::SeekSlider* getSeekSlider() { return seekSlider; }
53 QSlider* getSlider() { return slider; }
56 Phonon::AudioOutput* getAudioOutput() { return audioOutput; }
57 Phonon::VolumeSlider *getVolumeSlider() { return volumeSlider; }
59 QLabel *getCurrentTimeLabel() { return currentTimeLabel; }
62 static void printHelp();
63 QStackedWidget *getViews() { return views; }
64 MediaView* getMediaView() { return mediaView; }
65 HomeView* getHomeView() { return homeView; }
66 QAction* getRegionAction() { return regionAction; }
67 SearchLineEdit *getToolbarSearch() { return toolbarSearch; }
69 QAction *getAction(const char *name);
70 void addNamedAction(const QByteArray &name, QAction *action);
72 QMenu *getMenu(const char *name);
74 void showActionInStatusBar(QAction*, bool show);
75 void setStatusBarVisibility(bool show);
76 void adjustStatusBarVisibility();
82 void showActivationView();
87 void showMedia(SearchParams *params);
88 void showMedia(VideoSource *videoSource);
89 void showRegionsView();
91 void messageReceived(const QString &message);
93 void suggestionAccepted(Suggestion *suggestion);
94 void search(const QString &query);
95 bool canGoBack() { return history.size() > 1; }
97 void showMessage(const QString &message);
99 bool isReallyFullScreen();
100 bool isCompact() { return compactModeActive; }
101 void missingKeyWarning();
105 void currentTimeChanged(const QString &s);
109 void changeEvent(QEvent *e);
110 void closeEvent(QCloseEvent *e);
111 void showEvent(QShowEvent *e);
112 bool eventFilter(QObject *obj, QEvent *e);
113 void dragEnterEvent(QDragEnterEvent *e);
114 void dropEvent(QDropEvent *e);
115 void resizeEvent(QResizeEvent *e);
116 void moveEvent(QMoveEvent *e);
117 void leaveEvent(QEvent *e);
118 void enterEvent(QEvent *e);
122 void checkForUpdate();
123 void gotNewVersion(const QString &version);
127 void toggleFullscreen();
128 void updateUIForFullscreen();
129 void compactView(bool enable);
132 void stateChanged(Phonon::State newState, Phonon::State oldState);
135 void tick(qint64 time);
136 void totalTimeChanged(qint64 time);
137 void setDefinitionMode(const QString &definitionName);
138 void toggleDefinitionMode();
139 void clearRecentKeywords();
144 void volumeMutedChanged(bool muted);
146 void updateDownloadMessage(const QString &);
147 void downloadsFinished();
148 void toggleDownloads(bool show);
150 void setManualPlay(bool enabled);
151 void floatOnTop(bool, bool showAction = true);
152 void showStopAfterThisInStatusBar(bool show);
153 void hideFullscreenUI();
155 void toggleMenuVisibility();
156 void toggleMenuVisibilityWithMessage();
157 void toggleToolbarMenu();
160 void rateOnAppStore();
167 void createActions();
169 void createToolBars();
170 void createStatusBar();
171 void showWidget(QWidget*, bool transition = true);
172 static QString formatTime(qint64 duration);
174 void simpleUpdateDialog(const QString &version);
175 bool needStatusBar();
176 void adjustMessageLabelPosition();
178 UpdateChecker *updateChecker;
180 QHash<QByteArray, QAction*> actionMap;
181 QHash<QByteArray, QMenu*> menuMap;
184 QStackedWidget *views;
185 QStack<QWidget*> history;
186 // QVector<QAction*> viewActions;
190 MediaView *mediaView;
192 QWidget *downloadView;
193 QWidget *regionsView;
201 QAction *searchFocusAct;
204 QAction *skipBackwardAct;
208 QAction *fullscreenAct;
209 QAction *compactViewAct;
211 QAction *copyPageAct;
212 QAction *copyLinkAct;
213 QAction *volumeUpAct;
214 QAction *volumeDownAct;
215 QAction *volumeMuteAct;
216 QAction *findVideoPartsAct;
220 QAction *moveDownAct;
222 QAction *fetchMoreAct;
231 // toolbar & statusbar
232 QToolBar *mainToolBar;
233 SearchLineEdit *toolbarSearch;
234 QToolBar *statusToolBar;
235 QAction *regionAction;
239 #ifdef APP_PHONON_SEEK
240 Phonon::SeekSlider *seekSlider;
244 Phonon::VolumeSlider *volumeSlider;
245 Phonon::MediaObject *mediaObject;
246 Phonon::AudioOutput *audioOutput;
248 QLabel *currentTimeLabel;
250 bool fullScreenActive;
251 bool maximizedBeforeFullScreen;
252 bool menuVisibleBeforeFullScreen;
253 QTimer *fullscreenTimer;
254 bool compactModeActive;
255 bool menuVisibleBeforeCompactMode;
258 QLabel *messageLabel;
259 QTimer *messageTimer;
261 ToolbarMenu *toolbarMenu;
262 QToolButton *toolbarMenuButton;