LeechCraft  0.6.70-10870-g558588d6ec
Modular cross-platform feature rich live environment.
LeechCraft::Util::XDG::Item Class Reference

Describes a single XDG .desktop entry. More...

#include "item.h"

Public Member Functions

bool IsValid () const
 Checks whether this XDG item is valid. More...
 
bool IsHidden () const
 Checks whether this XDG item should be hidden. More...
 
void Execute (ICoreProxy_ptr proxy) const
 Executes this item, if possible. More...
 
QString GetName (const QString &language) const
 Returns the name of this item. More...
 
QString GetGenericName (const QString &language) const
 Returns the generic name of this item. More...
 
QString GetComment (const QString &language) const
 Returns the comment of this item. More...
 
QString GetIconName () const
 Returns the name of the icon for this item. More...
 
QStringList GetCategories () const
 Returns the categories where this item belongs. More...
 
Type GetType () const
 Returns the type of this item. More...
 
QString GetCommand () const
 Returns type type-specific command for this item. More...
 
QString GetWorkingDirectory () const
 Returns the working directory for command execution. More...
 
QString GetPermanentID () const
 Returns the permanent ID of this item. More...
 
QIcon GetIcon (const ICoreProxy_ptr &) const
 Returns the icon previously set by SetIcon(). More...
 
QDebug DebugPrint (QDebug stream) const
 Serializes item contents to the debugging stream. More...
 

Static Public Member Functions

static Item_ptr FromDesktopFile (const QString &file)
 Loads the XDG .desktop item from file. More...
 

Friends

UTIL_XDG_API bool operator== (const Item &left, const Item &right)
 Checks whether left and right are equal. More...
 
UTIL_XDG_API bool operator!= (const Item &left, const Item &right)
 Checks whether left and right are not equal. More...
 

Detailed Description

Describes a single XDG .desktop entry.

XDG entries can language-dependent fields like name, generic name or comment. The values of these fields are obtained via GetName(), GetGenericName() and GetComment() respectively, taking the language code and returning either the localized field for that language or the version of the field for the default (typically English) language.

Definition at line 60 of file item.h.

Member Function Documentation

◆ DebugPrint()

QDebug LeechCraft::Util::XDG::Item::DebugPrint ( QDebug  stream) const

Serializes item contents to the debugging stream.

This function is provided for convenience to pretty-print contents of this item to a debugging stream.

Parameters
[in]streamThe stream to debug-print
Returns
The debugging stream with the contents of this item.

Definition at line 196 of file item.cpp.

Referenced by LeechCraft::Util::XDG::operator<<().

+ Here is the caller graph for this function:

◆ Execute()

void LeechCraft::Util::XDG::Item::Execute ( ICoreProxy_ptr  proxy) const

Executes this item, if possible.

Depending on the type of this item, execution can mean launching an application (for Type::Application), opening a default URL handler (for Type::URL) and so on.

Parameters
[in]proxyThe ICoreProxy_ptr object to use if needed during execution.

Definition at line 75 of file item.cpp.

References LeechCraft::Util::XDG::Application, LeechCraft::FromUserInitiated, GetCommand(), GetType(), GetWorkingDirectory(), LeechCraft::Util::MakeEntity(), LeechCraft::OnlyHandle, and LeechCraft::Util::XDG::URL.

+ Here is the call graph for this function:

◆ FromDesktopFile()

Item_ptr LeechCraft::Util::XDG::Item::FromDesktopFile ( const QString &  file)
static

Loads the XDG .desktop item from file.

Parameters
[in]fileThe file to load the item from.
Returns
The item loaded from file, or an invalid item (with IsValid() returning false) if the file is invalid.
Exceptions
std::runtime_errorIf file cannot be opened.

Definition at line 221 of file item.cpp.

References LeechCraft::Util::XDG::Application, LeechCraft::Util::XDG::Dir, LeechCraft::Util::XDG::Other, and LeechCraft::Util::XDG::URL.

◆ GetCategories()

QStringList LeechCraft::Util::XDG::Item::GetCategories ( ) const

Returns the categories where this item belongs.

Returns
The list of categories for this item.

Definition at line 139 of file item.cpp.

◆ GetCommand()

QString LeechCraft::Util::XDG::Item::GetCommand ( ) const

Returns type type-specific command for this item.

A command could be a name of the application for Type::Application, an URL for Type::URL, and so on.

Returns
The type-specific XDG command for this item, or a null string if not set.
See also
GetWorkingDirectory()

Definition at line 149 of file item.cpp.

Referenced by Execute(), and GetPermanentID().

