-rw-r--r-- | library/fontdatabase.cpp | 2 | ||||
-rw-r--r-- | library/network.cpp | 6 | ||||
-rw-r--r-- | library/qpedecoration_qws.cpp | 2 |
3 files changed, 5 insertions, 5 deletions
diff --git a/library/fontdatabase.cpp b/library/fontdatabase.cpp index d94e338..7934a09 100644 --- a/library/fontdatabase.cpp +++ b/library/fontdatabase.cpp | |||
@@ -1,251 +1,251 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the 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 <qpe/qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
22 | #include "fontdatabase.h" | 22 | #include "fontdatabase.h" |
23 | 23 | ||
24 | #include <qpe/qlibrary.h> | 24 | #include <qpe/qlibrary.h> |
25 | 25 | ||
26 | #include <qfontmanager_qws.h> | 26 | #include <qfontmanager_qws.h> |
27 | #include <qdir.h> | 27 | #include <qdir.h> |
28 | #include <stdio.h> | 28 | #include <stdio.h> |
29 | #include <stdlib.h> | 29 | #include <stdlib.h> |
30 | 30 | ||
31 | static QString fontDir() | 31 | static QString fontDir() |
32 | { | 32 | { |
33 | QString qtdir = getenv("QTDIR"); | 33 | QString qtdir = getenv("QTDIR"); |
34 | if ( qtdir.isEmpty() ) qtdir = "/usr/local/qt-embedded"; | 34 | if ( qtdir.isEmpty() ) qtdir = "/usr/local/qt-embedded"; |
35 | return qtdir+"/lib/fonts/"; | 35 | return qtdir+"/lib/fonts/"; |
36 | } | 36 | } |
37 | 37 | ||
38 | #ifdef QT_NO_FONTDATABASE | 38 | #ifdef QT_NO_FONTDATABASE |
39 | static QString fontFamily( const QString& key ) | 39 | static QString fontFamily( const QString& key ) |
40 | { | 40 | { |
41 | int u0 = key.find('_'); | 41 | int u0 = key.find('_'); |
42 | int u1 = key.find('_',u0+1); | 42 | int u1 = key.find('_',u0+1); |
43 | int u2 = key.find('_',u1+1); | 43 | int u2 = key.find('_',u1+1); |
44 | QString family = key.left(u0); | 44 | QString family = key.left(u0); |
45 | //int pointSize = key.mid(u0+1,u1-u0-1).toInt(); | 45 | //int pointSize = key.mid(u0+1,u1-u0-1).toInt(); |
46 | //int weight = key.mid(u1+1,u2-u1-1).toInt(); | 46 | //int weight = key.mid(u1+1,u2-u1-1).toInt(); |
47 | //bool italic = key.mid(u2-1,1) == "i"; | 47 | //bool italic = key.mid(u2-1,1) == "i"; |
48 | // #### ignores _t and _I fields | 48 | // #### ignores _t and _I fields |
49 | return family; | 49 | return family; |
50 | } | 50 | } |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | 53 | ||
54 | QValueList<FontFactory> *FontDatabase::factoryList = 0; | 54 | QValueList<FontFactory> *FontDatabase::factoryList = 0; |
55 | /*! | 55 | /*! |
56 | \class FontDatabase fontdatabase.h | 56 | \class FontDatabase fontdatabase.h |
57 | \brief The FontDatabase class provides information about available fonts. | 57 | \brief The FontDatabase class provides information about available fonts. |
58 | 58 | ||
59 | Most often you will simply want to query the database for the | 59 | Most often you will simply want to query the database for the |
60 | available font families(). | 60 | available font families(). |
61 | 61 | ||
62 | Use FontDatabase rather than QFontDatabase when you may need access | 62 | Use FontDatabase rather than QFontDatabase when you may need access |
63 | to fonts that are not normally available. For example, if the | 63 | to fonts that are not normally available. For example, if the |
64 | freetype library and the Qtopia freetype plugin are installed, | 64 | freetype library and the Qtopia freetype plugin are installed, |
65 | TrueType fonts will be available to your application. Font renderer | 65 | TrueType fonts will be available to your application. Font renderer |
66 | plugins have greater resource requirements than system fonts so they | 66 | plugins have greater resource requirements than system fonts so they |
67 | should be used only when necessary. You can force the loading of | 67 | should be used only when necessary. You can force the loading of |
68 | font renderer plugins with loadRenderers(). | 68 | font renderer plugins with loadRenderers(). |
69 | 69 | ||
70 | \ingroup qtopiaemb | 70 | \ingroup qtopiaemb |
71 | */ | 71 | */ |
72 | 72 | ||
73 | /*! | 73 | /*! |
74 | Constructs a FontDatabase object. | 74 | Constructs a FontDatabase object. |
75 | */ | 75 | */ |
76 | FontDatabase::FontDatabase() | 76 | FontDatabase::FontDatabase() |
77 | #ifndef QT_NO_FONTDATABASE | 77 | #ifndef QT_NO_FONTDATABASE |
78 | : QFontDatabase() | 78 | : QFontDatabase() |
79 | #endif | 79 | #endif |
80 | { | 80 | { |
81 | if ( !factoryList ) | 81 | if ( !factoryList ) |
82 | loadRenderers(); | 82 | loadRenderers(); |
83 | } | 83 | } |
84 | 84 | ||
85 | /*! | 85 | /*! |
86 | Returns a list of names of all the available font families. | 86 | Returns a list of names of all the available font families. |
87 | */ | 87 | */ |
88 | QStringList FontDatabase::families() const | 88 | QStringList FontDatabase::families() const |
89 | { | 89 | { |
90 | #ifndef QT_NO_FONTDATABASE | 90 | #ifndef QT_NO_FONTDATABASE |
91 | return QFontDatabase::families(); | 91 | return QFontDatabase::families(); |
92 | #else | 92 | #else |
93 | 93 | ||
94 | #ifndef QWS | 94 | #ifndef QWS |
95 | QStringList list; | 95 | QStringList list; |
96 | return list; | 96 | return list; |
97 | #else | 97 | #else |
98 | QStringList list; | 98 | QStringList list; |
99 | QDict<void> familyDict; | 99 | QDict<void> familyDict; |
100 | QDiskFont *qdf; | 100 | QDiskFont *qdf; |
101 | for ( qdf=qt_fontmanager->diskfonts.first(); qdf!=0; | 101 | for ( qdf=qt_fontmanager->diskfonts.first(); qdf!=0; |
102 | qdf=qt_fontmanager->diskfonts.next()) { | 102 | qdf=qt_fontmanager->diskfonts.next()) { |
103 | QString familyname = qdf->name; | 103 | QString familyname = qdf->name; |
104 | if ( !familyDict.find( familyname ) ) { | 104 | if ( !familyDict.find( familyname ) ) { |
105 | familyDict.insert( familyname, (void *)1 ); | 105 | familyDict.insert( familyname, (void *)1 ); |
106 | list.append( familyname ); | 106 | list.append( familyname ); |
107 | } | 107 | } |
108 | } | 108 | } |
109 | 109 | ||
110 | QDir dir(fontDir(),"*.qpf"); | 110 | QDir dir(fontDir(),"*.qpf"); |
111 | for (int i=0; i<(int)dir.count(); i++) { | 111 | for (int i=0; i<(int)dir.count(); i++) { |
112 | QString familyname = fontFamily(dir[i]); | 112 | QString familyname = fontFamily(dir[i]); |
113 | if ( !familyDict.find( familyname ) ) { | 113 | if ( !familyDict.find( familyname ) ) { |
114 | familyDict.insert( familyname, (void *)1 ); | 114 | familyDict.insert( familyname, (void *)1 ); |
115 | list.append( familyname ); | 115 | list.append( familyname ); |
116 | } | 116 | } |
117 | } | 117 | } |
118 | 118 | ||
119 | return list; | 119 | return list; |
120 | #endif | 120 | #endif |
121 | #endif | 121 | #endif |
122 | } | 122 | } |
123 | 123 | ||
124 | #ifdef QT_NO_FONTDATABASE | 124 | #ifdef QT_NO_FONTDATABASE |
125 | /*! | 125 | /*! |
126 | Returns a list of standard fontsizes. | 126 | Returns a list of standard fontsizes. |
127 | */ | 127 | */ |
128 | QValueList<int> FontDatabase::standardSizes() | 128 | QValueList<int> FontDatabase::standardSizes() |
129 | { | 129 | { |
130 | static int s[]={ 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, | 130 | static int s[]={ 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, |
131 | 36, 48, 72, 0 }; | 131 | 36, 48, 72, 0 }; |
132 | static bool first = TRUE; | 132 | static bool first = TRUE; |
133 | static QValueList<int> sList; | 133 | static QValueList<int> sList; |
134 | if ( first ) { | 134 | if ( first ) { |
135 | first = FALSE; | 135 | first = FALSE; |
136 | int i = 0; | 136 | int i = 0; |
137 | while( s[i] ) | 137 | while( s[i] ) |
138 | sList.append( s[i++] ); | 138 | sList.append( s[i++] ); |
139 | } | 139 | } |
140 | return sList; | 140 | return sList; |
141 | } | 141 | } |
142 | 142 | ||
143 | #endif | 143 | #endif |
144 | 144 | ||
145 | /*! | 145 | /*! |
146 | Load any font renderer plugins that are available and make the fonts | 146 | Load any font renderer plugins that are available and make the fonts |
147 | that the plugins can read available. | 147 | that the plugins can read available. |
148 | */ | 148 | */ |
149 | void FontDatabase::loadRenderers() | 149 | void FontDatabase::loadRenderers() |
150 | { | 150 | { |
151 | #ifndef QWS | 151 | #ifndef QWS |
152 | return; | 152 | return; |
153 | #else | 153 | #else |
154 | 154 | ||
155 | #ifndef QT_NO_COMPONENT | 155 | #ifndef QT_NO_COMPONENT |
156 | if ( !factoryList ) | 156 | if ( !factoryList ) |
157 | factoryList = new QValueList<FontFactory>; | 157 | factoryList = new QValueList<FontFactory>; |
158 | 158 | ||
159 | QValueList<FontFactory>::Iterator mit; | 159 | QValueList<FontFactory>::Iterator mit; |
160 | for ( mit = factoryList->begin(); mit != factoryList->end(); ++mit ) { | 160 | for ( mit = factoryList->begin(); mit != factoryList->end(); ++mit ) { |
161 | qt_fontmanager->factories.setAutoDelete( false ); | 161 | qt_fontmanager->factories.setAutoDelete( false ); |
162 | qt_fontmanager->factories.removeRef( (*mit).factory ); | 162 | qt_fontmanager->factories.removeRef( (*mit).factory ); |
163 | qt_fontmanager->factories.setAutoDelete( true ); | 163 | qt_fontmanager->factories.setAutoDelete( true ); |
164 | (*mit).interface->release(); | 164 | (*mit).interface->release(); |
165 | (*mit).library->unload(); | 165 | (*mit).library->unload(); |
166 | delete (*mit).library; | 166 | delete (*mit).library; |
167 | } | 167 | } |
168 | factoryList->clear(); | 168 | factoryList->clear(); |
169 | 169 | ||
170 | QString path = QPEApplication::qpeDir() + "/plugins/fontfactories"; | 170 | QString path = QPEApplication::qpeDir() + "plugins/fontfactories"; |
171 | #ifdef Q_OS_MACX | 171 | #ifdef Q_OS_MACX |
172 | QDir dir( path, "lib*.dylib" ); | 172 | QDir dir( path, "lib*.dylib" ); |
173 | #else | 173 | #else |
174 | QDir dir( path, "lib*.so" ); | 174 | QDir dir( path, "lib*.so" ); |
175 | #endif | 175 | #endif |
176 | 176 | ||
177 | if ( !dir.exists()) | 177 | if ( !dir.exists()) |
178 | return; | 178 | return; |
179 | 179 | ||
180 | QStringList list = dir.entryList(); | 180 | QStringList list = dir.entryList(); |
181 | QStringList::Iterator it; | 181 | QStringList::Iterator it; |
182 | for ( it = list.begin(); it != list.end(); ++it ) { | 182 | for ( it = list.begin(); it != list.end(); ++it ) { |
183 | FontFactoryInterface *iface = 0; | 183 | FontFactoryInterface *iface = 0; |
184 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 184 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
185 | if ( lib->queryInterface( IID_FontFactory, (QUnknownInterface**)&iface ) == QS_OK ) { | 185 | if ( lib->queryInterface( IID_FontFactory, (QUnknownInterface**)&iface ) == QS_OK ) { |
186 | FontFactory factory; | 186 | FontFactory factory; |
187 | factory.library = lib; | 187 | factory.library = lib; |
188 | factory.interface = iface; | 188 | factory.interface = iface; |
189 | factory.factory = factory.interface->fontFactory(); | 189 | factory.factory = factory.interface->fontFactory(); |
190 | factoryList->append( factory ); | 190 | factoryList->append( factory ); |
191 | qt_fontmanager->factories.append( factory.factory ); | 191 | qt_fontmanager->factories.append( factory.factory ); |
192 | readFonts( factory.factory ); | 192 | readFonts( factory.factory ); |
193 | } else { | 193 | } else { |
194 | delete lib; | 194 | delete lib; |
195 | } | 195 | } |
196 | } | 196 | } |
197 | #endif | 197 | #endif |
198 | #endif | 198 | #endif |
199 | } | 199 | } |
200 | 200 | ||
201 | /*! | 201 | /*! |
202 | \internal | 202 | \internal |
203 | */ | 203 | */ |
204 | void FontDatabase::readFonts( QFontFactory *factory ) | 204 | void FontDatabase::readFonts( QFontFactory *factory ) |
205 | { | 205 | { |
206 | #ifndef QWS | 206 | #ifndef QWS |
207 | return; | 207 | return; |
208 | #else | 208 | #else |
209 | // Load in font definition file | 209 | // Load in font definition file |
210 | QString fn = fontDir() + "fontdir"; | 210 | QString fn = fontDir() + "fontdir"; |
211 | FILE* fontdef=fopen(fn.local8Bit(),"r"); | 211 | FILE* fontdef=fopen(fn.local8Bit(),"r"); |
212 | if(!fontdef) { | 212 | if(!fontdef) { |
213 | QCString temp=fn.local8Bit(); | 213 | QCString temp=fn.local8Bit(); |
214 | qWarning("Cannot find font definition file %s - is $QTDIR set correctly?", | 214 | qWarning("Cannot find font definition file %s - is $QTDIR set correctly?", |
215 | temp.data()); | 215 | temp.data()); |
216 | return; | 216 | return; |
217 | } | 217 | } |
218 | char buf[200]=""; | 218 | char buf[200]=""; |
219 | char name[200]=""; | 219 | char name[200]=""; |
220 | char render[200]=""; | 220 | char render[200]=""; |
221 | char file[200]=""; | 221 | char file[200]=""; |
222 | char flags[200]=""; | 222 | char flags[200]=""; |
223 | char isitalic[10]=""; | 223 | char isitalic[10]=""; |
224 | fgets(buf,200,fontdef); | 224 | fgets(buf,200,fontdef); |
225 | while(!feof(fontdef)) { | 225 | while(!feof(fontdef)) { |
226 | if ( buf[0] != '#' ) { | 226 | if ( buf[0] != '#' ) { |
227 | int weight=50; | 227 | int weight=50; |
228 | int size=0; | 228 | int size=0; |
229 | flags[0]=0; | 229 | flags[0]=0; |
230 | sscanf(buf,"%s %s %s %s %d %d %s",name,file,render,isitalic,&weight,&size,flags); | 230 | sscanf(buf,"%s %s %s %s %d %d %s",name,file,render,isitalic,&weight,&size,flags); |
231 | QString filename; | 231 | QString filename; |
232 | if ( file[0] != '/' ) | 232 | if ( file[0] != '/' ) |
233 | filename = fontDir(); | 233 | filename = fontDir(); |
234 | filename += file; | 234 | filename += file; |
235 | if ( QFile::exists(filename) ) { | 235 | if ( QFile::exists(filename) ) { |
236 | if( factory->name() == render ) { | 236 | if( factory->name() == render ) { |
237 | QDiskFont * qdf=new QDiskFont(factory,name,isitalic[0]=='y', | 237 | QDiskFont * qdf=new QDiskFont(factory,name,isitalic[0]=='y', |
238 | weight,size,flags,filename); | 238 | weight,size,flags,filename); |
239 | qt_fontmanager->diskfonts.append(qdf); | 239 | qt_fontmanager->diskfonts.append(qdf); |
240 | #if QT_VERSION >= 232 | 240 | #if QT_VERSION >= 232 |
241 | QFontDatabase::qwsAddDiskFont( qdf ); | 241 | QFontDatabase::qwsAddDiskFont( qdf ); |
242 | #endif | 242 | #endif |
243 | } | 243 | } |
244 | } | 244 | } |
245 | } | 245 | } |
246 | fgets(buf,200,fontdef); | 246 | fgets(buf,200,fontdef); |
247 | } | 247 | } |
248 | fclose(fontdef); | 248 | fclose(fontdef); |
249 | #endif | 249 | #endif |
250 | } | 250 | } |
251 | 251 | ||
diff --git a/library/network.cpp b/library/network.cpp index f2a673c..0bbbec1 100644 --- a/library/network.cpp +++ b/library/network.cpp | |||
@@ -1,448 +1,448 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the 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 | #define QTOPIA_INTERNAL_LANGLIST | 21 | #define QTOPIA_INTERNAL_LANGLIST |
22 | #include <qpe/network.h> | 22 | #include <qpe/network.h> |
23 | #include <qpe/networkinterface.h> | 23 | #include <qpe/networkinterface.h> |
24 | #include <qpe/global.h> | 24 | #include <qpe/global.h> |
25 | #include <qpe/config.h> | 25 | #include <qpe/config.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | #include <qpe/qcopenvelope_qws.h> | 28 | #include <qpe/qcopenvelope_qws.h> |
29 | #include <qpe/qlibrary.h> | 29 | #include <qpe/qlibrary.h> |
30 | 30 | ||
31 | #include <qlistbox.h> | 31 | #include <qlistbox.h> |
32 | #include <qdir.h> | 32 | #include <qdir.h> |
33 | #include <qlayout.h> | 33 | #include <qlayout.h> |
34 | #include <qdict.h> | 34 | #include <qdict.h> |
35 | #include <qtranslator.h> | 35 | #include <qtranslator.h> |
36 | 36 | ||
37 | #include <stdlib.h> | 37 | #include <stdlib.h> |
38 | 38 | ||
39 | #ifndef QT_NO_COP | 39 | #ifndef QT_NO_COP |
40 | class NetworkEmitter : public QCopChannel { | 40 | class NetworkEmitter : public QCopChannel { |
41 | Q_OBJECT | 41 | Q_OBJECT |
42 | public: | 42 | public: |
43 | NetworkEmitter() : QCopChannel("QPE/Network",qApp) | 43 | NetworkEmitter() : QCopChannel("QPE/Network",qApp) |
44 | { | 44 | { |
45 | } | 45 | } |
46 | 46 | ||
47 | void receive(const QCString &msg, const QByteArray&) | 47 | void receive(const QCString &msg, const QByteArray&) |
48 | { | 48 | { |
49 | if ( msg == "choicesChanged()" ) | 49 | if ( msg == "choicesChanged()" ) |
50 | emit changed(); | 50 | emit changed(); |
51 | } | 51 | } |
52 | 52 | ||
53 | signals: | 53 | signals: |
54 | void changed(); | 54 | void changed(); |
55 | }; | 55 | }; |
56 | 56 | ||
57 | /*! | 57 | /*! |
58 | \internal | 58 | \internal |
59 | 59 | ||
60 | Requests that the service \a choice be started. The \a password is | 60 | Requests that the service \a choice be started. The \a password is |
61 | the password to use if required. | 61 | the password to use if required. |
62 | */ | 62 | */ |
63 | void Network::start(const QString& choice, const QString& password) | 63 | void Network::start(const QString& choice, const QString& password) |
64 | { | 64 | { |
65 | QCopEnvelope e("QPE/Network", "start(QString,QString)"); | 65 | QCopEnvelope e("QPE/Network", "start(QString,QString)"); |
66 | e << choice << password; | 66 | e << choice << password; |
67 | } | 67 | } |
68 | 68 | ||
69 | /*! | 69 | /*! |
70 | \class Network network.h | 70 | \class Network network.h |
71 | \brief The Network class provides network access functionality. | 71 | \brief The Network class provides network access functionality. |
72 | \internal | 72 | \internal |
73 | */ | 73 | */ |
74 | 74 | ||
75 | // copy the proxy settings of the active config over to the Proxies.conf file | 75 | // copy the proxy settings of the active config over to the Proxies.conf file |
76 | /*! | 76 | /*! |
77 | \internal | 77 | \internal |
78 | */ | 78 | */ |
79 | void Network::writeProxySettings( Config &cfg ) | 79 | void Network::writeProxySettings( Config &cfg ) |
80 | { | 80 | { |
81 | Config proxy( Network::settingsDir() + "/Proxies.conf", Config::File ); | 81 | Config proxy( Network::settingsDir() + "/Proxies.conf", Config::File ); |
82 | proxy.setGroup("Properties"); | 82 | proxy.setGroup("Properties"); |
83 | cfg.setGroup("Proxy"); | 83 | cfg.setGroup("Proxy"); |
84 | proxy.writeEntry("type", cfg.readEntry("type") ); | 84 | proxy.writeEntry("type", cfg.readEntry("type") ); |
85 | proxy.writeEntry("autoconfig", cfg.readEntry("autoconfig") ); | 85 | proxy.writeEntry("autoconfig", cfg.readEntry("autoconfig") ); |
86 | proxy.writeEntry("httphost", cfg.readEntry("httphost") ); | 86 | proxy.writeEntry("httphost", cfg.readEntry("httphost") ); |
87 | proxy.writeEntry("httpport", cfg.readEntry("httpport") ); | 87 | proxy.writeEntry("httpport", cfg.readEntry("httpport") ); |
88 | proxy.writeEntry("ftphost", cfg.readEntry("ftphost") ); | 88 | proxy.writeEntry("ftphost", cfg.readEntry("ftphost") ); |
89 | proxy.writeEntry("ftpport", cfg.readEntry("ftpport") ); | 89 | proxy.writeEntry("ftpport", cfg.readEntry("ftpport") ); |
90 | proxy.writeEntry("noproxies", cfg.readEntry("noproxies") ); | 90 | proxy.writeEntry("noproxies", cfg.readEntry("noproxies") ); |
91 | cfg.setGroup("Properties"); | 91 | cfg.setGroup("Properties"); |
92 | } | 92 | } |
93 | 93 | ||
94 | 94 | ||
95 | 95 | ||
96 | /*! | 96 | /*! |
97 | \internal | 97 | \internal |
98 | 98 | ||
99 | Stops the current network service. | 99 | Stops the current network service. |
100 | */ | 100 | */ |
101 | void Network::stop() | 101 | void Network::stop() |
102 | { | 102 | { |
103 | QCopEnvelope e("QPE/Network", "stop()"); | 103 | QCopEnvelope e("QPE/Network", "stop()"); |
104 | } | 104 | } |
105 | 105 | ||
106 | static NetworkEmitter *emitter = 0; | 106 | static NetworkEmitter *emitter = 0; |
107 | 107 | ||
108 | /*! | 108 | /*! |
109 | \internal | 109 | \internal |
110 | */ | 110 | */ |
111 | void Network::connectChoiceChange(QObject* receiver, const char* slot) | 111 | void Network::connectChoiceChange(QObject* receiver, const char* slot) |
112 | { | 112 | { |
113 | if ( !emitter ) | 113 | if ( !emitter ) |
114 | emitter = new NetworkEmitter; | 114 | emitter = new NetworkEmitter; |
115 | QObject::connect(emitter,SIGNAL(changed()),receiver,slot); | 115 | QObject::connect(emitter,SIGNAL(changed()),receiver,slot); |
116 | } | 116 | } |
117 | 117 | ||
118 | #endif// QT_NO_COP | 118 | #endif// QT_NO_COP |
119 | /*! | 119 | /*! |
120 | \internal | 120 | \internal |
121 | */ | 121 | */ |
122 | QString Network::settingsDir() | 122 | QString Network::settingsDir() |
123 | { | 123 | { |
124 | return Global::applicationFileName("Network", "modules"); | 124 | return Global::applicationFileName("Network", "modules"); |
125 | } | 125 | } |
126 | 126 | ||
127 | #ifndef QT_NO_COP | 127 | #ifndef QT_NO_COP |
128 | /*! | 128 | /*! |
129 | \internal | 129 | \internal |
130 | */ | 130 | */ |
131 | QStringList Network::choices(QListBox* lb, const QString& dir) | 131 | QStringList Network::choices(QListBox* lb, const QString& dir) |
132 | { | 132 | { |
133 | QStringList list; | 133 | QStringList list; |
134 | 134 | ||
135 | if ( lb ) | 135 | if ( lb ) |
136 | lb->clear(); | 136 | lb->clear(); |
137 | 137 | ||
138 | QString adir = dir.isEmpty() ? settingsDir() : dir; | 138 | QString adir = dir.isEmpty() ? settingsDir() : dir; |
139 | QDir settingsdir(adir); | 139 | QDir settingsdir(adir); |
140 | settingsdir.mkdir(adir); | 140 | settingsdir.mkdir(adir); |
141 | 141 | ||
142 | QStringList files = settingsdir.entryList("*.conf"); | 142 | QStringList files = settingsdir.entryList("*.conf"); |
143 | for (QStringList::ConstIterator it=files.begin(); it!=files.end(); ++it ) { | 143 | for (QStringList::ConstIterator it=files.begin(); it!=files.end(); ++it ) { |
144 | QString filename = settingsdir.filePath(*it); | 144 | QString filename = settingsdir.filePath(*it); |
145 | Config cfg(filename, Config::File); | 145 | Config cfg(filename, Config::File); |
146 | cfg.setGroup("Info"); | 146 | cfg.setGroup("Info"); |
147 | if ( lb ) | 147 | if ( lb ) |
148 | lb->insertItem(Resource::loadPixmap("Network/" + cfg.readEntry("Type")), | 148 | lb->insertItem(Resource::loadPixmap("Network/" + cfg.readEntry("Type")), |
149 | cfg.readEntry("Name")); | 149 | cfg.readEntry("Name")); |
150 | list.append(filename); | 150 | list.append(filename); |
151 | } | 151 | } |
152 | 152 | ||
153 | return list; | 153 | return list; |
154 | } | 154 | } |
155 | 155 | ||
156 | class NetworkServer : public QCopChannel { | 156 | class NetworkServer : public QCopChannel { |
157 | Q_OBJECT | 157 | Q_OBJECT |
158 | public: | 158 | public: |
159 | NetworkServer(QObject* parent) : QCopChannel("QPE/Network",parent), wait(0) | 159 | NetworkServer(QObject* parent) : QCopChannel("QPE/Network",parent), wait(0) |
160 | { | 160 | { |
161 | up = FALSE; | 161 | up = FALSE; |
162 | examineNetworks( TRUE ); | 162 | examineNetworks( TRUE ); |
163 | QCopChannel* card = new QCopChannel("QPE/Card",parent); | 163 | QCopChannel* card = new QCopChannel("QPE/Card",parent); |
164 | connect(card,SIGNAL(received(const QCString&,const QByteArray&)), | 164 | connect(card,SIGNAL(received(const QCString&,const QByteArray&)), |
165 | this,SLOT(cardMessage(const QCString&,const QByteArray&))); | 165 | this,SLOT(cardMessage(const QCString&,const QByteArray&))); |
166 | } | 166 | } |
167 | 167 | ||
168 | ~NetworkServer() | 168 | ~NetworkServer() |
169 | { | 169 | { |
170 | stop(); | 170 | stop(); |
171 | } | 171 | } |
172 | 172 | ||
173 | bool networkOnline() const | 173 | bool networkOnline() const |
174 | { | 174 | { |
175 | return up; | 175 | return up; |
176 | } | 176 | } |
177 | 177 | ||
178 | private: | 178 | private: |
179 | void receive(const QCString &msg, const QByteArray& data) | 179 | void receive(const QCString &msg, const QByteArray& data) |
180 | { | 180 | { |
181 | if ( msg == "start(QString,QString)" ) { | 181 | if ( msg == "start(QString,QString)" ) { |
182 | QDataStream stream(data,IO_ReadOnly); | 182 | QDataStream stream(data,IO_ReadOnly); |
183 | QString file,password; | 183 | QString file,password; |
184 | stream >> file >> password; | 184 | stream >> file >> password; |
185 | if ( file.isEmpty() ) { | 185 | if ( file.isEmpty() ) { |
186 | QStringList l = Network::choices(); | 186 | QStringList l = Network::choices(); |
187 | for (QStringList::ConstIterator i=l.begin(); i!=l.end(); ++i) { | 187 | for (QStringList::ConstIterator i=l.begin(); i!=l.end(); ++i) { |
188 | Config cfg(*i,Config::File); | 188 | Config cfg(*i,Config::File); |
189 | cfg.setGroup("Info"); | 189 | cfg.setGroup("Info"); |
190 | QString type = cfg.readEntry("Type"); | 190 | QString type = cfg.readEntry("Type"); |
191 | NetworkInterface* plugin = Network::loadPlugin(type); | 191 | NetworkInterface* plugin = Network::loadPlugin(type); |
192 | cfg.setGroup("Properties"); | 192 | cfg.setGroup("Properties"); |
193 | if ( plugin && plugin->isAvailable(cfg) ) { | 193 | if ( plugin && plugin->isAvailable(cfg) ) { |
194 | file = *i; | 194 | file = *i; |
195 | break; | 195 | break; |
196 | } | 196 | } |
197 | } | 197 | } |
198 | if ( file.isEmpty() ) { | 198 | if ( file.isEmpty() ) { |
199 | QCopEnvelope("QPE/Network", "failed()"); | 199 | QCopEnvelope("QPE/Network", "failed()"); |
200 | return; | 200 | return; |
201 | } | 201 | } |
202 | } | 202 | } |
203 | start(file,password); | 203 | start(file,password); |
204 | } else if ( msg == "stop()" ) { | 204 | } else if ( msg == "stop()" ) { |
205 | stop(); | 205 | stop(); |
206 | } else if ( msg == "choicesChanged()" ) { | 206 | } else if ( msg == "choicesChanged()" ) { |
207 | examineNetworks(); | 207 | examineNetworks(); |
208 | } | 208 | } |
209 | } | 209 | } |
210 | 210 | ||
211 | private slots: | 211 | private slots: |
212 | void cardMessage(const QCString &msg, const QByteArray&) | 212 | void cardMessage(const QCString &msg, const QByteArray&) |
213 | { | 213 | { |
214 | if ( msg == "stabChanged()" ) | 214 | if ( msg == "stabChanged()" ) |
215 | examineNetworks(); | 215 | examineNetworks(); |
216 | } | 216 | } |
217 | 217 | ||
218 | private: | 218 | private: |
219 | void examineNetworks( bool firstStart = FALSE ) | 219 | void examineNetworks( bool firstStart = FALSE ) |
220 | { | 220 | { |
221 | QStringList l = Network::choices(); | 221 | QStringList l = Network::choices(); |
222 | bool wasup = up; up=FALSE; | 222 | bool wasup = up; up=FALSE; |
223 | QStringList pavailable = available; | 223 | QStringList pavailable = available; |
224 | available.clear(); | 224 | available.clear(); |
225 | for (QStringList::ConstIterator it=l.begin(); it!=l.end(); ++it) { | 225 | for (QStringList::ConstIterator it=l.begin(); it!=l.end(); ++it) { |
226 | Config cfg(*it,Config::File); | 226 | Config cfg(*it,Config::File); |
227 | cfg.setGroup("Info"); | 227 | cfg.setGroup("Info"); |
228 | QString type = cfg.readEntry("Type"); | 228 | QString type = cfg.readEntry("Type"); |
229 | NetworkInterface* plugin = Network::loadPlugin(type); | 229 | NetworkInterface* plugin = Network::loadPlugin(type); |
230 | cfg.setGroup("Properties"); | 230 | cfg.setGroup("Properties"); |
231 | if ( plugin ) { | 231 | if ( plugin ) { |
232 | if ( plugin->isActive(cfg) ) { | 232 | if ( plugin->isActive(cfg) ) { |
233 | up = TRUE; | 233 | up = TRUE; |
234 | if ( firstStart ) | 234 | if ( firstStart ) |
235 | plugin->start( cfg ); | 235 | plugin->start( cfg ); |
236 | } | 236 | } |
237 | if ( plugin->isAvailable(cfg) ) | 237 | if ( plugin->isAvailable(cfg) ) |
238 | available.append(*it); | 238 | available.append(*it); |
239 | } | 239 | } |
240 | } | 240 | } |
241 | 241 | ||
242 | // Try to work around unreproducible bug whereby | 242 | // Try to work around unreproducible bug whereby |
243 | // the netmon applet shows wrong state. | 243 | // the netmon applet shows wrong state. |
244 | bool reannounce = wait<0; | 244 | bool reannounce = wait<0; |
245 | 245 | ||
246 | if ( available != pavailable || reannounce ) { | 246 | if ( available != pavailable || reannounce ) { |
247 | QCopEnvelope e("QPE/Network", "available(QStringList)"); | 247 | QCopEnvelope e("QPE/Network", "available(QStringList)"); |
248 | e << available; | 248 | e << available; |
249 | } | 249 | } |
250 | if ( up != wasup || reannounce ) { | 250 | if ( up != wasup || reannounce ) { |
251 | QCopEnvelope("QPE/Network", up ? "up()" : "down()"); | 251 | QCopEnvelope("QPE/Network", up ? "up()" : "down()"); |
252 | } | 252 | } |
253 | } | 253 | } |
254 | 254 | ||
255 | void start( const QString& file, const QString& password ) | 255 | void start( const QString& file, const QString& password ) |
256 | { | 256 | { |
257 | if ( !current.isEmpty() ) | 257 | if ( !current.isEmpty() ) |
258 | stop(); | 258 | stop(); |
259 | current = QString::null; | 259 | current = QString::null; |
260 | Config cfg(file, Config::File); | 260 | Config cfg(file, Config::File); |
261 | cfg.setGroup("Info"); | 261 | cfg.setGroup("Info"); |
262 | QString type = cfg.readEntry("Type"); | 262 | QString type = cfg.readEntry("Type"); |
263 | NetworkInterface* plugin = Network::loadPlugin(type); | 263 | NetworkInterface* plugin = Network::loadPlugin(type); |
264 | bool started = FALSE; | 264 | bool started = FALSE; |
265 | if ( plugin ) { | 265 | if ( plugin ) { |
266 | cfg.setGroup("Properties"); | 266 | cfg.setGroup("Properties"); |
267 | if ( plugin->start(cfg,password) ) { | 267 | if ( plugin->start(cfg,password) ) { |
268 | Network::writeProxySettings( cfg ); | 268 | Network::writeProxySettings( cfg ); |
269 | current = file; | 269 | current = file; |
270 | wait=0; | 270 | wait=0; |
271 | startTimer(400); | 271 | startTimer(400); |
272 | started = TRUE; | 272 | started = TRUE; |
273 | } | 273 | } |
274 | } | 274 | } |
275 | if ( !started ) { | 275 | if ( !started ) { |
276 | QCopEnvelope("QPE/Network", "failed()"); | 276 | QCopEnvelope("QPE/Network", "failed()"); |
277 | } | 277 | } |
278 | } | 278 | } |
279 | 279 | ||
280 | void stop() | 280 | void stop() |
281 | { | 281 | { |
282 | bool stopped = FALSE; | 282 | bool stopped = FALSE; |
283 | if ( !current.isEmpty() ) { | 283 | if ( !current.isEmpty() ) { |
284 | Config cfg(current, Config::File); | 284 | Config cfg(current, Config::File); |
285 | cfg.setGroup("Info"); | 285 | cfg.setGroup("Info"); |
286 | QString type = cfg.readEntry("Type"); | 286 | QString type = cfg.readEntry("Type"); |
287 | NetworkInterface* plugin = Network::loadPlugin(type); | 287 | NetworkInterface* plugin = Network::loadPlugin(type); |
288 | if ( plugin ) { | 288 | if ( plugin ) { |
289 | cfg.setGroup("Properties"); | 289 | cfg.setGroup("Properties"); |
290 | if ( plugin->stop(cfg) ) { | 290 | if ( plugin->stop(cfg) ) { |
291 | current = QString::null; | 291 | current = QString::null; |
292 | wait=0; | 292 | wait=0; |
293 | startTimer(400); | 293 | startTimer(400); |
294 | stopped = TRUE; | 294 | stopped = TRUE; |
295 | } | 295 | } |
296 | } | 296 | } |
297 | } | 297 | } |
298 | if ( !stopped ) { | 298 | if ( !stopped ) { |
299 | QCopEnvelope("QPE/Network", "failed()"); | 299 | QCopEnvelope("QPE/Network", "failed()"); |
300 | } | 300 | } |
301 | } | 301 | } |
302 | 302 | ||
303 | void timerEvent(QTimerEvent*) | 303 | void timerEvent(QTimerEvent*) |
304 | { | 304 | { |
305 | examineNetworks(); | 305 | examineNetworks(); |
306 | if ( wait >= 0 ) { | 306 | if ( wait >= 0 ) { |
307 | if ( up == !current.isNull() ) { | 307 | if ( up == !current.isNull() ) { |
308 | // done | 308 | // done |
309 | killTimers(); | 309 | killTimers(); |
310 | if ( up ) { | 310 | if ( up ) { |
311 | startTimer(3000); // monitor link | 311 | startTimer(3000); // monitor link |
312 | wait = -1; | 312 | wait = -1; |
313 | } | 313 | } |
314 | } else { | 314 | } else { |
315 | wait++; | 315 | wait++; |
316 | if ( wait == 600 ) { | 316 | if ( wait == 600 ) { |
317 | killTimers(); // forget about it after 240 s | 317 | killTimers(); // forget about it after 240 s |
318 | QCopEnvelope("QPE/Network", "failed()"); | 318 | QCopEnvelope("QPE/Network", "failed()"); |
319 | up = !current.isNull(); | 319 | up = !current.isNull(); |
320 | } | 320 | } |
321 | } | 321 | } |
322 | } else if ( !up ) { | 322 | } else if ( !up ) { |
323 | killTimers(); | 323 | killTimers(); |
324 | } | 324 | } |
325 | } | 325 | } |
326 | 326 | ||
327 | private: | 327 | private: |
328 | QStringList available; | 328 | QStringList available; |
329 | QString current; | 329 | QString current; |
330 | bool up; | 330 | bool up; |
331 | int wait; | 331 | int wait; |
332 | }; | 332 | }; |
333 | 333 | ||
334 | static NetworkServer* ns=0; | 334 | static NetworkServer* ns=0; |
335 | 335 | ||
336 | /*! | 336 | /*! |
337 | \internal | 337 | \internal |
338 | */ | 338 | */ |
339 | QString Network::serviceName(const QString& service) | 339 | QString Network::serviceName(const QString& service) |
340 | { | 340 | { |
341 | Config cfg(service, Config::File); | 341 | Config cfg(service, Config::File); |
342 | cfg.setGroup("Info"); | 342 | cfg.setGroup("Info"); |
343 | return cfg.readEntry("Name"); | 343 | return cfg.readEntry("Name"); |
344 | } | 344 | } |
345 | 345 | ||
346 | /*! | 346 | /*! |
347 | \internal | 347 | \internal |
348 | */ | 348 | */ |
349 | QString Network::serviceType(const QString& service) | 349 | QString Network::serviceType(const QString& service) |
350 | { | 350 | { |
351 | Config cfg(service, Config::File); | 351 | Config cfg(service, Config::File); |
352 | cfg.setGroup("Info"); | 352 | cfg.setGroup("Info"); |
353 | return cfg.readEntry("Type"); | 353 | return cfg.readEntry("Type"); |
354 | } | 354 | } |
355 | 355 | ||
356 | /*! | 356 | /*! |
357 | \internal | 357 | \internal |
358 | */ | 358 | */ |
359 | bool Network::serviceNeedsPassword(const QString& service) | 359 | bool Network::serviceNeedsPassword(const QString& service) |
360 | { | 360 | { |
361 | Config cfg(service,Config::File); | 361 | Config cfg(service,Config::File); |
362 | cfg.setGroup("Info"); | 362 | cfg.setGroup("Info"); |
363 | QString type = cfg.readEntry("Type"); | 363 | QString type = cfg.readEntry("Type"); |
364 | NetworkInterface* plugin = Network::loadPlugin(type); | 364 | NetworkInterface* plugin = Network::loadPlugin(type); |
365 | cfg.setGroup("Properties"); | 365 | cfg.setGroup("Properties"); |
366 | return plugin ? plugin->needPassword(cfg) : FALSE; | 366 | return plugin ? plugin->needPassword(cfg) : FALSE; |
367 | } | 367 | } |
368 | 368 | ||
369 | /*! | 369 | /*! |
370 | \internal | 370 | \internal |
371 | */ | 371 | */ |
372 | bool Network::networkOnline() | 372 | bool Network::networkOnline() |
373 | { | 373 | { |
374 | return ns && ns->networkOnline(); | 374 | return ns && ns->networkOnline(); |
375 | } | 375 | } |
376 | 376 | ||
377 | /*! | 377 | /*! |
378 | \internal | 378 | \internal |
379 | */ | 379 | */ |
380 | void Network::createServer(QObject* parent) | 380 | void Network::createServer(QObject* parent) |
381 | { | 381 | { |
382 | ns = new NetworkServer(parent); | 382 | ns = new NetworkServer(parent); |
383 | } | 383 | } |
384 | 384 | ||
385 | /*! | 385 | /*! |
386 | \internal | 386 | \internal |
387 | */ | 387 | */ |
388 | int Network::addStateWidgets(QWidget* parent) | 388 | int Network::addStateWidgets(QWidget* parent) |
389 | { | 389 | { |
390 | int n=0; | 390 | int n=0; |
391 | QStringList l = Network::choices(); | 391 | QStringList l = Network::choices(); |
392 | QVBoxLayout* vb = new QVBoxLayout(parent); | 392 | QVBoxLayout* vb = new QVBoxLayout(parent); |
393 | for (QStringList::ConstIterator it=l.begin(); it!=l.end(); ++it) { | 393 | for (QStringList::ConstIterator it=l.begin(); it!=l.end(); ++it) { |
394 | Config cfg(*it,Config::File); | 394 | Config cfg(*it,Config::File); |
395 | cfg.setGroup("Info"); | 395 | cfg.setGroup("Info"); |
396 | QString type = cfg.readEntry("Type"); | 396 | QString type = cfg.readEntry("Type"); |
397 | NetworkInterface* plugin = Network::loadPlugin(type); | 397 | NetworkInterface* plugin = Network::loadPlugin(type); |
398 | cfg.setGroup("Properties"); | 398 | cfg.setGroup("Properties"); |
399 | if ( plugin ) { | 399 | if ( plugin ) { |
400 | QWidget* w; | 400 | QWidget* w; |
401 | if ( (w=plugin->addStateWidget(parent,cfg)) ) { | 401 | if ( (w=plugin->addStateWidget(parent,cfg)) ) { |
402 | n++; | 402 | n++; |
403 | vb->addWidget(w); | 403 | vb->addWidget(w); |
404 | } | 404 | } |
405 | } | 405 | } |
406 | } | 406 | } |
407 | return n; | 407 | return n; |
408 | } | 408 | } |
409 | 409 | ||
410 | static QDict<NetworkInterface> *ifaces; | 410 | static QDict<NetworkInterface> *ifaces; |
411 | 411 | ||
412 | /*! | 412 | /*! |
413 | \internal | 413 | \internal |
414 | */ | 414 | */ |
415 | NetworkInterface* Network::loadPlugin(const QString& type) | 415 | NetworkInterface* Network::loadPlugin(const QString& type) |
416 | { | 416 | { |
417 | #ifndef QT_NO_COMPONENT | 417 | #ifndef QT_NO_COMPONENT |
418 | if ( !ifaces ) ifaces = new QDict<NetworkInterface>; | 418 | if ( !ifaces ) ifaces = new QDict<NetworkInterface>; |
419 | NetworkInterface *iface = ifaces->find(type); | 419 | NetworkInterface *iface = ifaces->find(type); |
420 | if ( !iface ) { | 420 | if ( !iface ) { |
421 | #ifdef Q_OS_MACX | 421 | #ifdef Q_OS_MACX |
422 | QString libfile = QPEApplication::qpeDir() + "/plugins/network/lib" + type + ".dylib"; | 422 | QString libfile = QPEApplication::qpeDir() + "plugins/network/lib" + type + ".dylib"; |
423 | #else | 423 | #else |
424 | QString libfile = QPEApplication::qpeDir() + "/plugins/network/lib" + type + ".so"; | 424 | QString libfile = QPEApplication::qpeDir() + "plugins/network/lib" + type + ".so"; |
425 | #endif | 425 | #endif |
426 | QLibrary lib(libfile); | 426 | QLibrary lib(libfile); |
427 | if ( !lib.queryInterface( IID_Network, (QUnknownInterface**)&iface ) == QS_OK ) | 427 | if ( !lib.queryInterface( IID_Network, (QUnknownInterface**)&iface ) == QS_OK ) |
428 | return 0; | 428 | return 0; |
429 | ifaces->insert(type,iface); | 429 | ifaces->insert(type,iface); |
430 | QStringList langs = Global::languageList(); | 430 | QStringList langs = Global::languageList(); |
431 | for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { | 431 | for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { |
432 | QString lang = *it; | 432 | QString lang = *it; |
433 | QTranslator * trans = new QTranslator(qApp); | 433 | QTranslator * trans = new QTranslator(qApp); |
434 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/lib"+type+".qm"; | 434 | QString tfn = QPEApplication::qpeDir()+"i18n/"+lang+"/lib"+type+".qm"; |
435 | if ( trans->load( tfn )) | 435 | if ( trans->load( tfn )) |
436 | qApp->installTranslator( trans ); | 436 | qApp->installTranslator( trans ); |
437 | else | 437 | else |
438 | delete trans; | 438 | delete trans; |
439 | } | 439 | } |
440 | } | 440 | } |
441 | return iface; | 441 | return iface; |
442 | #else | 442 | #else |
443 | return 0; | 443 | return 0; |
444 | #endif | 444 | #endif |
445 | } | 445 | } |
446 | 446 | ||
447 | #include "network.moc" | 447 | #include "network.moc" |
448 | #endif// QT_NO_COP | 448 | #endif// QT_NO_COP |
diff --git a/library/qpedecoration_qws.cpp b/library/qpedecoration_qws.cpp index 7842ebd..8b02de6 100644 --- a/library/qpedecoration_qws.cpp +++ b/library/qpedecoration_qws.cpp | |||
@@ -1,967 +1,967 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the 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 | #ifdef QWS | 20 | #ifdef QWS |
21 | #define QTOPIA_INTERNAL_LANGLIST | 21 | #define QTOPIA_INTERNAL_LANGLIST |
22 | #include <qapplication.h> | 22 | #include <qapplication.h> |
23 | #include <qstyle.h> | 23 | #include <qstyle.h> |
24 | #include <qwidget.h> | 24 | #include <qwidget.h> |
25 | #include <qpainter.h> | 25 | #include <qpainter.h> |
26 | #include <qtimer.h> | 26 | #include <qtimer.h> |
27 | #include <qwhatsthis.h> | 27 | #include <qwhatsthis.h> |
28 | #include <qpopupmenu.h> | 28 | #include <qpopupmenu.h> |
29 | #include "qcopenvelope_qws.h" | 29 | #include "qcopenvelope_qws.h" |
30 | #include "qpedecoration_qws.h" | 30 | #include "qpedecoration_qws.h" |
31 | #include <qdialog.h> | 31 | #include <qdialog.h> |
32 | #include <qdrawutil.h> | 32 | #include <qdrawutil.h> |
33 | #include <qgfx_qws.h> | 33 | #include <qgfx_qws.h> |
34 | #include "qpeapplication.h" | 34 | #include "qpeapplication.h" |
35 | #include "resource.h" | 35 | #include "resource.h" |
36 | #include "global.h" | 36 | #include "global.h" |
37 | #include "qlibrary.h" | 37 | #include "qlibrary.h" |
38 | #include "windowdecorationinterface.h" | 38 | #include "windowdecorationinterface.h" |
39 | #include <qpe/qlibrary.h> | 39 | #include <qpe/qlibrary.h> |
40 | #include <qfile.h> | 40 | #include <qfile.h> |
41 | #include <qsignal.h> | 41 | #include <qsignal.h> |
42 | 42 | ||
43 | #include <stdlib.h> | 43 | #include <stdlib.h> |
44 | 44 | ||
45 | extern Q_EXPORT QRect qt_maxWindowRect; | 45 | extern Q_EXPORT QRect qt_maxWindowRect; |
46 | 46 | ||
47 | #define WHATSTHIS_MODE | 47 | #define WHATSTHIS_MODE |
48 | 48 | ||
49 | #ifndef QT_NO_QWS_QPE_WM_STYLE | 49 | #ifndef QT_NO_QWS_QPE_WM_STYLE |
50 | 50 | ||
51 | #ifndef QT_NO_IMAGEIO_XPM | 51 | #ifndef QT_NO_IMAGEIO_XPM |
52 | 52 | ||
53 | /* XPM */ | 53 | /* XPM */ |
54 | static const char * const qpe_close_xpm[] = { | 54 | static const char * const qpe_close_xpm[] = { |
55 | "16 16 3 1", | 55 | "16 16 3 1", |
56 | " c None", | 56 | " c None", |
57 | ". c #FFFFFF", | 57 | ". c #FFFFFF", |
58 | "+ c #000000", | 58 | "+ c #000000", |
59 | " ", | 59 | " ", |
60 | " ", | 60 | " ", |
61 | " ..... ", | 61 | " ..... ", |
62 | " ..+++++.. ", | 62 | " ..+++++.. ", |
63 | " .+++++++++. ", | 63 | " .+++++++++. ", |
64 | " .+..+++..+. ", | 64 | " .+..+++..+. ", |
65 | " .++...+...++. ", | 65 | " .++...+...++. ", |
66 | " .+++.....+++. ", | 66 | " .+++.....+++. ", |
67 | " .++++...++++. ", | 67 | " .++++...++++. ", |
68 | " .+++.....+++. ", | 68 | " .+++.....+++. ", |
69 | " .++...+...++. ", | 69 | " .++...+...++. ", |
70 | " .+..+++..+. ", | 70 | " .+..+++..+. ", |
71 | " .+++++++++. ", | 71 | " .+++++++++. ", |
72 | " ..+++++.. ", | 72 | " ..+++++.. ", |
73 | " ..... ", | 73 | " ..... ", |
74 | " "}; | 74 | " "}; |
75 | 75 | ||
76 | /* XPM */ | 76 | /* XPM */ |
77 | static const char * const qpe_accept_xpm[] = { | 77 | static const char * const qpe_accept_xpm[] = { |
78 | "16 16 3 1", | 78 | "16 16 3 1", |
79 | " c None", | 79 | " c None", |
80 | ". c #FFFFFF", | 80 | ". c #FFFFFF", |
81 | "+ c #000000", | 81 | "+ c #000000", |
82 | " ", | 82 | " ", |
83 | " ", | 83 | " ", |
84 | " ..... ", | 84 | " ..... ", |
85 | " ..+++++.. ", | 85 | " ..+++++.. ", |
86 | " .+++++++++. ", | 86 | " .+++++++++. ", |
87 | " .+++++++++. ", | 87 | " .+++++++++. ", |
88 | " .+++++++..++. ", | 88 | " .+++++++..++. ", |
89 | " .++.+++...++. ", | 89 | " .++.+++...++. ", |
90 | " .+...+...+++. ", | 90 | " .+...+...+++. ", |
91 | " .+......++++. ", | 91 | " .+......++++. ", |
92 | " .++....+++++. ", | 92 | " .++....+++++. ", |
93 | " .++..+++++. ", | 93 | " .++..+++++. ", |
94 | " .+++++++++. ", | 94 | " .+++++++++. ", |
95 | " ..+++++.. ", | 95 | " ..+++++.. ", |
96 | " ..... ", | 96 | " ..... ", |
97 | " "}; | 97 | " "}; |
98 | 98 | ||
99 | #endif // QT_NO_IMAGEIO_XPM | 99 | #endif // QT_NO_IMAGEIO_XPM |
100 | 100 | ||
101 | class DecorHackWidget : public QWidget | 101 | class DecorHackWidget : public QWidget |
102 | { | 102 | { |
103 | public: | 103 | public: |
104 | bool needsOk() { | 104 | bool needsOk() { |
105 | return (getWState() & WState_Reserved1 ) || | 105 | return (getWState() & WState_Reserved1 ) || |
106 | (inherits("QDialog") && !inherits("QMessageBox") | 106 | (inherits("QDialog") && !inherits("QMessageBox") |
107 | && !inherits("QWizard") ); | 107 | && !inherits("QWizard") ); |
108 | } | 108 | } |
109 | }; | 109 | }; |
110 | 110 | ||
111 | static QImage scaleButton( const QImage &img, int height ) | 111 | static QImage scaleButton( const QImage &img, int height ) |
112 | { | 112 | { |
113 | if ( img.height() != 0 && img.height() != height ) { | 113 | if ( img.height() != 0 && img.height() != height ) { |
114 | return img.smoothScale( img.width()*height/img.height(), height ); | 114 | return img.smoothScale( img.width()*height/img.height(), height ); |
115 | } else { | 115 | } else { |
116 | return img; | 116 | return img; |
117 | } | 117 | } |
118 | } | 118 | } |
119 | 119 | ||
120 | class TLWidget : public QWidget | 120 | class TLWidget : public QWidget |
121 | { | 121 | { |
122 | public: | 122 | public: |
123 | QWSManager *manager() | 123 | QWSManager *manager() |
124 | { | 124 | { |
125 | return topData()->qwsManager; | 125 | return topData()->qwsManager; |
126 | } | 126 | } |
127 | 127 | ||
128 | QTLWExtra *topExtra() | 128 | QTLWExtra *topExtra() |
129 | { | 129 | { |
130 | return topData(); | 130 | return topData(); |
131 | } | 131 | } |
132 | 132 | ||
133 | void setWState( uint s ) { QWidget::setWState( s ); } | 133 | void setWState( uint s ) { QWidget::setWState( s ); } |
134 | void clearWState( uint s ) { QWidget::clearWState( s ); } | 134 | void clearWState( uint s ) { QWidget::clearWState( s ); } |
135 | }; | 135 | }; |
136 | 136 | ||
137 | 137 | ||
138 | QPEManager::QPEManager( QPEDecoration *d, QObject *parent ) | 138 | QPEManager::QPEManager( QPEDecoration *d, QObject *parent ) |
139 | : QObject( parent ), decoration( d ), helpState(0), inWhatsThis(FALSE) | 139 | : QObject( parent ), decoration( d ), helpState(0), inWhatsThis(FALSE) |
140 | { | 140 | { |
141 | wtTimer = new QTimer( this ); | 141 | wtTimer = new QTimer( this ); |
142 | connect( wtTimer, SIGNAL(timeout()), this, SLOT(whatsThisTimeout()) ); | 142 | connect( wtTimer, SIGNAL(timeout()), this, SLOT(whatsThisTimeout()) ); |
143 | } | 143 | } |
144 | 144 | ||
145 | 145 | ||
146 | void QPEManager::updateActive() | 146 | void QPEManager::updateActive() |
147 | { | 147 | { |
148 | QWidget *newActive = qApp->activeWindow(); | 148 | QWidget *newActive = qApp->activeWindow(); |
149 | if ( newActive && (QWidget*)active == newActive ) | 149 | if ( newActive && (QWidget*)active == newActive ) |
150 | return; | 150 | return; |
151 | 151 | ||
152 | if ( active && (!newActive || ((TLWidget *)newActive)->manager()) ) { | 152 | if ( active && (!newActive || ((TLWidget *)newActive)->manager()) ) { |
153 | ((TLWidget *)(QWidget*)active)->manager()->removeEventFilter( this ); | 153 | ((TLWidget *)(QWidget*)active)->manager()->removeEventFilter( this ); |
154 | } | 154 | } |
155 | 155 | ||
156 | if ( newActive && ((TLWidget *)newActive)->manager() ) { | 156 | if ( newActive && ((TLWidget *)newActive)->manager() ) { |
157 | active = newActive; | 157 | active = newActive; |
158 | ((TLWidget *)(QWidget*)active)->manager()->installEventFilter( this ); | 158 | ((TLWidget *)(QWidget*)active)->manager()->installEventFilter( this ); |
159 | } else if ( !newActive ) { | 159 | } else if ( !newActive ) { |
160 | active = 0; | 160 | active = 0; |
161 | } | 161 | } |
162 | } | 162 | } |
163 | 163 | ||
164 | int QPEManager::pointInQpeRegion( QWidget *w, const QPoint &p ) | 164 | int QPEManager::pointInQpeRegion( QWidget *w, const QPoint &p ) |
165 | { | 165 | { |
166 | QRect rect(w->geometry()); | 166 | QRect rect(w->geometry()); |
167 | 167 | ||
168 | if ( decoration->region( w, rect, | 168 | if ( decoration->region( w, rect, |
169 | (QWSDecoration::Region)QPEDecoration::Help ).contains(p) ) | 169 | (QWSDecoration::Region)QPEDecoration::Help ).contains(p) ) |
170 | return QPEDecoration::Help; | 170 | return QPEDecoration::Help; |
171 | 171 | ||
172 | for (int i = QWSDecoration::LastRegion; i >= QWSDecoration::Title; i--) { | 172 | for (int i = QWSDecoration::LastRegion; i >= QWSDecoration::Title; i--) { |
173 | if (decoration->region(w, rect, (QWSDecoration::Region)i).contains(p)) | 173 | if (decoration->region(w, rect, (QWSDecoration::Region)i).contains(p)) |
174 | return (QWSDecoration::Region)i; | 174 | return (QWSDecoration::Region)i; |
175 | } | 175 | } |
176 | 176 | ||
177 | return QWSDecoration::None; | 177 | return QWSDecoration::None; |
178 | } | 178 | } |
179 | 179 | ||
180 | bool QPEManager::eventFilter( QObject *o, QEvent *e ) | 180 | bool QPEManager::eventFilter( QObject *o, QEvent *e ) |
181 | { | 181 | { |
182 | QWSManager *mgr = (QWSManager *)o; | 182 | QWSManager *mgr = (QWSManager *)o; |
183 | QWidget *w = mgr->widget(); | 183 | QWidget *w = mgr->widget(); |
184 | switch ( e->type() ) { | 184 | switch ( e->type() ) { |
185 | case QEvent::MouseButtonPress: | 185 | case QEvent::MouseButtonPress: |
186 | { | 186 | { |
187 | pressTime = QTime::currentTime(); | 187 | pressTime = QTime::currentTime(); |
188 | QPoint p = ((QMouseEvent*)e)->globalPos(); | 188 | QPoint p = ((QMouseEvent*)e)->globalPos(); |
189 | int inRegion = pointInQpeRegion( w, p ); | 189 | int inRegion = pointInQpeRegion( w, p ); |
190 | #ifdef WHATSTHIS_MODE | 190 | #ifdef WHATSTHIS_MODE |
191 | if ( !w->geometry().contains(p) && QWhatsThis::inWhatsThisMode() ) { | 191 | if ( !w->geometry().contains(p) && QWhatsThis::inWhatsThisMode() ) { |
192 | QString text; | 192 | QString text; |
193 | switch ( inRegion ) { | 193 | switch ( inRegion ) { |
194 | case QWSDecoration::Close: | 194 | case QWSDecoration::Close: |
195 | if ( ((DecorHackWidget*)w)->needsOk() ) | 195 | if ( ((DecorHackWidget*)w)->needsOk() ) |
196 | text = tr("Click to close this window, discarding changes."); | 196 | text = tr("Click to close this window, discarding changes."); |
197 | else | 197 | else |
198 | text = tr("Click to close this window."); | 198 | text = tr("Click to close this window."); |
199 | break; | 199 | break; |
200 | case QWSDecoration::Minimize: | 200 | case QWSDecoration::Minimize: |
201 | text = tr("Click to close this window and apply changes."); | 201 | text = tr("Click to close this window and apply changes."); |
202 | break; | 202 | break; |
203 | case QWSDecoration::Maximize: | 203 | case QWSDecoration::Maximize: |
204 | if ( w->isMaximized() ) | 204 | if ( w->isMaximized() ) |
205 | text = tr("Click to make this window movable."); | 205 | text = tr("Click to make this window movable."); |
206 | else | 206 | else |
207 | text = tr("Click to make this window use all available screen area."); | 207 | text = tr("Click to make this window use all available screen area."); |
208 | break; | 208 | break; |
209 | default: | 209 | default: |
210 | break; | 210 | break; |
211 | } | 211 | } |
212 | QWhatsThis::leaveWhatsThisMode( text ); | 212 | QWhatsThis::leaveWhatsThisMode( text ); |
213 | whatsThisTimeout(); | 213 | whatsThisTimeout(); |
214 | helpState = 0; | 214 | helpState = 0; |
215 | return true; | 215 | return true; |
216 | } | 216 | } |
217 | #endif | 217 | #endif |
218 | if ( inRegion == QPEDecoration::Help ) { | 218 | if ( inRegion == QPEDecoration::Help ) { |
219 | #ifdef WHATSTHIS_MODE | 219 | #ifdef WHATSTHIS_MODE |
220 | wtTimer->start( 400, TRUE ); | 220 | wtTimer->start( 400, TRUE ); |
221 | #endif | 221 | #endif |
222 | helpState = QWSButton::Clicked|QWSButton::MouseOver; | 222 | helpState = QWSButton::Clicked|QWSButton::MouseOver; |
223 | drawButton( w, QPEDecoration::Help, helpState ); | 223 | drawButton( w, QPEDecoration::Help, helpState ); |
224 | return true; | 224 | return true; |
225 | } | 225 | } |
226 | } | 226 | } |
227 | break; | 227 | break; |
228 | case QEvent::MouseButtonRelease: | 228 | case QEvent::MouseButtonRelease: |
229 | if ( helpState & QWSButton::Clicked ) { | 229 | if ( helpState & QWSButton::Clicked ) { |
230 | wtTimer->stop(); | 230 | wtTimer->stop(); |
231 | helpState = 0; | 231 | helpState = 0; |
232 | drawButton( w, QPEDecoration::Help, helpState ); | 232 | drawButton( w, QPEDecoration::Help, helpState ); |
233 | QPoint p = ((QMouseEvent*)e)->globalPos(); | 233 | QPoint p = ((QMouseEvent*)e)->globalPos(); |
234 | if ( pointInQpeRegion( w, p ) == QPEDecoration::Help ) { | 234 | if ( pointInQpeRegion( w, p ) == QPEDecoration::Help ) { |
235 | decoration->help( w ); | 235 | decoration->help( w ); |
236 | } | 236 | } |
237 | return true; | 237 | return true; |
238 | } | 238 | } |
239 | break; | 239 | break; |
240 | case QEvent::MouseMove: | 240 | case QEvent::MouseMove: |
241 | if ( helpState & QWSButton::Clicked ) { | 241 | if ( helpState & QWSButton::Clicked ) { |
242 | int oldState = helpState; | 242 | int oldState = helpState; |
243 | QPoint p = ((QMouseEvent*)e)->globalPos(); | 243 | QPoint p = ((QMouseEvent*)e)->globalPos(); |
244 | if ( pointInQpeRegion( w, p ) == QPEDecoration::Help ) { | 244 | if ( pointInQpeRegion( w, p ) == QPEDecoration::Help ) { |
245 | helpState = QWSButton::Clicked|QWSButton::MouseOver; | 245 | helpState = QWSButton::Clicked|QWSButton::MouseOver; |
246 | } else { | 246 | } else { |
247 | helpState = 0; | 247 | helpState = 0; |
248 | } | 248 | } |
249 | if ( helpState != oldState ) | 249 | if ( helpState != oldState ) |
250 | drawButton( w, QPEDecoration::Help, helpState ); | 250 | drawButton( w, QPEDecoration::Help, helpState ); |
251 | } | 251 | } |
252 | break; | 252 | break; |
253 | default: | 253 | default: |
254 | break; | 254 | break; |
255 | } | 255 | } |
256 | return QObject::eventFilter( o, e ); | 256 | return QObject::eventFilter( o, e ); |
257 | } | 257 | } |
258 | 258 | ||
259 | void QPEManager::drawButton( QWidget *w, QPEDecoration::QPERegion r, int state ) | 259 | void QPEManager::drawButton( QWidget *w, QPEDecoration::QPERegion r, int state ) |
260 | { | 260 | { |
261 | QPainter painter(w); | 261 | QPainter painter(w); |
262 | QRegion rgn = ((TLWidget *)w)->topExtra()->decor_allocated_region; | 262 | QRegion rgn = ((TLWidget *)w)->topExtra()->decor_allocated_region; |
263 | painter.internalGfx()->setWidgetDeviceRegion( rgn ); | 263 | painter.internalGfx()->setWidgetDeviceRegion( rgn ); |
264 | painter.setClipRegion(decoration->region(w, w->rect(),QWSDecoration::All)); | 264 | painter.setClipRegion(decoration->region(w, w->rect(),QWSDecoration::All)); |
265 | decoration->paintButton( &painter, w, (QWSDecoration::Region)r, state ); | 265 | decoration->paintButton( &painter, w, (QWSDecoration::Region)r, state ); |
266 | } | 266 | } |
267 | 267 | ||
268 | void QPEManager::drawTitle( QWidget *w ) | 268 | void QPEManager::drawTitle( QWidget *w ) |
269 | { | 269 | { |
270 | QPainter painter(w); | 270 | QPainter painter(w); |
271 | QRegion rgn = ((TLWidget *)w)->topExtra()->decor_allocated_region; | 271 | QRegion rgn = ((TLWidget *)w)->topExtra()->decor_allocated_region; |
272 | painter.internalGfx()->setWidgetDeviceRegion( rgn ); | 272 | painter.internalGfx()->setWidgetDeviceRegion( rgn ); |
273 | painter.setClipRegion(decoration->region(w, w->rect(),QWSDecoration::All)); | 273 | painter.setClipRegion(decoration->region(w, w->rect(),QWSDecoration::All)); |
274 | decoration->paint( &painter, w ); | 274 | decoration->paint( &painter, w ); |
275 | decoration->paintButton(&painter, w, QWSDecoration::Menu, 0); | 275 | decoration->paintButton(&painter, w, QWSDecoration::Menu, 0); |
276 | decoration->paintButton(&painter, w, QWSDecoration::Close, 0); | 276 | decoration->paintButton(&painter, w, QWSDecoration::Close, 0); |
277 | decoration->paintButton(&painter, w, QWSDecoration::Minimize, 0); | 277 | decoration->paintButton(&painter, w, QWSDecoration::Minimize, 0); |
278 | decoration->paintButton(&painter, w, QWSDecoration::Maximize, 0); | 278 | decoration->paintButton(&painter, w, QWSDecoration::Maximize, 0); |
279 | } | 279 | } |
280 | 280 | ||
281 | void QPEManager::whatsThisTimeout() | 281 | void QPEManager::whatsThisTimeout() |
282 | { | 282 | { |
283 | if ( !QWhatsThis::inWhatsThisMode() ) { | 283 | if ( !QWhatsThis::inWhatsThisMode() ) { |
284 | if ( inWhatsThis ) { | 284 | if ( inWhatsThis ) { |
285 | if ( whatsThis ) { | 285 | if ( whatsThis ) { |
286 | QWidget *w = whatsThis; | 286 | QWidget *w = whatsThis; |
287 | whatsThis = 0; | 287 | whatsThis = 0; |
288 | drawTitle( w ); | 288 | drawTitle( w ); |
289 | } | 289 | } |
290 | wtTimer->stop(); | 290 | wtTimer->stop(); |
291 | } else { | 291 | } else { |
292 | QWhatsThis::enterWhatsThisMode(); | 292 | QWhatsThis::enterWhatsThisMode(); |
293 | helpState = 0; | 293 | helpState = 0; |
294 | updateActive(); | 294 | updateActive(); |
295 | if ( active ) { | 295 | if ( active ) { |
296 | whatsThis = active; | 296 | whatsThis = active; |
297 | drawTitle( active ); | 297 | drawTitle( active ); |
298 | // check periodically to see if we've left whats this mode | 298 | // check periodically to see if we've left whats this mode |
299 | wtTimer->start( 250 ); | 299 | wtTimer->start( 250 ); |
300 | } | 300 | } |
301 | } | 301 | } |
302 | inWhatsThis = !inWhatsThis; | 302 | inWhatsThis = !inWhatsThis; |
303 | } | 303 | } |
304 | } | 304 | } |
305 | 305 | ||
306 | //=========================================================================== | 306 | //=========================================================================== |
307 | 307 | ||
308 | static QImage *okImage( int th ) | 308 | static QImage *okImage( int th ) |
309 | { | 309 | { |
310 | static QImage *i = 0; | 310 | static QImage *i = 0; |
311 | if ( !i || i->height() != th ) { | 311 | if ( !i || i->height() != th ) { |
312 | delete i; | 312 | delete i; |
313 | i = new QImage(scaleButton(Resource::loadImage("OKButton"),th)); | 313 | i = new QImage(scaleButton(Resource::loadImage("OKButton"),th)); |
314 | } | 314 | } |
315 | return i; | 315 | return i; |
316 | } | 316 | } |
317 | 317 | ||
318 | static QImage *closeImage( int th ) | 318 | static QImage *closeImage( int th ) |
319 | { | 319 | { |
320 | static QImage *i = 0; | 320 | static QImage *i = 0; |
321 | if ( !i || i->height() != th ) { | 321 | if ( !i || i->height() != th ) { |
322 | delete i; | 322 | delete i; |
323 | i = new QImage(scaleButton(Resource::loadImage("CloseButton"),th)); | 323 | i = new QImage(scaleButton(Resource::loadImage("CloseButton"),th)); |
324 | } | 324 | } |
325 | return i; | 325 | return i; |
326 | } | 326 | } |
327 | 327 | ||
328 | static QImage *helpImage( int th ) | 328 | static QImage *helpImage( int th ) |
329 | { | 329 | { |
330 | static QImage *i = 0; | 330 | static QImage *i = 0; |
331 | if ( !i || i->height() != th ) { | 331 | if ( !i || i->height() != th ) { |
332 | delete i; | 332 | delete i; |
333 | i = new QImage(scaleButton(Resource::loadImage("HelpButton"),th)); | 333 | i = new QImage(scaleButton(Resource::loadImage("HelpButton"),th)); |
334 | } | 334 | } |
335 | return i; | 335 | return i; |
336 | } | 336 | } |
337 | 337 | ||
338 | static QImage *maximizeImage( int th ) | 338 | static QImage *maximizeImage( int th ) |
339 | { | 339 | { |
340 | static QImage *i = 0; | 340 | static QImage *i = 0; |
341 | if ( !i || i->height() != th ) { | 341 | if ( !i || i->height() != th ) { |
342 | delete i; | 342 | delete i; |
343 | i = new QImage(scaleButton(Resource::loadImage("MaximizeButton"),th)); | 343 | i = new QImage(scaleButton(Resource::loadImage("MaximizeButton"),th)); |
344 | } | 344 | } |
345 | return i; | 345 | return i; |
346 | } | 346 | } |
347 | 347 | ||
348 | int WindowDecorationInterface::metric( Metric m, const WindowData *wd ) const | 348 | int WindowDecorationInterface::metric( Metric m, const WindowData *wd ) const |
349 | { | 349 | { |
350 | switch ( m ) { | 350 | switch ( m ) { |
351 | case TitleHeight: | 351 | case TitleHeight: |
352 | if ( QApplication::desktop()->height() > 320 ) | 352 | if ( QApplication::desktop()->height() > 320 ) |
353 | return 19; | 353 | return 19; |
354 | else | 354 | else |
355 | return 15; | 355 | return 15; |
356 | case LeftBorder: | 356 | case LeftBorder: |
357 | case RightBorder: | 357 | case RightBorder: |
358 | case TopBorder: | 358 | case TopBorder: |
359 | case BottomBorder: | 359 | case BottomBorder: |
360 | return 4; | 360 | return 4; |
361 | case OKWidth: | 361 | case OKWidth: |
362 | return okImage(metric(TitleHeight,wd))->width(); | 362 | return okImage(metric(TitleHeight,wd))->width(); |
363 | case CloseWidth: | 363 | case CloseWidth: |
364 | return closeImage(metric(TitleHeight,wd))->width(); | 364 | return closeImage(metric(TitleHeight,wd))->width(); |
365 | case HelpWidth: | 365 | case HelpWidth: |
366 | return helpImage(metric(TitleHeight,wd))->width(); | 366 | return helpImage(metric(TitleHeight,wd))->width(); |
367 | case MaximizeWidth: | 367 | case MaximizeWidth: |
368 | return maximizeImage(metric(TitleHeight,wd))->width(); | 368 | return maximizeImage(metric(TitleHeight,wd))->width(); |
369 | case CornerGrabSize: | 369 | case CornerGrabSize: |
370 | return 16; | 370 | return 16; |
371 | } | 371 | } |
372 | 372 | ||
373 | return 0; | 373 | return 0; |
374 | } | 374 | } |
375 | 375 | ||
376 | void WindowDecorationInterface::drawArea( Area a, QPainter *p, const WindowData *wd ) const | 376 | void WindowDecorationInterface::drawArea( Area a, QPainter *p, const WindowData *wd ) const |
377 | { | 377 | { |
378 | int th = metric( TitleHeight, wd ); | 378 | int th = metric( TitleHeight, wd ); |
379 | QRect r = wd->rect; | 379 | QRect r = wd->rect; |
380 | 380 | ||
381 | switch ( a ) { | 381 | switch ( a ) { |
382 | case Border: | 382 | case Border: |
383 | { | 383 | { |
384 | const QColorGroup &cg = wd->palette.active(); | 384 | const QColorGroup &cg = wd->palette.active(); |
385 | qDrawWinPanel(p, r.x()-metric(LeftBorder,wd), | 385 | qDrawWinPanel(p, r.x()-metric(LeftBorder,wd), |
386 | r.y()-th-metric(TopBorder,wd), | 386 | r.y()-th-metric(TopBorder,wd), |
387 | r.width()+metric(LeftBorder,wd)+metric(RightBorder,wd), | 387 | r.width()+metric(LeftBorder,wd)+metric(RightBorder,wd), |
388 | r.height()+th+metric(TopBorder,wd)+metric(BottomBorder,wd), | 388 | r.height()+th+metric(TopBorder,wd)+metric(BottomBorder,wd), |
389 | cg, FALSE, &cg.brush(QColorGroup::Background)); | 389 | cg, FALSE, &cg.brush(QColorGroup::Background)); |
390 | } | 390 | } |
391 | break; | 391 | break; |
392 | case Title: | 392 | case Title: |
393 | { | 393 | { |
394 | const QColorGroup &cg = wd->palette.active(); | 394 | const QColorGroup &cg = wd->palette.active(); |
395 | QBrush titleBrush; | 395 | QBrush titleBrush; |
396 | QPen titleLines; | 396 | QPen titleLines; |
397 | 397 | ||
398 | if ( wd->flags & WindowData::Active ) { | 398 | if ( wd->flags & WindowData::Active ) { |
399 | titleBrush = cg.brush(QColorGroup::Highlight); | 399 | titleBrush = cg.brush(QColorGroup::Highlight); |
400 | titleLines = titleBrush.color().dark(); | 400 | titleLines = titleBrush.color().dark(); |
401 | } else { | 401 | } else { |
402 | titleBrush = cg.brush(QColorGroup::Background); | 402 | titleBrush = cg.brush(QColorGroup::Background); |
403 | titleLines = titleBrush.color(); | 403 | titleLines = titleBrush.color(); |
404 | } | 404 | } |
405 | 405 | ||
406 | p->fillRect( r.x(), r.y()-th, r.width(), th, titleBrush); | 406 | p->fillRect( r.x(), r.y()-th, r.width(), th, titleBrush); |
407 | 407 | ||
408 | p->setPen( titleLines ); | 408 | p->setPen( titleLines ); |
409 | for ( int i = r.y()-th; i < r.y(); i += 2 ) | 409 | for ( int i = r.y()-th; i < r.y(); i += 2 ) |
410 | p->drawLine( r.left(), i, r.right(), i ); | 410 | p->drawLine( r.left(), i, r.right(), i ); |
411 | } | 411 | } |
412 | break; | 412 | break; |
413 | case TitleText: | 413 | case TitleText: |
414 | p->drawText( r.x()+3+metric(HelpWidth,wd), r.top()-th, | 414 | p->drawText( r.x()+3+metric(HelpWidth,wd), r.top()-th, |
415 | r.width()-metric(OKWidth,wd)-metric(CloseWidth,wd), | 415 | r.width()-metric(OKWidth,wd)-metric(CloseWidth,wd), |
416 | th, QPainter::AlignVCenter, wd->caption); | 416 | th, QPainter::AlignVCenter, wd->caption); |
417 | break; | 417 | break; |
418 | } | 418 | } |
419 | } | 419 | } |
420 | 420 | ||
421 | void WindowDecorationInterface::drawButton( Button b, QPainter *p, const WindowData *wd, int x, int y, int, int, QWSButton::State state ) const | 421 | void WindowDecorationInterface::drawButton( Button b, QPainter *p, const WindowData *wd, int x, int y, int, int, QWSButton::State state ) const |
422 | { | 422 | { |
423 | QImage *img = 0; | 423 | QImage *img = 0; |
424 | switch ( b ) { | 424 | switch ( b ) { |
425 | case OK: | 425 | case OK: |
426 | img = okImage(metric(TitleHeight,wd)); | 426 | img = okImage(metric(TitleHeight,wd)); |
427 | break; | 427 | break; |
428 | case Close: | 428 | case Close: |
429 | img = closeImage(metric(TitleHeight,wd)); | 429 | img = closeImage(metric(TitleHeight,wd)); |
430 | break; | 430 | break; |
431 | case Help: | 431 | case Help: |
432 | img = helpImage(metric(TitleHeight,wd)); | 432 | img = helpImage(metric(TitleHeight,wd)); |
433 | break; | 433 | break; |
434 | case Maximize: | 434 | case Maximize: |
435 | img = maximizeImage(metric(TitleHeight,wd)); | 435 | img = maximizeImage(metric(TitleHeight,wd)); |
436 | break; | 436 | break; |
437 | } | 437 | } |
438 | 438 | ||
439 | if ( img ) { | 439 | if ( img ) { |
440 | if ((state & QWSButton::MouseOver) && (state & QWSButton::Clicked)) | 440 | if ((state & QWSButton::MouseOver) && (state & QWSButton::Clicked)) |
441 | p->drawImage(x+2, y+2, *img); | 441 | p->drawImage(x+2, y+2, *img); |
442 | else | 442 | else |
443 | p->drawImage(x+1, y+1, *img); | 443 | p->drawImage(x+1, y+1, *img); |
444 | } | 444 | } |
445 | } | 445 | } |
446 | 446 | ||
447 | QRegion WindowDecorationInterface::mask( const WindowData *wd ) const | 447 | QRegion WindowDecorationInterface::mask( const WindowData *wd ) const |
448 | { | 448 | { |
449 | int th = metric(TitleHeight,wd); | 449 | int th = metric(TitleHeight,wd); |
450 | QRect rect( wd->rect ); | 450 | QRect rect( wd->rect ); |
451 | QRect r(rect.left() - metric(LeftBorder,wd), | 451 | QRect r(rect.left() - metric(LeftBorder,wd), |
452 | rect.top() - th - metric(TopBorder,wd), | 452 | rect.top() - th - metric(TopBorder,wd), |
453 | rect.width() + metric(LeftBorder,wd) + metric(RightBorder,wd), | 453 | rect.width() + metric(LeftBorder,wd) + metric(RightBorder,wd), |
454 | rect.height() + th + metric(TopBorder,wd) + metric(BottomBorder,wd)); | 454 | rect.height() + th + metric(TopBorder,wd) + metric(BottomBorder,wd)); |
455 | return QRegion(r) - rect; | 455 | return QRegion(r) - rect; |
456 | } | 456 | } |
457 | 457 | ||
458 | class DefaultWindowDecoration : public WindowDecorationInterface | 458 | class DefaultWindowDecoration : public WindowDecorationInterface |
459 | { | 459 | { |
460 | public: | 460 | public: |
461 | DefaultWindowDecoration(){} | 461 | DefaultWindowDecoration(){} |
462 | QString name() const { | 462 | QString name() const { |
463 | return qApp->translate("WindowDecoration", "Default", | 463 | return qApp->translate("WindowDecoration", "Default", |
464 | "List box text for default window decoration"); | 464 | "List box text for default window decoration"); |
465 | } | 465 | } |
466 | QPixmap icon() const { | 466 | QPixmap icon() const { |
467 | return QPixmap(); | 467 | return QPixmap(); |
468 | } | 468 | } |
469 | QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { | 469 | QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { |
470 | *iface = 0; | 470 | *iface = 0; |
471 | if ( uuid == IID_QUnknown ) | 471 | if ( uuid == IID_QUnknown ) |
472 | *iface = this; | 472 | *iface = this; |
473 | else if ( uuid == IID_WindowDecoration ) | 473 | else if ( uuid == IID_WindowDecoration ) |
474 | *iface = this; | 474 | *iface = this; |
475 | else | 475 | else |
476 | return QS_FALSE; | 476 | return QS_FALSE; |
477 | 477 | ||
478 | if ( *iface ) | 478 | if ( *iface ) |
479 | (*iface)->addRef(); | 479 | (*iface)->addRef(); |
480 | return QS_OK; | 480 | return QS_OK; |
481 | } | 481 | } |
482 | Q_REFCOUNT | 482 | Q_REFCOUNT |
483 | 483 | ||
484 | }; | 484 | }; |
485 | 485 | ||
486 | static WindowDecorationInterface *wdiface = 0; | 486 | static WindowDecorationInterface *wdiface = 0; |
487 | static QLibrary* wdlib = 0; | 487 | static QLibrary* wdlib = 0; |
488 | static QString libname; | 488 | static QString libname; |
489 | 489 | ||
490 | //=========================================================================== | 490 | //=========================================================================== |
491 | bool QPEDecoration::helpExists() const | 491 | bool QPEDecoration::helpExists() const |
492 | { | 492 | { |
493 | if ( helpFile.isNull() ) { | 493 | if ( helpFile.isNull() ) { |
494 | QStringList helpPath = Global::helpPath(); | 494 | QStringList helpPath = Global::helpPath(); |
495 | QString hf = QString(qApp->argv()[0]) + ".html"; | 495 | QString hf = QString(qApp->argv()[0]) + ".html"; |
496 | bool he = FALSE; | 496 | bool he = FALSE; |
497 | for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !he; ++it) | 497 | for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !he; ++it) |
498 | he = QFile::exists( *it + "/" + hf ); | 498 | he = QFile::exists( *it + "/" + hf ); |
499 | ((QPEDecoration*)this)->helpFile = hf; | 499 | ((QPEDecoration*)this)->helpFile = hf; |
500 | ((QPEDecoration*)this)->helpexists = he; | 500 | ((QPEDecoration*)this)->helpexists = he; |
501 | return he; | 501 | return he; |
502 | } | 502 | } |
503 | return helpexists; | 503 | return helpexists; |
504 | } | 504 | } |
505 | 505 | ||
506 | QPEDecoration::QPEDecoration() | 506 | QPEDecoration::QPEDecoration() |
507 | : QWSDefaultDecoration() | 507 | : QWSDefaultDecoration() |
508 | { | 508 | { |
509 | if ( wdlib ) { | 509 | if ( wdlib ) { |
510 | delete wdlib; | 510 | delete wdlib; |
511 | wdlib = 0; | 511 | wdlib = 0; |
512 | } else { | 512 | } else { |
513 | delete wdiface; | 513 | delete wdiface; |
514 | } | 514 | } |
515 | wdiface = new DefaultWindowDecoration; | 515 | wdiface = new DefaultWindowDecoration; |
516 | 516 | ||
517 | helpexists = FALSE; // We don't know (flagged by helpFile being null) | 517 | helpexists = FALSE; // We don't know (flagged by helpFile being null) |
518 | qpeManager = new QPEManager( this ); | 518 | qpeManager = new QPEManager( this ); |
519 | imageOk = Resource::loadImage( "OKButton" ); | 519 | imageOk = Resource::loadImage( "OKButton" ); |
520 | imageClose = Resource::loadImage( "CloseButton" ); | 520 | imageClose = Resource::loadImage( "CloseButton" ); |
521 | imageHelp = Resource::loadImage( "HelpButton" ); | 521 | imageHelp = Resource::loadImage( "HelpButton" ); |
522 | } | 522 | } |
523 | 523 | ||
524 | QPEDecoration::QPEDecoration( const QString &plugin ) | 524 | QPEDecoration::QPEDecoration( const QString &plugin ) |
525 | : QWSDefaultDecoration() | 525 | : QWSDefaultDecoration() |
526 | { | 526 | { |
527 | libname = plugin; | 527 | libname = plugin; |
528 | 528 | ||
529 | if ( wdlib ) { | 529 | if ( wdlib ) { |
530 | wdiface->release(); | 530 | wdiface->release(); |
531 | wdlib->unload(); | 531 | wdlib->unload(); |
532 | delete wdlib; | 532 | delete wdlib; |
533 | wdlib = 0; | 533 | wdlib = 0; |
534 | } else { | 534 | } else { |
535 | delete wdiface; | 535 | delete wdiface; |
536 | } | 536 | } |
537 | 537 | ||
538 | WindowDecorationInterface *iface = 0; | 538 | WindowDecorationInterface *iface = 0; |
539 | QString path = QPEApplication::qpeDir() + "/plugins/decorations/"; | 539 | QString path = QPEApplication::qpeDir() + "plugins/decorations/"; |
540 | 540 | ||
541 | #ifdef Q_OS_MACX | 541 | #ifdef Q_OS_MACX |
542 | if ( plugin.find( ".dylib" ) > 0 ) { | 542 | if ( plugin.find( ".dylib" ) > 0 ) { |
543 | #else | 543 | #else |
544 | if ( plugin.find( ".so" ) > 0 ) { | 544 | if ( plugin.find( ".so" ) > 0 ) { |
545 | #endif | 545 | #endif |
546 | // full library name supplied | 546 | // full library name supplied |
547 | path += plugin; | 547 | path += plugin; |
548 | } else { | 548 | } else { |
549 | #ifdef Q_OS_MACX | 549 | #ifdef Q_OS_MACX |
550 | path += "lib" + plugin.lower() + ".dylib"; // compatibility | 550 | path += "lib" + plugin.lower() + ".dylib"; // compatibility |
551 | #else | 551 | #else |
552 | path += "lib" + plugin.lower() + ".so"; // compatibility | 552 | path += "lib" + plugin.lower() + ".so"; // compatibility |
553 | #endif | 553 | #endif |
554 | } | 554 | } |
555 | 555 | ||
556 | QLibrary *lib = new QLibrary( path ); | 556 | QLibrary *lib = new QLibrary( path ); |
557 | if ( lib->queryInterface( IID_WindowDecoration, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 557 | if ( lib->queryInterface( IID_WindowDecoration, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
558 | wdiface = iface; | 558 | wdiface = iface; |
559 | wdlib = lib; | 559 | wdlib = lib; |
560 | } else { | 560 | } else { |
561 | delete lib; | 561 | delete lib; |
562 | wdiface = new DefaultWindowDecoration; | 562 | wdiface = new DefaultWindowDecoration; |
563 | } | 563 | } |
564 | 564 | ||
565 | 565 | ||
566 | 566 | ||
567 | helpexists = FALSE; // We don't know (flagged by helpFile being null) | 567 | helpexists = FALSE; // We don't know (flagged by helpFile being null) |
568 | qpeManager = new QPEManager( this ); | 568 | qpeManager = new QPEManager( this ); |
569 | } | 569 | } |
570 | 570 | ||
571 | QPEDecoration::~QPEDecoration() | 571 | QPEDecoration::~QPEDecoration() |
572 | { | 572 | { |
573 | delete qpeManager; | 573 | delete qpeManager; |
574 | } | 574 | } |
575 | 575 | ||
576 | const char **QPEDecoration::menuPixmap() | 576 | const char **QPEDecoration::menuPixmap() |
577 | { | 577 | { |
578 | return (const char **)0; | 578 | return (const char **)0; |
579 | } | 579 | } |
580 | 580 | ||
581 | const char **QPEDecoration::closePixmap() | 581 | const char **QPEDecoration::closePixmap() |
582 | { | 582 | { |
583 | return (const char **)qpe_close_xpm; | 583 | return (const char **)qpe_close_xpm; |
584 | } | 584 | } |
585 | 585 | ||
586 | const char **QPEDecoration::minimizePixmap() | 586 | const char **QPEDecoration::minimizePixmap() |
587 | { | 587 | { |
588 | return (const char **)qpe_accept_xpm; | 588 | return (const char **)qpe_accept_xpm; |
589 | } | 589 | } |
590 | 590 | ||
591 | const char **QPEDecoration::maximizePixmap() | 591 | const char **QPEDecoration::maximizePixmap() |
592 | { | 592 | { |
593 | return (const char **)0; | 593 | return (const char **)0; |
594 | } | 594 | } |
595 | 595 | ||
596 | const char **QPEDecoration::normalizePixmap() | 596 | const char **QPEDecoration::normalizePixmap() |
597 | { | 597 | { |
598 | return (const char **)0; | 598 | return (const char **)0; |
599 | } | 599 | } |
600 | 600 | ||
601 | int QPEDecoration::getTitleHeight( const QWidget *w ) | 601 | int QPEDecoration::getTitleHeight( const QWidget *w ) |
602 | { | 602 | { |
603 | WindowDecorationInterface::WindowData wd; | 603 | WindowDecorationInterface::WindowData wd; |
604 | windowData( w, wd ); | 604 | windowData( w, wd ); |
605 | return wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); | 605 | return wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); |
606 | } | 606 | } |
607 | 607 | ||
608 | /* | 608 | /* |
609 | If rect is empty, no frame is added. (a hack, really) | 609 | If rect is empty, no frame is added. (a hack, really) |
610 | */ | 610 | */ |
611 | QRegion QPEDecoration::region(const QWidget *widget, const QRect &rect, QWSDecoration::Region type) | 611 | QRegion QPEDecoration::region(const QWidget *widget, const QRect &rect, QWSDecoration::Region type) |
612 | { | 612 | { |
613 | qpeManager->updateActive(); | 613 | qpeManager->updateActive(); |
614 | 614 | ||
615 | WindowDecorationInterface::WindowData wd; | 615 | WindowDecorationInterface::WindowData wd; |
616 | windowData( widget, wd ); | 616 | windowData( widget, wd ); |
617 | wd.rect = rect; | 617 | wd.rect = rect; |
618 | 618 | ||
619 | int titleHeight = wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); | 619 | int titleHeight = wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); |
620 | int okWidth = wdiface->metric(WindowDecorationInterface::OKWidth,&wd); | 620 | int okWidth = wdiface->metric(WindowDecorationInterface::OKWidth,&wd); |
621 | int closeWidth = wdiface->metric(WindowDecorationInterface::CloseWidth,&wd); | 621 | int closeWidth = wdiface->metric(WindowDecorationInterface::CloseWidth,&wd); |
622 | int helpWidth = wdiface->metric(WindowDecorationInterface::HelpWidth,&wd); | 622 | int helpWidth = wdiface->metric(WindowDecorationInterface::HelpWidth,&wd); |
623 | int grab = wdiface->metric(WindowDecorationInterface::CornerGrabSize,&wd); | 623 | int grab = wdiface->metric(WindowDecorationInterface::CornerGrabSize,&wd); |
624 | 624 | ||
625 | QRegion region; | 625 | QRegion region; |
626 | 626 | ||
627 | switch ((int)type) { | 627 | switch ((int)type) { |
628 | case Menu: | 628 | case Menu: |
629 | break; | 629 | break; |
630 | case Maximize: | 630 | case Maximize: |
631 | if ( !widget->inherits( "QDialog" ) && qApp->desktop()->width() > 350 ) { | 631 | if ( !widget->inherits( "QDialog" ) && qApp->desktop()->width() > 350 ) { |
632 | int maximizeWidth = wdiface->metric(WindowDecorationInterface::MaximizeWidth,&wd); | 632 | int maximizeWidth = wdiface->metric(WindowDecorationInterface::MaximizeWidth,&wd); |
633 | int left = rect.right() - maximizeWidth - closeWidth; | 633 | int left = rect.right() - maximizeWidth - closeWidth; |
634 | if ( ((DecorHackWidget *)widget)->needsOk() ) | 634 | if ( ((DecorHackWidget *)widget)->needsOk() ) |
635 | left -= okWidth; | 635 | left -= okWidth; |
636 | QRect r(left, rect.top() - titleHeight, closeWidth, titleHeight); | 636 | QRect r(left, rect.top() - titleHeight, closeWidth, titleHeight); |
637 | region = r; | 637 | region = r; |
638 | } | 638 | } |
639 | break; | 639 | break; |
640 | case Minimize: | 640 | case Minimize: |
641 | if ( ((DecorHackWidget *)widget)->needsOk() ) { | 641 | if ( ((DecorHackWidget *)widget)->needsOk() ) { |
642 | QRect r(rect.right() - okWidth, | 642 | QRect r(rect.right() - okWidth, |
643 | rect.top() - titleHeight, okWidth, titleHeight); | 643 | rect.top() - titleHeight, okWidth, titleHeight); |
644 | if (r.left() > rect.left() + titleHeight) | 644 | if (r.left() > rect.left() + titleHeight) |
645 | region = r; | 645 | region = r; |
646 | } | 646 | } |
647 | break; | 647 | break; |
648 | case Close: | 648 | case Close: |
649 | { | 649 | { |
650 | int left = rect.right() - closeWidth; | 650 | int left = rect.right() - closeWidth; |
651 | if ( ((DecorHackWidget *)widget)->needsOk() ) | 651 | if ( ((DecorHackWidget *)widget)->needsOk() ) |
652 | left -= okWidth; | 652 | left -= okWidth; |
653 | QRect r(left, rect.top() - titleHeight, closeWidth, titleHeight); | 653 | QRect r(left, rect.top() - titleHeight, closeWidth, titleHeight); |
654 | region = r; | 654 | region = r; |
655 | } | 655 | } |
656 | break; | 656 | break; |
657 | case Title: | 657 | case Title: |
658 | if ( !widget->isMaximized() ) { | 658 | if ( !widget->isMaximized() ) { |
659 | int width = rect.width() - helpWidth - closeWidth; | 659 | int width = rect.width() - helpWidth - closeWidth; |
660 | if ( ((DecorHackWidget *)widget)->needsOk() ) | 660 | if ( ((DecorHackWidget *)widget)->needsOk() ) |
661 | width -= okWidth; | 661 | width -= okWidth; |
662 | QRect r(rect.left()+helpWidth, rect.top() - titleHeight, | 662 | QRect r(rect.left()+helpWidth, rect.top() - titleHeight, |
663 | width, titleHeight); | 663 | width, titleHeight); |
664 | if (r.width() > 0) | 664 | if (r.width() > 0) |
665 | region = r; | 665 | region = r; |
666 | } | 666 | } |
667 | break; | 667 | break; |
668 | case Help: | 668 | case Help: |
669 | if ( helpExists() || widget->testWFlags(Qt::WStyle_ContextHelp) ) { | 669 | if ( helpExists() || widget->testWFlags(Qt::WStyle_ContextHelp) ) { |
670 | QRect r(rect.left(), rect.top() - titleHeight, | 670 | QRect r(rect.left(), rect.top() - titleHeight, |
671 | helpWidth, titleHeight); | 671 | helpWidth, titleHeight); |
672 | region = r; | 672 | region = r; |
673 | } | 673 | } |
674 | break; | 674 | break; |
675 | case Top: | 675 | case Top: |
676 | if ( !widget->isMaximized() ) { | 676 | if ( !widget->isMaximized() ) { |
677 | QRegion m = wdiface->mask(&wd); | 677 | QRegion m = wdiface->mask(&wd); |
678 | QRect br = m.boundingRect(); | 678 | QRect br = m.boundingRect(); |
679 | int b = wdiface->metric(WindowDecorationInterface::TopBorder,&wd); | 679 | int b = wdiface->metric(WindowDecorationInterface::TopBorder,&wd); |
680 | region = m & QRect( br.left()+grab, br.top(), | 680 | region = m & QRect( br.left()+grab, br.top(), |
681 | br.width()-2*grab, b ); | 681 | br.width()-2*grab, b ); |
682 | } | 682 | } |
683 | break; | 683 | break; |
684 | case Left: | 684 | case Left: |
685 | if ( !widget->isMaximized() ) { | 685 | if ( !widget->isMaximized() ) { |
686 | QRegion m = wdiface->mask(&wd); | 686 | QRegion m = wdiface->mask(&wd); |
687 | QRect br = m.boundingRect(); | 687 | QRect br = m.boundingRect(); |
688 | int b = wdiface->metric(WindowDecorationInterface::LeftBorder,&wd); | 688 | int b = wdiface->metric(WindowDecorationInterface::LeftBorder,&wd); |
689 | region = m & QRect( br.left(), br.top()+grab, | 689 | region = m & QRect( br.left(), br.top()+grab, |
690 | b, br.height()-2*grab ); | 690 | b, br.height()-2*grab ); |
691 | } | 691 | } |
692 | break; | 692 | break; |
693 | case Right: | 693 | case Right: |
694 | if ( !widget->isMaximized() ) { | 694 | if ( !widget->isMaximized() ) { |
695 | QRegion m = wdiface->mask(&wd); | 695 | QRegion m = wdiface->mask(&wd); |
696 | QRect br = m.boundingRect(); | 696 | QRect br = m.boundingRect(); |
697 | int b = wdiface->metric(WindowDecorationInterface::RightBorder,&wd); | 697 | int b = wdiface->metric(WindowDecorationInterface::RightBorder,&wd); |
698 | region = m & QRect( rect.right(), br.top()+grab, | 698 | region = m & QRect( rect.right(), br.top()+grab, |
699 | b, br.height()-2*grab ); | 699 | b, br.height()-2*grab ); |
700 | } | 700 | } |
701 | break; | 701 | break; |
702 | case Bottom: | 702 | case Bottom: |
703 | if ( !widget->isMaximized() ) { | 703 | if ( !widget->isMaximized() ) { |
704 | QRegion m = wdiface->mask(&wd); | 704 | QRegion m = wdiface->mask(&wd); |
705 | QRect br = m.boundingRect(); | 705 | QRect br = m.boundingRect(); |
706 | int b = wdiface->metric(WindowDecorationInterface::BottomBorder,&wd); | 706 | int b = wdiface->metric(WindowDecorationInterface::BottomBorder,&wd); |
707 | region = m & QRect( br.left()+grab, rect.bottom(), | 707 | region = m & QRect( br.left()+grab, rect.bottom(), |
708 | br.width()-2*grab, b ); | 708 | br.width()-2*grab, b ); |
709 | } | 709 | } |
710 | break; | 710 | break; |
711 | case TopLeft: | 711 | case TopLeft: |
712 | if ( !widget->isMaximized() ) { | 712 | if ( !widget->isMaximized() ) { |
713 | QRegion m = wdiface->mask(&wd); | 713 | QRegion m = wdiface->mask(&wd); |
714 | QRect br = m.boundingRect(); | 714 | QRect br = m.boundingRect(); |
715 | int tb = wdiface->metric(WindowDecorationInterface::TopBorder,&wd); | 715 | int tb = wdiface->metric(WindowDecorationInterface::TopBorder,&wd); |
716 | int lb = wdiface->metric(WindowDecorationInterface::LeftBorder,&wd); | 716 | int lb = wdiface->metric(WindowDecorationInterface::LeftBorder,&wd); |
717 | QRegion crgn( br.left(), br.top(), grab, tb ); | 717 | QRegion crgn( br.left(), br.top(), grab, tb ); |
718 | crgn |= QRect( br.left(), br.top(), lb, grab ); | 718 | crgn |= QRect( br.left(), br.top(), lb, grab ); |
719 | region = m & crgn; | 719 | region = m & crgn; |
720 | } | 720 | } |
721 | break; | 721 | break; |
722 | case TopRight: | 722 | case TopRight: |
723 | if ( !widget->isMaximized() ) { | 723 | if ( !widget->isMaximized() ) { |
724 | QRegion m = wdiface->mask(&wd); | 724 | QRegion m = wdiface->mask(&wd); |
725 | QRect br = m.boundingRect(); | 725 | QRect br = m.boundingRect(); |
726 | int tb = wdiface->metric(WindowDecorationInterface::TopBorder,&wd); | 726 | int tb = wdiface->metric(WindowDecorationInterface::TopBorder,&wd); |
727 | int rb = wdiface->metric(WindowDecorationInterface::RightBorder,&wd); | 727 | int rb = wdiface->metric(WindowDecorationInterface::RightBorder,&wd); |
728 | QRegion crgn( br.right()-grab, br.top(), grab, tb ); | 728 | QRegion crgn( br.right()-grab, br.top(), grab, tb ); |
729 | crgn |= QRect( br.right()-rb, br.top(), rb, grab ); | 729 | crgn |= QRect( br.right()-rb, br.top(), rb, grab ); |
730 | region = m & crgn; | 730 | region = m & crgn; |
731 | } | 731 | } |
732 | break; | 732 | break; |
733 | case BottomLeft: | 733 | case BottomLeft: |
734 | if ( !widget->isMaximized() ) { | 734 | if ( !widget->isMaximized() ) { |
735 | QRegion m = wdiface->mask(&wd); | 735 | QRegion m = wdiface->mask(&wd); |
736 | QRect br = m.boundingRect(); | 736 | QRect br = m.boundingRect(); |
737 | region = m & QRect( br.left(), br.bottom()-grab, grab, grab ); | 737 | region = m & QRect( br.left(), br.bottom()-grab, grab, grab ); |
738 | } | 738 | } |
739 | break; | 739 | break; |
740 | case BottomRight: | 740 | case BottomRight: |
741 | if ( !widget->isMaximized() ) { | 741 | if ( !widget->isMaximized() ) { |
742 | QRegion m = wdiface->mask(&wd); | 742 | QRegion m = wdiface->mask(&wd); |
743 | QRect br = m.boundingRect(); | 743 | QRect br = m.boundingRect(); |
744 | region = m & QRect( br.right()-grab, br.bottom()-grab, grab, grab ); | 744 | region = m & QRect( br.right()-grab, br.bottom()-grab, grab, grab ); |
745 | } | 745 | } |
746 | break; | 746 | break; |
747 | case All: | 747 | case All: |
748 | if ( widget->isMaximized() ) | 748 | if ( widget->isMaximized() ) |
749 | region = QWSDefaultDecoration::region(widget, rect, type); | 749 | region = QWSDefaultDecoration::region(widget, rect, type); |
750 | else | 750 | else |
751 | region = wdiface->mask(&wd) - rect; | 751 | region = wdiface->mask(&wd) - rect; |
752 | break; | 752 | break; |
753 | default: | 753 | default: |
754 | region = QWSDefaultDecoration::region(widget, rect, type); | 754 | region = QWSDefaultDecoration::region(widget, rect, type); |
755 | break; | 755 | break; |
756 | } | 756 | } |
757 | 757 | ||
758 | return region; | 758 | return region; |
759 | } | 759 | } |
760 | 760 | ||
761 | void QPEDecoration::paint(QPainter *painter, const QWidget *widget) | 761 | void QPEDecoration::paint(QPainter *painter, const QWidget *widget) |
762 | { | 762 | { |
763 | WindowDecorationInterface::WindowData wd; | 763 | WindowDecorationInterface::WindowData wd; |
764 | windowData( widget, wd ); | 764 | windowData( widget, wd ); |
765 | 765 | ||
766 | int titleWidth = getTitleWidth(widget); | 766 | int titleWidth = getTitleWidth(widget); |
767 | int titleHeight = wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); | 767 | int titleHeight = wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); |
768 | 768 | ||
769 | QRect rect(widget->rect()); | 769 | QRect rect(widget->rect()); |
770 | 770 | ||
771 | // title bar rect | 771 | // title bar rect |
772 | QRect tbr( rect.left(), rect.top() - titleHeight, rect.width(), titleHeight ); | 772 | QRect tbr( rect.left(), rect.top() - titleHeight, rect.width(), titleHeight ); |
773 | 773 | ||
774 | #ifndef QT_NO_PALETTE | 774 | #ifndef QT_NO_PALETTE |
775 | QRegion oldClip = painter->clipRegion(); | 775 | QRegion oldClip = painter->clipRegion(); |
776 | painter->setClipRegion( oldClip - QRegion( tbr ) );// reduce flicker | 776 | painter->setClipRegion( oldClip - QRegion( tbr ) );// reduce flicker |
777 | wdiface->drawArea( WindowDecorationInterface::Border, painter, &wd ); | 777 | wdiface->drawArea( WindowDecorationInterface::Border, painter, &wd ); |
778 | painter->setClipRegion( oldClip ); | 778 | painter->setClipRegion( oldClip ); |
779 | 779 | ||
780 | if (titleWidth > 0) { | 780 | if (titleWidth > 0) { |
781 | const QColorGroup &cg = widget->palette().active(); | 781 | const QColorGroup &cg = widget->palette().active(); |
782 | QBrush titleBrush; | 782 | QBrush titleBrush; |
783 | QPen titlePen; | 783 | QPen titlePen; |
784 | 784 | ||
785 | if ( wd.flags & WindowDecorationInterface::WindowData::Active ) { | 785 | if ( wd.flags & WindowDecorationInterface::WindowData::Active ) { |
786 | titleBrush = cg.brush(QColorGroup::Highlight); | 786 | titleBrush = cg.brush(QColorGroup::Highlight); |
787 | titlePen = cg.color(QColorGroup::HighlightedText); | 787 | titlePen = cg.color(QColorGroup::HighlightedText); |
788 | } else { | 788 | } else { |
789 | titleBrush = cg.brush(QColorGroup::Background); | 789 | titleBrush = cg.brush(QColorGroup::Background); |
790 | titlePen = cg.color(QColorGroup::Text); | 790 | titlePen = cg.color(QColorGroup::Text); |
791 | } | 791 | } |
792 | 792 | ||
793 | wdiface->drawArea( WindowDecorationInterface::Title, painter, &wd ); | 793 | wdiface->drawArea( WindowDecorationInterface::Title, painter, &wd ); |
794 | 794 | ||
795 | // Draw caption | 795 | // Draw caption |
796 | painter->setPen(titlePen); | 796 | painter->setPen(titlePen); |
797 | QFont f( QApplication::font() ); | 797 | QFont f( QApplication::font() ); |
798 | f.setWeight( QFont::Bold ); | 798 | f.setWeight( QFont::Bold ); |
799 | painter->setFont(f); | 799 | painter->setFont(f); |
800 | wdiface->drawArea( WindowDecorationInterface::TitleText, painter, &wd ); | 800 | wdiface->drawArea( WindowDecorationInterface::TitleText, painter, &wd ); |
801 | } | 801 | } |
802 | #endif //QT_NO_PALETTE | 802 | #endif //QT_NO_PALETTE |
803 | 803 | ||
804 | paintButton( painter, widget, (QWSDecoration::Region)Help, 0 ); | 804 | paintButton( painter, widget, (QWSDecoration::Region)Help, 0 ); |
805 | } | 805 | } |
806 | 806 | ||
807 | void QPEDecoration::paintButton(QPainter *painter, const QWidget *w, | 807 | void QPEDecoration::paintButton(QPainter *painter, const QWidget *w, |
808 | QWSDecoration::Region type, int state) | 808 | QWSDecoration::Region type, int state) |
809 | { | 809 | { |
810 | WindowDecorationInterface::Button b; | 810 | WindowDecorationInterface::Button b; |
811 | switch ((int)type) { | 811 | switch ((int)type) { |
812 | case Close: | 812 | case Close: |
813 | b = WindowDecorationInterface::Close; | 813 | b = WindowDecorationInterface::Close; |
814 | break; | 814 | break; |
815 | case Minimize: | 815 | case Minimize: |
816 | if ( ((DecorHackWidget *)w)->needsOk() ) | 816 | if ( ((DecorHackWidget *)w)->needsOk() ) |
817 | b = WindowDecorationInterface::OK; | 817 | b = WindowDecorationInterface::OK; |
818 | else if ( helpExists() ) | 818 | else if ( helpExists() ) |
819 | b = WindowDecorationInterface::Help; | 819 | b = WindowDecorationInterface::Help; |
820 | else | 820 | else |
821 | return; | 821 | return; |
822 | break; | 822 | break; |
823 | case Help: | 823 | case Help: |
824 | b = WindowDecorationInterface::Help; | 824 | b = WindowDecorationInterface::Help; |
825 | break; | 825 | break; |
826 | case Maximize: | 826 | case Maximize: |
827 | b = WindowDecorationInterface::Maximize; | 827 | b = WindowDecorationInterface::Maximize; |
828 | break; | 828 | break; |
829 | default: | 829 | default: |
830 | return; | 830 | return; |
831 | } | 831 | } |
832 | 832 | ||
833 | WindowDecorationInterface::WindowData wd; | 833 | WindowDecorationInterface::WindowData wd; |
834 | windowData( w, wd ); | 834 | windowData( w, wd ); |
835 | 835 | ||
836 | int titleHeight = wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); | 836 | int titleHeight = wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); |
837 | QRect rect(w->rect()); | 837 | QRect rect(w->rect()); |
838 | QRect tbr( rect.left(), rect.top() - titleHeight, rect.width(), titleHeight ); | 838 | QRect tbr( rect.left(), rect.top() - titleHeight, rect.width(), titleHeight ); |
839 | QRect brect(region(w, w->rect(), type).boundingRect()); | 839 | QRect brect(region(w, w->rect(), type).boundingRect()); |
840 | 840 | ||
841 | const QColorGroup &cg = w->palette().active(); | 841 | const QColorGroup &cg = w->palette().active(); |
842 | if ( wd.flags & WindowDecorationInterface::WindowData::Active ) | 842 | if ( wd.flags & WindowDecorationInterface::WindowData::Active ) |
843 | painter->setPen( cg.color(QColorGroup::HighlightedText) ); | 843 | painter->setPen( cg.color(QColorGroup::HighlightedText) ); |
844 | else | 844 | else |
845 | painter->setPen( cg.color(QColorGroup::Text) ); | 845 | painter->setPen( cg.color(QColorGroup::Text) ); |
846 | 846 | ||
847 | QRegion oldClip = painter->clipRegion(); | 847 | QRegion oldClip = painter->clipRegion(); |
848 | painter->setClipRegion( QRect(brect.x(), tbr.y(), brect.width(), tbr.height()) ); // reduce flicker | 848 | painter->setClipRegion( QRect(brect.x(), tbr.y(), brect.width(), tbr.height()) ); // reduce flicker |
849 | wdiface->drawArea( WindowDecorationInterface::Title, painter, &wd ); | 849 | wdiface->drawArea( WindowDecorationInterface::Title, painter, &wd ); |
850 | wdiface->drawButton( b, painter, &wd, brect.x(), brect.y(), brect.width(), brect.height(), (QWSButton::State)state ); | 850 | wdiface->drawButton( b, painter, &wd, brect.x(), brect.y(), brect.width(), brect.height(), (QWSButton::State)state ); |
851 | painter->setClipRegion( oldClip ); | 851 | painter->setClipRegion( oldClip ); |
852 | } | 852 | } |
853 | 853 | ||
854 | //#define QPE_DONT_SHOW_TITLEBAR | 854 | //#define QPE_DONT_SHOW_TITLEBAR |
855 | 855 | ||
856 | void QPEDecoration::maximize( QWidget *widget ) | 856 | void QPEDecoration::maximize( QWidget *widget ) |
857 | { | 857 | { |
858 | #ifdef QPE_DONT_SHOW_TITLEBAR | 858 | #ifdef QPE_DONT_SHOW_TITLEBAR |
859 | if ( !widget->inherits( "QDialog" ) ) { | 859 | if ( !widget->inherits( "QDialog" ) ) { |
860 | widget->setGeometry( qt_maxWindowRect ); | 860 | widget->setGeometry( qt_maxWindowRect ); |
861 | } else | 861 | } else |
862 | #endif | 862 | #endif |
863 | { | 863 | { |
864 | QWSDecoration::maximize( widget ); | 864 | QWSDecoration::maximize( widget ); |
865 | } | 865 | } |
866 | } | 866 | } |
867 | 867 | ||
868 | QPopupMenu *QPEDecoration::menu( const QWidget *, const QPoint & ) | 868 | QPopupMenu *QPEDecoration::menu( const QWidget *, const QPoint & ) |
869 | { | 869 | { |
870 | QPopupMenu *m = new QPopupMenu(); | 870 | QPopupMenu *m = new QPopupMenu(); |
871 | 871 | ||
872 | m->insertItem(QPEManager::tr("Restore"), (int)Normalize); | 872 | m->insertItem(QPEManager::tr("Restore"), (int)Normalize); |
873 | m->insertItem(QPEManager::tr("Move"), (int)Title); | 873 | m->insertItem(QPEManager::tr("Move"), (int)Title); |
874 | m->insertItem(QPEManager::tr("Size"), (int)BottomRight); | 874 | m->insertItem(QPEManager::tr("Size"), (int)BottomRight); |
875 | m->insertItem(QPEManager::tr("Maximize"), (int)Maximize); | 875 | m->insertItem(QPEManager::tr("Maximize"), (int)Maximize); |
876 | m->insertSeparator(); | 876 | m->insertSeparator(); |
877 | m->insertItem(QPEManager::tr("Close"), (int)Close); | 877 | m->insertItem(QPEManager::tr("Close"), (int)Close); |
878 | 878 | ||
879 | return m; | 879 | return m; |
880 | } | 880 | } |
881 | 881 | ||
882 | #ifndef QT_NO_DIALOG | 882 | #ifndef QT_NO_DIALOG |
883 | class HackDialog : public QDialog | 883 | class HackDialog : public QDialog |
884 | { | 884 | { |
885 | public: | 885 | public: |
886 | void acceptIt() { | 886 | void acceptIt() { |
887 | if ( isA( "QMessageBox" ) ) | 887 | if ( isA( "QMessageBox" ) ) |
888 | qApp->postEvent( this, new QKeyEvent( QEvent::KeyPress, Key_Enter, '\n', 0, "\n" ) ); | 888 | qApp->postEvent( this, new QKeyEvent( QEvent::KeyPress, Key_Enter, '\n', 0, "\n" ) ); |
889 | else | 889 | else |
890 | accept(); | 890 | accept(); |
891 | } | 891 | } |
892 | }; | 892 | }; |
893 | #endif | 893 | #endif |
894 | 894 | ||
895 | 895 | ||
896 | void QPEDecoration::minimize( QWidget *widget ) | 896 | void QPEDecoration::minimize( QWidget *widget ) |
897 | { | 897 | { |
898 | #ifndef QT_NO_DIALOG | 898 | #ifndef QT_NO_DIALOG |
899 | // We use the minimize button as an "accept" button. | 899 | // We use the minimize button as an "accept" button. |
900 | if ( widget->inherits( "QDialog" ) ) { | 900 | if ( widget->inherits( "QDialog" ) ) { |
901 | HackDialog *d = (HackDialog *)widget; | 901 | HackDialog *d = (HackDialog *)widget; |
902 | d->acceptIt(); | 902 | d->acceptIt(); |
903 | } | 903 | } |
904 | #endif | 904 | #endif |
905 | else if ( ((DecorHackWidget *)widget)->needsOk() ) { | 905 | else if ( ((DecorHackWidget *)widget)->needsOk() ) { |
906 | QSignal s; | 906 | QSignal s; |
907 | s.connect( widget, SLOT( accept() ) ); | 907 | s.connect( widget, SLOT( accept() ) ); |
908 | s.activate(); | 908 | s.activate(); |
909 | } else { | 909 | } else { |
910 | help( widget ); | 910 | help( widget ); |
911 | } | 911 | } |
912 | } | 912 | } |
913 | 913 | ||
914 | void QPEDecoration::help( QWidget *w ) | 914 | void QPEDecoration::help( QWidget *w ) |
915 | { | 915 | { |
916 | if ( helpExists() ) { | 916 | if ( helpExists() ) { |
917 | QString hf = helpFile; | 917 | QString hf = helpFile; |
918 | QString localHelpFile = QString(qApp->argv()[0]) + "-" + w->name() + ".html"; | 918 | QString localHelpFile = QString(qApp->argv()[0]) + "-" + w->name() + ".html"; |
919 | QStringList helpPath = Global::helpPath(); | 919 | QStringList helpPath = Global::helpPath(); |
920 | for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end(); ++it) { | 920 | for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end(); ++it) { |
921 | if ( QFile::exists( *it + "/" + localHelpFile ) ) { | 921 | if ( QFile::exists( *it + "/" + localHelpFile ) ) { |
922 | hf = localHelpFile; | 922 | hf = localHelpFile; |
923 | break; | 923 | break; |
924 | } | 924 | } |
925 | } | 925 | } |
926 | Global::execute( "helpbrowser", hf ); | 926 | Global::execute( "helpbrowser", hf ); |
927 | } else if ( w && w->testWFlags(Qt::WStyle_ContextHelp) ) { | 927 | } else if ( w && w->testWFlags(Qt::WStyle_ContextHelp) ) { |
928 | QWhatsThis::enterWhatsThisMode(); | 928 | QWhatsThis::enterWhatsThisMode(); |
929 | QWhatsThis::leaveWhatsThisMode( QObject::tr( | 929 | QWhatsThis::leaveWhatsThisMode( QObject::tr( |
930 | "<Qt>Comprehensive help is not available for this application, " | 930 | "<Qt>Comprehensive help is not available for this application, " |
931 | "however there is context-sensitive help.<p>To use context-sensitive help:<p>" | 931 | "however there is context-sensitive help.<p>To use context-sensitive help:<p>" |
932 | "<ol><li>click and hold the help button." | 932 | "<ol><li>click and hold the help button." |
933 | "<li>when the title bar shows <b>What's this...</b>, " | 933 | "<li>when the title bar shows <b>What's this...</b>, " |
934 | "click on any control.</ol></Qt>" ) ); | 934 | "click on any control.</ol></Qt>" ) ); |
935 | } | 935 | } |
936 | } | 936 | } |
937 | 937 | ||
938 | void QPEDecoration::windowData( const QWidget *w, WindowDecorationInterface::WindowData &wd ) const | 938 | void QPEDecoration::windowData( const QWidget *w, WindowDecorationInterface::WindowData &wd ) const |
939 | { | 939 | { |
940 | wd.rect = w->rect(); | 940 | wd.rect = w->rect(); |
941 | if ( qpeManager->whatsThisWidget() == w ) | 941 | if ( qpeManager->whatsThisWidget() == w ) |
942 | wd.caption = QObject::tr( "What's this..." ); | 942 | wd.caption = QObject::tr( "What's this..." ); |
943 | else | 943 | else |
944 | wd.caption = w->caption(); | 944 | wd.caption = w->caption(); |
945 | wd.palette = qApp->palette(); | 945 | wd.palette = qApp->palette(); |
946 | wd.flags = 0; | 946 | wd.flags = 0; |
947 | wd.flags |= w->isMaximized() ? WindowDecorationInterface::WindowData::Maximized : 0; | 947 | wd.flags |= w->isMaximized() ? WindowDecorationInterface::WindowData::Maximized : 0; |
948 | wd.flags |= w->testWFlags(Qt::WStyle_Dialog) ? WindowDecorationInterface::WindowData::Dialog : 0; | 948 | wd.flags |= w->testWFlags(Qt::WStyle_Dialog) ? WindowDecorationInterface::WindowData::Dialog : 0; |
949 | const QWidget *active = qpeManager->activeWidget(); | 949 | const QWidget *active = qpeManager->activeWidget(); |
950 | wd.flags |= w == active ? WindowDecorationInterface::WindowData::Active : 0; | 950 | wd.flags |= w == active ? WindowDecorationInterface::WindowData::Active : 0; |
951 | wd.reserved = 1; | 951 | wd.reserved = 1; |
952 | } | 952 | } |
953 | 953 | ||
954 | /* | 954 | /* |
955 | #ifndef QT_NO_POPUPMENU | 955 | #ifndef QT_NO_POPUPMENU |
956 | QPopupMenu *QPEDecoration::menu(QWSManager*, const QWidget*, const QPoint&) | 956 | QPopupMenu *QPEDecoration::menu(QWSManager*, const QWidget*, const QPoint&) |
957 | { | 957 | { |
958 | return 0; | 958 | return 0; |
959 | } | 959 | } |
960 | #endif | 960 | #endif |
961 | */ | 961 | */ |
962 | 962 | ||
963 | 963 | ||
964 | 964 | ||
965 | 965 | ||
966 | #endif // QT_NO_QWS_QPE_WM_STYLE | 966 | #endif // QT_NO_QWS_QPE_WM_STYLE |
967 | #endif | 967 | #endif |