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