Put all KMyMoney config files in kmymoney subdirectory
ClosedPublic

Authored by wojnilowicz on Jan 1 2018, 4:40 PM.

Details

Summary

KMyMoney configuration files are scattered in ~/.config. This patch puts them all in ~/.config/kmymoney for easier backup and potential name clash avoidance with other apps plugins.
Besides it allows migration of more configuration files from KDE 4.
It's also a good moment to rename "Print Check" to "Check printing" as I think is better name in English and Walmart has service by that name :)

Test Plan

Beware: This patch will move your configuration files permanently.

Checked CSV Importer and Check Printing configuration.
Checked migration from KDE 4.

Diff Detail

Repository
R261 KMyMoney
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
wojnilowicz requested review of this revision.Jan 1 2018, 4:40 PM
wojnilowicz created this revision.

How is this supposed to work in other environments (e.g. MS-Windows / MacOS)?

How is this supposed to work in other environments (e.g. MS-Windows / MacOS)?

I obviously didn't test it but I think it shouldn't work differently in these cases.
I wasn't really precise at first i.e. it was not about
~/.config
directory but about
QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation)
directory which happens to be
~/.config
directory on Linux.
For proof, that something like that should work, please look at akonadi. It has its own directory in ~/.config on Linux.

I agree with the intent of this. However, if a user is testing both 4.8 and 5.x versions (assume with different kmy files) then once configuration files are moved by 5.x, will 4.8 create new default files, or will it find them in the new location?) I know it is an uncommon scenario, but we should avoid any surprises.

I agree with the intent of this. However, if a user is testing both 4.8 and 5.x versions (assume with different kmy files) then once configuration files are moved by 5.x, will 4.8 create new default files, or will it find them in the new location?) I know it is an uncommon scenario, but we should avoid any surprises.

AFAIK configuration files for 4.8 are in different location and using 5.x version doesn't affect them, with or without this patch.

tbaumgart requested changes to this revision.Jan 3 2018, 7:54 PM

I get the following error when compiling and currently have no idea how to resolve it:

/home/thb/devel/kmymoney/build> make -j9
[  2%] Automatic moc for target xea2kmt
:
:
[ 86%] Built target matchfinder-test
[ 92%] Built target newloanwizard
[ 98%] Built target views
[ 98%] Building CXX object kmymoney/CMakeFiles/kmymoney.dir/main.cpp.o
/home/thb/devel/kmymoney/kmymoney/main.cpp:367:30: error: no viable conversion from 'KSharedConfig::Ptr' (aka 'QExplicitlySharedDataPointer<KSharedConfig>') to 'const QString'
  KMyMoneySettings::instance(KSharedConfig::openConfig());  // kcfg settings file should be kmymoneyrc, so define it here in one place instead in kmymoney.kcfg
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/qt5/QtCore/qstring.h:217:5: note: candidate constructor not viable: no known conversion from 'KSharedConfig::Ptr' (aka 'QExplicitlySharedDataPointer<KSharedConfig>') to 'QChar' for 1st argument
    QString(QChar c);
    ^
/usr/include/qt5/QtCore/qstring.h:226:12: note: candidate constructor not viable: no known conversion from 'KSharedConfig::Ptr' (aka 'QExplicitlySharedDataPointer<KSharedConfig>') to 'QString &&' for 1st argument
    inline QString(QString && other) Q_DECL_NOTHROW : d(other.d) { other.d = Data::sharedNull(); }
           ^
/usr/include/qt5/QtCore/qstring.h:654:31: note: candidate constructor not viable: no known conversion from 'KSharedConfig::Ptr' (aka 'QExplicitlySharedDataPointer<KSharedConfig>') to 'const char *' for 1st argument
    inline QT_ASCII_CAST_WARN QString(const char *ch)
                              ^
/usr/include/qt5/QtCore/qstring.h:657:31: note: candidate constructor not viable: no known conversion from 'KSharedConfig::Ptr' (aka 'QExplicitlySharedDataPointer<KSharedConfig>') to 'const QByteArray &' for 1st argument
    inline QT_ASCII_CAST_WARN QString(const QByteArray &a)
                              ^
