Improve code avoiding allocation of unnecessary objects.

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

@ -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() );

@ -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;
};

Loading…
Cancel
Save