work save

This commit is contained in:
royqh1979 2021-10-24 17:31:20 +08:00
parent 7d82f37462
commit 4da3b6d1fa
5 changed files with 70 additions and 20 deletions

View File

@ -907,6 +907,34 @@ void MainWindow::openProject(const QString &filename)
updateForEncodingInfo(); 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() { void MainWindow::setupActions() {
} }
@ -3012,26 +3040,7 @@ void MainWindow::on_actionSaveAs_triggered()
void MainWindow::on_actionOptions_triggered() void MainWindow::on_actionOptions_triggered()
{ {
bool oldCodeCompletion = pSettings->codeCompletion().enabled(); changeOptions();
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();
}
}
} }
void MainWindow::onCompilerSetChanged(int index) 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")
);
}

View File

@ -143,6 +143,7 @@ public:
void openFile(const QString& filename, QTabWidget* page=nullptr); void openFile(const QString& filename, QTabWidget* page=nullptr);
void openProject(const QString& filename); void openProject(const QString& filename);
void changeOptions(const QString& widgetName=QString(), const QString& groupName=QString());
public slots: public slots:
void onCompileLog(const QString& msg); void onCompileLog(const QString& msg);
@ -429,6 +430,8 @@ private slots:
void on_actionOpen_Folder_triggered(); void on_actionOpen_Folder_triggered();
void on_actionRun_Parameters_triggered();
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
EditorList *mEditorList; EditorList *mEditorList;

View File

@ -992,6 +992,8 @@
<addaction name="actionCompile_Run"/> <addaction name="actionCompile_Run"/>
<addaction name="actionRebuild"/> <addaction name="actionRebuild"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionRun_Parameters"/>
<addaction name="separator"/>
<addaction name="actionDebug"/> <addaction name="actionDebug"/>
<addaction name="actionStep_Over"/> <addaction name="actionStep_Over"/>
<addaction name="actionStep_Into"/> <addaction name="actionStep_Into"/>
@ -2016,6 +2018,15 @@
<string>Open Folder</string> <string>Open Folder</string>
</property> </property>
</action> </action>
<action name="actionRun_Parameters">
<property name="icon">
<iconset resource="icons.qrc">
<normaloff>:/icons/images/newlook24/014-compopt.png</normaloff>:/icons/images/newlook24/014-compopt.png</iconset>
</property>
<property name="text">
<string>Running Parameters...</string>
</property>
</action>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>

View File

@ -241,6 +241,22 @@ PSettingsDialog SettingsDialog::projectOptionDialog()
return dialog; return dialog;
} }
bool SettingsDialog::setCurrentWidget(const QString &widgetName, const QString &groupName)
{
QList<QStandardItem*> items = model.findItems(groupName);
if (items.isEmpty())
return false;
QStandardItem* pGroupItem = items[0];
for (int i=0;i<pGroupItem->rowCount();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) void SettingsDialog::on_widgetsView_clicked(const QModelIndex &index)
{ {

View File

@ -30,6 +30,8 @@ public:
static PSettingsDialog optionDialog(); static PSettingsDialog optionDialog();
static PSettingsDialog projectOptionDialog(); static PSettingsDialog projectOptionDialog();
bool setCurrentWidget(const QString &widgetName, const QString &groupName);
bool appShouldQuit() const; bool appShouldQuit() const;
private slots: private slots: