KMoreToolsService

Search for usage in LXR

KMoreToolsService Class Reference

#include <kmoretools.h>

Public Member Functions

 KMoreToolsService (const KMoreToolsService &)=delete
 
QString appstreamId () const
 
QString desktopEntryName () const
 
QString formatString (const QString &formatString) const
 
QUrl homepageUrl () const
 
QIcon icon () const
 
KService::Ptr installedService () const
 
bool isInstalled () const
 
QIcon kmtProvidedIcon () const
 
KService::Ptr kmtProvidedService () const
 
int maxUrlArgCount () const
 
KMoreToolsServiceoperator= (const KMoreToolsService &)=delete
 
void setAppstreamId (const QString &)
 
void setExec (const QString &exec)
 
void setHomepageUrl (const QUrl &url)
 
void setMaxUrlArgCount (int maxUrlArgCount)
 

Detailed Description

A service described in a .desktop file (kmt-desktopfile) which will be called "registered service".

A registered service can either be installed (isInstalled() == true) or - if not found on the system - not installed (isInstalled() == false).

Definition at line 356 of file kmoretools.h.

Member Function Documentation

◆ appstreamId()

QString KMoreToolsService::appstreamId ( ) const

Returns the associated appstream id that was previously set with setAppstreamId().

If no appstream id was set, an empty string is returned.

Returns
The service's appstream id.

Definition at line 330 of file kmoretools.cpp.

◆ desktopEntryName()

QString KMoreToolsService::desktopEntryName ( ) const
Returns
the desktop entry name which the service is identified by and with which it was registered (see registerServiceByDesktopEntryName).

Filename without .desktop: e.g. if the desktop file is named "org.kde.ksnapshot.desktop" then the desktop entry name is "org.kde.ksnapshot".

Definition at line 242 of file kmoretools.cpp.

◆ formatString()

QString KMoreToolsService::formatString ( const QString & formatString) const
Parameters
formatStringsupports the following placeholders:
  1. $GenericName
  2. $Name
  3. $DesktopEntryName

which are replaced by the corresponding desktop file entries.

If a value for a placeholder is not available (or empty) (e.g. if no desktop file is available (not installed or not provided via kmt-desktopfiles)) then the next one is used until 3. is reached which is always available. Example: the formatString is "$GenericName", but the GenericName field is not available. So $Name is used. If this is also not available, $DesktopEntryName is used.

See also
KMoreToolsMenuItem::setInitialItemText
KMoreToolsMenuBuilder::setInitialItemTextTemplate

Definition at line 287 of file kmoretools.cpp.

◆ homepageUrl()

QUrl KMoreToolsService::homepageUrl ( ) const
See also
setHomepageUrl()

Definition at line 267 of file kmoretools.cpp.

◆ icon()

QIcon KMoreToolsService::icon ( ) const
  1. Icon from installed desktop file If 1. is not found not found then...
  2. icon from kmt desktop file (which is then searched in the kmt-desktopfiles directory, must have extension .svg or .png) If 2. is not not found then...
  3. no icon

Definition at line 311 of file kmoretools.cpp.

◆ installedService()

KService::Ptr KMoreToolsService::installedService ( ) const
Returns
the KService represented by an installed desktop file.
Note
that this might be nullptr even if isInstalled() is true. This can only happen when ServiceLocatingMode::ServiceLocatingMode_ByProvidedExecLine is used in registerServiceByDesktopEntryName. (Then the kmt-desktopfile's Exec line is used to determine if a program is installed)

Definition at line 252 of file kmoretools.cpp.

◆ isInstalled()

bool KMoreToolsService::isInstalled ( ) const
Returns
true if the desktopfile with the given desktopname (name of the .desktop file without the .desktop) is installed on the system

Definition at line 247 of file kmoretools.cpp.

◆ kmtProvidedIcon()

QIcon KMoreToolsService::kmtProvidedIcon ( ) const
Returns
the icon provided by the KMoreTools' user and not the installed one. (e.g. QGit currently has got a blank icon installed)

Definition at line 262 of file kmoretools.cpp.

◆ kmtProvidedService()

KService::Ptr KMoreToolsService::kmtProvidedService ( ) const
Returns
a non-null KService::Ptr if app-local kmt-desktopfile is found and valid

Definition at line 257 of file kmoretools.cpp.

◆ maxUrlArgCount()

int KMoreToolsService::maxUrlArgCount ( ) const
See also
setMaxUrlArgCount()

Definition at line 277 of file kmoretools.cpp.

◆ setAppstreamId()

void KMoreToolsService::setAppstreamId ( const QString & id)

Sets the appstream id of the service.

This is used to create a appstream url for installing the service via a software store (e.g. Discover). For instance, the appstream id for filelight is "org.kde.filelight.desktop".

Parameters
idthe appstream id

Definition at line 335 of file kmoretools.cpp.

◆ setExec()

void KMoreToolsService::setExec ( const QString & exec)

Will override the "Exec=" line of the service.

Will only apply if the service is installed.

See also
KService::setExec(...)

Definition at line 322 of file kmoretools.cpp.

◆ setHomepageUrl()

void KMoreToolsService::setHomepageUrl ( const QUrl & url)

Sets the homepage url the user is shown when a service is not installed.

This way the user gets some information of how to install the application.

Definition at line 272 of file kmoretools.cpp.

◆ setMaxUrlArgCount()

void KMoreToolsService::setMaxUrlArgCount ( int maxUrlArgCount)

In KMoreToolsMenuFactory some minor magic is done.

In the context of connecting the action trigger signal we need to know the maximum number of URL arguments a given service can accept. Usually a number between 0 and 1. Sometimes 2. E.g. kdf must not be called with any positional argument. E.g. gitg can be called with zero or one arguments.

Definition at line 282 of file kmoretools.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:15:34 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.