Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use QString overload for KConfigGroup #572

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ MainWindow::MainWindow(QWidget* parent)
});
ui->fileMenu->addAction(openNewWindow);
m_recentFilesAction = KStandardAction::openRecent(this, qOverload<const QUrl&>(&MainWindow::openFile), this);
m_recentFilesAction->loadEntries(m_config->group("RecentFiles"));
m_recentFilesAction->loadEntries(m_config->group(QStringLiteral("RecentFiles")));
ui->fileMenu->addAction(m_recentFilesAction);
ui->fileMenu->addSeparator();
m_reloadAction = KStandardAction::redisplay(this, &MainWindow::reload, this);
Expand Down Expand Up @@ -261,7 +261,7 @@ MainWindow::MainWindow(QWidget* parent)

clear();

auto config = m_config->group("Window");
auto config = m_config->group(QStringLiteral("Window"));
restoreGeometry(config.readEntry("geometry", QByteArray()));
restoreState(config.readEntry("state", QByteArray()));
KDDockWidgets::LayoutSaver serializer(KDDockWidgets::RestoreOption_RelativeToMainWindow);
Expand All @@ -280,7 +280,7 @@ MainWindow::~MainWindow() = default;

void MainWindow::closeEvent(QCloseEvent* event)
{
auto config = m_config->group("Window");
auto config = m_config->group(QStringLiteral("Window"));
config.writeEntry("geometry", saveGeometry());
config.writeEntry("state", saveState());

Expand Down Expand Up @@ -360,7 +360,7 @@ void MainWindow::openFile(const QString& path, bool isReload)
m_exportAction->setData(QUrl::fromLocalFile(file.absoluteFilePath() + QLatin1String(".perfparser")));

m_recentFilesAction->addUrl(QUrl::fromLocalFile(file.absoluteFilePath()));
m_recentFilesAction->saveEntries(m_config->group("RecentFiles"));
m_recentFilesAction->saveEntries(m_config->group(QStringLiteral("RecentFiles")));
m_config->sync();
}

Expand Down Expand Up @@ -465,7 +465,7 @@ void MainWindow::setupCodeNavigationMenu()
auto group = new QActionGroup(this);
group->setExclusive(true);

const auto settings = m_config->group("CodeNavigation");
const auto settings = m_config->group(QStringLiteral("CodeNavigation"));
const auto currentIdx = settings.readEntry("IDE", firstAvailableIde());

for (int i = 0; i < ideSettingsSize; ++i) {
Expand Down Expand Up @@ -517,7 +517,7 @@ void MainWindow::setupCodeNavigationMenu()

void MainWindow::setCodeNavigationIDE(QAction* action)
{
auto settings = m_config->group("CodeNavigation");
auto settings = m_config->group(QStringLiteral("CodeNavigation"));

if (action->data() == -1) {
const auto customCmd =
Expand All @@ -538,7 +538,7 @@ void MainWindow::setCodeNavigationIDE(QAction* action)

void MainWindow::navigateToCode(const QString& filePath, int lineNumber, int columnNumber)
{
const auto settings = m_config->group("CodeNavigation");
const auto settings = m_config->group(QStringLiteral("CodeNavigation"));
const auto ideIdx = settings.readEntry("IDE", firstAvailableIde());

QString command;
Expand Down
2 changes: 1 addition & 1 deletion src/recordpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void updateStartRecordingButtonState(const RecordHost* host, const std::unique_p

KConfigGroup config()
{
return KSharedConfig::openConfig()->group("RecordPage");
return KSharedConfig::openConfig()->group(QStringLiteral("RecordPage"));
}

KConfigGroup applicationConfig(const QString& application)
Expand Down
65 changes: 34 additions & 31 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,56 +168,58 @@ void Settings::loadFromFile()
{
auto sharedConfig = KSharedConfig::openConfig();

auto config = sharedConfig->group("Settings");
auto config = sharedConfig->group(QStringLiteral("Settings"));
setPrettifySymbols(config.readEntry("prettifySymbols", true));
setCollapseTemplates(config.readEntry("collapseTemplates", true));
setCollapseDepth(config.readEntry("collapseDepth", 1));

connect(Settings::instance(), &Settings::prettifySymbolsChanged, this, [sharedConfig](bool prettifySymbols) {
sharedConfig->group("Settings").writeEntry("prettifySymbols", prettifySymbols);
sharedConfig->group(QStringLiteral("Settings")).writeEntry("prettifySymbols", prettifySymbols);
});

connect(Settings::instance(), &Settings::collapseTemplatesChanged, this, [sharedConfig](bool collapseTemplates) {
sharedConfig->group("Settings").writeEntry("collapseTemplates", collapseTemplates);
sharedConfig->group(QStringLiteral("Settings")).writeEntry("collapseTemplates", collapseTemplates);
});

connect(this, &Settings::collapseDepthChanged, this, [sharedConfig](int collapseDepth) {
sharedConfig->group("Settings").writeEntry("collapseDepth", collapseDepth);
sharedConfig->group(QStringLiteral("Settings")).writeEntry("collapseDepth", collapseDepth);
});

const QStringList userPaths = {QDir::homePath()};
const QStringList systemPaths = {QDir::rootPath()};
setPaths(sharedConfig->group("PathSettings").readEntry("userPaths", userPaths),
sharedConfig->group("PathSettings").readEntry("systemPaths", systemPaths));
setPaths(sharedConfig->group(QStringLiteral("PathSettings")).readEntry("userPaths", userPaths),
sharedConfig->group(QStringLiteral("PathSettings")).readEntry("systemPaths", systemPaths));
connect(this, &Settings::pathsChanged, this, [sharedConfig, this] {
sharedConfig->group("PathSettings").writeEntry("userPaths", this->userPaths());
sharedConfig->group("PathSettings").writeEntry("systemPaths", this->systemPaths());
sharedConfig->group(QStringLiteral("PathSettings")).writeEntry("userPaths", this->userPaths());
sharedConfig->group(QStringLiteral("PathSettings")).writeEntry("systemPaths", this->systemPaths());
});

// fix build error in app image build
const auto colorScheme = KColorScheme(QPalette::Normal, KColorScheme::View, sharedConfig);
const auto color = colorScheme.background(KColorScheme::AlternateBackground).color().name();
const auto currentColor = colorScheme.background(KColorScheme::ActiveBackground).color().name();

setCallgraphParentDepth(sharedConfig->group("CallgraphSettings").readEntry("parent", 3));
setCallgraphChildDepth(sharedConfig->group("CallgraphSettings").readEntry("child", 3));
setCallgraphColors(sharedConfig->group("CallgraphSettings").readEntry("activeColor", currentColor),
sharedConfig->group("CallgraphSettings").readEntry("color", color));
setCallgraphParentDepth(sharedConfig->group(QStringLiteral("CallgraphSettings")).readEntry("parent", 3));
setCallgraphChildDepth(sharedConfig->group(QStringLiteral("CallgraphSettings")).readEntry("child", 3));
setCallgraphColors(sharedConfig->group(QStringLiteral("CallgraphSettings")).readEntry("activeColor", currentColor),
sharedConfig->group(QStringLiteral("CallgraphSettings")).readEntry("color", color));
connect(this, &Settings::callgraphChanged, this, [sharedConfig, this] {
sharedConfig->group("CallgraphSettings").writeEntry("parent", this->callgraphParentDepth());
sharedConfig->group("CallgraphSettings").writeEntry("child", this->callgraphChildDepth());
sharedConfig->group("CallgraphSettings").writeEntry("activeColor", this->callgraphActiveColor());
sharedConfig->group("CallgraphSettings").writeEntry("color", this->callgraphColor());
sharedConfig->group(QStringLiteral("CallgraphSettings")).writeEntry("parent", this->callgraphParentDepth());
sharedConfig->group(QStringLiteral("CallgraphSettings")).writeEntry("child", this->callgraphChildDepth());
sharedConfig->group(QStringLiteral("CallgraphSettings"))
.writeEntry("activeColor", this->callgraphActiveColor());
sharedConfig->group(QStringLiteral("CallgraphSettings")).writeEntry("color", this->callgraphColor());
});

setDebuginfodUrls(sharedConfig->group("debuginfod").readEntry("urls", QStringList()));
connect(this, &Settings::debuginfodUrlsChanged, this,
[sharedConfig, this] { sharedConfig->group("debuginfod").writeEntry("urls", this->debuginfodUrls()); });
setDebuginfodUrls(sharedConfig->group(QStringLiteral("debuginfod")).readEntry("urls", QStringList()));
connect(this, &Settings::debuginfodUrlsChanged, this, [sharedConfig, this] {
sharedConfig->group(QStringLiteral("debuginfod")).writeEntry("urls", this->debuginfodUrls());
});

m_lastUsedEnvironment = sharedConfig->group("PerfPaths").readEntry("lastUsed");
m_lastUsedEnvironment = sharedConfig->group(QStringLiteral("PerfPaths")).readEntry("lastUsed");

if (!m_lastUsedEnvironment.isEmpty()) {
auto currentConfig = sharedConfig->group("PerfPaths").group(m_lastUsedEnvironment);
auto currentConfig = sharedConfig->group(QStringLiteral("PerfPaths")).group(m_lastUsedEnvironment);
setSysroot(currentConfig.readEntry("sysroot", ""));
setAppPath(currentConfig.readEntry("appPath", ""));
setExtraLibPaths(currentConfig.readEntry("extraLibPaths", ""));
Expand All @@ -228,27 +230,28 @@ void Settings::loadFromFile()
setPerfMapPath(currentConfig.readEntry("perfMapPath", ""));
}

setPerfPath(sharedConfig->group("Perf").readEntry("path", ""));
connect(this, &Settings::perfPathChanged, this,
[sharedConfig](const QString& perfPath) { sharedConfig->group("Perf").writeEntry("path", perfPath); });
setPerfPath(sharedConfig->group(QStringLiteral("Perf")).readEntry("path", ""));
connect(this, &Settings::perfPathChanged, this, [sharedConfig](const QString& perfPath) {
sharedConfig->group(QStringLiteral("Perf")).writeEntry("path", perfPath);
});

connect(this, &Settings::lastUsedEnvironmentChanged, this, [sharedConfig](const QString& envName) {
sharedConfig->group("PerfPaths").writeEntry("lastUsed", envName);
sharedConfig->group(QStringLiteral("PerfPaths")).writeEntry("lastUsed", envName);
});

setSourceCodePaths(sharedConfig->group("Disassembly").readEntry("sourceCodePaths", QString()));
setSourceCodePaths(sharedConfig->group(QStringLiteral("Disassembly")).readEntry("sourceCodePaths", QString()));
connect(this, &Settings::sourceCodePathsChanged, this, [sharedConfig](const QString& paths) {
sharedConfig->group("Disassembly").writeEntry("sourceCodePaths", paths);
sharedConfig->group(QStringLiteral("Disassembly")).writeEntry("sourceCodePaths", paths);
});

setShowBranches(sharedConfig->group("Disassembly").readEntry("showBranches", true));
setShowBranches(sharedConfig->group(QStringLiteral("Disassembly")).readEntry("showBranches", true));
connect(this, &Settings::showBranchesChanged, [sharedConfig](bool showBranches) {
sharedConfig->group("Disassembly").writeEntry("showBranches", showBranches);
sharedConfig->group(QStringLiteral("Disassembly")).writeEntry("showBranches", showBranches);
});

setShowBranches(sharedConfig->group("Disassembly").readEntry("showHexdump", false));
setShowBranches(sharedConfig->group(QStringLiteral("Disassembly")).readEntry("showHexdump", false));
connect(this, &Settings::showHexdumpChanged, [sharedConfig](bool showHexdump) {
sharedConfig->group("Disassembly").writeEntry("showHexdump", showHexdump);
sharedConfig->group(QStringLiteral("Disassembly")).writeEntry("showHexdump", showHexdump);
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
namespace {
KConfigGroup config()
{
return KSharedConfig::openConfig()->group("PerfPaths");
return KSharedConfig::openConfig()->group(QStringLiteral("PerfPaths"));
}

QPushButton* setupMultiPath(KEditListWidget* listWidget, QLabel* buddy, QWidget* previous)
Expand Down