qBittorrent
Private::DefaultProfile Class Referencefinal

Default implementation. Takes paths from system. More...

#include <profile_p.h>

Inheritance diagram for Private::DefaultProfile:
Collaboration diagram for Private::DefaultProfile:

Public Member Functions

 DefaultProfile (const QString &configurationName)
 
QString rootPath () const override
 
QString basePath () const override
 The base path against to which portable (relative) paths are resolved. More...
 
QString cacheLocation () const override
 
QString configLocation () const override
 
QString dataLocation () const override
 
QString downloadLocation () const override
 
SettingsPtr applicationSettings (const QString &name) const override
 
- Public Member Functions inherited from Private::Profile
virtual ~Profile ()=default
 
QString configurationName () const
 
QString profileName () const
 QCoreApplication::applicationName() with optional configuration name appended. More...
 

Private Member Functions

QString locationWithConfigurationName (QStandardPaths::StandardLocation location) const
 Standard path writable location for profile files. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Private::Profile
 Profile (const QString &configurationName)
 
QString configurationSuffix () const
 

Detailed Description

Default implementation. Takes paths from system.

Definition at line 75 of file profile_p.h.

Constructor & Destructor Documentation

◆ DefaultProfile()

Private::DefaultProfile::DefaultProfile ( const QString &  configurationName)
explicit

Definition at line 54 of file profile_p.cpp.

56 {
57 }
QString configurationName() const
Definition: profile_p.cpp:39

Member Function Documentation

◆ applicationSettings()

SettingsPtr Private::DefaultProfile::applicationSettings ( const QString &  name) const
overridevirtual

Implements Private::Profile.

Definition at line 113 of file profile_p.cpp.

114 {
115 #if defined(Q_OS_WIN) || defined(Q_OS_MACOS)
116  return SettingsPtr(new QSettings(QSettings::IniFormat, QSettings::UserScope, profileName(), name));
117 #else
118  return SettingsPtr(new QSettings(profileName(), name));
119 #endif
120 }
QString profileName() const
QCoreApplication::applicationName() with optional configuration name appended.
Definition: profile_p.cpp:49
std::unique_ptr< QSettings > SettingsPtr
Definition: profile.h:44

◆ basePath()

QString Private::DefaultProfile::basePath ( ) const
overridevirtual

The base path against to which portable (relative) paths are resolved.

Implements Private::Profile.

Definition at line 64 of file profile_p.cpp.

65 {
66  return QDir::homePath();
67 }

◆ cacheLocation()

QString Private::DefaultProfile::cacheLocation ( ) const
overridevirtual

Implements Private::Profile.

Definition at line 69 of file profile_p.cpp.

70 {
71  return locationWithConfigurationName(QStandardPaths::CacheLocation);
72 }
QString locationWithConfigurationName(QStandardPaths::StandardLocation location) const
Standard path writable location for profile files.
Definition: profile_p.cpp:122

◆ configLocation()

QString Private::DefaultProfile::configLocation ( ) const
overridevirtual

Implements Private::Profile.

Definition at line 74 of file profile_p.cpp.

75 {
76 #if defined(Q_OS_WIN)
77  // On Windows QSettings stores files in FOLDERID_RoamingAppData\AppName
78  return locationWithConfigurationName(QStandardPaths::AppDataLocation);
79 #else
80  return locationWithConfigurationName(QStandardPaths::AppConfigLocation);
81 #endif
82 }

◆ dataLocation()

QString Private::DefaultProfile::dataLocation ( ) const
overridevirtual

Implements Private::Profile.

Definition at line 84 of file profile_p.cpp.

85 {
86 #if defined(Q_OS_WIN) || defined (Q_OS_MACOS)
87  return locationWithConfigurationName(QStandardPaths::AppLocalDataLocation);
88 #else
89  // On Linux keep using the legacy directory ~/.local/share/data/ if it exists
90  const QString legacyDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)
91  + QLatin1String("/data/") + profileName();
92 
93  const QString dataDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)
94  + QLatin1Char('/') + profileName();
95 
96  if (!QDir(dataDir).exists() && QDir(legacyDir).exists())
97  {
98  qWarning("The legacy data directory '%s' is used. It is recommended to move its content to '%s'",
99  qUtf8Printable(legacyDir), qUtf8Printable(dataDir));
100 
101  return legacyDir;
102  }
103 
104  return dataDir;
105 #endif
106 }

◆ downloadLocation()

QString Private::DefaultProfile::downloadLocation ( ) const
overridevirtual

Implements Private::Profile.

Definition at line 108 of file profile_p.cpp.

109 {
110  return QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
111 }

◆ locationWithConfigurationName()

QString Private::DefaultProfile::locationWithConfigurationName ( QStandardPaths::StandardLocation  location) const
private

Standard path writable location for profile files.

Parameters
locationlocation kind
Returns
QStandardPaths::writableLocation(location) / configurationName()

Definition at line 122 of file profile_p.cpp.

123 {
124  return QStandardPaths::writableLocation(location) + configurationSuffix();
125 }
QString configurationSuffix() const
Definition: profile_p.cpp:44

◆ rootPath()

QString Private::DefaultProfile::rootPath ( ) const
overridevirtual

Implements Private::Profile.

Definition at line 59 of file profile_p.cpp.

60 {
61  return {};
62 }

The documentation for this class was generated from the following files: