mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-02 01:13:19 +00:00
Use QFileDialog to chose files
This commit is contained in:
parent
375a1bfb2d
commit
7eb54cddce
5 changed files with 40 additions and 31 deletions
|
@ -6,12 +6,12 @@ set(CMAKE_CXX_STANDARD 20)
|
|||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
set(CMAKE_COMPILE_WARNING_AS_ERROR ON)
|
||||
|
||||
find_package(Qt6 6.6 REQUIRED COMPONENTS Quick)
|
||||
find_package(Qt6 6.7 REQUIRED COMPONENTS Quick)
|
||||
|
||||
include_directories(src)
|
||||
include_directories(libs)
|
||||
|
||||
qt_standard_project_setup(REQUIRES 6.6)
|
||||
qt_standard_project_setup(REQUIRES 6.7)
|
||||
|
||||
add_library(mirai-core
|
||||
src/core/Mirai.h src/core/Mirai.cpp
|
||||
|
@ -74,7 +74,6 @@ qt_add_qml_module(mirai
|
|||
target_link_libraries(mirai PRIVATE Qt6::Quick)
|
||||
target_link_libraries(mirai PRIVATE mirai-core)
|
||||
|
||||
|
||||
# Tests
|
||||
add_subdirectory(libs/Catch2)
|
||||
add_executable(tests tests/test.cpp)
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue