Qx v0.5.8
Qt Extensions Library
Loading...
Searching...
No Matches
Qx::DesktopEntry Class Referenceabstract

The DesktopEntry class provides the base functionality common to all Linux desktop entry files. More...

#include <qx/linux/qx-desktopentry.h>

Public Member Functions

QString comment () const
 
virtual QString extension () const =0
 
QString genericName () const
 
QString icon () const
 
bool isHidden () const
 
bool isNoDisplay () const
 
QString name () const
 
QStringList notShowIn () const
 
QStringList onlyShowIn () const
 
void setComment (const QString &comment)
 
void setGenericName (const QString &name)
 
void setHidden (bool hidden)
 
void setIcon (const QString &icon)
 
void setName (const QString &name)
 
void setNoDisplay (bool display)
 
void setNotShowIn (const QStringList &notIn)
 
void setOnlyShowIn (const QStringList &showIn)
 
virtual QString toString () const
 
virtual QString type () const =0
 

Static Public Member Functions

static IoOpReport writeToDisk (QString path, const DesktopEntry *entry)
 

Static Protected Member Functions

static QString keyValueString (const QString &key, bool value)
 
static QString keyValueString (const QString &key, const char *value)
 
static QString keyValueString (const QString &key, const QString &value)
 
static QString keyValueString (const QString &key, const QStringList &value)
 

Detailed Description

Desktop entry files act as extensible GUI shortcuts in a manner similar to Windows .lnk files, although with greater capabilities, and are supported by most major Linux desktop environments.

Standard entry files exist in one of three forms:

  • Application - Typically used as a shortcut to an application
  • Link - Typically used as a shortcut to a URL
  • Directory - Used to provide information about a menu

This class acts only as a base for all properties and facilities that are common to all desktop entry types. To create a desktop entry, instantiate one of the type specific derivatives.

This implementation aims to comply with version 1.5 of the XDG Desktop Entry Specification.

Warning
Although close, this class and its derivatives currently are not fully compliant with the XDG Desktop Entry Specification and do not offer a method of reading existing desktop entries.
See also
ApplicationDesktopEntry, LinkDesktopEntry, and DirectoryDesktopEntry.

Member Function Documentation

◆ comment()

QString Qx::DesktopEntry::comment ( ) const

Returns the entry's comment.

◆ extension()

QString Qx::DesktopEntry::extension ( ) const
pure virtual

Returns the proper extension of the entry that corresponds to its type.

Implemented in Qx::ApplicationDesktopEntry, Qx::DirectoryDesktopEntry, and Qx::LinkDesktopEntry.

◆ genericName()

QString Qx::DesktopEntry::genericName ( ) const

Returns the generic name of the entry.

◆ icon()

QString Qx::DesktopEntry::icon ( ) const

Returns the entry's icon path/name.

◆ isHidden()

bool Qx::DesktopEntry::isHidden ( ) const

Returns true if the entry is marked as 'deleted'; otherwise, returns false;

◆ isNoDisplay()

bool Qx::DesktopEntry::isNoDisplay ( ) const

Returns true if the entry should not be displayed to the user; otherwise, returns false.

◆ keyValueString() [1/4]

QString Qx::DesktopEntry::keyValueString ( const QString & key,
bool value )
staticprotected

Creates a string of key and value in the same arrangement they would appear in a file.

This is useful for implementing a custom desktop entry type.

◆ keyValueString() [2/4]

QString Qx::DesktopEntry::keyValueString ( const QString & key,
const char * value )
staticprotected

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ keyValueString() [3/4]

QString Qx::DesktopEntry::keyValueString ( const QString & key,
const QString & value )
staticprotected

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ keyValueString() [4/4]

QString Qx::DesktopEntry::keyValueString ( const QString & key,
const QStringList & value )
staticprotected

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ name()

QString Qx::DesktopEntry::name ( ) const

Returns the name of the entry.

◆ notShowIn()

QStringList Qx::DesktopEntry::notShowIn ( ) const

Returns the blacklist of environemnts that the entry should not be displayed on.

◆ onlyShowIn()

QStringList Qx::DesktopEntry::onlyShowIn ( ) const

Returns the whitelist of environemnts that the entry should be displayed on.

◆ setComment()

void Qx::DesktopEntry::setComment ( const QString & comment)

Sets comment of the entry to comment.

◆ setGenericName()

void Qx::DesktopEntry::setGenericName ( const QString & name)

Sets the generic name of the entry to name.

◆ setHidden()

void Qx::DesktopEntry::setHidden ( bool hidden)

Sets whether or not he entry should be considered 'deleted'.

◆ setIcon()

void Qx::DesktopEntry::setIcon ( const QString & icon)

Sets the icon path/name of the entry to icon.

◆ setName()

void Qx::DesktopEntry::setName ( const QString & name)

Sets the name of the entry to name.

◆ setNoDisplay()

void Qx::DesktopEntry::setNoDisplay ( bool display)

Sets whether or not the entry should be displayed to the user.

◆ setNotShowIn()

void Qx::DesktopEntry::setNotShowIn ( const QStringList & notIn)

Sets the blacklist of desktop environments that the entry should not be displayed on.

◆ setOnlyShowIn()

void Qx::DesktopEntry::setOnlyShowIn ( const QStringList & showIn)

Sets the whitelist of desktop environments that the entry should be displayed on.

◆ toString()

QString Qx::DesktopEntry::toString ( ) const
virtual

Composites the desktop entry into its string form, as would be found in an entry file on disk.

Warning
If this string is later written to disk, you must ensure that the correct extension is used in correspondence with the entry's type.
See also
extension(), and type().

Reimplemented in Qx::ApplicationDesktopEntry, Qx::DirectoryDesktopEntry, and Qx::LinkDesktopEntry.

◆ type()

QString Qx::DesktopEntry::type ( ) const
pure virtual

Returns the type string of the entry.

Implemented in Qx::ApplicationDesktopEntry, Qx::DirectoryDesktopEntry, and Qx::LinkDesktopEntry.

◆ writeToDisk()

IoOpReport Qx::DesktopEntry::writeToDisk ( QString path,
const DesktopEntry * entry )
static

Writes the DesktopEntry to the file specified by path, overwriting any existing entry if any, and sets the file's owner executable bit.

The correct extension is automatically appended to the filename portion of the path if it is not already present.

To completely conform with the XDG Desktop Entry Specification, the filename of the entry should follow the "reverse DNS" convention, with the primary name portion in CamelCase:

org.example.AppName.desktop

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