-rw-r--r-- | core/settings/launcher/tabdialog.cpp | 46 |
1 files changed, 18 insertions, 28 deletions
diff --git a/core/settings/launcher/tabdialog.cpp b/core/settings/launcher/tabdialog.cpp index bd51628..555e64e 100644 --- a/core/settings/launcher/tabdialog.cpp +++ b/core/settings/launcher/tabdialog.cpp | |||
@@ -98,138 +98,131 @@ public: | |||
98 | setViewMode ( TabConfig::Icon ); | 98 | setViewMode ( TabConfig::Icon ); |
99 | calculateGrid ( Bottom ); | 99 | calculateGrid ( Bottom ); |
100 | 100 | ||
101 | 101 | ||
102 | new SampleItem ( this, QObject::tr( "Sample 1" ), Resource::loadPixmap ( "datebook/DateBook" )); | 102 | new SampleItem ( this, QObject::tr( "Sample 1" ), Resource::loadPixmap ( "datebook/DateBook" )); |
103 | new SampleItem ( this, QObject::tr( "Sample 2" ), Resource::loadPixmap ( "Calibrate" )); | 103 | new SampleItem ( this, QObject::tr( "Sample 2" ), Resource::loadPixmap ( "Calibrate" )); |
104 | new SampleItem ( this, QObject::tr( "Sample 3" ), Resource::loadPixmap ( "UnknownDocument" )); | 104 | new SampleItem ( this, QObject::tr( "Sample 3" ), Resource::loadPixmap ( "UnknownDocument" )); |
105 | 105 | ||
106 | setBackgroundType ( TabConfig::Ruled, QString::null ); | 106 | setBackgroundType ( TabConfig::Ruled, QString::null ); |
107 | 107 | ||
108 | setMaximumHeight ( firstItem ( )-> height ( ) + 16 ); | 108 | setMaximumHeight ( firstItem ( )-> height ( ) + 16 ); |
109 | } | 109 | } |
110 | 110 | ||
111 | void setViewMode ( TabConfig::ViewMode m ) | 111 | void setViewMode ( TabConfig::ViewMode m ) |
112 | { | 112 | { |
113 | viewport ( )-> setUpdatesEnabled ( false ); | 113 | viewport ( )-> setUpdatesEnabled ( false ); |
114 | 114 | ||
115 | switch ( m ) { | 115 | switch ( m ) { |
116 | case TabConfig::List: | 116 | case TabConfig::List: |
117 | setItemTextPos( QIconView::Right ); | 117 | setItemTextPos( QIconView::Right ); |
118 | break; | 118 | break; |
119 | case TabConfig::Icon: | 119 | case TabConfig::Icon: |
120 | setItemTextPos( QIconView::Bottom ); | 120 | setItemTextPos( QIconView::Bottom ); |
121 | break; | 121 | break; |
122 | } | 122 | } |
123 | // hideOrShowItems ( false ); | 123 | // hideOrShowItems ( false ); |
124 | 124 | ||
125 | for ( QIconViewItem *it = firstItem ( ); it; it = it-> nextItem ( )) | 125 | for ( QIconViewItem *it = firstItem ( ); it; it = it-> nextItem ( )) |
126 | ((SampleItem *) it )-> sizeChange ( ); | 126 | ((SampleItem *) it )-> sizeChange ( ); |
127 | arrangeItemsInGrid ( true ); | 127 | arrangeItemsInGrid ( true ); |
128 | viewport ( )-> setUpdatesEnabled ( true ); | 128 | viewport ( )-> setUpdatesEnabled ( true ); |
129 | update ( ); | 129 | update ( ); |
130 | } | 130 | } |
131 | 131 | ||
132 | 132 | ||
133 | void setBackgroundType( TabConfig::BackgroundType t, const QString &val ) | 133 | void setBackgroundType( TabConfig::BackgroundType t, const QString &val ) |
134 | { | 134 | { |
135 | switch ( t ) { | 135 | switch ( t ) { |
136 | case TabConfig::Ruled: { | 136 | case TabConfig::Ruled: { |
137 | QPixmap bg ( width ( ), 9 ); | 137 | QPixmap bg ( width ( ), 9 ); |
138 | QPainter painter ( &bg ); | 138 | QPainter painter ( &bg ); |
139 | for ( int i = 0; i < 3; i++ ) { | 139 | for ( int i = 0; i < 3; i++ ) { |
140 | painter. setPen ( white ); | 140 | painter. setPen ( white ); |
141 | painter. drawLine ( 0, i*3, width()-1, i*3 ); | 141 | painter. drawLine ( 0, i*3, width()-1, i*3 ); |
142 | painter. drawLine ( 0, i*3+1, width()-1, i*3+1 ); | 142 | painter. drawLine ( 0, i*3+1, width()-1, i*3+1 ); |
143 | painter. setPen ( colorGroup().background().light(105) ); | 143 | painter. setPen ( colorGroup().background().light(105) ); |
144 | painter. drawLine ( 0, i*3+2, width()-1, i*3+2 ); | 144 | painter. drawLine ( 0, i*3+2, width()-1, i*3+2 ); |
145 | } | 145 | } |
146 | painter.end ( ); | 146 | painter.end ( ); |
147 | setBackgroundPixmap ( bg ); | 147 | setBackgroundPixmap ( bg ); |
148 | break; | 148 | break; |
149 | } | 149 | } |
150 | 150 | ||
151 | case TabConfig::SolidColor: { | 151 | case TabConfig::SolidColor: { |
152 | setBackgroundPixmap ( QPixmap ( )); | 152 | setBackgroundPixmap ( QPixmap ( )); |
153 | if ( val. isEmpty ( )) | 153 | if ( val. isEmpty ( )) |
154 | setBackgroundColor ( colorGroup ( ). base ( )); | 154 | setBackgroundColor ( colorGroup ( ). base ( )); |
155 | else | 155 | else |
156 | setBackgroundColor ( val ); | 156 | setBackgroundColor ( val ); |
157 | break; | 157 | break; |
158 | } | 158 | } |
159 | 159 | ||
160 | case TabConfig::Image: { | 160 | case TabConfig::Image: { |
161 | odebug << "Loading image: " << val << "" << oendl; | 161 | odebug << "Loading image: " << val << "" << oendl; |
162 | QPixmap bg ( Resource::loadPixmap ( "wallpaper/" + val )); | 162 | QPixmap bg = Resource::loadPixmap ( val ); |
163 | if ( bg. isNull ( )) { | 163 | if ( bg. isNull () ) |
164 | QImageIO imgio; | 164 | bg = QPixmap( val ); |
165 | imgio. setFileName ( val ); | ||
166 | QSize ds = qApp-> desktop ( )-> size ( ); | ||
167 | QString param ( "Scale( %1, %2, ScaleMin )" ); // No tr | ||
168 | imgio. setParameters ( param. arg ( ds. width ( )). arg ( ds. height ( )). latin1 ( )); | ||
169 | imgio. read ( ); | ||
170 | bg = imgio. image ( ); | ||
171 | } | ||
172 | setBackgroundPixmap ( bg ); | 165 | setBackgroundPixmap ( bg ); |
173 | break; | 166 | break; |
174 | } | 167 | } |
175 | } | 168 | } |
176 | m_bgtype = t; | 169 | m_bgtype = t; |
177 | viewport ( )-> update ( ); | 170 | viewport ( )-> update ( ); |
178 | } | 171 | } |
179 | 172 | ||
180 | void setTextColor ( const QColor &tc ) | 173 | void setTextColor ( const QColor &tc ) |
181 | { | 174 | { |
182 | m_textcolor = tc; | 175 | m_textcolor = tc; |
183 | QColorGroup cg = colorGroup ( ); | 176 | QColorGroup cg = colorGroup ( ); |
184 | cg. setColor ( QColorGroup::Text, tc ); | 177 | cg. setColor ( QColorGroup::Text, tc ); |
185 | setPalette ( QPalette ( cg, cg, cg )); | 178 | setPalette ( QPalette ( cg, cg, cg )); |
186 | viewport ( )-> update ( ); | 179 | viewport ( )-> update ( ); |
187 | } | 180 | } |
188 | 181 | ||
189 | void setViewFont ( const QFont &f ) | 182 | void setViewFont ( const QFont &f ) |
190 | { | 183 | { |
191 | setFont ( f ); | 184 | setFont ( f ); |
192 | } | 185 | } |
193 | 186 | ||
194 | void setItemTextPos ( ItemTextPos pos ) | 187 | void setItemTextPos ( ItemTextPos pos ) |
195 | { | 188 | { |
196 | calculateGrid ( pos ); | 189 | calculateGrid ( pos ); |
197 | QIconView::setItemTextPos( pos ); | 190 | QIconView::setItemTextPos( pos ); |
198 | } | 191 | } |
199 | 192 | ||
200 | //FIXME: Add per-tab column handling from launcherview.cpp | 193 | //FIXME: Add per-tab column handling from launcherview.cpp |
201 | void calculateGrid ( ItemTextPos pos ) | 194 | void calculateGrid ( ItemTextPos pos ) |
202 | { | 195 | { |
203 | int dw = QApplication::desktop ( )-> width ( ); | 196 | int dw = QApplication::desktop ( )-> width ( ); |
204 | int viewerWidth = dw - style ( ).scrollBarExtent ( ). width ( ); | 197 | int viewerWidth = dw - style ( ).scrollBarExtent ( ). width ( ); |
205 | if ( pos == Bottom ) { | 198 | if ( pos == Bottom ) { |
206 | int cols = 3; | 199 | int cols = 3; |
207 | if ( viewerWidth <= 200 ) | 200 | if ( viewerWidth <= 200 ) |
208 | cols = 2; | 201 | cols = 2; |
209 | else if ( viewerWidth >= 400 ) | 202 | else if ( viewerWidth >= 400 ) |
210 | cols = viewerWidth/96; | 203 | cols = viewerWidth/96; |
211 | setSpacing ( 4 ); | 204 | setSpacing ( 4 ); |
212 | setGridX (( viewerWidth - ( cols + 1 ) * spacing ( )) / cols ); | 205 | setGridX (( viewerWidth - ( cols + 1 ) * spacing ( )) / cols ); |
213 | setGridY ( fontMetrics ( ). height ( ) * 2 + 24 ); | 206 | setGridY ( fontMetrics ( ). height ( ) * 2 + 24 ); |
214 | } | 207 | } |
215 | else { | 208 | else { |
216 | int cols = 2; | 209 | int cols = 2; |
217 | if ( viewerWidth < 150 ) | 210 | if ( viewerWidth < 150 ) |
218 | cols = 1; | 211 | cols = 1; |
219 | else if ( viewerWidth >= 400 ) | 212 | else if ( viewerWidth >= 400 ) |
220 | cols = viewerWidth / 150; | 213 | cols = viewerWidth / 150; |
221 | setSpacing ( 2 ); | 214 | setSpacing ( 2 ); |
222 | setGridX (( viewerWidth - ( cols + 1 ) * spacing ( )) / cols ); | 215 | setGridX (( viewerWidth - ( cols + 1 ) * spacing ( )) / cols ); |
223 | setGridY ( fontMetrics ( ). height ( ) + 2 ); | 216 | setGridY ( fontMetrics ( ). height ( ) + 2 ); |
224 | } | 217 | } |
225 | } | 218 | } |
226 | 219 | ||
227 | void paletteChange( const QPalette &p ) | 220 | void paletteChange( const QPalette &p ) |
228 | { | 221 | { |
229 | static bool excllock = false; | 222 | static bool excllock = false; |
230 | 223 | ||
231 | if ( excllock ) | 224 | if ( excllock ) |
232 | return; | 225 | return; |
233 | excllock = true; | 226 | excllock = true; |
234 | 227 | ||
235 | unsetPalette ( ); | 228 | unsetPalette ( ); |
@@ -238,298 +231,295 @@ public: | |||
238 | setBackgroundType ( TabConfig::Ruled, QString::null ); | 231 | setBackgroundType ( TabConfig::Ruled, QString::null ); |
239 | QColorGroup cg = colorGroup ( ); | 232 | QColorGroup cg = colorGroup ( ); |
240 | cg.setColor ( QColorGroup::Text, m_textcolor ); | 233 | cg.setColor ( QColorGroup::Text, m_textcolor ); |
241 | setPalette ( QPalette ( cg, cg, cg )); | 234 | setPalette ( QPalette ( cg, cg, cg )); |
242 | 235 | ||
243 | excllock = false; | 236 | excllock = false; |
244 | } | 237 | } |
245 | 238 | ||
246 | void setBackgroundPixmap ( const QPixmap &pm ) | 239 | void setBackgroundPixmap ( const QPixmap &pm ) |
247 | { | 240 | { |
248 | m_bgpix = pm; | 241 | m_bgpix = pm; |
249 | } | 242 | } |
250 | 243 | ||
251 | void setBackgroundColor ( const QColor &c ) | 244 | void setBackgroundColor ( const QColor &c ) |
252 | { | 245 | { |
253 | m_bgcolor = c; | 246 | m_bgcolor = c; |
254 | } | 247 | } |
255 | 248 | ||
256 | void drawBackground ( QPainter *p, const QRect &r ) | 249 | void drawBackground ( QPainter *p, const QRect &r ) |
257 | { | 250 | { |
258 | if ( !m_bgpix. isNull ( )) { | 251 | if ( !m_bgpix. isNull ( )) { |
259 | p-> drawTiledPixmap ( r, m_bgpix, QPoint (( r. x ( ) + contentsX ( )) % m_bgpix. width ( ), | 252 | p-> drawTiledPixmap ( r, m_bgpix, QPoint (( r. x ( ) + contentsX ( )) % m_bgpix. width ( ), |
260 | ( r. y ( ) + contentsY ( )) % m_bgpix. height ( ))); | 253 | ( r. y ( ) + contentsY ( )) % m_bgpix. height ( ))); |
261 | } | 254 | } |
262 | else | 255 | else |
263 | p-> fillRect ( r, m_bgcolor ); | 256 | p-> fillRect ( r, m_bgcolor ); |
264 | } | 257 | } |
265 | 258 | ||
266 | private: | 259 | private: |
267 | QColor m_textcolor; | 260 | QColor m_textcolor; |
268 | QColor m_bgcolor; | 261 | QColor m_bgcolor; |
269 | QPixmap m_bgpix; | 262 | QPixmap m_bgpix; |
270 | TabConfig::BackgroundType m_bgtype; | 263 | TabConfig::BackgroundType m_bgtype; |
271 | }; | 264 | }; |
272 | 265 | ||
273 | 266 | ||
274 | 267 | ||
275 | TabDialog::TabDialog ( const QPixmap *tabicon, const QString &tabname, TabConfig &tc, QWidget *parent, const char *dname, bool modal, WFlags fl ) | 268 | TabDialog::TabDialog ( const QPixmap *tabicon, const QString &tabname, TabConfig &tc, QWidget *parent, const char *dname, bool modal, WFlags fl ) |
276 | : QDialog ( parent, dname, modal, fl | WStyle_ContextHelp ), m_tc ( tc ) | 269 | : QDialog ( parent, dname, modal, fl | WStyle_ContextHelp ), m_tc ( tc ) |
277 | { | 270 | { |
278 | setCaption ( tr( "Edit Tab" )); | 271 | setCaption ( tr( "Edit Tab" )); |
279 | 272 | ||
280 | QVBoxLayout *lay = new QVBoxLayout ( this, 3, 3 ); | 273 | QVBoxLayout *lay = new QVBoxLayout ( this, 3, 3 ); |
281 | 274 | ||
282 | OTabWidget *tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); | 275 | OTabWidget *tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); |
283 | QWidget *bgtab; | 276 | QWidget *bgtab; |
284 | 277 | ||
285 | tw-> addTab ( bgtab = createBgTab ( tw ), "appearance/color", tr( "Background" )); | 278 | tw-> addTab ( bgtab = createBgTab ( tw ), "appearance/color", tr( "Background" )); |
286 | tw-> addTab ( createFontTab ( tw ), "font", tr( "Font" )); | 279 | tw-> addTab ( createFontTab ( tw ), "font", tr( "Font" )); |
287 | tw-> addTab ( createIconTab ( tw ), "pixmap", tr( "Icons" ) ); | 280 | tw-> addTab ( createIconTab ( tw ), "pixmap", tr( "Icons" ) ); |
288 | 281 | ||
289 | tw-> setCurrentTab ( bgtab ); | 282 | tw-> setCurrentTab ( bgtab ); |
290 | 283 | ||
291 | QWidget *sample = new QVBox ( this ); | 284 | QWidget *sample = new QVBox ( this ); |
292 | QTabBar *tb = new QTabBar ( sample ); | 285 | QTabBar *tb = new QTabBar ( sample ); |
293 | QString name ( tr( "Previewing %1" ). arg ( tabname )); | 286 | QString name ( tr( "Previewing %1" ). arg ( tabname )); |
294 | 287 | ||
295 | tb-> addTab ( tabicon ? new QTab ( *tabicon, name ) : new QTab ( name )); | 288 | tb-> addTab ( tabicon ? new QTab ( *tabicon, name ) : new QTab ( name )); |
296 | 289 | ||
297 | m_sample = new SampleView ( sample ); | 290 | m_sample = new SampleView ( sample ); |
298 | 291 | ||
299 | lay-> addWidget ( tw, 10 ); | 292 | lay-> addWidget ( tw, 10 ); |
300 | lay-> addWidget ( sample, 1 ); | 293 | lay-> addWidget ( sample, 1 ); |
301 | 294 | ||
302 | m_iconsize-> setButton ( tc. m_view ); | ||
303 | iconSizeClicked ( tc. m_view ); | ||
304 | //m_iconcolor-> setColor ( QColor ( m_tc. m_text_color )); | ||
305 | iconColorClicked ( m_iconcolor-> color ( )); | ||
306 | m_bgtype-> setButton ( tc. m_bg_type ); | ||
307 | //m_solidcolor-> setColor ( QColor ( tc. m_bg_color )); | ||
308 | m_iconcolumns->setValue( tc. m_iconcolumns ); | ||
309 | m_bgimage = tc. m_bg_image; | 295 | m_bgimage = tc. m_bg_image; |
310 | bgTypeClicked ( tc. m_bg_type ); | 296 | m_bgtype-> setButton ( tc. m_bg_type ); |
297 | bgTypeClicked( tc.m_bg_type ); | ||
298 | |||
311 | m_fontuse-> setChecked ( tc. m_font_use ); | 299 | m_fontuse-> setChecked ( tc. m_font_use ); |
312 | m_fontselect-> setSelectedFont ( QFont ( tc. m_font_family, tc. m_font_size, tc. m_font_weight, tc. m_font_italic )); | 300 | m_fontselect-> setSelectedFont ( QFont ( tc. m_font_family, tc. m_font_size, tc. m_font_weight, tc. m_font_italic )); |
313 | m_fontselect-> setEnabled ( m_fontuse-> isChecked ( )); | 301 | m_fontselect-> setEnabled ( m_fontuse-> isChecked ( )); |
314 | fontClicked ( m_fontselect-> selectedFont ( )); | 302 | fontClicked ( m_fontselect-> selectedFont ( )); |
315 | 303 | ||
304 | m_iconsize-> setButton ( tc. m_view ); | ||
305 | iconSizeClicked ( tc. m_view ); | ||
306 | iconColorClicked ( m_iconcolor-> color ( )); | ||
307 | m_iconcolumns->setValue( tc. m_iconcolumns ); | ||
308 | |||
316 | QWhatsThis::add ( sample, tr( "This is a rough preview of what the currently selected Tab will look like." )); | 309 | QWhatsThis::add ( sample, tr( "This is a rough preview of what the currently selected Tab will look like." )); |
317 | } | 310 | } |
318 | 311 | ||
319 | 312 | ||
320 | TabDialog::~TabDialog ( ) | 313 | TabDialog::~TabDialog ( ) |
321 | { | 314 | { |
322 | } | 315 | } |
323 | 316 | ||
324 | QWidget *TabDialog::createFontTab ( QWidget *parent ) | 317 | QWidget *TabDialog::createFontTab ( QWidget *parent ) |
325 | { | 318 | { |
326 | QWidget *tab = new QWidget ( parent, "FontTab" ); | 319 | QWidget *tab = new QWidget ( parent, "FontTab" ); |
327 | QVBoxLayout *vertLayout = new QVBoxLayout ( tab, 3, 3 ); | 320 | QVBoxLayout *vertLayout = new QVBoxLayout ( tab, 3, 3 ); |
328 | 321 | ||
329 | m_fontuse = new QCheckBox ( tr( "Use a custom font" ), tab ); | 322 | m_fontuse = new QCheckBox ( tr( "Use a custom font" ), tab ); |
330 | vertLayout-> addWidget ( m_fontuse ); | 323 | vertLayout-> addWidget ( m_fontuse ); |
331 | 324 | ||
332 | m_fontselect = new OFontSelector ( false, tab, "fontsel" ); | 325 | m_fontselect = new OFontSelector ( false, tab, "fontsel" ); |
333 | vertLayout-> addWidget ( m_fontselect ); | 326 | vertLayout-> addWidget ( m_fontselect ); |
334 | 327 | ||
335 | connect ( m_fontuse, SIGNAL( toggled(bool)), m_fontselect, SLOT( setEnabled(bool))); | 328 | connect ( m_fontuse, SIGNAL( toggled(bool)), m_fontselect, SLOT( setEnabled(bool))); |
336 | connect( m_fontselect, SIGNAL( fontSelected(const QFont&)), | 329 | connect( m_fontselect, SIGNAL( fontSelected(const QFont&)), |
337 | this, SLOT( fontClicked(const QFont&))); | 330 | this, SLOT( fontClicked(const QFont&))); |
338 | 331 | ||
339 | return tab; | 332 | return tab; |
340 | } | 333 | } |
341 | 334 | ||
342 | QWidget *TabDialog::createBgTab ( QWidget *parent ) | 335 | QWidget *TabDialog::createBgTab ( QWidget *parent ) |
343 | { | 336 | { |
344 | QWidget *tab = new QWidget( parent, "BgTab" ); | 337 | QWidget *tab = new QWidget( parent, "BgTab" ); |
345 | QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 ); | 338 | QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 ); |
346 | 339 | ||
347 | QGridLayout* gridLayout = new QGridLayout ( vertLayout ); | 340 | QGridLayout* gridLayout = new QGridLayout ( vertLayout ); |
348 | gridLayout-> setColStretch ( 1, 10 ); | 341 | gridLayout-> setColStretch ( 1, 10 ); |
349 | 342 | ||
350 | QLabel* label = new QLabel( tr( "Type:" ), tab ); | 343 | QLabel* label = new QLabel( tr( "Type:" ), tab ); |
351 | gridLayout-> addWidget ( label, 0, 0 ); | 344 | gridLayout-> addWidget ( label, 0, 0 ); |
352 | m_bgtype = new QButtonGroup( tab, "buttongroup" ); | 345 | m_bgtype = new QButtonGroup( tab, "buttongroup" ); |
353 | m_bgtype-> hide ( ); | 346 | m_bgtype-> hide ( ); |
354 | m_bgtype-> setExclusive ( true ); | 347 | m_bgtype-> setExclusive ( true ); |
348 | connect ( m_bgtype, SIGNAL( clicked(int)), this, SLOT( bgTypeClicked(int))); | ||
355 | 349 | ||
356 | QRadioButton *rb; | 350 | QRadioButton *rb; |
357 | rb = new QRadioButton( tr( "Ruled" ), tab, "ruled" ); | 351 | rb = new QRadioButton( tr( "Ruled" ), tab, "ruled" ); |
358 | m_bgtype-> insert ( rb, TabConfig::Ruled ); | 352 | m_bgtype-> insert ( rb, TabConfig::Ruled ); |
359 | gridLayout-> addWidget( rb, 0, 1 ); | 353 | gridLayout-> addWidget( rb, 0, 1 ); |
360 | 354 | ||
361 | QHBoxLayout *hb = new QHBoxLayout ( ); | 355 | QHBoxLayout *hb = new QHBoxLayout ( ); |
362 | hb-> setSpacing ( 3 ); | 356 | hb-> setSpacing ( 3 ); |
363 | 357 | ||
364 | rb = new QRadioButton( tr( "Solid color" ), tab, "solid" ); | 358 | rb = new QRadioButton( tr( "Solid color" ), tab, "solid" ); |
365 | m_bgtype-> insert ( rb, TabConfig::SolidColor ); | 359 | m_bgtype-> insert ( rb, TabConfig::SolidColor ); |
366 | hb-> addWidget ( rb ); | 360 | hb-> addWidget ( rb ); |
367 | hb-> addSpacing ( 10 ); | 361 | hb-> addSpacing ( 10 ); |
368 | 362 | ||
369 | m_solidcolor = new Opie::OColorButton ( tab, QColor ( m_tc. m_bg_color ) ); | 363 | m_solidcolor = new Opie::OColorButton ( tab, QColor ( m_tc. m_bg_color ) ); |
370 | connect ( m_solidcolor, SIGNAL( colorSelected(const QColor&)), this, SLOT( bgColorClicked(const QColor&))); | 364 | connect ( m_solidcolor, SIGNAL( colorSelected(const QColor&)), this, SLOT( bgColorClicked(const QColor&))); |
371 | hb-> addWidget ( m_solidcolor ); | 365 | hb-> addWidget ( m_solidcolor ); |
372 | hb-> addStretch ( 10 ); | 366 | hb-> addStretch ( 10 ); |
373 | 367 | ||
374 | gridLayout-> addLayout ( hb, 1, 1 ); | 368 | gridLayout-> addLayout ( hb, 1, 1 ); |
375 | 369 | ||
376 | hb = new QHBoxLayout ( ); | 370 | hb = new QHBoxLayout ( ); |
377 | hb-> setSpacing ( 3 ); | 371 | hb-> setSpacing ( 3 ); |
378 | 372 | ||
379 | rb = new QRadioButton( tr( "Image" ), tab, "image" ); | 373 | rb = new QRadioButton( tr( "Image" ), tab, "image" ); |
380 | m_bgtype-> insert ( rb, TabConfig::Image ); | 374 | m_bgtype-> insert ( rb, TabConfig::Image ); |
381 | hb-> addWidget( rb ); | 375 | hb-> addWidget( rb ); |
382 | hb-> addSpacing ( 10 ); | 376 | hb-> addSpacing ( 10 ); |
383 | 377 | ||
384 | m_imagebrowse = new QPushButton ( tr( "Select..." ), tab ); | 378 | m_imagebrowse = new QPushButton ( tr( "Select..." ), tab ); |
385 | connect ( m_imagebrowse, SIGNAL( clicked()), this, SLOT( bgImageClicked())); | 379 | connect ( m_imagebrowse, SIGNAL( clicked()), this, SLOT( bgImageClicked())); |
386 | hb-> addWidget ( m_imagebrowse ); | 380 | hb-> addWidget ( m_imagebrowse ); |
387 | hb-> addStretch ( 10 ); | 381 | hb-> addStretch ( 10 ); |
388 | 382 | ||
389 | gridLayout-> addLayout ( hb, 2, 1 ); | 383 | gridLayout-> addLayout ( hb, 2, 1 ); |
390 | 384 | ||
391 | QPushButton *p = new QPushButton ( tr( "Default" ), tab ); | 385 | QPushButton *p = new QPushButton ( tr( "Default" ), tab ); |
392 | connect ( p, SIGNAL( clicked()), this, SLOT( bgDefaultClicked())); | 386 | connect ( p, SIGNAL( clicked()), this, SLOT( bgDefaultClicked())); |
393 | gridLayout-> addWidget ( p, 3, 1 ); | 387 | gridLayout-> addWidget ( p, 3, 1 ); |
394 | 388 | ||
395 | connect ( m_bgtype, SIGNAL( clicked(int)), this, SLOT( bgTypeClicked(int))); | ||
396 | |||
397 | vertLayout-> addStretch ( 10 ); | 389 | vertLayout-> addStretch ( 10 ); |
398 | 390 | ||
399 | return tab; | 391 | return tab; |
400 | } | 392 | } |
401 | 393 | ||
402 | QWidget *TabDialog::createIconTab ( QWidget *parent ) | 394 | QWidget *TabDialog::createIconTab ( QWidget *parent ) |
403 | { | 395 | { |
404 | QWidget *tab = new QWidget( parent, "IconTab" ); | 396 | QWidget *tab = new QWidget( parent, "IconTab" ); |
405 | QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 ); | 397 | QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 ); |
406 | 398 | ||
407 | QGridLayout* gridLayout = new QGridLayout ( vertLayout ); | 399 | QGridLayout* gridLayout = new QGridLayout ( vertLayout ); |
408 | gridLayout-> setColStretch ( 1, 10 ); | 400 | gridLayout-> setColStretch ( 1, 10 ); |
409 | 401 | ||
410 | QLabel* label = new QLabel( tr( "Size:" ), tab ); | 402 | QLabel* label = new QLabel( tr( "Size:" ), tab ); |
411 | gridLayout-> addWidget ( label, 0, 0 ); | 403 | gridLayout-> addWidget ( label, 0, 0 ); |
412 | m_iconsize = new QButtonGroup( tab, "buttongroup" ); | 404 | m_iconsize = new QButtonGroup( tab, "buttongroup" ); |
413 | m_iconsize-> hide ( ); | 405 | m_iconsize-> hide ( ); |
414 | m_iconsize-> setExclusive ( true ); | 406 | m_iconsize-> setExclusive ( true ); |
415 | 407 | ||
416 | QRadioButton *rb; | 408 | QRadioButton *rb; |
417 | rb = new QRadioButton( tr( "Small" ), tab, "iconsmall" ); | 409 | rb = new QRadioButton( tr( "Small" ), tab, "iconsmall" ); |
418 | m_iconsize-> insert ( rb, TabConfig::List ); | 410 | m_iconsize-> insert ( rb, TabConfig::List ); |
419 | gridLayout-> addWidget( rb, 0, 1 ); | 411 | gridLayout-> addWidget( rb, 0, 1 ); |
420 | 412 | ||
421 | rb = new QRadioButton( tr( "Large" ), tab, "iconlarge" ); | 413 | rb = new QRadioButton( tr( "Large" ), tab, "iconlarge" ); |
422 | m_iconsize-> insert ( rb, TabConfig::Icon ); | 414 | m_iconsize-> insert ( rb, TabConfig::Icon ); |
423 | gridLayout-> addWidget( rb, 1, 1 ); | 415 | gridLayout-> addWidget( rb, 1, 1 ); |
424 | connect ( m_iconsize, SIGNAL( clicked(int)), this, SLOT( iconSizeClicked(int))); | 416 | connect ( m_iconsize, SIGNAL( clicked(int)), this, SLOT( iconSizeClicked(int))); |
425 | gridLayout-> addRowSpacing ( 2, 8 ); | 417 | gridLayout-> addRowSpacing ( 2, 8 ); |
426 | 418 | ||
427 | label = new QLabel ( tr( "Color:" ), tab ); | 419 | label = new QLabel ( tr( "Color:" ), tab ); |
428 | gridLayout-> addWidget ( label, 3, 0 ); | 420 | gridLayout-> addWidget ( label, 3, 0 ); |
429 | gridLayout-> addRowSpacing ( 3, 8 ); | 421 | gridLayout-> addRowSpacing ( 3, 8 ); |
430 | 422 | ||
431 | m_iconcolor = new Opie::OColorButton ( tab, QColor ( m_tc. m_text_color ) ); | 423 | m_iconcolor = new Opie::OColorButton ( tab, QColor ( m_tc. m_text_color ) ); |
432 | connect ( m_iconcolor, SIGNAL( colorSelected(const QColor&)), this, SLOT( iconColorClicked(const QColor&))); | 424 | connect ( m_iconcolor, SIGNAL( colorSelected(const QColor&)), this, SLOT( iconColorClicked(const QColor&))); |
433 | gridLayout-> addWidget ( m_iconcolor, 3, 1, AlignLeft ); | 425 | gridLayout-> addWidget ( m_iconcolor, 3, 1, AlignLeft ); |
434 | 426 | ||
435 | label = new QLabel( tr( "Columns:" ), tab ); | 427 | label = new QLabel( tr( "Columns:" ), tab ); |
436 | gridLayout->addWidget( label, 4, 0 ); | 428 | gridLayout->addWidget( label, 4, 0 ); |
437 | m_iconcolumns = new QSpinBox( 0, 10, 1, tab, "iconspinbox" ); | 429 | m_iconcolumns = new QSpinBox( 0, 10, 1, tab, "iconspinbox" ); |
438 | m_iconcolumns->setSpecialValueText( tr( "Automatic" ) ); | 430 | m_iconcolumns->setSpecialValueText( tr( "Automatic" ) ); |
439 | gridLayout->addWidget( m_iconcolumns, 4, 1, AlignLeft ); | 431 | gridLayout->addWidget( m_iconcolumns, 4, 1, AlignLeft ); |
440 | 432 | ||
441 | vertLayout-> addStretch ( 10 ); | 433 | vertLayout-> addStretch ( 10 ); |
442 | 434 | ||
443 | if ( m_tc.m_last_directory == QString::null ) { | 435 | if ( m_tc.m_last_directory == QString::null ) { |
444 | m_tc.m_last_directory = QPEApplication::documentDir(); | 436 | m_tc.m_last_directory = QPEApplication::documentDir(); |
445 | } | 437 | } |
446 | 438 | ||
447 | return tab; | 439 | return tab; |
448 | } | 440 | } |
449 | 441 | ||
450 | 442 | ||
451 | void TabDialog::iconSizeClicked ( int s ) | 443 | void TabDialog::iconSizeClicked ( int s ) |
452 | { | 444 | { |
453 | m_sample-> setViewMode ((TabConfig::ViewMode) s ); | 445 | m_sample-> setViewMode ((TabConfig::ViewMode) s ); |
454 | } | 446 | } |
455 | 447 | ||
456 | void TabDialog::fontClicked ( const QFont &f ) | 448 | void TabDialog::fontClicked ( const QFont &f ) |
457 | { | 449 | { |
458 | m_sample-> setViewFont ( f ); | 450 | m_sample-> setViewFont ( f ); |
459 | } | 451 | } |
460 | 452 | ||
461 | void TabDialog::bgTypeClicked ( int t ) | 453 | void TabDialog::bgTypeClicked ( int t ) |
462 | { | 454 | { |
463 | QString s; | 455 | QString s; |
464 | |||
465 | if ( m_bgtype-> id ( m_bgtype-> selected ( )) != t ) | ||
466 | m_bgtype-> setButton ( t ); | ||
467 | |||
468 | m_solidcolor-> setEnabled ( t == TabConfig::SolidColor ); | 456 | m_solidcolor-> setEnabled ( t == TabConfig::SolidColor ); |
469 | m_imagebrowse-> setEnabled ( t == TabConfig::Image ); | 457 | m_imagebrowse-> setEnabled ( t == TabConfig::Image ); |
470 | 458 | ||
471 | if ( t == TabConfig::SolidColor ) | 459 | if ( t == TabConfig::SolidColor ) |
472 | s = m_solidcolor-> color ( ). name ( ); | 460 | s = m_solidcolor-> color ( ). name ( ); |
473 | else if ( t == TabConfig::Image ) | 461 | else if ( t == TabConfig::Image ) |
474 | s = Resource::findPixmap ( m_bgimage ); | 462 | s = m_bgimage; |
475 | 463 | ||
476 | m_sample-> setBackgroundType ((TabConfig::BackgroundType) t, s ); | 464 | m_sample-> setBackgroundType ((TabConfig::BackgroundType) t, s ); |
477 | } | 465 | } |
478 | 466 | ||
479 | void TabDialog::bgColorClicked ( const QColor & ) | 467 | void TabDialog::bgColorClicked ( const QColor & ) |
480 | { | 468 | { |
481 | bgTypeClicked ( TabConfig::SolidColor ); | 469 | m_sample-> setBackgroundType ( TabConfig::SolidColor, m_solidcolor-> color ( ). name ( ) ); |
482 | } | 470 | } |
483 | 471 | ||
484 | void TabDialog::iconColorClicked ( const QColor &col ) | 472 | void TabDialog::iconColorClicked ( const QColor &col ) |
485 | { | 473 | { |
486 | m_sample-> setTextColor ( col ); | 474 | m_sample-> setTextColor ( col ); |
487 | } | 475 | } |
488 | 476 | ||
489 | void TabDialog::bgImageClicked ( ) | 477 | void TabDialog::bgImageClicked ( ) |
490 | { | 478 | { |
491 | // ### use OFileSelector here ### | 479 | // ### use OFileSelector here ### |
492 | // this is just a quick c&p from the old appearance app | 480 | // this is just a quick c&p from the old appearance app |
493 | 481 | ||
494 | MimeTypes types; | 482 | MimeTypes types; |
495 | QStringList list; | 483 | QStringList list; |
496 | list << "image/*"; | 484 | list << "image/*"; |
497 | types. insert ( "Images", list ); | 485 | types. insert ( "Images", list ); |
498 | 486 | ||
499 | QString file = OFileDialog::getOpenFileName ( 1, m_tc.m_last_directory, QString::null, types ); | 487 | QString file = OFileDialog::getOpenFileName ( 1, m_tc.m_last_directory, QString::null, types ); |
500 | 488 | ||
501 | if ( !file. isEmpty ( )) { | 489 | if ( !file. isEmpty ( )) { |
502 | m_tc.m_last_directory = QFileInfo( file ).dirPath(); | 490 | m_tc.m_last_directory = QFileInfo( file ).dirPath(); |
503 | m_bgimage = DocLnk ( file ). file ( ); | 491 | m_bgimage = DocLnk ( file ). file ( ); |
504 | bgTypeClicked ( TabConfig::Image ); | 492 | m_sample-> setBackgroundType ( TabConfig::Image, m_bgimage ); |
505 | } | 493 | } |
506 | } | 494 | } |
507 | 495 | ||
508 | void TabDialog::bgDefaultClicked ( ) | 496 | void TabDialog::bgDefaultClicked ( ) |
509 | { | 497 | { |
498 | m_bgtype-> setButton ( TabConfig::Image ); | ||
510 | m_bgimage = "launcher/opie-background"; | 499 | m_bgimage = "launcher/opie-background"; |
511 | bgTypeClicked ( TabConfig::Image ); | 500 | bgTypeClicked( TabConfig::Image ); |
501 | //m_sample-> setBackgroundType ( TabConfig::Image, m_bgimage ); | ||
512 | } | 502 | } |
513 | 503 | ||
514 | void TabDialog::accept ( ) | 504 | void TabDialog::accept ( ) |
515 | { | 505 | { |
516 | m_tc. m_view = (TabConfig::ViewMode) m_iconsize-> id ( m_iconsize-> selected ( )); | 506 | m_tc. m_view = (TabConfig::ViewMode) m_iconsize-> id ( m_iconsize-> selected ( )); |
517 | m_tc. m_bg_type = (TabConfig::BackgroundType) m_bgtype-> id ( m_bgtype-> selected ( )); | 507 | m_tc. m_bg_type = (TabConfig::BackgroundType) m_bgtype-> id ( m_bgtype-> selected ( )); |
518 | m_tc. m_bg_color = m_solidcolor-> color ( ). name ( ); | 508 | m_tc. m_bg_color = m_solidcolor-> color ( ). name ( ); |
519 | m_tc. m_iconcolumns = m_iconcolumns-> value( ); | 509 | m_tc. m_iconcolumns = m_iconcolumns-> value( ); |
520 | m_tc. m_bg_image = m_bgimage; | 510 | m_tc. m_bg_image = m_bgimage; |
521 | m_tc. m_text_color = m_iconcolor-> color ( ). name ( ); | 511 | m_tc. m_text_color = m_iconcolor-> color ( ). name ( ); |
522 | 512 | ||
523 | m_tc. m_font_use = m_fontuse-> isChecked ( ); | 513 | m_tc. m_font_use = m_fontuse-> isChecked ( ); |
524 | 514 | ||
525 | if ( m_tc. m_font_use ) { | 515 | if ( m_tc. m_font_use ) { |
526 | QFont f = m_fontselect-> selectedFont ( ); | 516 | QFont f = m_fontselect-> selectedFont ( ); |
527 | 517 | ||
528 | m_tc. m_font_family = f. family ( ); | 518 | m_tc. m_font_family = f. family ( ); |
529 | m_tc. m_font_size = f. pointSize ( ); | 519 | m_tc. m_font_size = f. pointSize ( ); |
530 | m_tc. m_font_weight = f. weight ( ); | 520 | m_tc. m_font_weight = f. weight ( ); |
531 | m_tc. m_font_italic = f. italic ( ); | 521 | m_tc. m_font_italic = f. italic ( ); |
532 | } | 522 | } |
533 | 523 | ||
534 | QDialog::accept ( ); | 524 | QDialog::accept ( ); |
535 | } | 525 | } |