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