-rw-r--r-- | libopie/colordialog.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/libopie/colordialog.cpp b/libopie/colordialog.cpp index d46da41..b2854a6 100644 --- a/libopie/colordialog.cpp +++ b/libopie/colordialog.cpp | |||
@@ -379,196 +379,196 @@ public: | |||
379 | 379 | ||
380 | QRgb currentColor() const { return curCol; } | 380 | QRgb currentColor() const { return curCol; } |
381 | 381 | ||
382 | public slots: | 382 | public slots: |
383 | void setRgb( QRgb rgb ); | 383 | void setRgb( QRgb rgb ); |
384 | 384 | ||
385 | signals: | 385 | signals: |
386 | void newCol( QRgb rgb ); | 386 | void newCol( QRgb rgb ); |
387 | private slots: | 387 | private slots: |
388 | void rgbEd(); | 388 | void rgbEd(); |
389 | void hsvEd(); | 389 | void hsvEd(); |
390 | private: | 390 | private: |
391 | void showCurrentColor(); | 391 | void showCurrentColor(); |
392 | int hue, sat, val; | 392 | int hue, sat, val; |
393 | QRgb curCol; | 393 | QRgb curCol; |
394 | QColNumLineEdit *hEd; | 394 | QColNumLineEdit *hEd; |
395 | QColNumLineEdit *sEd; | 395 | QColNumLineEdit *sEd; |
396 | QColNumLineEdit *vEd; | 396 | QColNumLineEdit *vEd; |
397 | QColNumLineEdit *rEd; | 397 | QColNumLineEdit *rEd; |
398 | QColNumLineEdit *gEd; | 398 | QColNumLineEdit *gEd; |
399 | QColNumLineEdit *bEd; | 399 | QColNumLineEdit *bEd; |
400 | QColNumLineEdit *alphaEd; | 400 | QColNumLineEdit *alphaEd; |
401 | QLabel *alphaLab; | 401 | QLabel *alphaLab; |
402 | QColorShowLabel *lab; | 402 | QColorShowLabel *lab; |
403 | bool rgbOriginal; | 403 | bool rgbOriginal; |
404 | }; | 404 | }; |
405 | 405 | ||
406 | class QColorShowLabel : public QFrame | 406 | class QColorShowLabel : public QFrame |
407 | { | 407 | { |
408 | Q_OBJECT | 408 | Q_OBJECT |
409 | 409 | ||
410 | public: | 410 | public: |
411 | QColorShowLabel( QWidget *parent ) :QFrame( parent ) { | 411 | QColorShowLabel( QWidget *parent ) :QFrame( parent ) { |
412 | setFrameStyle( QFrame::Panel|QFrame::Sunken ); | 412 | setFrameStyle( QFrame::Panel|QFrame::Sunken ); |
413 | setBackgroundMode( PaletteBackground ); | 413 | setBackgroundMode( PaletteBackground ); |
414 | setAcceptDrops( TRUE ); | 414 | setAcceptDrops( TRUE ); |
415 | mousePressed = FALSE; | 415 | mousePressed = FALSE; |
416 | } | 416 | } |
417 | void setColor( QColor c ) { col = c; } | 417 | void setColor( QColor c ) { col = c; } |
418 | 418 | ||
419 | signals: | 419 | signals: |
420 | void colorDropped( QRgb ); | 420 | void colorDropped( QRgb ); |
421 | 421 | ||
422 | protected: | 422 | protected: |
423 | void drawContents( QPainter *p ); | 423 | void drawContents( QPainter *p ); |
424 | void mousePressEvent( QMouseEvent *e ); | 424 | void mousePressEvent( QMouseEvent *e ); |
425 | void mouseReleaseEvent( QMouseEvent *e ); | 425 | void mouseReleaseEvent( QMouseEvent *e ); |
426 | 426 | ||
427 | private: | 427 | private: |
428 | QColor col; | 428 | QColor col; |
429 | bool mousePressed; | 429 | bool mousePressed; |
430 | QPoint pressPos; | 430 | QPoint pressPos; |
431 | 431 | ||
432 | }; | 432 | }; |
433 | 433 | ||
434 | void QColorShowLabel::drawContents( QPainter *p ) | 434 | void QColorShowLabel::drawContents( QPainter *p ) |
435 | { | 435 | { |
436 | p->fillRect( contentsRect(), col ); | 436 | p->fillRect( contentsRect(), col ); |
437 | } | 437 | } |
438 | 438 | ||
439 | void QColorShower::showAlpha( bool b ) | 439 | void QColorShower::showAlpha( bool b ) |
440 | { | 440 | { |
441 | if ( b ) { | 441 | if ( b ) { |
442 | alphaLab->show(); | 442 | alphaLab->show(); |
443 | alphaEd->show(); | 443 | alphaEd->show(); |
444 | } else { | 444 | } else { |
445 | alphaLab->hide(); | 445 | alphaLab->hide(); |
446 | alphaEd->hide(); | 446 | alphaEd->hide(); |
447 | } | 447 | } |
448 | } | 448 | } |
449 | 449 | ||
450 | void QColorShowLabel::mousePressEvent( QMouseEvent *e ) | 450 | void QColorShowLabel::mousePressEvent( QMouseEvent *e ) |
451 | { | 451 | { |
452 | mousePressed = TRUE; | 452 | mousePressed = TRUE; |
453 | pressPos = e->pos(); | 453 | pressPos = e->pos(); |
454 | } | 454 | } |
455 | 455 | ||
456 | void QColorShowLabel::mouseReleaseEvent( QMouseEvent * ) | 456 | void QColorShowLabel::mouseReleaseEvent( QMouseEvent * ) |
457 | { | 457 | { |
458 | if ( !mousePressed ) | 458 | if ( !mousePressed ) |
459 | return; | 459 | return; |
460 | mousePressed = FALSE; | 460 | mousePressed = FALSE; |
461 | } | 461 | } |
462 | 462 | ||
463 | QColorShower::QColorShower( QWidget *parent, const char *name ) | 463 | QColorShower::QColorShower( QWidget *parent, const char *name ) |
464 | :QWidget( parent, name) | 464 | :QWidget( parent, name) |
465 | { | 465 | { |
466 | curCol = qRgb( -1, -1, -1 ); | 466 | curCol = qRgb( -1, -1, -1 ); |
467 | QColIntValidator *val256 = new QColIntValidator( 0, 255, this ); | 467 | QColIntValidator *val256 = new QColIntValidator( 0, 255, this ); |
468 | QColIntValidator *val360 = new QColIntValidator( 0, 360, this ); | 468 | QColIntValidator *val360 = new QColIntValidator( 0, 360, this ); |
469 | 469 | ||
470 | QGridLayout *gl = new QGridLayout( this, 1, 1, 2 ); | 470 | QGridLayout *gl = new QGridLayout( this, 1, 1, 2 ); |
471 | gl->setMargin( 0 ); | 471 | gl->setMargin( 0 ); |
472 | lab = new QColorShowLabel( this ); | 472 | lab = new QColorShowLabel( this ); |
473 | lab->setMinimumWidth( 60 ); //### | 473 | lab->setMinimumWidth( 60 ); //### |
474 | gl->addMultiCellWidget(lab, 0,-1,0,0); | 474 | gl->addMultiCellWidget(lab, 0,-1,0,0); |
475 | connect( lab, SIGNAL( colorDropped( QRgb ) ), | 475 | connect( lab, SIGNAL( colorDropped(QRgb) ), |
476 | this, SIGNAL( newCol( QRgb ) ) ); | 476 | this, SIGNAL( newCol(QRgb) ) ); |
477 | connect( lab, SIGNAL( colorDropped( QRgb ) ), | 477 | connect( lab, SIGNAL( colorDropped(QRgb) ), |
478 | this, SLOT( setRgb( QRgb ) ) ); | 478 | this, SLOT( setRgb(QRgb) ) ); |
479 | 479 | ||
480 | hEd = new QColNumLineEdit( this ); | 480 | hEd = new QColNumLineEdit( this ); |
481 | hEd->setValidator( val360 ); | 481 | hEd->setValidator( val360 ); |
482 | QLabel *l = new QLabel( hEd, OColorDialog::tr("Hue:"), this ); | 482 | QLabel *l = new QLabel( hEd, OColorDialog::tr("Hue:"), this ); |
483 | l->setAlignment( AlignRight|AlignVCenter ); | 483 | l->setAlignment( AlignRight|AlignVCenter ); |
484 | gl->addWidget( l, 0, 1 ); | 484 | gl->addWidget( l, 0, 1 ); |
485 | gl->addWidget( hEd, 0, 2 ); | 485 | gl->addWidget( hEd, 0, 2 ); |
486 | 486 | ||
487 | sEd = new QColNumLineEdit( this ); | 487 | sEd = new QColNumLineEdit( this ); |
488 | sEd->setValidator( val256 ); | 488 | sEd->setValidator( val256 ); |
489 | l = new QLabel( sEd, OColorDialog::tr("Sat:"), this ); | 489 | l = new QLabel( sEd, OColorDialog::tr("Sat:"), this ); |
490 | l->setAlignment( AlignRight|AlignVCenter ); | 490 | l->setAlignment( AlignRight|AlignVCenter ); |
491 | gl->addWidget( l, 1, 1 ); | 491 | gl->addWidget( l, 1, 1 ); |
492 | gl->addWidget( sEd, 1, 2 ); | 492 | gl->addWidget( sEd, 1, 2 ); |
493 | 493 | ||
494 | vEd = new QColNumLineEdit( this ); | 494 | vEd = new QColNumLineEdit( this ); |
495 | vEd->setValidator( val256 ); | 495 | vEd->setValidator( val256 ); |
496 | l = new QLabel( vEd, OColorDialog::tr("Val:"), this ); | 496 | l = new QLabel( vEd, OColorDialog::tr("Val:"), this ); |
497 | l->setAlignment( AlignRight|AlignVCenter ); | 497 | l->setAlignment( AlignRight|AlignVCenter ); |
498 | gl->addWidget( l, 2, 1 ); | 498 | gl->addWidget( l, 2, 1 ); |
499 | gl->addWidget( vEd, 2, 2 ); | 499 | gl->addWidget( vEd, 2, 2 ); |
500 | 500 | ||
501 | rEd = new QColNumLineEdit( this ); | 501 | rEd = new QColNumLineEdit( this ); |
502 | rEd->setValidator( val256 ); | 502 | rEd->setValidator( val256 ); |
503 | l = new QLabel( rEd, OColorDialog::tr("Red:"), this ); | 503 | l = new QLabel( rEd, OColorDialog::tr("Red:"), this ); |
504 | l->setAlignment( AlignRight|AlignVCenter ); | 504 | l->setAlignment( AlignRight|AlignVCenter ); |
505 | gl->addWidget( l, 0, 3 ); | 505 | gl->addWidget( l, 0, 3 ); |
506 | gl->addWidget( rEd, 0, 4 ); | 506 | gl->addWidget( rEd, 0, 4 ); |
507 | 507 | ||
508 | gEd = new QColNumLineEdit( this ); | 508 | gEd = new QColNumLineEdit( this ); |
509 | gEd->setValidator( val256 ); | 509 | gEd->setValidator( val256 ); |
510 | l = new QLabel( gEd, OColorDialog::tr("Green:"), this ); | 510 | l = new QLabel( gEd, OColorDialog::tr("Green:"), this ); |
511 | l->setAlignment( AlignRight|AlignVCenter ); | 511 | l->setAlignment( AlignRight|AlignVCenter ); |
512 | gl->addWidget( l, 1, 3 ); | 512 | gl->addWidget( l, 1, 3 ); |
513 | gl->addWidget( gEd, 1, 4 ); | 513 | gl->addWidget( gEd, 1, 4 ); |
514 | 514 | ||
515 | bEd = new QColNumLineEdit( this ); | 515 | bEd = new QColNumLineEdit( this ); |
516 | bEd->setValidator( val256 ); | 516 | bEd->setValidator( val256 ); |
517 | l = new QLabel( bEd, OColorDialog::tr("Blue:"), this ); | 517 | l = new QLabel( bEd, OColorDialog::tr("Blue:"), this ); |
518 | l->setAlignment( AlignRight|AlignVCenter ); | 518 | l->setAlignment( AlignRight|AlignVCenter ); |
519 | gl->addWidget( l, 2, 3 ); | 519 | gl->addWidget( l, 2, 3 ); |
520 | gl->addWidget( bEd, 2, 4 ); | 520 | gl->addWidget( bEd, 2, 4 ); |
521 | 521 | ||
522 | alphaEd = new QColNumLineEdit( this ); | 522 | alphaEd = new QColNumLineEdit( this ); |
523 | alphaEd->setValidator( val256 ); | 523 | alphaEd->setValidator( val256 ); |
524 | alphaLab = new QLabel( alphaEd, OColorDialog::tr("Alpha channel:"), this ); | 524 | alphaLab = new QLabel( alphaEd, OColorDialog::tr("Alpha channel:"), this ); |
525 | alphaLab->setAlignment( AlignRight|AlignVCenter ); | 525 | alphaLab->setAlignment( AlignRight|AlignVCenter ); |
526 | gl->addMultiCellWidget( alphaLab, 3, 3, 1, 3 ); | 526 | gl->addMultiCellWidget( alphaLab, 3, 3, 1, 3 ); |
527 | gl->addWidget( alphaEd, 3, 4 ); | 527 | gl->addWidget( alphaEd, 3, 4 ); |
528 | alphaEd->hide(); | 528 | alphaEd->hide(); |
529 | alphaLab->hide(); | 529 | alphaLab->hide(); |
530 | 530 | ||
531 | connect( hEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) ); | 531 | connect( hEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) ); |
532 | connect( sEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) ); | 532 | connect( sEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) ); |
533 | connect( vEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) ); | 533 | connect( vEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) ); |
534 | 534 | ||
535 | connect( rEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) ); | 535 | connect( rEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) ); |
536 | connect( gEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) ); | 536 | connect( gEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) ); |
537 | connect( bEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) ); | 537 | connect( bEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) ); |
538 | } | 538 | } |
539 | 539 | ||
540 | void QColorShower::showCurrentColor() | 540 | void QColorShower::showCurrentColor() |
541 | { | 541 | { |
542 | lab->setColor( currentColor() ); | 542 | lab->setColor( currentColor() ); |
543 | lab->repaint(FALSE); //### | 543 | lab->repaint(FALSE); //### |
544 | } | 544 | } |
545 | 545 | ||
546 | void QColorShower::rgbEd() | 546 | void QColorShower::rgbEd() |
547 | { | 547 | { |
548 | rgbOriginal = TRUE; | 548 | rgbOriginal = TRUE; |
549 | curCol = qRgb( rEd->val(), gEd->val(), bEd->val() ); | 549 | curCol = qRgb( rEd->val(), gEd->val(), bEd->val() ); |
550 | rgb2hsv(currentColor(), hue, sat, val ); | 550 | rgb2hsv(currentColor(), hue, sat, val ); |
551 | 551 | ||
552 | hEd->setNum( hue ); | 552 | hEd->setNum( hue ); |
553 | sEd->setNum( sat ); | 553 | sEd->setNum( sat ); |
554 | vEd->setNum( val ); | 554 | vEd->setNum( val ); |
555 | 555 | ||
556 | showCurrentColor(); | 556 | showCurrentColor(); |
557 | emit newCol( currentColor() ); | 557 | emit newCol( currentColor() ); |
558 | } | 558 | } |
559 | 559 | ||
560 | void QColorShower::hsvEd() | 560 | void QColorShower::hsvEd() |
561 | { | 561 | { |
562 | rgbOriginal = FALSE; | 562 | rgbOriginal = FALSE; |
563 | hue = hEd->val(); | 563 | hue = hEd->val(); |
564 | sat = sEd->val(); | 564 | sat = sEd->val(); |
565 | val = vEd->val(); | 565 | val = vEd->val(); |
566 | 566 | ||
567 | curCol = QColor( hue, sat, val, QColor::Hsv ).rgb(); | 567 | curCol = QColor( hue, sat, val, QColor::Hsv ).rgb(); |
568 | 568 | ||
569 | rEd->setNum( qRed(currentColor()) ); | 569 | rEd->setNum( qRed(currentColor()) ); |
570 | gEd->setNum( qGreen(currentColor()) ); | 570 | gEd->setNum( qGreen(currentColor()) ); |
571 | bEd->setNum( qBlue(currentColor()) ); | 571 | bEd->setNum( qBlue(currentColor()) ); |
572 | 572 | ||
573 | showCurrentColor(); | 573 | showCurrentColor(); |
574 | emit newCol( currentColor() ); | 574 | emit newCol( currentColor() ); |