summaryrefslogtreecommitdiff
path: root/noncore/settings
Unidiff
Diffstat (limited to 'noncore/settings') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/language/language.cpp2
-rw-r--r--noncore/settings/networksettings/mainwindow/mainwindowimp.cpp2
-rw-r--r--noncore/settings/sysinfo/benchmarkinfo.cpp2
-rw-r--r--noncore/settings/tabmanager/tabmanager.cpp4
4 files changed, 5 insertions, 5 deletions
diff --git a/noncore/settings/language/language.cpp b/noncore/settings/language/language.cpp
index 81d6717..14750ac 100644
--- a/noncore/settings/language/language.cpp
+++ b/noncore/settings/language/language.cpp
@@ -12,97 +12,97 @@
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "settings.h" 21#include "settings.h"
22 22
23#include <qpe/global.h> 23#include <qpe/global.h>
24#include <qpe/fontmanager.h> 24#include <qpe/fontmanager.h>
25#include <qpe/config.h> 25#include <qpe/config.h>
26#include <qpe/applnk.h> 26#include <qpe/applnk.h>
27#include <qpe/qpedialog.h> 27#include <qpe/qpedialog.h>
28#include <qpe/qpeapplication.h> 28#include <qpe/qpeapplication.h>
29#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 29#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
30#include <qpe/qcopenvelope_qws.h> 30#include <qpe/qcopenvelope_qws.h>
31#endif 31#endif
32 32
33#include <qlabel.h> 33#include <qlabel.h>
34#include <qcheckbox.h> 34#include <qcheckbox.h>
35#include <qradiobutton.h> 35#include <qradiobutton.h>
36#include <qtabwidget.h> 36#include <qtabwidget.h>
37#include <qslider.h> 37#include <qslider.h>
38#include <qfile.h> 38#include <qfile.h>
39#include <qtextstream.h> 39#include <qtextstream.h>
40#include <qdatastream.h> 40#include <qdatastream.h>
41#include <qmessagebox.h> 41#include <qmessagebox.h>
42#include <qcombobox.h> 42#include <qcombobox.h>
43#include <qspinbox.h> 43#include <qspinbox.h>
44#include <qlistbox.h> 44#include <qlistbox.h>
45#include <qdir.h> 45#include <qdir.h>
46#if QT_VERSION >= 300 46#if QT_VERSION >= 300
47#include <qstylefactory.h> 47#include <qstylefactory.h>
48#endif 48#endif
49 49
50#include <stdlib.h> 50#include <stdlib.h>
51 51
52 52
53LanguageSettings::LanguageSettings( QWidget* parent, const char* name, WFlags fl ) 53LanguageSettings::LanguageSettings( QWidget* parent, const char* name, WFlags fl )
54 : LanguageSettingsBase( parent, name, TRUE, fl ) 54 : LanguageSettingsBase( parent, name, TRUE, fl )
55{ 55{
56 if ( FontManager::hasUnicodeFont() ) 56 if ( FontManager::hasUnicodeFont() )
57 languages->setFont(FontManager::unicodeFont(FontManager::Proportional)); 57 languages->setFont(FontManager::unicodeFont(FontManager::Proportional));
58 58
59 59
60 QString tfn = QPEApplication::qpeDir() + "/i18n/"; 60 QString tfn = QPEApplication::qpeDir() + "i18n/";
61 QDir langDir = tfn; 61 QDir langDir = tfn;
62 QStringList list = langDir.entryList("*", QDir::Dirs ); 62 QStringList list = langDir.entryList("*", QDir::Dirs );
63 63
64 QStringList::Iterator it; 64 QStringList::Iterator it;
65 65
66 for ( it = list.begin(); it != list.end(); ++it ) { 66 for ( it = list.begin(); it != list.end(); ++it ) {
67 QString name = (*it); 67 QString name = (*it);
68 QFileInfo desktopFile( tfn + "/" + name + "/.directory" ); 68 QFileInfo desktopFile( tfn + "/" + name + "/.directory" );
69 if ( desktopFile.exists() ) { 69 if ( desktopFile.exists() ) {
70 langAvail.append(name); 70 langAvail.append(name);
71 Config conf( desktopFile.filePath(), Config::File ); 71 Config conf( desktopFile.filePath(), Config::File );
72 QString langName = conf.readEntry( "Name" ); 72 QString langName = conf.readEntry( "Name" );
73 QString ownName = conf.readEntryDirect( "Name[" + name + "]" ); 73 QString ownName = conf.readEntryDirect( "Name[" + name + "]" );
74 if ( ownName.isEmpty() ) 74 if ( ownName.isEmpty() )
75 ownName = conf.readEntryDirect( "Name" ); 75 ownName = conf.readEntryDirect( "Name" );
76 if ( !ownName.isEmpty() && ownName != langName ) 76 if ( !ownName.isEmpty() && ownName != langName )
77 langName = langName + " [" + ownName + "]"; 77 langName = langName + " [" + ownName + "]";
78 languages->insertItem( langName ); 78 languages->insertItem( langName );
79 79
80 } 80 }
81 } 81 }
82 if ( langAvail. find ( "en" ) == -1 ) { 82 if ( langAvail. find ( "en" ) == -1 ) {
83 langAvail. prepend ( "" ); // no tr 83 langAvail. prepend ( "" ); // no tr
84 languages-> insertItem ( QString ( "English [%1] (%2)" /* no tr (!) */ ). arg ( tr ( "English" )). arg ( tr( "default" )), 0 ); 84 languages-> insertItem ( QString ( "English [%1] (%2)" /* no tr (!) */ ). arg ( tr ( "English" )). arg ( tr( "default" )), 0 );
85 } 85 }
86 86
87 dl = new QPEDialogListener(this); 87 dl = new QPEDialogListener(this);
88 reset(); 88 reset();
89} 89}
90 90
91LanguageSettings::~LanguageSettings() 91LanguageSettings::~LanguageSettings()
92{} 92{}
93 93
94void LanguageSettings::accept() 94void LanguageSettings::accept()
95{ 95{
96 Config c( "qpe" ); 96 Config c( "qpe" );
97 c.setGroup( "Startup" ); 97 c.setGroup( "Startup" );
98 if ( ( c.readNumEntry( "FirstUse", 42 ) == 0 ) && 98 if ( ( c.readNumEntry( "FirstUse", 42 ) == 0 ) &&
99 ( QMessageBox::warning( this, tr("Language"), tr("<qt>Attention, all windows will be closed by changing the language\n" 99 ( QMessageBox::warning( this, tr("Language"), tr("<qt>Attention, all windows will be closed by changing the language\n"
100 "without saving the Data.<br><br>Go on?</qt>"), 1, 2) ) 100 "without saving the Data.<br><br>Go on?</qt>"), 1, 2) )
101 == QMessageBox::Cancel ) 101 == QMessageBox::Cancel )
102 return; 102 return;
103 applyLanguage(); 103 applyLanguage();
104 QDialog::accept(); 104 QDialog::accept();
105} 105}
106 106
107void LanguageSettings::applyLanguage() 107void LanguageSettings::applyLanguage()
108{ 108{
diff --git a/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp
index fb7d7c9..5f23aea 100644
--- a/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp
@@ -243,97 +243,97 @@ void MainWindowImp::getAllInterfaces()
243 } 243 }
244 // now lets ask the plugins too ;) 244 // now lets ask the plugins too ;)
245 QMap<Module*, QLibrary*>::Iterator it; 245 QMap<Module*, QLibrary*>::Iterator it;
246 QList<Interface> ilist; 246 QList<Interface> ilist;
247 for( it = libraries.begin(); it != libraries.end(); ++it ) 247 for( it = libraries.begin(); it != libraries.end(); ++it )
248 { 248 {
249 if(it.key()) 249 if(it.key())
250 { 250 {
251 ilist = it.key()->getInterfaces(); 251 ilist = it.key()->getInterfaces();
252 for( i = ilist.first(); i != 0; i = ilist.next() ) 252 for( i = ilist.first(); i != 0; i = ilist.next() )
253 { 253 {
254 owarn << "Adding interface " << i->getInterfaceName().latin1() << " to interfaceNames\n" << oendl; 254 owarn << "Adding interface " << i->getInterfaceName().latin1() << " to interfaceNames\n" << oendl;
255 interfaceNames.insert(i->getInterfaceName(), i); 255 interfaceNames.insert(i->getInterfaceName(), i);
256 updateInterface(i); 256 updateInterface(i);
257 connect(i, SIGNAL(updateInterface(Interface*)), 257 connect(i, SIGNAL(updateInterface(Interface*)),
258 this, SLOT(updateInterface(Interface*))); 258 this, SLOT(updateInterface(Interface*)));
259 } 259 }
260 } 260 }
261 } 261 }
262} 262}
263 263
264/** 264/**
265 * Load all modules that are found in the path 265 * Load all modules that are found in the path
266 * @param path a directory that is scaned for any plugins that can be loaded 266 * @param path a directory that is scaned for any plugins that can be loaded
267 * and attempts to load them 267 * and attempts to load them
268 */ 268 */
269void MainWindowImp::loadModules(const QString &path) 269void MainWindowImp::loadModules(const QString &path)
270{ 270{
271#ifdef DEBUG 271#ifdef DEBUG
272 odebug << "MainWindowImp::loadModules: " << path.latin1() << "" << oendl; 272 odebug << "MainWindowImp::loadModules: " << path.latin1() << "" << oendl;
273#endif 273#endif
274 QDir d(path); 274 QDir d(path);
275 if(!d.exists()) 275 if(!d.exists())
276 return; 276 return;
277 277
278 QString lang = ::getenv("LANG"); 278 QString lang = ::getenv("LANG");
279 // Don't want sym links 279 // Don't want sym links
280 d.setFilter( QDir::Files | QDir::NoSymLinks ); 280 d.setFilter( QDir::Files | QDir::NoSymLinks );
281 const QFileInfoList *list = d.entryInfoList(); 281 const QFileInfoList *list = d.entryInfoList();
282 QFileInfoListIterator it( *list ); 282 QFileInfoListIterator it( *list );
283 QFileInfo *fi; 283 QFileInfo *fi;
284 while ( (fi=it.current()) ) 284 while ( (fi=it.current()) )
285 { 285 {
286 if(fi->fileName().contains(".so")) 286 if(fi->fileName().contains(".so"))
287 { 287 {
288 /* if loaded install translation */ 288 /* if loaded install translation */
289 if( loadPlugin(path + "/" + fi->fileName()) != 0l ){ 289 if( loadPlugin(path + "/" + fi->fileName()) != 0l ){
290 QTranslator *trans = new QTranslator(qApp); 290 QTranslator *trans = new QTranslator(qApp);
291 QString fn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+ fi->fileName().left( fi->fileName().find(".") )+".qm"; 291 QString fn = QPEApplication::qpeDir()+"i18n/"+lang+"/"+ fi->fileName().left( fi->fileName().find(".") )+".qm";
292 if( trans->load( fn ) ) 292 if( trans->load( fn ) )
293 qApp->installTranslator( trans ); 293 qApp->installTranslator( trans );
294 else 294 else
295 delete trans; 295 delete trans;
296 } 296 }
297 odebug << "loaded plugin: >" << QString(path + "/" + fi->fileName()).latin1() << "< " << oendl; 297 odebug << "loaded plugin: >" << QString(path + "/" + fi->fileName()).latin1() << "< " << oendl;
298 } 298 }
299 ++it; 299 ++it;
300 } 300 }
301} 301}
302 302
303/** 303/**
304 * Attempt to load a function and resolve a function. 304 * Attempt to load a function and resolve a function.
305 * @param pluginFileName - the name of the file in which to attempt to load 305 * @param pluginFileName - the name of the file in which to attempt to load
306 * @param resolveString - function pointer to resolve 306 * @param resolveString - function pointer to resolve
307 * @return pointer to the function with name resolveString or NULL 307 * @return pointer to the function with name resolveString or NULL
308 */ 308 */
309Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString) 309Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString)
310{ 310{
311#ifdef DEBUG 311#ifdef DEBUG
312 odebug << "MainWindowImp::loadPlugin: " << pluginFileName.latin1() << ": resolving " << resolveString.latin1() << "" << oendl; 312 odebug << "MainWindowImp::loadPlugin: " << pluginFileName.latin1() << ": resolving " << resolveString.latin1() << "" << oendl;
313#endif 313#endif
314 QLibrary *lib = new QLibrary(pluginFileName); 314 QLibrary *lib = new QLibrary(pluginFileName);
315 void *functionPointer = lib->resolve(resolveString); 315 void *functionPointer = lib->resolve(resolveString);
316 if( !functionPointer ) 316 if( !functionPointer )
317 { 317 {
318#ifdef DEBUG 318#ifdef DEBUG
319 odebug << "MainWindowImp::loadPlugin: Warning: " << pluginFileName.latin1() << " is not a plugin" << oendl; 319 odebug << "MainWindowImp::loadPlugin: Warning: " << pluginFileName.latin1() << " is not a plugin" << oendl;
320#endif 320#endif
321 delete lib; 321 delete lib;
322 return 0; 322 return 0;
323 } 323 }
324 // Try to get an object. 324 // Try to get an object.
325 Module *object = ((Module* (*)()) functionPointer)(); 325 Module *object = ((Module* (*)()) functionPointer)();
326 if(object == 0) 326 if(object == 0)
327 { 327 {
328#ifdef DEBUG 328#ifdef DEBUG
329 odebug << "MainWindowImp: Couldn't create object, but did load library!" << oendl; 329 odebug << "MainWindowImp: Couldn't create object, but did load library!" << oendl;
330#endif 330#endif
331 delete lib; 331 delete lib;
332 return 0; 332 return 0;
333 } 333 }
334 334
335 m_handledIfaces += object->handledInterfaceNames(); 335 m_handledIfaces += object->handledInterfaceNames();
336 // Store for deletion later 336 // Store for deletion later
337 libraries.insert(object, lib); 337 libraries.insert(object, lib);
338 return object; 338 return object;
339} 339}
diff --git a/noncore/settings/sysinfo/benchmarkinfo.cpp b/noncore/settings/sysinfo/benchmarkinfo.cpp
index 793fcb1..060185a 100644
--- a/noncore/settings/sysinfo/benchmarkinfo.cpp
+++ b/noncore/settings/sysinfo/benchmarkinfo.cpp
@@ -97,97 +97,97 @@ BenchmarkInfo::BenchmarkInfo( QWidget *parent, const char *name, int wFlags )
97 vb->setMargin( 4 ); 97 vb->setMargin( 4 );
98 98
99 tests = new OListView( this ); 99 tests = new OListView( this );
100 QWhatsThis::add( tests->viewport(), tr( "This area shows the available tests, the results for which the tests " 100 QWhatsThis::add( tests->viewport(), tr( "This area shows the available tests, the results for which the tests "
101 "have been performed, and comparison values for one selected device. " 101 "have been performed, and comparison values for one selected device. "
102 "Use the checkboxes to define which tests you want to perform." ) ); 102 "Use the checkboxes to define which tests you want to perform." ) );
103 tests->setMargin( 0 ); 103 tests->setMargin( 0 );
104 tests->addColumn( tr( "Tests" ) ); 104 tests->addColumn( tr( "Tests" ) );
105 tests->addColumn( tr( "Results" ) ); 105 tests->addColumn( tr( "Results" ) );
106 tests->addColumn( tr( "Comparison" ) ); 106 tests->addColumn( tr( "Comparison" ) );
107 tests->setShowSortIndicator( true ); 107 tests->setShowSortIndicator( true );
108 108
109 test_alu = new OCheckListItem( tests, tr( "1. Integer Arithmetic " ), OCheckListItem::CheckBox ); 109 test_alu = new OCheckListItem( tests, tr( "1. Integer Arithmetic " ), OCheckListItem::CheckBox );
110 test_fpu = new OCheckListItem( tests, tr( "2. Floating Point Unit " ), OCheckListItem::CheckBox ); 110 test_fpu = new OCheckListItem( tests, tr( "2. Floating Point Unit " ), OCheckListItem::CheckBox );
111 test_txt = new OCheckListItem( tests, tr( "3. Text Rendering " ), OCheckListItem::CheckBox ); 111 test_txt = new OCheckListItem( tests, tr( "3. Text Rendering " ), OCheckListItem::CheckBox );
112 test_gfx = new OCheckListItem( tests, tr( "4. Gfx Rendering " ), OCheckListItem::CheckBox ); 112 test_gfx = new OCheckListItem( tests, tr( "4. Gfx Rendering " ), OCheckListItem::CheckBox );
113 test_ram = new OCheckListItem( tests, tr( "5. RAM Performance " ), OCheckListItem::CheckBox ); 113 test_ram = new OCheckListItem( tests, tr( "5. RAM Performance " ), OCheckListItem::CheckBox );
114#ifndef QT_QWS_RAMSES 114#ifndef QT_QWS_RAMSES
115 test_sd = new OCheckListItem( tests, tr( "6. SD Card Performance " ), OCheckListItem::CheckBox ); 115 test_sd = new OCheckListItem( tests, tr( "6. SD Card Performance " ), OCheckListItem::CheckBox );
116 test_cf = new OCheckListItem( tests, tr( "7. CF Card Performance " ), OCheckListItem::CheckBox ); 116 test_cf = new OCheckListItem( tests, tr( "7. CF Card Performance " ), OCheckListItem::CheckBox );
117#endif 117#endif
118 test_alu->setText( 1, "n/a" ); 118 test_alu->setText( 1, "n/a" );
119 test_fpu->setText( 1, "n/a" ); 119 test_fpu->setText( 1, "n/a" );
120 test_txt->setText( 1, "n/a" ); 120 test_txt->setText( 1, "n/a" );
121 test_gfx->setText( 1, "n/a" ); 121 test_gfx->setText( 1, "n/a" );
122 test_ram->setText( 1, "n/a" ); 122 test_ram->setText( 1, "n/a" );
123#ifndef QT_QWS_RAMSES 123#ifndef QT_QWS_RAMSES
124 test_sd->setText( 1, "n/a" ); 124 test_sd->setText( 1, "n/a" );
125 test_cf->setText( 1, "n/a" ); 125 test_cf->setText( 1, "n/a" );
126#endif 126#endif
127 test_alu->setText( 2, "n/a" ); 127 test_alu->setText( 2, "n/a" );
128 test_fpu->setText( 2, "n/a" ); 128 test_fpu->setText( 2, "n/a" );
129 test_txt->setText( 2, "n/a" ); 129 test_txt->setText( 2, "n/a" );
130 test_gfx->setText( 2, "n/a" ); 130 test_gfx->setText( 2, "n/a" );
131 test_ram->setText( 2, "n/a" ); 131 test_ram->setText( 2, "n/a" );
132#ifndef QT_QWS_RAMSES 132#ifndef QT_QWS_RAMSES
133 test_sd->setText( 2, "n/a" ); 133 test_sd->setText( 2, "n/a" );
134 test_cf->setText( 2, "n/a" ); 134 test_cf->setText( 2, "n/a" );
135#endif 135#endif
136 136
137 startButton = new QPushButton( tr( "&Start Tests!" ), this ); 137 startButton = new QPushButton( tr( "&Start Tests!" ), this );
138 QWhatsThis::add( startButton, tr( "Click here to perform the selected tests." ) ); 138 QWhatsThis::add( startButton, tr( "Click here to perform the selected tests." ) );
139 connect( startButton, SIGNAL( clicked() ), this, SLOT( run() ) ); 139 connect( startButton, SIGNAL( clicked() ), this, SLOT( run() ) );
140 vb->addWidget( tests, 2 ); 140 vb->addWidget( tests, 2 );
141 141
142 QHBoxLayout* hb = new QHBoxLayout( vb ); 142 QHBoxLayout* hb = new QHBoxLayout( vb );
143 hb->addWidget( startButton, 2 ); 143 hb->addWidget( startButton, 2 );
144 144
145 QFile f( QPEApplication::qpeDir() + "/share/sysinfo/results" ); 145 QFile f( QPEApplication::qpeDir() + "share/sysinfo/results" );
146 if ( f.open( IO_ReadOnly ) ) 146 if ( f.open( IO_ReadOnly ) )
147 { 147 {
148 machineCombo = new QComboBox( this ); 148 machineCombo = new QComboBox( this );
149 QWhatsThis::add( machineCombo, tr( "Choose a model to compare your results with." ) ); 149 QWhatsThis::add( machineCombo, tr( "Choose a model to compare your results with." ) );
150 150
151 QTextStream ts( &f ); 151 QTextStream ts( &f );
152 while( !ts.eof() ) 152 while( !ts.eof() )
153 { 153 {
154 QString machline = ts.readLine(); 154 QString machline = ts.readLine();
155 odebug << "sysinfo: parsing benchmark results for '" << machline << "'" << oendl; 155 odebug << "sysinfo: parsing benchmark results for '" << machline << "'" << oendl;
156 QString resline = ts.readLine(); 156 QString resline = ts.readLine();
157 machines.insert( machline, new QStringList( QStringList::split( ",", resline ) ) ); 157 machines.insert( machline, new QStringList( QStringList::split( ",", resline ) ) );
158 machineCombo->insertItem( machline ); 158 machineCombo->insertItem( machline );
159 } 159 }
160 160
161 hb->addWidget( new QLabel( tr( "Compare:" ), this ) ); 161 hb->addWidget( new QLabel( tr( "Compare:" ), this ) );
162 hb->addWidget( machineCombo, 2 ); 162 hb->addWidget( machineCombo, 2 );
163 connect( machineCombo, SIGNAL( activated(int) ), this, SLOT( machineActivated(int) ) ); 163 connect( machineCombo, SIGNAL( activated(int) ), this, SLOT( machineActivated(int) ) );
164 } 164 }
165} 165}
166 166
167 167
168BenchmarkInfo::~BenchmarkInfo() 168BenchmarkInfo::~BenchmarkInfo()
169{} 169{}
170 170
171 171
172void BenchmarkInfo::machineActivated( int index ) 172void BenchmarkInfo::machineActivated( int index )
173{ 173{
174 QStringList* results = machines[ machineCombo->text( index ) ]; 174 QStringList* results = machines[ machineCombo->text( index ) ];
175 if ( !results ) 175 if ( !results )
176 { 176 {
177 odebug << "sysinfo: no results available." << oendl; 177 odebug << "sysinfo: no results available." << oendl;
178 return; 178 return;
179 } 179 }
180 QStringList::Iterator it = results->begin(); 180 QStringList::Iterator it = results->begin();
181 test_alu->setText( 2, *(it++) ); 181 test_alu->setText( 2, *(it++) );
182 test_fpu->setText( 2, *(it++) ); 182 test_fpu->setText( 2, *(it++) );
183 test_txt->setText( 2, *(it++) ); 183 test_txt->setText( 2, *(it++) );
184 test_gfx->setText( 2, *(it++) ); 184 test_gfx->setText( 2, *(it++) );
185 test_ram->setText( 2, *(it++) ); 185 test_ram->setText( 2, *(it++) );
186#ifndef QT_QWS_RAMSES 186#ifndef QT_QWS_RAMSES
187 test_sd->setText( 2, *(it++) ); 187 test_sd->setText( 2, *(it++) );
188 test_cf->setText( 2, *(it++) ); 188 test_cf->setText( 2, *(it++) );
189#endif 189#endif
190} 190}
191 191
192 192
193void BenchmarkInfo::run() 193void BenchmarkInfo::run()
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