1 /* 2 * Cantata 3 * 4 * Copyright (c) 2011-2020 Craig Drummond <craig.p.drummond@gmail.com> 5 * 6 * ---- 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; see the file COPYING. If not, write to 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 21 * Boston, MA 02110-1301, USA. 22 */ 23 24 #ifndef PLAYQUEUEVIEW_H 25 #define PLAYQUEUEVIEW_H 26 27 #include <QStackedWidget> 28 #include <QAbstractItemView> 29 #include <QSet> 30 #include <QPixmap> 31 #include <QImage> 32 #include <QPropertyAnimation> 33 #include <QPainter> 34 #include "tableview.h" 35 #include "listview.h" 36 #include "groupedview.h" 37 #include "mpd-interface/song.h" 38 #include "itemview.h" 39 40 class QAbstractItemModel; 41 class QAction; 42 class Action; 43 class QItemSelectionModel; 44 class QModelIndex; 45 class Spinner; 46 class PlayQueueView; 47 class MessageOverlay; 48 49 class PlayQueueTreeView : public TableView 50 { 51 public: 52 PlayQueueTreeView(PlayQueueView *p); ~PlayQueueTreeView()53 ~PlayQueueTreeView() override { } 54 void paintEvent(QPaintEvent *e) override; 55 private: 56 PlayQueueView *view; 57 }; 58 59 class PlayQueueGroupedView : public GroupedView 60 { 61 public: 62 PlayQueueGroupedView(PlayQueueView *p); 63 ~PlayQueueGroupedView() override; 64 void paintEvent(QPaintEvent *e) override; 65 private: 66 PlayQueueView *view; 67 }; 68 69 class PlayQueueView : public QStackedWidget 70 { 71 Q_OBJECT 72 Q_PROPERTY(float fade READ fade WRITE setFade) 73 74 public: 75 enum BackgroundImage { 76 BI_None, 77 BI_Cover, 78 BI_Custom 79 }; 80 81 PlayQueueView(QWidget *parent=nullptr); 82 ~PlayQueueView() override; 83 84 void readConfig(); 85 void saveConfig(); 86 void saveHeader(); 87 void setMode(ItemView::Mode m); isGrouped()88 bool isGrouped() const { return ItemView::Mode_GroupedTree==mode; } 89 void setAutoExpand(bool ae); 90 bool isAutoExpand() const; 91 void setStartClosed(bool sc); 92 bool isStartClosed() const; 93 void setFilterActive(bool f); 94 void updateRows(qint32 row, quint16 curAlbum, bool scroll, bool forceScroll=false); 95 void scrollTo(const QModelIndex &index, QAbstractItemView::ScrollHint hint); 96 QModelIndex indexAt(const QPoint &point); setModel(QAbstractItemModel * m)97 void setModel(QAbstractItemModel *m) { view()->setModel(m); } 98 void addAction(QAction *a); 99 void setFocus(); 100 bool hasFocus(); model()101 QAbstractItemModel * model() { return view()->model(); } 102 bool haveSelectedItems(); 103 bool haveUnSelectedItems(); setCurrentIndex(const QModelIndex & idx)104 void setCurrentIndex(const QModelIndex &idx) { view()->setCurrentIndex(idx); } 105 void clearSelection(); 106 QAbstractItemView * view() const; 107 bool hasFocus() const; 108 QModelIndexList selectedIndexes(bool sorted=true) const; 109 QList<Song> selectedSongs() const; fade()110 float fade() { return fadeValue; } 111 void setFade(float value); 112 void updatePalette(); removeFromAct()113 Action * removeFromAct() { return removeFromAction; } 114 115 public Q_SLOTS: 116 void showSpinner(); 117 void hideSpinner(); 118 void setImage(const QImage &img); 119 void streamFetchStatus(const QString &msg); 120 void searchActive(bool a); 121 122 Q_SIGNALS: 123 void itemsSelected(bool); 124 void doubleClicked(const QModelIndex &); 125 void cancelStreamFetch(); 126 void focusSearch(const QString &text); 127 128 private: 129 void drawBackdrop(QWidget *widget, const QSize &size); 130 131 private: 132 Action *removeFromAction; 133 ItemView::Mode mode; 134 PlayQueueGroupedView *groupedView; 135 PlayQueueTreeView *treeView; 136 Spinner *spinner; 137 MessageOverlay *msgOverlay; 138 139 BackgroundImage backgroundImageType; 140 QPropertyAnimation animator; 141 QImage curentCover; 142 QPixmap curentBackground; 143 QPixmap previousBackground; 144 QSize lastBgndSize; 145 double fadeValue; 146 int backgroundOpacity; 147 int backgroundBlur; 148 QString customBackgroundFile; 149 friend class PlayQueueGroupedView; 150 friend class PlayQueueTreeView; 151 }; 152 153 #endif 154