/usr/include/qt5/QtCore/qstring.h:773:12: note: candidate constructor not viable: no known conversion from 'KSharedConfig::Ptr' (aka 'QExplicitlySharedDataPointer<KSharedConfig>') to 'const QString::Null &' for 1st argument
    inline QString(const Null &): d(Data::sharedNull()) {}
           ^
/usr/include/qt5/QtCore/qstring.h:782:29: note: candidate constructor not viable: no known conversion from 'KSharedConfig::Ptr' (aka 'QExplicitlySharedDataPointer<KSharedConfig>') to 'QStringDataPtr' for 1st argument
    Q_DECL_CONSTEXPR inline QString(QStringDataPtr dd) : d(dd.ptr) {}
                            ^
/usr/include/qt5/QtCore/qstring.h:863:17: note: candidate constructor not viable: no known conversion from 'KSharedConfig::Ptr' (aka 'QExplicitlySharedDataPointer<KSharedConfig>') to 'QLatin1String' for 1st argument
inline QString::QString(QLatin1String aLatin1) : d(fromLatin1_helper(aLatin1.latin1(), aLatin1.size()))
                ^
/usr/include/qt5/QtCore/qstring.h:889:17: note: candidate constructor not viable: no known conversion from 'KSharedConfig::Ptr' (aka 'QExplicitlySharedDataPointer<KSharedConfig>') to 'const QString &' for 1st argument
inline QString::QString(const QString &other) Q_DECL_NOTHROW : d(other.d)
                ^
/usr/include/qt5/QtCore/qshareddata.h:151:12: note: candidate function
    inline operator bool () const { return d != Q_NULLPTR; }
           ^
/home/thb/devel/kmymoney/build/kmymoney/kmymoneysettings.h:15:41: note: passing argument to parameter 'cfgfilename' here
    static void instance(const QString& cfgfilename);
                                        ^
1 error generated.
kmymoney/CMakeFiles/kmymoney.dir/build.make:78: recipe for target 'kmymoney/CMakeFiles/kmymoney.dir/main.cpp.o' failed
CMakeFiles/Makefile2:472: recipe for target 'kmymoney/CMakeFiles/kmymoney.dir/all' failed
Makefile:127: recipe for target 'all' failed
make[2]: *** [kmymoney/CMakeFiles/kmymoney.dir/main.cpp.o] Error 1
make[1]: *** [kmymoney/CMakeFiles/kmymoney.dir/all] Error 2
make: *** [all] Error 2
*** Failure: Exit code 2 ***
This revision now requires changes to proceed.Jan 3 2018, 7:54 PM
wojnilowicz updated this revision to Diff 24716.Jan 4 2018, 2:39 PM

Maybe it was enough to add

#include <KSharedConfig>

Please check.

tbaumgart added inline comments.Jan 4 2018, 3:59 PM
kmymoney/main.cpp
367

It still fails. KMyMoneySettings::instance() requires a const QString& to the filename and KSharedConfig::openConfig() returns a pointer to a KSharedConfig object. That somehow does not look right to me. Are you using a different version of KSharedConfig than I do.

wojnilowicz updated this revision to Diff 24729.Jan 4 2018, 5:56 PM
wojnilowicz marked an inline comment as done.

This should work as it provides QString instead of pointer.

wojnilowicz added inline comments.Jan 4 2018, 6:11 PM
kmymoney/main.cpp
367

It seems so. Please look at
https://api.kde.org/frameworks/kconfig/html/classKConfigSkeleton.html
pointer to a KSharedConfig is allowed, so something must have been changed along in time.

Now it compiles even in my (apparently more ancient) environment. I am still not sure if we want this at this point in time, but if you think we are safe, then go for it.

This revision was not accepted when it landed; it landed in state Needs Review.Jan 5 2018, 4:11 PM
This revision was automatically updated to reflect the committed changes.

Now it compiles even in my (apparently more ancient) environment. I am still not sure if we want this at this point in time, but if you think we are safe, then go for it.

We want this because users migrating from KDE4 won't have csvimporterrc migrated and if they would like to migrate to KDE6 then they would know that all KMyMoney configuration files they need are in kmymoney config directory.