From 4da3b6d1fa25814297b8423bf4fa034660387ca3 Mon Sep 17 00:00:00 2001 From: royqh1979 Date: Sun, 24 Oct 2021 17:31:20 +0800 Subject: [PATCH] work save --- RedPandaIDE/mainwindow.cpp | 58 ++++++++++++------- RedPandaIDE/mainwindow.h | 3 + RedPandaIDE/mainwindow.ui | 11 ++++ RedPandaIDE/settingsdialog/settingsdialog.cpp | 16 +++++ RedPandaIDE/settingsdialog/settingsdialog.h | 2 + 5 files changed, 70 insertions(+), 20 deletions(-) diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index c67f5cd0..9817b8bd 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -907,6 +907,34 @@ void MainWindow::openProject(const QString &filename) updateForEncodingInfo(); } +void MainWindow::changeOptions(const QString &widgetName, const QString &groupName) +{ + bool oldCodeCompletion = pSettings->codeCompletion().enabled(); + PSettingsDialog settingsDialog = SettingsDialog::optionDialog(); + if (!groupName.isEmpty()) { + settingsDialog->setCurrentWidget(widgetName, groupName); + } + settingsDialog->exec(); + if (settingsDialog->appShouldQuit()) { + mShouldRemoveAllSettings = true; + close(); + return; + } + + bool newCodeCompletion = pSettings->codeCompletion().enabled(); + if (!oldCodeCompletion && newCodeCompletion) { + Editor *e = mEditorList->getEditor(); + if (mProject && !e) { + scanActiveProject(true); + } else if (mProject && e && e->inProject()) { + scanActiveProject(true); + } else if (e) { + e->reparse(); + } + } + +} + void MainWindow::setupActions() { } @@ -3012,26 +3040,7 @@ void MainWindow::on_actionSaveAs_triggered() void MainWindow::on_actionOptions_triggered() { - bool oldCodeCompletion = pSettings->codeCompletion().enabled(); - PSettingsDialog settingsDialog = SettingsDialog::optionDialog(); - settingsDialog->exec(); - if (settingsDialog->appShouldQuit()) { - mShouldRemoveAllSettings = true; - close(); - return; - } - - bool newCodeCompletion = pSettings->codeCompletion().enabled(); - if (!oldCodeCompletion && newCodeCompletion) { - Editor *e = mEditorList->getEditor(); - if (mProject && !e) { - scanActiveProject(true); - } else if (mProject && e && e->inProject()) { - scanActiveProject(true); - } else if (e) { - e->reparse(); - } - } + changeOptions(); } void MainWindow::onCompilerSetChanged(int index) @@ -4721,3 +4730,12 @@ void MainWindow::on_actionOpen_Folder_triggered() } } + +void MainWindow::on_actionRun_Parameters_triggered() +{ + changeOptions( + SettingsDialog::tr("General"), + SettingsDialog::tr("Program Runner") + ); +} + diff --git a/RedPandaIDE/mainwindow.h b/RedPandaIDE/mainwindow.h index 5c3bcaa2..b4532e6d 100644 --- a/RedPandaIDE/mainwindow.h +++ b/RedPandaIDE/mainwindow.h @@ -143,6 +143,7 @@ public: void openFile(const QString& filename, QTabWidget* page=nullptr); void openProject(const QString& filename); + void changeOptions(const QString& widgetName=QString(), const QString& groupName=QString()); public slots: void onCompileLog(const QString& msg); @@ -429,6 +430,8 @@ private slots: void on_actionOpen_Folder_triggered(); + void on_actionRun_Parameters_triggered(); + private: Ui::MainWindow *ui; EditorList *mEditorList; diff --git a/RedPandaIDE/mainwindow.ui b/RedPandaIDE/mainwindow.ui index 02dfdd4d..d75c45b2 100644 --- a/RedPandaIDE/mainwindow.ui +++ b/RedPandaIDE/mainwindow.ui @@ -992,6 +992,8 @@ + + @@ -2016,6 +2018,15 @@ Open Folder + + + + :/icons/images/newlook24/014-compopt.png:/icons/images/newlook24/014-compopt.png + + + Running Parameters... + + diff --git a/RedPandaIDE/settingsdialog/settingsdialog.cpp b/RedPandaIDE/settingsdialog/settingsdialog.cpp index 3b5592c7..c0f2be56 100644 --- a/RedPandaIDE/settingsdialog/settingsdialog.cpp +++ b/RedPandaIDE/settingsdialog/settingsdialog.cpp @@ -241,6 +241,22 @@ PSettingsDialog SettingsDialog::projectOptionDialog() return dialog; } +bool SettingsDialog::setCurrentWidget(const QString &widgetName, const QString &groupName) +{ + QList items = model.findItems(groupName); + if (items.isEmpty()) + return false; + QStandardItem* pGroupItem = items[0]; + for (int i=0;irowCount();i++) { + QStandardItem* pWidgetItem = pGroupItem->child(i); + if (pWidgetItem->text() == widgetName) { + on_widgetsView_clicked(pWidgetItem->index()); + return true; + } + } + return false; +} + void SettingsDialog::on_widgetsView_clicked(const QModelIndex &index) { diff --git a/RedPandaIDE/settingsdialog/settingsdialog.h b/RedPandaIDE/settingsdialog/settingsdialog.h index f08d026c..e9f56163 100644 --- a/RedPandaIDE/settingsdialog/settingsdialog.h +++ b/RedPandaIDE/settingsdialog/settingsdialog.h @@ -30,6 +30,8 @@ public: static PSettingsDialog optionDialog(); static PSettingsDialog projectOptionDialog(); + bool setCurrentWidget(const QString &widgetName, const QString &groupName); + bool appShouldQuit() const; private slots: