summaryrefslogtreecommitdiff
path: root/core/settings/launcher/tabdialog.cpp
Unidiff
Diffstat (limited to 'core/settings/launcher/tabdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/settings/launcher/tabdialog.cpp45
1 files changed, 30 insertions, 15 deletions
diff --git a/core/settings/launcher/tabdialog.cpp b/core/settings/launcher/tabdialog.cpp
index a90ba7d..d20412a 100644
--- a/core/settings/launcher/tabdialog.cpp
+++ b/core/settings/launcher/tabdialog.cpp
@@ -18,48 +18,49 @@
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#include <qpe/resource.h> 28#include <qpe/resource.h>
29#include <qpe/config.h> 29#include <qpe/config.h>
30#include <qpe/applnk.h> 30#include <qpe/applnk.h>
31 31
32#include <qlayout.h> 32#include <qlayout.h>
33#include <qvbox.h> 33#include <qvbox.h>
34#include <qtabbar.h> 34#include <qtabbar.h>
35#include <qiconview.h> 35#include <qiconview.h>
36#include <qapplication.h> 36#include <qapplication.h>
37#include <qlabel.h> 37#include <qlabel.h>
38#include <qradiobutton.h> 38#include <qradiobutton.h>
39#include <qbuttongroup.h> 39#include <qbuttongroup.h>
40#include <qpushbutton.h> 40#include <qpushbutton.h>
41#include <qwhatsthis.h> 41#include <qwhatsthis.h>
42#include <qcheckbox.h>
42 43
43#include <opie/ofontselector.h> 44#include <opie/ofontselector.h>
44#include <opie/otabwidget.h> 45#include <opie/otabwidget.h>
45#include <opie/ocolorbutton.h> 46#include <opie/ocolorbutton.h>
46#include <opie/ofiledialog.h> 47#include <opie/ofiledialog.h>
47 48
48#include "tabdialog.h" 49#include "tabdialog.h"
49 50
50 51
51class SampleItem : public QIconViewItem { 52class SampleItem : public QIconViewItem {
52public: 53public:
53 SampleItem ( QIconView *v, const QString &text, const QPixmap &pix ) : QIconViewItem ( v, text ) 54 SampleItem ( QIconView *v, const QString &text, const QPixmap &pix ) : QIconViewItem ( v, text )
54 { 55 {
55 m_large = pix; 56 m_large = pix;
56 m_small. convertFromImage ( pix. convertToImage ( ). smoothScale ( pix. width ( ) / 2, pix. height ( ) / 2 )); 57 m_small. convertFromImage ( pix. convertToImage ( ). smoothScale ( pix. width ( ) / 2, pix. height ( ) / 2 ));
57 } 58 }
58 59
59 void sizeChange ( ) 60 void sizeChange ( )
60 { 61 {
61 calcRect ( ); 62 calcRect ( );
62 repaint ( ); 63 repaint ( );
63 } 64 }
64 65
65 QPixmap *pixmap ( ) const 66 QPixmap *pixmap ( ) const
@@ -246,163 +247,173 @@ public:
246 void drawBackground ( QPainter *p, const QRect &r ) 247 void drawBackground ( QPainter *p, const QRect &r )
247 { 248 {
248 if ( !m_bgpix. isNull ( )) { 249 if ( !m_bgpix. isNull ( )) {
249 p-> drawTiledPixmap ( r, m_bgpix, QPoint (( r. x ( ) + contentsX ( )) % m_bgpix. width ( ), 250 p-> drawTiledPixmap ( r, m_bgpix, QPoint (( r. x ( ) + contentsX ( )) % m_bgpix. width ( ),
250 ( r. y ( ) + contentsY ( )) % m_bgpix. height ( ))); 251 ( r. y ( ) + contentsY ( )) % m_bgpix. height ( )));
251 } 252 }
252 else 253 else
253 p-> fillRect ( r, m_bgcolor ); 254 p-> fillRect ( r, m_bgcolor );
254 } 255 }
255 256
256private: 257private:
257 QColor m_textcolor; 258 QColor m_textcolor;
258 QColor m_bgcolor; 259 QColor m_bgcolor;
259 QPixmap m_bgpix; 260 QPixmap m_bgpix;
260 TabConfig::BackgroundType m_bgtype; 261 TabConfig::BackgroundType m_bgtype;
261}; 262};
262 263
263 264
264 265
265TabDialog::TabDialog ( const QPixmap *tabicon, const QString &tabname, TabConfig &tc, QWidget *parent, const char *name, bool modal, WFlags fl ) 266TabDialog::TabDialog ( const QPixmap *tabicon, const QString &tabname, TabConfig &tc, QWidget *parent, const char *name, bool modal, WFlags fl )
266 : QDialog ( parent, name, modal, fl | WStyle_ContextHelp ), m_tc ( tc ) 267 : QDialog ( parent, name, modal, fl | WStyle_ContextHelp ), m_tc ( tc )
267{ 268{
268 setCaption ( tr( "Edit Tab" )); 269 setCaption ( tr( "Edit Tab" ));
269 270
270 QVBoxLayout *lay = new QVBoxLayout ( this, 4, 4 ); 271 QVBoxLayout *lay = new QVBoxLayout ( this, 3, 3 );
271 272
272 OTabWidget *tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); 273 OTabWidget *tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom );
273 QWidget *bgtab; 274 QWidget *bgtab;
274 275
275 tw-> addTab ( bgtab = createBgTab ( tw ), "appearance/backgroundtabicon.png", tr( "Background" )); 276 tw-> addTab ( bgtab = createBgTab ( tw ), "appearance/backgroundtabicon.png", tr( "Background" ));
276 tw-> addTab ( createFontTab ( tw ), "appearance/fonttabicon.png", tr( "Font" )); 277 tw-> addTab ( createFontTab ( tw ), "appearance/fonttabicon.png", tr( "Font" ));
277 tw-> addTab ( createIconTab ( tw ), "appearance/colorstabicon.png", tr( "Icons" ) ); 278 tw-> addTab ( createIconTab ( tw ), "appearance/colorstabicon.png", tr( "Icons" ) );
278 279
279 tw-> setCurrentTab ( bgtab ); 280 tw-> setCurrentTab ( bgtab );
280 281
281 QWidget *sample = new QVBox ( this ); 282 QWidget *sample = new QVBox ( this );
282 QTabBar *tb = new QTabBar ( sample ); 283 QTabBar *tb = new QTabBar ( sample );
283 QString name ( tr( "Previewing %1" ). arg ( tabname )); 284 QString name ( tr( "Previewing %1" ). arg ( tabname ));
284 285
285 tb-> addTab ( tabicon ? new QTab ( *tabicon, name ) : new QTab ( name )); 286 tb-> addTab ( tabicon ? new QTab ( *tabicon, name ) : new QTab ( name ));
286 287
287 m_sample = new SampleView ( sample ); 288 m_sample = new SampleView ( sample );
288 289
289 lay-> addWidget ( tw, 10 ); 290 lay-> addWidget ( tw, 10 );
290 lay-> addWidget ( sample, 1 ); 291 lay-> addWidget ( sample, 1 );
291 292
292 m_iconsize-> setButton ( tc. m_view ); 293 m_iconsize-> setButton ( tc. m_view );
293 iconSizeClicked ( tc. m_view ); 294 iconSizeClicked ( tc. m_view );
294 m_iconcolor-> setColor ( QColor ( m_tc. m_text_color )); 295 m_iconcolor-> setColor ( QColor ( m_tc. m_text_color ));
295 iconColorClicked ( m_iconcolor-> color ( )); 296 iconColorClicked ( m_iconcolor-> color ( ));
296 m_bgtype-> setButton ( tc. m_bg_type ); 297 m_bgtype-> setButton ( tc. m_bg_type );
297 m_solidcolor-> setColor ( QColor ( tc. m_bg_color )); 298 m_solidcolor-> setColor ( QColor ( tc. m_bg_color ));
298 m_bgimage = tc. m_bg_image; 299 m_bgimage = tc. m_bg_image;
299 bgTypeClicked ( tc. m_bg_type ); 300 bgTypeClicked ( tc. m_bg_type );
301 m_fontuse-> setChecked ( tc. m_font_use );
300 m_fontselect-> setSelectedFont ( QFont ( tc. m_font_family, tc. m_font_size, tc. m_font_weight, tc. m_font_italic )); 302 m_fontselect-> setSelectedFont ( QFont ( tc. m_font_family, tc. m_font_size, tc. m_font_weight, tc. m_font_italic ));
303 m_fontselect-> setEnabled ( m_fontuse-> isChecked ( ));
301 fontClicked ( m_fontselect-> selectedFont ( )); 304 fontClicked ( m_fontselect-> selectedFont ( ));
302 305
303 QWhatsThis::add ( sample, tr( "This is a rough preview of what the currently selected Tab will look like." )); 306 QWhatsThis::add ( sample, tr( "This is a rough preview of what the currently selected Tab will look like." ));
304} 307}
305 308
306 309
307TabDialog::~TabDialog ( ) 310TabDialog::~TabDialog ( )
308{ 311{
309} 312}
310 313
311QWidget *TabDialog::createFontTab ( QWidget *parent ) 314QWidget *TabDialog::createFontTab ( QWidget *parent )
312{ 315{
313 m_fontselect = new OFontSelector ( false, parent, "FontTab" ); 316 QWidget *tab = new QWidget ( parent, "FontTab" );
317 QVBoxLayout *vertLayout = new QVBoxLayout ( tab, 3, 3 );
318
319 m_fontuse = new QCheckBox ( tr( "Use a custom font" ), tab );
320 vertLayout-> addWidget ( m_fontuse );
321
322 m_fontselect = new OFontSelector ( false, tab, "fontsel" );
323 vertLayout-> addWidget ( m_fontselect );
314 324
325 connect ( m_fontuse, SIGNAL( toggled ( bool )), m_fontselect, SLOT( setEnabled ( bool )));
315 connect( m_fontselect, SIGNAL( fontSelected ( const QFont & )), 326 connect( m_fontselect, SIGNAL( fontSelected ( const QFont & )),
316 this, SLOT( fontClicked ( const QFont & ))); 327 this, SLOT( fontClicked ( const QFont & )));
317 328
318 return m_fontselect; 329 return tab;
319} 330}
320 331
321QWidget *TabDialog::createBgTab ( QWidget *parent ) 332QWidget *TabDialog::createBgTab ( QWidget *parent )
322{ 333{
323 QWidget *tab = new QWidget( parent, "AdvancedTab" ); 334 QWidget *tab = new QWidget( parent, "BgTab" );
324 QVBoxLayout *vertLayout = new QVBoxLayout( tab, 4, 4 ); 335 QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 );
325 336
326 QGridLayout* gridLayout = new QGridLayout ( vertLayout ); 337 QGridLayout* gridLayout = new QGridLayout ( vertLayout );
327 gridLayout-> setColStretch ( 1, 10 ); 338 gridLayout-> setColStretch ( 1, 10 );
328 339
329 QLabel* label = new QLabel( tr( "Type:" ), tab ); 340 QLabel* label = new QLabel( tr( "Type:" ), tab );
330 gridLayout-> addWidget ( label, 0, 0 ); 341 gridLayout-> addWidget ( label, 0, 0 );
331 m_bgtype = new QButtonGroup( tab, "buttongroup" ); 342 m_bgtype = new QButtonGroup( tab, "buttongroup" );
332 m_bgtype-> hide ( ); 343 m_bgtype-> hide ( );
333 m_bgtype-> setExclusive ( true ); 344 m_bgtype-> setExclusive ( true );
334 345
335 QRadioButton *rb; 346 QRadioButton *rb;
336 rb = new QRadioButton( tr( "Ruled" ), tab, "ruled" ); 347 rb = new QRadioButton( tr( "Ruled" ), tab, "ruled" );
337 m_bgtype-> insert ( rb, TabConfig::Ruled ); 348 m_bgtype-> insert ( rb, TabConfig::Ruled );
338 gridLayout-> addWidget( rb, 0, 1 ); 349 gridLayout-> addWidget( rb, 0, 1 );
339 350
340 QHBoxLayout *hb = new QHBoxLayout ( ); 351 QHBoxLayout *hb = new QHBoxLayout ( );
341 hb-> setSpacing ( 4 ); 352 hb-> setSpacing ( 3 );
342 353
343 rb = new QRadioButton( tr( "Solid color" ), tab, "solid" ); 354 rb = new QRadioButton( tr( "Solid color" ), tab, "solid" );
344 m_bgtype-> insert ( rb, TabConfig::SolidColor ); 355 m_bgtype-> insert ( rb, TabConfig::SolidColor );
345 hb-> addWidget ( rb ); 356 hb-> addWidget ( rb );
346 hb-> addSpacing ( 10 ); 357 hb-> addSpacing ( 10 );
347 358
348 m_solidcolor = new OColorButton ( tab ); 359 m_solidcolor = new OColorButton ( tab );
349 connect ( m_solidcolor, SIGNAL( colorSelected ( const QColor & )), this, SLOT( bgColorClicked ( const QColor & ))); 360 connect ( m_solidcolor, SIGNAL( colorSelected ( const QColor & )), this, SLOT( bgColorClicked ( const QColor & )));
350 hb-> addWidget ( m_solidcolor ); 361 hb-> addWidget ( m_solidcolor );
351 hb-> addStretch ( 10 ); 362 hb-> addStretch ( 10 );
352 363
353 gridLayout-> addLayout ( hb, 1, 1 ); 364 gridLayout-> addLayout ( hb, 1, 1 );
354 365
355 hb = new QHBoxLayout ( ); 366 hb = new QHBoxLayout ( );
356 hb-> setSpacing ( 4 ); 367 hb-> setSpacing ( 3 );
357 368
358 rb = new QRadioButton( tr( "Image" ), tab, "image" ); 369 rb = new QRadioButton( tr( "Image" ), tab, "image" );
359 m_bgtype-> insert ( rb, TabConfig::Image ); 370 m_bgtype-> insert ( rb, TabConfig::Image );
360 hb-> addWidget( rb ); 371 hb-> addWidget( rb );
361 hb-> addSpacing ( 10 ); 372 hb-> addSpacing ( 10 );
362 373
363 m_imagebrowse = new QPushButton ( tr( "Select..." ), tab ); 374 m_imagebrowse = new QPushButton ( tr( "Select..." ), tab );
364 connect ( m_imagebrowse, SIGNAL( clicked ( )), this, SLOT( bgImageClicked ( ))); 375 connect ( m_imagebrowse, SIGNAL( clicked ( )), this, SLOT( bgImageClicked ( )));
365 hb-> addWidget ( m_imagebrowse ); 376 hb-> addWidget ( m_imagebrowse );
366 hb-> addStretch ( 10 ); 377 hb-> addStretch ( 10 );
367 378
368 gridLayout-> addLayout ( hb, 2, 1 ); 379 gridLayout-> addLayout ( hb, 2, 1 );
369 380
370 QPushButton *p = new QPushButton ( tr( "Default" ), tab ); 381 QPushButton *p = new QPushButton ( tr( "Default" ), tab );
371 connect ( p, SIGNAL( clicked ( )), this, SLOT( bgDefaultClicked ( ))); 382 connect ( p, SIGNAL( clicked ( )), this, SLOT( bgDefaultClicked ( )));
372 gridLayout-> addWidget ( p, 3, 1 ); 383 gridLayout-> addWidget ( p, 3, 1 );
373 384
374 connect ( m_bgtype, SIGNAL( clicked ( int )), this, SLOT( bgTypeClicked ( int ))); 385 connect ( m_bgtype, SIGNAL( clicked ( int )), this, SLOT( bgTypeClicked ( int )));
375 386
376 vertLayout-> addStretch ( 10 ); 387 vertLayout-> addStretch ( 10 );
377 388
378 return tab; 389 return tab;
379} 390}
380 391
381QWidget *TabDialog::createIconTab ( QWidget *parent ) 392QWidget *TabDialog::createIconTab ( QWidget *parent )
382{ 393{
383 QWidget *tab = new QWidget( parent, "AdvancedTab" ); 394 QWidget *tab = new QWidget( parent, "IconTab" );
384 QVBoxLayout *vertLayout = new QVBoxLayout( tab, 4, 4 ); 395 QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 );
385 396
386 QGridLayout* gridLayout = new QGridLayout ( vertLayout ); 397 QGridLayout* gridLayout = new QGridLayout ( vertLayout );
387 gridLayout-> setColStretch ( 1, 10 ); 398 gridLayout-> setColStretch ( 1, 10 );
388 399
389 QLabel* label = new QLabel( tr( "Size:" ), tab ); 400 QLabel* label = new QLabel( tr( "Size:" ), tab );
390 gridLayout-> addWidget ( label, 0, 0 ); 401 gridLayout-> addWidget ( label, 0, 0 );
391 m_iconsize = new QButtonGroup( tab, "buttongroup" ); 402 m_iconsize = new QButtonGroup( tab, "buttongroup" );
392 m_iconsize-> hide ( ); 403 m_iconsize-> hide ( );
393 m_iconsize-> setExclusive ( true ); 404 m_iconsize-> setExclusive ( true );
394 405
395 QRadioButton *rb; 406 QRadioButton *rb;
396 rb = new QRadioButton( tr( "Small" ), tab, "iconsmall" ); 407 rb = new QRadioButton( tr( "Small" ), tab, "iconsmall" );
397 m_iconsize-> insert ( rb, TabConfig::List ); 408 m_iconsize-> insert ( rb, TabConfig::List );
398 gridLayout-> addWidget( rb, 0, 1 ); 409 gridLayout-> addWidget( rb, 0, 1 );
399 410
400 rb = new QRadioButton( tr( "Large" ), tab, "iconlarge" ); 411 rb = new QRadioButton( tr( "Large" ), tab, "iconlarge" );
401 m_iconsize-> insert ( rb, TabConfig::Icon ); 412 m_iconsize-> insert ( rb, TabConfig::Icon );
402 gridLayout-> addWidget( rb, 1, 1 ); 413 gridLayout-> addWidget( rb, 1, 1 );
403 414
404 connect ( m_iconsize, SIGNAL( clicked ( int )), this, SLOT( iconSizeClicked ( int ))); 415 connect ( m_iconsize, SIGNAL( clicked ( int )), this, SLOT( iconSizeClicked ( int )));
405 416
406 //vertLayout-> addSpacing ( 8 ); 417 //vertLayout-> addSpacing ( 8 );
407 418
408 //gridLayout = new QGridLayout ( vertLayout ); 419 //gridLayout = new QGridLayout ( vertLayout );
@@ -468,34 +479,38 @@ void TabDialog::bgImageClicked ( )
468 QStringList list; 479 QStringList list;
469 list << "image/*"; 480 list << "image/*";
470 types. insert ( "Images", list ); 481 types. insert ( "Images", list );
471 482
472 QString file = OFileDialog::getOpenFileName ( 1, "/", QString::null, types ); 483 QString file = OFileDialog::getOpenFileName ( 1, "/", QString::null, types );
473 if ( !file. isEmpty ( )) { 484 if ( !file. isEmpty ( )) {
474 m_bgimage = DocLnk ( file ). file ( ); 485 m_bgimage = DocLnk ( file ). file ( );
475 bgTypeClicked ( TabConfig::Image ); 486 bgTypeClicked ( TabConfig::Image );
476 } 487 }
477} 488}
478 489
479void TabDialog::bgDefaultClicked ( ) 490void TabDialog::bgDefaultClicked ( )
480{ 491{
481 m_bgimage = "launcher/opie-background"; 492 m_bgimage = "launcher/opie-background";
482 bgTypeClicked ( TabConfig::Image ); 493 bgTypeClicked ( TabConfig::Image );
483} 494}
484 495
485void TabDialog::accept ( ) 496void TabDialog::accept ( )
486{ 497{
487 m_tc. m_view = (TabConfig::ViewMode) m_iconsize-> id ( m_iconsize-> selected ( )); 498 m_tc. m_view = (TabConfig::ViewMode) m_iconsize-> id ( m_iconsize-> selected ( ));
488 m_tc. m_bg_type = (TabConfig::BackgroundType) m_bgtype-> id ( m_bgtype-> selected ( )); 499 m_tc. m_bg_type = (TabConfig::BackgroundType) m_bgtype-> id ( m_bgtype-> selected ( ));
489 m_tc. m_bg_color = m_solidcolor-> color ( ). name ( ); 500 m_tc. m_bg_color = m_solidcolor-> color ( ). name ( );
490 m_tc. m_bg_image = m_bgimage; 501 m_tc. m_bg_image = m_bgimage;
491 m_tc. m_text_color = m_iconcolor-> color ( ). name ( ); 502 m_tc. m_text_color = m_iconcolor-> color ( ). name ( );
503
504 m_tc. m_font_use = m_fontuse-> isChecked ( );
505
506 if ( m_tc. m_font_use ) {
507 QFont f = m_fontselect-> selectedFont ( );
492 508
493 QFont f = m_fontselect-> selectedFont ( ); 509 m_tc. m_font_family = f. family ( );
494 510 m_tc. m_font_size = f. pointSize ( );
495 m_tc. m_font_family = f. family ( ); 511 m_tc. m_font_weight = f. weight ( );
496 m_tc. m_font_size = f. pointSize ( ); 512 m_tc. m_font_italic = f. italic ( );
497 m_tc. m_font_weight = f. weight ( ); 513 }
498 m_tc. m_font_italic = f. italic ( );
499 514
500 QDialog::accept ( ); 515 QDialog::accept ( );
501} 516}