]> git.sur5r.net Git - minitube/blob - src/mediaview.h
Qt5 fixes
[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
46 namespace The {
47 QHash<QString, QAction*>* globalActions();
48 }
49
50 class MediaView : public QWidget, public View {
51
52     Q_OBJECT
53
54 public:
55     static MediaView* instance();
56     void initialize();
57
58     void appear();
59     void disappear();
60
61 #ifdef APP_PHONON
62     void setMediaObject(Phonon::MediaObject *mediaObject);
63 #endif
64     const QList<VideoSource*> & getHistory() { return history; }
65     int getHistoryIndex();
66     PlaylistModel* getPlaylistModel() { return playlistModel; }
67     const QString &getCurrentVideoId();
68     void updateSubscriptionAction(Video *video, bool subscribed);
69     VideoAreaWidget* getVideoArea() { return videoAreaWidget; }
70
71 public slots:
72     void search(SearchParams *searchParams);
73     void setVideoSource(VideoSource *videoSource, bool addToHistory = true);
74     void pause();
75     void stop();
76     void skip();
77     void skipBackward();
78     void skipVideo();
79     void openWebPage();
80     void copyWebPage();
81     void copyVideoLink();
82     void openInBrowser();
83     void shareViaTwitter();
84     void shareViaFacebook();
85     void shareViaBuffer();
86     void shareViaEmail();
87     void removeSelected();
88     void moveUpSelected();
89     void moveDownSelected();
90     bool isPlaylistVisible();
91     void setPlaylistVisible(bool visible=true);
92     void saveSplitterState();
93     void downloadVideo();
94     // void snapshot();
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
104 private slots:
105     // list/model
106     void itemActivated(const QModelIndex &index);
107     void selectionChanged (const QItemSelection & selected, const QItemSelection & deselected);
108     void activeRowChanged(int);
109     void selectVideos(QList<Video*> videos);
110     void gotStreamUrl(QUrl streamUrl);
111     void handleError(QString message);
112     // phonon
113 #ifdef APP_PHONON
114     void stateChanged(Phonon::State newState, Phonon::State oldState);
115 #endif
116     void aboutToFinish();
117 #ifdef APP_ACTIVATION
118     void demoMessage();
119     void updateContinueButton(int);
120 #endif
121     void startPlaying();
122     void downloadStatusChanged();
123     void playbackFinished();
124     void playbackResume();
125     void authorPushed(QModelIndex);
126     void searchAgain();
127     void sliderMoved(int value);
128     qint64 offsetToTime(qint64 offset);
129     void startDownloading();
130
131 private:
132     MediaView(QWidget *parent = 0);
133     SearchParams* getSearchParams();
134
135     static QRegExp wordRE(QString s);
136
137     QSplitter *splitter;
138     SidebarWidget *sidebar;
139     PlaylistView *playlistView;
140     PlaylistModel *playlistModel;
141     VideoAreaWidget *videoAreaWidget;
142     LoadingWidget *loadingWidget;
143
144 #ifdef APP_PHONON
145     Phonon::MediaObject *mediaObject;
146     Phonon::VideoWidget *videoWidget;
147 #endif
148
149     bool stopped;
150     QTimer *errorTimer;
151     Video *skippedVideo;
152     QString currentVideoId;
153
154 #ifdef APP_ACTIVATION
155     QTimer *demoTimer;
156 #endif
157
158     DownloadItem *downloadItem;
159     QList<VideoSource*> history;
160     QList<QAction*> currentVideoActions;
161
162     qint64 currentVideoSize;
163 };
164
165 #endif // __MEDIAVIEW_H__