]> git.sur5r.net Git - minitube/blob - src/mediaview.h
Imported Upstream version 2.5.1
[minitube] / src / mediaview.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 __MEDIAVIEW_H__
22 #define __MEDIAVIEW_H__
23
24 #include <QtGui>
25 #if QT_VERSION >= 0x050000
26 #include <QtWidgets>
27 #endif
28 #include <QtNetwork>
29 #ifdef APP_PHONON
30 #include <phonon/mediaobject.h>
31 #include <phonon/videowidget.h>
32 #include <phonon/seekslider.h>
33 #endif
34 #include "view.h"
35
36 class Video;
37 class PlaylistModel;
38 class SearchParams;
39 class LoadingWidget;
40 class VideoAreaWidget;
41 class DownloadItem;
42 class PlaylistView;
43 class SidebarWidget;
44 class VideoSource;
45 #ifdef APP_SNAPSHOT
46 class SnapshotSettings;
47 #endif
48
49 namespace The {
50 QHash<QString, QAction*>* globalActions();
51 }
52
53 class MediaView : public View {
54
55     Q_OBJECT
56
57 public:
58     static MediaView* instance();
59     void initialize();
60
61     void appear();
62     void disappear();
63
64 #ifdef APP_PHONON
65     void setMediaObject(Phonon::MediaObject *mediaObject);
66 #endif
67     const QList<VideoSource*> & getHistory() { return history; }
68     int getHistoryIndex();
69     PlaylistModel* getPlaylistModel() { return playlistModel; }
70     const QString &getCurrentVideoId();
71     void updateSubscriptionAction(Video *video, bool subscribed);
72     VideoAreaWidget* getVideoArea() { return videoAreaWidget; }
73
74 public slots:
75     void search(SearchParams *searchParams);
76     void setVideoSource(VideoSource *videoSource, bool addToHistory = true, bool back = false);
77     void pause();
78     void stop();
79     void skip();
80     void skipBackward();
81     void skipVideo();
82     void openWebPage();
83     void copyWebPage();
84     void copyVideoLink();
85     void openInBrowser();
86     void shareViaTwitter();
87     void shareViaFacebook();
88     void shareViaBuffer();
89     void shareViaEmail();
90     void removeSelected();
91     void moveUpSelected();
92     void moveDownSelected();
93     bool isPlaylistVisible();
94     void setPlaylistVisible(bool visible=true);
95     void saveSplitterState();
96     void downloadVideo();
97 #ifdef APP_SNAPSHOT
98     void snapshot();
99 #endif
100     void fullscreen();
101     void findVideoParts();
102     void relatedVideos();
103     bool canGoBack();
104     void goBack();
105     bool canGoForward();
106     void goForward();
107     void toggleSubscription();
108     void adjustWindowSize();
109     void maybeAdjustWindowSize();
110
111 private slots:
112     // list/model
113     void itemActivated(const QModelIndex &index);
114     void selectionChanged (const QItemSelection & selected, const QItemSelection & deselected);
115     void activeRowChanged(int);
116     void selectVideos(QList<Video*> videos);
117     void gotStreamUrl(QUrl streamUrl);
118     void handleError(const QString &message);
119     // phonon
120 #ifdef APP_PHONON
121     void stateChanged(Phonon::State newState, Phonon::State oldState);
122 #endif
123     void aboutToFinish();
124 #ifdef APP_ACTIVATION
125     void demoMessage();
126     void updateContinueButton(int);
127 #endif
128     void startPlaying();
129     void downloadStatusChanged();
130     void playbackFinished();
131     void playbackResume();
132     void authorPushed(QModelIndex);
133     void searchAgain();
134     void sliderMoved(int value);
135     qint64 offsetToTime(qint64 offset);
136     void startDownloading();
137     void resumeWithNewStreamUrl(const QUrl &streamUrl);
138
139 private:
140     MediaView(QWidget *parent = 0);
141     SearchParams* getSearchParams();
142
143     static QRegExp wordRE(const QString &s);
144
145     QSplitter *splitter;
146     SidebarWidget *sidebar;
147     PlaylistView *playlistView;
148     PlaylistModel *playlistModel;
149     VideoAreaWidget *videoAreaWidget;
150     LoadingWidget *loadingWidget;
151
152 #ifdef APP_PHONON
153     Phonon::MediaObject *mediaObject;
154     Phonon::VideoWidget *videoWidget;
155 #endif
156
157     bool stopped;
158     QTimer *errorTimer;
159     Video *skippedVideo;
160     QString currentVideoId;
161
162 #ifdef APP_ACTIVATION
163     QTimer *demoTimer;
164 #endif
165
166     DownloadItem *downloadItem;
167     QList<VideoSource*> history;
168     QList<QAction*> currentVideoActions;
169
170     qint64 currentVideoSize;
171
172 #ifdef APP_SNAPSHOT
173     SnapshotSettings *snapshotSettings;
174 #endif
175
176     QElapsedTimer pauseTimer;
177     qint64 pauseTime;
178 };
179
180 #endif // __MEDIAVIEW_H__