summaryrefslogtreecommitdiff
authorsandman <sandman>2002-10-21 12:13:18 (UTC)
committer sandman <sandman>2002-10-21 12:13:18 (UTC)
commitcdaf60fdf5dc19e88db4faa319daacfe4e879518 (patch) (unidiff)
tree39ef0f3b4505cddb7f7eca2f2a1b14528c937bf2
parent3774660eaa50fe7adab39564ded7a2e1f296724b (diff)
downloadopie-cdaf60fdf5dc19e88db4faa319daacfe4e879518.zip
opie-cdaf60fdf5dc19e88db4faa319daacfe4e879518.tar.gz
opie-cdaf60fdf5dc19e88db4faa319daacfe4e879518.tar.bz2
Language settings didn't let you de-select a language (i.e. if you have
opie-i18n-de, but NOT opie-i18n-en installed, you can't go back to english) Now there's always a "English (default)" entry, as long as opie-i18n-en is not installed.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/language/language.cpp124
1 files changed, 67 insertions, 57 deletions
diff --git a/noncore/settings/language/language.cpp b/noncore/settings/language/language.cpp
index 397d372..5c4284b 100644
--- a/noncore/settings/language/language.cpp
+++ b/noncore/settings/language/language.cpp
@@ -53,98 +53,108 @@
53#include <sys/types.h> 53#include <sys/types.h>
54#include <sys/stat.h> 54#include <sys/stat.h>
55#include <fcntl.h> 55#include <fcntl.h>
56#include <sys/ioctl.h> 56#include <sys/ioctl.h>
57#endif 57#endif
58#include <stdlib.h> 58#include <stdlib.h>
59 59
60 60
61LanguageSettings::LanguageSettings( QWidget* parent, const char* name, WFlags fl ) 61LanguageSettings::LanguageSettings( QWidget* parent, const char* name, WFlags fl )
62 : LanguageSettingsBase( parent, name, TRUE, fl ) 62 : LanguageSettingsBase( parent, name, TRUE, fl )
63{ 63{
64 if ( FontManager::hasUnicodeFont() ) 64 if ( FontManager::hasUnicodeFont() )
65 languages->setFont(FontManager::unicodeFont(FontManager::Proportional)); 65 languages->setFont(FontManager::unicodeFont(FontManager::Proportional));
66 66
67 QString tfn = QPEApplication::qpeDir()+"/i18n/"; 67
68 QDir langDir = tfn; 68 QString tfn = QPEApplication::qpeDir() + "/i18n/";
69 QStringList list = langDir.entryList("*", QDir::Dirs ); 69 QDir langDir = tfn;
70 70 QStringList list = langDir.entryList("*", QDir::Dirs );
71 QStringList::Iterator it; 71
72 72 QStringList::Iterator it;
73 for( it = list.begin(); it != list.end(); ++it ) { 73
74 QString name = (*it); 74 for ( it = list.begin(); it != list.end(); ++it ) {
75 QFileInfo desktopFile( tfn + "/" + name + "/.directory" ); 75 QString name = (*it);
76 if( desktopFile.exists() ) { 76 QFileInfo desktopFile( tfn + "/" + name + "/.directory" );
77 langAvail.append(name); 77 if ( desktopFile.exists() ) {
78 Config conf( desktopFile.filePath(), Config::File ); 78 langAvail.append(name);
79 QString langName = conf.readEntry( "Name" ); 79 Config conf( desktopFile.filePath(), Config::File );
80 QString ownName = conf.readEntryDirect( "Name["+name+"]" ); 80 QString langName = conf.readEntry( "Name" );
81 if ( ownName.isEmpty() ) 81 QString ownName = conf.readEntryDirect( "Name[" + name + "]" );
82 ownName = conf.readEntryDirect( "Name" ); 82 if ( ownName.isEmpty() )
83 if ( !ownName.isEmpty() && ownName != langName ) 83 ownName = conf.readEntryDirect( "Name" );
84 langName = langName + " [" + ownName + "]"; 84 if ( !ownName.isEmpty() && ownName != langName )
85 languages->insertItem( langName ); 85 langName = langName + " [" + ownName + "]";
86 86 languages->insertItem( langName );
87
88 }
87 } 89 }
88 } 90 if ( langAvail. find ( "en" ) == -1 ) {
89 91 langAvail. prepend ( "" ); // no tr
90 dl = new QPEDialogListener(this); 92 languages-> insertItem ( QString ( "English [%1] (%2)" /* no tr (!) */ ). arg ( tr ( "English" )). arg ( tr( "default" )), 0 );
91 reset(); 93 }
94
95 dl = new QPEDialogListener(this);
96 reset();
92} 97}
93 98
94LanguageSettings::~LanguageSettings() 99LanguageSettings::~LanguageSettings()
95{ 100{}
96}
97 101
98void LanguageSettings::accept() 102void LanguageSettings::accept()
99{ 103{
100 applyLanguage(); 104 applyLanguage();
101 QDialog::accept(); 105 QDialog::accept();
102} 106}
103 107
104void LanguageSettings::applyLanguage() 108void LanguageSettings::applyLanguage()
105{ 109{
106 QString lang = langAvail.at( languages->currentItem() ); 110 setLanguage ( langAvail. at ( languages-> currentItem ( )));
107 setLanguage( lang );
108} 111}
109 112
110 113
111void LanguageSettings::reject() 114void LanguageSettings::reject()
112{ 115{
113 reset(); 116 reset();
114 QDialog::reject(); 117 QDialog::reject();
115} 118}
116 119
117void LanguageSettings::reset() 120void LanguageSettings::reset()
118{ 121{
119 QString l = getenv("LANG"); 122 QString l = getenv("LANG");
120 Config config("language"); 123 Config config("locale");
121 l = config.readEntry( "Language", l ); 124 config.setGroup("Language");
122 if(l.isEmpty()) l = "en"; 125 l = config.readEntry( "Language", l );
123 actualLanguage = l; 126 if (l.isEmpty())
124 127 l = "en";
125 int n = langAvail.find( l ); 128 actualLanguage = l;
126 languages->setCurrentItem( n ); 129
130 int n = langAvail.find( l );
131 languages->setCurrentItem( n );
127} 132}
128 133
129QString LanguageSettings::actualLanguage; 134QString LanguageSettings::actualLanguage;
130 135
131void LanguageSettings::setLanguage(const QString& lang) 136void LanguageSettings::setLanguage(const QString& lang)
132{ 137{
133 if( lang != actualLanguage ) { 138 if ( lang != actualLanguage ) {
134 Config config("locale"); 139 Config config("locale");
135 config.setGroup( "Language" ); 140 config.setGroup( "Language" );
136 config.writeEntry( "Language", lang ); 141 if ( lang. isEmpty ( ))
137 config.write(); 142 config. removeEntry ( "Language" );
138 143 else
144 config.writeEntry( "Language", lang );
145 config.write();
146
139#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 147#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
140 QCopEnvelope e("QPE/System","language(QString)"); 148
141 e << lang; 149 QCopEnvelope e("QPE/System", "language(QString)");
150 e << lang;
142#endif 151#endif
143 } 152
153 }
144} 154}
145 155
146void LanguageSettings::done(int r) 156void LanguageSettings::done(int r)
147{ 157{
148 QDialog::done(r); 158 QDialog::done(r);
149 close(); 159 close();
150} 160}