Split AbstractClient::iconFromDesktopFile into a static function
This way it can be used before we have the window
This commit is contained in:
parent
e72a555247
commit
0f8813671b
2 changed files with 16 additions and 2 deletions
|
@ -2707,11 +2707,15 @@ void AbstractClient::setDesktopFileName(QByteArray name)
|
|||
|
||||
QString AbstractClient::iconFromDesktopFile() const
|
||||
{
|
||||
if (m_desktopFileName.isEmpty()) {
|
||||
return iconFromDesktopFile(QFile::decodeName(m_desktopFileName));
|
||||
}
|
||||
|
||||
QString AbstractClient::iconFromDesktopFile(const QString &desktopFileName)
|
||||
{
|
||||
if (desktopFileName.isEmpty()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const QString desktopFileName = QString::fromUtf8(m_desktopFileName);
|
||||
QString desktopFilePath;
|
||||
|
||||
if (QDir::isAbsolutePath(desktopFileName)) {
|
||||
|
@ -2726,6 +2730,9 @@ QString AbstractClient::iconFromDesktopFile() const
|
|||
desktopFilePath = QStandardPaths::locate(QStandardPaths::ApplicationsLocation,
|
||||
desktopFileName + QLatin1String(".desktop"));
|
||||
}
|
||||
if (desktopFilePath.isEmpty()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
KDesktopFile df(desktopFilePath);
|
||||
return df.readIcon();
|
||||
|
|
|
@ -878,6 +878,13 @@ public:
|
|||
|
||||
QRect fullscreenGeometryRestore() const;
|
||||
|
||||
/**
|
||||
* Helper function to compute the icon out of an application id defined by @p fileName
|
||||
*
|
||||
* @returns an icon name that can be used with QIcon::fromTheme()
|
||||
*/
|
||||
static QString iconFromDesktopFile(const QString &fileName);
|
||||
|
||||
public Q_SLOTS:
|
||||
virtual void closeWindow() = 0;
|
||||
|
||||
|
|
Loading…
Reference in a new issue