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