1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404
|
/* smplayer, GUI front-end for mplayer.
Copyright (C) 2006-2018 Ricardo Villalba <rvm@users.sourceforge.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef PLAYLIST_H
#define PLAYLIST_H
#include <QList>
#include <QStringList>
#include <QWidget>
#include <QModelIndex>
#include <QStandardItem>
#include <QProcess>
#include "mediadata.h"
#define PLAYLIST_DOWNLOAD
//#define PLAYLIST_DOUBLE_TOOLBAR
#define PLAYLIST_DELETE_FROM_DISK
#define YT_PLAYLIST_SUPPORT
class PLItem : public QStandardItem {
public:
enum PLItem_Roles { Role_Played = Qt::UserRole + 2, Role_Current = Qt::UserRole + 3, Role_Params = Qt::UserRole + 4,
Role_Video_URL = Qt::UserRole + 5, Role_Icon_URL = Qt::UserRole + 6 };
PLItem();
PLItem(const QString filename, const QString name, double duration);
~PLItem();
void setFilename(const QString filename);
void setName(const QString name);
void setDuration(double duration);
void setExtraParams(const QStringList & pars);
void setVideoURL(const QString & url);
void setIconURL(const QString & url);
void setPlayed(bool played);
void setPosition(int position);
void setCurrent(bool b);
QString filename();
QString name();
double duration();
QStringList extraParams();
QString videoURL();
QString iconURL();
bool played();
int position();
bool isCurrent();
QList<QStandardItem *> items();
protected:
QStandardItem * col_num;
QStandardItem * col_duration;
QStandardItem * col_filename;
};
class QTableView;
class QStandardItemModel;
class QStandardItem;
class QSortFilterProxyModel;
class QToolBar;
class MyAction;
class MyLineEdit;
class LoadPage;
class QMenu;
class QSettings;
class QToolButton;
class QTimer;
class QMovie;
class URLHistory;
class Playlist : public QWidget
{
Q_OBJECT
public:
enum AutoGetInfo { NoGetInfo = 0, GetInfo = 1, UserDefined = 2 };
enum M3UFormat { M3U = 0, M3U8 = 1, DetectFormat = 2 };
Playlist(QWidget * parent = 0, Qt::WindowFlags f = Qt::Window );
~Playlist();
void setConfigPath(const QString & config_path);
void clear();
void list();
int count();
bool isEmpty();
bool isModified() { return modified; };
PLItem * itemData(int row);
PLItem * itemFromProxy(int row);
bool existsItem(int row);
/*
void changeItem(int row, const QString & filename, const QString name, double duration, bool played = false, int pos = -1);
*/
public slots:
void addItem(QString filename, QString name, double duration, QStringList params = QStringList(),
QString video_url = QString::null, QString icon_url = QString::null);
// Start playing, from item 0 if shuffle is off, or from
// a random item otherwise
void startPlay();
void playItem(int n);
void playNext();
void playPrev();
void playNextAuto(); // Called from GUI when a file finished
void resumePlay();
void removeSelected();
void removeAll();
void addCurrentFile();
void addFiles();
void addDirectory();
void addUrls();
void addFile(QString file, AutoGetInfo auto_get_info = UserDefined);
void addFiles(QStringList files, AutoGetInfo auto_get_info = UserDefined);
// Adds a directory, no recursive
void addOneDirectory(QString dir);
// Adds a directory, maybe with recursion (depends on user config)
void addDirectory(QString dir);
#ifdef PLAYLIST_DELETE_FROM_DISK
void deleteSelectedFileFromDisk();
#endif
bool maybeSave();
void load();
bool saveCurrentPlaylist();
bool save(const QString & filename = QString::null);
#ifdef PLAYLIST_DOWNLOAD
void openUrl();
void openUrl(const QString & url);
#endif
void load_m3u(QString file, M3UFormat format = DetectFormat);
bool save_m3u(QString file);
void load_pls(QString file);
bool save_pls(QString file);
void loadXSPF(const QString & filename);
bool saveXSPF(const QString & filename);
#ifdef YT_PLAYLIST_SUPPORT
void loadYoutubeList(QByteArray & data);
#endif
void setModified(bool);
void setFilter(const QString & filter);
// Slots to connect from basegui
void getMediaInfo(const MediaData &);
void playerFailed(QProcess::ProcessError);
void playerFinishedWithError(int);
public:
// Preferences
void setDirectoryRecursion(bool b) { recursive_add_directory = b; };
void setAutoGetInfo(bool b) { automatically_get_info = b; };
void setSavePlaylistOnExit(bool b) { save_playlist_in_config = b; };
void setPlayFilesFromStart(bool b) { play_files_from_start = b; };
void setIgnorePlayerErrors(bool b) { ignore_player_errors = b; };
void setStartPlayOnLoad(bool b) { start_play_on_load = b; };
void setAutomaticallyPlayNext(bool b) { automatically_play_next = b; };
void setAutoSort(bool b);
void setSortCaseSensitive(bool b);
void setFilterCaseSensitive(bool b);
bool directoryRecursion() { return recursive_add_directory; };
bool autoGetInfo() { return automatically_get_info; };
bool savePlaylistOnExit() { return save_playlist_in_config; };
bool playFilesFromStart() { return play_files_from_start; };
bool ignorePlayerErrors() { return ignore_player_errors; };
bool startPlayOnLoad() { return start_play_on_load; };
bool automaticallyPlayNext() { return automatically_play_next; };
bool autoSort();
bool sortCaseSensitive();
bool filterCaseSensitive();
#ifdef PLAYLIST_DOWNLOAD
void setMaxItemsUrlHistory(int max_items);
int maxItemsUrlHistory();
#endif
#ifdef PLAYLIST_DELETE_FROM_DISK
void allowDeleteFromDisk(bool enabled) { allow_delete_from_disk = enabled; };
bool isDeleteFromDiskAllowed() { return allow_delete_from_disk; };
#endif
#ifdef YT_PLAYLIST_SUPPORT
static bool isYTPlaylist(const QString & url);
#endif
/*
public:
MyAction * playPrevAct() { return prevAct; };
MyAction * playNextAct() { return nextAct; };
*/
signals:
void requestToPlayFile(const QString & filename, int seek = -1);
void requestToPlayStream(const QString & filename, QStringList params = QStringList());
void requestToAddCurrentFile();
void playlistEnded();
void visibilityChanged(bool visible);
void modifiedChanged(bool);
void windowTitleChanged(const QString & title);
protected:
void setCurrentItem(int current);
int findCurrentItem();
void clearPlayedTag();
int chooseRandomItem();
QString lastDir();
void setPlaylistFilename(const QString &);
QString playlistFilename() { return playlist_filename; };
void updateWindowTitle();
protected slots:
void playCurrent();
void itemActivated(const QModelIndex & index );
void showPopup(const QPoint & pos);
void upItem();
void downItem();
void editCurrentItem();
void editItem(int row);
void copyURL();
void openFolder();
#ifdef CHROMECAST_SUPPORT
void playOnChromecast();
#else
void openURLInWeb();
#endif
void saveSettings();
void loadSettings();
void maybeSaveSettings();
void filterEditChanged(const QString &);
#ifdef PLAYLIST_DOWNLOAD
void playlistDownloaded(QByteArray);
void errorOcurred(int error_number, QString error_str);
void showLoadingAnimation(bool b);
#endif
void setPositionColumnVisible(bool b);
void setNameColumnVisible(bool b);
void setDurationColumnVisible(bool b);
void setFilenameColumnVisible(bool b);
protected:
void createTable();
void createActions();
void createToolbar();
protected:
void retranslateStrings();
virtual void changeEvent ( QEvent * event ) ;
virtual void dragEnterEvent( QDragEnterEvent * ) ;
virtual void dropEvent ( QDropEvent * );
virtual void hideEvent ( QHideEvent * );
virtual void showEvent ( QShowEvent * );
virtual void closeEvent( QCloseEvent * e );
protected:
QString playlist_path;
QString playlist_filename;
QString latest_dir;
QMenu * file_menu;
QMenu * add_menu;
QMenu * remove_menu;
QMenu * popup;
QTableView * listView;
QStandardItemModel * table;
QSortFilterProxyModel * proxy;
QToolBar * toolbar;
#ifdef PLAYLIST_DOUBLE_TOOLBAR
QToolBar * toolbar2;
#endif
QToolButton * file_button;
QToolButton * add_button;
QToolButton * remove_button;
MyLineEdit * filter_edit;
MyAction * openAct;
#ifdef PLAYLIST_DOWNLOAD
MyAction * openUrlAct;
#endif
MyAction * saveAct;
MyAction * saveAsAct;
MyAction * playAct;
MyAction * prevAct;
MyAction * nextAct;
MyAction * repeatAct;
MyAction * shuffleAct;
MyAction * showSearchAct;
MyAction * moveUpAct;
MyAction * moveDownAct;
MyAction * editAct;
MyAction * addCurrentAct;
MyAction * addFilesAct;
MyAction * addDirectoryAct;
MyAction * addUrlsAct;
MyAction * removeSelectedAct;
MyAction * removeAllAct;
#ifdef PLAYLIST_DELETE_FROM_DISK
MyAction * deleteSelectedFileFromDiskAct;
#endif
MyAction * copyURLAct;
MyAction * openFolderAct;
#ifdef CHROMECAST_SUPPORT
MyAction * playOnChromecastAct;
#else
MyAction * openURLInWebAct;
#endif
MyAction * showPositionColumnAct;
MyAction * showNameColumnAct;
MyAction * showDurationColumnAct;
MyAction * showFilenameColumnAct;
QSettings * set;
#ifdef PLAYLIST_DOWNLOAD
LoadPage * downloader;
URLHistory * history_urls;
QMovie * animation;
QAction * loading_label_action;
#endif
private:
bool modified;
QTimer * save_timer;
//Preferences
bool recursive_add_directory;
bool automatically_get_info;
bool save_playlist_in_config;
bool play_files_from_start;
int row_spacing;
bool start_play_on_load;
bool automatically_play_next;
bool ignore_player_errors;
bool change_name;
bool save_dirs;
#ifdef PLAYLIST_DELETE_FROM_DISK
bool allow_delete_from_disk;
#endif
};
#endif
|