bug: fixing insertion bugs of many items
Videos, images, and presentations were all look at the wrong index. I needed to look for the count - 1 in order to find the right index from the model when switching to the editMode
This commit is contained in:
parent
085ede2e04
commit
4dc4036dda
2 changed files with 116 additions and 98 deletions
|
@ -291,28 +291,48 @@ Item {
|
|||
}
|
||||
onExited: overlay = false
|
||||
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: fileDropOverlay
|
||||
color: overlay ? Kirigami.Theme.highlightColor : "#00000000"
|
||||
anchors.fill: parent
|
||||
border.width: 8
|
||||
border.color: overlay ? Kirigami.Theme.hoverColor : "#00000000"
|
||||
}
|
||||
|
||||
// used for detecting number of pages without the need for PoDoFo
|
||||
PdfDocument {
|
||||
id: pdf
|
||||
}
|
||||
|
||||
WebEngineView {
|
||||
id: web
|
||||
height: 0
|
||||
width: 0
|
||||
onLoadingChanged: {
|
||||
if (loadRequest.status == 2)
|
||||
addHtml(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function addVideo(url) {
|
||||
videoProxyModel.videoModel.newItem(url);
|
||||
selectedLibrary = "video";
|
||||
videoLibrary.libraryList.currentIndex = videoProxyModel.videoModel.count();
|
||||
console.log(videoProxyModel.getVideo(videoLibrary.libraryList.currentIndex));
|
||||
const video = videoProxyModel.getVideo(videoLibrary.libraryList.currentIndex);
|
||||
showPassiveNotification("newest video: " + video.title);
|
||||
videoLibrary.libraryList.currentIndex = videoProxyModel.videoModel.count() - 1;
|
||||
if (!editMode)
|
||||
editMode = true;
|
||||
editSwitch(video, "video");
|
||||
editSwitch(videoLibrary.libraryList.currentIndex, "video");
|
||||
}
|
||||
|
||||
function addImg(url) {
|
||||
imageProxyModel.newItem(url);
|
||||
selectedLibrary = "image";
|
||||
imageLibrary.libraryList.currentIndex = imageProxyModel.imageModel.count();
|
||||
console.log(imageProxyModel.getImage(imageLibrary.libraryList.currentIndex));
|
||||
const image = imageProxyModel.getImage(imageLibrary.libraryList.currentIndex);
|
||||
showPassiveNotification("newest image: " + image.title);
|
||||
imageLibrary.libraryList.currentIndex = imageProxyModel.imageModel.count() - 1;
|
||||
if (!editMode)
|
||||
editMode = true;
|
||||
editSwitch(image, "image");
|
||||
editSwitch(imageLibrary.libraryList.currentIndex, "image");
|
||||
}
|
||||
|
||||
function addPres(url) {
|
||||
|
@ -326,13 +346,10 @@ Item {
|
|||
}
|
||||
presProxyModel.presentationModel.newItem(url, pageCount);
|
||||
selectedLibrary = "presentation";
|
||||
presentationLibrary.libraryList.currentIndex = presProxyModel.presentationModel.count();
|
||||
console.log(presProxyModel.getPresentation(presentationLibrary.libraryList.currentIndex));
|
||||
const presentation = presProxyModel.getPresentation(presentationLibrary.libraryList.currentIndex);
|
||||
showPassiveNotification("newest image: " + presentation.title);
|
||||
presentationLibrary.libraryList.currentIndex = presProxyModel.presentationModel.count() - 1;
|
||||
if (!editMode)
|
||||
editMode = true;
|
||||
editSwitch(presentation, "presentation");
|
||||
editSwitch(presentationLibrary.libraryList.currentIndex, "presentation");
|
||||
pdf.source = "";
|
||||
}
|
||||
|
||||
|
@ -389,31 +406,6 @@ Item {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: fileDropOverlay
|
||||
color: overlay ? Kirigami.Theme.highlightColor : "#00000000"
|
||||
anchors.fill: parent
|
||||
border.width: 8
|
||||
border.color: overlay ? Kirigami.Theme.hoverColor : "#00000000"
|
||||
}
|
||||
|
||||
// used for detecting number of pages without the need for PoDoFo
|
||||
PdfDocument {
|
||||
id: pdf
|
||||
}
|
||||
|
||||
WebEngineView {
|
||||
id: web
|
||||
height: 0
|
||||
width: 0
|
||||
onLoadingChanged: {
|
||||
if (loadRequest.status == 2)
|
||||
addHtml(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function addHtml(url) {
|
||||
console.log("adding an html");
|
||||
|
|
|
@ -36,6 +36,14 @@ Kirigami.OverlaySheet {
|
|||
text: ""
|
||||
onEditingFinished: videoInput.text.startsWith("http") ? loadVideo() : showPassiveNotification("Coach called, this isn't it.");
|
||||
}
|
||||
|
||||
Controls.ToolButton {
|
||||
id: localButton
|
||||
text: "Local Video"
|
||||
icon.name: "fileopen"
|
||||
hoverEnabled: true
|
||||
onClicked: videoFileDialog.open()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,6 +125,24 @@ Kirigami.OverlaySheet {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
FileDialog {
|
||||
id: videoFileDialog
|
||||
title: "Please choose a video"
|
||||
folder: shortcuts.home
|
||||
selectMultiple: false
|
||||
nameFilters: ["Video files (*.mp4 *.mkv *.mov *.wmv *.avi *.MP4 *.MOV *.MKV)"]
|
||||
onAccepted: {
|
||||
console.log("video = " + videoFileDialog.fileUrls[0]);
|
||||
addVideo(videoFileDialog.fileUrls[0]);
|
||||
root.close();
|
||||
}
|
||||
onRejected: {
|
||||
console.log("Canceled")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function loadVideo() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue