attempting to modernize the VideoEditor.qml
This commit is contained in:
parent
1a9b7b0bd7
commit
90f551edff
3 changed files with 109 additions and 107 deletions
|
@ -268,7 +268,7 @@ void MpvObject::doUpdate()
|
||||||
|
|
||||||
void MpvObject::command(const QVariant& params)
|
void MpvObject::command(const QVariant& params)
|
||||||
{
|
{
|
||||||
qDebug() << params;
|
// qDebug() << params;
|
||||||
mpv::qt::command(mpv, params);
|
mpv::qt::command(mpv, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,9 @@ Item {
|
||||||
RowLayout {
|
RowLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
|
Controls.Label {
|
||||||
|
text: "Title:"
|
||||||
|
}
|
||||||
Controls.TextField {
|
Controls.TextField {
|
||||||
implicitWidth: 300
|
implicitWidth: 300
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
|
@ -36,11 +39,14 @@ Item {
|
||||||
onEditingFinished: updateTitle(text);
|
onEditingFinished: updateTitle(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Controls.Label {
|
||||||
|
text: "Looping:"
|
||||||
|
Layout.leftMargin: 20
|
||||||
|
}
|
||||||
Controls.CheckBox {
|
Controls.CheckBox {
|
||||||
id: loopCheckBox
|
id: loopCheckBox
|
||||||
Layout.preferredWidth: 300
|
Layout.preferredWidth: 300
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.leftMargin: 20
|
|
||||||
Layout.rightMargin: 20
|
Layout.rightMargin: 20
|
||||||
|
|
||||||
text: "Repeat"
|
text: "Repeat"
|
||||||
|
@ -60,80 +66,44 @@ Item {
|
||||||
onClicked: {}
|
onClicked: {}
|
||||||
}
|
}
|
||||||
Controls.ToolButton {
|
Controls.ToolButton {
|
||||||
id: backgroundButton
|
id: fileButton
|
||||||
text: "Background"
|
text: "File"
|
||||||
icon.name: "fileopen"
|
icon.name: "fileopen"
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
onClicked: backgroundType.open()
|
onClicked: fileType.open()
|
||||||
}
|
|
||||||
|
|
||||||
Controls.Popup {
|
|
||||||
id: backgroundType
|
|
||||||
x: backgroundButton.x
|
|
||||||
y: backgroundButton.y + backgroundButton.height + 20
|
|
||||||
modal: true
|
|
||||||
focus: true
|
|
||||||
dim: false
|
|
||||||
background: Rectangle {
|
|
||||||
Kirigami.Theme.colorSet: Kirigami.Theme.Tooltip
|
|
||||||
color: Kirigami.Theme.backgroundColor
|
|
||||||
radius: 10
|
|
||||||
border.color: Kirigami.Theme.activeBackgroundColor
|
|
||||||
border.width: 2
|
|
||||||
}
|
|
||||||
closePolicy: Controls.Popup.CloseOnEscape | Controls.Popup.CloseOnPressOutsideParent
|
|
||||||
ColumnLayout {
|
|
||||||
anchors.fill: parent
|
|
||||||
Controls.ToolButton {
|
|
||||||
Layout.fillHeight: true
|
|
||||||
Layout.fillWidth: true
|
|
||||||
text: "Video"
|
|
||||||
icon.name: "emblem-videos-symbolic"
|
|
||||||
onClicked: videoFileDialog.open() & backgroundType.close()
|
|
||||||
}
|
|
||||||
Controls.ToolButton {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.fillHeight: true
|
|
||||||
text: "Image"
|
|
||||||
icon.name: "folder-pictures-symbolic"
|
|
||||||
onClicked: imageFileDialog.open() & backgroundType.close()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: topEmpty
|
|
||||||
Layout.preferredHeight: 50
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.columnSpan: 2
|
Layout.columnSpan: 2
|
||||||
}
|
Layout.preferredWidth: root.width - 50
|
||||||
|
Layout.preferredHeight: Layout.preferredWidth / 16 * 9
|
||||||
|
Layout.alignment: Qt.AlignCenter
|
||||||
|
Layout.topMargin: 10
|
||||||
|
|
||||||
MpvObject {
|
MpvObject {
|
||||||
id: videoPreview
|
id: videoPreview
|
||||||
|
width: parent.width
|
||||||
|
height: parent.height
|
||||||
objectName: "mpv"
|
objectName: "mpv"
|
||||||
Layout.columnSpan: 2
|
|
||||||
Layout.preferredWidth: 600
|
|
||||||
Layout.preferredHeight: Layout.preferredWidth / 16 * 9
|
|
||||||
Layout.alignment: Qt.AlignCenter
|
|
||||||
useHwdec: true
|
useHwdec: true
|
||||||
enableAudio: audioOn
|
enableAudio: audioOn
|
||||||
Component.onCompleted: mpvLoadingTimer.start()
|
Component.onCompleted: mpvLoadingTimer.start()
|
||||||
onPositionChanged: videoSlider.value = position
|
onPositionChanged: videoSlider.value = position
|
||||||
onFileLoaded: {
|
onFileLoaded: {
|
||||||
showPassiveNotification(video.title + " has been loaded");
|
/* showPassiveNotification(video.title + " has been loaded"); */
|
||||||
videoPreview.pause();
|
videoPreview.pause();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: videoBg
|
id: videoBg
|
||||||
color: Kirigami.Theme.alternateBackgroundColor
|
color: Kirigami.Theme.alternateBackgroundColor
|
||||||
|
|
||||||
Layout.columnSpan: 2
|
anchors.top: videoPreview.bottom
|
||||||
Layout.preferredWidth: videoPreview.Layout.preferredWidth
|
width: parent.width
|
||||||
Layout.preferredHeight: videoTitleField.height
|
height: videoTitleField.height
|
||||||
Layout.alignment: Qt.AlignHCenter
|
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
@ -158,13 +128,14 @@ Item {
|
||||||
live: true
|
live: true
|
||||||
onMoved: videoPreview.seek(value);
|
onMoved: videoPreview.seek(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Controls.Label {
|
||||||
|
id: videoTime
|
||||||
|
text: new Date(videoPreview.position * 1000).toISOString().slice(11, 19);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
|
||||||
Layout.columnSpan: 2
|
|
||||||
Layout.preferredHeight: 60
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Controls.RangeSlider {
|
Controls.RangeSlider {
|
||||||
|
@ -174,14 +145,17 @@ Item {
|
||||||
Layout.preferredWidth: videoPreview.Layout.preferredWidth
|
Layout.preferredWidth: videoPreview.Layout.preferredWidth
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
Layout.leftMargin: width / 3
|
Layout.leftMargin: 25
|
||||||
Layout.rightMargin: width / 3
|
Layout.rightMargin: 25
|
||||||
|
Layout.topMargin: 50
|
||||||
|
|
||||||
to: videoPreview.duration
|
to: videoPreview.duration
|
||||||
from: 0
|
from: 0
|
||||||
|
stepSize: 0.5
|
||||||
|
snapMode: Controls.RangeSlider.SnapAlways
|
||||||
|
|
||||||
first.value: 0
|
first.value: video.startTime
|
||||||
second.value: to
|
second.value: video.endTime
|
||||||
|
|
||||||
first.onMoved: updateStartTime(first.value)
|
first.onMoved: updateStartTime(first.value)
|
||||||
second.onMoved: updateEndTime(second.value)
|
second.onMoved: updateEndTime(second.value)
|
||||||
|
@ -200,6 +174,11 @@ Item {
|
||||||
text: "End Time: " + videoLengthSlider.second.value
|
text: "End Time: " + videoLengthSlider.second.value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Controls.ToolButton {
|
||||||
|
text: "FIX"
|
||||||
|
onClicked: videoLengthSlider.setValues(video.startTime, video.endTime)
|
||||||
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: botEmpty
|
id: botEmpty
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
|
@ -210,7 +189,7 @@ Item {
|
||||||
Layout.alignment: Qt.AlignBottom
|
Layout.alignment: Qt.AlignBottom
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.columnSpan: 2
|
Layout.columnSpan: 2
|
||||||
text: video.filePath
|
text: "File path: " + video.filePath
|
||||||
background: Item{}
|
background: Item{}
|
||||||
readOnly: true
|
readOnly: true
|
||||||
HoverHandler {
|
HoverHandler {
|
||||||
|
@ -227,6 +206,7 @@ Item {
|
||||||
interval: 100
|
interval: 100
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
videoPreview.loadFile(video.filePath.toString());
|
videoPreview.loadFile(video.filePath.toString());
|
||||||
|
videoLengthSlider.setValues(video.startTime, video.endTime);
|
||||||
/* showPassiveNotification(video[0]); */
|
/* showPassiveNotification(video[0]); */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -234,7 +214,10 @@ Item {
|
||||||
function changeVideo(index) {
|
function changeVideo(index) {
|
||||||
let vid = videoProxyModel.getVideo(index);
|
let vid = videoProxyModel.getVideo(index);
|
||||||
root.video = vid;
|
root.video = vid;
|
||||||
|
console.log(video.startTime);
|
||||||
|
console.log(video.endTime);
|
||||||
mpvLoadingTimer.restart();
|
mpvLoadingTimer.restart();
|
||||||
|
videoLengthSlider.setValues(vid.startTime, vid.endTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
function stop() {
|
function stop() {
|
||||||
|
@ -244,30 +227,31 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateEndTime(value) {
|
function updateEndTime(value) {
|
||||||
/* changeStartTime(value, false); */
|
videoPreview.seek(value);
|
||||||
videoProxyModel.updateEndTime(video.id, value);
|
videoProxyModel.updateEndTime(video.id, value);
|
||||||
video.endTime = value;
|
video.endTime = value;
|
||||||
showPassiveNotification(video.endTime);
|
/* showPassiveNotification(video.endTime); */
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateStartTime(value) {
|
function updateStartTime(value) {
|
||||||
/* changeStartTime(value, false); */
|
/* changeStartTime(value, false); */
|
||||||
|
videoPreview.seek(value);
|
||||||
videoProxyModel.updateStartTime(video.id, value);
|
videoProxyModel.updateStartTime(video.id, value);
|
||||||
video.startTime = value;
|
video.startTime = value;
|
||||||
showPassiveNotification(video.startTime);
|
/* showPassiveNotification(value); */
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateTitle(text) {
|
function updateTitle(text) {
|
||||||
changeTitle(text, false);
|
changeTitle(text, false);
|
||||||
videoProxyModel.updateTitle(video.id, text);
|
videoProxyModel.updateTitle(video.id, text);
|
||||||
showPassiveNotification(video.title);
|
/* showPassiveNotification(video.title); */
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateLoop(value) {
|
function updateLoop(value) {
|
||||||
/* changeStartTime(value, false); */
|
/* changeStartTime(value, false); */
|
||||||
let bool = videoProxyModel.updateLoop(video.id, value);
|
let bool = videoProxyModel.updateLoop(video.id, value);
|
||||||
video.loop = value;
|
video.loop = value;
|
||||||
showPassiveNotification("Loop changed to: " + video.loop);
|
/* showPassiveNotification("Loop changed to: " + video.loop); */
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeTitle(text, updateBox) {
|
function changeTitle(text, updateBox) {
|
||||||
|
|
|
@ -301,8 +301,14 @@ mod video_model {
|
||||||
.execute(db);
|
.execute(db);
|
||||||
match result {
|
match result {
|
||||||
Ok(_i) => {
|
Ok(_i) => {
|
||||||
let video = self.as_mut().videos_mut().get_mut(index as usize).unwrap();
|
for video in self
|
||||||
|
.as_mut()
|
||||||
|
.videos_mut()
|
||||||
|
.iter_mut()
|
||||||
|
.filter(|x| x.id == index)
|
||||||
|
{
|
||||||
video.end_time = updated_end_time.clone();
|
video.end_time = updated_end_time.clone();
|
||||||
|
}
|
||||||
self.as_mut()
|
self.as_mut()
|
||||||
.emit_data_changed(model_index, model_index, &vector_roles);
|
.emit_data_changed(model_index, model_index, &vector_roles);
|
||||||
println!("rust-end-time: {:?}", updated_end_time);
|
println!("rust-end-time: {:?}", updated_end_time);
|
||||||
|
@ -328,8 +334,14 @@ mod video_model {
|
||||||
.execute(db);
|
.execute(db);
|
||||||
match result {
|
match result {
|
||||||
Ok(_i) => {
|
Ok(_i) => {
|
||||||
let video = self.as_mut().videos_mut().get_mut(index as usize).unwrap();
|
for video in self
|
||||||
|
.as_mut()
|
||||||
|
.videos_mut()
|
||||||
|
.iter_mut()
|
||||||
|
.filter(|x| x.id == index)
|
||||||
|
{
|
||||||
video.start_time = updated_start_time.clone();
|
video.start_time = updated_start_time.clone();
|
||||||
|
}
|
||||||
self.as_mut()
|
self.as_mut()
|
||||||
.emit_data_changed(model_index, model_index, &vector_roles);
|
.emit_data_changed(model_index, model_index, &vector_roles);
|
||||||
println!("rust-start-time: {:?}", updated_start_time);
|
println!("rust-start-time: {:?}", updated_start_time);
|
||||||
|
@ -351,8 +363,14 @@ mod video_model {
|
||||||
.execute(db);
|
.execute(db);
|
||||||
match result {
|
match result {
|
||||||
Ok(_i) => {
|
Ok(_i) => {
|
||||||
let video = self.as_mut().videos_mut().get_mut(index as usize).unwrap();
|
for video in self
|
||||||
|
.as_mut()
|
||||||
|
.videos_mut()
|
||||||
|
.iter_mut()
|
||||||
|
.filter(|x| x.id == index)
|
||||||
|
{
|
||||||
video.title = updated_title.clone();
|
video.title = updated_title.clone();
|
||||||
|
}
|
||||||
self.as_mut()
|
self.as_mut()
|
||||||
.emit_data_changed(model_index, model_index, &vector_roles);
|
.emit_data_changed(model_index, model_index, &vector_roles);
|
||||||
println!("rust-title: {:?}", updated_title);
|
println!("rust-title: {:?}", updated_title);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue