@ -5,7 +5,7 @@
SPDX - License - Identifier : LGPL - 2.0 - or - later
*/
# include "k autostart.h"
# include "plasma autostart.h"
# include <KConfigGroup>
# include <KDesktopFile>
@ -14,16 +14,16 @@
# include <QDir>
# include <QFile>
class K AutostartPrivate
class Plasma AutostartPrivate
{
public :
K AutostartPrivate( )
Plasma AutostartPrivate( )
: df ( nullptr )
, copyIfNeededChecked ( false )
{
}
~ K AutostartPrivate( )
~ Plasma AutostartPrivate( )
{
delete df ;
}
@ -35,7 +35,7 @@ public:
bool copyIfNeededChecked ;
} ;
void K AutostartPrivate: : copyIfNeeded ( )
void Plasma AutostartPrivate: : copyIfNeeded ( )
{
if ( copyIfNeededChecked ) {
return ;
@ -56,9 +56,9 @@ void KAutostartPrivate::copyIfNeeded()
copyIfNeededChecked = true ;
}
KAutostart : : K Autostart( const QString & entryName , QObject * parent )
PlasmaAutostart : : Plasma Autostart( const QString & entryName , QObject * parent )
: QObject ( parent )
, d ( new K AutostartPrivate)
, d ( new Plasma AutostartPrivate)
{
const bool isAbsolute = QDir : : isAbsolutePath ( entryName ) ;
if ( isAbsolute ) {
@ -85,9 +85,9 @@ KAutostart::KAutostart(const QString &entryName, QObject *parent)
}
}
K Autostart: : ~ K Autostart( ) = default ;
Plasma Autostart: : ~ Plasma Autostart( ) = default ;
void K Autostart: : setAutostarts ( bool autostart )
void Plasma Autostart: : setAutostarts ( bool autostart )
{
bool currentAutostartState = ! d - > df - > desktopGroup ( ) . readEntry ( " Hidden " , false ) ;
if ( currentAutostartState = = autostart ) {
@ -98,7 +98,7 @@ void KAutostart::setAutostarts(bool autostart)
d - > df - > desktopGroup ( ) . writeEntry ( " Hidden " , ! autostart ) ;
}
bool K Autostart: : autostarts ( const QString & environment , Conditions check ) const
bool Plasma Autostart: : autostarts ( const QString & environment , Conditions check ) const
{
// check if this is actually a .desktop file
bool starts = d - > df - > desktopGroup ( ) . exists ( ) ;
@ -121,12 +121,12 @@ bool KAutostart::autostarts(const QString &environment, Conditions check) const
return starts ;
}
bool K Autostart: : checkStartCondition ( ) const
bool Plasma Autostart: : checkStartCondition ( ) const
{
return K Autostart: : isStartConditionMet ( d - > df - > desktopGroup ( ) . readEntry ( " X-KDE-autostart-condition " ) ) ;
return Plasma Autostart: : isStartConditionMet ( d - > df - > desktopGroup ( ) . readEntry ( " X-KDE-autostart-condition " ) ) ;
}
bool K Autostart: : isStartConditionMet ( const QString & condition )
bool Plasma Autostart: : isStartConditionMet ( const QString & condition )
{
if ( condition . isEmpty ( ) ) {
return true ;
@ -148,7 +148,7 @@ bool KAutostart::isStartConditionMet(const QString &condition)
return cg . readEntry ( list [ 2 ] , defaultValue ) ;
}
bool K Autostart: : checkAllowedEnvironment ( const QString & environment ) const
bool Plasma Autostart: : checkAllowedEnvironment ( const QString & environment ) const
{
const QStringList allowed = allowedEnvironments ( ) ;
if ( ! allowed . isEmpty ( ) ) {
@ -163,12 +163,12 @@ bool KAutostart::checkAllowedEnvironment(const QString &environment) const
return true ;
}
QString K Autostart: : command ( ) const
QString Plasma Autostart: : command ( ) const
{
return d - > df - > desktopGroup ( ) . readEntry ( " Exec " , QString ( ) ) ;
}
void K Autostart: : setCommand ( const QString & command )
void Plasma Autostart: : setCommand ( const QString & command )
{
if ( d - > df - > desktopGroup ( ) . readEntry ( " Exec " , QString ( ) ) = = command ) {
return ;
@ -178,12 +178,12 @@ void KAutostart::setCommand(const QString &command)
d - > df - > desktopGroup ( ) . writeEntry ( " Exec " , command ) ;
}
QString K Autostart: : visibleName ( ) const
QString Plasma Autostart: : visibleName ( ) const
{
return d - > df - > readName ( ) ;
}
void K Autostart: : setVisibleName ( const QString & name )
void Plasma Autostart: : setVisibleName ( const QString & name )
{
if ( d - > df - > desktopGroup ( ) . readEntry ( " Name " , QString ( ) ) = = name ) {
return ;
@ -193,18 +193,18 @@ void KAutostart::setVisibleName(const QString &name)
d - > df - > desktopGroup ( ) . writeEntry ( " Name " , name ) ;
}
bool K Autostart: : isServiceRegistered ( const QString & entryName )
bool Plasma Autostart: : isServiceRegistered ( const QString & entryName )
{
const QString localDir = QStandardPaths : : writableLocation ( QStandardPaths : : GenericConfigLocation ) + QLatin1String ( " /autostart/ " ) ;
return QFile : : exists ( localDir + entryName + QLatin1String ( " .desktop " ) ) ;
}
QString K Autostart: : commandToCheck ( ) const
QString Plasma Autostart: : commandToCheck ( ) const
{
return d - > df - > desktopGroup ( ) . readPathEntry ( " TryExec " , QString ( ) ) ;
}
void K Autostart: : setCommandToCheck ( const QString & exec )
void Plasma Autostart: : setCommandToCheck ( const QString & exec )
{
if ( d - > df - > desktopGroup ( ) . readEntry ( " TryExec " , QString ( ) ) = = exec ) {
return ;
@ -216,7 +216,7 @@ void KAutostart::setCommandToCheck(const QString &exec)
// do not specialize the readEntry template -
// http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=100911
static K Autostart: : StartPhase readEntry ( const KConfigGroup & group , const char * key , K Autostart: : StartPhase aDefault )
static Plasma Autostart: : StartPhase readEntry ( const KConfigGroup & group , const char * key , Plasma Autostart: : StartPhase aDefault )
{
const QByteArray data = group . readEntry ( key , QByteArray ( ) ) ;
@ -225,22 +225,22 @@ static KAutostart::StartPhase readEntry(const KConfigGroup &group, const char *k
}
if ( data = = " 0 " | | data = = " BaseDesktop " ) {
return K Autostart: : BaseDesktop ;
return Plasma Autostart: : BaseDesktop ;
} else if ( data = = " 1 " | | data = = " DesktopServices " ) {
return K Autostart: : DesktopServices ;
return Plasma Autostart: : DesktopServices ;
} else if ( data = = " 2 " | | data = = " Applications " ) {
return K Autostart: : Applications ;
return Plasma Autostart: : Applications ;
}
return aDefault ;
}
K Autostart: : StartPhase K Autostart: : startPhase ( ) const
Plasma Autostart: : StartPhase Plasma Autostart: : startPhase ( ) const
{
return readEntry ( d - > df - > desktopGroup ( ) , " X-KDE-autostart-phase " , Applications ) ;
}
void K Autostart: : setStartPhase ( K Autostart: : StartPhase phase )
void Plasma Autostart: : setStartPhase ( Plasma Autostart: : StartPhase phase )
{
QString data = QStringLiteral ( " Applications " ) ;
@ -263,12 +263,12 @@ void KAutostart::setStartPhase(KAutostart::StartPhase phase)
d - > df - > desktopGroup ( ) . writeEntry ( " X-KDE-autostart-phase " , data ) ;
}
QStringList K Autostart: : allowedEnvironments ( ) const
QStringList Plasma Autostart: : allowedEnvironments ( ) const
{
return d - > df - > desktopGroup ( ) . readXdgListEntry ( " OnlyShowIn " ) ;
}
void K Autostart: : setAllowedEnvironments ( const QStringList & environments )
void Plasma Autostart: : setAllowedEnvironments ( const QStringList & environments )
{
if ( d - > df - > desktopGroup ( ) . readEntry ( " OnlyShowIn " , QStringList ( ) ) = = environments ) {
return ;
@ -278,7 +278,7 @@ void KAutostart::setAllowedEnvironments(const QStringList &environments)
d - > df - > desktopGroup ( ) . writeXdgListEntry ( " OnlyShowIn " , environments ) ;
}
void K Autostart: : addToAllowedEnvironments ( const QString & environment )
void Plasma Autostart: : addToAllowedEnvironments ( const QString & environment )
{
QStringList envs = allowedEnvironments ( ) ;
@ -290,7 +290,7 @@ void KAutostart::addToAllowedEnvironments(const QString &environment)
setAllowedEnvironments ( envs ) ;
}
void K Autostart: : removeFromAllowedEnvironments ( const QString & environment )
void Plasma Autostart: : removeFromAllowedEnvironments ( const QString & environment )
{
QStringList envs = allowedEnvironments ( ) ;
int index = envs . indexOf ( environment ) ;
@ -303,12 +303,12 @@ void KAutostart::removeFromAllowedEnvironments(const QString &environment)
setAllowedEnvironments ( envs ) ;
}
QStringList K Autostart: : excludedEnvironments ( ) const
QStringList Plasma Autostart: : excludedEnvironments ( ) const
{
return d - > df - > desktopGroup ( ) . readXdgListEntry ( " NotShowIn " ) ;
}
void K Autostart: : setExcludedEnvironments ( const QStringList & environments )
void Plasma Autostart: : setExcludedEnvironments ( const QStringList & environments )
{
if ( d - > df - > desktopGroup ( ) . readEntry ( " NotShowIn " , QStringList ( ) ) = = environments ) {
return ;
@ -318,7 +318,7 @@ void KAutostart::setExcludedEnvironments(const QStringList &environments)
d - > df - > desktopGroup ( ) . writeXdgListEntry ( " NotShowIn " , environments ) ;
}
void K Autostart: : addToExcludedEnvironments ( const QString & environment )
void Plasma Autostart: : addToExcludedEnvironments ( const QString & environment )
{
QStringList envs = excludedEnvironments ( ) ;
@ -330,7 +330,7 @@ void KAutostart::addToExcludedEnvironments(const QString &environment)
setExcludedEnvironments ( envs ) ;
}
void K Autostart: : removeFromExcludedEnvironments ( const QString & environment )
void Plasma Autostart: : removeFromExcludedEnvironments ( const QString & environment )
{
QStringList envs = excludedEnvironments ( ) ;
int index = envs . indexOf ( environment ) ;
@ -343,7 +343,7 @@ void KAutostart::removeFromExcludedEnvironments(const QString &environment)
setExcludedEnvironments ( envs ) ;
}
QString K Autostart: : startAfter ( ) const
QString Plasma Autostart: : startAfter ( ) const
{
return d - > df - > desktopGroup ( ) . readEntry ( " X-KDE-autostart-after " ) ;
}