From 8dd58923278ba046725c188f79ccf1fedf4cb50b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lie=20Delhaie?= Date: Sun, 6 Nov 2022 16:06:38 +0100 Subject: [PATCH] Add config dialog --- WorkPad.pro | 6 +- icons.qrc | 2 +- resources/outline_help_outline_black_48dp.png | Bin 1297 -> 0 bytes resources/settings.png | Bin 0 -> 887 bytes LICENSE => src/LICENSE | 0 src/frames/aboutdialog.cpp | 16 - src/frames/aboutdialog.h | 23 -- src/frames/aboutdialog.ui | 100 ------ src/frames/configdialog.cpp | 45 +++ src/frames/configdialog.h | 31 ++ src/frames/configdialog.ui | 296 ++++++++++++++++++ src/frames/mainwindow.cpp | 9 +- src/frames/mainwindow.h | 2 +- src/frames/mainwindow.ui | 11 +- 14 files changed, 389 insertions(+), 152 deletions(-) delete mode 100644 resources/outline_help_outline_black_48dp.png create mode 100644 resources/settings.png rename LICENSE => src/LICENSE (100%) delete mode 100755 src/frames/aboutdialog.cpp delete mode 100755 src/frames/aboutdialog.h delete mode 100755 src/frames/aboutdialog.ui create mode 100644 src/frames/configdialog.cpp create mode 100644 src/frames/configdialog.h create mode 100644 src/frames/configdialog.ui diff --git a/WorkPad.pro b/WorkPad.pro index 6309da1..337ead2 100755 --- a/WorkPad.pro +++ b/WorkPad.pro @@ -69,10 +69,10 @@ linux-* { #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ + src/frames/configdialog.cpp \ src/services/configmanager.cpp \ src/frames/exportdialog.cpp \ src/frames/renamedialog.cpp \ - src/frames/aboutdialog.cpp \ src/frames/createdialog.cpp \ src/frames/movedialog.cpp \ src/main.cpp \ @@ -83,10 +83,10 @@ SOURCES += \ src/services/savemanager.cpp HEADERS += \ + src/frames/configdialog.h \ src/services/configmanager.h \ src/frames/exportdialog.h \ src/frames/renamedialog.h \ - src/frames/aboutdialog.h \ src/frames/createdialog.h \ src/frames/mainwindow.h \ src/frames/movedialog.h \ @@ -96,9 +96,9 @@ HEADERS += \ src/services/savemanager.h FORMS += \ + src/frames/configdialog.ui \ src/frames/exportdialog.ui \ src/frames/renamedialog.ui \ - src/frames/aboutdialog.ui \ src/frames/createdialog.ui \ src/frames/mainwindow.ui \ src/frames/movedialog.ui diff --git a/icons.qrc b/icons.qrc index 8bf35f5..8add7a1 100755 --- a/icons.qrc +++ b/icons.qrc @@ -1,10 +1,10 @@ resources/outline_delete_forever_black_48dp.png - resources/outline_help_outline_black_48dp.png resources/outline_save_black_48dp.png resources/new_file.png resources/new_folder.png + resources/settings.png resources/logo.png diff --git a/resources/outline_help_outline_black_48dp.png b/resources/outline_help_outline_black_48dp.png deleted file mode 100644 index 50895841ef12ca00670b38dea8030cb33c83c652..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1297 zcmV+s1@8KZP)NyTiy$d%!cgSUSmiJjn;W#AqS% zh^0IhLX4)y^h`)nK5*YeJH%EyyqWUBoS^JkUo{WlVZ`3UIADH7EptPRJG&Rx!KVbh zP{fy*i><$zi!V_`FC_5kI_x!`R71)+y|BUf;}3>wN1=!<5Th+9;wZQ_*mw{&lxy1J zP0JbLapu>ffNc;*+fYEg$CY5Y!rv^%tfm+|>~Yrr2q}>tJ+6j_AqM@?C^g6YfM-QV zEQOTVQgjS>wa-U$1n+L+dwx5|Gk+;0kfn}SLObLCgu4;6dMq>C_w$b1{t*(`kB-lT zyy1DU4D|@sO{VDuw+fI(Qh-Y@LKHV4NL83;m{>a!X*)W_+s<^{gLBa8H|O9UOt-%s zF=qOXG)&;lLlsKir2)^Zu@J=`+<_YWUp2S`dmxIj0k70cQSzQP%;)Ejw#0B&?M6>n z>xtclt2IH|a)$MUrvtotsz1^&xYQe>xD#o+6Qbx1mxdV*ZgZ5Z0T9J`aH(jx=hq-@ zHHK$G(PL#z6a(O&@rX}=YhQZ2Tl@ZJ`4X;8u-*~;(?68GAFj<(wtX&KJ6GBEEVy>R z{y}hQYQTPFu#Rv|o8@c`*IKKyrtWoAw!I$>@UEva&>B=B##$-+z8$VrVU4o=p78E= zWsuhpYaP`EcE4UzwtqXk8?6lT1Y+$`W#8X|PfsY@9}Vw5Q3kmZF_y!6W#4awPgg42 z{{-GmQ3mOb*h&m1&K9(VPu-OXh7ZFoM8NFR(eW+F`1eA9`);rWndp}!1MJIn zFc)%3GR{SL|5hpcavIDw`t%1`axF%bX&2m>+yuCdUC%knY6 zz)H*KVU|Y^v;1iy=T8&;aW3VLbNzWb=g-r9Kw~n@-}!)sk0|*C_=u7Z>G=itke-jJ z`UUuyst;=W1^A%0uPX2h@KpuAtivzBmv#8M8nysmSF@|INvpEVtF+Inw$iJ()vLPL ztGt`5z8>g-1JDZ-peH^+Z>)eGxdFX0OwT-fXPYERk|e(lu!<;82WFK100000NkvXX Hu0mjfX#i!H diff --git a/resources/settings.png b/resources/settings.png new file mode 100644 index 0000000000000000000000000000000000000000..555535219454f6e52d87fb9cb5a13cdec25e1f7d GIT binary patch literal 887 zcmV--1Bm>IP)Px#1am@3R0s$N2z&@+hyVZsAxT6*RA@u(nT>JNKoEtK3V;eQ6#x~WQ~*?fseq&c zlnMeB;8YN(0HuN?6<{hLsQ~uNoHA#5?{-f)Cl=$K(Tr{Fz1z2cx03hwCNBFEw|{R( z;ISiEI|AQ@&|8Dl54r!Y7V+8yF2t}`hH;m2|Mj*K`0F&Rn&YYg15Nc z4Az5SJfQP2Rx4{3@*B<~(nDFw4==_LXl0Q%rz`PD!X#@Z6#+bf_cf1f+E@*rh!cgi zW|AU6fqi-mOEY_Zm3tKSif9C8!TVcg|E)Phftt7zjR0-4sbKxNVDzUg-ReyR%uX;? z+NwriE=r`(laU)TZGth(SL$gYmo=@Xw!I0sD=jru1Edj(FAGV03`XXbLGD{2F41J& za=6Yq2TF>$WX{Jq-biG}4vPSUIbaCAl~T`?v`IOdboygN;dj`(uOn66Lx6>yT)847 z#7$vZRKcu8K<&{6AuByyPT3I%UUqqF5RnHmiZ0aDRmExS`(3sRHf#_{A1r zcw!O4$vMIIv0dv**3RXkTamVW=HQH-cCQy(usaXT&W}8sh5!i%ROE4!Nfq(FFmNEBU{E+|v N002ovPDHLkV1hdYje-CG literal 0 HcmV?d00001 diff --git a/LICENSE b/src/LICENSE similarity index 100% rename from LICENSE rename to src/LICENSE diff --git a/src/frames/aboutdialog.cpp b/src/frames/aboutdialog.cpp deleted file mode 100755 index 3ad17a1..0000000 --- a/src/frames/aboutdialog.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "aboutdialog.h" -#include "ui_aboutdialog.h" - -AboutDialog::AboutDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::AboutDialog) -{ - ui->setupUi(this); - ui->appNameLabel->setText(QString("%1 (%2)").arg(APP_NAME, APP_ARCH)); - ui->versionLabel->setText(QString("Version %1").arg(APP_VERSION)); -} - -AboutDialog::~AboutDialog() -{ - delete ui; -} diff --git a/src/frames/aboutdialog.h b/src/frames/aboutdialog.h deleted file mode 100755 index a8c5c53..0000000 --- a/src/frames/aboutdialog.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef ABOUTDIALOG_H -#define ABOUTDIALOG_H - -#include -#include - -namespace Ui { -class AboutDialog; -} - -class AboutDialog : public QDialog -{ - Q_OBJECT - -public: - explicit AboutDialog(QWidget *parent = nullptr); - ~AboutDialog(); - -private: - Ui::AboutDialog *ui; -}; - -#endif // ABOUTDIALOG_H diff --git a/src/frames/aboutdialog.ui b/src/frames/aboutdialog.ui deleted file mode 100755 index 63debeb..0000000 --- a/src/frames/aboutdialog.ui +++ /dev/null @@ -1,100 +0,0 @@ - - - AboutDialog - - - - 0 - 0 - 334 - 180 - - - - - 334 - 180 - - - - - 334 - 180 - - - - About WorkPad - - - true - - - - - - - - - 0 - 64 - - - - - 16777215 - 64 - - - - image: url(:/logo/resources/logo.png); - - - - - - Qt::AlignCenter - - - - - - - - 14 - - - - WorkPad - - - Qt::AlignCenter - - - - - - - Version 1.2.0.0 - - - Qt::AlignCenter - - - - - - - Author: Aurélie Delhaie (aureliedelhaie.fr) - - - Qt::AlignCenter - - - - - - - - - - diff --git a/src/frames/configdialog.cpp b/src/frames/configdialog.cpp new file mode 100644 index 0000000..ac9923d --- /dev/null +++ b/src/frames/configdialog.cpp @@ -0,0 +1,45 @@ +#include "configdialog.h" +#include "ui_configdialog.h" + +ConfigDialog::ConfigDialog(AppConfiguration *cfg, QWidget *parent) : + QDialog(parent), + ui(new Ui::ConfigDialog) +{ + ui->setupUi(this); + ui->appNameLabel->setText(QString("%1 (%2)").arg(APP_NAME, APP_ARCH)); + ui->versionLabel->setText(QString("Version %1").arg(APP_VERSION)); + + this->cfg = cfg; + applyCfg(); + + connect(ui->autoSaveEnableCheckbox, &QCheckBox::stateChanged, this, &ConfigDialog::autoSaveEnableChange); + connect(ui->autoSaveDelaySpinbox, &QSpinBox::valueChanged, this, &ConfigDialog::autoSaveDelayChange); +} + +ConfigDialog::~ConfigDialog() +{ + delete ui; +} + +void ConfigDialog::autoSaveEnableChange(int state) +{ + if (state == Qt::CheckState::Checked) + { + cfg->setEnableAutoSave(true); + } + else + { + cfg->setEnableAutoSave(false); + } +} + +void ConfigDialog::autoSaveDelayChange(int value) +{ + cfg->setAutoSaveDelay(value); +} + +void ConfigDialog::applyCfg() +{ + ui->autoSaveEnableCheckbox->setCheckState(cfg->isEnableAutoSave() ? Qt::CheckState::Checked : Qt::CheckState::Unchecked); + ui->autoSaveDelaySpinbox->setValue(cfg->getAutoSaveDelay()); +} diff --git a/src/frames/configdialog.h b/src/frames/configdialog.h new file mode 100644 index 0000000..f027ce1 --- /dev/null +++ b/src/frames/configdialog.h @@ -0,0 +1,31 @@ +#ifndef CONFIGDIALOG_H +#define CONFIGDIALOG_H + +#include + +#include "../models/appconfiguration.h" + +namespace Ui { +class ConfigDialog; +} + +class ConfigDialog : public QDialog +{ + Q_OBJECT + +public: + explicit ConfigDialog(AppConfiguration *cfg, QWidget *parent = nullptr); + ~ConfigDialog(); + +private slots: + void autoSaveEnableChange(int); + void autoSaveDelayChange(int); + +private: + Ui::ConfigDialog *ui; + AppConfiguration *cfg; + + void applyCfg(); +}; + +#endif // CONFIGDIALOG_H diff --git a/src/frames/configdialog.ui b/src/frames/configdialog.ui new file mode 100644 index 0000000..89e1d30 --- /dev/null +++ b/src/frames/configdialog.ui @@ -0,0 +1,296 @@ + + + ConfigDialog + + + + 0 + 0 + 400 + 612 + + + + + 400 + 612 + + + + + 400 + 612 + + + + Configuration + + + + + 10 + 10 + 381 + 561 + + + + 0 + + + + General + + + + + 10 + 20 + 361 + 17 + + + + + true + + + + Auto save + + + + + + 10 + 50 + 51 + 17 + + + + Enable + + + + + + 360 + 45 + 31 + 23 + + + + + + + + + + 56 + 56 + 231 + 16 + + + + Qt::Horizontal + + + + + + 10 + 81 + 71 + 17 + + + + Delay (ms.) + + + + + + 76 + 84 + 211 + 20 + + + + Qt::Horizontal + + + + + + 291 + 71 + 81 + 26 + + + + 500 + + + 900000000 + + + 1000 + + + + + + About + + + + + 7 + 321 + 314 + 26 + + + + Author: Aurélie Delhaie (github.com/mojitaurelie) + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 7 + 290 + 314 + 26 + + + + Version 1.2.0.0 + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 3 + 229 + 371 + 41 + + + + + 20 + + + + WorkPad + + + Qt::AlignCenter + + + + + + 8 + 10 + 360 + 201 + + + + image: url(:/logo/resources/logo.png); + + + + + + Qt::AlignCenter + + + + + + 7 + 353 + 314 + 26 + + + + <html><head/><body><p>Under MIT license</p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 9 + 380 + 361 + 141 + + + + true + + + Copyright 2022 Aurélie Delhaie + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + + + + + + + 225 + 578 + 166 + 25 + + + + QDialogButtonBox::Ok + + + + + + + buttonBox + accepted() + ConfigDialog + accept() + + + 307 + 590 + + + 199 + 305 + + + + + diff --git a/src/frames/mainwindow.cpp b/src/frames/mainwindow.cpp index 4718f52..5e53c48 100755 --- a/src/frames/mainwindow.cpp +++ b/src/frames/mainwindow.cpp @@ -1,7 +1,7 @@ #include "mainwindow.h" #include "ui_mainwindow.h" -#include "aboutdialog.h" +#include "configdialog.h" #include "createdialog.h" #include "movedialog.h" #include "renamedialog.h" @@ -16,7 +16,7 @@ MainWindow::MainWindow(QWidget *parent) connect(ui->actionAdd_folder, &QAction::triggered, this, &MainWindow::createFolder); connect(ui->actionAdd, &QAction::triggered, this, &MainWindow::createNote); connect(ui->actionSave, &QAction::triggered, this, &MainWindow::save); - connect(ui->actionAbout, &QAction::triggered, this, &MainWindow::showAboutBox); + connect(ui->actionSettings, &QAction::triggered, this, &MainWindow::showSettingsBox); connect(ui->contentEdit, &QPlainTextEdit::textChanged, this, &MainWindow::markdownContentChanged); connect(ui->plainTextEdit, &QPlainTextEdit::textChanged, this, &MainWindow::plainContentChanged); connect(ui->treeWidget, &QTreeWidget::itemSelectionChanged, this, &MainWindow::selectionChanged); @@ -124,11 +124,12 @@ void MainWindow::save() this->savemng->flushSave(); } -void MainWindow::showAboutBox() +void MainWindow::showSettingsBox() { - AboutDialog dialog(this); + ConfigDialog dialog(cfgmng->getConfiguration(), this); dialog.setModal(true); dialog.exec(); + cfgmng->writeToDisk(); } void MainWindow::prepareMenu(const QPoint &pos) diff --git a/src/frames/mainwindow.h b/src/frames/mainwindow.h index 262edc0..1c329a9 100755 --- a/src/frames/mainwindow.h +++ b/src/frames/mainwindow.h @@ -40,7 +40,7 @@ private slots: void save(); void markdownContentChanged(); void plainContentChanged(); - void showAboutBox(); + void showSettingsBox(); void prepareMenu(const QPoint &pos); void deleteItem(); void moveNote(); diff --git a/src/frames/mainwindow.ui b/src/frames/mainwindow.ui index 97e908b..214f585 100755 --- a/src/frames/mainwindow.ui +++ b/src/frames/mainwindow.ui @@ -214,7 +214,7 @@ - + @@ -249,13 +249,16 @@ Ctrl+S - + - :/icon/resources/outline_help_outline_black_48dp.png:/icon/resources/outline_help_outline_black_48dp.png + :/icon/resources/settings.png:/icon/resources/settings.png - About + Settings + + + Settings