summaryrefslogtreecommitdiff
path: root/noncore/settings
Side-by-side diff
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
@@ -1,156 +1,156 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "settings.h"
#include <qpe/global.h>
#include <qpe/fontmanager.h>
#include <qpe/config.h>
#include <qpe/applnk.h>
#include <qpe/qpedialog.h>
#include <qpe/qpeapplication.h>
#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
#include <qpe/qcopenvelope_qws.h>
#endif
#include <qlabel.h>
#include <qcheckbox.h>
#include <qradiobutton.h>
#include <qtabwidget.h>
#include <qslider.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qdatastream.h>
#include <qmessagebox.h>
#include <qcombobox.h>
#include <qspinbox.h>
#include <qlistbox.h>
#include <qdir.h>
#if QT_VERSION >= 300
#include <qstylefactory.h>
#endif
#include <stdlib.h>
LanguageSettings::LanguageSettings( QWidget* parent, const char* name, WFlags fl )
: LanguageSettingsBase( parent, name, TRUE, fl )
{
if ( FontManager::hasUnicodeFont() )
languages->setFont(FontManager::unicodeFont(FontManager::Proportional));
- QString tfn = QPEApplication::qpeDir() + "/i18n/";
+ QString tfn = QPEApplication::qpeDir() + "i18n/";
QDir langDir = tfn;
QStringList list = langDir.entryList("*", QDir::Dirs );
QStringList::Iterator it;
for ( it = list.begin(); it != list.end(); ++it ) {
QString name = (*it);
QFileInfo desktopFile( tfn + "/" + name + "/.directory" );
if ( desktopFile.exists() ) {
langAvail.append(name);
Config conf( desktopFile.filePath(), Config::File );
QString langName = conf.readEntry( "Name" );
QString ownName = conf.readEntryDirect( "Name[" + name + "]" );
if ( ownName.isEmpty() )
ownName = conf.readEntryDirect( "Name" );
if ( !ownName.isEmpty() && ownName != langName )
langName = langName + " [" + ownName + "]";
languages->insertItem( langName );
}
}
if ( langAvail. find ( "en" ) == -1 ) {
langAvail. prepend ( "" ); // no tr
languages-> insertItem ( QString ( "English [%1] (%2)" /* no tr (!) */ ). arg ( tr ( "English" )). arg ( tr( "default" )), 0 );
}
dl = new QPEDialogListener(this);
reset();
}
LanguageSettings::~LanguageSettings()
{}
void LanguageSettings::accept()
{
Config c( "qpe" );
c.setGroup( "Startup" );
if ( ( c.readNumEntry( "FirstUse", 42 ) == 0 ) &&
( QMessageBox::warning( this, tr("Language"), tr("<qt>Attention, all windows will be closed by changing the language\n"
"without saving the Data.<br><br>Go on?</qt>"), 1, 2) )
== QMessageBox::Cancel )
return;
applyLanguage();
QDialog::accept();
}
void LanguageSettings::applyLanguage()
{
setLanguage ( langAvail. at ( languages-> currentItem ( )));
}
void LanguageSettings::reject()
{
reset();
QDialog::reject();
}
void LanguageSettings::reset()
{
QString l = getenv("LANG");
Config config("locale");
config.setGroup("Language");
l = config.readEntry( "Language", l );
actualLanguage = l;
if (l.isEmpty())
l = "en";
int n = langAvail.find( l );
languages->setCurrentItem( n );
}
QString LanguageSettings::actualLanguage;
void LanguageSettings::setLanguage(const QString& lang)
{
if ( lang != actualLanguage ) {
Config config("locale");
config.setGroup( "Language" );
if ( lang. isEmpty ( ))
config. removeEntry ( "Language" );
else
config.writeEntry( "Language", lang );
config.write();
#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
QCopEnvelope e("QPE/System", "language(QString)");
e << lang;
#endif
}
}
void LanguageSettings::done(int r)
{
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
@@ -195,193 +195,193 @@ void MainWindowImp::getAllInterfaces()
{
if((loc = line.find(":")) != -1)
{
ifaces += line.left(loc);
}
}
}
for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it)
{
int flags = 0;
if ( m_handledIfaces.contains( (*it) ) )
{
odebug << " " << (*it).latin1() << " is handled by a module" << oendl;
continue;
}
// int family;
i = NULL;
strcpy(ifr.ifr_name, (*it).latin1());
struct ifreq ifcopy;
ifcopy = ifr;
result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy);
flags = ifcopy.ifr_flags;
i = new Interface(this, ifr.ifr_name, false);
i->setAttached(true);
if ((flags & IFF_UP) == IFF_UP)
i->setStatus(true);
else
i->setStatus(false);
if ((flags & IFF_BROADCAST) == IFF_BROADCAST)
i->setHardwareName("Ethernet");
else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT)
i->setHardwareName("Point to Point");
else if ((flags & IFF_MULTICAST) == IFF_MULTICAST)
i->setHardwareName("Multicast");
else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK)
i->setHardwareName("Loopback");
else
i->setHardwareName("Unknown");
owarn << "Adding interface " << ifr.ifr_name << " to interfaceNames\n" << oendl;
interfaceNames.insert(i->getInterfaceName(), i);
updateInterface(i);
connect(i, SIGNAL(updateInterface(Interface*)),
this, SLOT(updateInterface(Interface*)));
}
// now lets ask the plugins too ;)
QMap<Module*, QLibrary*>::Iterator it;
QList<Interface> ilist;
for( it = libraries.begin(); it != libraries.end(); ++it )
{
if(it.key())
{
ilist = it.key()->getInterfaces();
for( i = ilist.first(); i != 0; i = ilist.next() )
{
owarn << "Adding interface " << i->getInterfaceName().latin1() << " to interfaceNames\n" << oendl;
interfaceNames.insert(i->getInterfaceName(), i);
updateInterface(i);
connect(i, SIGNAL(updateInterface(Interface*)),
this, SLOT(updateInterface(Interface*)));
}
}
}
}
/**
* Load all modules that are found in the path
* @param path a directory that is scaned for any plugins that can be loaded
* and attempts to load them
*/
void MainWindowImp::loadModules(const QString &path)
{
#ifdef DEBUG
odebug << "MainWindowImp::loadModules: " << path.latin1() << "" << oendl;
#endif
QDir d(path);
if(!d.exists())
return;
QString lang = ::getenv("LANG");
// Don't want sym links
d.setFilter( QDir::Files | QDir::NoSymLinks );
const QFileInfoList *list = d.entryInfoList();
QFileInfoListIterator it( *list );
QFileInfo *fi;
while ( (fi=it.current()) )
{
if(fi->fileName().contains(".so"))
{
/* if loaded install translation */
if( loadPlugin(path + "/" + fi->fileName()) != 0l ){
QTranslator *trans = new QTranslator(qApp);
- QString fn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+ fi->fileName().left( fi->fileName().find(".") )+".qm";
+ QString fn = QPEApplication::qpeDir()+"i18n/"+lang+"/"+ fi->fileName().left( fi->fileName().find(".") )+".qm";
if( trans->load( fn ) )
qApp->installTranslator( trans );
else
delete trans;
}
odebug << "loaded plugin: >" << QString(path + "/" + fi->fileName()).latin1() << "< " << oendl;
}
++it;
}
}
/**
* Attempt to load a function and resolve a function.
* @param pluginFileName - the name of the file in which to attempt to load
* @param resolveString - function pointer to resolve
* @return pointer to the function with name resolveString or NULL
*/
Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString)
{
#ifdef DEBUG
odebug << "MainWindowImp::loadPlugin: " << pluginFileName.latin1() << ": resolving " << resolveString.latin1() << "" << oendl;
#endif
QLibrary *lib = new QLibrary(pluginFileName);
void *functionPointer = lib->resolve(resolveString);
if( !functionPointer )
{
#ifdef DEBUG
odebug << "MainWindowImp::loadPlugin: Warning: " << pluginFileName.latin1() << " is not a plugin" << oendl;
#endif
delete lib;
return 0;
}
// Try to get an object.
Module *object = ((Module* (*)()) functionPointer)();
if(object == 0)
{
#ifdef DEBUG
odebug << "MainWindowImp: Couldn't create object, but did load library!" << oendl;
#endif
delete lib;
return 0;
}
m_handledIfaces += object->handledInterfaceNames();
// Store for deletion later
libraries.insert(object, lib);
return object;
}
/**
* The Add button was clicked. Bring up the add dialog and if OK is hit
* load the plugin and append it to the list
*/
void MainWindowImp::addClicked()
{
QMap<Module*, QLibrary*>::Iterator it;
QMap<QString, QString> list;
QMap<QString, Module*> newInterfaceOwners;
for( it = libraries.begin(); it != libraries.end(); ++it )
{
if(it.key())
{
(it.key())->possibleNewInterfaces(list);
}
}
// See if the list has anything that we can add.
if(list.count() == 0)
{
QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok);
return;
}
AddConnectionImp addNewConnection(this, "AddConnectionImp", true);
addNewConnection.addConnections(list);
if( QDialog::Accepted == QPEApplication::execDialog( &addNewConnection ) )
{
QListViewItem *item = addNewConnection.registeredServicesList->currentItem();
if(!item)
return;
for( it = libraries.begin(); it != libraries.end(); ++it )
{
if(it.key())
{
Interface *i = (it.key())->addNewInterface(item->text(0));
if(i)
{
odebug << "iface name " << i->getInterfaceName().latin1() << "" << oendl;
interfaceNames.insert(i->getInterfaceName(), i);
updateInterface(i);
}
}
}
}
}
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
@@ -49,193 +49,193 @@ using namespace Opie::Ui;
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#if defined (__GNUC__) && (__GNUC__ < 3)
#define round qRound
#endif
extern "C"
{
void BenchFFT( void );
double dhry_main( int );
}
#define DHRYSTONE_RUNS 20000000
#define TEST_DURATION 3
//===========================================================================
class BenchmarkPaintWidget : public QWidget
{
public:
BenchmarkPaintWidget() : QWidget( 0, "Benchmark Paint Widget", WStyle_Customize|WStyle_StaysOnTop|WPaintUnclipped|WPaintClever )
{
resize( QApplication::desktop()->size() );
show();
p.begin( this );
};
~BenchmarkPaintWidget()
{
p.end();
hide();
};
QPainter p;
};
//===========================================================================
BenchmarkInfo::BenchmarkInfo( QWidget *parent, const char *name, int wFlags )
: QWidget( parent, name, wFlags )
{
setMinimumSize( 200, 150 );
QVBoxLayout* vb = new QVBoxLayout( this );
vb->setSpacing( 4 );
vb->setMargin( 4 );
tests = new OListView( this );
QWhatsThis::add( tests->viewport(), tr( "This area shows the available tests, the results for which the tests "
"have been performed, and comparison values for one selected device. "
"Use the checkboxes to define which tests you want to perform." ) );
tests->setMargin( 0 );
tests->addColumn( tr( "Tests" ) );
tests->addColumn( tr( "Results" ) );
tests->addColumn( tr( "Comparison" ) );
tests->setShowSortIndicator( true );
test_alu = new OCheckListItem( tests, tr( "1. Integer Arithmetic " ), OCheckListItem::CheckBox );
test_fpu = new OCheckListItem( tests, tr( "2. Floating Point Unit " ), OCheckListItem::CheckBox );
test_txt = new OCheckListItem( tests, tr( "3. Text Rendering " ), OCheckListItem::CheckBox );
test_gfx = new OCheckListItem( tests, tr( "4. Gfx Rendering " ), OCheckListItem::CheckBox );
test_ram = new OCheckListItem( tests, tr( "5. RAM Performance " ), OCheckListItem::CheckBox );
#ifndef QT_QWS_RAMSES
test_sd = new OCheckListItem( tests, tr( "6. SD Card Performance " ), OCheckListItem::CheckBox );
test_cf = new OCheckListItem( tests, tr( "7. CF Card Performance " ), OCheckListItem::CheckBox );
#endif
test_alu->setText( 1, "n/a" );
test_fpu->setText( 1, "n/a" );
test_txt->setText( 1, "n/a" );
test_gfx->setText( 1, "n/a" );
test_ram->setText( 1, "n/a" );
#ifndef QT_QWS_RAMSES
test_sd->setText( 1, "n/a" );
test_cf->setText( 1, "n/a" );
#endif
test_alu->setText( 2, "n/a" );
test_fpu->setText( 2, "n/a" );
test_txt->setText( 2, "n/a" );
test_gfx->setText( 2, "n/a" );
test_ram->setText( 2, "n/a" );
#ifndef QT_QWS_RAMSES
test_sd->setText( 2, "n/a" );
test_cf->setText( 2, "n/a" );
#endif
startButton = new QPushButton( tr( "&Start Tests!" ), this );
QWhatsThis::add( startButton, tr( "Click here to perform the selected tests." ) );
connect( startButton, SIGNAL( clicked() ), this, SLOT( run() ) );
vb->addWidget( tests, 2 );
QHBoxLayout* hb = new QHBoxLayout( vb );
hb->addWidget( startButton, 2 );
- QFile f( QPEApplication::qpeDir() + "/share/sysinfo/results" );
+ QFile f( QPEApplication::qpeDir() + "share/sysinfo/results" );
if ( f.open( IO_ReadOnly ) )
{
machineCombo = new QComboBox( this );
QWhatsThis::add( machineCombo, tr( "Choose a model to compare your results with." ) );
QTextStream ts( &f );
while( !ts.eof() )
{
QString machline = ts.readLine();
odebug << "sysinfo: parsing benchmark results for '" << machline << "'" << oendl;
QString resline = ts.readLine();
machines.insert( machline, new QStringList( QStringList::split( ",", resline ) ) );
machineCombo->insertItem( machline );
}
hb->addWidget( new QLabel( tr( "Compare:" ), this ) );
hb->addWidget( machineCombo, 2 );
connect( machineCombo, SIGNAL( activated(int) ), this, SLOT( machineActivated(int) ) );
}
}
BenchmarkInfo::~BenchmarkInfo()
{}
void BenchmarkInfo::machineActivated( int index )
{
QStringList* results = machines[ machineCombo->text( index ) ];
if ( !results )
{
odebug << "sysinfo: no results available." << oendl;
return;
}
QStringList::Iterator it = results->begin();
test_alu->setText( 2, *(it++) );
test_fpu->setText( 2, *(it++) );
test_txt->setText( 2, *(it++) );
test_gfx->setText( 2, *(it++) );
test_ram->setText( 2, *(it++) );
#ifndef QT_QWS_RAMSES
test_sd->setText( 2, *(it++) );
test_cf->setText( 2, *(it++) );
#endif
}
void BenchmarkInfo::run()
{
startButton->setText( "> Don't touch! <" );
qApp->processEvents();
QTime t;
if ( test_alu->isOn() )
{
int d = round( dhry_main( DHRYSTONE_RUNS ) );
test_alu->setText( 1, QString().sprintf( "%d dhrys", d ) );
test_alu->setOn( false );
}
if ( test_fpu->isOn() )
{
t.start();
BenchFFT();
test_fpu->setText( 1, QString().sprintf( "%.2f secs", t.elapsed() / 1000.0 ) );;
test_fpu->setOn( false );
}
if ( test_txt->isOn() )
{
int value = textRendering( TEST_DURATION );
test_txt->setText( 1, QString().sprintf( "%d chars/sec", value / TEST_DURATION ) );
test_txt->setOn( false );
}
if ( test_gfx->isOn() )
{
int value = gfxRendering( TEST_DURATION );
test_gfx->setText( 1, QString().sprintf( "%.2f gops/sec", value / 4.0 / TEST_DURATION ) ); // 4 tests
test_gfx->setOn( false );
}
if ( test_ram->isOn() ) // /tmp is supposed to be in RAM on a PDA
{
performFileTest( "/tmp/benchmarkFile.dat", test_ram );
}
#ifndef QT_QWS_RAMSES
if ( test_cf->isOn() )
{
OStorageInfo storage;
performFileTest( storage.cfPath() + "/benchmarkFile.dat", test_cf );
}
if ( test_sd->isOn() )
{
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,120 +1,120 @@
#include "tabmanager.h"
#include "app.h"
#include "wait.h"
#include "tabapplnk.h"
#include <opie2/odebug.h>
#include <qpe/applnk.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"
+#define HOME_APP_DIR QPEApplication::qpeDir()+"apps"
#define HOME_APP_INSTALL_DIR "/usr/lib/ipkg/info"
#define NEW_FOLDER "EmptyTab"
#define NEW_APPLICATION "NewApp"
#define APPLICATION_EXTENSION ".desktop"
#define APPLICATION_EXTENSION_LENGTH 8
/**
* Constructor. Sets up signals. Performs initial scan of applications
* and tabs
*/
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*)));
(tabList->header())->hide();
connect(tabList, SIGNAL(moveItem(QListViewItem*,QListViewItem*)), this, SLOT(moveApplication(QListViewItem*,QListViewItem*)));
}
/**
* If anything in the tab's have been changed then update the system or alert
* the user.
*/
TabManager::~TabManager(){
if(changed){
// Prompt.
//int answer = QMessageBox::warning(this, "Message", "Should your desktop be","Yes", "Cancel", 0, 1 );
//if (answer)
// return;
QCopEnvelope e("QPE/System", "linkChanged(QString)");
QString link; //we'll just send an empty string
e << link;
}
}
/**
* Scans root directory for any tabs or applications. Will recursivly go down,
* but will not follow symlinks.
* @param directory - the directory to look in.
* @param parent - the parent to place any new tabs or apps into. If parent is
* NULL then the item is a tab and should be placed as a child of the window.
*/
void TabManager::rescanFolder(QString directory, QListViewItem* parent){
//odebug << QString("rescanFolder: ") + directory.latin1() << oendl;
QDir d;
d.setPath(directory);
// Show hidden files for .directories
d.setFilter( QDir::Files | QDir::Hidden | QDir::Dirs);
const QFileInfoList *list = d.entryInfoList();
QFileInfoListIterator it( *list ); // create list iterator
QFileInfo *fi; // pointer for traversing
while ( (fi=it.current()) ) { // for each file...
// If it is a dir and not .. or . then add it as a tab and go down.
if(fi->isDir()){
if(fi->fileName() != ".." && fi->fileName() != ".") {
QListViewItem* newItem;
if(!parent)
newItem = new QListViewItem(tabList, fi->fileName());
else
newItem = new QListViewItem(parent, fi->fileName());
itemList.insert(newItem, directory + "/" + fi->fileName() + "/.directory" );
rescanFolder(directory + "/" + fi->fileName(), newItem);
}
}
else{
// it is a file, if not a .directory add to parent.
// Change parents name and icon to reflect icon.
if(fi->fileName() == ".directory"){
AppLnk app(directory + "/" + fi->fileName());
if(parent){
parent->setPixmap(0,app.pixmap());
parent->setText(0, app.name());
}
}
else{
// Add any desktop files found.
QListViewItem* newItem;
if(directory != HOME_APP_DIR){
if(!parent)
newItem = new QListViewItem(tabList, fi->fileName());
else
newItem = new QListViewItem(parent, fi->fileName());
if(fi->fileName().right(APPLICATION_EXTENSION_LENGTH) == APPLICATION_EXTENSION){
AppLnk app(directory + "/" + fi->fileName());
newItem->setPixmap(0,app.pixmap());
newItem->setText(0, app.name());
itemList.insert(newItem, directory + "/" + fi->fileName());
}
}
}
}
++it; // goto next list element
@@ -165,193 +165,193 @@ void TabManager::newApplication(){
itemList.insert(newItem, homeLocation );
// We have changed something.
changed = true;
}
/**
* Remove the item.
* Check if we can
* Prompt user
* Delete physical file (Dir, remove .dir, then dir. File, remove file)
* Remove from installer if need too.
*/
void TabManager::removeItem(){
// Make sure we can delete
QListViewItem *item = tabList->currentItem();
if(!item)
return;
if(item->childCount() > 0){
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 );
if (answer)
return;
bool removeSuccessful = true;
QString location = itemList[item];
// Remove file (.directory in a Directory case)
if(!QFile::remove(location))
removeSuccessful = false;
// Remove directory
if(item->parent() == NULL){
// Remove .directory file string
location = location.mid(0,location.length()-10);
QDir dir;
if(!dir.rmdir(location))
removeSuccessful = false;
else
removeSuccessful = true;
}
// If removing failed.
if(!removeSuccessful){
odebug << (QString("removeItem: ") + location).latin1() << oendl;
QMessageBox::critical(this, tr("Message"), tr("Can't remove."), tr("Ok") );
return;
}
// Remove from the installer so it wont fail.
// Don't need to do this sense the current install uses rm -f so no error
// Remove from the gui list.
itemList.remove(item);
if(item->parent())
item->parent()->takeItem(item);
delete item;
// We have changed something.
changed = true;
}
/**
* 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()){
odebug << QString("editItem: Not a valid applnk file: ") + itemList[item].latin1() << oendl;
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/");
+ 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);
}
//odebug << fi->fileName().latin1() << oendl;
++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);