- fix: Settings in Options/Tools/General is messed up when switching items in the list.
This commit is contained in:
parent
7f1b27e099
commit
4a941b63b4
1
NEWS.md
1
NEWS.md
|
@ -13,6 +13,7 @@ Red Panda C++ Version 2.10
|
|||
- enhancement: If there is "cppreference.chm" or "cppreference-%locale_name%.chm"(like cppreference-zh_CN.chm) in the redpanda C++'s app folder, open it instead of the cppreference website.
|
||||
- enhancement: Use lldb-mi as the debugger.
|
||||
- enhancement: Set lldb-mi as the debugger program for clang, when finding compiler set in folders and gdb doesn't exist.
|
||||
- fix: Settings in Options/Tools/General is messed up when switching items in the list.
|
||||
|
||||
Red Panda C++ Version 2.9
|
||||
|
||||
|
|
|
@ -33,13 +33,24 @@ ToolsGeneralWidget::ToolsGeneralWidget(const QString &name, const QString &group
|
|||
ui->lstTools->setModel(&mToolsModel);
|
||||
delete m;
|
||||
mEditType = EditType::None;
|
||||
finishEditing(false);
|
||||
showEditPanel(false);
|
||||
connect(ui->lstTools->selectionModel(), &QItemSelectionModel::currentRowChanged,
|
||||
this,&ToolsGeneralWidget::onToolsCurrentChanged);
|
||||
connect(ui->txtProgram,&QLineEdit::textChanged,
|
||||
this, &ToolsGeneralWidget::updateDemo);
|
||||
connect(ui->txtParameters,&QLineEdit::textChanged,
|
||||
this, &ToolsGeneralWidget::updateDemo);
|
||||
|
||||
connect(ui->txtTitle,&QLineEdit::textChanged,
|
||||
this, &ToolsGeneralWidget::onEdited);
|
||||
connect(ui->txtProgram,&QLineEdit::textChanged,
|
||||
this, &ToolsGeneralWidget::onEdited);
|
||||
connect(ui->txtParameters,&QLineEdit::textChanged,
|
||||
this, &ToolsGeneralWidget::onEdited);
|
||||
connect(ui->txtDirectory,&QLineEdit::textChanged,
|
||||
this, &ToolsGeneralWidget::onEdited);
|
||||
connect(ui->chkPauseConsole,&QCheckBox::stateChanged,
|
||||
this, &ToolsGeneralWidget::onEdited);
|
||||
}
|
||||
|
||||
ToolsGeneralWidget::~ToolsGeneralWidget()
|
||||
|
@ -47,72 +58,76 @@ ToolsGeneralWidget::~ToolsGeneralWidget()
|
|||
delete ui;
|
||||
}
|
||||
|
||||
void ToolsGeneralWidget::onToolsCurrentChanged()
|
||||
void ToolsGeneralWidget::onToolsCurrentChanged(const QModelIndex ¤t, const QModelIndex &previous)
|
||||
{
|
||||
if (mEditType != EditType::None) {
|
||||
finishEditing(true);
|
||||
}
|
||||
QModelIndex index = ui->lstTools->currentIndex();
|
||||
finishEditing(true,previous);
|
||||
QModelIndex index = current;
|
||||
if (!index.isValid())
|
||||
return;
|
||||
PToolItem item = mToolsModel.getTool(index.row());
|
||||
if (item) {
|
||||
prepareEdit(item);
|
||||
}
|
||||
}
|
||||
|
||||
void ToolsGeneralWidget::finishEditing(bool askSave, const QModelIndex& itemIndex)
|
||||
{
|
||||
auto action = finally([this]{
|
||||
showEditPanel(false);
|
||||
});
|
||||
if (mEditType == EditType::None)
|
||||
return;
|
||||
if (!mEdited)
|
||||
return;
|
||||
if (askSave && QMessageBox::question(this,
|
||||
tr("Save Changes?"),
|
||||
tr("Do you want to save changes to \"%1\"?").arg(ui->txtTitle->text()),
|
||||
QMessageBox::Yes | QMessageBox::No,
|
||||
QMessageBox::Yes) != QMessageBox::Yes) {
|
||||
return;
|
||||
}
|
||||
if (ui->txtTitle->text().isEmpty()) {
|
||||
QMessageBox::critical(this,
|
||||
tr("Error"),
|
||||
tr("Title shouldn't be empty!"));
|
||||
return;
|
||||
}
|
||||
mEditType = EditType::None;
|
||||
QModelIndex index=itemIndex.isValid()?itemIndex:ui->lstTools->currentIndex();
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
PToolItem item = mToolsModel.getTool(index.row());
|
||||
item->workingDirectory = ui->txtDirectory->text();
|
||||
item->parameters = ui->txtParameters->text();
|
||||
item->program = ui->txtProgram->text();
|
||||
item->title = ui->txtTitle->text();
|
||||
item->pauseAfterExit = ui->chkPauseConsole->isChecked();
|
||||
mEdited=false;
|
||||
}
|
||||
|
||||
void ToolsGeneralWidget::prepareEdit(const PToolItem& item)
|
||||
{
|
||||
mEditType = EditType::Edit;
|
||||
ui->txtDirectory->setText(item->workingDirectory);
|
||||
ui->txtParameters->setText(item->parameters);
|
||||
ui->txtProgram->setText(item->program);
|
||||
ui->txtTitle->setText(item->title);
|
||||
ui->chkPauseConsole->setChecked(item->pauseAfterExit);
|
||||
ui->panelEdit->setVisible(true);
|
||||
}
|
||||
showEditPanel(true);
|
||||
ui->txtTitle->setFocus();
|
||||
mEdited = false;
|
||||
}
|
||||
|
||||
void ToolsGeneralWidget::finishEditing(bool askSave)
|
||||
void ToolsGeneralWidget::showEditPanel(bool isShow)
|
||||
{
|
||||
if (mEditType == EditType::None) {
|
||||
ui->panelEdit->setVisible(false);
|
||||
return;
|
||||
}
|
||||
if (askSave && QMessageBox::question(this,
|
||||
tr("Save Changes?"),
|
||||
tr("Do you want to save changes to the current tool?"),
|
||||
QMessageBox::Yes | QMessageBox::No,
|
||||
QMessageBox::Yes) != QMessageBox::Yes) {
|
||||
ui->panelEdit->setVisible(false);
|
||||
return;
|
||||
}
|
||||
ui->panelEdit->setVisible(false);
|
||||
if (mEditType == EditType::Add) {
|
||||
mEditType = EditType::None;
|
||||
PToolItem item = std::make_shared<ToolItem>();
|
||||
item->title = ui->txtTitle->text();
|
||||
item->program = ui->txtProgram->text();
|
||||
item->workingDirectory = ui->txtDirectory->text();
|
||||
item->parameters = ui->txtParameters->text();
|
||||
item->pauseAfterExit = ui->chkPauseConsole->isChecked();
|
||||
mToolsModel.addTool(item);
|
||||
} else {
|
||||
mEditType = EditType::None;
|
||||
QModelIndex index = ui->lstTools->currentIndex();
|
||||
if (!index.isValid())
|
||||
return;
|
||||
PToolItem item = mToolsModel.getTool(index.row());
|
||||
item->workingDirectory = ui->txtDirectory->text();
|
||||
item->parameters = ui->txtParameters->text();
|
||||
item->program = ui->txtProgram->text();
|
||||
item->title = ui->txtTitle->text();
|
||||
item->pauseAfterExit = ui->chkPauseConsole->isChecked();
|
||||
}
|
||||
ui->panelEdit->setVisible(isShow);
|
||||
ui->panelEditButtons->setVisible(!isShow);
|
||||
}
|
||||
|
||||
void ToolsGeneralWidget::prepareEdit()
|
||||
void ToolsGeneralWidget::onEdited()
|
||||
{
|
||||
ui->txtDirectory->setText("");
|
||||
ui->txtParameters->setText("");
|
||||
ui->txtProgram->setText("");
|
||||
ui->txtTitle->setText("");
|
||||
ui->chkPauseConsole->setChecked(false);
|
||||
ui->panelEdit->setVisible(true);
|
||||
mEdited=true;
|
||||
}
|
||||
|
||||
void ToolsGeneralWidget::updateDemo()
|
||||
|
@ -175,8 +190,13 @@ QVariant ToolsModel::data(const QModelIndex &index, int role) const
|
|||
void ToolsGeneralWidget::on_btnAdd_clicked()
|
||||
{
|
||||
ui->lstTools->setCurrentIndex(QModelIndex());
|
||||
prepareEdit();
|
||||
mEditType = EditType::Add;
|
||||
PToolItem item = std::make_shared<ToolItem>();
|
||||
item->title = tr("untitled");
|
||||
item->pauseAfterExit = false;
|
||||
mToolsModel.addTool(item);
|
||||
QModelIndex index=mToolsModel.index(mToolsModel.tools().count()-1);
|
||||
ui->lstTools->setCurrentIndex(index);
|
||||
prepareEdit(item);
|
||||
}
|
||||
|
||||
|
||||
|
@ -189,7 +209,7 @@ void ToolsGeneralWidget::on_btnEditOk_clicked()
|
|||
void ToolsGeneralWidget::on_btnEditCancel_clicked()
|
||||
{
|
||||
mEditType = EditType::None;
|
||||
ui->panelEdit->setVisible(false);
|
||||
showEditPanel(false);
|
||||
}
|
||||
|
||||
void ToolsGeneralWidget::doLoad()
|
||||
|
@ -253,3 +273,4 @@ void ToolsGeneralWidget::on_btnBrowseProgram_clicked()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -52,18 +52,18 @@ class ToolsGeneralWidget : public SettingsWidget
|
|||
Q_OBJECT
|
||||
public:
|
||||
enum class EditType {
|
||||
Add,
|
||||
Edit,
|
||||
None
|
||||
};
|
||||
explicit ToolsGeneralWidget(const QString& name, const QString& group, QWidget *parent = nullptr);
|
||||
~ToolsGeneralWidget();
|
||||
private:
|
||||
void onToolsCurrentChanged();
|
||||
private:
|
||||
void finishEditing(bool askSave);
|
||||
void prepareEdit();
|
||||
void finishEditing(bool askSave, const QModelIndex& itemIndex=QModelIndex());
|
||||
void prepareEdit(const PToolItem& PToolItem);
|
||||
void showEditPanel(bool isShow);
|
||||
private slots:
|
||||
void onEdited();
|
||||
void onToolsCurrentChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
||||
void updateDemo();
|
||||
void on_btnAdd_clicked();
|
||||
|
||||
|
@ -78,12 +78,12 @@ private slots:
|
|||
void on_btnBrowseWorkingDirectory_clicked();
|
||||
|
||||
void on_btnBrowseProgram_clicked();
|
||||
|
||||
private:
|
||||
Ui::ToolsGeneralWidget *ui;
|
||||
MacroInfoModel mMacroInfoModel;
|
||||
ToolsModel mToolsModel;
|
||||
EditType mEditType;
|
||||
bool mEdited;
|
||||
|
||||
// SettingsWidget interface
|
||||
protected:
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<widget class="QWidget" name="panelEditButtons" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
|
@ -67,6 +67,24 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_5" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
|
@ -85,7 +103,7 @@
|
|||
<item>
|
||||
<widget class="QListView" name="lstTools">
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -113,6 +131,77 @@
|
|||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="txtDirectory"/>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="txtParameters"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Working Directory</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="3">
|
||||
<widget class="QLineEdit" name="txtDemo">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="3">
|
||||
<widget class="QCheckBox" name="chkPauseConsole">
|
||||
<property name="text">
|
||||
<string>Pause console after the program exit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="3">
|
||||
<widget class="QWidget" name="widget_2" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnInsertMacro">
|
||||
<property name="text">
|
||||
<string>Insert Macro</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cbMacros">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToContents</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QToolButton" name="btnBrowseProgram">
|
||||
<property name="text">
|
||||
|
@ -124,6 +213,9 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="txtTitle"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
|
@ -131,17 +223,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="txtTitle"/>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="3">
|
||||
<widget class="QLineEdit" name="txtDemo">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="3">
|
||||
<item row="9" column="0" colspan="3">
|
||||
<widget class="QWidget" name="widget_3" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
|
@ -192,8 +274,19 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="txtDirectory"/>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Title</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Program</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QToolButton" name="btnBrowseWorkingDirectory">
|
||||
|
@ -209,82 +302,7 @@
|
|||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="txtProgram"/>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="txtParameters"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Title</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="3">
|
||||
<widget class="QCheckBox" name="chkPauseConsole">
|
||||
<property name="text">
|
||||
<string>Pause console after the program exit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Program</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Working Directory</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="3">
|
||||
<widget class="QWidget" name="widget_2" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnInsertMacro">
|
||||
<property name="text">
|
||||
<string>Insert Macro</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cbMacros">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToContents</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="8" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
|
@ -305,6 +323,9 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../icons.qrc"/>
|
||||
</resources>
|
||||
|
|
|
@ -7276,7 +7276,7 @@
|
|||
</message>
|
||||
<message>
|
||||
<source>Do you want to save changes to the current tool?</source>
|
||||
<translation>Quer salvar as alterações na ferramenta atual?</translation>
|
||||
<translation type="vanished">Quer salvar as alterações na ferramenta atual?</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Choose Folder</source>
|
||||
|
@ -7290,6 +7290,22 @@
|
|||
<source>Executable files (*.exe)</source>
|
||||
<translation>Arquivos executáveis (*.exe)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Do you want to save changes to "%1"?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Error</source>
|
||||
<translation type="unfinished">Erro</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Title shouldn't be empty!</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>untitled</source>
|
||||
<translation type="unfinished">sem nome</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ToolsGitWidget</name>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -6805,10 +6805,6 @@
|
|||
<source>Save Changes?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Do you want to save changes to the current tool?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Choose Folder</source>
|
||||
<translation type="unfinished"></translation>
|
||||
|
@ -6821,6 +6817,22 @@
|
|||
<source>Executable files (*.exe)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Do you want to save changes to "%1"?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Error</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Title shouldn't be empty!</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>untitled</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ToolsGitWidget</name>
|
||||
|
|
Loading…
Reference in New Issue