+ Here is the caller graph for this function:

◆ GetComment()

QString LeechCraft::Util::XDG::Item::GetComment ( const QString &  language) const

Returns the comment of this item.

Parameters
[in]languageThe code of the desired language for the localized comment.
Returns
The localized comment matching the language, or the default generic name if there is no localized one for the language.

Definition at line 129 of file item.cpp.

◆ GetGenericName()

QString LeechCraft::Util::XDG::Item::GetGenericName ( const QString &  language) const

Returns the generic name of this item.

Parameters
[in]languageThe code of the desired language for the localized generic name.
Returns
The localized generic name matching the language, or the default generic name if there is no localized one for the language.
See also
GetName()

Definition at line 124 of file item.cpp.

◆ GetIcon()

QIcon LeechCraft::Util::XDG::Item::GetIcon ( const ICoreProxy_ptr proxy) const

Returns the icon previously set by SetIcon().

If no icon has been set previously via SetIcon(), this method returns a null icon even if GetIconName() returns a perfectly valid name of an existing icon.

This method is not related to GetIconName() in any way and (along with SetIcon()) is provided purely for convenience, for example, to associate a loaded icon with the item.

Returns
The icon previously set via SetIcon(), or a null icon if no icon has been set.
See also
SetIcon()
GetIconName()

Definition at line 188 of file item.cpp.

References GetIconName().

+ Here is the call graph for this function:

◆ GetIconName()

QString LeechCraft::Util::XDG::Item::GetIconName ( ) const

Returns the name of the icon for this item.

Please note this is not related to the GetIcon() method which (along with SetIcon()) is provided purely for convenience.

Returns
The XDG name of this icon, or a null string if not set.
See also
GetIcon()

Definition at line 134 of file item.cpp.

Referenced by GetIcon().

+ Here is the caller graph for this function:

◆ GetName()

QString LeechCraft::Util::XDG::Item::GetName ( const QString &  language) const

Returns the name of this item.

Parameters
[in]languageThe code of the desired language for the localized name.
Returns
The localized name matching the language, or the default name if there is no localized one for the language.
See also
GetGenericName()

Definition at line 119 of file item.cpp.

◆ GetPermanentID()

QString LeechCraft::Util::XDG::Item::GetPermanentID ( ) const

Returns the permanent ID of this item.

The returned ID is language-agnostic and is suitable to, for instance, identify the item in a favorites list.

Returns
The permanent ID of this item.

Definition at line 159 of file item.cpp.

References GetCommand().

+ Here is the call graph for this function:

◆ GetType()

Type LeechCraft::Util::XDG::Item::GetType ( ) const

Returns the type of this item.

Returns
The type of this item.

Definition at line 144 of file item.cpp.

Referenced by Execute().

+ Here is the caller graph for this function:

◆ GetWorkingDirectory()

QString LeechCraft::Util::XDG::Item::GetWorkingDirectory ( ) const

Returns the working directory for command execution.

This directory specifies the working directory where the command returned by GetCommand() should be executed.

Returns
The directory where the command associated with this item should be executed, or a null string if not set.
See also
GetCommand()

Definition at line 154 of file item.cpp.

Referenced by Execute().

+ Here is the caller graph for this function:

◆ IsHidden()

bool LeechCraft::Util::XDG::Item::IsHidden ( ) const

Checks whether this XDG item should be hidden.

A hidden XDG item is not presented to the user in start menus and so on.

Returns
Whether this item is hidden.

Definition at line 70 of file item.cpp.

◆ IsValid()

bool LeechCraft::Util::XDG::Item::IsValid ( ) const

Checks whether this XDG item is valid.

A valid item has name field set for at least one language.

Returns
Whether this XDG item is valid.

Definition at line 65 of file item.cpp.

Friends And Related Function Documentation

◆ operator!=

UTIL_XDG_API bool operator!= ( const Item left,
const Item right 
)
friend

Checks whether left and right are not equal.

The icon field obtained via GetIcon() is not checked for equality.

Parameters
[in]leftFirst XDG item to check for inequality.
[in]rightSecond XDG item to check for inequality.
Returns
Whether left and right are not equal.

Definition at line 60 of file item.cpp.

◆ operator==

UTIL_XDG_API bool operator== ( const Item left,
const Item right 
)
friend

Checks whether left and right are equal.

The icon field obtained via GetIcon() is not checked for equality.

Parameters
[in]leftFirst XDG item to check for equality.
[in]rightSecond XDG item to check for equality.
Returns
Whether left and right are equal.

Definition at line 47 of file item.cpp.


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