KMoreToolsService

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).

Since
5.10

Definition at line 361 of file kmoretools.h.

Member Function Documentation

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.
Since
5.48

Definition at line 361 of file kmoretools.cpp.

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 273 of file kmoretools.cpp.

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 318 of file kmoretools.cpp.

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

Definition at line 298 of file kmoretools.cpp.

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 342 of file kmoretools.cpp.

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 283 of file kmoretools.cpp.

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 278 of file kmoretools.cpp.

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 293 of file kmoretools.cpp.

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

Definition at line 288 of file kmoretools.cpp.

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

Definition at line 308 of file kmoretools.cpp.

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
Since
5.48

Definition at line 366 of file kmoretools.cpp.

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 353 of file kmoretools.cpp.

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 303 of file kmoretools.cpp.

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 313 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-2020 The KDE developers.
Generated on Wed Aug 12 2020 22:42:03 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.