Skip to content

Commit dee24b8

Browse files
thestr4ng3rxarkes
authored andcommitted
Remember last selected Decompiler
1 parent 26dce4c commit dee24b8

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

src/common/Configuration.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -642,3 +642,13 @@ QStringList Configuration::getTranslationsDirectories() const
642642
#endif // Q_OS_MAC
643643
};
644644
}
645+
646+
QString Configuration::getSelectedDecompiler()
647+
{
648+
return s.value("selectedDecompiler").toString();
649+
}
650+
651+
void Configuration::setSelectedDecompiler(const QString &id)
652+
{
653+
s.setValue("selectedDecompiler", id);
654+
}

src/common/Configuration.h

+6
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ class Configuration : public QObject
148148
*/
149149
QStringList getTranslationsDirectories() const;
150150

151+
/**
152+
* @return id of the last selected decompiler (see CutterCore::getDecompilerById)
153+
*/
154+
QString getSelectedDecompiler();
155+
void setSelectedDecompiler(const QString &id);
156+
151157
signals:
152158
void fontsUpdated();
153159
void colorsUpdated();

src/widgets/PseudocodeWidget.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,12 @@ PseudocodeWidget::PseudocodeWidget(MainWindow *main, QAction *action) :
6060
});
6161

6262
auto decompilers = Core()->getDecompilers();
63+
auto selectedDecompilerId = Config()->getSelectedDecompiler();
6364
for (auto dec : decompilers) {
6465
ui->decompilerComboBox->addItem(dec->getName(), dec->getId());
66+
if (dec->getId() == selectedDecompilerId) {
67+
ui->decompilerComboBox->setCurrentIndex(ui->decompilerComboBox->count() - 1);
68+
}
6569
}
6670

6771
if(decompilers.size() <= 1) {
@@ -71,6 +75,7 @@ PseudocodeWidget::PseudocodeWidget(MainWindow *main, QAction *action) :
7175
}
7276
}
7377

78+
connect(ui->decompilerComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &PseudocodeWidget::decompilerSelected);
7479
connectCursorPositionChanged(false);
7580
connect(Core(), &CutterCore::seekChanged, this, &PseudocodeWidget::seekChanged);
7681

@@ -124,6 +129,11 @@ void PseudocodeWidget::refreshPseudocode()
124129
doRefresh(Core()->getOffset());
125130
}
126131

132+
void PseudocodeWidget::decompilerSelected()
133+
{
134+
Configuration().setSelectedDecompiler(ui->decompilerComboBox->currentData().toString());
135+
}
136+
127137
void PseudocodeWidget::connectCursorPositionChanged(bool disconnect)
128138
{
129139
if (disconnect) {

src/widgets/PseudocodeWidget.h

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ private slots:
2727
void fontsUpdated();
2828
void colorsUpdatedSlot();
2929
void refreshPseudocode();
30+
void decompilerSelected();
3031
void cursorPositionChanged();
3132
void seekChanged();
3233

0 commit comments

Comments
 (0)