On Wednesday 27 January 2016 10:32:50 Boudewijn Rempt wrote:
> On Sat, 23 Jan 2016, David Faure wrote:
> 
> >
> > Not sure this answers Boud's question, since he *is* seeing "Local" on 
> > Windows.
> > He said: "I noticed that krita on windows wrote its kritarc to 
> > Roaming\local\ or Local\local "
> 
> Hm, looks like that was a sideeffect of something else I tried, it's now in 
> Roaming\Local
> 
> >
> > According to the QStandardPaths documentation, it is expected to see
> > something like "C:/Users/<USER>/AppData/Local" in the paths for 
> > GenericConfigLocation
> >
> > The the lowercase "local" after that puzzles me. I wonder where that comes 
> > from,
> > it's not anywhere in the QStandardPaths code for Windows, nor KConfig 
> > AFAICS.
> >
> > Boud, how is KConfig called exactly?
> >  (I don't mean "it's called KConfig" ;-) I mean what does the code using 
> > it, look like?
> >  I think this needs some debugging to find out where this "local" string 
> > comes from)
> 
> Well, it's done in a lot of places, about 160, like:
> 
>   KConfigGroup cfg =  
> KSharedConfig::openConfig()->group("advancedColorSelector");
> 
> or
> 
>   KConfigGroup cg(KSharedConfig::openConfig(), "");
> 
> 
> What I want in the end is have AppData\Roaming\Krita\ where both kritarc and 
> the user's
> custom resources are saved, like brushes and so on. I'm fine with patching 
> kconfig for
> windows for that, though.
> 
> > Don't forget that KConfig is also used by libraries, not just by 
> > applications.
> > Let's pick a random example: KIO, which stores the KFileWidget mode (icon 
> > or list) that the user prefers.
> > Right now this is global, it affects all applications. If you make KConfig 
> > use AppConfigLocation
> > by default, then suddenly this setting is per application. Maybe no big 
> > deal for this particular one,
> > but imagine having to select your spellcheck dictionaries in all apps or 
> > <insert a ton more global settings here>.
> 
> Well, those are resources, aren't they? Not config files. But I confuse 
> myself all the time, too, with those two.
> 
> > In general, I don't like AppConfigLocation, we've been bitten by "appdata" 
> > too much in kde4 times, same issue:
> > some code starts as app code, it uses such an app-specific location type, 
> > then it's moved to a library,
> > and that breaks sharing data between apps (example: kmail identities, 
> > initially in kmail, then one day
> > moved to a library --> definitely want the identities to be shared, not per 
> > app). But I guess that's my
> > "library developer" point of view, I can understand that application 
> > developers don't want to hardcode
> > "krita/kritarc" everywhere...
> 
> Yes... But given that I need to build kconfig on windows myself anyway, I 
> guess I can just patch that. In the
> beginning I was just wondering wether this was the right behaviour.

Sounds to me like Patrick's pending patch to add configurable paths in 
QStandardPaths using qt.conf
would work exactly right for this. Your windows installer for krita would 
install a qt.conf where
GenericConfigLocation = [...]\AppData\Roaming\Krita.

-- 
David Faure, fa...@kde.org, http://www.davidfaure.fr
Working on KDE Frameworks 5
>From c6524a252fc362abe5b8412dcabec499ff092143 Mon Sep 17 00:00:00 2001
From: Patrick Spendrin <ps...@gmx.de>
Date: Tue, 29 Sep 2015 15:47:09 +0200
Subject: [PATCH] WIP: configurable standardpaths

---
 src/corelib/global/global.pri         |  1 +
 src/corelib/global/qlibraryinfo.cpp   | 49 +++++++++++++---------------
 src/corelib/global/qlibraryinfo_p.h   | 61 +++++++++++++++++++++++++++++++++++
 src/corelib/io/qstandardpaths.cpp     | 42 ++++++++++++++++++++++++
 src/corelib/io/qstandardpaths.h       |  2 ++
 src/corelib/io/qstandardpaths_mac.mm  |  4 +++
 src/corelib/io/qstandardpaths_win.cpp |  4 ++-
 7 files changed, 136 insertions(+), 27 deletions(-)
 create mode 100644 src/corelib/global/qlibraryinfo_p.h

diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri
index 6a8104b..a905cb2 100644
--- a/src/corelib/global/global.pri
+++ b/src/corelib/global/global.pri
@@ -10,6 +10,7 @@ HEADERS +=  \
         global/qnumeric_p.h \
         global/qnumeric.h \
         global/qglobalstatic.h \
