summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Calgaro <[email protected]>2020-01-12 00:26:22 +0900
committerMichele Calgaro <[email protected]>2020-01-12 00:27:18 +0900
commit71b675fa4e99c5f77e63408dcf8f6a9f7566df1c (patch)
tree42eaab0360a8bc819d4deba7a08723e7abce5e4a
parent68672d4f27f55ece3dba82622d309c884722eafc (diff)
downloadkcmautostart-71b675fa4e99c5f77e63408dcf8f6a9f7566df1c.tar.gz
kcmautostart-71b675fa4e99c5f77e63408dcf8f6a9f7566df1c.zip
Improve code avoiding allocation of unnecessary objects.
Signed-off-by: Michele Calgaro <[email protected]> (cherry picked from commit 46555645d00c11ea59993b09fa3464643bd98f62)
-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;
};