diff --git a/RedPandaIDE/RedPandaIDE.pro b/RedPandaIDE/RedPandaIDE.pro index 7fec64f1..bf2c86ae 100644 --- a/RedPandaIDE/RedPandaIDE.pro +++ b/RedPandaIDE/RedPandaIDE.pro @@ -13,8 +13,11 @@ SOURCES += \ editorlist.cpp \ main.cpp \ mainwindow.cpp \ + settingsdialog/compilersetdirectorieswidget.cpp \ + settingsdialog/compilersetoptionwidget.cpp \ settings.cpp \ - settingsdialog.cpp \ + settingsdialog/settingsdialog.cpp \ + settingsdialog/settingswidget.cpp \ systemconsts.cpp \ utils.cpp @@ -22,14 +25,19 @@ HEADERS += \ editor.h \ editorlist.h \ mainwindow.h \ + settingsdialog/compilersetdirectorieswidget.h \ + settingsdialog/compilersetoptionwidget.h \ settings.h \ - settingsdialog.h \ + settingsdialog/settingsdialog.h \ + settingsdialog/settingswidget.h \ systemconsts.h \ utils.h FORMS += \ mainwindow.ui \ - settingsdialog.ui + settingsdialog/compilersetdirectorieswidget.ui \ + settingsdialog/compilersetoptionwidget.ui \ + settingsdialog/settingsdialog.ui TRANSLATIONS += \ RedPandaIDE_zh_CN.ts diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 13de410b..2b61eefc 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -9,6 +9,8 @@ #include #include +#include + MainWindow* pMainWindow; MainWindow::MainWindow(QWidget *parent) @@ -131,3 +133,9 @@ void MainWindow::on_actionSaveAs_triggered() editor->saveAs(); } } + +void MainWindow::on_actionOptions_triggered() +{ + SettingsDialog settingsDialog; + settingsDialog.exec(); +} diff --git a/RedPandaIDE/mainwindow.h b/RedPandaIDE/mainwindow.h index a85e675f..200cc8fd 100644 --- a/RedPandaIDE/mainwindow.h +++ b/RedPandaIDE/mainwindow.h @@ -35,6 +35,8 @@ private slots: void on_actionSaveAs_triggered(); + void on_actionOptions_triggered(); + private: void setupActions(); diff --git a/RedPandaIDE/mainwindow.ui b/RedPandaIDE/mainwindow.ui index 22b534a2..d4ab798a 100644 --- a/RedPandaIDE/mainwindow.ui +++ b/RedPandaIDE/mainwindow.ui @@ -193,9 +193,16 @@ - + + + + + Tools + + + @@ -211,7 +218,7 @@ - + @@ -276,7 +283,7 @@ Save As - + :/icons/images/newlook24/071-saveall.png @@ -289,6 +296,11 @@ Ctrl+Shift+S + + + Options + + diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp index c929ea0c..85def1e8 100644 --- a/RedPandaIDE/settings.cpp +++ b/RedPandaIDE/settings.cpp @@ -223,6 +223,11 @@ void Settings::CompilerSet::setOption(PCompilerOption &option, char valueChar) option->value = charToValue(valueChar); } +bool Settings::CompilerSet::dirsValid(QString &msg) +{ + return true; +} + const QString &Settings::CompilerSet::CCompilerName() const { return mCCompilerName; @@ -987,6 +992,28 @@ void Settings::CompilerSets::loadSets() PCompilerSet pSet=loadSet(i); mList.push_back(pSet); } + + PCompilerSet pCurrentSet = defaultSet(); + if (pCurrentSet) { + QString msg; + if (!pCurrentSet->dirsValid(msg)) { + + } + } +} + +void Settings::CompilerSets::deleteSet(int index) +{ + // Erase all sections at and above from disk + for (int i=index;imSettings.beginGroup(QString(SETTING_COMPILTER_SET).arg(i)); + mSettings->mSettings.remove(""); + mSettings->mSettings.endGroup(); + } + mList.erase(std::begin(mList)+index); + for (int i=index;i=0 && mDefaultIndexsetupUi(this); -} - -SettingsDialog::~SettingsDialog() -{ - delete ui; -} diff --git a/RedPandaIDE/settingsdialog.h b/RedPandaIDE/settingsdialog.h deleted file mode 100644 index 1cafa4ee..00000000 --- a/RedPandaIDE/settingsdialog.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef SETTINGSDIALOG_H -#define SETTINGSDIALOG_H - -#include - -namespace Ui { -class SettingsDialog; -} - -class SettingsDialog : public QDialog -{ - Q_OBJECT - -public: - explicit SettingsDialog(QWidget *parent = nullptr); - ~SettingsDialog(); - -private: - Ui::SettingsDialog *ui; -}; - -#endif // SETTINGSDIALOG_H diff --git a/RedPandaIDE/settingsdialog.ui b/RedPandaIDE/settingsdialog.ui deleted file mode 100644 index 7513850e..00000000 --- a/RedPandaIDE/settingsdialog.ui +++ /dev/null @@ -1,150 +0,0 @@ - - - SettingsDialog - - - - 0 - 0 - 977 - 622 - - - - Dialog - - - - 2 - - - 2 - - - 2 - - - 2 - - - - - Qt::Horizontal - - - - QFrame::NoFrame - - - QFrame::Plain - - - - - - - - - - QFrame::NoFrame - - - QFrame::Raised - - - - - - - 0 - 0 - - - - TextLabel - - - - - - - QFrame::NoFrame - - - QFrame::Plain - - - - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 2 - - - 2 - - - 2 - - - 2 - - - - - Qt::Horizontal - - - - 192 - 20 - - - - - - - - OK - - - - - - - Apply - - - - - - - Cancle - - - - - - - - - - - - - - - diff --git a/RedPandaIDE/settingsdialog/settingswidget.cpp b/RedPandaIDE/settingsdialog/settingswidget.cpp new file mode 100644 index 00000000..18ceb759 --- /dev/null +++ b/RedPandaIDE/settingsdialog/settingswidget.cpp @@ -0,0 +1,64 @@ +#include "settingswidget.h" + +#include +#include +#include + +SettingsWidget::SettingsWidget(const QString &name, const QString &group, QWidget *parent): + QWidget(parent), + mName(name), + mGroup(group) +{ + +} + +void SettingsWidget::init() +{ + load(); + for (QLineEdit* p:findChildren()) { + connect(p, &QLineEdit::textChanged, this, &SettingsWidget::setSettingsChanged); + } + for (QCheckBox* p:findChildren()) { + connect(p, &QCheckBox::stateChanged, this, &SettingsWidget::setSettingsChanged); + } + for (QPlainTextEdit* p:findChildren()) { + connect(p, &QPlainTextEdit::textChanged, this, &SettingsWidget::setSettingsChanged); + } +} + +void SettingsWidget::load() +{ + doLoad(); + mSettingsChanged = false; +} + +void SettingsWidget::save() +{ + doSave(); + mSettingsChanged = false; +} + +const QString &SettingsWidget::group() +{ + return mGroup; +} + +const QString &SettingsWidget::name() +{ + return mName; +} + +bool SettingsWidget::settingsChanged() +{ + return mSettingsChanged; +} + +void SettingsWidget::setSettingsChanged() +{ + mSettingsChanged = true; +} + +void SettingsWidget::clearSettingsChanged() +{ + mSettingsChanged = false; +} diff --git a/RedPandaIDE/settingsdialog/settingswidget.h b/RedPandaIDE/settingsdialog/settingswidget.h new file mode 100644 index 00000000..e1f9c245 --- /dev/null +++ b/RedPandaIDE/settingsdialog/settingswidget.h @@ -0,0 +1,34 @@ +#ifndef SETTINGSWIDGET_H +#define SETTINGSWIDGET_H + +#include + +class SettingsWidget : public QWidget +{ + Q_OBJECT +public: + explicit SettingsWidget(const QString& name, const QString& group, QWidget *parent = nullptr); + + virtual void init(); + + void load(); + void save(); +signals: + +protected: + virtual void doLoad() = 0; + virtual void doSave() = 0; +public: + const QString& group(); + const QString& name(); + bool settingsChanged(); +public slots: + void setSettingsChanged(); + void clearSettingsChanged(); +private: + bool mSettingsChanged; + QString mGroup; + QString mName; +}; + +#endif // SETTINGSWIDGET_H