From a1f18f803d2b2dbc91255326cc27152838abe1b4 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Thu, 12 Sep 2024 11:19:03 -0500 Subject: [PATCH] things are building and running now Now for all the issues of things not working --- justfile | 5 +- src/main.cpp | 33 +------------ src/qml/main.qml | 6 +-- src/qml/presenter/LibraryItem.qml | 77 ++++++++++++++++--------------- src/qml/presenter/MainWindow.qml | 10 ++-- src/qml/presenter/NewVideo.qml | 21 +-------- src/qml/presenter/ServiceList.qml | 19 ++------ src/rust/service_item_model.rs | 10 ++-- 8 files changed, 66 insertions(+), 115 deletions(-) diff --git a/justfile b/justfile index bc39438..fff41ce 100644 --- a/justfile +++ b/justfile @@ -12,4 +12,7 @@ clean: cargo clean rm -rf bld/ test: - RUST_LOG=debug cargo test --benches --tests --all-features -- --nocapture \ No newline at end of file + RUST_LOG=debug cargo test --benches --tests --all-features -- --nocapture + +alias b := build +alias r := run diff --git a/src/main.cpp b/src/main.cpp index ab32b5b..084d60d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -73,37 +73,6 @@ static QWindow *windowFromEngine(QQmlApplicationEngine *engine) return window; } -// static void connectToDatabase() { -// // let's setup our sql database -// QSqlDatabase db = QSqlDatabase::database(); -// if (!db.isValid()){ -// db = QSqlDatabase::addDatabase("QSQLITE"); -// if (!db.isValid()) -// qFatal("Cannot add database: %s", qPrintable(db.lastError().text())); -// } - -// const QDir writeDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); -// qDebug() << "dir location " << writeDir.absolutePath(); - -// if (!writeDir.mkpath(".")) { -// qFatal("Failed to create writable location at %s", qPrintable(writeDir.absolutePath())); -// } - -// const QString dbName = writeDir.absolutePath() + "/library-db.sqlite3"; - -// db.setHostName("localhost"); -// db.setDatabaseName(dbName); -// db.setUserName("presenter"); -// // TODO change password system before launch -// db.setPassword("i393jkf782djyr98302j"); -// if (!db.open()) { -// qFatal("Cannot open database: %s", qPrintable(db.lastError().text())); -// QFile::remove(dbName); -// } -// qDebug() << "Finished connecting to db"; - -// } - int main(int argc, char *argv[]) { // qDebug() << QSurfaceFormat::defaultFormat(); @@ -224,6 +193,8 @@ int main(int argc, char *argv[]) // qmlRegisterType("mpv", 1, 0, "MpvItem"); // qmlRegisterSingletonInstance("org.presenter", 1, 0, "MpvProperties", MpvProperties::self()); + qDebug() << serviceItemModel.count; + //register our models // qmlRegisterType("org.presenter", 1, 0, "SongProxyModel"); // qmlRegisterType("org.presenter", 1, 0, "VideoProxyModel"); diff --git a/src/qml/main.qml b/src/qml/main.qml index a7d61f7..a838537 100644 --- a/src/qml/main.qml +++ b/src/qml/main.qml @@ -203,7 +203,7 @@ Kirigami.ApplicationWindow { folder: shortcuts.home /* fileMode: Labs.FileDialog.SaveFile */ defaultSuffix: ".pres" - selectExisting: false + /* selectExisting: false */ onAccepted: { ServiceItemModel.save(saveFileDialog.fileUrl); console.log(saveFileDialog.fileUrl); @@ -223,7 +223,7 @@ Kirigami.ApplicationWindow { folder: shortcuts.home /* fileMode: Labs.FileDialog.SaveFile */ defaultSuffix: ".pres" - selectExisting: true + /* selectExisting: true */ onAccepted: { load(loadFileDialog.fileUrl); } @@ -237,7 +237,7 @@ Kirigami.ApplicationWindow { title: "Pick a Sound Effect" folder: shortcuts.home /* fileMode: Labs.FileDialog.SaveFile */ - selectExisting: true + /* selectExisting: true */ onAccepted: { soundEffect = loadFileDialog.fileUrl; showPassiveNotification(soundEffect); diff --git a/src/qml/presenter/LibraryItem.qml b/src/qml/presenter/LibraryItem.qml index c699728..78e1aa4 100644 --- a/src/qml/presenter/LibraryItem.qml +++ b/src/qml/presenter/LibraryItem.qml @@ -222,7 +222,7 @@ ColumnLayout { Item { implicitWidth: ListView.view.width height: selectedLibrary == libraryType ? 50 : 0 - Kirigami.BasicListItem { + Controls.ItemDelegate { id: listItem property bool rightMenu: false @@ -236,43 +236,48 @@ ColumnLayout { implicitWidth: libraryList.width height: selectedLibrary == libraryType ? 50 : 0 - clip: true - label: title - subtitle: { - if (libraryType == "song") - author - else if (fileValidation) - filePath; - else - "file is missing" - } - icon: itemIcon - iconSize: Kirigami.Units.gridUnit - supportsMouseEvents: false - backgroundColor: index % 2 === 0 ? Kirigami.Theme.backgroundColor : Kirigami.Theme.alternateBackgroundColor; - Binding on backgroundColor { - when: dragHandler.containsMouse || - (selectionModel.hasSelection && - selectionModel.isSelected(proxyModel.idx(index))) - value: Kirigami.Theme.highlightColor - } + text: title + + /* subtitle: { */ + /* if (libraryType == "song") */ + /* author */ + /* else if (fileValidation) */ + /* filePath; */ + /* else */ + /* "file is missing" */ + /* } */ - textColor: { - if (selectedLibrary == "song") - Kirigami.Theme.textColor; - else if (fileValidation) { - Kirigami.Theme.textColor; - } - else - "red" - } + icon.source: itemIcon + icon.width: Kirigami.Units.gridUnit + icon.height: Kirigami.Units.gridUnit + /* supportsMouseEvents: false */ + /* background: Rectangle { */ + /* color: Kirigami.Theme.backgroundColor */ + /* fill: parent */ + /* } */ + /* Binding on backgroundColor { */ + /* when: dragHandler.containsMouse || */ + /* (selectionModel.hasSelection && */ + /* selectionModel.isSelected(proxyModel.idx(index))) */ + /* value: Kirigami.Theme.highlightColor */ + /* } */ - Binding on textColor { - when: dragHandler.containsMouse || - (selectionModel.hasSelection && - selectionModel.isSelected(proxyModel.idx(index))) - value: Kirigami.Theme.highlightedTextColor - } + /* textColor: { */ + /* if (selectedLibrary == "song") */ + /* Kirigami.Theme.textColor; */ + /* else if (fileValidation) { */ + /* Kirigami.Theme.textColor; */ + /* } */ + /* else */ + /* "red" */ + /* } */ + + /* Binding on textColor { */ + /* when: dragHandler.containsMouse || */ + /* (selectionModel.hasSelection && */ + /* selectionModel.isSelected(proxyModel.idx(index))) */ + /* value: Kirigami.Theme.highlightedTextColor */ + /* } */ Behavior on height { NumberAnimation { diff --git a/src/qml/presenter/MainWindow.qml b/src/qml/presenter/MainWindow.qml index 696a693..d94ab96 100644 --- a/src/qml/presenter/MainWindow.qml +++ b/src/qml/presenter/MainWindow.qml @@ -14,7 +14,7 @@ Controls.Page { // properties passed around for the slides property int currentServiceItem property int currentSlide - property int totalServiceItems: ServiceItemModel.rowCount + property int totalServiceItems: ServiceItemModel.rowCount() property int totalSlides: SlideModel.count property url imageBackground: presentation.imageBackground property url videoBackground: presentation.vidBackground @@ -155,10 +155,10 @@ Controls.Page { anchors.left: parent.right url: "file:///home/chris/org/lessons/2023_24_3_noah_lesson.html" visible: false - WebEngineScript { - name: "html2canvas" - sourceUrl: "file:///home/chris/dev/lumina/src/qml/presenter/html2canvas.min.js" - } + /* WebEngineScript { */ + /* name: "html2canvas" */ + /* sourceUrl: "file:///home/chris/dev/lumina/src/qml/presenter/html2canvas.min.js" */ + /* } */ onLoadingChanged: { if (loadRequest.status == 2) showPassiveNotification("yahoo?"); diff --git a/src/qml/presenter/NewVideo.qml b/src/qml/presenter/NewVideo.qml index f84ea16..2d710df 100644 --- a/src/qml/presenter/NewVideo.qml +++ b/src/qml/presenter/NewVideo.qml @@ -1,7 +1,7 @@ import QtQuick 2.15 import QtQuick.Controls 2.15 as Controls import QtQuick.Layouts 1.15 -import QtGraphicalEffects 1.15 +import Qt5Compat.GraphicalEffects import org.kde.kirigami 2.13 as Kirigami import "./" as Presenter import org.presenter 1.0 @@ -42,7 +42,7 @@ Kirigami.OverlaySheet { text: videoInput.text.startsWith("http") ? "Download" : "Local Video" icon.name: "folder-videos-symbolic" hoverEnabled: true - onClicked: videoInput.text.startsWith("http") ? loadVideo() : videoFileDialog.open() + onClicked: videoInput.text.startsWith("http") ? loadVideo() : addVideo(fileHelper.load("Pick a video", "video")); } } } @@ -134,23 +134,6 @@ 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") - } - - } - Timer { id: videoDLTimer interval: 3000 diff --git a/src/qml/presenter/ServiceList.qml b/src/qml/presenter/ServiceList.qml index 36bd6a0..6f0835b 100644 --- a/src/qml/presenter/ServiceList.qml +++ b/src/qml/presenter/ServiceList.qml @@ -81,6 +81,7 @@ Item { id: serviceListItem implicitWidth: serviceItemList.width height: Kirigami.Units.gridUnit * 2 + Component.onCompleted: Utils.dbg("SERVICEMODEL: " + name) property var selectedItems @@ -150,6 +151,7 @@ Item { else Kirigami.Theme.textColor; } + Component.onCompleted: Utils.dbg("SERVICEMODEL: " + name) } Kirigami.Icon { @@ -359,6 +361,7 @@ Item { model: ServiceItemModel delegate: serviceListItem + Kirigami.WheelHandler { id: wheelHandler target: serviceItemList @@ -375,22 +378,6 @@ Item { anchors.bottom: serviceItemList.bottom active: hovered || pressed } - - /* function updateDrag(y) { */ - /* if (moveToIndex === serviceItemList.indexAt(0,y)) */ - /* return; */ - /* else */ - /* moveToIndex = serviceItemList.indexAt(0,y); */ - /* moveRequested(indexDragged, moveToIndex); */ - /* } */ - - /* function moveRequested(oldIndex, newIndex) { */ - /* console.log("moveRequested: ", oldIndex, newIndex); */ - /* ServiceItemModel.moveRows(oldIndex, newIndex, 1); */ - /* indexDragged = newIndex; */ - /* serviceItemList.currentIndex = newIndex; */ - /* } */ - } Rectangle { diff --git a/src/rust/service_item_model.rs b/src/rust/service_item_model.rs index 15b4124..6d0bc3a 100644 --- a/src/rust/service_item_model.rs +++ b/src/rust/service_item_model.rs @@ -479,7 +479,7 @@ impl service_item_model::ServiceItemModel { ) { let index = self.as_ref().service_items.len() as i32; println!("{:?}", service_item); - let service_item = service_item.clone(); + let s_item = service_item.clone(); let count = self.as_ref().count; self.as_mut().set_count(count + 1); unsafe { @@ -488,10 +488,11 @@ impl service_item_model::ServiceItemModel { index, index, ); - self.as_mut().rust_mut().service_items.push(service_item); + self.as_mut().rust_mut().service_items.push(s_item); self.as_mut().end_insert_rows(); } let item = self.as_mut().get_item(index); + debug!("ADDING: {:?}", &service_item); self.as_mut().item_added(&index, &item); } @@ -537,7 +538,7 @@ impl service_item_model::ServiceItemModel { service_item: &ServiceItem, id: i32, ) { - let service_item = service_item.clone(); + let s_item = service_item.clone(); unsafe { self.as_mut().begin_insert_rows( &QModelIndex::default(), @@ -547,10 +548,11 @@ impl service_item_model::ServiceItemModel { self.as_mut() .rust_mut() .service_items - .insert(id as usize, service_item); + .insert(id as usize, s_item); self.as_mut().end_insert_rows(); } let item = self.as_mut().get_item(id); + debug!("ADDING: {:?}", &service_item); self.as_mut().item_inserted(&id, &item); }