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 @@ -1,21 +1,25 @@ #include "tabmanager.h" #include "app.h" +#include "wait.h" #include "tabapplnk.h" #include <qpe/applnk.h> -#include <qpe/qpeapplication.h> #include <qdir.h> #include <qfile.h> #include <qtextstream.h> #include <qlistview.h> #include <qheader.h> +#include <qcombobox.h> #include <qlineedit.h> #include <qlabel.h> #include <qmessagebox.h> #include <stdlib.h> #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" #define NEW_FOLDER "EmptyTab" #define NEW_APPLICATION "NewApp" @@ -26,15 +30,13 @@ * Constructor. Sets up signals. Performs initial scan of applications * and tabs */ -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); // 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 *))); } /** @@ -43,10 +45,11 @@ TabManager::TabManager( QWidget* parent, const char* name):TabManagerBase(parent */ 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 e << link; } @@ -176,14 +179,12 @@ void TabManager::removeItem(){ if(!item) return; 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; } // 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) return; @@ -202,14 +203,12 @@ void TabManager::removeItem(){ removeSuccessfull = false; else removeSuccessfull = true; - } // If removing failed. if(!removeSuccessfull){ 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; } @@ -249,38 +248,91 @@ void TabManager::editItem( QListViewItem * item){ return; } - 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")); } // Only do somthing if they hit OK - if(application.exec() == 0) + 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->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; // Change the applnk file 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; } @@ -344,8 +396,7 @@ void TabManager::moveApplication(QListViewItem *item, QListViewItem *newGroup){ // Move file QDir r; 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; } //qDebug((QString("moveApplication: ") + itemList[item]).latin1()); |