DtkCore
DTK Core module
|
Handling desktop entry files. 更多...
Public 类型 | |
enum | EntryType { Unknown = 0 , Application , Link , Directory , ServiceType , Service , FSDevice } |
enum | ValueType { Unparsed = 0 , String , Strings , Boolean , Numeric , NotExisted = 99 } |
enum | Status { NoError = 0 , AccessError , FormatError } |
Public 成员函数 | |
DDesktopEntry (const QString &filePath) noexcept | |
bool | save () const |
Write back data to the desktop entry file. 更多... | |
Status | status () const |
Get data parse status 更多... | |
QStringList | keys (const QString §ion="Desktop Entry") const |
Get a list of all section keys inside the given section. 更多... | |
QStringList | allGroups (bool sorted=false) const |
Get a list of all section groups inside the desktop entry. 更多... | |
bool | contains (const QString &key, const QString §ion="Desktop Entry") const |
Check if the desktop entry file have the given section contains the given key 更多... | |
QString | name () const |
Returns the localized string value of the "Name" key under "Desktop Entry" section. 更多... | |
QString | genericName () const |
Returns the localized string value of the "GenericName" key under "Desktop Entry" section. 更多... | |
QString | ddeDisplayName () const |
Display name specially for DDE applications. 更多... | |
QString | comment () const |
Returns the localized string value of the "Comment" key under "Desktop Entry" section. 更多... | |
QString | rawValue (const QString &key, const QString §ion="Desktop Entry", const QString &defaultValue=QString()) const |
Returns the raw string value associated with the given key in section. 更多... | |
QString | stringValue (const QString &key, const QString §ion="Desktop Entry", const QString &defaultValue=QString()) const |
Returns the unescaped string value associated with the given key in section. 更多... | |
QString | localizedValue (const QString &key, const QString &localeKey="default", const QString §ion="Desktop Entry", const QString &defaultValue=QString()) const |
Returns the localized string value associated with the given key and localeKey in section. 更多... | |
QString | localizedValue (const QString &key, const QLocale &locale, const QString §ion="Desktop Entry", const QString &defaultValue=QString()) const |
Returns the localized string value associated with the given key and locale in section. 更多... | |
QStringList | stringListValue (const QString &key, const QString §ion="Desktop Entry") const |
Returns a list of strings associated with the given key in the given section. 更多... | |
bool | setRawValue (const QString &value, const QString &key, const QString §ion="Desktop Entry") |
bool | setStringValue (const QString &value, const QString &key, const QString §ion="Desktop Entry") |
bool | setLocalizedValue (const QString &value, const QString &localeKey, const QString &key, const QString §ion="Desktop Entry") |
bool | removeEntry (const QString &key, const QString §ion="Desktop Entry") |
Protected 成员函数 | |
bool | setStatus (const Status &status) |
Handling desktop entry files.
\inmodule dtkcore
DDesktopEntry provide method for handling XDG desktop entry read and write. The interface of this class is similar to QSettings.
For more details about the spec itself, please refer to: https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html
QStringList Dtk::Core::DDesktopEntry::allGroups | ( | bool | sorted = false | ) | const |
Get a list of all section groups inside the desktop entry.
If sorted is set to true, the returned result will keep the order as-is when reading the entry file.
QString Dtk::Core::DDesktopEntry::comment | ( | ) | const |
Returns the localized string value of the "Comment" key under "Desktop Entry" section.
It's equivalent to calling localizedValue("Comment").
bool Dtk::Core::DDesktopEntry::contains | ( | const QString & | key, |
const QString & | section = "Desktop Entry" |
||
) | const |
Check if the desktop entry file have the given section contains the given key
QString Dtk::Core::DDesktopEntry::ddeDisplayName | ( | ) | const |
Display name specially for DDE applications.
This will check "X-Deepin-Vendor" and will return the localized string value of "GenericName" if "X-Deepin-Vendor" is "deepin", or it will return the localized string value of "Name".
QString Dtk::Core::DDesktopEntry::genericName | ( | ) | const |
Returns the localized string value of the "GenericName" key under "Desktop Entry" section.
It's equivalent to calling localizedValue("GenericName"). It will NOT fallback to "Name" if "GenericName" is not existed.
QStringList Dtk::Core::DDesktopEntry::keys | ( | const QString & | section = "Desktop Entry" | ) | const |
Get a list of all section keys inside the given section.
QString Dtk::Core::DDesktopEntry::localizedValue | ( | const QString & | key, |
const QLocale & | locale, | ||
const QString & | section = "Desktop Entry" , |
||
const QString & | defaultValue = QString() |
||
) | const |
Returns the localized string value associated with the given key and locale in section.
If the given locale can't be found, it will fallback to "C", if still cannot found, will fallback to the key without a locale key.
If the entry contains no item with the key, the function returns a default-constructed value.
QString Dtk::Core::DDesktopEntry::localizedValue | ( | const QString & | key, |
const QString & | localeKey = "default" , |
||
const QString & | section = "Desktop Entry" , |
||
const QString & | defaultValue = QString() |
||
) | const |
Returns the localized string value associated with the given key and localeKey in section.
If the given localeKey can't be found, it will fallback to "C", if still cannot found, will fallback to the key without localeKey.
If the entry contains no item with the key, the function returns a constructed defaultValue.
QString Dtk::Core::DDesktopEntry::name | ( | ) | const |
Returns the localized string value of the "Name" key under "Desktop Entry" section.
It's equivalent to calling localizedValue("Name").
QString Dtk::Core::DDesktopEntry::rawValue | ( | const QString & | key, |
const QString & | section = "Desktop Entry" , |
||
const QString & | defaultValue = QString() |
||
) | const |
Returns the raw string value associated with the given key in section.
If the entry contains no item with the key, the function returns a constructed defaultValue.
bool Dtk::Core::DDesktopEntry::save | ( | ) | const |
Write back data to the desktop entry file.
DDesktopEntry::Status Dtk::Core::DDesktopEntry::status | ( | ) | const |
Get data parse status
Be aware that DDesktopEntry delays performing some operations.
QStringList Dtk::Core::DDesktopEntry::stringListValue | ( | const QString & | key, |
const QString & | section = "Desktop Entry" |
||
) | const |
Returns a list of strings associated with the given key in the given section.
If the entry contains no item with the key, the function returns a empty string list.
QString Dtk::Core::DDesktopEntry::stringValue | ( | const QString & | key, |
const QString & | section = "Desktop Entry" , |
||
const QString & | defaultValue = QString() |
||
) | const |
Returns the unescaped string value associated with the given key in section.
If the entry contains no item with the key, the function returns a constructed defaultValue.