mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-02 01:13:19 +00:00
Fix config file not saving on Android
This commit is contained in:
parent
3ad558cf6e
commit
4164d8fbf3
5 changed files with 12 additions and 7 deletions
|
@ -7,8 +7,8 @@
|
|||
#ifndef MIRAI_ANDROID_FILE_RESOURCE_H
|
||||
#define MIRAI_ANDROID_FILE_RESOURCE_H
|
||||
|
||||
#include "QFile"
|
||||
#include "QDebug"
|
||||
#include "QFile"
|
||||
#include "core/BaseFileResource.h"
|
||||
#include "core/TodoMd.h"
|
||||
|
||||
|
@ -48,7 +48,6 @@ class AndroidFileResource : public BaseFileResource
|
|||
return;
|
||||
}
|
||||
QString content = file.readAll();
|
||||
qDebug() << "Content " << content;
|
||||
file.close();
|
||||
|
||||
auto result = TodoMdFormat::parse(content.toStdString());
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <qjsonarray.h>
|
||||
#include <qjsonvalue.h>
|
||||
#include <qlogging.h>
|
||||
#include <qstandardpaths.h>
|
||||
#include <qvariant.h>
|
||||
#include <sstream>
|
||||
|
||||
|
@ -29,8 +30,8 @@ Backend::Backend() : todoView(&mirai)
|
|||
std::cout << "Backend created" << std::endl;
|
||||
|
||||
cpputils::debug::Timer readConfigDuration;
|
||||
QDir().mkdir(QDir::homePath() + "/.config/mirai");
|
||||
QFile loadFile(QDir::homePath() + "/.config/mirai/config.json");
|
||||
QDir().mkpath(getConfigFilePath());
|
||||
QFile loadFile(getConfigFilePath());
|
||||
readConfigDuration.printTimeElapsed("Read config duration");
|
||||
|
||||
if (loadFile.open(QIODevice::ReadOnly)) {
|
||||
|
@ -341,7 +342,7 @@ void Backend::saveConfig()
|
|||
}
|
||||
rootJson["tags"] = tagsJson;
|
||||
|
||||
QFile configFile(QDir::homePath() + "/.config/mirai/config.json");
|
||||
QFile configFile(getConfigFilePath());
|
||||
if (!configFile.open(QIODevice::WriteOnly)) {
|
||||
qWarning() << "Cannot save config";
|
||||
return;
|
||||
|
@ -350,3 +351,9 @@ void Backend::saveConfig()
|
|||
configFile.close();
|
||||
qDebug() << "Config file saved";
|
||||
}
|
||||
|
||||
QString Backend::getConfigFilePath() const
|
||||
{
|
||||
QString configFolder = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
|
||||
return configFolder + "/config.json";
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@ class Backend : public QObject
|
|||
QVariant getActiveResourcesFilter();
|
||||
bool shouldHideCompletedTasks();
|
||||
void saveConfig();
|
||||
QString getConfigFilePath() const;
|
||||
|
||||
mirai::Mirai mirai;
|
||||
// Both Todo and Calendar view use the todoView for now.
|
||||
|
|
|
@ -74,7 +74,6 @@ Rectangle {
|
|||
Component {
|
||||
id: calendarViewComponent
|
||||
CalendarView {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,6 @@ ColumnLayout {
|
|||
|
||||
FileDialog {
|
||||
id: fileDialog
|
||||
currentFolder: StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0]
|
||||
onAccepted: {
|
||||
console.log(selectedFile.toString())
|
||||
internal.paths = [...internal.paths, selectedFile.toString().replace(/^file:\/\//, "")]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue