Improve code avoiding allocation of unnecessary objects.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/4/head
Michele Calgaro 5 years ago
parent c36344fa1b
commit 46555645d0
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -86,19 +86,17 @@ TQString fStartOn() {
void setStartOn(int start) { void setStartOn(int start) {
iStartOn = start; iStartOn = start;
setText(2, fStartOn() ); setText(2, fStartOn());
TDEStandardDirs *ksd = new TDEStandardDirs();
TDEGlobalSettings * kgs = new TDEGlobalSettings();
TQString path; TQString path;
switch (iStartOn) { switch (iStartOn) {
case AutoStart: case AutoStart:
path = kgs->autostartPath()+"/"; path = TDEGlobalSettings::autostartPath()+"/";
break; break;
case Shutdown: case Shutdown:
path = ksd->localtdedir()+"shutdown/"; path = TDEGlobal::dirs()->localtdedir()+"shutdown/";
break; break;
case ENV: case ENV:
path = ksd->localtdedir()+"env/"; path = TDEGlobal::dirs()->localtdedir()+"env/";
break; break;
} }
TDEIO::file_move(fileName, KURL( path + fileName.fileName() )); TDEIO::file_move(fileName, KURL( path + fileName.fileName() ));
@ -191,20 +189,18 @@ CAutostart::~CAutostart()
void CAutostart::load() void CAutostart::load()
{ {
kgs = new TDEGlobalSettings(); kdDebug() << "According to TDE your Autostart location is: " << TDEGlobalSettings::autostartPath() << endl;
kdDebug() << "According to TDE your Autostart location is: " << kgs->autostartPath() << endl;
TDEStandardDirs *ksd = new TDEStandardDirs();
TQString path; TQString path;
for (int x=0;x<3;x++) { for (int x=0;x<3;x++) {
if (x==0) if (x==0)
path = kgs->autostartPath(); path = TDEGlobalSettings::autostartPath();
else if (x==1) else if (x==1)
path = ksd->localtdedir() + "/shutdown"; path = TDEGlobal::dirs()->localtdedir() + "/shutdown";
else if (x==2) else if (x==2)
path = ksd->localtdedir() + "/env"; path = TDEGlobal::dirs()->localtdedir() + "/env";
if (! TDEStandardDirs::exists(path)) if (!TDEStandardDirs::exists(path))
TDEStandardDirs::makeDir(path); TDEStandardDirs::makeDir(path);
TQDir *autostartdir = new TQDir( path ); TQDir *autostartdir = new TQDir( path );
@ -256,7 +252,7 @@ void CAutostart::addCMD() {
return; return;
} }
else if ( service->desktopEntryName().isNull() ) { else if ( service->desktopEntryName().isNull() ) {
desktopTemplate = KURL( kgs->autostartPath() + service->name() + ".desktop" ); desktopTemplate = KURL( TDEGlobalSettings::autostartPath() + service->name() + ".desktop" );
KSimpleConfig ksc(desktopTemplate.path()); KSimpleConfig ksc(desktopTemplate.path());
ksc.setGroup("Desktop Entry"); ksc.setGroup("Desktop Entry");
ksc.writeEntry("Encoding","UTF-8"); ksc.writeEntry("Encoding","UTF-8");
@ -279,13 +275,13 @@ void CAutostart::addCMD() {
return; 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*/ ); service->name() + ".desktop", this, 0, true /*modal*/, false /*no auto-show*/ );
if ( dlg->exec() != TQDialog::Accepted ) if ( dlg->exec() != TQDialog::Accepted )
return; 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( 0, item->service->name() );
item->setText( 1, item->service->exec() ); item->setText( 1, item->service->exec() );
item->setText( 2, item->fStartOn() ); item->setText( 2, item->fStartOn() );

@ -29,7 +29,6 @@
#include <kpushbutton.h> #include <kpushbutton.h>
#include <tdelistview.h> #include <tdelistview.h>
#include <tdefileitem.h> #include <tdefileitem.h>
#include <tdeglobalsettings.h>
#include <tqpushbutton.h> #include <tqpushbutton.h>
#include <tqcombobox.h> #include <tqcombobox.h>
@ -59,7 +58,6 @@ public slots:
private: private:
TDEAboutData *myAboutData; TDEAboutData *myAboutData;
TDEGlobalSettings *kgs;
KPushButton* btnAdd; KPushButton* btnAdd;
TDEListView* listCMD; TDEListView* listCMD;
KPushButton* btnRemove; KPushButton* btnRemove;

Loading…
Cancel
Save