summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/language/language.cpp8
1 files changed, 0 insertions, 8 deletions
diff --git a/noncore/settings/language/language.cpp b/noncore/settings/language/language.cpp
index 5c4284b..8985fd5 100644
--- a/noncore/settings/language/language.cpp
+++ b/noncore/settings/language/language.cpp
@@ -1,160 +1,152 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
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#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
51#include <unistd.h>
52#include <linux/fb.h>
53#include <sys/types.h>
54#include <sys/stat.h>
55#include <fcntl.h>
56#include <sys/ioctl.h>
57#endif
58#include <stdlib.h> 50#include <stdlib.h>
59 51
60 52
61LanguageSettings::LanguageSettings( QWidget* parent, const char* name, WFlags fl ) 53LanguageSettings::LanguageSettings( QWidget* parent, const char* name, WFlags fl )
62 : LanguageSettingsBase( parent, name, TRUE, fl ) 54 : LanguageSettingsBase( parent, name, TRUE, fl )
63{ 55{
64 if ( FontManager::hasUnicodeFont() ) 56 if ( FontManager::hasUnicodeFont() )
65 languages->setFont(FontManager::unicodeFont(FontManager::Proportional)); 57 languages->setFont(FontManager::unicodeFont(FontManager::Proportional));
66 58
67 59
68 QString tfn = QPEApplication::qpeDir() + "/i18n/"; 60 QString tfn = QPEApplication::qpeDir() + "/i18n/";
69 QDir langDir = tfn; 61 QDir langDir = tfn;
70 QStringList list = langDir.entryList("*", QDir::Dirs ); 62 QStringList list = langDir.entryList("*", QDir::Dirs );
71 63
72 QStringList::Iterator it; 64 QStringList::Iterator it;
73 65
74 for ( it = list.begin(); it != list.end(); ++it ) { 66 for ( it = list.begin(); it != list.end(); ++it ) {
75 QString name = (*it); 67 QString name = (*it);
76 QFileInfo desktopFile( tfn + "/" + name + "/.directory" ); 68 QFileInfo desktopFile( tfn + "/" + name + "/.directory" );
77 if ( desktopFile.exists() ) { 69 if ( desktopFile.exists() ) {
78 langAvail.append(name); 70 langAvail.append(name);
79 Config conf( desktopFile.filePath(), Config::File ); 71 Config conf( desktopFile.filePath(), Config::File );
80 QString langName = conf.readEntry( "Name" ); 72 QString langName = conf.readEntry( "Name" );
81 QString ownName = conf.readEntryDirect( "Name[" + name + "]" ); 73 QString ownName = conf.readEntryDirect( "Name[" + name + "]" );
82 if ( ownName.isEmpty() ) 74 if ( ownName.isEmpty() )
83 ownName = conf.readEntryDirect( "Name" ); 75 ownName = conf.readEntryDirect( "Name" );
84 if ( !ownName.isEmpty() && ownName != langName ) 76 if ( !ownName.isEmpty() && ownName != langName )
85 langName = langName + " [" + ownName + "]"; 77 langName = langName + " [" + ownName + "]";
86 languages->insertItem( langName ); 78 languages->insertItem( langName );
87 79
88 } 80 }
89 } 81 }
90 if ( langAvail. find ( "en" ) == -1 ) { 82 if ( langAvail. find ( "en" ) == -1 ) {
91 langAvail. prepend ( "" ); // no tr 83 langAvail. prepend ( "" ); // no tr
92 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 );
93 } 85 }
94 86
95 dl = new QPEDialogListener(this); 87 dl = new QPEDialogListener(this);
96 reset(); 88 reset();
97} 89}
98 90
99LanguageSettings::~LanguageSettings() 91LanguageSettings::~LanguageSettings()
100{} 92{}
101 93
102void LanguageSettings::accept() 94void LanguageSettings::accept()
103{ 95{
104 applyLanguage(); 96 applyLanguage();
105 QDialog::accept(); 97 QDialog::accept();
106} 98}
107 99
108void LanguageSettings::applyLanguage() 100void LanguageSettings::applyLanguage()
109{ 101{
110 setLanguage ( langAvail. at ( languages-> currentItem ( ))); 102 setLanguage ( langAvail. at ( languages-> currentItem ( )));
111} 103}
112 104
113 105
114void LanguageSettings::reject() 106void LanguageSettings::reject()
115{ 107{
116 reset(); 108 reset();
117 QDialog::reject(); 109 QDialog::reject();
118} 110}
119 111
120void LanguageSettings::reset() 112void LanguageSettings::reset()
121{ 113{
122 QString l = getenv("LANG"); 114 QString l = getenv("LANG");
123 Config config("locale"); 115 Config config("locale");
124 config.setGroup("Language"); 116 config.setGroup("Language");
125 l = config.readEntry( "Language", l ); 117 l = config.readEntry( "Language", l );
126 if (l.isEmpty()) 118 if (l.isEmpty())
127 l = "en"; 119 l = "en";
128 actualLanguage = l; 120 actualLanguage = l;
129 121
130 int n = langAvail.find( l ); 122 int n = langAvail.find( l );
131 languages->setCurrentItem( n ); 123 languages->setCurrentItem( n );
132} 124}
133 125
134QString LanguageSettings::actualLanguage; 126QString LanguageSettings::actualLanguage;
135 127
136void LanguageSettings::setLanguage(const QString& lang) 128void LanguageSettings::setLanguage(const QString& lang)
137{ 129{
138 if ( lang != actualLanguage ) { 130 if ( lang != actualLanguage ) {
139 Config config("locale"); 131 Config config("locale");
140 config.setGroup( "Language" ); 132 config.setGroup( "Language" );
141 if ( lang. isEmpty ( )) 133 if ( lang. isEmpty ( ))
142 config. removeEntry ( "Language" ); 134 config. removeEntry ( "Language" );
143 else 135 else
144 config.writeEntry( "Language", lang ); 136 config.writeEntry( "Language", lang );
145 config.write(); 137 config.write();
146 138
147#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 139#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
148 140
149 QCopEnvelope e("QPE/System", "language(QString)"); 141 QCopEnvelope e("QPE/System", "language(QString)");
150 e << lang; 142 e << lang;
151#endif 143#endif
152 144
153 } 145 }
154} 146}
155 147
156void LanguageSettings::done(int r) 148void LanguageSettings::done(int r)
157{ 149{
158 QDialog::done(r); 150 QDialog::done(r);
159 close(); 151 close();
160} 152}