From ffebb3c7d7646ea349fdd2090c1bfc01f25c7f4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aure=CC=81lie=20Delhaie?= Date: Sun, 9 Jan 2022 21:21:18 +0100 Subject: [PATCH] starting cloud save --- .DS_Store | Bin 8196 -> 8196 bytes Chronos.pro | 23 +- Chronos.pro.user | 213 ++------------ Chronos.pro.user.67c351c | 426 ++++++++++++++++++++++++++++ sources/.DS_Store | Bin 8196 -> 8196 bytes sources/aboutbox.h | 2 +- sources/breakdialog.h | 2 +- sources/configurationdialog.cpp | 32 +++ sources/configurationdialog.h | 28 ++ sources/configurationmanager.cpp | 51 ++++ sources/configurationmanager.h | 27 ++ sources/mainwindow.h | 4 +- sources/{ => models}/breakpoint.cpp | 0 sources/{ => models}/breakpoint.h | 0 sources/{ => models}/day.cpp | 0 sources/{ => models}/day.h | 0 sources/models/settings.cpp | 96 +++++++ sources/models/settings.h | 43 +++ sources/{ => models}/week.cpp | 0 sources/{ => models}/week.h | 0 sources/{ => models}/year.cpp | 0 sources/{ => models}/year.h | 0 sources/setdaydialog.h | 4 +- sources/welcome.h | 4 +- ui/aboutbox.ui | 20 +- ui/configurationdialog.ui | 221 +++++++++++++++ 26 files changed, 983 insertions(+), 213 deletions(-) create mode 100644 Chronos.pro.user.67c351c create mode 100644 sources/configurationdialog.cpp create mode 100644 sources/configurationdialog.h create mode 100644 sources/configurationmanager.cpp create mode 100644 sources/configurationmanager.h rename sources/{ => models}/breakpoint.cpp (100%) rename sources/{ => models}/breakpoint.h (100%) rename sources/{ => models}/day.cpp (100%) rename sources/{ => models}/day.h (100%) create mode 100644 sources/models/settings.cpp create mode 100644 sources/models/settings.h rename sources/{ => models}/week.cpp (100%) rename sources/{ => models}/week.h (100%) rename sources/{ => models}/year.cpp (100%) rename sources/{ => models}/year.h (100%) create mode 100644 ui/configurationdialog.ui diff --git a/.DS_Store b/.DS_Store index f69dba364eb03297b24f64a3f33bce0a1f64269c..721506888ff4a9681b0ba50bcdaa85bef9acfea1 100644 GIT binary patch literal 8196 zcmeHMUvC>l5TA7eIonNrY2zeCAf2#~kQxOWJ1G&W>N=^Yg{nkx6_TdKz4NV|Q_i>M z?wpXAAV0$suORpeydv=dKzsmrLVN^xn}QHRpxj2gvw!9{yF0V9>$v~` zsdUW(z#;%Bm^oF`SWHNKoaeEW2zus_62t>Iz`%oL=zu%M9e2bUh&2#vAl5*vfmj3o z1r6Yv&6Dy6@4g(3%UA=k1}>xq`2C<^=CmBpzNF&nz(RxoNT;w{B&=f`ATU}$%K`06 zDxfG+Mh_%_k|4w&5{}~f|*GWp%5`U;xxeyq%3J%#u|twARCh2hpNoVw-Zv42(SH}e0Z?!w_%9>)#XrNNq#~?= z0VOb@32USB$V-1i-YVRL21;Fl0yM_ukt?D7{gw4KQBDc+DAj;MMBc}E35De)!NR$@ zj+aHv0dEwMKrItBv;rl9h**T+3?mjvK^3JpaSr|k#zwRU{^%TV59e5rbDWbd8q6(yylW>Sx92kf}!>wed( z=I$%BQe=7bj^&u_xWc-Q=?OVCIiM&> zC0SRm_j<)rX>~~}77J%fT5s)UVM$xfub!PHm4#Odx2jLtC#Ss+&OZDUcZG=rj|pUC zdsu#kwXvNZ)m+DBPKyIEUyf=Hwf-LJFmkREoImV0N!W(F=uI1NAL%l*!Hn35d)gPF zb1;o|WWqj;aSH+Wt7mYB?DN&YKHm@QGp(eR3D)^1EFuiD*y~Aq+>*_T_ZydH{<=x$dzY=SZr>&l#9&W z{zWP?SAKg?c~w?a$jJ&olD`GvM3Q@^?$bM_NzGh&OAaN`F>c`Ty$?HZ2&eD~e2z!( zYxov^grDIzGEG$SGPyxYNQeJ0#JYy898(Tx cUsCMB^sj#ih~IzIdafM5{}XI<>U}oHMI3i$gQlZuBok?3A73b7#Sfn13#38QL{Er6)R%g*r3C-nO))= N%VbUQdm9@xnE*D|D(e6M diff --git a/Chronos.pro b/Chronos.pro index 637b784..49469ba 100644 --- a/Chronos.pro +++ b/Chronos.pro @@ -56,31 +56,38 @@ DEFINES += QT_DEPRECATED_WARNINGS #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ + sources/configurationmanager.cpp \ + sources/configurationdialog.cpp \ sources/aboutbox.cpp \ sources/breakdialog.cpp \ - sources/breakpoint.cpp \ - sources/day.cpp \ + sources/models/breakpoint.cpp \ + sources/models/day.cpp \ sources/main.cpp \ sources/mainwindow.cpp \ + sources/models/settings.cpp \ sources/setdaydialog.cpp \ sources/tools.cpp \ - sources/week.cpp \ + sources/models/week.cpp \ sources/welcome.cpp \ - sources/year.cpp + sources/models/year.cpp HEADERS += \ + sources/configurationmanager.h \ + sources/configurationdialog.h \ sources/aboutbox.h \ sources/breakdialog.h \ - sources/breakpoint.h \ - sources/day.h \ + sources/models/breakpoint.h \ + sources/models/day.h \ sources/mainwindow.h \ + sources/models/settings.h \ sources/setdaydialog.h \ sources/tools.h \ - sources/week.h \ + sources/models/week.h \ sources/welcome.h \ - sources/year.h + sources/models/year.h FORMS += \ + ui/configurationdialog.ui \ ui/breakdialog.ui \ ui/aboutbox.ui \ ui/mainwindow.ui \ diff --git a/Chronos.pro.user b/Chronos.pro.user index 7f2ec76..72b2744 100644 --- a/Chronos.pro.user +++ b/Chronos.pro.user @@ -1,10 +1,10 @@ - + EnvironmentId - {67c351c8-ac7f-4fbb-b594-e8b60a17310f} + {f1407b1e-b4d5-4aac-ba0d-b38072a0dfb8} ProjectExplorer.Project.ActiveTarget @@ -70,205 +70,46 @@ 0 true - - -fno-delayed-template-parsing - + true Builtin.BuildSystem true true Builtin.DefaultTidyAndClazy - 8 + 4 true + + true + ProjectExplorer.Project.Target.0 Desktop - Desktop Qt 6.2.0 MSVC2019 64bit - Desktop Qt 6.2.0 MSVC2019 64bit - qt.qt6.620.win64_msvc2019_64_kit - 1 - 0 - 0 - - 0 - E:\Qt Projects Sources\build-Chronos-Desktop_Qt_6_2_0_MSVC2019_64bit-Debug - E:/Qt Projects Sources/build-Chronos-Desktop_Qt_6_2_0_MSVC2019_64bit-Debug - - - true - QtProjectManager.QMakeBuildStep - false - - - - true - Qt4ProjectManager.MakeStep - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - clean - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - - Debug - Qt4ProjectManager.Qt4BuildConfiguration - 2 - - - E:\Qt Projects Sources\build-Chronos-Desktop_Qt_6_2_0_MSVC2019_64bit-Release - E:/Qt Projects Sources/build-Chronos-Desktop_Qt_6_2_0_MSVC2019_64bit-Release - - - true - QtProjectManager.QMakeBuildStep - false - - - - true - Qt4ProjectManager.MakeStep - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - clean - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - - Release - Qt4ProjectManager.Qt4BuildConfiguration - 0 - 0 - - - 0 - E:\Qt Projects Sources\build-Chronos-Desktop_Qt_6_2_0_MSVC2019_64bit-Profile - E:/Qt Projects Sources/build-Chronos-Desktop_Qt_6_2_0_MSVC2019_64bit-Profile - - - true - QtProjectManager.QMakeBuildStep - false - - - - true - Qt4ProjectManager.MakeStep - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - clean - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - - Profile - Qt4ProjectManager.Qt4BuildConfiguration - 0 - 0 - 0 - - 3 - - - 0 - Deploy - Deploy - ProjectExplorer.BuildSteps.Deploy - - 1 - - false - ProjectExplorer.DefaultDeployConfiguration - - 1 - - true - true - true - - 2 - - Qt4ProjectManager.Qt4RunConfiguration:E:/Qt Projects Sources/Chronos/Chronos.pro - E:/Qt Projects Sources/Chronos/Chronos.pro - false - true - true - false - true - E:/Qt Projects Sources/build-Chronos-Desktop_Qt_6_2_0_MSVC2019_64bit-Release - - 1 - - - - ProjectExplorer.Project.Target.1 - - Desktop - Desktop Qt 6.2.0 MSVC2019 ARM64 - Desktop Qt 6.2.0 MSVC2019 ARM64 - qt.qt6.620.win64_msvc2019_arm64_kit + Qt 6.2.0 for macOS + Qt 6.2.0 for macOS + qt.qt6.620.clang_64_kit 0 0 0 0 - E:\Qt Projects Sources\build-Chronos-Desktop_Qt_6_2_0_MSVC2019_ARM64-Debug - E:/Qt Projects Sources/build-Chronos-Desktop_Qt_6_2_0_MSVC2019_ARM64-Debug + /Volumes/Macintosh SSD/sources/Qt/build-Chronos-Qt_6_2_0_for_macOS-Debug + /Volumes/Macintosh SSD/sources/Qt/build-Chronos-Qt_6_2_0_for_macOS-Debug true QtProjectManager.QMakeBuildStep false - + + arm-darwin-generic-mach_o-64bit + true @@ -299,14 +140,16 @@ 2 - E:\Qt Projects Sources\build-Chronos-Desktop_Qt_6_2_0_MSVC2019_ARM64-Release - E:/Qt Projects Sources/build-Chronos-Desktop_Qt_6_2_0_MSVC2019_ARM64-Release + /Volumes/Macintosh SSD/sources/Qt/build-Chronos-Qt_6_2_0_for_macOS-Release + /Volumes/Macintosh SSD/sources/Qt/build-Chronos-Qt_6_2_0_for_macOS-Release true QtProjectManager.QMakeBuildStep - false - + true + + arm-darwin-generic-mach_o-64bit + true @@ -339,13 +182,13 @@ 0 - E:\Qt Projects Sources\build-Chronos-Desktop_Qt_6_2_0_MSVC2019_ARM64-Profile - E:/Qt Projects Sources/build-Chronos-Desktop_Qt_6_2_0_MSVC2019_ARM64-Profile + /Volumes/Macintosh SSD/sources/Qt/build-Chronos-Qt_6_2_0_for_macOS-Profile + /Volumes/Macintosh SSD/sources/Qt/build-Chronos-Qt_6_2_0_for_macOS-Profile true QtProjectManager.QMakeBuildStep - false + true @@ -399,21 +242,21 @@ 2 - Qt4ProjectManager.Qt4RunConfiguration:E:/Qt Projects Sources/Chronos/Chronos.pro - E:/Qt Projects Sources/Chronos/Chronos.pro + Qt4ProjectManager.Qt4RunConfiguration:/Volumes/Macintosh SSD/sources/Qt/Chronos/Chronos.pro + /Volumes/Macintosh SSD/sources/Qt/Chronos/Chronos.pro false true true false true - E:/Qt Projects Sources/build-Chronos-Desktop_Qt_6_2_0_MSVC2019_ARM64-Debug + /Volumes/Macintosh SSD/sources/Qt/build-Chronos-Qt_6_2_0_for_macOS-Debug/Chronos.app/Contents/MacOS 1 ProjectExplorer.Project.TargetCount - 2 + 1 ProjectExplorer.Project.Updater.FileVersion diff --git a/Chronos.pro.user.67c351c b/Chronos.pro.user.67c351c new file mode 100644 index 0000000..7f2ec76 --- /dev/null +++ b/Chronos.pro.user.67c351c @@ -0,0 +1,426 @@ + + + + + + EnvironmentId + {67c351c8-ac7f-4fbb-b594-e8b60a17310f} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + false + true + false + 0 + true + true + 0 + 8 + true + false + 1 + true + true + true + *.md, *.MD, Makefile + false + true + + + + ProjectExplorer.Project.PluginSettings + + + true + false + true + true + true + true + + + 0 + true + + -fno-delayed-template-parsing + + true + Builtin.BuildSystem + + true + true + Builtin.DefaultTidyAndClazy + 8 + + + + true + + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop Qt 6.2.0 MSVC2019 64bit + Desktop Qt 6.2.0 MSVC2019 64bit + qt.qt6.620.win64_msvc2019_64_kit + 1 + 0 + 0 + + 0 + E:\Qt Projects Sources\build-Chronos-Desktop_Qt_6_2_0_MSVC2019_64bit-Debug + E:/Qt Projects Sources/build-Chronos-Desktop_Qt_6_2_0_MSVC2019_64bit-Debug + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + E:\Qt Projects Sources\build-Chronos-Desktop_Qt_6_2_0_MSVC2019_64bit-Release + E:/Qt Projects Sources/build-Chronos-Desktop_Qt_6_2_0_MSVC2019_64bit-Release + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + + + 0 + E:\Qt Projects Sources\build-Chronos-Desktop_Qt_6_2_0_MSVC2019_64bit-Profile + E:/Qt Projects Sources/build-Chronos-Desktop_Qt_6_2_0_MSVC2019_64bit-Profile + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + true + true + true + + 2 + + Qt4ProjectManager.Qt4RunConfiguration:E:/Qt Projects Sources/Chronos/Chronos.pro + E:/Qt Projects Sources/Chronos/Chronos.pro + false + true + true + false + true + E:/Qt Projects Sources/build-Chronos-Desktop_Qt_6_2_0_MSVC2019_64bit-Release + + 1 + + + + ProjectExplorer.Project.Target.1 + + Desktop + Desktop Qt 6.2.0 MSVC2019 ARM64 + Desktop Qt 6.2.0 MSVC2019 ARM64 + qt.qt6.620.win64_msvc2019_arm64_kit + 0 + 0 + 0 + + 0 + E:\Qt Projects Sources\build-Chronos-Desktop_Qt_6_2_0_MSVC2019_ARM64-Debug + E:/Qt Projects Sources/build-Chronos-Desktop_Qt_6_2_0_MSVC2019_ARM64-Debug + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + E:\Qt Projects Sources\build-Chronos-Desktop_Qt_6_2_0_MSVC2019_ARM64-Release + E:/Qt Projects Sources/build-Chronos-Desktop_Qt_6_2_0_MSVC2019_ARM64-Release + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + + + 0 + E:\Qt Projects Sources\build-Chronos-Desktop_Qt_6_2_0_MSVC2019_ARM64-Profile + E:/Qt Projects Sources/build-Chronos-Desktop_Qt_6_2_0_MSVC2019_ARM64-Profile + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + true + true + true + + 2 + + Qt4ProjectManager.Qt4RunConfiguration:E:/Qt Projects Sources/Chronos/Chronos.pro + E:/Qt Projects Sources/Chronos/Chronos.pro + false + true + true + false + true + E:/Qt Projects Sources/build-Chronos-Desktop_Qt_6_2_0_MSVC2019_ARM64-Debug + + 1 + + + + ProjectExplorer.Project.TargetCount + 2 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/sources/.DS_Store b/sources/.DS_Store index 36e69c219cd70b2d2a23278138b03d90f956ea53..3a1ac2c0fb550ddbe8c0e65cc4644d66688e8eb7 100644 GIT binary patch delta 914 zcmaJlp1d;j_PdK zY1JzFw`I<$*5#_ULU6Mr$qSr0Dq+}a2M`^5lGTTV>Aacd8%(#`u?lh99zhhuk~Frx zolIVzo|s9@>`YH=-@KNXo|wHcyR#z-vG|o+OQkwB7=P+D=N*Isgy9Z$;h9Hzh9c!g zXDIZsJJgXR1!K7(K|D7&G<<$U3P+-0IUI|{MlZxh$44)gq^PEr>s8C|cY#xGrRfGP zRxP3{rdlSfns@LMM$ zF$*vS^Kc(lpblH`0$#xzIDk*^4Sv8c6u7Z%6Yp delta 319 zcmZp1XmOa}&nUVvU^hRb=wu#&=c0TJNeo2{sSJq>*$f2?`3#v1c?>0!6$Hcrn9>;- z81(*w0g%POz=KUGgC0YMXHI@{QcivnP>lc(I|A`MBz^1*DL~^Zfrg6fuSb((g~(x= z!YB(;Ir)Xa`pKU}?r?H2lmi`^%8(6mnjYg%1_nkxBrDip(wGJ@rBB{3S`IXz670(& mkO7nXMOj7bQ1ruOF9?WnF~X%b$MCFX-pnrXon>Ps8#4fXa$jr! diff --git a/sources/aboutbox.h b/sources/aboutbox.h index 295a4b7..c260e7c 100644 --- a/sources/aboutbox.h +++ b/sources/aboutbox.h @@ -1,7 +1,7 @@ #ifndef ABOUTBOX_H #define ABOUTBOX_H -#define VERSION "2.0.0" +#define VERSION "2.1.0" #include #include diff --git a/sources/breakdialog.h b/sources/breakdialog.h index 8c33568..98fb443 100644 --- a/sources/breakdialog.h +++ b/sources/breakdialog.h @@ -3,7 +3,7 @@ #include -#include "breakpoint.h" +#include "models/breakpoint.h" namespace Ui { class BreakDialog; diff --git a/sources/configurationdialog.cpp b/sources/configurationdialog.cpp new file mode 100644 index 0000000..3f828fd --- /dev/null +++ b/sources/configurationdialog.cpp @@ -0,0 +1,32 @@ +#include "configurationdialog.h" +#include "ui_configurationdialog.h" + +ConfigurationDialog::ConfigurationDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::ConfigurationDialog) +{ + ui->setupUi(this); + RefreshField(); +} + +ConfigurationDialog::~ConfigurationDialog() +{ + delete ui; +} + +void ConfigurationDialog::RefreshField() +{ + Settings* s = mng.GetConfiguration(); + ui->cloud_url->setText(s->GetCloudUrl()); + ui->cloud_Email->setText(s->GetCloudEmail()); + ui->cloud_password->setText(s->GetCloudPassword()); + ui->cloud_agent->setText(s->GetCloudAgent()); + ui->cloud_enable->setCheckState(s->GetCloudEnabled() ? Qt::CheckState::Checked : Qt::CheckState::Unchecked); + + bool cloudDisabled = !s->GetCloudEnabled(); + ui->cloud_url->setDisabled(cloudDisabled); + ui->cloud_Email->setDisabled(cloudDisabled); + ui->cloud_password->setDisabled(cloudDisabled); + ui->cloud_agent->setDisabled(cloudDisabled); +} + diff --git a/sources/configurationdialog.h b/sources/configurationdialog.h new file mode 100644 index 0000000..a227417 --- /dev/null +++ b/sources/configurationdialog.h @@ -0,0 +1,28 @@ +#ifndef CONFIGURATIONDIALOG_H +#define CONFIGURATIONDIALOG_H + +#include + +#include "configurationmanager.h" + +namespace Ui { +class ConfigurationDialog; +} + +class ConfigurationDialog : public QDialog +{ + Q_OBJECT + +public: + explicit ConfigurationDialog(QWidget *parent = nullptr); + ~ConfigurationDialog(); + +private: + Ui::ConfigurationDialog *ui; + ConfigurationManager mng; + + void RefreshField(); + +}; + +#endif // CONFIGURATIONDIALOG_H diff --git a/sources/configurationmanager.cpp b/sources/configurationmanager.cpp new file mode 100644 index 0000000..754aa59 --- /dev/null +++ b/sources/configurationmanager.cpp @@ -0,0 +1,51 @@ +#include "configurationmanager.h" + +ConfigurationManager::ConfigurationManager() +{ + if (QFile::exists(GetPath())) { + QFile* file = new QFile(GetPath()); + file->open(QIODevice::ReadOnly); + auto json = QString(file->readAll()); + file->close(); + delete file; + + QJsonObject obj = QJsonDocument::fromJson(json.toUtf8()).object(); + this->s = Settings::FromJSON(obj); + } else { + this->s = new Settings(); + Save(); + } +} + +ConfigurationManager::~ConfigurationManager() +{ + delete s; +} + +Settings *ConfigurationManager::GetConfiguration() +{ + return s; +} + +QString ConfigurationManager::GetPath() { + QString path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); + if (!QDir(path).exists()) { + QDir().mkpath(path); + } + path += "/"; + if (!QDir(path).exists()) { + QDir().mkpath(path); + } + path += FILENAME; + return path; +} + +void ConfigurationManager::Save() { + QJsonDocument doc(s->ToJSON()); + QFile *f = new QFile(GetPath()); + if (f->open(QIODevice::WriteOnly)) { + f->write(doc.toJson()); + f->close(); + } + delete f; +} diff --git a/sources/configurationmanager.h b/sources/configurationmanager.h new file mode 100644 index 0000000..e864f67 --- /dev/null +++ b/sources/configurationmanager.h @@ -0,0 +1,27 @@ +#ifndef CONFIGURATIONMANAGER_H +#define CONFIGURATIONMANAGER_H + +#define FILENAME "settings.json" + +#include +#include +#include +#include +#include + +#include "models/settings.h" + +class ConfigurationManager +{ +private: + Settings *s; + QString GetPath(); + void Save(); +public: + ConfigurationManager(); + ~ConfigurationManager(); + + Settings* GetConfiguration(); +}; + +#endif // CONFIGURATIONMANAGER_H diff --git a/sources/mainwindow.h b/sources/mainwindow.h index 382f668..c65185d 100644 --- a/sources/mainwindow.h +++ b/sources/mainwindow.h @@ -22,8 +22,8 @@ #include #include -#include "week.h" -#include "year.h" +#include "models/week.h" +#include "models/year.h" #include "welcome.h" #include "tools.h" #include "aboutbox.h" diff --git a/sources/breakpoint.cpp b/sources/models/breakpoint.cpp similarity index 100% rename from sources/breakpoint.cpp rename to sources/models/breakpoint.cpp diff --git a/sources/breakpoint.h b/sources/models/breakpoint.h similarity index 100% rename from sources/breakpoint.h rename to sources/models/breakpoint.h diff --git a/sources/day.cpp b/sources/models/day.cpp similarity index 100% rename from sources/day.cpp rename to sources/models/day.cpp diff --git a/sources/day.h b/sources/models/day.h similarity index 100% rename from sources/day.h rename to sources/models/day.h diff --git a/sources/models/settings.cpp b/sources/models/settings.cpp new file mode 100644 index 0000000..b66027d --- /dev/null +++ b/sources/models/settings.cpp @@ -0,0 +1,96 @@ +#include "settings.h" + +Settings::Settings() +{ + this->cloudEnabled = false; + this->cloudEmail = ""; + this->cloudPassword = ""; + this->cloudUrl = ""; + this->cloudAgent = DEFAULT_AGENT_KEY; +} + +Settings* Settings::FromJSON(QJsonObject obj) +{ + Settings *s = new Settings(); + if (obj["cloud"].isObject()) + { + QJsonObject cloud = obj["cloud"].toObject(); + s->cloudEnabled = cloud["enabled"].toBool(false); + s->cloudUrl = cloud["url"].toString(""); + s->cloudEmail = cloud["email"].toString(""); + s->cloudPassword = cloud["password"].toString(""); + s->cloudAgent = cloud["agent"].toString(DEFAULT_AGENT_KEY); + } + return s; +} + +QJsonObject Settings::ToJSON() +{ + QJsonObject s; + + QJsonObject cloud; + cloud["enabled"] = this->cloudEnabled; + cloud["url"] = this->cloudUrl; + cloud["email"] = this->cloudEmail; + cloud["password"] = this->cloudPassword; + cloud["agent"] = this->cloudAgent; + + s["cloud"] = cloud; + + return s; +} + +bool Settings::GetCloudEnabled() +{ + return this->cloudEnabled; +} + +QString Settings::GetCloudUrl() +{ + return this->cloudUrl; +} + +QString Settings::GetCloudEmail() +{ + return this->cloudEmail; +} + +QString Settings::GetCloudPassword() +{ + return this->cloudPassword; +} + +QString Settings::GetCloudAgent() +{ + return this->cloudAgent; +} + +QString Settings::GetCloudAgentDefault() +{ + return DEFAULT_AGENT; +} + +void Settings::SetCloudEnabled(bool enabled) +{ + this->cloudEnabled = enabled; +} + +void Settings::SetCloudUrl(QString url) +{ + this->cloudUrl = url; +} + +void Settings::SetCloudEmail(QString email) +{ + this->cloudEmail = email; +} + +void Settings::SetCloudPassword(QString password) +{ + this->cloudPassword = password; +} + +void Settings::SetCloudAgent(QString agent) +{ + this->cloudAgent = agent; +} diff --git a/sources/models/settings.h b/sources/models/settings.h new file mode 100644 index 0000000..af5a2e3 --- /dev/null +++ b/sources/models/settings.h @@ -0,0 +1,43 @@ +#ifndef SETTINGS_H +#define SETTINGS_H + +#ifdef _WIN32 + #define DEFAULT_AGENT "cagent.exe" +#else + #define DEFAULT_AGENT "cagent" +#endif + +#define DEFAULT_AGENT_KEY "" + +#include +#include + +class Settings +{ +private: + bool cloudEnabled; + QString cloudUrl; + QString cloudEmail; + QString cloudPassword; + QString cloudAgent; +public: + Settings(); + + static Settings* FromJSON(QJsonObject obj); + QJsonObject ToJSON(); + + bool GetCloudEnabled(); + QString GetCloudUrl(); + QString GetCloudEmail(); + QString GetCloudPassword(); + QString GetCloudAgent(); + QString GetCloudAgentDefault(); + + void SetCloudEnabled(bool enabled); + void SetCloudUrl(QString url); + void SetCloudEmail(QString email); + void SetCloudPassword(QString password); + void SetCloudAgent(QString agent); +}; + +#endif // SETTINGS_H diff --git a/sources/week.cpp b/sources/models/week.cpp similarity index 100% rename from sources/week.cpp rename to sources/models/week.cpp diff --git a/sources/week.h b/sources/models/week.h similarity index 100% rename from sources/week.h rename to sources/models/week.h diff --git a/sources/year.cpp b/sources/models/year.cpp similarity index 100% rename from sources/year.cpp rename to sources/models/year.cpp diff --git a/sources/year.h b/sources/models/year.h similarity index 100% rename from sources/year.h rename to sources/models/year.h diff --git a/sources/setdaydialog.h b/sources/setdaydialog.h index cd75d08..9fd29fb 100644 --- a/sources/setdaydialog.h +++ b/sources/setdaydialog.h @@ -4,10 +4,10 @@ #include #include -#include "day.h" +#include "models/day.h" #include "tools.h" #include "breakdialog.h" -#include "breakpoint.h" +#include "models/breakpoint.h" namespace Ui { class SetDayDialog; diff --git a/sources/welcome.h b/sources/welcome.h index 3ebb6fa..b7a9c02 100644 --- a/sources/welcome.h +++ b/sources/welcome.h @@ -6,8 +6,8 @@ #include #include -#include "week.h" -#include "day.h" +#include "models/week.h" +#include "models/day.h" #include "tools.h" #include "setdaydialog.h" diff --git a/ui/aboutbox.ui b/ui/aboutbox.ui index 69202c1..11c0a24 100644 --- a/ui/aboutbox.ui +++ b/ui/aboutbox.ui @@ -217,18 +217,14 @@ background-color: qlineargradient(spread:pad, x1:0, y1:1, x2:1, y2:1, stop:0 rgb <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:12px; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12px;">Qt 6.2.0 : https://www.qt.io/download-open-source</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Application icon: Alexis Delhaie (me)</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">About box banner: Alexis Delhaie (me)</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Clock image: iconsdb, Iconic (MIT License)</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Running image: Icons made by </span><a href="https://www.flaticon.com/authors/freepik"><span style=" font-size:10pt; text-decoration: underline; color:#0000ff;">Freepik</span></a><span style=" font-size:10pt;"> from </span><a href="https://www.flaticon.com/"><span style=" font-size:10pt; text-decoration: underline; color:#0000ff;">www.flaticon.com</span></a></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt; text-decoration: underline; color:#0000ff;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Calendar image: Icons made by </span><a href="https://www.flaticon.com/authors/freepik"><span style=" font-size:10pt; text-decoration: underline; color:#0000ff;">Freepik</span></a><span style=" font-size:10pt;"> from </span><a href="https://www.flaticon.com/"><span style=" font-size:10pt; text-decoration: underline; color:#0000ff;">www.flaticon.com</span></a></p></body></html> +</style></head><body style=" font-family:'.AppleSystemUIFont'; font-size:12px; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:12px;">Qt 6.2.0 : https://www.qt.io/download-open-source</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:10pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt;">Clock image: iconsdb, Iconic (MIT License)</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:10pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt;">Running image: Icons made by </span><a href="https://www.flaticon.com/authors/freepik"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt; text-decoration: underline; color:#0000ff;">Freepik</span></a><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt;"> from </span><a href="https://www.flaticon.com/"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt; text-decoration: underline; color:#0000ff;">www.flaticon.com</span></a></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:10pt; text-decoration: underline; color:#0000ff;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt;">Calendar image: Icons made by </span><a href="https://www.flaticon.com/authors/freepik"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt; text-decoration: underline; color:#0000ff;">Freepik</span></a><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt;"> from </span><a href="https://www.flaticon.com/"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt; text-decoration: underline; color:#0000ff;">www.flaticon.com</span></a></p></body></html> diff --git a/ui/configurationdialog.ui b/ui/configurationdialog.ui new file mode 100644 index 0000000..e7a22c8 --- /dev/null +++ b/ui/configurationdialog.ui @@ -0,0 +1,221 @@ + + + ConfigurationDialog + + + + 0 + 0 + 400 + 269 + + + + + 400 + 269 + + + + + 400 + 269 + + + + Dialog + + + + + 10 + 20 + 141 + 16 + + + + + 75 + true + + + + Sauvegarde Cloud + + + + + + 140 + 24 + 251 + 20 + + + + Qt::Horizontal + + + + + false + + + + 164 + 86 + 221 + 21 + + + + + + + 13 + 87 + 101 + 20 + + + + Serveur + + + + + + 10 + 50 + 371 + 20 + + + + Utiliser la sauvegarde en ligne + + + + + false + + + + 164 + 118 + 221 + 21 + + + + + + + 13 + 119 + 101 + 20 + + + + Email + + + + + false + + + + 164 + 150 + 221 + 21 + + + + QLineEdit::Password + + + + + + 13 + 151 + 101 + 20 + + + + Mot de passe + + + + + false + + + + 164 + 183 + 171 + 21 + + + + + + + <default> + + + QLineEdit::Normal + + + + + + 13 + 184 + 151 + 20 + + + + Agent de sauvegarde + + + + + false + + + + 339 + 178 + 51 + 32 + + + + ... + + + + + + 280 + 230 + 113 + 32 + + + + Fermer + + + + + +