]> git.sur5r.net Git - minitube/blob - src/MediaView.h
Imported Upstream version 1.2
[minitube] / src / MediaView.h
1 #ifndef __MEDIAVIEW_H__
2 #define __MEDIAVIEW_H__
3
4 #include <QtGui>
5 #include <QtNetwork>
6 #include <phonon/mediaobject.h>
7 #include <phonon/videowidget.h>
8 #include "View.h"
9 #include "ListModel.h"
10 #include "thlibrary/thblackbar.h"
11 #include "searchparams.h"
12 #include "playlistwidget.h"
13 #include "loadingwidget.h"
14 #include "videoareawidget.h"
15
16 namespace The {
17     QMap<QString, QAction*>* globalActions();
18 }
19
20 class MediaView : public QWidget, public View {
21     Q_OBJECT
22
23 public:
24     MediaView(QWidget *parent);
25     void initialize();
26
27     // View
28     void appear() {
29         listView->setFocus();
30     }
31     void disappear();
32     QMap<QString, QVariant> metadata() {
33         QMap<QString, QVariant> metadata;
34         if (searchParams) {
35             metadata.insert("title", searchParams->keywords());
36             metadata.insert("description", tr("You're watching \"%1\"").arg(searchParams->keywords()));
37         }
38         return metadata;
39     }
40
41     void setMediaObject(Phonon::MediaObject *mediaObject);
42
43 public slots:
44     void search(SearchParams *searchParams);
45     void pause();
46     void stop();
47     void skip();
48     void skipVideo();
49     void openWebPage();
50     void copyWebPage();
51     void copyVideoLink();
52     void removeSelected();
53     void moveUpSelected();
54     void moveDownSelected();
55     void setPlaylistVisible(bool visible=true);
56     void saveSplitterState();
57     void downloadVideo();
58     void fullscreen();
59
60 private slots:
61     // list/model
62     void itemActivated(const QModelIndex &index);
63     void selectionChanged (const QItemSelection & selected, const QItemSelection & deselected);
64     void activeRowChanged(int);
65     void selectVideos(QList<Video*> videos);
66     void gotStreamUrl(QUrl streamUrl);
67     void handleError(QString message);
68     // phonon
69     void stateChanged(Phonon::State newState, Phonon::State oldState);
70     void currentSourceChanged(const Phonon::MediaSource source);
71     void showVideoContextMenu(QPoint point);
72     // bar
73     void searchMostRelevant();
74     void searchMostRecent();
75     void searchMostViewed();
76     // timer
77     void timerPlay();
78 #ifdef APP_DEMO
79     void demoMessage();
80 #endif
81
82 private:
83
84     SearchParams *searchParams;
85
86     QSplitter *splitter;
87
88     PlaylistWidget *playlistWidget;
89     QListView *listView;
90     ListModel *listModel;
91
92     // sortBar
93     THBlackBar *sortBar;
94     QAction *mostRelevantAction;
95     QAction *mostRecentAction;
96     QAction *mostViewedAction;
97
98     // phonon
99     Phonon::MediaObject *mediaObject;
100     Phonon::VideoWidget *videoWidget;
101
102     // loadingWidget
103     VideoAreaWidget *videoAreaWidget;
104     LoadingWidget *loadingWidget;
105
106     bool timerPlayFlag;
107     bool reallyStopped;
108
109     QTimer *errorTimer;
110     QTimer *workaroundTimer;
111     Video *skippedVideo;
112
113 #ifdef APP_DEMO
114     QTimer *demoTimer;
115 #endif
116
117 };
118
119 #endif // __MEDIAVIEW_H__