diff options
author | Pascal Viandier <midi-pascal@videotron.ca> | 2015-10-01 19:38:38 +0200 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2015-10-01 19:38:38 +0200 |
commit | 1e0e72fceb542e4eb984b50f747c38314f055b8f (patch) | |
tree | 40d35ec3682c465348f8d8d73509aeda4729a8bb /src/setupdialogprg.cpp | |
parent | c9e33e7d3fcd5b21a00e13dcbb5742a6c8da6106 (diff) | |
download | kooldock-1e0e72fceb542e4eb984b50f747c38314f055b8f.tar.gz kooldock-1e0e72fceb542e4eb984b50f747c38314f055b8f.zip |
Fix remaining issues and build warnings
Cleanup code
Signed-off-by: Pascal Viandier <midi-pascal@videotron.ca>
Diffstat (limited to 'src/setupdialogprg.cpp')
-rw-r--r-- | src/setupdialogprg.cpp | 528 |
1 files changed, 235 insertions, 293 deletions
diff --git a/src/setupdialogprg.cpp b/src/setupdialogprg.cpp index 38a11e8..ae304cb 100644 --- a/src/setupdialogprg.cpp +++ b/src/setupdialogprg.cpp @@ -33,30 +33,30 @@ #include "appProp.h" #include "kooldock.h" -SetupDialogPrg::SetupDialogPrg(TQWidget *parent, const char *name) +SetupDialogPrg::SetupDialogPrg(TQWidget* parent, const char* name) : SetupDialog(parent, name) { - //Ignore list handlers - grabbing=0; - gwm=new KWinModule(); + //Ignore list handlers + grabbing = 0; + gwm = new KWinModule(); connect(gwm, SIGNAL(activeWindowChanged(WId)), SLOT(activeWindowChanged(WId))); gwm->blockSignals(true); - in=ignoreBox->lineEdit(); - //Remove useless buttons from widget - up=ignoreBox->upButton(); - down=ignoreBox->downButton(); + in = ignoreBox->lineEdit(); + // Remove useless buttons from widget + up = ignoreBox->upButton(); + down = ignoreBox->downButton(); up->hide(); down->hide(); - //End ignore list handlers + //End ignore list handlers - // some configuration variables + // some configuration variables progPath = locateLocal("data", "kooldock"); menuPath = progPath + TQString("/menu/"); - TDEConfig *config = TDEGlobal::config(); + TDEConfig* config = TDEGlobal::config(); config->setGroup("kooldock"); - appdlg=new appPropPrg(); + appdlg = new appPropPrg(); appdlg->user->setEnabled(false); appdlg->cuser->setChecked(false); appdlg->terminal->setChecked(false); @@ -64,42 +64,47 @@ SetupDialogPrg::SetupDialogPrg(TQWidget *parent, const char *name) appdlg->tclose->setEnabled(false); connect(appdlg, SIGNAL(apply()), SLOT(appRestart())); - //Lets load the theme List + // Load the theme List TDEStandardDirs sys; TQStringList bgPath = sys.findDirs("data", "kooldock/backgrounds"); - for(unsigned int i=0; i<bgPath.count();i++) - { + for (unsigned int i = 0; i < bgPath.count(); i++) { TQDir tmpdir(bgPath[i]); TQStringList theme_tmp(tmpdir.entryList(TQDir::Dirs, TQDir::Name)); - //We do it like this to avoid showing "." and ".." instead of copying TQDir::entryList directly into "theme" - for(unsigned int j=2; j<theme_tmp.count(); j++) theme->insertItem(theme_tmp[j]); + // Avoid showing "." and ".." instead of copying TQDir::entryList directly into "theme" + for (unsigned int j = 2; j < theme_tmp.count(); j++) { + theme->insertItem(theme_tmp[j]); + } } } - void SetupDialogPrg::appRestart() { - if(!appdlg) return; + if (!appdlg) { + return; + } iconsChanged(); kdDebug(0) << "Refresh applist" << endl; appClear(); appFill(); } - SetupDialogPrg::~SetupDialogPrg() { - if(appdlg) delete(appdlg); - if(in) delete(in); + if (appdlg) { + delete appdlg; + } + if (in) { + delete in; + } kdDebug(0) << "Destroying..." << endl; } - // Setup dialog implementation void SetupDialogPrg::iconsChanged() { - toReloadIcons->setChecked(TRUE); + toReloadIcons->setChecked(true); } + void SetupDialogPrg::configOK() { this->hide(); @@ -108,60 +113,38 @@ void SetupDialogPrg::configOK() void SetupDialogPrg::configApply() { - int fShowTaskbar=0; - int fMinimizedOnly=0; - int fShowNotification=0; - int fShowBorders=0; - int fShowKMenu=0; - int fUseKBFX=0; - int fHidden=0; - int showNames=0; - int fCleaner=0; - int fHideOnClick=0; - int fStayBelow = 0; - int fSteppy=0; - int xinerama=0; - int fhideTimer=5; - int fShowNav=0; - int fSystray=0; - int fCurrent=0; - int fPriority=0; - int fpercentPos=0; - int fOrientation=0; - int fClipping=0; - int fClipIcons=0; - int fSpeed=0; - - //Stop grabbing window + int fhideTimer = 5; + int fPriority = 0; + int fpercentPos = 0; + int fOrientation = 0; + + // Stop grabbing window gwm->blockSignals(true); - grabbing=0; + grabbing = 0; grabWin->setText(i18n("Grab Window")); - if (chk5->isChecked() == true) fShowTaskbar = 1; - if (cbMinimizedOnly->isChecked() == true) fMinimizedOnly = 1; - if (chk6->isChecked() == true) fShowNotification = 1; - if (chk4->isChecked() == true) fShowBorders = 1; - if (chk7->isChecked() == true) fShowKMenu = 1; - if (chkUseKBFX->isChecked() == true) fUseKBFX = 1; - if (chk1->isChecked() == true) - { - fHidden = 1; - } - fhideTimer = hideTimer->value(); - if (chk2->isChecked() == true) showNames = 1; - if (cbCleaner->isChecked() == true) fCleaner = 1; - if (hideOnClick->isChecked() == true) fHideOnClick = 1; - if (cbStayBelow->isChecked() == true) fStayBelow = 1; - if (Steppy->isChecked() == true) fSteppy = 1; - if (xrma->isChecked() == true) xinerama=1; - if (nav->isChecked()==true) fShowNav=1; - if (systray->isChecked()==true) fSystray=1; - if (currentDesk->isChecked()==true) fCurrent=1; - if (chClipping->isChecked()==true) fClipping=1; - if (chClipIcons->isChecked()==true) fClipIcons=1; - if (chkSpeed->isChecked()==true) fSpeed=1; - fPriority=Priority->value(); - fpercentPos=percentPos->value(); + int fShowTaskbar = (chk5->isChecked() == true) ? 1 : 0; + int fMinimizedOnly = (cbMinimizedOnly->isChecked() == true) ? 1 : 0; + int fShowNotification = (chk6->isChecked() == true) ? 1 : 0; + int fShowBorders = (chk4->isChecked() == true) ? 1 : 0; + int fShowKMenu = (chk7->isChecked() == true) ? 1 : 0; + int fUseKBFX = (chkUseKBFX->isChecked() == true) ? 1 : 0; + int fHidden = (chk1->isChecked() == true) ? 1 : 0; + fhideTimer = hideTimer->value(); + int showNames = (chk2->isChecked() == true) ? 1 : 0; + int fCleaner = (cbCleaner->isChecked() == true) ? 1 : 0; + int fHideOnClick = (hideOnClick->isChecked() == true) ? 1 : 0; + int fStayBelow = (cbStayBelow->isChecked() == true) ? 1 : 0; + int fSteppy = (Steppy->isChecked() == true) ? 1 : 0; + int xinerama = (xrma->isChecked() == true) ? 1 : 0; + int fShowNav = (nav->isChecked() == true) ? 1 : 0; + int fSystray = (systray->isChecked() == true) ? 1 : 0; + int fCurrent = (currentDesk->isChecked() == true) ? 1 : 0; + int fClipping = (chClipping->isChecked() == true) ? 1 : 0; + int fClipIcons = (chClipIcons->isChecked() == true) ? 1 : 0; + int fSpeed = (chkSpeed->isChecked() == true) ? 1 : 0; + fPriority = Priority->value(); + fpercentPos = percentPos->value(); kdDebug(0) << "Saving preferences..." << endl; TDEConfig *config = TDEGlobal::config(); @@ -185,7 +168,11 @@ void SetupDialogPrg::configApply() config->writeEntry("Xinerama", xinerama); config->writeEntry("nWideBg", nWideBg->isChecked()); config->writeEntry("scaleMax", opScale2->isChecked()); - if(xinerama==1) {config->writeEntry("leftRes", SleftRes->value()); config->writeEntry("XinDesiredHeight", SHeight->value()); config->writeEntry("XinPreviousWidth", PWidth->value());} + if(xinerama==1) { + config->writeEntry("leftRes", SleftRes->value()); + config->writeEntry("XinDesiredHeight", SHeight->value()); + config->writeEntry("XinPreviousWidth", PWidth->value()); + } config->writeEntry("hideTimer", fhideTimer); config->writeEntry("Navigator", fShowNav); config->writeEntry("Systray", fSystray); @@ -195,14 +182,20 @@ void SetupDialogPrg::configApply() config->writeEntry("Clipping", fClipping); config->writeEntry("ClipIconArea", fClipIcons); config->writeEntry("percentPos", fpercentPos); - if (op1->isChecked()) fOrientation=1; - if (op2->isChecked()) fOrientation=2; - if (op3->isChecked()) fOrientation=3; + if (op1->isChecked()) { + fOrientation = 1; + } + if (op2->isChecked()) { + fOrientation = 2; + } + if (op3->isChecked()) { + fOrientation = 3; + } config->writeEntry("fOrientation", fOrientation); config->writeEntry("zoomSpeed", zoomSpeed->value()); config->writeEntry("speedControl", fSpeed); - // kosd config + // kosd config config->writeEntry("showNames", showNames); config->writeEntry("Cleaner", fCleaner); config->writeEntry("xosdFont", xosdFont->currentText()); @@ -210,40 +203,35 @@ void SetupDialogPrg::configApply() config->writeEntry("xosdShadowColor", kColorCombo_shadow->color().name()); config->writeEntry("xosdShadowOffset", spinBox2->value()); config->writeEntry("xosdSize", xosdSize->value()); - if (xosdBold->isChecked()) - { + if (xosdBold->isChecked()) { config->writeEntry("xosdBold", 1); } - else - { + else { config->writeEntry("xosdBold", 0); } - if (xosdItalic->isChecked()) - { + if (xosdItalic->isChecked()) { config->writeEntry("xosdItalic", 1); } - else - { + else { config->writeEntry("xosdItalic", 0); } config->writeEntry("ShowSShot", chkSshot->isChecked()); config->writeEntry("iconGrouping", chkGrouping->isChecked()); - // save background configurations - if (chkImg->isChecked()) - { - //Lets find exactly where the selected theme is + // Save background configurations + if (chkImg->isChecked()) { + // Find where is the selected theme TDEStandardDirs sys; - TQString theme_dir="kooldock/backgrounds/"+theme->currentText(); + TQString theme_dir = "kooldock/backgrounds/" + theme->currentText(); TQStringList bgPath = sys.findDirs("data", theme_dir); - //Lets set the images and write the config - TQString LeftImg=(TQString)bgPath[0]+"background-left.png"; - TQString CenterImg=(TQString)bgPath[0]+"background-center.png"; - TQString RightImg=(TQString)bgPath[0]+"background-right.png"; + // Set the images and write the config + TQString LeftImg = (TQString)bgPath[0] + "background-left.png"; + TQString CenterImg = (TQString)bgPath[0] + "background-center.png"; + TQString RightImg = (TQString)bgPath[0] + "background-right.png"; - // background image enabled + // Background image enabled config->writeEntry("Solid", 0); config->writeEntry("Theme", theme->currentText()); config->writeEntry("LeftImg", LeftImg); @@ -252,9 +240,8 @@ void SetupDialogPrg::configApply() config->writeEntry("ShowBorders", 0); config->writeEntry("DockOpacity", 0); } - else - { - // background image disabled + else { + // Background image disabled config->writeEntry("Solid", 1); config->writeEntry("Theme", ""); config->writeEntry("LeftImg", ""); @@ -266,25 +253,21 @@ void SetupDialogPrg::configApply() config->sync(); - // write ignore list to file + // Write ignore list to file TQString progPath = locateLocal("data", "kooldock"); TQString menuPath = progPath + TQString("/menu/"); filepath = TQString(progPath + "/ignorelist.conf"); - if(ignoreBox->count()>0) - { + if(ignoreBox->count() > 0) { TQFile out(filepath); - if (out.open(IO_WriteOnly)) - { + if (out.open(IO_WriteOnly)) { TQTextStream out_s(&out); - for(int i=0; i<ignoreBox->count(); i++) - { + for(int i = 0; i < ignoreBox->count(); i++) { out_s << ignoreBox->text(i) << "\n"; } out.close(); } } - else - { + else { TQFile::remove(filepath); } emit apply(); @@ -292,14 +275,14 @@ void SetupDialogPrg::configApply() void SetupDialogPrg::configCancel() { - //Stop grabbing Windows + // Stop grabbing Windows gwm->blockSignals(true); grabWin->setText(i18n("Grab Window")); - grabbing=0; + grabbing = 0; this->hide(); } -void SetupDialogPrg::closeEvent( TQCloseEvent *e ) +void SetupDialogPrg::closeEvent(TQCloseEvent* e) { e->ignore(); configCancel(); @@ -309,13 +292,11 @@ void SetupDialogPrg::chkFont() { bool tmp; //just to save some code - if(chk2->isChecked()) - { - tmp=true; + if(chk2->isChecked()) { + tmp = true; } - else - { - tmp=false; + else { + tmp = false; } xosdBold->setEnabled(tmp); xosdItalic->setEnabled(tmp); @@ -327,26 +308,24 @@ void SetupDialogPrg::chkFont() cbCleaner->setEnabled(tmp); } - void SetupDialogPrg::xrma_clicked() { - if(xrma->isChecked()==true) {SleftRes->setEnabled(true); SHeight->setEnabled(true); PWidth->setEnabled(true);} - if(xrma->isChecked()==false) {SleftRes->setEnabled(false); SHeight->setEnabled(false); PWidth->setEnabled(false);} + if (xrma->isChecked()==true) { + SleftRes->setEnabled(true); + SHeight->setEnabled(true); + PWidth->setEnabled(true); + } + if (xrma->isChecked()==false) { + SleftRes->setEnabled(false); + SHeight->setEnabled(false); + PWidth->setEnabled(false); + } } void SetupDialogPrg::chkTask() { - iconsChanged(); - bool tmp; - - if(chk5->isChecked()) - { - tmp=true; - } - else - { - tmp=false; - } + iconsChanged(); + bool tmp = chk5->isChecked(); chk6->setEnabled(tmp); currentDesk->setEnabled(tmp); chkSshot->setEnabled(tmp); @@ -356,22 +335,13 @@ void SetupDialogPrg::chkTask() void SetupDialogPrg::chkHidden() { - bool tmp; - - if(chk1->isChecked()) - { - tmp=true; - } - else - { - tmp=false; - } + bool tmp = chk1->isChecked(); hideTimer->setEnabled(tmp); hideOnClick->setEnabled(tmp); cbStayBelow->setEnabled(!tmp); } -void SetupDialogPrg::applist_dropped(TQDropEvent*e,const TQValueList<TQIconDragItem>&) +void SetupDialogPrg::applist_dropped(TQDropEvent* e,const TQValueList<TQIconDragItem>&) { TDEIconLoader icon_obj; TQStringList lst; @@ -379,39 +349,34 @@ void SetupDialogPrg::applist_dropped(TQDropEvent*e,const TQValueList<TQIconDragI int pos; TQUriDrag::decodeLocalFiles(e, lst); - name=lst[0]; + name = lst[0]; - //Lets see if it is a desktop file - pos=name.findRev(".desktop", -1); - if(pos!=-1) - { - KSimpleConfig *desktopfile; + // Check if it is a desktop file + pos = name.findRev(".desktop", -1); + if(pos != -1) { + KSimpleConfig* desktopfile; kdDebug(0) << "Desktop file dropped!" << endl; - desktopfile = new KSimpleConfig(lst[0], TRUE); + desktopfile = new KSimpleConfig(lst[0], true); desktopfile->setGroup("Desktop Entry"); appdlg->cmdname->setText(desktopfile->readEntry("Name")); appdlg->cmdpath->setText(desktopfile->readEntry("Exec")); appdlg->iconbutton->setIcon(desktopfile->readEntry("Icon")); - delete(desktopfile); - } - else - { - //It was not a dekstop file, so lets create a new entry - //Lets set a default name based on the program name - pos=name.findRev("/", -1); - if(pos!=-1) - { + delete desktopfile; + } + else { + // It was not a dekstop file, so create a new entry + // Set a default name based on the program name + pos = name.findRev("/", -1); + if (pos != -1) { name.remove(1, pos); name.remove("/", TRUE); } - - //Now we create and show the appProp dialog - //appdlg=new appPropPrg(); + // Create and show the appProp dialog appdlg->cmdname->setText(name); appdlg->cmdpath->setText(lst[0]); - //Based on the program name, lets try to set an icon; if it does - //not exists, the system will set the "default" icon + //Based on the program name, try to set an icon; if it does + // not exists, the system will set the "default" icon appdlg->iconbutton->setIcon(name); } appdlg->show(); @@ -419,98 +384,83 @@ void SetupDialogPrg::applist_dropped(TQDropEvent*e,const TQValueList<TQIconDragI void SetupDialogPrg::removeLauncher() { - if(fileName!=NULL) - { - TQString question=i18n("Do you want to remove ") + fileName + TQString("?"); + if (fileName != NULL) { + TQString question = i18n("Do you want to remove ") + fileName + TQString("?"); int remove = KMessageBox::questionYesNo(0, question, i18n("Remove Launcher")); - if(remove!=KMessageBox::Yes) return; - KSimpleConfig *desktopfile; + if (remove != KMessageBox::Yes) { + return; + } + KSimpleConfig* desktopfile; TQDir homeDir = TQDir::home(); - - if (homeDir.exists(progPath)) - { + if (homeDir.exists(progPath)) { TQDir dir(menuPath); TQStringList fileListRemove; fileListRemove = dir.entryList("*.desktop"); - for ( TQStringList::Iterator it = fileListRemove.begin(); it != fileListRemove.end(); ++it ) - { - if ( ((*it) != ".") && ((*it) != "..") ) - { - desktopfile = new KSimpleConfig( menuPath + (*it), TRUE); + for (TQStringList::Iterator it = fileListRemove.begin(); it != fileListRemove.end(); ++it) { + if (((*it) != ".") && ((*it) != "..")) { + desktopfile = new KSimpleConfig(menuPath + (*it), true); desktopfile->setGroup("Desktop Entry"); - if(desktopfile->readEntry("Name")==fileName) - { + if (desktopfile->readEntry("Name") == fileName) { kdDebug(0) << "Removing " << menuPath + (*it) << endl; - delete(desktopfile); - if(TQFile::remove(menuPath+(*it))==TRUE) - { + delete desktopfile; + if (TQFile::remove(menuPath+(*it)) == true) { kdDebug(0) << "Item removed!" << endl; - - //Lets update the launchers index + // Update the launchers index TQString preffix; fileListRemove.clear(); fileListRemove=dir.entryList("*.desktop"); TQStringList fileListRemove2=fileListRemove; - - //Not really sure why I couldn't do this within the other for, something like fileListRemove[i].remove(0,2).prepend(preffix), but hell it works - for(unsigned int i=0; i<fileListRemove2.count(); i++) - { - fileListRemove2[i].remove(0,2); + + for (unsigned int i = 0; i < fileListRemove2.count(); i++) { + fileListRemove2[i].remove(0, 2); } - - //Rename the files so they reflect their new position - for(unsigned int i=0; i<fileListRemove.count(); i++) - { - if(i<10) preffix=TQString("0%1").arg(i); - if(i>=10) preffix=TQString("%1").arg(i); - + // Rename the files so they reflect their new position + for (unsigned int i = 0; i < fileListRemove.count(); i++) { + if (i < 10) { + preffix = TQString("0%1").arg(i); + } + if (i >= 10) { + preffix = TQString("%1").arg(i); + } dir.rename(fileListRemove[i], TQString("%1%2").arg(preffix).arg(fileListRemove2[i])); } - //End updating - + // End updating appClear(); appFill(); iconsChanged(); } - else - { + else { kdDebug(0) << "Unable to remove file!" << endl; } return; } - delete(desktopfile); + delete desktopfile; } } } } } - void SetupDialogPrg::grabWin_clicked() { - if(grabbing==0) - { - grabbing=1; + if (grabbing == 0) { + grabbing = 1; grabWin->setText(i18n("Grabbing...")); gwm->blockSignals(false); } - else - { - grabbing=0; + else { + grabbing = 0; grabWin->setText(i18n("Grab Window")); gwm->blockSignals(true); } } - void SetupDialogPrg::activeWindowChanged(WId id) { - KWin::WindowInfo winfo; - winfo=KWin::windowInfo(id); - TQString ninfo=winfo.visibleName(); + KWin::WindowInfo winfo = KWin::windowInfo(id); + TQString ninfo = winfo.visibleName(); - if(ninfo!=caption()) - { + if (ninfo != caption()) { in->setText(ninfo); } } @@ -523,44 +473,40 @@ void SetupDialogPrg::buttonadd_clicked() appdlg->show(); } -void SetupDialogPrg::showEvent(TQShowEvent *) +void SetupDialogPrg::showEvent(TQShowEvent*) { - //Here we fill the applist + // Fill the applist appFill(); } void SetupDialogPrg::appFill() { - // fill the application list. - KSimpleConfig *desktopfile; + // Fill the application list. + KSimpleConfig* desktopfile; TQDir homeDir = TQDir::home(); TDEIconLoader icon_obj; TQPixmap pixm; - if(homeDir.exists(progPath)) - { + if (homeDir.exists(progPath)) { TQDir dir(menuPath); - fileList.clear(); fileList = dir.entryList("*.desktop"); - for ( TQStringList::Iterator it = fileList.begin(); it != fileList.end(); ++it ) - { - if ( ((*it) != ".") && ((*it) != "..") ) - { - desktopfile = new KSimpleConfig( menuPath + (*it), TRUE); + for (TQStringList::Iterator it = fileList.begin(); it != fileList.end(); ++it ) { + if (((*it) != ".") && ((*it) != "..")) { + desktopfile = new KSimpleConfig(menuPath + (*it), true); desktopfile->setGroup("Desktop Entry"); - TQPixmap pixm=icon_obj.loadIcon(desktopfile->readEntry("Icon") ,TDEIcon::Desktop,0,TDEIcon::DefaultState,0L,false); + TQPixmap pixm=icon_obj.loadIcon(desktopfile->readEntry("Icon"), TDEIcon::Desktop, 0, TDEIcon::DefaultState, 0L, false); new TDEIconViewItem(applist, desktopfile->readEntry("Name"), pixm); - delete(desktopfile); + delete desktopfile; } } } } -void SetupDialogPrg::hideEvent ( TQHideEvent * ) +void SetupDialogPrg::hideEvent(TQHideEvent*) { - // the application list is erased here. + // the application list is erased here. appClear(); } @@ -571,64 +517,77 @@ void SetupDialogPrg::appClear() void SetupDialogPrg::left() { - if (oldPos>0) {setnewpos(oldPos-1); oldPos--;iconsChanged();} + if (oldPos > 0) { + setnewpos(oldPos - 1); + oldPos--; + iconsChanged(); + } } void SetupDialogPrg::right() { - if (oldPos!=-1 && oldPos < (int)fileList.count()-1) {setnewpos(oldPos+1); oldPos++;iconsChanged();} + if ((oldPos != -1) && (oldPos < (int)fileList.count() - 1)) { + setnewpos(oldPos + 1); + oldPos++; + iconsChanged(); + } } -void SetupDialogPrg::applist_clicked(TQIconViewItem *e, const TQPoint&) +void SetupDialogPrg::applist_clicked(TQIconViewItem* e, const TQPoint&) { - if(e!=NULL) - {oldPos=e->index();} - else - {oldPos=-1;} + if (e != NULL) { + oldPos = e->index(); + } + else { + oldPos = -1; + } } -void SetupDialogPrg::applist_contextMenuRequested(TQIconViewItem *e,const TQPoint&) + +void SetupDialogPrg::applist_contextMenuRequested(TQIconViewItem* e,const TQPoint&) { - if(e!=NULL) - { - TDEPopupMenu *popup=new TDEPopupMenu(); - TDEPopupMenu *setpos=new TDEPopupMenu(); + if (e != NULL) { + TDEPopupMenu* popup = new TDEPopupMenu(); + TDEPopupMenu* setpos = new TDEPopupMenu(); - fileName=e->text(); - oldPos=e->index(); + fileName = e->text(); + oldPos = e->index(); connect(setpos, SIGNAL(activated(int)), this, SLOT(setnewpos(int))); - //Load desktop data - KSimpleConfig *desktopfile; - + // Load desktop data + KSimpleConfig* desktopfile; TQDir dir(menuPath); fileList.clear(); fileList = dir.entryList("*.desktop"); - int i=0; - for ( TQStringList::Iterator it = fileList.begin(); it != fileList.end(); ++it ) - { - if ( ((*it) != ".") && ((*it) != "..") ) - { - desktopfile = new KSimpleConfig( menuPath + (*it), TRUE); + int i = 0; + for (TQStringList::Iterator it = fileList.begin(); it != fileList.end(); ++it) { + if (((*it) != ".") && ((*it) != "..")) { + desktopfile = new KSimpleConfig(menuPath + (*it), true); desktopfile->setGroup("Desktop Entry"); - int menustate=setpos->insertItem(TQString("%1").arg(desktopfile->readEntry("Name")),i); - if(i==oldPos) {setpos->setItemEnabled(menustate, false);filepath=menuPath + (*it);} - delete(desktopfile); + int menustate = setpos->insertItem(TQString("%1").arg(desktopfile->readEntry("Name")),i); + if (i == oldPos) { + setpos->setItemEnabled(menustate, false); + filepath = menuPath + (*it); + } + delete desktopfile; i++; } } - //End Load + // End Load popup->insertTitle(e->text()); popup->insertItem(i18n("Swap with"), setpos); popup->insertItem(i18n("&Edit item"), this, SLOT(editItem())); popup->insertItem(i18n("Remove"), this, SLOT(removeLauncher())); popup->exec(TQCursor::pos()); - if(popup) delete(popup); - if(setpos) delete(setpos); + if (popup) { + delete popup; + } + if (setpos) { + delete setpos; + } } - else - { - oldPos=-1; + else { + oldPos = -1; } } @@ -640,7 +599,9 @@ void SetupDialogPrg::editItem() void SetupDialogPrg::setnewpos(int newpos) { kdDebug(0) << "New pos " << TQString("0%1").arg(newpos) << "requested for: " << fileName<< endl; - if(newpos==oldPos) return; //Nothing to be done + if (newpos == oldPos) { + return; // Nothing to be done + } computeNewPos(newpos); } @@ -652,20 +613,14 @@ void SetupDialogPrg::computeNewPos(int pos) fileList.clear(); fileList = dir.entryList("*.desktop"); - //Lets remove the preffix of the files from fileList - for(unsigned int i=0; i<fileList.count(); i++) - { - fileList[i]=fileList[i].remove(0,2); + // Remove the prefix of the files from fileList + for (unsigned int i = 0; i < fileList.count(); i++) { + fileList[i] = fileList[i].remove(0, 2); } - - //Preffix for old position - if(oldPos<10) preffix=TQString("0%1").arg(oldPos); - if(oldPos>=10) preffix=TQString("%1").arg(oldPos); - - //Preffix for new position - if(pos<10) preffix2=TQString("0%1").arg(pos); - if(pos>=10) preffix2=TQString("%1").arg(pos); - + // Prefix for old position + preffix.sprintf("%02d", oldPos); + // Prefix for new position + preffix2.sprintf("%02d", pos); kdDebug(0) << "Old Position: " << oldPos << endl; kdDebug(0) << "New Position: " << pos << endl; @@ -678,25 +633,12 @@ void SetupDialogPrg::computeNewPos(int pos) void SetupDialogPrg::chkImgSlot() { - if (chkImg->isChecked()) - { - chkSolid->setChecked(false); - } - else - { - chkSolid->setChecked(true); - } + chkSolid->setChecked(!chkImg->isChecked()); } void SetupDialogPrg::chkSolidSlot() { - if (chkSolid->isChecked()) - { - chkImg->setChecked(false); - } - else - { - chkImg->setChecked(true); - }} + chkImg->setChecked(!chkSolid->isChecked()); +} #include "setupdialogprg.moc" |