Remember last selected Decompiler

This commit is contained in:
Florian Märkl 2019-07-16 20:33:05 +02:00 committed by xarkes
parent 26dce4c7b9
commit dee24b861d
4 changed files with 27 additions and 0 deletions

View File

@ -642,3 +642,13 @@ QStringList Configuration::getTranslationsDirectories() const
#endif // Q_OS_MAC #endif // Q_OS_MAC
}; };
} }
QString Configuration::getSelectedDecompiler()
{
return s.value("selectedDecompiler").toString();
}
void Configuration::setSelectedDecompiler(const QString &id)
{
s.setValue("selectedDecompiler", id);
}

View File

@ -148,6 +148,12 @@ public:
*/ */
QStringList getTranslationsDirectories() const; QStringList getTranslationsDirectories() const;
/**
* @return id of the last selected decompiler (see CutterCore::getDecompilerById)
*/
QString getSelectedDecompiler();
void setSelectedDecompiler(const QString &id);
signals: signals:
void fontsUpdated(); void fontsUpdated();
void colorsUpdated(); void colorsUpdated();

View File

@ -60,8 +60,12 @@ PseudocodeWidget::PseudocodeWidget(MainWindow *main, QAction *action) :
}); });
auto decompilers = Core()->getDecompilers(); auto decompilers = Core()->getDecompilers();
auto selectedDecompilerId = Config()->getSelectedDecompiler();
for (auto dec : decompilers) { for (auto dec : decompilers) {
ui->decompilerComboBox->addItem(dec->getName(), dec->getId()); ui->decompilerComboBox->addItem(dec->getName(), dec->getId());
if (dec->getId() == selectedDecompilerId) {
ui->decompilerComboBox->setCurrentIndex(ui->decompilerComboBox->count() - 1);
}
} }
if(decompilers.size() <= 1) { if(decompilers.size() <= 1) {
@ -71,6 +75,7 @@ PseudocodeWidget::PseudocodeWidget(MainWindow *main, QAction *action) :
} }
} }
connect(ui->decompilerComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &PseudocodeWidget::decompilerSelected);
connectCursorPositionChanged(false); connectCursorPositionChanged(false);
connect(Core(), &CutterCore::seekChanged, this, &PseudocodeWidget::seekChanged); connect(Core(), &CutterCore::seekChanged, this, &PseudocodeWidget::seekChanged);
@ -124,6 +129,11 @@ void PseudocodeWidget::refreshPseudocode()
doRefresh(Core()->getOffset()); doRefresh(Core()->getOffset());
} }
void PseudocodeWidget::decompilerSelected()
{
Configuration().setSelectedDecompiler(ui->decompilerComboBox->currentData().toString());
}
void PseudocodeWidget::connectCursorPositionChanged(bool disconnect) void PseudocodeWidget::connectCursorPositionChanged(bool disconnect)
{ {
if (disconnect) { if (disconnect) {

View File

@ -27,6 +27,7 @@ private slots:
void fontsUpdated(); void fontsUpdated();
void colorsUpdatedSlot(); void colorsUpdatedSlot();
void refreshPseudocode(); void refreshPseudocode();
void decompilerSelected();
void cursorPositionChanged(); void cursorPositionChanged();
void seekChanged(); void seekChanged();