summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2020-01-12 00:26:22 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2020-01-12 00:26:22 +0900
commit46555645d00c11ea59993b09fa3464643bd98f62 (patch)
tree451194d10fe099993c0cf9d94491543ac9080eca
parentc36344fa1b97f4ed652876d1ac2b70e475b7fa90 (diff)
downloadkcmautostart-46555645.zip
kcmautostart-46555645.tar.gz
Improve code avoiding allocation of unnecessary objects.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
-rw-r--r--src/autostart.cpp28
-rw-r--r--src/autostart.h10
2 files changed, 16 insertions, 22 deletions
diff --git a/src/autostart.cpp b/src/autostart.cpp
index 446c17d..188b3c9 100644
--- a/src/autostart.cpp
+++ b/src/autostart.cpp
@@ -86,19 +86,17 @@ TQString fStartOn() {
void setStartOn(int start) {
iStartOn = start;
- setText(2, fStartOn() );
- TDEStandardDirs *ksd = new TDEStandardDirs();
- TDEGlobalSettings * kgs = new TDEGlobalSettings();
+ setText(2, fStartOn());
TQString path;
switch (iStartOn) {
case AutoStart:
- path = kgs->autostartPath()+"/";
+ path = TDEGlobalSettings::autostartPath()+"/";
break;
case Shutdown:
- path = ksd->localtdedir()+"shutdown/";
+ path = TDEGlobal::dirs()->localtdedir()+"shutdown/";
break;
case ENV:
- path = ksd->localtdedir()+"env/";
+ path = TDEGlobal::dirs()->localtdedir()+"env/";
break;
}
TDEIO::file_move(fileName, KURL( path + fileName.fileName() ));
@@ -191,20 +189,18 @@ CAutostart::~CAutostart()
void CAutostart::load()
{
- kgs = new TDEGlobalSettings();
- kdDebug() << "According to TDE your Autostart location is: " << kgs->autostartPath() << endl;
- TDEStandardDirs *ksd = new TDEStandardDirs();
+ kdDebug() << "According to TDE your Autostart location is: " << TDEGlobalSettings::autostartPath() << endl;
TQString path;
for (int x=0;x<3;x++) {
if (x==0)
- path = kgs->autostartPath();
+ path = TDEGlobalSettings::autostartPath();
else if (x==1)
- path = ksd->localtdedir() + "/shutdown";
+ path = TDEGlobal::dirs()->localtdedir() + "/shutdown";
else if (x==2)
- path = ksd->localtdedir() + "/env";
+ path = TDEGlobal::dirs()->localtdedir() + "/env";
- if (! TDEStandardDirs::exists(path))
+ if (!TDEStandardDirs::exists(path))
TDEStandardDirs::makeDir(path);
TQDir *autostartdir = new TQDir( path );
@@ -256,7 +252,7 @@ void CAutostart::addCMD() {
return;
}
else if ( service->desktopEntryName().isNull() ) {
- desktopTemplate = KURL( kgs->autostartPath() + service->name() + ".desktop" );
+ desktopTemplate = KURL( TDEGlobalSettings::autostartPath() + service->name() + ".desktop" );
KSimpleConfig ksc(desktopTemplate.path());
ksc.setGroup("Desktop Entry");
ksc.writeEntry("Encoding","UTF-8");
@@ -279,13 +275,13 @@ void CAutostart::addCMD() {
return;
}
- KPropertiesDialog *dlg = new KPropertiesDialog( desktopTemplate, KURL(kgs->autostartPath()),
+ KPropertiesDialog *dlg = new KPropertiesDialog( desktopTemplate, KURL(TDEGlobalSettings::autostartPath()),
service->name() + ".desktop", this, 0, true /*modal*/, false /*no auto-show*/ );
if ( dlg->exec() != TQDialog::Accepted )
return;
}
- CDesktopItem * item = new CDesktopItem( kgs->autostartPath() + service->name() + ".desktop", CDesktopItem::AutoStart, listCMD );
+ CDesktopItem * item = new CDesktopItem( TDEGlobalSettings::autostartPath() + service->name() + ".desktop", CDesktopItem::AutoStart, listCMD );
item->setText( 0, item->service->name() );
item->setText( 1, item->service->exec() );
item->setText( 2, item->fStartOn() );
diff --git a/src/autostart.h b/src/autostart.h
index 25381e1..0f82473 100644
--- a/src/autostart.h
+++ b/src/autostart.h
@@ -29,7 +29,6 @@
#include <kpushbutton.h>
#include <tdelistview.h>
#include <tdefileitem.h>
-#include <tdeglobalsettings.h>
#include <tqpushbutton.h>
#include <tqcombobox.h>
@@ -59,11 +58,10 @@ public slots:
private:
TDEAboutData *myAboutData;
- TDEGlobalSettings *kgs;
- KPushButton* btnAdd;
- TDEListView* listCMD;
- KPushButton* btnRemove;
- TQPushButton* btnProperties;
+ KPushButton* btnAdd;
+ TDEListView* listCMD;
+ KPushButton* btnRemove;
+ TQPushButton* btnProperties;
TQComboBox* cmbStartOn;
};