-rw-r--r-- | noncore/settings/appearance2/appearance.cpp | 8 | ||||
-rw-r--r-- | noncore/settings/appearance2/exceptlistitem.h | 2 |
2 files changed, 7 insertions, 3 deletions
diff --git a/noncore/settings/appearance2/appearance.cpp b/noncore/settings/appearance2/appearance.cpp index 22b12b4..f611799 100644 --- a/noncore/settings/appearance2/appearance.cpp +++ b/noncore/settings/appearance2/appearance.cpp | |||
@@ -1,754 +1,758 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | Copyright (c) 2002 Trolltech AS <info@trolltech.com> | 3 | Copyright (c) 2002 Trolltech AS <info@trolltech.com> |
4 | =. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> | 4 | =. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> |
5 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> | 5 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <qbuttongroup.h> | 30 | #include <qbuttongroup.h> |
31 | #include <qcheckbox.h> | 31 | #include <qcheckbox.h> |
32 | #include <qcombobox.h> | 32 | #include <qcombobox.h> |
33 | #include <qdialog.h> | 33 | #include <qdialog.h> |
34 | #include <qdir.h> | 34 | #include <qdir.h> |
35 | #include <qlabel.h> | 35 | #include <qlabel.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qlineedit.h> | 37 | #include <qlineedit.h> |
38 | #include <qlistbox.h> | 38 | #include <qlistbox.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qpushbutton.h> | 40 | #include <qpushbutton.h> |
41 | #include <qradiobutton.h> | 41 | #include <qradiobutton.h> |
42 | #if QT_VERSION >= 300 | 42 | #if QT_VERSION >= 300 |
43 | #include <qstylefactory.h> | 43 | #include <qstylefactory.h> |
44 | #endif | 44 | #endif |
45 | #include <qtoolbutton.h> | 45 | #include <qtoolbutton.h> |
46 | #include <qwindowsstyle.h> | 46 | #include <qwindowsstyle.h> |
47 | #include <qlistview.h> | 47 | #include <qlistview.h> |
48 | #include <qheader.h> | 48 | #include <qheader.h> |
49 | #include <qvbox.h> | 49 | #include <qvbox.h> |
50 | 50 | ||
51 | #include <qpe/config.h> | 51 | #include <qpe/config.h> |
52 | #include <qpe/global.h> | 52 | #include <qpe/global.h> |
53 | #include <qpe/resource.h> | 53 | #include <qpe/resource.h> |
54 | #include <qpe/qpeapplication.h> | 54 | #include <qpe/qpeapplication.h> |
55 | #include <qpe/qcopenvelope_qws.h> | 55 | #include <qpe/qcopenvelope_qws.h> |
56 | #include <qpe/qpestyle.h> | 56 | #include <qpe/qpestyle.h> |
57 | #include <qpe/lightstyle.h> | 57 | #include <qpe/lightstyle.h> |
58 | #include <qpe/qlibrary.h> | 58 | #include <qpe/qlibrary.h> |
59 | #include <qpe/styleinterface.h> | 59 | #include <qpe/styleinterface.h> |
60 | 60 | ||
61 | #include <opie/ofontselector.h> | 61 | #include <opie/ofontselector.h> |
62 | #include <opie/odevice.h> | 62 | #include <opie/odevice.h> |
63 | #include <opie/ofiledialog.h> | 63 | #include <opie/ofiledialog.h> |
64 | #include <opie/otabwidget.h> | 64 | #include <opie/otabwidget.h> |
65 | 65 | ||
66 | #include "appearance.h" | 66 | #include "appearance.h" |
67 | #include "editScheme.h" | 67 | #include "editScheme.h" |
68 | #include "stylelistitem.h" | 68 | #include "stylelistitem.h" |
69 | #include "decolistitem.h" | 69 | #include "decolistitem.h" |
70 | #include "colorlistitem.h" | 70 | #include "colorlistitem.h" |
71 | #include "exceptlistitem.h" | 71 | #include "exceptlistitem.h" |
72 | #include "sample.h" | 72 | #include "sample.h" |
73 | 73 | ||
74 | 74 | ||
75 | using namespace Opie; | 75 | using namespace Opie; |
76 | 76 | ||
77 | 77 | ||
78 | class DefaultWindowDecoration : public WindowDecorationInterface | 78 | class DefaultWindowDecoration : public WindowDecorationInterface |
79 | { | 79 | { |
80 | public: | 80 | public: |
81 | DefaultWindowDecoration() : ref(0) {} | 81 | DefaultWindowDecoration() : ref(0) {} |
82 | QString name() const { | 82 | QString name() const { |
83 | return "Default"; | 83 | return "Default"; |
84 | } | 84 | } |
85 | QPixmap icon() const { | 85 | QPixmap icon() const { |
86 | return QPixmap(); | 86 | return QPixmap(); |
87 | } | 87 | } |
88 | QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { | 88 | QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { |
89 | *iface = 0; | 89 | *iface = 0; |
90 | if ( uuid == IID_QUnknown ) | 90 | if ( uuid == IID_QUnknown ) |
91 | *iface = this; | 91 | *iface = this; |
92 | else if ( uuid == IID_WindowDecoration ) | 92 | else if ( uuid == IID_WindowDecoration ) |
93 | *iface = this; | 93 | *iface = this; |
94 | 94 | ||
95 | if ( *iface ) | 95 | if ( *iface ) |
96 | (*iface)->addRef(); | 96 | (*iface)->addRef(); |
97 | return QS_OK; | 97 | return QS_OK; |
98 | } | 98 | } |
99 | Q_REFCOUNT | 99 | Q_REFCOUNT |
100 | 100 | ||
101 | private: | 101 | private: |
102 | ulong ref; | 102 | ulong ref; |
103 | }; | 103 | }; |
104 | 104 | ||
105 | 105 | ||
106 | 106 | ||
107 | 107 | ||
108 | 108 | ||
109 | 109 | ||
110 | 110 | ||
111 | QWidget *Appearance::createStyleTab ( QWidget *parent, Config &cfg ) | 111 | QWidget *Appearance::createStyleTab ( QWidget *parent, Config &cfg ) |
112 | { | 112 | { |
113 | QWidget* tab = new QWidget( parent, "StyleTab" ); | 113 | QWidget* tab = new QWidget( parent, "StyleTab" ); |
114 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 ); | 114 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 ); |
115 | 115 | ||
116 | m_style_list = new QListBox( tab, "m_style_list" ); | 116 | m_style_list = new QListBox( tab, "m_style_list" ); |
117 | vertLayout->addWidget( m_style_list ); | 117 | vertLayout->addWidget( m_style_list ); |
118 | 118 | ||
119 | m_style_settings = new QPushButton ( tr( "Settings..." ), tab ); | 119 | m_style_settings = new QPushButton ( tr( "Settings..." ), tab ); |
120 | connect ( m_style_settings, SIGNAL( clicked ( )), this, SLOT( styleSettingsClicked ( ))); | 120 | connect ( m_style_settings, SIGNAL( clicked ( )), this, SLOT( styleSettingsClicked ( ))); |
121 | vertLayout-> addWidget ( m_style_settings ); | 121 | vertLayout-> addWidget ( m_style_settings ); |
122 | 122 | ||
123 | QString s = cfg. readEntry ( "Style", "Light" ); | 123 | QString s = cfg. readEntry ( "Style", "Light" ); |
124 | 124 | ||
125 | 125 | ||
126 | #if QT_VERSION >= 300 | 126 | #if QT_VERSION >= 300 |
127 | m_style_list->insertStringList(QStyleFactory::styles()); | 127 | m_style_list->insertStringList(QStyleFactory::styles()); |
128 | #else | 128 | #else |
129 | m_style_list-> insertItem ( new StyleListItem ( "Windows", new QWindowsStyle ( ))); | 129 | m_style_list-> insertItem ( new StyleListItem ( "Windows", new QWindowsStyle ( ))); |
130 | m_style_list-> insertItem ( new StyleListItem ( "Light", new LightStyle ( ))); | 130 | m_style_list-> insertItem ( new StyleListItem ( "Light", new LightStyle ( ))); |
131 | m_style_list-> insertItem ( new StyleListItem ( "QPE", new QPEStyle ( ))); | 131 | m_style_list-> insertItem ( new StyleListItem ( "QPE", new QPEStyle ( ))); |
132 | #endif | 132 | #endif |
133 | { | 133 | { |
134 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/"; | 134 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/"; |
135 | QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); | 135 | QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); |
136 | 136 | ||
137 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { | 137 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { |
138 | QLibrary *lib = new QLibrary ( path + "/" + *it ); | 138 | QLibrary *lib = new QLibrary ( path + "/" + *it ); |
139 | StyleInterface *iface; | 139 | StyleInterface *iface; |
140 | 140 | ||
141 | if (( lib-> queryInterface ( IID_Style, (QUnknownInterface **) &iface ) == QS_OK ) && iface ) { | 141 | if (( lib-> queryInterface ( IID_Style, (QUnknownInterface **) &iface ) == QS_OK ) && iface ) { |
142 | StyleListItem *slit = new StyleListItem ( lib, iface ); | 142 | StyleListItem *slit = new StyleListItem ( lib, iface ); |
143 | m_style_list-> insertItem ( slit ); | 143 | m_style_list-> insertItem ( slit ); |
144 | 144 | ||
145 | if ( slit-> key ( ) == s ) | 145 | if ( slit-> key ( ) == s ) |
146 | m_style_list-> setCurrentItem ( slit ); | 146 | m_style_list-> setCurrentItem ( slit ); |
147 | } | 147 | } |
148 | else | 148 | else |
149 | delete lib; | 149 | delete lib; |
150 | } | 150 | } |
151 | } | 151 | } |
152 | 152 | ||
153 | m_original_style = m_style_list-> currentItem ( ); | 153 | m_original_style = m_style_list-> currentItem ( ); |
154 | styleClicked ( m_original_style ); | 154 | styleClicked ( m_original_style ); |
155 | 155 | ||
156 | connect( m_style_list, SIGNAL( highlighted( int ) ), this, SLOT( styleClicked( int ) ) ); | 156 | connect( m_style_list, SIGNAL( highlighted( int ) ), this, SLOT( styleClicked( int ) ) ); |
157 | 157 | ||
158 | return tab; | 158 | return tab; |
159 | } | 159 | } |
160 | 160 | ||
161 | QWidget *Appearance::createDecoTab ( QWidget *parent, Config &cfg ) | 161 | QWidget *Appearance::createDecoTab ( QWidget *parent, Config &cfg ) |
162 | { | 162 | { |
163 | QWidget* tab = new QWidget( parent, "DecoTab" ); | 163 | QWidget* tab = new QWidget( parent, "DecoTab" ); |
164 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 ); | 164 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 ); |
165 | 165 | ||
166 | m_deco_list = new QListBox( tab, "m_deco_list" ); | 166 | m_deco_list = new QListBox( tab, "m_deco_list" ); |
167 | vertLayout->addWidget( m_deco_list ); | 167 | vertLayout->addWidget( m_deco_list ); |
168 | 168 | ||
169 | QString s = cfg. readEntry ( "Decoration" ); | 169 | QString s = cfg. readEntry ( "Decoration" ); |
170 | 170 | ||
171 | m_deco_list-> insertItem ( new DecoListItem ( "QPE" )); | 171 | m_deco_list-> insertItem ( new DecoListItem ( "QPE" )); |
172 | 172 | ||
173 | { | 173 | { |
174 | QString path = QPEApplication::qpeDir() + "/plugins/decorations/"; | 174 | QString path = QPEApplication::qpeDir() + "/plugins/decorations/"; |
175 | QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); | 175 | QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); |
176 | 176 | ||
177 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { | 177 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { |
178 | QLibrary *lib = new QLibrary ( path + "/" + *it ); | 178 | QLibrary *lib = new QLibrary ( path + "/" + *it ); |
179 | WindowDecorationInterface *iface; | 179 | WindowDecorationInterface *iface; |
180 | 180 | ||
181 | if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK ) { | 181 | if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK ) { |
182 | DecoListItem *dlit = new DecoListItem ( lib, iface ); | 182 | DecoListItem *dlit = new DecoListItem ( lib, iface ); |
183 | m_deco_list-> insertItem ( dlit ); | 183 | m_deco_list-> insertItem ( dlit ); |
184 | 184 | ||
185 | if ( dlit-> key ( ) == s ) | 185 | if ( dlit-> key ( ) == s ) |
186 | m_deco_list-> setCurrentItem ( dlit ); | 186 | m_deco_list-> setCurrentItem ( dlit ); |
187 | } | 187 | } |
188 | else | 188 | else |
189 | delete lib; | 189 | delete lib; |
190 | } | 190 | } |
191 | } | 191 | } |
192 | 192 | ||
193 | m_original_deco = m_deco_list-> currentItem ( ); | 193 | m_original_deco = m_deco_list-> currentItem ( ); |
194 | if ( m_deco_list-> currentItem ( ) < 0 ) | 194 | if ( m_deco_list-> currentItem ( ) < 0 ) |
195 | m_deco_list-> setCurrentItem ( 0 ); | 195 | m_deco_list-> setCurrentItem ( 0 ); |
196 | decoClicked ( m_original_deco ); | 196 | decoClicked ( m_original_deco ); |
197 | 197 | ||
198 | connect( m_deco_list, SIGNAL( highlighted( int ) ), this, SLOT( decoClicked( int ) ) ); | 198 | connect( m_deco_list, SIGNAL( highlighted( int ) ), this, SLOT( decoClicked( int ) ) ); |
199 | 199 | ||
200 | return tab; | 200 | return tab; |
201 | } | 201 | } |
202 | 202 | ||
203 | QWidget *Appearance::createFontTab ( QWidget *parent, Config &cfg ) | 203 | QWidget *Appearance::createFontTab ( QWidget *parent, Config &cfg ) |
204 | { | 204 | { |
205 | QString familyStr = cfg. readEntry ( "FontFamily", "Helvetica" ); | 205 | QString familyStr = cfg. readEntry ( "FontFamily", "Helvetica" ); |
206 | QString styleStr = cfg. readEntry ( "FontStyle", "Regular" ); | 206 | QString styleStr = cfg. readEntry ( "FontStyle", "Regular" ); |
207 | int size = cfg. readNumEntry ( "FontSize", 10 ); | 207 | int size = cfg. readNumEntry ( "FontSize", 10 ); |
208 | 208 | ||
209 | m_fontselect = new OFontSelector ( false, parent, "FontTab" ); | 209 | m_fontselect = new OFontSelector ( false, parent, "FontTab" ); |
210 | m_fontselect-> setSelectedFont ( familyStr, styleStr, size ); | 210 | m_fontselect-> setSelectedFont ( familyStr, styleStr, size ); |
211 | 211 | ||
212 | connect( m_fontselect, SIGNAL( fontSelected ( const QFont & )), | 212 | connect( m_fontselect, SIGNAL( fontSelected ( const QFont & )), |
213 | this, SLOT( fontClicked ( const QFont & ))); | 213 | this, SLOT( fontClicked ( const QFont & ))); |
214 | 214 | ||
215 | return m_fontselect; | 215 | return m_fontselect; |
216 | } | 216 | } |
217 | 217 | ||
218 | QWidget *Appearance::createColorTab ( QWidget *parent, Config &cfg ) | 218 | QWidget *Appearance::createColorTab ( QWidget *parent, Config &cfg ) |
219 | { | 219 | { |
220 | QWidget *tab = new QWidget( parent, "ColorTab" ); | 220 | QWidget *tab = new QWidget( parent, "ColorTab" ); |
221 | QGridLayout *gridLayout = new QGridLayout( tab, 0, 0, 3, 3 ); | 221 | QGridLayout *gridLayout = new QGridLayout( tab, 0, 0, 3, 3 ); |
222 | gridLayout->setRowStretch ( 3, 10 ); | 222 | gridLayout->setRowStretch ( 3, 10 ); |
223 | 223 | ||
224 | m_color_list = new QListBox ( tab ); | 224 | m_color_list = new QListBox ( tab ); |
225 | gridLayout->addMultiCellWidget ( m_color_list, 0, 3, 0, 0 ); | 225 | gridLayout->addMultiCellWidget ( m_color_list, 0, 3, 0, 0 ); |
226 | connect( m_color_list, SIGNAL( highlighted( int ) ), this, SLOT( colorClicked( int ) ) ); | 226 | connect( m_color_list, SIGNAL( highlighted( int ) ), this, SLOT( colorClicked( int ) ) ); |
227 | 227 | ||
228 | m_color_list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), cfg )); | 228 | m_color_list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), cfg )); |
229 | 229 | ||
230 | QString path = QPEApplication::qpeDir ( ) + "/etc/colors/"; | 230 | QString path = QPEApplication::qpeDir ( ) + "/etc/colors/"; |
231 | QStringList sl = QDir ( path ). entryList ( "*.scheme" ); | 231 | QStringList sl = QDir ( path ). entryList ( "*.scheme" ); |
232 | 232 | ||
233 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { | 233 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { |
234 | QString name = (*it). left ((*it). find ( ".scheme" )); | 234 | QString name = (*it). left ((*it). find ( ".scheme" )); |
235 | Config config ( path + *it, Config::File ); | 235 | Config config ( path + *it, Config::File ); |
236 | config. setGroup ( "Colors" ); | 236 | config. setGroup ( "Colors" ); |
237 | 237 | ||
238 | m_color_list-> insertItem ( new ColorListItem ( name, config )); | 238 | m_color_list-> insertItem ( new ColorListItem ( name, config )); |
239 | } | 239 | } |
240 | 240 | ||
241 | m_color_list-> setCurrentItem ( 0 ); | 241 | m_color_list-> setCurrentItem ( 0 ); |
242 | 242 | ||
243 | QPushButton* tempButton = new QPushButton( tab, "editSchemeButton" ); | 243 | QPushButton* tempButton = new QPushButton( tab, "editSchemeButton" ); |
244 | tempButton->setText( tr( "Edit..." ) ); | 244 | tempButton->setText( tr( "Edit..." ) ); |
245 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( editSchemeClicked() ) ); | 245 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( editSchemeClicked() ) ); |
246 | gridLayout->addWidget( tempButton, 0, 1 ); | 246 | gridLayout->addWidget( tempButton, 0, 1 ); |
247 | 247 | ||
248 | tempButton = new QPushButton( tab, "deleteSchemeButton" ); | 248 | tempButton = new QPushButton( tab, "deleteSchemeButton" ); |
249 | tempButton->setText( tr( "Delete" ) ); | 249 | tempButton->setText( tr( "Delete" ) ); |
250 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( deleteSchemeClicked() ) ); | 250 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( deleteSchemeClicked() ) ); |
251 | gridLayout->addWidget( tempButton, 1, 1 ); | 251 | gridLayout->addWidget( tempButton, 1, 1 ); |
252 | 252 | ||
253 | tempButton = new QPushButton( tab, "saveSchemeButton" ); | 253 | tempButton = new QPushButton( tab, "saveSchemeButton" ); |
254 | tempButton->setText( tr( "Save" ) ); | 254 | tempButton->setText( tr( "Save" ) ); |
255 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( saveSchemeClicked() ) ); | 255 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( saveSchemeClicked() ) ); |
256 | gridLayout->addWidget( tempButton, 2, 1 ); | 256 | gridLayout->addWidget( tempButton, 2, 1 ); |
257 | 257 | ||
258 | return tab; | 258 | return tab; |
259 | } | 259 | } |
260 | 260 | ||
261 | QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg ) | 261 | QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg ) |
262 | { | 262 | { |
263 | QWidget *tab = new QWidget ( parent ); | 263 | QWidget *tab = new QWidget ( parent ); |
264 | QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 ); | 264 | QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 ); |
265 | 265 | ||
266 | QGridLayout *lay = new QGridLayout ( vertLayout, 0, 0, 3, 0 ); | 266 | QGridLayout *lay = new QGridLayout ( vertLayout, 0, 0, 3, 0 ); |
267 | 267 | ||
268 | m_force = new QCheckBox ( tr( "Force styling for all applications." ), tab ); | 268 | m_force = new QCheckBox ( tr( "Force styling for all applications." ), tab ); |
269 | m_force-> setChecked ( cfg. readBoolEntry ( "ForceStyle" )); | 269 | m_force-> setChecked ( cfg. readBoolEntry ( "ForceStyle" )); |
270 | lay-> addMultiCellWidget ( m_force, 0, 0, 0, 1 ); | 270 | lay-> addMultiCellWidget ( m_force, 0, 0, 0, 1 ); |
271 | 271 | ||
272 | QLabel *l = new QLabel ( tab ); | 272 | QLabel *l = new QLabel ( tab ); |
273 | l-> setText ( QString ( "<p>%1</p>" ). arg ( tr( "Disable styling for these applications ( <b>*</b> can be used as a wildcard):" ))); | 273 | l-> setText ( QString ( "<p>%1</p>" ). arg ( tr( "Disable styling for these applications ( <b>*</b> can be used as a wildcard):" ))); |
274 | lay-> addMultiCellWidget ( l, 1, 1, 0, 1 ); | 274 | lay-> addMultiCellWidget ( l, 1, 1, 0, 1 ); |
275 | 275 | ||
276 | m_except = new QListView ( tab ); | 276 | m_except = new QListView ( tab ); |
277 | m_except-> addColumn ( Resource::loadIconSet ( "appearance/style.png" ), "", 24 ); | 277 | m_except-> addColumn ( Resource::loadIconSet ( "appearance/style.png" ), "", 24 ); |
278 | m_except-> addColumn ( Resource::loadIconSet ( "appearance/font.png" ), "", 24 ); | 278 | m_except-> addColumn ( Resource::loadIconSet ( "appearance/font.png" ), "", 24 ); |
279 | m_except-> addColumn ( Resource::loadIconSet ( "appearance/deco.png" ), "", 24 ); | 279 | m_except-> addColumn ( Resource::loadIconSet ( "appearance/deco.png" ), "", 24 ); |
280 | m_except-> addColumn ( tr( "Binary file(s)" )); | 280 | m_except-> addColumn ( tr( "Binary file(s)" )); |
281 | m_except-> setColumnAlignment ( 0, AlignCenter ); | 281 | m_except-> setColumnAlignment ( 0, AlignCenter ); |
282 | m_except-> setColumnAlignment ( 1, AlignCenter ); | 282 | m_except-> setColumnAlignment ( 1, AlignCenter ); |
283 | m_except-> setColumnAlignment ( 2, AlignCenter ); | 283 | m_except-> setColumnAlignment ( 2, AlignCenter ); |
284 | m_except-> setAllColumnsShowFocus ( true ); | 284 | m_except-> setAllColumnsShowFocus ( true ); |
285 | m_except-> setMinimumHeight ( 30 ); | 285 | m_except-> setMinimumHeight ( 30 ); |
286 | m_except-> header ( )-> setClickEnabled ( false ); | 286 | m_except-> header ( )-> setClickEnabled ( false ); |
287 | m_except-> header ( )-> setResizeEnabled ( false ); | 287 | m_except-> header ( )-> setResizeEnabled ( false ); |
288 | m_except-> header ( )-> setMovingEnabled ( false ); | 288 | m_except-> header ( )-> setMovingEnabled ( false ); |
289 | m_except-> setSorting ( -1 ); | ||
289 | lay-> addMultiCellWidget ( m_except, 2, 6, 0, 0 ); | 290 | lay-> addMultiCellWidget ( m_except, 2, 6, 0, 0 ); |
290 | 291 | ||
291 | connect ( m_except, SIGNAL( clicked ( QListViewItem *, const QPoint &, int )), this, SLOT( clickedExcept ( QListViewItem *, const QPoint &, int ))); | 292 | connect ( m_except, SIGNAL( clicked ( QListViewItem *, const QPoint &, int )), this, SLOT( clickedExcept ( QListViewItem *, const QPoint &, int ))); |
292 | 293 | ||
293 | QToolButton *tb = new QToolButton ( tab ); | 294 | QToolButton *tb = new QToolButton ( tab ); |
294 | tb-> setIconSet ( Resource::loadIconSet ( "appearance/add" )); | 295 | tb-> setIconSet ( Resource::loadIconSet ( "appearance/add" )); |
295 | tb-> setFocusPolicy ( QWidget::StrongFocus ); | 296 | tb-> setFocusPolicy ( QWidget::StrongFocus ); |
296 | lay-> addWidget ( tb, 2, 1 ); | 297 | lay-> addWidget ( tb, 2, 1 ); |
297 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( addExcept ( ))); | 298 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( addExcept ( ))); |
298 | 299 | ||
299 | tb = new QToolButton ( tab ); | 300 | tb = new QToolButton ( tab ); |
300 | tb-> setIconSet ( Resource::loadIconSet ( "editdelete" )); | 301 | tb-> setIconSet ( Resource::loadIconSet ( "editdelete" )); |
301 | tb-> setFocusPolicy ( QWidget::StrongFocus ); | 302 | tb-> setFocusPolicy ( QWidget::StrongFocus ); |
302 | lay-> addWidget ( tb, 3, 1 ); | 303 | lay-> addWidget ( tb, 3, 1 ); |
303 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( delExcept ( ))); | 304 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( delExcept ( ))); |
304 | 305 | ||
305 | tb = new QToolButton ( tab ); | 306 | tb = new QToolButton ( tab ); |
306 | tb-> setIconSet ( Resource::loadIconSet ( "up" )); | 307 | tb-> setIconSet ( Resource::loadIconSet ( "up" )); |
307 | tb-> setFocusPolicy ( QWidget::StrongFocus ); | 308 | tb-> setFocusPolicy ( QWidget::StrongFocus ); |
308 | lay-> addWidget ( tb, 4, 1 ); | 309 | lay-> addWidget ( tb, 4, 1 ); |
309 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( upExcept ( ))); | 310 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( upExcept ( ))); |
310 | 311 | ||
311 | tb = new QToolButton ( tab ); | 312 | tb = new QToolButton ( tab ); |
312 | tb-> setIconSet ( Resource::loadIconSet ( "down" )); | 313 | tb-> setIconSet ( Resource::loadIconSet ( "down" )); |
313 | tb-> setFocusPolicy ( QWidget::StrongFocus ); | 314 | tb-> setFocusPolicy ( QWidget::StrongFocus ); |
314 | lay-> addWidget ( tb, 5, 1 ); | 315 | lay-> addWidget ( tb, 5, 1 ); |
315 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( downExcept ( ))); | 316 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( downExcept ( ))); |
316 | 317 | ||
317 | lay-> setRowStretch ( 6, 10 ); | 318 | lay-> setRowStretch ( 6, 10 ); |
318 | lay-> setColStretch ( 0, 10 ); | 319 | lay-> setColStretch ( 0, 10 ); |
319 | 320 | ||
320 | QStringList sl = cfg. readListEntry ( "NoStyle", ';' ); | 321 | QStringList sl = cfg. readListEntry ( "NoStyle", ';' ); |
322 | QListViewItem *lvit = 0; | ||
321 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { | 323 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { |
322 | int fl = ( *it ). left ( 1 ). toInt ( 0, 32 ); | 324 | int fl = ( *it ). left ( 1 ). toInt ( 0, 32 ); |
323 | 325 | ||
324 | new ExceptListItem ( m_except, ( *it ). mid ( 1 ), fl & 0x01, fl & 0x02, fl & 0x04 ); | 326 | lvit = new ExceptListItem ( m_except, lvit, ( *it ). mid ( 1 ), fl & 0x01, fl & 0x02, fl & 0x04 ); |
325 | } | 327 | } |
326 | 328 | ||
327 | 329 | ||
328 | vertLayout-> addSpacing ( 3 ); | 330 | vertLayout-> addSpacing ( 3 ); |
329 | QFrame *f = new QFrame ( tab ); | 331 | QFrame *f = new QFrame ( tab ); |
330 | f-> setFrameStyle ( QFrame::HLine | QFrame::Sunken ); | 332 | f-> setFrameStyle ( QFrame::HLine | QFrame::Sunken ); |
331 | vertLayout-> addWidget ( f ); | 333 | vertLayout-> addWidget ( f ); |
332 | vertLayout-> addSpacing ( 3 ); | 334 | vertLayout-> addSpacing ( 3 ); |
333 | 335 | ||
334 | 336 | ||
335 | QGridLayout* gridLayout = new QGridLayout ( vertLayout, 0, 0, 3, 0 ); | 337 | QGridLayout* gridLayout = new QGridLayout ( vertLayout, 0, 0, 3, 0 ); |
336 | 338 | ||
337 | int style = cfg. readNumEntry ( "TabStyle", 2 ) - 1; | 339 | int style = cfg. readNumEntry ( "TabStyle", 2 ) - 1; |
338 | bool tabtop = ( cfg. readEntry ( "TabPosition", "Top" ) == "Top" ); | 340 | bool tabtop = ( cfg. readEntry ( "TabPosition", "Top" ) == "Top" ); |
339 | 341 | ||
340 | QLabel* label = new QLabel( tr( "Tab style:" ), tab ); | 342 | QLabel* label = new QLabel( tr( "Tab style:" ), tab ); |
341 | gridLayout-> addWidget ( label, 0, 0 ); | 343 | gridLayout-> addWidget ( label, 0, 0 ); |
342 | QButtonGroup* btngrp = new QButtonGroup( tab, "buttongroup" ); | 344 | QButtonGroup* btngrp = new QButtonGroup( tab, "buttongroup" ); |
343 | btngrp-> hide ( ); | 345 | btngrp-> hide ( ); |
344 | btngrp-> setExclusive ( true ); | 346 | btngrp-> setExclusive ( true ); |
345 | 347 | ||
346 | m_tabstyle_list = new QComboBox ( false, tab, "tabstyle" ); | 348 | m_tabstyle_list = new QComboBox ( false, tab, "tabstyle" ); |
347 | m_tabstyle_list-> insertItem ( tr( "Tabs" )); | 349 | m_tabstyle_list-> insertItem ( tr( "Tabs" )); |
348 | m_tabstyle_list-> insertItem ( tr( "Tabs w/icons" )); | 350 | m_tabstyle_list-> insertItem ( tr( "Tabs w/icons" )); |
349 | m_tabstyle_list-> insertItem ( tr( "Drop down list" )); | 351 | m_tabstyle_list-> insertItem ( tr( "Drop down list" )); |
350 | m_tabstyle_list-> insertItem ( tr( "Drop down list w/icons" )); | 352 | m_tabstyle_list-> insertItem ( tr( "Drop down list w/icons" )); |
351 | m_tabstyle_list-> setCurrentItem ( style ); | 353 | m_tabstyle_list-> setCurrentItem ( style ); |
352 | gridLayout-> addMultiCellWidget ( m_tabstyle_list, 0, 0, 1, 2 ); | 354 | gridLayout-> addMultiCellWidget ( m_tabstyle_list, 0, 0, 1, 2 ); |
353 | 355 | ||
354 | m_tabstyle_top = new QRadioButton( tr( "Top" ), tab, "tabpostop" ); | 356 | m_tabstyle_top = new QRadioButton( tr( "Top" ), tab, "tabpostop" ); |
355 | btngrp-> insert ( m_tabstyle_top ); | 357 | btngrp-> insert ( m_tabstyle_top ); |
356 | gridLayout-> addWidget( m_tabstyle_top, 1, 1 ); | 358 | gridLayout-> addWidget( m_tabstyle_top, 1, 1 ); |
357 | 359 | ||
358 | m_tabstyle_bottom = new QRadioButton( tr( "Bottom" ), tab, "tabposbottom" ); | 360 | m_tabstyle_bottom = new QRadioButton( tr( "Bottom" ), tab, "tabposbottom" ); |
359 | btngrp-> insert ( m_tabstyle_bottom ); | 361 | btngrp-> insert ( m_tabstyle_bottom ); |
360 | gridLayout-> addWidget( m_tabstyle_bottom, 1, 2 ); | 362 | gridLayout-> addWidget( m_tabstyle_bottom, 1, 2 ); |
361 | 363 | ||
362 | m_tabstyle_top-> setChecked ( tabtop ); | 364 | m_tabstyle_top-> setChecked ( tabtop ); |
363 | m_tabstyle_bottom-> setChecked ( !tabtop ); | 365 | m_tabstyle_bottom-> setChecked ( !tabtop ); |
364 | 366 | ||
365 | m_original_tabstyle = style; | 367 | m_original_tabstyle = style; |
366 | m_original_tabpos = tabtop; | 368 | m_original_tabpos = tabtop; |
367 | 369 | ||
368 | return tab; | 370 | return tab; |
369 | } | 371 | } |
370 | 372 | ||
371 | 373 | ||
372 | Appearance::Appearance( QWidget* parent, const char* name, WFlags ) | 374 | Appearance::Appearance( QWidget* parent, const char* name, WFlags ) |
373 | : QDialog ( parent, name, true ) | 375 | : QDialog ( parent, name, true ) |
374 | { | 376 | { |
375 | setCaption( tr( "Appearance" ) ); | 377 | setCaption( tr( "Appearance" ) ); |
376 | 378 | ||
377 | Config config( "qpe" ); | 379 | Config config( "qpe" ); |
378 | config.setGroup( "Appearance" ); | 380 | config.setGroup( "Appearance" ); |
379 | 381 | ||
380 | QVBoxLayout *top = new QVBoxLayout ( this, 3, 3 ); | 382 | QVBoxLayout *top = new QVBoxLayout ( this, 3, 3 ); |
381 | 383 | ||
382 | m_sample = new SampleWindow ( this ); | 384 | m_sample = new SampleWindow ( this ); |
383 | m_sample-> setDecoration ( new DefaultWindowDecoration ( )); | 385 | m_sample-> setDecoration ( new DefaultWindowDecoration ( )); |
384 | 386 | ||
385 | OTabWidget* tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); | 387 | OTabWidget* tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); |
386 | QWidget *styletab; | 388 | QWidget *styletab; |
387 | 389 | ||
388 | tw-> addTab ( styletab = createStyleTab ( tw, config ), "appearance/style.png", tr( "Style" )); | 390 | tw-> addTab ( styletab = createStyleTab ( tw, config ), "appearance/style.png", tr( "Style" )); |
389 | tw-> addTab ( createFontTab ( tw, config ), "appearance/font.png", tr( "Font" )); | 391 | tw-> addTab ( createFontTab ( tw, config ), "appearance/font.png", tr( "Font" )); |
390 | tw-> addTab ( createColorTab ( tw, config ), "appearance/color.png", tr( "Colors" ) ); | 392 | tw-> addTab ( createColorTab ( tw, config ), "appearance/color.png", tr( "Colors" ) ); |
391 | tw-> addTab ( createDecoTab ( tw, config ), "appearance/deco.png", tr( "Windows" ) ); | 393 | tw-> addTab ( createDecoTab ( tw, config ), "appearance/deco.png", tr( "Windows" ) ); |
392 | tw-> addTab ( m_advtab = createAdvancedTab ( tw, config ), "appearance/advanced.png", tr( "Advanced" ) ); | 394 | tw-> addTab ( m_advtab = createAdvancedTab ( tw, config ), "appearance/advanced.png", tr( "Advanced" ) ); |
393 | 395 | ||
394 | top-> addWidget ( tw, 10 ); | 396 | top-> addWidget ( tw, 10 ); |
395 | top-> addWidget ( m_sample, 1 ); | 397 | top-> addWidget ( m_sample, 1 ); |
396 | 398 | ||
397 | tw-> setCurrentTab ( styletab ); | 399 | tw-> setCurrentTab ( styletab ); |
398 | connect ( tw, SIGNAL( currentChanged ( QWidget * )), this, SLOT( tabChanged ( QWidget * ))); | 400 | connect ( tw, SIGNAL( currentChanged ( QWidget * )), this, SLOT( tabChanged ( QWidget * ))); |
399 | 401 | ||
400 | m_style_changed = m_font_changed = m_color_changed = m_deco_changed = false; | 402 | m_style_changed = m_font_changed = m_color_changed = m_deco_changed = false; |
401 | } | 403 | } |
402 | 404 | ||
403 | Appearance::~Appearance() | 405 | Appearance::~Appearance() |
404 | { | 406 | { |
405 | } | 407 | } |
406 | 408 | ||
407 | void Appearance::tabChanged ( QWidget *w ) | 409 | void Appearance::tabChanged ( QWidget *w ) |
408 | { | 410 | { |
409 | if ( w == m_advtab ) { | 411 | if ( w == m_advtab ) { |
410 | m_sample-> hide ( ); | 412 | m_sample-> hide ( ); |
411 | updateGeometry ( ); // shouldn't be necessary ... | 413 | updateGeometry ( ); // shouldn't be necessary ... |
412 | } | 414 | } |
413 | else | 415 | else |
414 | m_sample-> show ( ); | 416 | m_sample-> show ( ); |
415 | } | 417 | } |
416 | 418 | ||
417 | void Appearance::accept ( ) | 419 | void Appearance::accept ( ) |
418 | { | 420 | { |
419 | bool newtabpos = m_tabstyle_top-> isChecked ( ); | 421 | bool newtabpos = m_tabstyle_top-> isChecked ( ); |
420 | int newtabstyle = m_tabstyle_list-> currentItem ( ); | 422 | int newtabstyle = m_tabstyle_list-> currentItem ( ); |
421 | 423 | ||
422 | Config config ( "qpe" ); | 424 | Config config ( "qpe" ); |
423 | config. setGroup ( "Appearance" ); | 425 | config. setGroup ( "Appearance" ); |
424 | 426 | ||
425 | if ( m_style_changed ) { | 427 | if ( m_style_changed ) { |
426 | StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); | 428 | StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); |
427 | if ( item ) | 429 | if ( item ) |
428 | config.writeEntry( "Style", item-> key ( )); | 430 | config.writeEntry( "Style", item-> key ( )); |
429 | } | 431 | } |
430 | 432 | ||
431 | if ( m_deco_changed ) { | 433 | if ( m_deco_changed ) { |
432 | DecoListItem *item = (DecoListItem *) m_deco_list-> item ( m_deco_list-> currentItem ( )); | 434 | DecoListItem *item = (DecoListItem *) m_deco_list-> item ( m_deco_list-> currentItem ( )); |
433 | if ( item ) | 435 | if ( item ) |
434 | config.writeEntry( "Decoration", item-> key ( )); | 436 | config.writeEntry( "Decoration", item-> key ( )); |
435 | } | 437 | } |
436 | 438 | ||
437 | if (( newtabstyle != m_original_tabstyle ) || ( newtabpos != m_original_tabpos )) { | 439 | if (( newtabstyle != m_original_tabstyle ) || ( newtabpos != m_original_tabpos )) { |
438 | config. writeEntry ( "TabStyle", newtabstyle + 1 ); | 440 | config. writeEntry ( "TabStyle", newtabstyle + 1 ); |
439 | config. writeEntry ( "TabPosition", newtabpos ? "Top" : "Bottom" ); | 441 | config. writeEntry ( "TabPosition", newtabpos ? "Top" : "Bottom" ); |
440 | } | 442 | } |
441 | 443 | ||
442 | if ( m_font_changed ) { | 444 | if ( m_font_changed ) { |
443 | config. writeEntry ( "FontFamily", m_fontselect-> fontFamily ( )); | 445 | config. writeEntry ( "FontFamily", m_fontselect-> fontFamily ( )); |
444 | config. writeEntry ( "FontStyle", m_fontselect-> fontStyle ( )); | 446 | config. writeEntry ( "FontStyle", m_fontselect-> fontStyle ( )); |
445 | config. writeEntry ( "FontSize", m_fontselect-> fontSize ( )); | 447 | config. writeEntry ( "FontSize", m_fontselect-> fontSize ( )); |
446 | } | 448 | } |
447 | 449 | ||
448 | 450 | ||
449 | if ( m_color_changed ) | 451 | if ( m_color_changed ) |
450 | { | 452 | { |
451 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); | 453 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); |
452 | 454 | ||
453 | if ( item ) | 455 | if ( item ) |
454 | item-> save ( config ); | 456 | item-> save ( config ); |
455 | } | 457 | } |
456 | 458 | ||
457 | 459 | ||
460 | m_except-> setFocus ( ); // if the focus was on the embedded line-edit, we have to move it away first, so the contents are updated | ||
461 | |||
458 | QStringList sl; | 462 | QStringList sl; |
459 | for ( ExceptListItem *it = (ExceptListItem *) m_except-> firstChild ( ); it; it = (ExceptListItem *) it-> nextSibling ( )) { | 463 | for ( ExceptListItem *it = (ExceptListItem *) m_except-> firstChild ( ); it; it = (ExceptListItem *) it-> nextSibling ( )) { |
460 | int fl = 0; | 464 | int fl = 0; |
461 | fl |= ( it-> noStyle ( ) ? 0x01 : 0 ); | 465 | fl |= ( it-> noStyle ( ) ? 0x01 : 0 ); |
462 | fl |= ( it-> noFont ( ) ? 0x02 : 0 ); | 466 | fl |= ( it-> noFont ( ) ? 0x02 : 0 ); |
463 | fl |= ( it-> noDeco ( ) ? 0x04 : 0 ); | 467 | fl |= ( it-> noDeco ( ) ? 0x04 : 0 ); |
464 | sl << ( QString::number ( fl, 32 ) + it-> pattern ( )); | 468 | sl << ( QString::number ( fl, 32 ) + it-> pattern ( )); |
465 | } | 469 | } |
466 | config. writeEntry ( "NoStyle", sl, ';' ); | 470 | config. writeEntry ( "NoStyle", sl, ';' ); |
467 | config. writeEntry ( "ForceStyle", m_force-> isChecked ( )); | 471 | config. writeEntry ( "ForceStyle", m_force-> isChecked ( )); |
468 | 472 | ||
469 | config. write ( ); // need to flush the config info first | 473 | config. write ( ); // need to flush the config info first |
470 | Global::applyStyle ( ); | 474 | Global::applyStyle ( ); |
471 | 475 | ||
472 | if ( QMessageBox::warning ( this, tr( "Restart" ), tr( "Do you want to restart %1 now?" ). arg ( ODevice::inst ( )-> system ( ) == System_Zaurus ? "Qtopia" : "Opie" ), tr( "Yes" ), tr( "No" ), 0, 0, 1 ) == 0 ) { | 476 | if ( QMessageBox::warning ( this, tr( "Restart" ), tr( "Do you want to restart %1 now?" ). arg ( ODevice::inst ( )-> system ( ) == System_Zaurus ? "Qtopia" : "Opie" ), tr( "Yes" ), tr( "No" ), 0, 0, 1 ) == 0 ) { |
473 | QCopEnvelope e( "QPE/System", "restart()" ); | 477 | QCopEnvelope e( "QPE/System", "restart()" ); |
474 | } | 478 | } |
475 | 479 | ||
476 | QDialog::accept ( ); | 480 | QDialog::accept ( ); |
477 | } | 481 | } |
478 | 482 | ||
479 | void Appearance::done ( int r ) | 483 | void Appearance::done ( int r ) |
480 | { | 484 | { |
481 | QDialog::done ( r ); | 485 | QDialog::done ( r ); |
482 | close ( ); | 486 | close ( ); |
483 | } | 487 | } |
484 | 488 | ||
485 | 489 | ||
486 | void Appearance::styleClicked ( int index ) | 490 | void Appearance::styleClicked ( int index ) |
487 | { | 491 | { |
488 | StyleListItem *sli = (StyleListItem *) m_style_list-> item ( index ); | 492 | StyleListItem *sli = (StyleListItem *) m_style_list-> item ( index ); |
489 | m_style_settings-> setEnabled ( sli ? sli-> hasSettings ( ) : false ); | 493 | m_style_settings-> setEnabled ( sli ? sli-> hasSettings ( ) : false ); |
490 | 494 | ||
491 | if ( m_sample && sli && sli-> style ( )) | 495 | if ( m_sample && sli && sli-> style ( )) |
492 | m_sample-> setStyle2 ( sli-> style ( )); | 496 | m_sample-> setStyle2 ( sli-> style ( )); |
493 | 497 | ||
494 | m_style_changed |= ( index != m_original_style ); | 498 | m_style_changed |= ( index != m_original_style ); |
495 | } | 499 | } |
496 | 500 | ||
497 | void Appearance::styleSettingsClicked ( ) | 501 | void Appearance::styleSettingsClicked ( ) |
498 | { | 502 | { |
499 | StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); | 503 | StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); |
500 | 504 | ||
501 | if ( item && item-> hasSettings ( )) { | 505 | if ( item && item-> hasSettings ( )) { |
502 | QDialog *d = new QDialog ( this, "SETTINGS-DLG", true ); | 506 | QDialog *d = new QDialog ( this, "SETTINGS-DLG", true ); |
503 | QVBoxLayout *vbox = new QVBoxLayout ( d, 3, 0 ); | 507 | QVBoxLayout *vbox = new QVBoxLayout ( d, 3, 0 ); |
504 | 508 | ||
505 | QWidget *w = item-> settings ( d ); | 509 | QWidget *w = item-> settings ( d ); |
506 | 510 | ||
507 | if ( w ) { | 511 | if ( w ) { |
508 | vbox-> addWidget ( w ); | 512 | vbox-> addWidget ( w ); |
509 | 513 | ||
510 | d-> setCaption ( w-> caption ( )); | 514 | d-> setCaption ( w-> caption ( )); |
511 | 515 | ||
512 | d-> showMaximized ( ); | 516 | d-> showMaximized ( ); |
513 | bool accepted = ( d-> exec ( ) == QDialog::Accepted ); | 517 | bool accepted = ( d-> exec ( ) == QDialog::Accepted ); |
514 | 518 | ||
515 | if ( item-> setSettings ( accepted )) | 519 | if ( item-> setSettings ( accepted )) |
516 | m_style_changed = true; | 520 | m_style_changed = true; |
517 | } | 521 | } |
518 | delete d; | 522 | delete d; |
519 | } | 523 | } |
520 | } | 524 | } |
521 | 525 | ||
522 | void Appearance::decoClicked ( int index ) | 526 | void Appearance::decoClicked ( int index ) |
523 | { | 527 | { |
524 | DecoListItem *dli = (DecoListItem *) m_deco_list-> item ( index ); | 528 | DecoListItem *dli = (DecoListItem *) m_deco_list-> item ( index ); |
525 | 529 | ||
526 | if ( m_sample ) { | 530 | if ( m_sample ) { |
527 | if ( dli && dli-> interface ( )) | 531 | if ( dli && dli-> interface ( )) |
528 | m_sample-> setDecoration ( dli-> interface ( )); | 532 | m_sample-> setDecoration ( dli-> interface ( )); |
529 | else | 533 | else |
530 | m_sample-> setDecoration ( new DefaultWindowDecoration ( )); | 534 | m_sample-> setDecoration ( new DefaultWindowDecoration ( )); |
531 | m_sample-> repaint ( ); | 535 | m_sample-> repaint ( ); |
532 | } | 536 | } |
533 | m_deco_changed |= ( index != m_original_deco ); | 537 | m_deco_changed |= ( index != m_original_deco ); |
534 | } | 538 | } |
535 | 539 | ||
536 | void Appearance::fontClicked ( const QFont &f ) | 540 | void Appearance::fontClicked ( const QFont &f ) |
537 | { | 541 | { |
538 | m_font_changed |= ( f != m_sample-> font ( )); | 542 | m_font_changed |= ( f != m_sample-> font ( )); |
539 | m_sample-> setFont ( f ); | 543 | m_sample-> setFont ( f ); |
540 | } | 544 | } |
541 | 545 | ||
542 | void Appearance::colorClicked ( int index ) | 546 | void Appearance::colorClicked ( int index ) |
543 | { | 547 | { |
544 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( index ); | 548 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( index ); |
545 | 549 | ||
546 | if ( item ) | 550 | if ( item ) |
547 | m_sample-> setPalette ( item-> palette ( )); | 551 | m_sample-> setPalette ( item-> palette ( )); |
548 | 552 | ||
549 | m_color_changed |= ( item-> palette ( ) != qApp-> palette ( )); | 553 | m_color_changed |= ( item-> palette ( ) != qApp-> palette ( )); |
550 | } | 554 | } |
551 | 555 | ||
552 | 556 | ||
553 | void Appearance::editSchemeClicked ( ) | 557 | void Appearance::editSchemeClicked ( ) |
554 | { | 558 | { |
555 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); | 559 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); |
556 | 560 | ||
557 | int cnt = 0; | 561 | int cnt = 0; |
558 | QString labels [QColorGroup::NColorRoles]; | 562 | QString labels [QColorGroup::NColorRoles]; |
559 | QColor colors [QColorGroup::NColorRoles]; | 563 | QColor colors [QColorGroup::NColorRoles]; |
560 | 564 | ||
561 | for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { | 565 | for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { |
562 | QColor col = item-> color ( role ); | 566 | QColor col = item-> color ( role ); |
563 | 567 | ||
564 | if ( col. isValid ( )) { | 568 | if ( col. isValid ( )) { |
565 | labels [cnt] = item-> label ( role ); | 569 | labels [cnt] = item-> label ( role ); |
566 | colors [cnt] = col; | 570 | colors [cnt] = col; |
567 | 571 | ||
568 | cnt++; | 572 | cnt++; |
569 | } | 573 | } |
570 | } | 574 | } |
571 | 575 | ||
572 | EditScheme* editdlg = new EditScheme( cnt, labels, colors, this, "editScheme", true ); | 576 | EditScheme* editdlg = new EditScheme( cnt, labels, colors, this, "editScheme", true ); |
573 | editdlg-> showMaximized ( ); | 577 | editdlg-> showMaximized ( ); |
574 | if ( editdlg-> exec ( ) == QDialog::Accepted ) { | 578 | if ( editdlg-> exec ( ) == QDialog::Accepted ) { |
575 | ColorListItem *citem = (ColorListItem *) m_color_list-> item ( 0 ); | 579 | ColorListItem *citem = (ColorListItem *) m_color_list-> item ( 0 ); |
576 | cnt = 0; | 580 | cnt = 0; |
577 | 581 | ||
578 | for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { | 582 | for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { |
579 | if ( item-> color ( role ). isValid ( )) { | 583 | if ( item-> color ( role ). isValid ( )) { |
580 | citem-> setColor ( role, colors [cnt] ); | 584 | citem-> setColor ( role, colors [cnt] ); |
581 | cnt++; | 585 | cnt++; |
582 | } | 586 | } |
583 | } | 587 | } |
584 | 588 | ||
585 | m_color_list-> setCurrentItem ( 0 ); | 589 | m_color_list-> setCurrentItem ( 0 ); |
586 | colorClicked ( 0 ); | 590 | colorClicked ( 0 ); |
587 | 591 | ||
588 | m_color_changed = true; | 592 | m_color_changed = true; |
589 | } | 593 | } |
590 | delete editdlg; | 594 | delete editdlg; |
591 | } | 595 | } |
592 | 596 | ||
593 | 597 | ||
594 | void Appearance::saveSchemeClicked() | 598 | void Appearance::saveSchemeClicked() |
595 | { | 599 | { |
596 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); | 600 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); |
597 | 601 | ||
598 | if ( !item ) | 602 | if ( !item ) |
599 | return; | 603 | return; |
600 | 604 | ||
601 | QDialog *d = new QDialog ( this, 0, true ); | 605 | QDialog *d = new QDialog ( this, 0, true ); |
602 | d-> setCaption ( tr( "Save Scheme" )); | 606 | d-> setCaption ( tr( "Save Scheme" )); |
603 | QLineEdit *ed = new QLineEdit ( d ); | 607 | QLineEdit *ed = new QLineEdit ( d ); |
604 | ( new QVBoxLayout ( d, 3, 3 ))-> addWidget ( ed ); | 608 | ( new QVBoxLayout ( d, 3, 3 ))-> addWidget ( ed ); |
605 | ed-> setFocus ( ); | 609 | ed-> setFocus ( ); |
606 | 610 | ||
607 | if ( d-> exec ( ) == QDialog::Accepted ) { | 611 | if ( d-> exec ( ) == QDialog::Accepted ) { |
608 | QString schemename = ed-> text ( ); | 612 | QString schemename = ed-> text ( ); |
609 | QFile file ( QPEApplication::qpeDir() + "/etc/colors/" + schemename + ".scheme" ); | 613 | QFile file ( QPEApplication::qpeDir() + "/etc/colors/" + schemename + ".scheme" ); |
610 | if ( !file. exists ( )) | 614 | if ( !file. exists ( )) |
611 | { | 615 | { |
612 | QPalette p = item-> palette ( ); | 616 | QPalette p = item-> palette ( ); |
613 | 617 | ||
614 | Config config ( file.name(), Config::File ); | 618 | Config config ( file.name(), Config::File ); |
615 | config. setGroup( "Colors" ); | 619 | config. setGroup( "Colors" ); |
616 | 620 | ||
617 | item-> save ( config ); | 621 | item-> save ( config ); |
618 | 622 | ||
619 | config. write ( ); // need to flush the config info first | 623 | config. write ( ); // need to flush the config info first |
620 | 624 | ||
621 | m_color_list-> insertItem ( new ColorListItem ( schemename, config )); | 625 | m_color_list-> insertItem ( new ColorListItem ( schemename, config )); |
622 | } | 626 | } |
623 | else | 627 | else |
624 | { | 628 | { |
625 | QMessageBox::information ( this, tr( "Save scheme" ), tr( "Scheme does already exist." )); | 629 | QMessageBox::information ( this, tr( "Save scheme" ), tr( "Scheme does already exist." )); |
626 | } | 630 | } |
627 | } | 631 | } |
628 | delete d; | 632 | delete d; |
629 | } | 633 | } |
630 | 634 | ||
631 | void Appearance::deleteSchemeClicked() | 635 | void Appearance::deleteSchemeClicked() |
632 | { | 636 | { |
633 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); | 637 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); |
634 | 638 | ||
635 | if ( !item ) | 639 | if ( !item ) |
636 | return; | 640 | return; |
637 | 641 | ||
638 | if ( m_color_list-> currentItem ( ) > 0 ) | 642 | if ( m_color_list-> currentItem ( ) > 0 ) |
639 | { | 643 | { |
640 | if ( QMessageBox::warning ( this, tr( "Delete scheme" ), tr( "Do you really want to delete\n" ) + item-> text ( ) + "?", | 644 | if ( QMessageBox::warning ( this, tr( "Delete scheme" ), tr( "Do you really want to delete\n" ) + item-> text ( ) + "?", |
641 | tr( "Yes" ), tr( "No" ), 0, 0, 1 ) == 0 ) { | 645 | tr( "Yes" ), tr( "No" ), 0, 0, 1 ) == 0 ) { |
642 | QFile::remove ( QPEApplication::qpeDir ( ) + "/etc/colors/" + item-> text ( ) + ".scheme" ); | 646 | QFile::remove ( QPEApplication::qpeDir ( ) + "/etc/colors/" + item-> text ( ) + ".scheme" ); |
643 | delete item; | 647 | delete item; |
644 | } | 648 | } |
645 | } | 649 | } |
646 | else | 650 | else |
647 | { | 651 | { |
648 | QMessageBox::information( this, tr( "Delete scheme" ), tr( "Unable to delete current scheme." )); | 652 | QMessageBox::information( this, tr( "Delete scheme" ), tr( "Unable to delete current scheme." )); |
649 | } | 653 | } |
650 | } | 654 | } |
651 | 655 | ||
652 | 656 | ||
653 | void Appearance::addExcept ( ) | 657 | void Appearance::addExcept ( ) |
654 | { | 658 | { |
655 | ExceptListItem *it = new ExceptListItem ( m_except, tr( "<new>" ), true, true, true ); | 659 | ExceptListItem *it = new ExceptListItem ( m_except, 0, tr( "<new>" ), true, true, true ); |
656 | m_except-> ensureItemVisible ( it ); | 660 | m_except-> ensureItemVisible ( it ); |
657 | m_except-> setSelected ( it, true ); | 661 | m_except-> setSelected ( it, true ); |
658 | } | 662 | } |
659 | 663 | ||
660 | void Appearance::delExcept ( ) | 664 | void Appearance::delExcept ( ) |
661 | { | 665 | { |
662 | if ( m_except-> selectedItem ( )) { | 666 | if ( m_except-> selectedItem ( )) { |
663 | m_except-> setFocus ( ); | 667 | m_except-> setFocus ( ); |
664 | delete m_except-> selectedItem ( ); | 668 | delete m_except-> selectedItem ( ); |
665 | } | 669 | } |
666 | } | 670 | } |
667 | 671 | ||
668 | void Appearance::upExcept ( ) | 672 | void Appearance::upExcept ( ) |
669 | { | 673 | { |
670 | ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( ); | 674 | ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( ); |
671 | 675 | ||
672 | if ( it && it-> itemAbove ( )) | 676 | if ( it && it-> itemAbove ( )) |
673 | it-> itemAbove ( )-> moveItem ( it ); | 677 | it-> itemAbove ( )-> moveItem ( it ); |
674 | } | 678 | } |
675 | 679 | ||
676 | void Appearance::downExcept ( ) | 680 | void Appearance::downExcept ( ) |
677 | { | 681 | { |
678 | ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( ); | 682 | ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( ); |
679 | 683 | ||
680 | if ( it && it-> itemBelow ( )) | 684 | if ( it && it-> itemBelow ( )) |
681 | it-> moveItem ( it-> itemBelow ( )); | 685 | it-> moveItem ( it-> itemBelow ( )); |
682 | } | 686 | } |
683 | 687 | ||
684 | class ExEdit : public QLineEdit { | 688 | class ExEdit : public QLineEdit { |
685 | public: | 689 | public: |
686 | ExEdit ( ExceptListItem *item ) | 690 | ExEdit ( ExceptListItem *item ) |
687 | : QLineEdit ( item-> listView ( )-> viewport ( ), "exedit" ), it ( item ) | 691 | : QLineEdit ( item-> listView ( )-> viewport ( ), "exedit" ), it ( item ) |
688 | { | 692 | { |
689 | setFrame ( false ); | 693 | setFrame ( false ); |
690 | 694 | ||
691 | QRect r = it-> listView ( )-> itemRect ( it ); | 695 | QRect r = it-> listView ( )-> itemRect ( it ); |
692 | 696 | ||
693 | int x = it-> listView ( )-> header ( )-> cellPos ( 3 ) - 1; | 697 | int x = it-> listView ( )-> header ( )-> cellPos ( 3 ) - 1; |
694 | int y = r. y ( ); | 698 | int y = r. y ( ); |
695 | int w = it-> listView ( )-> viewport ( )-> width ( ) - x; | 699 | int w = it-> listView ( )-> viewport ( )-> width ( ) - x; |
696 | int h = r. height ( ); // + 2; | 700 | int h = r. height ( ); // + 2; |
697 | 701 | ||
698 | setText ( it-> pattern ( )); | 702 | setText ( it-> pattern ( )); |
699 | setGeometry ( x, y, w, h ); | 703 | setGeometry ( x, y, w, h ); |
700 | 704 | ||
701 | qDebug ( "ExEdit: [%s] at %d,%d %d,%d", it->text(2).latin1(),x,y,w,h); | 705 | qDebug ( "ExEdit: [%s] at %d,%d %d,%d", it->text(2).latin1(),x,y,w,h); |
702 | 706 | ||
703 | m_out = true; | 707 | m_out = true; |
704 | 708 | ||
705 | show ( ); | 709 | show ( ); |
706 | setFocus ( ); | 710 | setFocus ( ); |
707 | selectAll ( ); | 711 | selectAll ( ); |
708 | end ( true ); | 712 | end ( true ); |
709 | } | 713 | } |
710 | 714 | ||
711 | virtual void focusOutEvent ( QFocusEvent * ) | 715 | virtual void focusOutEvent ( QFocusEvent * ) |
712 | { | 716 | { |
713 | hide ( ); | 717 | hide ( ); |
714 | if ( m_out ) | 718 | if ( m_out ) |
715 | it-> setPattern ( text ( )); | 719 | it-> setPattern ( text ( )); |
716 | delete this; | 720 | delete this; |
717 | } | 721 | } |
718 | 722 | ||
719 | virtual void keyPressEvent ( QKeyEvent *e ) | 723 | virtual void keyPressEvent ( QKeyEvent *e ) |
720 | { | 724 | { |
721 | if ( e-> key ( ) == Key_Return ) | 725 | if ( e-> key ( ) == Key_Return ) |
722 | it-> listView ( )-> setFocus ( ); | 726 | it-> listView ( )-> setFocus ( ); |
723 | else if ( e-> key ( ) == Key_Escape ) { | 727 | else if ( e-> key ( ) == Key_Escape ) { |
724 | m_out = false; | 728 | m_out = false; |
725 | it-> listView ( )-> setFocus ( ); | 729 | it-> listView ( )-> setFocus ( ); |
726 | } | 730 | } |
727 | else | 731 | else |
728 | QLineEdit::keyPressEvent ( e ); | 732 | QLineEdit::keyPressEvent ( e ); |
729 | } | 733 | } |
730 | 734 | ||
731 | private: | 735 | private: |
732 | ExceptListItem *it; | 736 | ExceptListItem *it; |
733 | bool m_out; | 737 | bool m_out; |
734 | }; | 738 | }; |
735 | 739 | ||
736 | void Appearance::clickedExcept ( QListViewItem *item, const QPoint &, int c ) | 740 | void Appearance::clickedExcept ( QListViewItem *item, const QPoint &, int c ) |
737 | { | 741 | { |
738 | if ( !item || c < 0 || c > 3 ) | 742 | if ( !item || c < 0 || c > 3 ) |
739 | return; | 743 | return; |
740 | 744 | ||
741 | ExceptListItem *it = (ExceptListItem *) item; | 745 | ExceptListItem *it = (ExceptListItem *) item; |
742 | 746 | ||
743 | if ( c == 0 ) | 747 | if ( c == 0 ) |
744 | it-> setNoStyle ( !it-> noStyle ( )); | 748 | it-> setNoStyle ( !it-> noStyle ( )); |
745 | else if ( c == 1 ) | 749 | else if ( c == 1 ) |
746 | it-> setNoFont ( !it-> noFont ( )); | 750 | it-> setNoFont ( !it-> noFont ( )); |
747 | else if ( c == 2 ) | 751 | else if ( c == 2 ) |
748 | it-> setNoDeco ( !it-> noDeco ( )); | 752 | it-> setNoDeco ( !it-> noDeco ( )); |
749 | else if ( c == 3 ) { | 753 | else if ( c == 3 ) { |
750 | m_except-> ensureItemVisible ( it ); | 754 | m_except-> ensureItemVisible ( it ); |
751 | new ExEdit ( it ); | 755 | new ExEdit ( it ); |
752 | } | 756 | } |
753 | } | 757 | } |
754 | 758 | ||
diff --git a/noncore/settings/appearance2/exceptlistitem.h b/noncore/settings/appearance2/exceptlistitem.h index 5eda79c..7b4fa48 100644 --- a/noncore/settings/appearance2/exceptlistitem.h +++ b/noncore/settings/appearance2/exceptlistitem.h | |||
@@ -1,199 +1,199 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> | 3 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This file is free software; you can | 5 | _;:, .> :=|. This file is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This file is distributed in the hope that | 12 | .i_,=:_. -<s. This file is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
17 | ..}^=.= = ; Public License for more details. | 17 | ..}^=.= = ; Public License for more details. |
18 | ++= -. .` .: | 18 | ++= -. .` .: |
19 | : = ...= . :.=- You should have received a copy of the GNU | 19 | : = ...= . :.=- You should have received a copy of the GNU |
20 | -. .:....=;==+<; General Public License along with this file; | 20 | -. .:....=;==+<; General Public License along with this file; |
21 | -_. . . )=. = see the file COPYING. If not, write to the | 21 | -_. . . )=. = see the file COPYING. If not, write to the |
22 | -- :-=` Free Software Foundation, Inc., | 22 | -- :-=` Free Software Foundation, Inc., |
23 | 59 Temple Place - Suite 330, | 23 | 59 Temple Place - Suite 330, |
24 | Boston, MA 02111-1307, USA. | 24 | Boston, MA 02111-1307, USA. |
25 | 25 | ||
26 | */ | 26 | */ |
27 | 27 | ||
28 | #ifndef EXCEPTLISTITEM_H | 28 | #ifndef EXCEPTLISTITEM_H |
29 | #define EXCEPTLISTITEM_H | 29 | #define EXCEPTLISTITEM_H |
30 | 30 | ||
31 | #include <qlistview.h> | 31 | #include <qlistview.h> |
32 | #include <qpixmap.h> | 32 | #include <qpixmap.h> |
33 | #include <qimage.h> | 33 | #include <qimage.h> |
34 | #include <qpainter.h> | 34 | #include <qpainter.h> |
35 | 35 | ||
36 | class ExceptListItem : public QListViewItem { | 36 | class ExceptListItem : public QListViewItem { |
37 | public: | 37 | public: |
38 | ExceptListItem ( QListView *lv, const QString &t, bool nostyle = true, bool nofont = true, bool nodeco = true ) : QListViewItem ( lv ) | 38 | ExceptListItem ( QListView *lv, QListViewItem *after, const QString &t, bool nostyle = true, bool nofont = true, bool nodeco = true ) : QListViewItem ( lv, after ) |
39 | { | 39 | { |
40 | m_text = t; | 40 | m_text = t; |
41 | 41 | ||
42 | m_nofont = nofont; | 42 | m_nofont = nofont; |
43 | m_nostyle = nostyle; | 43 | m_nostyle = nostyle; |
44 | m_nodeco = nodeco; | 44 | m_nodeco = nodeco; |
45 | 45 | ||
46 | init ( ); | 46 | init ( ); |
47 | } | 47 | } |
48 | 48 | ||
49 | virtual ~ExceptListItem ( ) | 49 | virtual ~ExceptListItem ( ) |
50 | { | 50 | { |
51 | } | 51 | } |
52 | 52 | ||
53 | static void overlay ( QImage &img, const QImage &ovl ) | 53 | static void overlay ( QImage &img, const QImage &ovl ) |
54 | { | 54 | { |
55 | if (( img. size ( ) != ovl. size ( )) || | 55 | if (( img. size ( ) != ovl. size ( )) || |
56 | ( img. depth ( ) != ovl. depth ( ))) | 56 | ( img. depth ( ) != ovl. depth ( ))) |
57 | return; | 57 | return; |
58 | 58 | ||
59 | for ( int y = 0; y != img. height ( ); y++ ) { | 59 | for ( int y = 0; y != img. height ( ); y++ ) { |
60 | QRgb *iline = (QRgb *) img. scanLine ( y ); | 60 | QRgb *iline = (QRgb *) img. scanLine ( y ); |
61 | QRgb *oline = (QRgb *) ovl. scanLine ( y ); | 61 | QRgb *oline = (QRgb *) ovl. scanLine ( y ); |
62 | 62 | ||
63 | for ( int x = 0; x != img. width ( ); x++ ) { | 63 | for ( int x = 0; x != img. width ( ); x++ ) { |
64 | QRgb i = *iline; | 64 | QRgb i = *iline; |
65 | QRgb o = *oline; | 65 | QRgb o = *oline; |
66 | 66 | ||
67 | *iline = qRgba (( qRed ( i ) + qRed ( o )) / 2, | 67 | *iline = qRgba (( qRed ( i ) + qRed ( o )) / 2, |
68 | ( qGreen ( i ) + qGreen ( o )) / 2, | 68 | ( qGreen ( i ) + qGreen ( o )) / 2, |
69 | ( qBlue ( i ) + qBlue ( o )) / 2, | 69 | ( qBlue ( i ) + qBlue ( o )) / 2, |
70 | ( qAlpha ( i ) + qAlpha ( o )) / 2 ); | 70 | ( qAlpha ( i ) + qAlpha ( o )) / 2 ); |
71 | iline++; | 71 | iline++; |
72 | oline++; | 72 | oline++; |
73 | } | 73 | } |
74 | } | 74 | } |
75 | } | 75 | } |
76 | 76 | ||
77 | static void init ( ) | 77 | static void init ( ) |
78 | { | 78 | { |
79 | static bool init = false; | 79 | static bool init = false; |
80 | 80 | ||
81 | if ( init ) | 81 | if ( init ) |
82 | return; | 82 | return; |
83 | 83 | ||
84 | QImage noimg = Resource::loadImage ( "appearance/no.png" ); | 84 | QImage noimg = Resource::loadImage ( "appearance/no.png" ); |
85 | QImage fontimg = Resource::loadImage ( "appearance/font.png" ); | 85 | QImage fontimg = Resource::loadImage ( "appearance/font.png" ); |
86 | QImage styleimg = Resource::loadImage ( "appearance/style.png" ); | 86 | QImage styleimg = Resource::loadImage ( "appearance/style.png" ); |
87 | QImage decoimg = Resource::loadImage ( "appearance/deco.png" ); | 87 | QImage decoimg = Resource::loadImage ( "appearance/deco.png" ); |
88 | 88 | ||
89 | s_fontpix [0] = new QPixmap ( ); | 89 | s_fontpix [0] = new QPixmap ( ); |
90 | s_fontpix [0]-> convertFromImage ( fontimg ); | 90 | s_fontpix [0]-> convertFromImage ( fontimg ); |
91 | overlay ( fontimg, noimg ); | 91 | overlay ( fontimg, noimg ); |
92 | s_fontpix [1] = new QPixmap ( ); | 92 | s_fontpix [1] = new QPixmap ( ); |
93 | s_fontpix [1]-> convertFromImage ( fontimg ); | 93 | s_fontpix [1]-> convertFromImage ( fontimg ); |
94 | 94 | ||
95 | s_stylepix [0] = new QPixmap ( ); | 95 | s_stylepix [0] = new QPixmap ( ); |
96 | s_stylepix [0]-> convertFromImage ( styleimg ); | 96 | s_stylepix [0]-> convertFromImage ( styleimg ); |
97 | overlay ( styleimg, noimg ); | 97 | overlay ( styleimg, noimg ); |
98 | s_stylepix [1] = new QPixmap ( ); | 98 | s_stylepix [1] = new QPixmap ( ); |
99 | s_stylepix [1]-> convertFromImage ( styleimg ); | 99 | s_stylepix [1]-> convertFromImage ( styleimg ); |
100 | 100 | ||
101 | s_decopix [0] = new QPixmap ( ); | 101 | s_decopix [0] = new QPixmap ( ); |
102 | s_decopix [0]-> convertFromImage ( decoimg ); | 102 | s_decopix [0]-> convertFromImage ( decoimg ); |
103 | overlay ( decoimg, noimg ); | 103 | overlay ( decoimg, noimg ); |
104 | s_decopix [1] = new QPixmap ( ); | 104 | s_decopix [1] = new QPixmap ( ); |
105 | s_decopix [1]-> convertFromImage ( decoimg ); | 105 | s_decopix [1]-> convertFromImage ( decoimg ); |
106 | 106 | ||
107 | init = true; | 107 | init = true; |
108 | } | 108 | } |
109 | 109 | ||
110 | bool noFont ( ) const | 110 | bool noFont ( ) const |
111 | { | 111 | { |
112 | return m_nofont; | 112 | return m_nofont; |
113 | } | 113 | } |
114 | 114 | ||
115 | bool noStyle ( ) const | 115 | bool noStyle ( ) const |
116 | { | 116 | { |
117 | return m_nostyle; | 117 | return m_nostyle; |
118 | } | 118 | } |
119 | 119 | ||
120 | bool noDeco ( ) const | 120 | bool noDeco ( ) const |
121 | { | 121 | { |
122 | return m_nodeco; | 122 | return m_nodeco; |
123 | } | 123 | } |
124 | 124 | ||
125 | void setNoDeco ( bool b ) | 125 | void setNoDeco ( bool b ) |
126 | { | 126 | { |
127 | if ( b != m_nodeco ) { | 127 | if ( b != m_nodeco ) { |
128 | m_nodeco = b; | 128 | m_nodeco = b; |
129 | repaint ( ); | 129 | repaint ( ); |
130 | } | 130 | } |
131 | } | 131 | } |
132 | 132 | ||
133 | void setNoStyle ( bool b ) | 133 | void setNoStyle ( bool b ) |
134 | { | 134 | { |
135 | if ( b != m_nostyle ) { | 135 | if ( b != m_nostyle ) { |
136 | m_nostyle = b; | 136 | m_nostyle = b; |
137 | repaint ( ); | 137 | repaint ( ); |
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
141 | void setNoFont ( bool b ) | 141 | void setNoFont ( bool b ) |
142 | { | 142 | { |
143 | if ( b != m_nofont ) { | 143 | if ( b != m_nofont ) { |
144 | m_nofont = b; | 144 | m_nofont = b; |
145 | repaint ( ); | 145 | repaint ( ); |
146 | } | 146 | } |
147 | } | 147 | } |
148 | 148 | ||
149 | QString pattern ( ) const | 149 | QString pattern ( ) const |
150 | { | 150 | { |
151 | return m_text; | 151 | return m_text; |
152 | } | 152 | } |
153 | 153 | ||
154 | void setPattern ( const QString &s ) | 154 | void setPattern ( const QString &s ) |
155 | { | 155 | { |
156 | if ( s != m_text ) { | 156 | if ( s != m_text ) { |
157 | m_text = s; | 157 | m_text = s; |
158 | widthChanged ( 3 ); | 158 | widthChanged ( 3 ); |
159 | repaint ( ); | 159 | repaint ( ); |
160 | } | 160 | } |
161 | } | 161 | } |
162 | 162 | ||
163 | QString text ( int i ) const | 163 | QString text ( int i ) const |
164 | { | 164 | { |
165 | if ( i == 3 ) | 165 | if ( i == 3 ) |
166 | return m_text; | 166 | return m_text; |
167 | else | 167 | else |
168 | return QString::null; | 168 | return QString::null; |
169 | 169 | ||
170 | } | 170 | } |
171 | 171 | ||
172 | const QPixmap *pixmap ( int i ) const | 172 | const QPixmap *pixmap ( int i ) const |
173 | { | 173 | { |
174 | if ( i == 0 ) | 174 | if ( i == 0 ) |
175 | return (const QPixmap *) s_stylepix [m_nostyle ? 1 : 0]; | 175 | return (const QPixmap *) s_stylepix [m_nostyle ? 1 : 0]; |
176 | else if ( i == 1 ) | 176 | else if ( i == 1 ) |
177 | return (const QPixmap *) s_fontpix [m_nofont ? 1 : 0]; | 177 | return (const QPixmap *) s_fontpix [m_nofont ? 1 : 0]; |
178 | else if ( i == 2 ) | 178 | else if ( i == 2 ) |
179 | return (const QPixmap *) s_decopix [m_nodeco ? 1 : 0]; | 179 | return (const QPixmap *) s_decopix [m_nodeco ? 1 : 0]; |
180 | else | 180 | else |
181 | return 0; | 181 | return 0; |
182 | } | 182 | } |
183 | 183 | ||
184 | private: | 184 | private: |
185 | QString m_text; | 185 | QString m_text; |
186 | bool m_nofont; | 186 | bool m_nofont; |
187 | bool m_nostyle; | 187 | bool m_nostyle; |
188 | bool m_nodeco; | 188 | bool m_nodeco; |
189 | 189 | ||
190 | static QPixmap *s_stylepix [2]; | 190 | static QPixmap *s_stylepix [2]; |
191 | static QPixmap *s_fontpix [2]; | 191 | static QPixmap *s_fontpix [2]; |
192 | static QPixmap *s_decopix [2]; | 192 | static QPixmap *s_decopix [2]; |
193 | }; | 193 | }; |
194 | 194 | ||
195 | QPixmap *ExceptListItem::s_stylepix [2] = { 0, 0 }; | 195 | QPixmap *ExceptListItem::s_stylepix [2] = { 0, 0 }; |
196 | QPixmap *ExceptListItem::s_fontpix [2] = { 0, 0 }; | 196 | QPixmap *ExceptListItem::s_fontpix [2] = { 0, 0 }; |
197 | QPixmap *ExceptListItem::s_decopix [2] = { 0, 0 }; | 197 | QPixmap *ExceptListItem::s_decopix [2] = { 0, 0 }; |
198 | 198 | ||
199 | #endif | 199 | #endif |