some initial setup to get the service_item_model.rs working
This commit is contained in:
parent
2df4c646a7
commit
d61da6f09f
3 changed files with 35 additions and 13 deletions
14
src/main.cpp
14
src/main.cpp
|
@ -148,7 +148,7 @@ int main(int argc, char *argv[])
|
|||
QScopedPointer<SlideyMod> slideMod(new SlideyMod);
|
||||
QScopedPointer<File> filemanager(new File);
|
||||
// QScopedPointer<QQuickView> preswin(new QQuickView);
|
||||
QScopedPointer<ServiceItemModel> serviceItemModel(new ServiceItemModel);
|
||||
QScopedPointer<ServiceItemMod> serviceItemModel(new ServiceItemMod);
|
||||
QScopedPointer<SlideObj> slideobject(new SlideObj);
|
||||
|
||||
Settings *settings = new Settings;
|
||||
|
@ -169,19 +169,19 @@ int main(int argc, char *argv[])
|
|||
slideModel.get(),
|
||||
SLOT(addItemFromService(const int&, const ServiceItem&)));
|
||||
QObject::connect(serviceItemModel.get(),
|
||||
&ServiceItemModel::itemAddedRust,
|
||||
&ServiceItemMod::itemAdded,
|
||||
slideMod.get(),
|
||||
&SlideyMod::addItemFromService);
|
||||
QObject::connect(serviceItemModel.get(),
|
||||
&ServiceItemModel::itemInsertedRust,
|
||||
&ServiceItemMod::itemInserted,
|
||||
slideMod.get(),
|
||||
&SlideyMod::insertItemFromService);
|
||||
QObject::connect(serviceItemModel.get(),
|
||||
&ServiceItemModel::rowMovedRust,
|
||||
&ServiceItemMod::itemMoved,
|
||||
slideMod.get(),
|
||||
&SlideyMod::moveItemFromService);
|
||||
QObject::connect(serviceItemModel.get(),
|
||||
&ServiceItemModel::rowRemovedRust,
|
||||
&ServiceItemMod::itemRemoved,
|
||||
slideMod.get(),
|
||||
&SlideyMod::removeItemFromService);
|
||||
// QObject::connect(serviceItemModel.get(),
|
||||
|
@ -193,12 +193,12 @@ int main(int argc, char *argv[])
|
|||
slideMod.get(),
|
||||
SLOT(activate(int)));
|
||||
|
||||
if (!serviceItemModel.get()->loadLastSaved()) {
|
||||
if (!serviceItemModel.get()->load(settings->getLastSaveFile())) {
|
||||
qDebug() << "Last saved file is missing or there isn't a last saved file.";
|
||||
serviceItemModel.get()->addItem("Black", "image",
|
||||
"qrc:/assets/black.jpg",
|
||||
"image", QStringList(""),
|
||||
"", "", 0, 1, false);
|
||||
"", "", 0, 1, false, 0, 0);
|
||||
}
|
||||
|
||||
// apparently mpv needs this class set
|
||||
|
|
|
@ -95,9 +95,21 @@ mod service_item_model {
|
|||
SelectedChanged,
|
||||
ItemInserted {
|
||||
index: &'a i32,
|
||||
item: &'a QMap_QString_QVariant,
|
||||
},
|
||||
ItemAdded {
|
||||
index: &'a i32,
|
||||
item: &'a QMap_QString_QVariant,
|
||||
},
|
||||
ItemRemoved {
|
||||
index: &'a i32,
|
||||
item: &'a QMap_QString_QVariant,
|
||||
},
|
||||
ItemMoved {
|
||||
source_index: &'a i32,
|
||||
dest_index: &'a i32,
|
||||
// index: &'a i32,
|
||||
item: &'a QMap_QString_QVariant,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -120,7 +132,11 @@ mod service_item_model {
|
|||
|
||||
// use crate::video_thumbnail;
|
||||
// use image::{ImageBuffer, Rgba};
|
||||
use std::path::PathBuf;
|
||||
use dirs;
|
||||
use std::fs;
|
||||
use std::io::{self, Write};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::str;
|
||||
impl qobject::ServiceItemMod {
|
||||
#[qinvokable]
|
||||
pub fn clear(mut self: Pin<&mut Self>) {
|
||||
|
@ -150,9 +166,9 @@ mod service_item_model {
|
|||
mut self: Pin<&mut Self>,
|
||||
name: QString,
|
||||
ty: QString,
|
||||
text: QStringList,
|
||||
background: QString,
|
||||
background_type: QString,
|
||||
text: QStringList,
|
||||
audio: QString,
|
||||
font: QString,
|
||||
font_size: i32,
|
||||
|
@ -333,7 +349,11 @@ mod service_item_model {
|
|||
|
||||
#[qinvokable]
|
||||
pub fn load(mut self: Pin<&mut Self>, file: QUrl) -> bool {
|
||||
todo!();
|
||||
// todo!();
|
||||
println!("THE LAST SAVE FILE ISSSSS: {file}");
|
||||
let lf = PathBuf::from(file.to_local_file().unwrap_or_default().to_string());
|
||||
println!("{:?}", lf);
|
||||
false
|
||||
}
|
||||
|
||||
#[qinvokable]
|
||||
|
|
|
@ -7,6 +7,8 @@ mod settings {
|
|||
unsafe extern "C++" {
|
||||
include!("cxx-qt-lib/qstring.h");
|
||||
type QString = cxx_qt_lib::QString;
|
||||
include!("cxx-qt-lib/qurl.h");
|
||||
type QUrl = cxx_qt_lib::QUrl;
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
@ -17,7 +19,7 @@ mod settings {
|
|||
#[qproperty]
|
||||
sound_effect: QString,
|
||||
#[qproperty]
|
||||
last_save_file: QString,
|
||||
last_save_file: QUrl,
|
||||
}
|
||||
|
||||
impl Default for Settings {
|
||||
|
@ -25,7 +27,7 @@ mod settings {
|
|||
Self {
|
||||
screen: QString::from(""),
|
||||
sound_effect: QString::from(""),
|
||||
last_save_file: QString::from(""),
|
||||
last_save_file: QUrl::from(""),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +56,7 @@ mod settings {
|
|||
let sf = config.get("General", "lastSaveFile");
|
||||
println!("{:?}", sf);
|
||||
if let Some(s) = sf {
|
||||
self.set_last_save_file(QString::from(&s));
|
||||
self.set_last_save_file(QUrl::from(&s));
|
||||
println!("{s}");
|
||||
} else {
|
||||
println!("error loading last save file");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue