-rw-r--r-- | noncore/settings/tabmanager/tabmanager.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/noncore/settings/tabmanager/tabmanager.cpp b/noncore/settings/tabmanager/tabmanager.cpp index 5f0899c..c9d7aed 100644 --- a/noncore/settings/tabmanager/tabmanager.cpp +++ b/noncore/settings/tabmanager/tabmanager.cpp @@ -228,128 +228,131 @@ void TabManager::removeItem(){ /** * Helper function. Edits the current item. * calls editItem with the currently selected item. */ void TabManager::editCurrentItem(){ editItem(tabList->currentItem()); } /** * Edit the item that is passed in. * Show application dialog and if anything changed * @param item the item to edit. */ void TabManager::editItem( QListViewItem * item){ if(!item) return; TabAppLnk app(itemList[item]); if(!app.isValid()){ qDebug(QString("editItem: Not a valid applnk file: ") + itemList[item].latin1()); return; } // Fill with all of the icons if(!application){ Wait waitDialog(this, "Wait dialog"); waitDialog.waitLabel->setText(tr("Gathering icons...")); waitDialog.show(); qApp->processEvents(); application = new AppEdit(this, "Application edit", true); QDir d(QPEApplication::qpeDir() + "/pics/"); d.setFilter( QDir::Files); const QFileInfoList *list = d.entryInfoList(); QFileInfoListIterator it( *list ); // create list iterator QFileInfo *fi; // pointer for traversing while ( (fi=it.current()) ) { // for each file... QString fileName = fi->fileName(); if(fileName.right(4) == ".png"){ fileName = fileName.mid(0,fileName.length()-4); QPixmap imageOfFile(Resource::loadPixmap(fileName)); QImage foo = imageOfFile.convertToImage(); foo = foo.smoothScale(16,16); imageOfFile.convertFromImage(foo); application->iconLineEdit->insertItem(imageOfFile,fileName); } //qDebug(fi->fileName().latin1()); ++it; } waitDialog.hide(); } int pixmap = -1; QString pixmapText = app.pixmapString(); QComboBox *f = application->iconLineEdit; for(int i = 0; i < application->iconLineEdit->count(); i++){ if(f->text(i) == pixmapText){ pixmap = i; break; } } if(pixmap != -1) application->iconLineEdit->setCurrentItem(pixmap); + else if(pixmapText.isEmpty()){ + application->iconLineEdit->setCurrentItem(0); + } else{ QPixmap imageOfFile(Resource::loadPixmap(pixmapText)); QImage foo = imageOfFile.convertToImage(); foo = foo.smoothScale(16,16); imageOfFile.convertFromImage(foo); application->iconLineEdit->insertItem(imageOfFile,pixmapText,0); application->iconLineEdit->setCurrentItem(0); } application->nameLineEdit->setText(app.name()); application->execLineEdit->setText(app.exec()); application->commentLineEdit->setText(app.comment()); if(item->parent() == NULL){ application->execLineEdit->setEnabled(false); application->TextLabel3->setEnabled(false); application->setCaption(tr("Tab")); } else{ application->execLineEdit->setEnabled(true); application->TextLabel3->setEnabled(true); application->setCaption(tr("Application")); } // Only do somthing if they hit OK application->showMaximized(); if(application->exec() == 0) return; // If nothing has changed exit (hmmm why did they hit ok?) if(app.name() == application->nameLineEdit->text() && app.pixmapString() == application->iconLineEdit->currentText() && app.comment() == application->commentLineEdit->text() && app.exec() == application->execLineEdit->text()) return; // Change the applnk file QString oldName = app.name(); app.setName(application->nameLineEdit->text()); app.setIcon(application->iconLineEdit->currentText()); app.setComment(application->commentLineEdit->text()); app.setExec(application->execLineEdit->text()); if(!app.writeLink()){ QMessageBox::critical(this, tr("Message"), "Can't save.", tr("Ok") ); return; } // Update the gui icon and name item->setText(0,app.name()); item->setPixmap(0,app.pixmap()); // We have changed something. changed = true; // If we were dealing with a new folder or new application change // the file names. Also change the item location in itemList if(oldName == NEW_FOLDER){ QDir r; QString oldName = itemList[item]; oldName = oldName.mid(0,oldName.length()-11); QString newName = oldName.mid(0,oldName.length()-9); newName = newName + "/" + app.name(); r.rename(oldName, newName); itemList.remove(item); |