- enhancement: Open project's option dialog instead of the option dialog, when click the compiler set settings button in the toolbar and the current editor is for project.

- enhancement: Reset project compile options when change compiler set in the project options dialog.
This commit is contained in:
Roy Qu 2023-04-03 09:39:45 +08:00
parent 799ce52460
commit d8f9cef762
8 changed files with 418 additions and 358 deletions

View File

@ -7,6 +7,8 @@ Red Panda C++ Version 2.20
- fix: Octal numeric escape sequences is not correctly syntax highlighted. - fix: Octal numeric escape sequences is not correctly syntax highlighted.
- enhancement: Refine suggestion info when try debug and the compiler settings are not correct. - enhancement: Refine suggestion info when try debug and the compiler settings are not correct.
- enhancement: Open the options dialog/project options dialog when user want to correct compiler settings for debug. - enhancement: Open the options dialog/project options dialog when user want to correct compiler settings for debug.
- enhancement: Open project's option dialog instead of the option dialog, when click the compiler set settings button in the toolbar and the current editor is for project.
- enhancement: Reset project compile options when change compiler set in the project options dialog.
Red Panda C++ Version 2.19 Red Panda C++ Version 2.19

View File

@ -2198,6 +2198,8 @@ void MainWindow::debug()
+"<BR />" +"<BR />"
+tr(" - Turned off the \"Optimization level (-O)\" option or set it to \"Debug (-Og)\".") +tr(" - Turned off the \"Optimization level (-O)\" option or set it to \"Debug (-Og)\".")
+"<BR /><BR />" +"<BR /><BR />"
+tr("You should recompile after change the compiler set or it's settings.")
+"<BR /><BR />"
+tr("Do you want to mannually change the compiler set settings now?") +tr("Do you want to mannually change the compiler set settings now?")
)== QMessageBox::Yes) { )== QMessageBox::Yes) {
changeProjectOptions( changeProjectOptions(
@ -2311,6 +2313,8 @@ void MainWindow::debug()
+"<BR />" +"<BR />"
+tr(" - Turned off the \"Optimization level (-O)\" option or set it to \"Debug (-Og)\".") +tr(" - Turned off the \"Optimization level (-O)\" option or set it to \"Debug (-Og)\".")
+"<BR /><BR />" +"<BR /><BR />"
+tr("You should recompile after change the compiler set or it's settings.")
+"<BR /><BR />"
+tr("Do you want to mannually change the compiler set settings now?") +tr("Do you want to mannually change the compiler set settings now?")
)== QMessageBox::Yes) { )== QMessageBox::Yes) {
changeOptions( changeOptions(
@ -5049,20 +5053,25 @@ void MainWindow::stopDebugForNoSymbolTable()
+"<BR />" +"<BR />"
+tr(" - Turned off the \"Optimization level (-O)\" option or set it to \"Debug (-Og)\".") +tr(" - Turned off the \"Optimization level (-O)\" option or set it to \"Debug (-Og)\".")
+"<BR /><BR />" +"<BR /><BR />"
+tr("You should recompile after change the compiler set or it's settings.")
+"<BR /><BR />"
+tr("You should recompile after change the compiler set or it's settings.")
+"<BR /><BR />"
+tr("Do you want to mannually change the compiler set settings now?") +tr("Do you want to mannually change the compiler set settings now?")
)== QMessageBox::Yes) { )== QMessageBox::Yes) {
Editor * editor = mEditorList->getEditor(); on_actionCompiler_Options_triggered();
if (editor && editor->inProject()) { // Editor * editor = mEditorList->getEditor();
changeProjectOptions( // if (!mProject || (editor && !editor->inProject())) {
SettingsDialog::tr("Compiler Set"), // changeOptions(
SettingsDialog::tr("Project") // SettingsDialog::tr("Compiler Set"),
); // SettingsDialog::tr("Compiler")
} else { // );
changeOptions( // } else {
SettingsDialog::tr("Compiler Set"), // changeProjectOptions(
SettingsDialog::tr("Compiler") // SettingsDialog::tr("Compiler Set"),
); // SettingsDialog::tr("Project")
} // );
// }
} }
} }
@ -9440,10 +9449,18 @@ void MainWindow::on_actionEncode_in_UTF_8_BOM_triggered()
void MainWindow::on_actionCompiler_Options_triggered() void MainWindow::on_actionCompiler_Options_triggered()
{ {
Editor * editor = mEditorList->getEditor();
if (!mProject || (editor && !editor->inProject())) {
changeOptions( changeOptions(
SettingsDialog::tr("Compiler Set"), SettingsDialog::tr("Compiler Set"),
SettingsDialog::tr("Compiler") SettingsDialog::tr("Compiler")
); );
} else {
changeProjectOptions(
SettingsDialog::tr("Compiler Set"),
SettingsDialog::tr("Project")
);
}
} }
void MainWindow::on_dockExplorer_dockLocationChanged(const Qt::DockWidgetArea &area) void MainWindow::on_dockExplorer_dockLocationChanged(const Qt::DockWidgetArea &area)

View File

@ -120,7 +120,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>955</width> <width>955</width>
<height>25</height> <height>24</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile"> <widget class="QMenu" name="menuFile">

View File

@ -20,11 +20,13 @@
#include "../project.h" #include "../project.h"
#include "../mainwindow.h" #include "../mainwindow.h"
#include <qt_utils/charsetinfo.h> #include <qt_utils/charsetinfo.h>
#include <QMessageBox>
ProjectCompilerWidget::ProjectCompilerWidget(const QString &name, const QString &group, QWidget *parent) : ProjectCompilerWidget::ProjectCompilerWidget(const QString &name, const QString &group, QWidget *parent) :
SettingsWidget(name,group,parent), SettingsWidget(name,group,parent),
ui(new Ui::ProjectCompilerWidget) ui(new Ui::ProjectCompilerWidget)
{ {
mInitialized=false;
ui->setupUi(this); ui->setupUi(this);
} }
@ -77,6 +79,7 @@ void ProjectCompilerWidget::doLoad()
ui->cbCompilerSet->setCurrentIndex(pMainWindow->project()->options().compilerSet); ui->cbCompilerSet->setCurrentIndex(pMainWindow->project()->options().compilerSet);
ui->chkAddCharset->setChecked(pMainWindow->project()->options().addCharset); ui->chkAddCharset->setChecked(pMainWindow->project()->options().addCharset);
ui->chkStaticLink->setChecked(pMainWindow->project()->options().staticLink); ui->chkStaticLink->setChecked(pMainWindow->project()->options().staticLink);
mInitialized=true;
} }
void ProjectCompilerWidget::doSave() void ProjectCompilerWidget::doSave()
@ -115,9 +118,28 @@ void ProjectCompilerWidget::init()
SettingsWidget::init(); SettingsWidget::init();
} }
void ProjectCompilerWidget::on_cbCompilerSet_currentIndexChanged(int) void ProjectCompilerWidget::on_cbCompilerSet_currentIndexChanged(int index)
{ {
refreshOptions(); std::shared_ptr<Project> project = pMainWindow->project();
auto action = finally([this]{
this->refreshOptions();
});
if (!mInitialized || index==project->options().compilerSet) {
return;
}
if (QMessageBox::warning(
this,
MainWindow::tr("Change Project Compiler Set"),
MainWindow::tr("Change the project's compiler set will lose all custom compiler set options.")
+"<br />"
+ MainWindow::tr("Do you really want to do that?"),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::No) != QMessageBox::Yes) {
ui->cbCompilerSet->setCurrentIndex(project->options().compilerSet);
return;
}
project->setCompilerSet(index);
project->saveOptions();
} }
void ProjectCompilerWidget::on_cbEncoding_currentTextChanged(const QString &/*arg1*/) void ProjectCompilerWidget::on_cbEncoding_currentTextChanged(const QString &/*arg1*/)

View File

@ -37,6 +37,7 @@ private:
private: private:
Ui::ProjectCompilerWidget *ui; Ui::ProjectCompilerWidget *ui;
QMap<QString,QString> mOptions; QMap<QString,QString> mOptions;
bool mInitialized;
// SettingsWidget interface // SettingsWidget interface
protected: protected:

View File

@ -5191,6 +5191,10 @@
<source>Do you want to mannually change the compiler set settings now?</source> <source>Do you want to mannually change the compiler set settings now?</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>You should recompile after change the compiler set or it&apos;s settings.</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>MemoryModel</name> <name>MemoryModel</name>

File diff suppressed because it is too large Load Diff

View File

@ -4920,6 +4920,10 @@
<source>Do you want to mannually change the compiler set settings now?</source> <source>Do you want to mannually change the compiler set settings now?</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>You should recompile after change the compiler set or it&apos;s settings.</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>MemoryModel</name> <name>MemoryModel</name>