]> git.sur5r.net Git - minitube/blob - src/mediaview.h
Upload 3.9.3-2 to unstable
[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 <QtNetwork>
25 #include <QtWidgets>
26
27 #include "media.h"
28
29 #include "view.h"
30
31 class Video;
32 class PlaylistModel;
33 class SearchParams;
34 class LoadingWidget;
35 class VideoArea;
36 class PlaylistView;
37 class SidebarWidget;
38 class VideoSource;
39 #ifdef APP_SNAPSHOT
40 class SnapshotSettings;
41 #endif
42
43 class MediaView : public View {
44     Q_OBJECT
45
46 public:
47     static MediaView *instance();
48     void initialize();
49
50     void appear();
51     void disappear();
52
53     void setMedia(Media *media);
54     const QVector<VideoSource *> &getHistory() { return history; }
55     int getHistoryIndex();
56     PlaylistModel *getPlaylistModel() { return playlistModel; }
57     const QString &getCurrentVideoId();
58     void updateSubscriptionActionForVideo(Video *video, bool subscribed);
59     void updateSubscriptionActionForChannel(const QString & channelId);
60     VideoArea *getVideoArea() { return videoAreaWidget; }
61     void reloadCurrentVideo();
62
63 public slots:
64     void search(SearchParams *searchParams);
65     void setVideoSource(VideoSource *videoSource, bool addToHistory = true, bool back = false);
66     void pause();
67     void stop();
68     void skip();
69     void skipBackward();
70     void skipVideo();
71     void openWebPage();
72     void copyWebPage();
73     void copyVideoLink();
74     void openInBrowser();
75     void shareViaTwitter();
76     void shareViaFacebook();
77     void shareViaEmail();
78     void removeSelected();
79     void moveUpSelected();
80     void moveDownSelected();
81     bool isSidebarVisible();
82     void setSidebarVisibility(bool visible);
83     SidebarWidget *getSidebar() { return sidebar; }
84     void removeSidebar();
85     void restoreSidebar();
86     void saveSplitterState();
87     void downloadVideo();
88 #ifdef APP_SNAPSHOT
89     void snapshot();
90 #endif
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     void adjustWindowSize();
100     void updateSubscriptionAction(bool subscribed);
101
102 private slots:
103     void onItemActivated(const QModelIndex &index);
104     void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
105     void activeVideoChanged(Video *video, Video *previousVideo);
106     void selectVideos(const QVector<Video *> &videos);
107     void gotStreamUrl(const QString &streamUrl, const QString &audioUrl);
108     void handleError(const QString &message);
109     void mediaStateChanged(Media::State state);
110     void onAboutToFinish();
111     void onPlaybackFinished();
112     void resumePlayback();
113     void onAuthorPushed(QModelIndex);
114     void searchAgain();
115     void resumeWithNewStreamUrl(const QString &streamUrl, const QString &audioUrl);
116
117 private:
118     MediaView(QWidget *parent = nullptr);
119     SearchParams *getSearchParams();
120
121     static QRegExp wordRE(const QString &s);
122
123     QSplitter *splitter;
124     SidebarWidget *sidebar;
125     PlaylistView *playlistView;
126     PlaylistModel *playlistModel;
127     VideoArea *videoAreaWidget;
128     LoadingWidget *loadingWidget;
129
130     Media *media;
131     QWidget *videoWidget;
132
133     bool stopped;
134     QTimer *errorTimer;
135     Video *skippedVideo;
136     QString currentVideoId;
137
138     QString currentSubscriptionChannelId;
139     QString currentSubscriptionChannelTitle;
140
141 #ifdef APP_ACTIVATION
142     QTimer *demoTimer;
143 #endif
144
145     QVector<VideoSource *> history;
146     QVector<QAction *> currentVideoActions;
147     QVector<QAction *> playingVideoActions;
148
149     qint64 currentVideoSize;
150
151 #ifdef APP_SNAPSHOT
152     SnapshotSettings *snapshotSettings;
153 #endif
154
155     QElapsedTimer pauseTimer;
156     qint64 pauseTime;
157 };
158
159 #endif // MEDIAVIEW_H