From 46555645d00c11ea59993b09fa3464643bd98f62 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sun, 12 Jan 2020 00:26:22 +0900 Subject: Improve code avoiding allocation of unnecessary objects. Signed-off-by: Michele Calgaro --- src/autostart.cpp | 28 ++++++++++++---------------- src/autostart.h | 10 ++++------ 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 #include #include -#include #include #include @@ -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; }; -- cgit v1.2.1