KCoreAddons

kdelibs4migration.h
Go to the documentation of this file.
1 /*
2  This file is part of the KDE Frameworks
3 
4  SPDX-FileCopyrightText: 2014 David Faure <[email protected]>
5  SPDX-FileCopyrightText: 2014 Ivan Cukic <ivan.cukic(at)kde.org>
6 
7  SPDX-License-Identifier: LGPL-2.0-or-later
8 */
9 
10 #ifndef KDELIBS4MIGRATION_H
11 #define KDELIBS4MIGRATION_H
12 
13 #include <kcoreaddons_export.h>
14 
15 #include <QString>
16 
17 #include <memory>
18 
19 class Kdelibs4MigrationPrivate;
20 
21 /**
22  * \file kdelibs4migration.h
23  */
24 
25 /**
26  * @class Kdelibs4Migration kdelibs4migration.h Kdelibs4Migration
27  *
28  * Kdelibs4Migration provides support for locating config files
29  * and application data files saved by kdelibs 4 in the user's home directory
30  * ($KDEHOME, i.e. typically ~/.kde).
31  *
32  * Distributions that built kdelibs4 with a custom KDE home with
33  * the CMake option _KDE_DEFAULT_HOME_POSTFIX should use the same option
34  * here with _KDE4_DEFAULT_HOME_POSTFIX
35  *
36  * The purpose is to be able to let the application migrate these files
37  * to the KF5/Qt5 location for these files (QStandardPaths).
38  *
39  * Files from the "config" resource (as saved by KConfig) should be migrated to
40  * QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)
41  *
42  * Files from the "data" resource should be migrated to a subdirectory of
43  * QStandardPaths::writableLocation(QStandardPaths::DataLocation)
44  *
45  * The following resources are supported:
46  <ul>
47  <li>config</li>
48  <li>data</li>
49  <li>services</li>
50  <li>servicetypes</li>
51  <li>wallpaper</li>
52  <li>emoticons</li>
53  <li>templates</li>
54  </ul>
55  * Use kdeHome() for anything else.
56  *
57  * @short Class for migration of config files from kdelibs4
58  * @since 5.0
59  */
60 class KCOREADDONS_EXPORT Kdelibs4Migration Q_DECL_FINAL
61 {
62 public:
63  /**
64  * Constructs a Kdelibs4Migration instance.
65  * The constructor attempts to locate the user's "kdehome" from kdelibs4.
66  */
67  explicit Kdelibs4Migration();
68 
69  /**
70  * Destructor
71  */
73 
74  Kdelibs4Migration(const Kdelibs4Migration &) = delete;
75  Kdelibs4Migration &operator=(const Kdelibs4Migration &) = delete;
76 
77  /**
78  * Returns true if a "kdehome" was found.
79  * Otherwise, there is nothing to migrate.
80  */
81  bool kdeHomeFound() const;
82 
83  /**
84  * Returns the kdehome that was found.
85  * Don't use this method if you can use locateLocal or saveLocation
86  * @since 5.13
87  */
88  QString kdeHome() const;
89 
90  /**
91  * Finds a local file in a resource.
92  * This API is inspired by KStandardDirs::locateLocal for ease of porting.
93  * @param type The type of wanted resource.
94  * @param filename A relative filename of the resource.
95  */
96  QString locateLocal(const char *type, const QString &filename) const;
97 
98  /**
99  * Finds a location to save files into for the given type
100  * in the user's home directory.
101  * @param type The type of location to return.
102  * @param suffix A subdirectory name.
103  */
104  QString saveLocation(const char *type, const QString &suffix = QString()) const;
105 
106 private:
107  std::unique_ptr<Kdelibs4MigrationPrivate> const d;
108 };
109 
110 #endif // KFORMAT_H
Kdelibs4Migration provides support for locating config files and application data files saved by kdel...
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Apr 18 2021 23:02:02 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.