Diffstat (limited to 'noncore/settings/tabmanager/tabmanager.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/tabmanager/tabmanager.cpp | 127 |
1 files changed, 89 insertions, 38 deletions
diff --git a/noncore/settings/tabmanager/tabmanager.cpp b/noncore/settings/tabmanager/tabmanager.cpp index 13aae81..5f0899c 100644 --- a/noncore/settings/tabmanager/tabmanager.cpp +++ b/noncore/settings/tabmanager/tabmanager.cpp @@ -2,2 +2,3 @@ #include "app.h" +#include "wait.h" #include "tabapplnk.h" @@ -5,3 +6,2 @@ #include <qpe/applnk.h> -#include <qpe/qpeapplication.h> #include <qdir.h> @@ -11,2 +11,3 @@ #include <qheader.h> +#include <qcombobox.h> #include <qlineedit.h> @@ -16,4 +17,7 @@ #include <qpe/qcopenvelope_qws.h> +#include <qpe/qpeapplication.h> +#include <qpe/resource.h> + -#define HOME_APP_DIR QPEApplication::qpeDir()+"/apps" // <-- made this a little more flexible +#define HOME_APP_DIR QPEApplication::qpeDir()+"/apps" #define HOME_APP_INSTALL_DIR "/usr/lib/ipkg/info" @@ -28,3 +32,3 @@ */ -TabManager::TabManager( QWidget* parent, const char* name):TabManagerBase(parent, name), changed(false){ +TabManager::TabManager( QWidget* parent, const char* name):TabManagerBase(parent, name), changed(false), application(NULL){ rescanFolder(HOME_APP_DIR); @@ -32,7 +36,5 @@ TabManager::TabManager( QWidget* parent, const char* name):TabManagerBase(parent // Connect the signals and slots - connect(tabList, SIGNAL(doubleClicked(QListViewItem *)), - this, SLOT(editItem(QListViewItem*))); + connect(tabList, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(editItem(QListViewItem*))); (tabList->header())->hide(); - connect(tabList, SIGNAL(moveItem(QListViewItem *, QListViewItem *)), - this, SLOT(moveApplication(QListViewItem *, QListViewItem *))); + connect(tabList, SIGNAL(moveItem(QListViewItem *, QListViewItem *)), this, SLOT(moveApplication(QListViewItem *, QListViewItem *))); } @@ -45,6 +47,7 @@ TabManager::~TabManager(){ if(changed){ - //QMessageBox::critical(this, tr("Message"), tr("Please restart Qtopia to see all new changes."),tr("Ok") ); - //filename = fn; + // Prompt. + //int answer = QMessageBox::warning(this, "Message", "Should your desktop be","Yes", "Cancel", 0, 1 ); + //if (answer) + // return; QCopEnvelope e("QPE/System", "linkChanged(QString)"); - //e << description << filename << mimetype; QString link; //we'll just send an empty string @@ -178,4 +181,3 @@ void TabManager::removeItem(){ if(item->childCount() > 0){ - QMessageBox::critical(this, tr("Message"), tr("Can't remove with applications\nstill in the group."), - tr("Ok") ); + QMessageBox::critical(this, tr("Message"), tr("Can't remove with applications\nstill in the group."), tr("Ok") ); return; @@ -184,4 +186,3 @@ void TabManager::removeItem(){ // Prompt. - int answer = QMessageBox::warning(this, tr("Message"), tr("Are you sure you want to delete?"), - tr("Yes"), tr("Cancel"), 0, 1 ); + int answer = QMessageBox::warning(this, tr("Message"), tr("Are you sure you want to delete?"), tr("Yes"), tr("Cancel"), 0, 1 ); if (answer) @@ -204,3 +205,2 @@ void TabManager::removeItem(){ removeSuccessfull = true; - } @@ -210,4 +210,3 @@ void TabManager::removeItem(){ qDebug((QString("removeItem: ") + location).latin1()); - QMessageBox::critical(this, tr("Message"), tr("Can't remove."), - tr("Ok") ); + QMessageBox::critical(this, tr("Message"), tr("Can't remove."), tr("Ok") ); return; @@ -251,12 +250,65 @@ void TabManager::editItem( QListViewItem * item){ - AppEdit application(this, tr("Application edit"), true); - application.nameLineEdit->setText(app.name()); - application.iconLineEdit->setText(app.pixmapString()); - application.execLineEdit->setText(app.exec()); - application.commentLineEdit->setText(app.comment()); + // 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{ + 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")); + 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")); } @@ -264,3 +316,4 @@ void TabManager::editItem( QListViewItem * item){ // Only do somthing if they hit OK - if(application.exec() == 0) + application->showMaximized(); + if(application->exec() == 0) return; @@ -268,6 +321,6 @@ void TabManager::editItem( QListViewItem * item){ // If nothing has changed exit (hmmm why did they hit ok?) - if(app.name() == application.nameLineEdit->text() && - app.pixmapString() == application.iconLineEdit->text() && - app.comment() == application.commentLineEdit->text() && - app.exec() == application.execLineEdit->text()) + if(app.name() == application->nameLineEdit->text() && + app.pixmapString() == application->iconLineEdit->currentText() && + app.comment() == application->commentLineEdit->text() && + app.exec() == application->execLineEdit->text()) return; @@ -276,9 +329,8 @@ void TabManager::editItem( QListViewItem * item){ QString oldName = app.name(); - app.setName(application.nameLineEdit->text()); - app.setIcon(application.iconLineEdit->text()); - app.setComment(application.commentLineEdit->text()); - app.setExec(application.execLineEdit->text()); + 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"), tr("Can't save."), - tr("Ok") ); + QMessageBox::critical(this, tr("Message"), "Can't save.", tr("Ok") ); return; @@ -346,4 +398,3 @@ void TabManager::moveApplication(QListViewItem *item, QListViewItem *newGroup){ if(!r.rename(itemList[item], newFolder)){ - QMessageBox::critical(this, tr("Message"), tr("Can't move application."), - tr("Ok") ); + QMessageBox::critical(this, tr("Message"), "Can't move application.", tr("Ok") ); return; |