Use QFileDialog to chose files

This commit is contained in:
Vyn 2024-05-05 15:58:56 +02:00
parent 375a1bfb2d
commit 7eb54cddce
5 changed files with 40 additions and 31 deletions

View file

@ -11,13 +11,13 @@
#include "core/TodoMd.h"
#include "cpp-utils/debug.h"
#include <exception>
#include <sstream>
#include <iostream>
#include <ostream>
#include <qjsonarray.h>
#include <qjsonvalue.h>
#include <qlogging.h>
#include <qvariant.h>
#include <sstream>
Backend::Backend() : todoView(&mirai)
{
@ -49,7 +49,7 @@ Backend::Backend() : todoView(&mirai)
mirai.loadFile(filePath.toString().toStdString());
loadingFileDuration.printTimeElapsed(
"Loading file duration of " + filePath.toString().toStdString()
);
);
}
auto jsonTagsConfig = json["tags"];
@ -63,8 +63,6 @@ Backend::Backend() : todoView(&mirai)
qWarning() << "Couldn't find existing config file";
}
cpputils::debug::Timer updatingViewDuration;
todoView.update();
updatingViewDuration.printTimeElapsed("Updating view duration");
@ -332,4 +330,5 @@ void Backend::saveConfig()
}
configFile.write(QJsonDocument(rootJson).toJson());
configFile.close();
qDebug() << "Config file saved";
}

View file

@ -112,4 +112,26 @@ Window {
}
onWidthChanged: setFittingLayout()
Component.onCompleted: setFittingLayout()
Popup {
id: taskFormPopup
width: parent.width * 0.75
implicitHeight: taskForm.height + padding * 2
x: Math.round((parent.width - width) / 2)
y: Math.round((parent.height * 0.4) / 2)
padding: 8
background: Rectangle {
border.color: colorPalette.selected.modalBorder
border.width: 2
color: colorPalette.selected.pane
radius: 4
}
TaskForm {
id: taskForm
width: parent.width
onConfirmed: {
taskFormPopup.close()
}
}
}
}

View file

@ -87,26 +87,6 @@ Rectangle {
Popup {
id: taskFormPopup
width: parent.width * 0.75
implicitHeight: taskForm.height + padding * 2
x: Math.round((parent.width - width) / 2)
y: Math.round((parent.height * 0.4) / 2)
padding: 8
background: Rectangle {
border.color: colorPalette.selected.modalBorder
border.width: 2
color: colorPalette.selected.pane
radius: 4
}
TaskForm {
id: taskForm
width: parent.width
onConfirmed: {
taskFormPopup.close()
}
}
}
}
}

View file

@ -8,6 +8,7 @@ import QtQuick
import QtQuick.Window
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Dialogs
import Mirai
// WIP
@ -39,10 +40,19 @@ ColumnLayout {
}
}
FileDialog {
id: fileDialog
currentFolder: StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0]
onAccepted: {
console.log(selectedFile)
internal.paths = [...internal.paths, selectedFile]
}
}
AppButton {
text: "+"
text: "+ Add"
onClicked: {
internal.paths = [...internal.paths, ""]
fileDialog.open()
}
}
@ -53,4 +63,3 @@ ColumnLayout {
}
}
}