]> git.sur5r.net Git - minitube/blob - src/mediaview.h
Preliminary Qt5 support
[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 #include <phonon/mediaobject.h>
30 #include <phonon/videowidget.h>
31 #include <phonon/seekslider.h>
32 #include "view.h"
33
34 class Video;
35 class PlaylistModel;
36 class SearchParams;
37 class LoadingWidget;
38 class VideoAreaWidget;
39 class DownloadItem;
40 class PlaylistView;
41 class SidebarWidget;
42 class VideoSource;
43
44 namespace The {
45     QHash<QString, QAction*>* globalActions();
46 }
47
48 class MediaView : public QWidget, public View {
49
50     Q_OBJECT
51
52 public:
53     static MediaView* instance();
54     void initialize();
55
56     void appear();
57     void disappear();
58
59     void setMediaObject(Phonon::MediaObject *mediaObject);
60     const QList<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);
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 shareViaBuffer();
82     void shareViaEmail();
83     void removeSelected();
84     void moveUpSelected();
85     void moveDownSelected();
86     bool isPlaylistVisible();
87     void setPlaylistVisible(bool visible=true);
88     void saveSplitterState();
89     void downloadVideo();
90     // void snapshot();
91     void fullscreen();
92     void findVideoParts();
93     void relatedVideos();
94     bool canGoBack();
95     void goBack();
96     bool canGoForward();
97     void goForward();
98     void toggleSubscription();
99
100 private slots:
101     // list/model
102     void itemActivated(const QModelIndex &index);
103     void selectionChanged (const QItemSelection & selected, const QItemSelection & deselected);
104     void activeRowChanged(int);
105     void selectVideos(QList<Video*> videos);
106     void gotStreamUrl(QUrl streamUrl);
107     void handleError(QString message);
108     // phonon
109     void stateChanged(Phonon::State newState, Phonon::State oldState);
110     void aboutToFinish();
111 #ifdef APP_ACTIVATION
112     void demoMessage();
113     void updateContinueButton(int);
114 #endif
115     void startPlaying();
116     void downloadStatusChanged();
117     void playbackFinished();
118     void playbackResume();
119     void authorPushed(QModelIndex);
120     void searchAgain();
121     void sliderMoved(int value);
122     qint64 offsetToTime(qint64 offset);
123     void startDownloading();
124
125 private:
126     MediaView(QWidget *parent = 0);
127     SearchParams* getSearchParams();
128
129     static QRegExp wordRE(QString s);
130
131     QSplitter *splitter;
132     SidebarWidget *sidebar;
133     PlaylistView *playlistView;
134     PlaylistModel *playlistModel;
135     VideoAreaWidget *videoAreaWidget;
136     LoadingWidget *loadingWidget;
137
138     // phonon
139     Phonon::MediaObject *mediaObject;
140     Phonon::VideoWidget *videoWidget;
141
142     bool stopped;
143     QTimer *errorTimer;
144     Video *skippedVideo;
145     QString currentVideoId;
146
147 #ifdef APP_ACTIVATION
148     QTimer *demoTimer;
149 #endif
150
151     DownloadItem *downloadItem;
152     QList<VideoSource*> history;
153     QList<QAction*> currentVideoActions;
154
155     qint64 currentVideoSize;
156 };
157
158 #endif // __MEDIAVIEW_H__