basic function of getting all items from servicelist to save it
This commit is contained in:
parent
e4d4cfe8c3
commit
c1f0e87056
4 changed files with 43 additions and 5 deletions
|
@ -69,7 +69,7 @@ Kirigami.ApplicationWindow {
|
|||
Labs.MenuItem {
|
||||
text: qsTr("Save")
|
||||
shortcut: "Ctrl+S"
|
||||
onTriggered: save()
|
||||
onTriggered: saveFileDialog.open()
|
||||
}
|
||||
Labs.MenuItem {
|
||||
text: qsTr("Save As...")
|
||||
|
@ -101,6 +101,21 @@ Kirigami.ApplicationWindow {
|
|||
id: mainPage
|
||||
}
|
||||
|
||||
FileDialog {
|
||||
id: saveFileDialog
|
||||
title: "Save"
|
||||
folder: shortcuts.home
|
||||
/* fileMode: FileDialog.SaveFile */
|
||||
defaultSuffix: ".pres"
|
||||
selectExisting: false
|
||||
onAccepted: {
|
||||
save(saveFileDialog.fileUrl + ".pres");
|
||||
}
|
||||
onRejected: {
|
||||
print("Canceled")
|
||||
}
|
||||
}
|
||||
|
||||
function toggleEditMode() {
|
||||
editMode = !editMode;
|
||||
mainPage.editSwitch();
|
||||
|
@ -119,9 +134,9 @@ Kirigami.ApplicationWindow {
|
|||
settingsSheet.open()
|
||||
}
|
||||
|
||||
function save() {
|
||||
const saved = FileManager.save("/home/chris/blah.pres", mainPage.serviceList);
|
||||
saved ? showPassiveNotification("SAVED!") : showPassiveNotification("FAILED!");
|
||||
function save(file) {
|
||||
const saved = FileManager.save(file, mainPage.serviceItems.getItems());
|
||||
saved ? showPassiveNotification("SAVED! " + file) : showPassiveNotification("FAILED!");
|
||||
}
|
||||
|
||||
function saveAs() {
|
||||
|
|
|
@ -37,7 +37,7 @@ Controls.Page {
|
|||
property var song
|
||||
property var draggedLibraryItem
|
||||
|
||||
property var serviceList: ["testing", "data"]
|
||||
property var serviceItems: serviceItemModel
|
||||
|
||||
property bool songDragged: false
|
||||
|
||||
|
|
|
@ -372,6 +372,28 @@ QVariantMap ServiceItemModel::getItem(int index) const {
|
|||
return data;
|
||||
}
|
||||
|
||||
QVariantList ServiceItemModel::getItems() {
|
||||
QVariantList data;
|
||||
ServiceItem * item;
|
||||
foreach (item, m_items) {
|
||||
qDebug() << item->name();
|
||||
QVariantMap itm;
|
||||
itm["name"] = item->name();
|
||||
itm["type"] = item->type();
|
||||
itm["background"] = item->background();
|
||||
itm["backgroundType"] = item->backgroundType();
|
||||
itm["text"] = item->text();
|
||||
itm["audio"] = item->audio();
|
||||
itm["font"] = item->font();
|
||||
itm["fontSize"] = item->fontSize();
|
||||
data.append(itm);
|
||||
}
|
||||
qDebug() << "$$$$$$$$$$$$$$$$$$$$$$$$$$$";
|
||||
qDebug() << data;
|
||||
qDebug() << "$$$$$$$$$$$$$$$$$$$$$$$$$$$";
|
||||
return data;
|
||||
}
|
||||
|
||||
bool ServiceItemModel::select(int id) {
|
||||
for (int i = 0; i < m_items.length(); i++) {
|
||||
QModelIndex idx = index(i);
|
||||
|
|
|
@ -88,6 +88,7 @@ public:
|
|||
Q_INVOKABLE bool select(int id);
|
||||
Q_INVOKABLE bool activate(int id);
|
||||
Q_INVOKABLE QVariantMap getItem(int index) const;
|
||||
Q_INVOKABLE QVariantList getItems();
|
||||
|
||||
private:
|
||||
QList<ServiceItem *> m_items;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue