summaryrefslogtreecommitdiff
path: root/noncore/settings/tabmanager/tabmanager.cpp
Unidiff
Diffstat (limited to 'noncore/settings/tabmanager/tabmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/tabmanager/tabmanager.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/settings/tabmanager/tabmanager.cpp b/noncore/settings/tabmanager/tabmanager.cpp
index 3eae424..85e5814 100644
--- a/noncore/settings/tabmanager/tabmanager.cpp
+++ b/noncore/settings/tabmanager/tabmanager.cpp
@@ -1,72 +1,72 @@
1#include "tabmanager.h" 1#include "tabmanager.h"
2#include "app.h" 2#include "app.h"
3#include "wait.h" 3#include "wait.h"
4#include "tabapplnk.h" 4#include "tabapplnk.h"
5 5
6#include <opie2/odebug.h> 6#include <opie2/odebug.h>
7 7
8#include <qpe/applnk.h> 8#include <qpe/applnk.h>
9#include <qdir.h> 9#include <qdir.h>
10#include <qfile.h> 10#include <qfile.h>
11#include <qtextstream.h> 11#include <qtextstream.h>
12#include <qlistview.h> 12#include <qlistview.h>
13#include <qheader.h> 13#include <qheader.h>
14#include <qcombobox.h> 14#include <qcombobox.h>
15#include <qlineedit.h> 15#include <qlineedit.h>
16#include <qlabel.h> 16#include <qlabel.h>
17#include <qmessagebox.h> 17#include <qmessagebox.h>
18#include <stdlib.h> 18#include <stdlib.h>
19#include <qpe/qcopenvelope_qws.h> 19#include <qpe/qcopenvelope_qws.h>
20#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21#include <qpe/resource.h> 21#include <qpe/resource.h>
22 22
23 23
24#define HOME_APP_DIR QPEApplication::qpeDir()+"/apps" 24#define HOME_APP_DIR QPEApplication::qpeDir()+"apps"
25#define HOME_APP_INSTALL_DIR "/usr/lib/ipkg/info" 25#define HOME_APP_INSTALL_DIR "/usr/lib/ipkg/info"
26#define NEW_FOLDER "EmptyTab" 26#define NEW_FOLDER "EmptyTab"
27#define NEW_APPLICATION "NewApp" 27#define NEW_APPLICATION "NewApp"
28#define APPLICATION_EXTENSION ".desktop" 28#define APPLICATION_EXTENSION ".desktop"
29#define APPLICATION_EXTENSION_LENGTH 8 29#define APPLICATION_EXTENSION_LENGTH 8
30 30
31/** 31/**
32 * Constructor. Sets up signals. Performs initial scan of applications 32 * Constructor. Sets up signals. Performs initial scan of applications
33 * and tabs 33 * and tabs
34 */ 34 */
35TabManager::TabManager( QWidget* parent, const char* name):TabManagerBase(parent, name), changed(false), application(NULL){ 35TabManager::TabManager( QWidget* parent, const char* name):TabManagerBase(parent, name), changed(false), application(NULL){
36 rescanFolder(HOME_APP_DIR); 36 rescanFolder(HOME_APP_DIR);
37 37
38 // Connect the signals and slots 38 // Connect the signals and slots
39 connect(tabList, SIGNAL(doubleClicked(QListViewItem*)), this, SLOT(editItem(QListViewItem*))); 39 connect(tabList, SIGNAL(doubleClicked(QListViewItem*)), this, SLOT(editItem(QListViewItem*)));
40 (tabList->header())->hide(); 40 (tabList->header())->hide();
41 connect(tabList, SIGNAL(moveItem(QListViewItem*,QListViewItem*)), this, SLOT(moveApplication(QListViewItem*,QListViewItem*))); 41 connect(tabList, SIGNAL(moveItem(QListViewItem*,QListViewItem*)), this, SLOT(moveApplication(QListViewItem*,QListViewItem*)));
42} 42}
43 43
44/** 44/**
45 * If anything in the tab's have been changed then update the system or alert 45 * If anything in the tab's have been changed then update the system or alert
46 * the user. 46 * the user.
47 */ 47 */
48TabManager::~TabManager(){ 48TabManager::~TabManager(){
49 if(changed){ 49 if(changed){
50 // Prompt. 50 // Prompt.
51 //int answer = QMessageBox::warning(this, "Message", "Should your desktop be","Yes", "Cancel", 0, 1 ); 51 //int answer = QMessageBox::warning(this, "Message", "Should your desktop be","Yes", "Cancel", 0, 1 );
52 //if (answer) 52 //if (answer)
53 // return; 53 // return;
54 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 54 QCopEnvelope e("QPE/System", "linkChanged(QString)");
55 QString link; //we'll just send an empty string 55 QString link; //we'll just send an empty string
56 e << link; 56 e << link;
57 } 57 }
58} 58}
59 59
60/** 60/**
61 * Scans root directory for any tabs or applications. Will recursivly go down, 61 * Scans root directory for any tabs or applications. Will recursivly go down,
62 * but will not follow symlinks. 62 * but will not follow symlinks.
63 * @param directory - the directory to look in. 63 * @param directory - the directory to look in.
64 * @param parent - the parent to place any new tabs or apps into. If parent is 64 * @param parent - the parent to place any new tabs or apps into. If parent is
65 * NULL then the item is a tab and should be placed as a child of the window. 65 * NULL then the item is a tab and should be placed as a child of the window.
66 */ 66 */
67void TabManager::rescanFolder(QString directory, QListViewItem* parent){ 67void TabManager::rescanFolder(QString directory, QListViewItem* parent){
68 //odebug << QString("rescanFolder: ") + directory.latin1() << oendl; 68 //odebug << QString("rescanFolder: ") + directory.latin1() << oendl;
69 69
70 QDir d; 70 QDir d;
71 d.setPath(directory); 71 d.setPath(directory);
72 // Show hidden files for .directories 72 // Show hidden files for .directories
@@ -213,97 +213,97 @@ void TabManager::removeItem(){
213 QMessageBox::critical(this, tr("Message"), tr("Can't remove."), tr("Ok") ); 213 QMessageBox::critical(this, tr("Message"), tr("Can't remove."), tr("Ok") );
214 return; 214 return;
215 } 215 }
216 216
217 // Remove from the installer so it wont fail. 217 // Remove from the installer so it wont fail.
218 // Don't need to do this sense the current install uses rm -f so no error 218 // Don't need to do this sense the current install uses rm -f so no error
219 219
220 // Remove from the gui list. 220 // Remove from the gui list.
221 itemList.remove(item); 221 itemList.remove(item);
222 if(item->parent()) 222 if(item->parent())
223 item->parent()->takeItem(item); 223 item->parent()->takeItem(item);
224 delete item; 224 delete item;
225 225
226 // We have changed something. 226 // We have changed something.
227 changed = true; 227 changed = true;
228} 228}
229 229
230/** 230/**
231 * Helper function. Edits the current item. 231 * Helper function. Edits the current item.
232 * calls editItem with the currently selected item. 232 * calls editItem with the currently selected item.
233 */ 233 */
234void TabManager::editCurrentItem(){ 234void TabManager::editCurrentItem(){
235 editItem(tabList->currentItem()); 235 editItem(tabList->currentItem());
236} 236}
237 237
238/** 238/**
239 * Edit the item that is passed in. 239 * Edit the item that is passed in.
240 * Show application dialog and if anything changed 240 * Show application dialog and if anything changed
241 * @param item the item to edit. 241 * @param item the item to edit.
242 */ 242 */
243void TabManager::editItem( QListViewItem * item){ 243void TabManager::editItem( QListViewItem * item){
244 if(!item) 244 if(!item)
245 return; 245 return;
246 246
247 TabAppLnk app(itemList[item]); 247 TabAppLnk app(itemList[item]);
248 if(!app.isValid()){ 248 if(!app.isValid()){
249 odebug << QString("editItem: Not a valid applnk file: ") + itemList[item].latin1() << oendl; 249 odebug << QString("editItem: Not a valid applnk file: ") + itemList[item].latin1() << oendl;
250 return; 250 return;
251 } 251 }
252 252
253 // Fill with all of the icons 253 // Fill with all of the icons
254 if(!application){ 254 if(!application){
255 Wait waitDialog(this, "Wait dialog"); 255 Wait waitDialog(this, "Wait dialog");
256 waitDialog.waitLabel->setText(tr("Gathering icons...")); 256 waitDialog.waitLabel->setText(tr("Gathering icons..."));
257 waitDialog.show(); 257 waitDialog.show();
258 qApp->processEvents(); 258 qApp->processEvents();
259 application = new AppEdit(this, "Application edit", true); 259 application = new AppEdit(this, "Application edit", true);
260 260
261 QDir d(QPEApplication::qpeDir() + "/pics/"); 261 QDir d(QPEApplication::qpeDir() + "pics/");
262 d.setFilter( QDir::Files); 262 d.setFilter( QDir::Files);
263 263
264 const QFileInfoList *list = d.entryInfoList(); 264 const QFileInfoList *list = d.entryInfoList();
265 QFileInfoListIterator it( *list ); // create list iterator 265 QFileInfoListIterator it( *list ); // create list iterator
266 QFileInfo *fi; // pointer for traversing 266 QFileInfo *fi; // pointer for traversing
267 267
268 while ( (fi=it.current()) ) { // for each file... 268 while ( (fi=it.current()) ) { // for each file...
269 QString fileName = fi->fileName(); 269 QString fileName = fi->fileName();
270 if(fileName.right(4) == ".png"){ 270 if(fileName.right(4) == ".png"){
271 fileName = fileName.mid(0,fileName.length()-4); 271 fileName = fileName.mid(0,fileName.length()-4);
272 QPixmap imageOfFile(Resource::loadPixmap(fileName)); 272 QPixmap imageOfFile(Resource::loadPixmap(fileName));
273 QImage foo = imageOfFile.convertToImage(); 273 QImage foo = imageOfFile.convertToImage();
274 foo = foo.smoothScale(16,16); 274 foo = foo.smoothScale(16,16);
275 imageOfFile.convertFromImage(foo); 275 imageOfFile.convertFromImage(foo);
276 application->iconLineEdit->insertItem(imageOfFile,fileName); 276 application->iconLineEdit->insertItem(imageOfFile,fileName);
277 } 277 }
278 //odebug << fi->fileName().latin1() << oendl; 278 //odebug << fi->fileName().latin1() << oendl;
279 ++it; 279 ++it;
280 } 280 }
281 waitDialog.hide(); 281 waitDialog.hide();
282 } 282 }
283 int pixmap = -1; 283 int pixmap = -1;
284 QString pixmapText = app.pixmapString(); 284 QString pixmapText = app.pixmapString();
285 QComboBox *f = application->iconLineEdit; 285 QComboBox *f = application->iconLineEdit;
286 for(int i = 0; i < application->iconLineEdit->count(); i++){ 286 for(int i = 0; i < application->iconLineEdit->count(); i++){
287 if(f->text(i) == pixmapText){ 287 if(f->text(i) == pixmapText){
288 pixmap = i; 288 pixmap = i;
289 break; 289 break;
290 } 290 }
291 } 291 }
292 if(pixmap != -1) 292 if(pixmap != -1)
293 application->iconLineEdit->setCurrentItem(pixmap); 293 application->iconLineEdit->setCurrentItem(pixmap);
294 else if(pixmapText.isEmpty()){ 294 else if(pixmapText.isEmpty()){
295 application->iconLineEdit->setCurrentItem(0); 295 application->iconLineEdit->setCurrentItem(0);
296 } 296 }
297 else{ 297 else{
298 QPixmap imageOfFile(Resource::loadPixmap(pixmapText)); 298 QPixmap imageOfFile(Resource::loadPixmap(pixmapText));
299 QImage foo = imageOfFile.convertToImage(); 299 QImage foo = imageOfFile.convertToImage();
300 foo = foo.smoothScale(16,16); 300 foo = foo.smoothScale(16,16);
301 imageOfFile.convertFromImage(foo); 301 imageOfFile.convertFromImage(foo);
302 application->iconLineEdit->insertItem(imageOfFile,pixmapText,0); 302 application->iconLineEdit->insertItem(imageOfFile,pixmapText,0);
303 application->iconLineEdit->setCurrentItem(0); 303 application->iconLineEdit->setCurrentItem(0);
304 } 304 }
305 305
306 application->nameLineEdit->setText(app.name()); 306 application->nameLineEdit->setText(app.name());
307 application->execLineEdit->setText(app.exec()); 307 application->execLineEdit->setText(app.exec());
308 application->commentLineEdit->setText(app.comment()); 308 application->commentLineEdit->setText(app.comment());
309 309