File indexing completed on 2024-04-28 16:54:31
0001 /* 0002 SPDX-FileCopyrightText: 2021 Henri Chain <henri.chain@enioka.com> 0003 SPDX-License-Identifier: LGPL-2.1-or-later 0004 */ 0005 0006 #include "autostartscriptdesktopfile.h" 0007 #include <KConfigGroup> 0008 #include <QStandardPaths> 0009 0010 static const auto autostartScriptKey = QStringLiteral("X-KDE-AutostartScript"); 0011 0012 QDir AutostartScriptDesktopFile::autostartLocation() 0013 { 0014 return QDir(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation)).filePath(QStringLiteral("autostart")); 0015 } 0016 0017 AutostartScriptDesktopFile::AutostartScriptDesktopFile(const QString &name, const QString &execPath) 0018 : KDesktopFile(autostartLocation().absoluteFilePath(name + QStringLiteral(".desktop"))) 0019 { 0020 KConfigGroup kcg = desktopGroup(); 0021 kcg.writeEntry("Type", "Application"); 0022 kcg.writeEntry("Name", name); 0023 kcg.writeEntry("Exec", execPath); 0024 kcg.writeEntry("Icon", "dialog-scripts"); 0025 kcg.writeEntry(autostartScriptKey, "true"); 0026 } 0027 0028 bool AutostartScriptDesktopFile::isAutostartScript(const KDesktopFile &file) 0029 { 0030 return file.desktopGroup().readEntry<bool>(autostartScriptKey, false); 0031 }