+        global/qlibraryinfo_p.h \
         global/qlibraryinfo.h \
         global/qlogging.h \
         global/qtypeinfo.h \
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index 0cfcc4e..640e9cf 100644
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -38,6 +38,7 @@
 #include "qsettings.h"
 #include "qlibraryinfo.h"
 #include "qscopedpointer.h"
+#include "qlibraryinfo_p.h"
 
 #ifdef QT_BUILD_QMAKE
 QT_BEGIN_NAMESPACE
@@ -77,37 +78,33 @@ struct QLibrarySettings
 };
 Q_GLOBAL_STATIC(QLibrarySettings, qt_library_settings)
 
-class QLibraryInfoPrivate
-{
-public:
-    static QSettings *findConfiguration();
 #ifdef QT_BUILD_QMAKE
-    static bool haveGroup(QLibraryInfo::PathGroup group)
-    {
-        QLibrarySettings *ls = qt_library_settings();
-        return ls ? (group == QLibraryInfo::EffectiveSourcePaths
-                     ? ls->haveEffectiveSourcePaths
-                     : group == QLibraryInfo::EffectivePaths
-                       ? ls->haveEffectivePaths
-                       : group == QLibraryInfo::DevicePaths
-                         ? ls->haveDevicePaths
-                         : ls->havePaths) : false;
-    }
+bool QLibraryInfoPrivate::haveGroup(QLibraryInfo::PathGroup group)
+{
+    QLibrarySettings *ls = qt_library_settings();
+    return ls ? (group == QLibraryInfo::EffectiveSourcePaths
+                    ? ls->haveEffectiveSourcePaths
+                    : group == QLibraryInfo::EffectivePaths
+                    ? ls->haveEffectivePaths
+                    : group == QLibraryInfo::DevicePaths
+                        ? ls->haveDevicePaths
+                        : ls->havePaths) : false;
+}
 #endif
-    static QSettings *configuration()
-    {
-        QLibrarySettings *ls = qt_library_settings();
-        if (ls) {
+QSettings *QLibraryInfoPrivate::configuration()
+{
+    QLibrarySettings *ls = qt_library_settings();
+    if (ls) {
 #ifndef QT_BUILD_QMAKE
-            if (ls->reloadOnQAppAvailable && QCoreApplication::instance() != 0)
-                ls->load();
+        if (ls->reloadOnQAppAvailable && QCoreApplication::instance() != 0)
+            ls->load();
 #endif
-            return ls->settings.data();
-        } else {
-            return 0;
-        }
+        return ls->settings.data();
+    } else {
+        return 0;
     }
-};
+}
+
 
 static const char platformsSection[] = "Platforms";
 
diff --git a/src/corelib/global/qlibraryinfo_p.h b/src/corelib/global/qlibraryinfo_p.h
new file mode 100644
index 0000000..e6e1b15
--- /dev/null
+++ b/src/corelib/global/qlibraryinfo_p.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLIBRARYINFO_P_H
+#define QLIBRARYINFO_P_H
+
+//
+//  W A R N I N G
+//  -------------
+//
+// This file is not part of the Qt API.  It exists purely as an
+// implementation detail.  This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qsettings.h"
+#include "qlibraryinfo.h"
+
+class QLibraryInfoPrivate
+{
+public:
+    static QSettings *findConfiguration();
+#ifdef QT_BUILD_QMAKE
+    static bool haveGroup(QLibraryInfo::PathGroup group);
+#endif
+    static QSettings *configuration();
+};
+
+#endif
\ No newline at end of file
diff --git a/src/corelib/io/qstandardpaths.cpp b/src/corelib/io/qstandardpaths.cpp
index 74252d1..5bcfe2a 100644
--- a/src/corelib/io/qstandardpaths.cpp
+++ b/src/corelib/io/qstandardpaths.cpp
@@ -36,6 +36,10 @@
 #include <qdir.h>
 #include <qfileinfo.h>
 #include <qhash.h>
+// #include <QtCore/private/qlibraryinfo_p.h>
+#if !defined(QT_BUILD_QMAKE) && !defined(QT_NO_SETTINGS) && !defined(QT_BOOTSTRAPPED)
+#include "../global/qlibraryinfo_p.h"
+#endif
 
 #ifndef QT_BOOTSTRAPPED
 #include <qobject.h>
@@ -661,6 +665,44 @@ bool QStandardPaths::isTestModeEnabled()
     return qsp_testMode;
 }
 
