From ebd14f29f8052ff5119bf97b42e61f404f223615 Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Sun, 5 Jan 2020 21:02:08 +0100 Subject: Add KSharedConfig::openStateConfig for storing state information Summary: A common complaint is that our apps store 'state' information such as recent files or window sizes in their configuration files, making it ugly to store them in version control systems. Therefore we should not store such information in XDG_CONFIG_DIR but instead use XDG_DATA_DIR for this. This patch adds a utility method that creates a KSharedConfig backed by a file in such a suitable location. For e.g. dolphin the file .local/share/dolphin/dolphinstaterc would be created. See T12246 for some context Reviewers: #frameworks, dfaure Reviewed By: dfaure Subscribers: kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D26440 --- src/core/ksharedconfig.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/core/ksharedconfig.cpp') diff --git a/src/core/ksharedconfig.cpp b/src/core/ksharedconfig.cpp index 0b2b9c35..0530abac 100644 --- a/src/core/ksharedconfig.cpp +++ b/src/core/ksharedconfig.cpp @@ -121,6 +121,17 @@ KSharedConfigPtr KSharedConfig::openConfig(const QString &_fileName, return ptr; } +KSharedConfig::Ptr KSharedConfig::openStateConfig(const QString &_fileName) +{ + QString fileName(_fileName); + + if (fileName.isEmpty()) { + fileName = QCoreApplication::applicationName() + QLatin1String("staterc"); + } + + return openConfig(fileName, SimpleConfig, QStandardPaths::AppDataLocation); +} + KSharedConfig::KSharedConfig(const QString &fileName, OpenFlags flags, QStandardPaths::StandardLocation resType) -- cgit v1.2.1