Skip to content

Commit

Permalink
feat: show current unwind settings in settings dialog
Browse files Browse the repository at this point in the history
If the settings are set by the command line they are not shown in the
dialog.
  • Loading branch information
lievenhey committed Jun 4, 2024
1 parent 081812d commit ec5632c
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 31 deletions.
69 changes: 40 additions & 29 deletions src/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,32 +89,6 @@ void SettingsDialog::initSettings()
}
}

void SettingsDialog::initSettings(const QString& sysroot, const QString& appPath, const QString& extraLibPaths,
const QString& debugPaths, const QString& kallsyms, const QString& arch,
const QString& objdump)
{
auto fromPathString = [](KEditListWidget* listWidget, const QString& string) {
listWidget->setItems(string.split(QLatin1Char(':'), Qt::SkipEmptyParts));
};
fromPathString(unwindPage->extraLibraryPaths, extraLibPaths);
fromPathString(unwindPage->debugPaths, debugPaths);

unwindPage->lineEditSysroot->setText(sysroot);
unwindPage->lineEditApplicationPath->setText(appPath);
unwindPage->lineEditKallsyms->setText(kallsyms);
unwindPage->lineEditObjdump->setText(objdump);

int itemIndex = 0;
if (!arch.isEmpty()) {
itemIndex = unwindPage->comboBoxArchitecture->findText(arch);
if (itemIndex == -1) {
itemIndex = unwindPage->comboBoxArchitecture->count();
unwindPage->comboBoxArchitecture->addItem(arch);
}
}
unwindPage->comboBoxArchitecture->setCurrentIndex(itemIndex);
}

QString SettingsDialog::sysroot() const
{
return unwindPage->lineEditSysroot->text();
Expand Down Expand Up @@ -188,6 +162,33 @@ void SettingsDialog::addPathSettingsPage()
auto* label = new QLabel(this);
label->setText(tr("Config:"));

auto loadFromSettings = [this]() {
auto settings = Settings::instance();
auto fromPathString = [](KEditListWidget* listWidget, const QString& string) {
listWidget->setItems(string.split(QLatin1Char(':'), Qt::SkipEmptyParts));
};
fromPathString(unwindPage->extraLibraryPaths, settings->extraLibPaths());
fromPathString(unwindPage->debugPaths, settings->debugPaths());

unwindPage->lineEditSysroot->setText(settings->sysroot());
unwindPage->lineEditApplicationPath->setText(settings->appPath());
unwindPage->lineEditKallsyms->setText(settings->kallsyms());
unwindPage->lineEditObjdump->setText(settings->objdump());

const auto arch = settings->arch();
int itemIndex = 0;
if (!arch.isEmpty()) {
itemIndex = unwindPage->comboBoxArchitecture->findText(arch);
if (itemIndex == -1) {
itemIndex = unwindPage->comboBoxArchitecture->count();
unwindPage->comboBoxArchitecture->addItem(arch);
}
}
unwindPage->comboBoxArchitecture->setCurrentIndex(itemIndex);
};

loadFromSettings();

auto saveFunction = [this](KConfigGroup group) {
group.writeEntry("sysroot", sysroot());
group.writeEntry("appPath", appPath());
Expand All @@ -198,16 +199,26 @@ void SettingsDialog::addPathSettingsPage()
group.writeEntry("objdump", objdump());
};

auto restoreFunction = [this](const KConfigGroup& group) {
auto restoreFunction = [this, loadFromSettings](const KConfigGroup& group) {
::config().writeEntry("lastUsed", m_configs->currentConfig());
auto settings = Settings::instance();

const auto sysroot = group.readEntry("sysroot");
settings->setSysroot(sysroot);
const auto appPath = group.readEntry("appPath");
settings->setAppPath(appPath);
const auto extraLibPaths = group.readEntry("extraLibPaths");
settings->setExtraLibPaths(extraLibPaths);
const auto debugPaths = group.readEntry("debugPaths");
settings->setDebugPaths(debugPaths);
const auto kallsyms = group.readEntry("kallsyms");
settings->setKallsyms(kallsyms);
const auto arch = group.readEntry("arch");
settings->setArch(arch);
const auto objdump = group.readEntry("objdump");
initSettings(sysroot, appPath, extraLibPaths, debugPaths, kallsyms, arch, objdump);
::config().writeEntry("lastUsed", m_configs->currentConfig());
settings->setObjdump(objdump);

loadFromSettings();
};

m_configs = new MultiConfigWidget(this);
Expand Down
2 changes: 0 additions & 2 deletions src/settingsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ class SettingsDialog : public KPageDialog
explicit SettingsDialog(QWidget* parent = nullptr);
~SettingsDialog();
void initSettings();
void initSettings(const QString& sysroot, const QString& appPath, const QString& extraLibPaths,
const QString& debugPaths, const QString& kallsyms, const QString& arch, const QString& objdump);
QString sysroot() const;
QString appPath() const;
QString extraLibPaths() const;
Expand Down

0 comments on commit ec5632c

Please sign in to comment.