+static const char standardPathsSection[] = "StandardPaths";
+
+QString QStandardPaths::presetLocation(StandardLocation type)
+{
+#if !defined(QT_BUILD_QMAKE) && !defined(QT_NO_SETTINGS) && !defined(QT_BOOTSTRAPPED)
+    QStringList locations = QStringList()   << QStringLiteral("DesktopLocation")
+                                            << QStringLiteral("DocumentsLocation")
+                                            << QStringLiteral("FontsLocation")
+                                            << QStringLiteral("ApplicationsLocation")
+                                            << QStringLiteral("MusicLocation")
+                                            << QStringLiteral("MoviesLocation")
+                                            << QStringLiteral("PicturesLocation")
+                                            << QStringLiteral("TempLocation")
+                                            << QStringLiteral("HomeLocation")
+                                            << QStringLiteral("DataLocation")
+                                            << QStringLiteral("CacheLocation")
+                                            << QStringLiteral("GenericDataLocation")
+                                            << QStringLiteral("RuntimeLocation")
+                                            << QStringLiteral("ConfigLocation")
+                                            << QStringLiteral("DownloadLocation")
+                                            << QStringLiteral("GenericCacheLocation")
+                                            << QStringLiteral("GenericConfigLocation")
+                                            << QStringLiteral("AppDataLocation")
+                                            << QStringLiteral("AppConfigLocation")
+                                            << QStringLiteral("AppLocalDataLocation");
+
+    QScopedPointer<const QSettings> settings(QLibraryInfoPrivate::findConfiguration());
+    if (!settings.isNull()) {
+        QString key = QLatin1String(standardPathsSection);
+        key += QLatin1Char('/');
+        key += locations[type];
+        return settings->value(key).toString();
+    }
+#endif // !QT_BUILD_QMAKE && !QT_NO_SETTINGS
+
+    return QString();
+}
+
 
 QT_END_NAMESPACE
 
diff --git a/src/corelib/io/qstandardpaths.h b/src/corelib/io/qstandardpaths.h
index 5c0e08b..2fb29bb 100644
--- a/src/corelib/io/qstandardpaths.h
+++ b/src/corelib/io/qstandardpaths.h
@@ -92,6 +92,8 @@ public:
     static bool isTestModeEnabled();
 
 private:
+    static QString presetLocation(StandardLocation type);
+
     // prevent construction
     QStandardPaths();
     ~QStandardPaths();
diff --git a/src/corelib/io/qstandardpaths_mac.mm b/src/corelib/io/qstandardpaths_mac.mm
index d6126ce..29333bd 100644
--- a/src/corelib/io/qstandardpaths_mac.mm
+++ b/src/corelib/io/qstandardpaths_mac.mm
@@ -138,6 +138,10 @@ static QString macLocation(QStandardPaths::StandardLocation type, short domain)
 
 QString QStandardPaths::writableLocation(StandardLocation type)
 {
+    const QString result = QStandardPaths::presetLocation(type);
+    if(!result.isEmpty())
+        return result;
+
     if (isTestModeEnabled()) {
         const QString qttestDir = QDir::homePath() + QLatin1String("/.qttest");
         QString path;
diff --git a/src/corelib/io/qstandardpaths_win.cpp b/src/corelib/io/qstandardpaths_win.cpp
index b1d5821..76d569d 100644
--- a/src/corelib/io/qstandardpaths_win.cpp
+++ b/src/corelib/io/qstandardpaths_win.cpp
@@ -87,7 +87,9 @@ static inline int clsidForAppDataLocation(QStandardPaths::StandardLocation type)
 
 QString QStandardPaths::writableLocation(StandardLocation type)
 {
-    QString result;
+    QString result = QStandardPaths::presetLocation(type);
+    if (!result.isEmpty())
+        return result;
 
 #if !defined(Q_OS_WINCE)
     static GetKnownFolderPath SHGetKnownFolderPath = (GetKnownFolderPath)QSystemLibrary::resolve(QLatin1String("shell32"), "SHGetKnownFolderPath");
-- 
2.5.0.windows.1

_______________________________________________
Kde-frameworks-devel mailing list
Kde-frameworks-devel@kde.org
https://mail.kde.org/mailman/listinfo/kde-frameworks-devel

Reply via email to