return {};
}
+int TrackModel::count() const
+{
+ return rowCount();
+}
+
void TrackModel::requestTrackChangeForRow(int row)
{
if (row < 0 || row >= rowCount())
class TrackModel : public QAbstractListModel {
Q_OBJECT
+ Q_PROPERTY(int count READ count NOTIFY countChanged STORED false)
+
public:
enum TrackRoles { TitleRole = Qt::UserRole + 1, LanguageRole, IdRole };
int rowCount(const QModelIndex &parent = QModelIndex{}) const override;
QVariant data(const QModelIndex &index, int role) const override;
+ // TODO make const or private
QString type;
+ int count() const;
+
public slots:
void requestTrackChangeForRow(int row);
int rowForTrackIndex(int trackIndex);
signals:
void trackChangeRequested(int track);
+ void countChanged(int count);
+
private:
PlayerPluginInterface::TrackList m_data;
};
<file>qml/PlaybackPosition.qml</file>
<file>qml/VolumeSlider.qml</file>
<file>qml/TextWithBackground.qml</file>
+ <file>qml/BasicButton.qml</file>
+ <file>qml/ComboButton.qml</file>
</qresource>
</RCC>
--- /dev/null
+import QtQuick 2.0
+
+Rectangle {
+ id: buttonRoot
+ property string text: ""
+ property bool checkable: false
+ property bool checked: false
+
+ signal clicked
+ signal checkedChangedByUser(bool checked)
+
+ width: label.width + 6
+ height: label.height + 6
+ color: "#0000ff"
+
+ Text {
+ id: label
+ text: {
+ if(checkable) {
+ return (checked ? "+ " : "- ") + buttonRoot.text
+ }
+ return buttonRoot.text
+ }
+
+ color: "red"
+ font.pointSize: 14
+ anchors.centerIn: parent
+ }
+
+ MouseArea {
+ id: ma
+ anchors.fill: parent
+ hoverEnabled: true
+ onEntered: buttonRoot.state = "hover"
+ onExited: buttonRoot.state = ""
+ onPressed: buttonRoot.state = "pressed"
+ onReleased: {
+ if (buttonRoot.state === "pressed") {
+ buttonRoot.clicked();
+ if (checkable) {
+ checked = !checked
+ buttonRoot.checkedChangedByUser(checked)
+ }
+ buttonRoot.state = "hover"
+ }
+ }
+ }
+
+
+ states: [
+ State {
+ name: "hover"
+ PropertyChanges {
+ target: buttonRoot
+ color: "yellow"
+ }
+ },
+ State {
+ name: "pressed"
+ PropertyChanges {
+ target: buttonRoot
+ color: "green"
+ }
+ }
+ ]
+}
+++ /dev/null
-import QtQuick 2.0
-
-Item {
- id: buttonRoot
- property alias text: label.text
-
- signal clicked
-
- width: 80
- height: label.lineHeight
-
- Text {
- id: label
- color: "red"
- font.pointSize: 24
- anchors.fill: parent
- }
- MouseArea {
- id: ma
- anchors.fill: parent
- onClicked: buttonRoot.clicked()
- }
-}
--- /dev/null
+import QtQuick 2.0
+
+BasicButton {
+ property var model: null
+ property int currentIndex: 0
+ property string textRole: null
+
+ signal activated(int index)
+
+ ListModel {
+ id: ph
+ }
+
+ text: {
+ if (!model) return "-";
+ if (textRole) return model.data(model.index(currentIndex, 0), textRole);
+ if (currentIndex) return "-";
+ return (currentIndex - 1);
+ }
+
+ onCurrentIndexChanged: {
+ console.log("idx change detected " + currentIndex);
+ }
+
+ onClicked: {
+ if (!model) return;
+ var nextIndex = currentIndex;
+ ++nextIndex;
+ if (nextIndex >= model.count)
+ nextIndex = 0;
+
+ if (nextIndex === currentIndex)
+ return;
+
+ currentIndex = nextIndex;
+ activated(currentIndex);
+ }
+}
import QtQuick 2.0
import QtQuick.Dialogs 1.2
-import QtQuick.Controls 1.4
-Button {
+BasicButton {
signal openFileRequested(string file)
text: "Open"
controlledPlayer.loadAndPlay(file)
}
}
- Button {
+ BasicButton {
id: togglePlayButton
- text: "Play"
+ text: {
+ if (controlledPlayer) {
+ return controlledPlayer.state === Player.Playing ? "Pause"
+ : "Play"
+ }
+ return "Play"
+ }
onClicked: {
+ console.log("I got clicked " + controlledPlayer.state)
if (controlledPlayer.state === Player.Stopped) {
openButton.open()
} else {
controlledPlayer.togglePlay()
}
}
- state: {
- if (!controlledPlayer) return "";
- return controlledPlayer.state === Player.Playing ? "pause" : ""
- }
- states: [
- State {
- name: "pause"
- PropertyChanges {
- target: togglePlayButton
- text: "Pause"
- }
- }
- ]
}
- Button {
+ BasicButton {
id: fullscreenButton
text: "FS"
checkable: true
}
}
}
- Button {
+ BasicButton {
id: stayOnTopButton
text: "OnTop"
enabled: !controlledWindow.isFullScreen()
}
}
}
- Button {
+ BasicButton {
id: framelessButton
text: "Frameless"
enabled: !controlledWindow.isFullScreen()
volume: controlledPlayer ? controlledPlayer.volume : 1
onVolumeChangeRequested: controlledPlayer.setVolume(volume)
}
- ComboBox {
+ ComboButton {
id: videoTracks
model: player.videoTrackModel
textRole: "text"
currentIndex: player.videoTrackModel.rowForTrackIndex(player.currentVideoTrack)
onActivated: player.videoTrackModel.requestTrackChangeForRow(index)
}
- ComboBox {
+ ComboButton {
id: audioTracks
model: player.audioTrackModel
textRole: "text"
currentIndex: player.audioTrackModel.rowForTrackIndex(player.currentAudioTrack)
onActivated: player.audioTrackModel.requestTrackChangeForRow(index)
}
- ComboBox {
+ ComboButton {
id: subtitleTracks
model: player.subtitleTrackModel
textRole: "text"