Changeset View
Changeset View
Standalone View
Standalone View
src/managemediaplayercontrol.h
Show All 40 Lines | 29 | { | |||
---|---|---|---|---|---|
41 | Q_PROPERTY(bool skipForwardControlEnabled | 41 | Q_PROPERTY(bool skipForwardControlEnabled | ||
42 | READ skipForwardControlEnabled | 42 | READ skipForwardControlEnabled | ||
43 | NOTIFY skipForwardControlEnabledChanged) | 43 | NOTIFY skipForwardControlEnabledChanged) | ||
44 | 44 | | |||
45 | Q_PROPERTY(bool musicPlaying | 45 | Q_PROPERTY(bool musicPlaying | ||
46 | READ musicPlaying | 46 | READ musicPlaying | ||
47 | NOTIFY musicPlayingChanged) | 47 | NOTIFY musicPlayingChanged) | ||
48 | 48 | | |||
49 | Q_PROPERTY(QAbstractItemModel* playListModel | 49 | Q_PROPERTY(QPersistentModelIndex previousTrack | ||
50 | READ playListModel | 50 | READ previousTrack | ||
51 | WRITE setPlayListModel | 51 | WRITE setPreviousTrack | ||
52 | NOTIFY playListModelChanged) | 52 | NOTIFY previousTrackChanged) | ||
53 | 53 | | |||
54 | Q_PROPERTY(QPersistentModelIndex currentTrack | 54 | Q_PROPERTY(QPersistentModelIndex currentTrack | ||
55 | READ currentTrack | 55 | READ currentTrack | ||
56 | WRITE setCurrentTrack | 56 | WRITE setCurrentTrack | ||
57 | NOTIFY currentTrackChanged) | 57 | NOTIFY currentTrackChanged) | ||
58 | 58 | | |||
59 | Q_PROPERTY(bool randomOrContinuePlay | 59 | Q_PROPERTY(QPersistentModelIndex nextTrack | ||
60 | READ randomOrContinuePlay | 60 | READ nextTrack | ||
61 | WRITE setRandomOrContinuePlay | 61 | WRITE setNextTrack | ||
62 | NOTIFY randomOrContinuePlayChanged) | 62 | NOTIFY nextTrackChanged) | ||
63 | 63 | | |||
64 | public: | 64 | public: | ||
65 | 65 | | |||
66 | enum class PlayerState | | |||
67 | { | | |||
68 | Playing, | | |||
69 | Paused, | | |||
70 | Stopped, | | |||
71 | }; | | |||
72 | | ||||
73 | Q_ENUM(PlayerState) | | |||
74 | | ||||
75 | explicit ManageMediaPlayerControl(QObject *parent = nullptr); | 66 | explicit ManageMediaPlayerControl(QObject *parent = nullptr); | ||
76 | 67 | | |||
77 | bool playControlEnabled() const; | 68 | bool playControlEnabled() const; | ||
78 | 69 | | |||
79 | bool skipBackwardControlEnabled() const; | 70 | bool skipBackwardControlEnabled() const; | ||
80 | 71 | | |||
81 | bool skipForwardControlEnabled() const; | 72 | bool skipForwardControlEnabled() const; | ||
82 | 73 | | |||
83 | bool musicPlaying() const; | 74 | bool musicPlaying() const; | ||
84 | 75 | | |||
85 | QAbstractItemModel* playListModel() const; | 76 | QPersistentModelIndex previousTrack() const; | ||
86 | 77 | | |||
87 | QPersistentModelIndex currentTrack() const; | 78 | QPersistentModelIndex currentTrack() const; | ||
88 | 79 | | |||
89 | bool randomOrContinuePlay() const; | 80 | QPersistentModelIndex nextTrack() const; | ||
90 | 81 | | |||
91 | Q_SIGNALS: | 82 | Q_SIGNALS: | ||
92 | 83 | | |||
93 | void playControlEnabledChanged(); | 84 | void playControlEnabledChanged(); | ||
94 | 85 | | |||
95 | void skipBackwardControlEnabledChanged(); | 86 | void skipBackwardControlEnabledChanged(); | ||
96 | 87 | | |||
97 | void skipForwardControlEnabledChanged(); | 88 | void skipForwardControlEnabledChanged(); | ||
98 | 89 | | |||
99 | void musicPlayingChanged(); | 90 | void musicPlayingChanged(); | ||
100 | 91 | | |||
101 | void playListModelChanged(); | 92 | void previousTrackChanged(); | ||
102 | 93 | | |||
103 | void currentTrackChanged(); | 94 | void currentTrackChanged(); | ||
104 | 95 | | |||
105 | void randomOrContinuePlayChanged(); | 96 | void nextTrackChanged(); | ||
106 | 97 | | |||
107 | public Q_SLOTS: | 98 | public Q_SLOTS: | ||
108 | 99 | | |||
109 | void setPlayListModel(QAbstractItemModel* aPlayListModel); | 100 | void playerPausedOrStopped(); | ||
110 | | ||||
111 | void playerPaused(); | | |||
112 | 101 | | |||
113 | void playerPlaying(); | 102 | void playerPlaying(); | ||
114 | 103 | | |||
115 | void playerStopped(); | 104 | void setPreviousTrack(const QPersistentModelIndex &previousTrack); | ||
116 | 105 | | |||
117 | void setCurrentTrack(const QPersistentModelIndex ¤tTrack); | 106 | void setCurrentTrack(const QPersistentModelIndex ¤tTrack); | ||
118 | 107 | | |||
119 | void setRandomOrContinuePlay(bool randomOrContinuePlay); | 108 | void setNextTrack(const QPersistentModelIndex &nextTrack); | ||
120 | | ||||
121 | private Q_SLOTS: | | |||
122 | | ||||
123 | void playListTracksWillBeInserted(const QModelIndex &parent, int first, int last); | | |||
124 | | ||||
125 | void playListTracksInserted(const QModelIndex &parent, int first, int last); | | |||
126 | | ||||
127 | void playListTracksWillBeRemoved(const QModelIndex & parent, int first, int last); | | |||
128 | | ||||
129 | void playListTracksRemoved(const QModelIndex & parent, int first, int last); | | |||
130 | | ||||
131 | void playListReset(); | | |||
132 | | ||||
133 | void tracksAboutToBeMoved(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row); | | |||
134 | | ||||
135 | void tracksMoved(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row); | | |||
136 | 109 | | |||
137 | private: | 110 | private: | ||
138 | 111 | | |||
139 | QAbstractItemModel *mPlayListModel = nullptr; | 112 | QPersistentModelIndex mPreviousTrack; | ||
140 | 113 | | |||
141 | QPersistentModelIndex mCurrentTrack; | 114 | QPersistentModelIndex mCurrentTrack; | ||
142 | 115 | | |||
116 | QPersistentModelIndex mNextTrack; | ||||
117 | | ||||
143 | bool mCurrentTrackWillBeRemoved = false; | 118 | bool mCurrentTrackWillBeRemoved = false; | ||
144 | 119 | | |||
145 | bool mSkipBackwardControlWasEnabled = false; | 120 | bool mSkipBackwardControlWasEnabled = false; | ||
146 | 121 | | |||
147 | bool mSkipForwardControlWasEnabled = false; | 122 | bool mSkipForwardControlWasEnabled = false; | ||
148 | 123 | | |||
149 | bool mIsInPlayingState = false; | 124 | bool mIsInPlayingState = false; | ||
150 | 125 | | |||
151 | PlayerState mPlayerState = ManageMediaPlayerControl::PlayerState::Stopped; | | |||
152 | | ||||
153 | bool mRandomOrContinuePlay = false; | | |||
154 | | ||||
155 | }; | 126 | }; | ||
156 | 127 | | |||
157 | ELISALIB_EXPORT QDataStream &operator<<(QDataStream &out, const ManageMediaPlayerControl::PlayerState &state); | | |||
158 | ELISALIB_EXPORT QDataStream &operator>>(QDataStream &in, ManageMediaPlayerControl::PlayerState &state); | | |||
159 | | ||||
160 | #endif // MANAGEMEDIAPLAYERCONTROL_H | 128 | #endif // MANAGEMEDIAPLAYERCONTROL_H |