-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 | |||
@@ -146,42 +146,35 @@ public: | |||
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 | } |
@@ -286,46 +279,46 @@ TabDialog::TabDialog ( const QPixmap *tabicon, const QString &tabname, TabConfig | |||
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 | ||
@@ -339,32 +332,33 @@ QWidget *TabDialog::createFontTab ( QWidget *parent ) | |||
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&))); |
@@ -379,34 +373,32 @@ QWidget *TabDialog::createBgTab ( QWidget *parent ) | |||
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" ); |
@@ -448,80 +440,78 @@ QWidget *TabDialog::createIconTab ( QWidget *parent ) | |||
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 | ||