]> git.sur5r.net Git - minitube/blob - src/mediaview.h
84146d7d2e105918b4ec832682fcdd79eb7111ea
[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 QWidget, 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
109 private slots:
110     // list/model
111     void itemActivated(const QModelIndex &index);
112     void selectionChanged (const QItemSelection & selected, const QItemSelection & deselected);
113     void activeRowChanged(int);
114     void selectVideos(QList<Video*> videos);
115     void gotStreamUrl(QUrl streamUrl);
116     void handleError(QString message);
117     // phonon
118 #ifdef APP_PHONON
119     void stateChanged(Phonon::State newState, Phonon::State oldState);
120 #endif
121     void aboutToFinish();
122 #ifdef APP_ACTIVATION
123     void demoMessage();
124     void updateContinueButton(int);
125 #endif
126     void startPlaying();
127     void downloadStatusChanged();
128     void playbackFinished();
129     void playbackResume();
130     void authorPushed(QModelIndex);
131     void searchAgain();
132     void sliderMoved(int value);
133     qint64 offsetToTime(qint64 offset);
134     void startDownloading();
135
136 private:
137     MediaView(QWidget *parent = 0);
138     SearchParams* getSearchParams();
139
140     static QRegExp wordRE(QString s);
141
142     QSplitter *splitter;
143     SidebarWidget *sidebar;
144     PlaylistView *playlistView;
145     PlaylistModel *playlistModel;
146     VideoAreaWidget *videoAreaWidget;
147     LoadingWidget *loadingWidget;
148
149 #ifdef APP_PHONON
150     Phonon::MediaObject *mediaObject;
151     Phonon::VideoWidget *videoWidget;
152 #endif
153
154     bool stopped;
155     QTimer *errorTimer;
156     Video *skippedVideo;
157     QString currentVideoId;
158
159 #ifdef APP_ACTIVATION
160     QTimer *demoTimer;
161 #endif
162
163     DownloadItem *downloadItem;
164     QList<VideoSource*> history;
165     QList<QAction*> currentVideoActions;
166
167     qint64 currentVideoSize;
168
169 #ifdef APP_SNAPSHOT
170     SnapshotSettings *snapshotSettings;
171 #endif
172 };
173
174 #endif // __MEDIAVIEW_H__