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 5089584..0000000 Binary files a/resources/outline_help_outline_black_48dp.png and /dev/null differ diff --git a/resources/settings.png b/resources/settings.png new file mode 100644 index 0000000..5555352 Binary files /dev/null and b/resources/settings.png differ 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