|
Krita Source Code Documentation
|
#include <KoResourcePaths.h>
Inheritance diagram for KoResourcePaths:Public Types | |
| enum | SearchOption { NoSearchOptions = 0 , Recursive = 1 , IgnoreExecBit = 4 } |
Public Member Functions | |
| QStringList | aliases (const QString &type) |
| KoResourcePaths () | |
| QStandardPaths::StandardLocation | mapTypeToQStandardPaths (const QString &type) |
| virtual | ~KoResourcePaths () |
Static Public Member Functions | |
| static void | addAssetDir (const QString &type, const QString &dir, bool priority=true) |
| static void | addAssetType (const QString &type, const char *basetype, const QString &relativeName, bool priority=true) |
| static QStringList | assetDirs (const QString &type) |
| static QStringList | findAllAssets (const QString &type, const QString &filter=QString(), SearchOptions options=NoSearchOptions) |
| static QString | findAsset (const QString &type, const QString &fileName) |
| static QStringList | findDirs (const QString &type) |
| static void | getAllUserResourceFoldersLocationsForWindowsStore (QString &standardLocation, QString &privateLocation) |
| getAllAppDataLocationsForWindowsStore Use this to get both private and general appdata folders which also considers user's choice of custom resource folder Used in GeneralTab in kis_dlg_preferences, and KisViewManager::openResourceDirectory(). | |
| static QString | getAppDataLocation () |
| static QString | getApplicationRoot () |
| static QString | locate (const QString &type, const QString &filename) |
| static QString | locateLocal (const QString &type, const QString &filename, bool createDir=false) |
| static QString | saveLocation (const QString &type, const QString &suffix=QString(), bool create=true) |
Public Attributes | |
| QMap< QString, QStringList > | absolutes |
| QMutex | absolutesMutex |
| QMap< QString, QStringList > | relatives |
| QMutex | relativesMutex |
Static Public Attributes | |
| static QString | s_overrideAppDataLocation |
| getAppDataLocation Use this instead of QStandardPaths::AppDataLocation! The user can configure the location where resources and other user writable items are stored now. | |
Private Member Functions | |
| void | addResourceDirInternal (const QString &type, const QString &absdir, bool priority) |
| void | addResourceTypeInternal (const QString &type, const QString &basetype, const QString &relativeName, bool priority) |
| QStringList | findAllResourcesInternal (const QString &type, const QString &filter=QString(), SearchOptions options=NoSearchOptions) const |
| QStringList | findDirsInternal (const QString &type) |
| QStringList | findExtraResourceDirs () const |
| QString | findResourceInternal (const QString &type, const QString &fileName) |
| QString | locateInternal (const QString &type, const QString &filename) |
| QString | locateLocalInternal (const QString &type, const QString &filename, bool createDir=false) |
| QStringList | resourceDirsInternal (const QString &type) |
| QString | saveLocationInternal (const QString &type, const QString &suffix=QString(), bool create=true) |
Private Member Functions inherited from Private | |
| Private (KisCanvas2 *c) | |
Private Attributes | |
| QScopedPointer< Private > | d |
Private Attributes inherited from Private | |
| KisCanvas2 * | canvas |
| int | displayedFrame |
| int | intendedFrame |
The usual place to look for assets is Qt's AppDataLocation. This corresponds to XDG_DATA_DIRS on Linux. To ensure your installation and path are configured correctly, ensure your files are located in the directories contained in this variable:
QStandardPaths::standardLocations(QStandardPaths::AppDataLocation);
This can be overridden in Krita's configuration.
Unfortunately, we are mixing up two things in the appdatalocation:
There are many debug lines that can be uncommented for more specific installation checks. In the future these should be converted to qloggingcategory to enable convenient enable/disable functionality.
Note: DO NOT USE THIS CLASS WHEN LOCATING RESOURCES LIKE BRUSHES OR GRADIENTS. Use KisResourceLocator instead.
Definition at line 156 of file KoResourcePaths.cpp.
| Enumerator | |
|---|---|
| NoSearchOptions | |
| Recursive | |
| IgnoreExecBit | |
Definition at line 45 of file KoResourcePaths.h.
| KoResourcePaths::KoResourcePaths | ( | ) |
Definition at line 205 of file KoResourcePaths.cpp.
|
virtual |
Definition at line 210 of file KoResourcePaths.cpp.
|
static |
Adds absolute path at the beginning of the search path for particular types (for example in case of icons where the user specifies extra paths).
You shouldn't need this function in 99% of all cases besides adding user-given paths.
| type | Specifies a short descriptive string to access files of this type. |
| absdir | Points to directory where to look for this specific type. Nonexistent directories may be saved but pruned. |
| priority | if true, the directory is added before any other, otherwise after |
Definition at line 304 of file KoResourcePaths.cpp.
|
static |
Adds suffixes for asset types.
You may add as many as you need, but it is advised that there is exactly one to make writing definite.
The later a suffix is added, the higher its priority. Note, that the suffix should end with / but doesn't have to start with one (as prefixes should end with one). So adding a suffix for app_pics would look like KoStandardPaths::addResourceType("app_pics", "data", "app/pics");
| type | Specifies a short descriptive string to access files of this type. |
| basetype | Specifies an already known type, or 0 if none |
| relativename | Specifies a directory relative to the basetype |
| priority | if true, the directory is added before any other, otherwise after |
Definition at line 298 of file KoResourcePaths.cpp.
|
private |
Definition at line 376 of file KoResourcePaths.cpp.
References d, and dbgResources.
|
private |
Definition at line 346 of file KoResourcePaths.cpp.
References d, and dbgResources.
|
inline |
Definition at line 164 of file KoResourcePaths.cpp.
|
static |
| type | The type of resource |
type. The function updates the cache if possible. If the resource type specified is unknown, it will return an empty list. Note, that the directories are assured to exist beside the save location, which may not exist, but is returned anyway. Definition at line 326 of file KoResourcePaths.cpp.
|
static |
Tries to find all resources with the specified type.
The function will look into all specified directories and return all filenames in these directories.
The "most local" files are returned before the "more global" files.
| type | The type of resource to locate directories for. |
| filter | Only accept filenames that fit to filter. The filter may consist of an optional directory and a QRegExp wildcard expression. E.g. "images\*.jpg". Use QString() if you do not want a filter. |
| options | if the flags passed include Recursive, subdirectories will also be search. |
Definition at line 319 of file KoResourcePaths.cpp.
|
private |
Definition at line 532 of file KoResourcePaths.cpp.
References aliases(), d, dbgResources, filesInDir(), findExtraResourceDirs(), and Recursive.
|
static |
Tries to find a resource in the following order:
The filename should be a filename relative to the base dir for resources. So it's a way to get the path to libkdecore.la to findResource("lib", "libkdecore.la"). KStandardDirs will then look into the subdir lib of all elements of all prefixes ($KDEDIRS) for a file libkdecore.la and return the path to the first one it finds (e.g. /opt/kde/lib/libkdecore.la).
Example:
| type | The type of the wanted resource |
| filename | A relative filename of the resource. |
Definition at line 309 of file KoResourcePaths.cpp.
|
static |
Tries to find all directories whose names consist of the specified type and a relative path. So findDirs("xdgdata-apps", "Settings") would return
(from the most local to the most global)
Note that it appends / to the end of the directories, so you can use this right away as directory names.
| type | The type of the base directory. |
| reldir | Relative directory. |
Definition at line 314 of file KoResourcePaths.cpp.
|
private |
Definition at line 490 of file KoResourcePaths.cpp.
References aliases(), d, dbgResources, getApplicationRoot(), and saveLocation().
|
private |
Definition at line 714 of file KoResourcePaths.cpp.
References getAppDataLocation(), and KisResourceLocator::resourceLocationKey.
|
private |
Definition at line 400 of file KoResourcePaths.cpp.
References aliases(), d, dbgResources, findExtraResourceDirs(), and getApplicationRoot().
|
static |
getAllAppDataLocationsForWindowsStore Use this to get both private and general appdata folders which also considers user's choice of custom resource folder Used in GeneralTab in kis_dlg_preferences, and KisViewManager::openResourceDirectory().
| standardLocation | - location in standard AppData% |
| privateLocation | - location in private app AppData% location, only relevant for Windows Store |
Definition at line 248 of file KoResourcePaths.cpp.
References KisWindowsPackageUtils::getPackageRoamingAppDataLocation(), KisResourceLocator::instance(), and KisWindowsPackageUtils::isRunningInPackage().
|
static |
Definition at line 219 of file KoResourcePaths.cpp.
References KisResourceLocator::resourceLocationKey, and s_overrideAppDataLocation.
|
static |
Definition at line 214 of file KoResourcePaths.cpp.
|
static |
This function is just for convenience. It simply calls KoResourcePaths::findResource((type, filename).
| type | The type of the wanted resource, see KStandardDirs |
| filename | A relative filename of the resource |
Definition at line 336 of file KoResourcePaths.cpp.
|
private |
Definition at line 685 of file KoResourcePaths.cpp.
References aliases(), d, and dbgResources.
|
static |
This function is much like locate. However it returns a filename suitable for writing to. No check is made if the specified filename actually exists. Missing directories are created. If filename is only a directory, without a specific file, filename must have a trailing slash.
| type | The type of the wanted resource, see KStandardDirs |
| filename | A relative filename of the resource |
Definition at line 341 of file KoResourcePaths.cpp.
|
private |
Definition at line 707 of file KoResourcePaths.cpp.
References dbgResources, and saveLocationInternal().
|
inline |
Definition at line 182 of file KoResourcePaths.cpp.
|
private |
Definition at line 618 of file KoResourcePaths.cpp.
References aliases(), d, and dbgResources.
|
static |
Finds a location to save files into for the given type in the user's home directory.
| type | The type of location to return. |
| suffix | A subdirectory name. Makes it easier for you to create subdirectories. You can't pass filenames here, you have to pass directory names only and add possible filename in that directory yourself. A directory name always has a trailing slash ('/'). |
| create | If set, saveLocation() will create the directories needed (including those given by suffix). |
Definition at line 331 of file KoResourcePaths.cpp.
|
private |
Definition at line 641 of file KoResourcePaths.cpp.
References aliases(), d, dbgResources, and KisResourceLocator::resourceLocationKey.
| QMap<QString, QStringList> KoResourcePaths::absolutes |
Definition at line 158 of file KoResourcePaths.cpp.
| QMutex KoResourcePaths::absolutesMutex |
Definition at line 162 of file KoResourcePaths.cpp.
|
private |
Definition at line 265 of file KoResourcePaths.h.
| QMap<QString, QStringList> KoResourcePaths::relatives |
Definition at line 159 of file KoResourcePaths.cpp.
| QMutex KoResourcePaths::relativesMutex |
Definition at line 161 of file KoResourcePaths.cpp.
|
static |
getAppDataLocation Use this instead of QStandardPaths::AppDataLocation! The user can configure the location where resources and other user writable items are stored now.
Definition at line 62 of file KoResourcePaths.h.