From ab46276cee2971cfc1de41343cd391c10fe279f1 Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Sun, 5 Jul 2020 20:15:32 +0200 Subject: [PATCH] check if recurring file exists --- src/mainwindow.cpp | 4 ++-- src/recurring.cpp | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 6de23ab..64a3148 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1332,9 +1332,9 @@ void MainWindow::setupTransactionsTab() { // Set up context menu on transactions tab auto theme = Settings::getInstance()->get_theme_name(); if (theme == "Dark" || theme == "Midnight") { - ui->listChat->setStyleSheet("background-image: url(:/icons/res/SDLogo.png) ;background-attachment: fixed ;background-position: center center ;background-repeat: no-repeat;background-size: cover"); + ui->listChat->setStyleSheet("background-image: url(:/icons/res/SDLogo.png) ;background-attachment: fixed ;background-position: center center ;background-repeat: no-repeat"); } - if (theme == "Default") {ui->listChat->setStyleSheet("background-image: url(:/icons/res/sdlogo2.png) ;background-attachment: fixed ;background-position: center center ;background-repeat: no-repeat;background-size: cover");} + if (theme == "Default") {ui->listChat->setStyleSheet("background-image: url(:/icons/res/sdlogo2.png) ;background-attachment: fixed ;background-position: center center ;background-repeat: no-repeat");} ui->listChat->setResizeMode(QListView::Adjust); ui->listChat->setWordWrap(true); diff --git a/src/recurring.cpp b/src/recurring.cpp index 471cd90..dd10f70 100644 --- a/src/recurring.cpp +++ b/src/recurring.cpp @@ -319,7 +319,7 @@ QString Recurring::writeableFile() { auto filename = QStringLiteral("recurringpayments.json"); auto dir = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)); - if (!dir.exists()) + if (dir.exists()) QDir().mkpath(dir.absolutePath()); if (Settings::getInstance()->isTestnet()) { @@ -353,6 +353,9 @@ void Recurring::removeRecurringInfo(QString hash) { void Recurring::readFromStorage() { + + if (writeableFile().isEmpty()) + { QFile file(writeableFile()); file.open(QIODevice::ReadOnly); @@ -365,10 +368,14 @@ void Recurring::readFromStorage() { auto p = RecurringPaymentInfo::fromJson(k.toObject()); payments.insert(p.getHash(), p); } + }else{} } void Recurring::writeToStorage() { + + if (writeableFile().isEmpty()) + { QFile file(writeableFile()); file.open(QIODevice::ReadWrite | QIODevice::Truncate); @@ -381,6 +388,7 @@ void Recurring::writeToStorage() { out << QJsonDocument(arr).toJson(); file.close(); +}else{} } /**