summaryrefslogtreecommitdiff
path: root/libopie/colordialog.cpp
Unidiff
Diffstat (limited to 'libopie/colordialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/colordialog.cpp56
1 files changed, 28 insertions, 28 deletions
diff --git a/libopie/colordialog.cpp b/libopie/colordialog.cpp
index 6d72ff6..684d6ea 100644
--- a/libopie/colordialog.cpp
+++ b/libopie/colordialog.cpp
@@ -1,28 +1,28 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Implementation of QColorDialog class 4** Implementation of OColorDialog class
5** 5**
6** Created : 990222 6** Created : 990222
7** 7**
8** Copyright (C) 1999-2000 Trolltech AS. All rights reserved. 8** Copyright (C) 1999-2000 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the dialogs module of the Qt GUI Toolkit. 10** This file is part of the dialogs module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 23** Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
@@ -455,91 +455,91 @@ void QColorShowLabel::mouseReleaseEvent( QMouseEvent * )
455 if ( !mousePressed ) 455 if ( !mousePressed )
456 return; 456 return;
457 mousePressed = FALSE; 457 mousePressed = FALSE;
458} 458}
459 459
460QColorShower::QColorShower( QWidget *parent, const char *name ) 460QColorShower::QColorShower( QWidget *parent, const char *name )
461 :QWidget( parent, name) 461 :QWidget( parent, name)
462{ 462{
463 curCol = qRgb( -1, -1, -1 ); 463 curCol = qRgb( -1, -1, -1 );
464 QColIntValidator *val256 = new QColIntValidator( 0, 255, this ); 464 QColIntValidator *val256 = new QColIntValidator( 0, 255, this );
465 QColIntValidator *val360 = new QColIntValidator( 0, 360, this ); 465 QColIntValidator *val360 = new QColIntValidator( 0, 360, this );
466 466
467 QGridLayout *gl = new QGridLayout( this, 1, 1, 2 ); 467 QGridLayout *gl = new QGridLayout( this, 1, 1, 2 );
468 gl->setMargin( 0 ); 468 gl->setMargin( 0 );
469 lab = new QColorShowLabel( this ); 469 lab = new QColorShowLabel( this );
470 lab->setMinimumWidth( 60 ); //### 470 lab->setMinimumWidth( 60 ); //###
471 gl->addMultiCellWidget(lab, 0,-1,0,0); 471 gl->addMultiCellWidget(lab, 0,-1,0,0);
472 connect( lab, SIGNAL( colorDropped( QRgb ) ), 472 connect( lab, SIGNAL( colorDropped( QRgb ) ),
473 this, SIGNAL( newCol( QRgb ) ) ); 473 this, SIGNAL( newCol( QRgb ) ) );
474 connect( lab, SIGNAL( colorDropped( QRgb ) ), 474 connect( lab, SIGNAL( colorDropped( QRgb ) ),
475 this, SLOT( setRgb( QRgb ) ) ); 475 this, SLOT( setRgb( QRgb ) ) );
476 476
477 hEd = new QColNumLineEdit( this ); 477 hEd = new QColNumLineEdit( this );
478 hEd->setValidator( val360 ); 478 hEd->setValidator( val360 );
479 QLabel *l = new QLabel( hEd, QColorDialog::tr("Hue:"), this ); 479 QLabel *l = new QLabel( hEd, OColorDialog::tr("Hue:"), this );
480 l->setAlignment( AlignRight|AlignVCenter ); 480 l->setAlignment( AlignRight|AlignVCenter );
481 gl->addWidget( l, 0, 1 ); 481 gl->addWidget( l, 0, 1 );
482 gl->addWidget( hEd, 0, 2 ); 482 gl->addWidget( hEd, 0, 2 );
483 483
484 sEd = new QColNumLineEdit( this ); 484 sEd = new QColNumLineEdit( this );
485 sEd->setValidator( val256 ); 485 sEd->setValidator( val256 );
486 l = new QLabel( sEd, QColorDialog::tr("Sat:"), this ); 486 l = new QLabel( sEd, OColorDialog::tr("Sat:"), this );
487 l->setAlignment( AlignRight|AlignVCenter ); 487 l->setAlignment( AlignRight|AlignVCenter );
488 gl->addWidget( l, 1, 1 ); 488 gl->addWidget( l, 1, 1 );
489 gl->addWidget( sEd, 1, 2 ); 489 gl->addWidget( sEd, 1, 2 );
490 490
491 vEd = new QColNumLineEdit( this ); 491 vEd = new QColNumLineEdit( this );
492 vEd->setValidator( val256 ); 492 vEd->setValidator( val256 );
493 l = new QLabel( vEd, QColorDialog::tr("Val:"), this ); 493 l = new QLabel( vEd, OColorDialog::tr("Val:"), this );
494 l->setAlignment( AlignRight|AlignVCenter ); 494 l->setAlignment( AlignRight|AlignVCenter );
495 gl->addWidget( l, 2, 1 ); 495 gl->addWidget( l, 2, 1 );
496 gl->addWidget( vEd, 2, 2 ); 496 gl->addWidget( vEd, 2, 2 );
497 497
498 rEd = new QColNumLineEdit( this ); 498 rEd = new QColNumLineEdit( this );
499 rEd->setValidator( val256 ); 499 rEd->setValidator( val256 );
500 l = new QLabel( rEd, QColorDialog::tr("Red:"), this ); 500 l = new QLabel( rEd, OColorDialog::tr("Red:"), this );
501 l->setAlignment( AlignRight|AlignVCenter ); 501 l->setAlignment( AlignRight|AlignVCenter );
502 gl->addWidget( l, 0, 3 ); 502 gl->addWidget( l, 0, 3 );
503 gl->addWidget( rEd, 0, 4 ); 503 gl->addWidget( rEd, 0, 4 );
504 504
505 gEd = new QColNumLineEdit( this ); 505 gEd = new QColNumLineEdit( this );
506 gEd->setValidator( val256 ); 506 gEd->setValidator( val256 );
507 l = new QLabel( gEd, QColorDialog::tr("Green:"), this ); 507 l = new QLabel( gEd, OColorDialog::tr("Green:"), this );
508 l->setAlignment( AlignRight|AlignVCenter ); 508 l->setAlignment( AlignRight|AlignVCenter );
509 gl->addWidget( l, 1, 3 ); 509 gl->addWidget( l, 1, 3 );
510 gl->addWidget( gEd, 1, 4 ); 510 gl->addWidget( gEd, 1, 4 );
511 511
512 bEd = new QColNumLineEdit( this ); 512 bEd = new QColNumLineEdit( this );
513 bEd->setValidator( val256 ); 513 bEd->setValidator( val256 );
514 l = new QLabel( bEd, QColorDialog::tr("Blue:"), this ); 514 l = new QLabel( bEd, OColorDialog::tr("Blue:"), this );
515 l->setAlignment( AlignRight|AlignVCenter ); 515 l->setAlignment( AlignRight|AlignVCenter );
516 gl->addWidget( l, 2, 3 ); 516 gl->addWidget( l, 2, 3 );
517 gl->addWidget( bEd, 2, 4 ); 517 gl->addWidget( bEd, 2, 4 );
518 518
519 alphaEd = new QColNumLineEdit( this ); 519 alphaEd = new QColNumLineEdit( this );
520 alphaEd->setValidator( val256 ); 520 alphaEd->setValidator( val256 );
521 alphaLab = new QLabel( alphaEd, QColorDialog::tr("Alpha channel:"), this ); 521 alphaLab = new QLabel( alphaEd, OColorDialog::tr("Alpha channel:"), this );
522 alphaLab->setAlignment( AlignRight|AlignVCenter ); 522 alphaLab->setAlignment( AlignRight|AlignVCenter );
523 gl->addMultiCellWidget( alphaLab, 3, 3, 1, 3 ); 523 gl->addMultiCellWidget( alphaLab, 3, 3, 1, 3 );
524 gl->addWidget( alphaEd, 3, 4 ); 524 gl->addWidget( alphaEd, 3, 4 );
525 alphaEd->hide(); 525 alphaEd->hide();
526 alphaLab->hide(); 526 alphaLab->hide();
527 527
528 connect( hEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) ); 528 connect( hEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) );
529 connect( sEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) ); 529 connect( sEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) );
530 connect( vEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) ); 530 connect( vEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) );
531 531
532 connect( rEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) ); 532 connect( rEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) );
533 connect( gEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) ); 533 connect( gEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) );
534 connect( bEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) ); 534 connect( bEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) );
535} 535}
536 536
537void QColorShower::showCurrentColor() 537void QColorShower::showCurrentColor()
538{ 538{
539 lab->setColor( currentColor() ); 539 lab->setColor( currentColor() );
540 lab->repaint(FALSE); //### 540 lab->repaint(FALSE); //###
541} 541}
542 542
543void QColorShower::rgbEd() 543void QColorShower::rgbEd()
544{ 544{
545 rgbOriginal = TRUE; 545 rgbOriginal = TRUE;
@@ -586,266 +586,266 @@ void QColorShower::setRgb( QRgb rgb )
586 gEd->setNum( qGreen(currentColor()) ); 586 gEd->setNum( qGreen(currentColor()) );
587 bEd->setNum( qBlue(currentColor()) ); 587 bEd->setNum( qBlue(currentColor()) );
588 588
589 showCurrentColor(); 589 showCurrentColor();
590} 590}
591 591
592void QColorShower::setHsv( int h, int s, int v ) 592void QColorShower::setHsv( int h, int s, int v )
593{ 593{
594 rgbOriginal = FALSE; 594 rgbOriginal = FALSE;
595 hue = h; val = v; sat = s; //Range check### 595 hue = h; val = v; sat = s; //Range check###
596 curCol = QColor( hue, sat, val, QColor::Hsv ).rgb(); 596 curCol = QColor( hue, sat, val, QColor::Hsv ).rgb();
597 597
598 hEd->setNum( hue ); 598 hEd->setNum( hue );
599 sEd->setNum( sat ); 599 sEd->setNum( sat );
600 vEd->setNum( val ); 600 vEd->setNum( val );
601 601
602 rEd->setNum( qRed(currentColor()) ); 602 rEd->setNum( qRed(currentColor()) );
603 gEd->setNum( qGreen(currentColor()) ); 603 gEd->setNum( qGreen(currentColor()) );
604 bEd->setNum( qBlue(currentColor()) ); 604 bEd->setNum( qBlue(currentColor()) );
605 605
606 606
607 showCurrentColor(); 607 showCurrentColor();
608} 608}
609 609
610class QColorDialogPrivate : public QObject 610class OColorDialogPrivate : public QObject
611{ 611{
612Q_OBJECT 612Q_OBJECT
613public: 613public:
614 QColorDialogPrivate( QColorDialog *p ); 614 OColorDialogPrivate( OColorDialog *p );
615 QRgb currentColor() const { return cs->currentColor(); } 615 QRgb currentColor() const { return cs->currentColor(); }
616 void setCurrentColor( QRgb rgb ); 616 void setCurrentColor( QRgb rgb );
617 617
618 int currentAlpha() const { return cs->currentAlpha(); } 618 int currentAlpha() const { return cs->currentAlpha(); }
619 void setCurrentAlpha( int a ) { cs->setCurrentAlpha( a ); } 619 void setCurrentAlpha( int a ) { cs->setCurrentAlpha( a ); }
620 void showAlpha( bool b ) { cs->showAlpha( b ); } 620 void showAlpha( bool b ) { cs->showAlpha( b ); }
621 621
622private slots: 622private slots:
623 void newHsv( int h, int s, int v ); 623 void newHsv( int h, int s, int v );
624 void newColorTypedIn( QRgb rgb ); 624 void newColorTypedIn( QRgb rgb );
625private: 625private:
626 QColorPicker *cp; 626 QColorPicker *cp;
627 QColorLuminancePicker *lp; 627 QColorLuminancePicker *lp;
628 QColorShower *cs; 628 QColorShower *cs;
629}; 629};
630 630
631//sets all widgets to display h,s,v 631//sets all widgets to display h,s,v
632void QColorDialogPrivate::newHsv( int h, int s, int v ) 632void OColorDialogPrivate::newHsv( int h, int s, int v )
633{ 633{
634 cs->setHsv( h, s, v ); 634 cs->setHsv( h, s, v );
635 cp->setCol( h, s ); 635 cp->setCol( h, s );
636 lp->setCol( h, s, v ); 636 lp->setCol( h, s, v );
637} 637}
638 638
639//sets all widgets to display rgb 639//sets all widgets to display rgb
640void QColorDialogPrivate::setCurrentColor( QRgb rgb ) 640void OColorDialogPrivate::setCurrentColor( QRgb rgb )
641{ 641{
642 cs->setRgb( rgb ); 642 cs->setRgb( rgb );
643 newColorTypedIn( rgb ); 643 newColorTypedIn( rgb );
644} 644}
645 645
646//sets all widgets exept cs to display rgb 646//sets all widgets exept cs to display rgb
647void QColorDialogPrivate::newColorTypedIn( QRgb rgb ) 647void OColorDialogPrivate::newColorTypedIn( QRgb rgb )
648{ 648{
649 int h, s, v; 649 int h, s, v;
650 rgb2hsv(rgb, h, s, v ); 650 rgb2hsv(rgb, h, s, v );
651 cp->setCol( h, s ); 651 cp->setCol( h, s );
652 lp->setCol( h, s, v); 652 lp->setCol( h, s, v);
653} 653}
654 654
655QColorDialogPrivate::QColorDialogPrivate( QColorDialog *dialog ) : 655OColorDialogPrivate::OColorDialogPrivate( OColorDialog *dialog ) :
656 QObject(dialog) 656 QObject(dialog)
657{ 657{
658 int border = 2; 658 int border = 2;
659 QVBoxLayout *topLay = new QVBoxLayout( dialog, border, 2 ); 659 QVBoxLayout *topLay = new QVBoxLayout( dialog, border, 2 );
660 660
661 QHBoxLayout *pickLay = new QHBoxLayout( topLay ); 661 QHBoxLayout *pickLay = new QHBoxLayout( topLay );
662 662
663 663
664 cp = new QColorPicker( dialog ); 664 cp = new QColorPicker( dialog );
665 cp->setFrameStyle( QFrame::Panel + QFrame::Sunken ); 665 cp->setFrameStyle( QFrame::Panel + QFrame::Sunken );
666 pickLay->addWidget( cp ); 666 pickLay->addWidget( cp );
667 667
668 pickLay->addStretch(); 668 pickLay->addStretch();
669 669
670 lp = new QColorLuminancePicker( dialog ); 670 lp = new QColorLuminancePicker( dialog );
671 lp->setFixedWidth( 20 ); //### 671 lp->setFixedWidth( 20 ); //###
672 pickLay->addWidget( lp ); 672 pickLay->addWidget( lp );
673 673
674 connect( cp, SIGNAL(newCol(int,int)), lp, SLOT(setCol(int,int)) ); 674 connect( cp, SIGNAL(newCol(int,int)), lp, SLOT(setCol(int,int)) );
675 connect( lp, SIGNAL(newHsv(int,int,int)), this, SLOT(newHsv(int,int,int)) ); 675 connect( lp, SIGNAL(newHsv(int,int,int)), this, SLOT(newHsv(int,int,int)) );
676 676
677 topLay->addStretch(); 677 topLay->addStretch();
678 678
679 cs = new QColorShower( dialog ); 679 cs = new QColorShower( dialog );
680 connect( cs, SIGNAL(newCol(QRgb)), this, SLOT(newColorTypedIn(QRgb))); 680 connect( cs, SIGNAL(newCol(QRgb)), this, SLOT(newColorTypedIn(QRgb)));
681 topLay->addWidget( cs ); 681 topLay->addWidget( cs );
682 682
683} 683}
684 684
685 685
686// BEING REVISED: jo 686// BEING REVISED: jo
687/*! 687/*!
688 \class QColorDialog qcolordialog.h 688 \class OColorDialog OColorDialog.h
689 \brief The QColorDialog class provides a dialog widget for specifying colors. 689 \brief The OColorDialog class provides a dialog widget for specifying colors.
690 \ingroup dialogs 690 \ingroup dialogs
691 691
692 The color dialog's function is to allow users to choose colors - 692 The color dialog's function is to allow users to choose colors -
693 for instance, you might use this in a drawing program to allow the 693 for instance, you might use this in a drawing program to allow the
694 user to set the brush color. 694 user to set the brush color.
695 695
696 This version of Qt only provides modal color dialogs. The static 696 This version of Qt only provides modal color dialogs. The static
697 getColor() function shows the dialog and allows the user to specify a color, 697 getColor() function shows the dialog and allows the user to specify a color,
698 while getRgba() does the same but allows the user to specify a color with an 698 while getRgba() does the same but allows the user to specify a color with an
699 alpha channel (transparency) value. 699 alpha channel (transparency) value.
700 700
701 The user can store customCount() different custom colors. The custom 701 The user can store customCount() different custom colors. The custom
702 colors are shared by all color dialogs, and remembered during the 702 colors are shared by all color dialogs, and remembered during the
703 execution of the program. Use setCustomColor() to set the 703 execution of the program. Use setCustomColor() to set the
704 custom colors, and customColor() to get them. 704 custom colors, and customColor() to get them.
705 705
706 <img src=qcolordlg-m.png> <img src=qcolordlg-w.png> 706 <img src=qcolordlg-m.png> <img src=qcolordlg-w.png>
707*/ 707*/
708 708
709/*! 709/*!
710 Constructs a default color dialog. Use setColor() for setting an initial value. 710 Constructs a default color dialog. Use setColor() for setting an initial value.
711 711
712 \sa getColor() 712 \sa getColor()
713*/ 713*/
714 714
715QColorDialog::QColorDialog(QWidget* parent, const char* name, bool modal) : 715OColorDialog::OColorDialog(QWidget* parent, const char* name, bool modal) :
716 QDialog(parent, name, modal ) 716 QDialog(parent, name, modal )
717{ 717{
718 d = new QColorDialogPrivate( this ); 718 d = new OColorDialogPrivate( this );
719} 719}
720 720
721 721
722/*! 722/*!
723 Pops up a modal color dialog letting the user choose a color and returns 723 Pops up a modal color dialog letting the user choose a color and returns
724 that color. The color is initially set to \a initial. Returns an \link QColor::isValid() invalid\endlink color if the user cancels 724 that color. The color is initially set to \a initial. Returns an \link QColor::isValid() invalid\endlink color if the user cancels
725 the dialog. All colors allocated by the dialog will be deallocated 725 the dialog. All colors allocated by the dialog will be deallocated
726 before this function returns. 726 before this function returns.
727*/ 727*/
728 728
729QColor QColorDialog::getColor( QColor initial, QWidget *parent, 729QColor OColorDialog::getColor( QColor initial, QWidget *parent,
730 const char *name ) 730 const char *name )
731{ 731{
732 int allocContext = QColor::enterAllocContext(); 732 int allocContext = QColor::enterAllocContext();
733 QColorDialog *dlg = new QColorDialog( parent, name, TRUE ); //modal 733 OColorDialog *dlg = new OColorDialog( parent, name, TRUE ); //modal
734 if ( parent && parent->icon() && !parent->icon()->isNull() ) 734 if ( parent && parent->icon() && !parent->icon()->isNull() )
735 dlg->setIcon( *parent->icon() ); 735 dlg->setIcon( *parent->icon() );
736 else if ( qApp->mainWidget() && qApp->mainWidget()->icon() && !qApp->mainWidget()->icon()->isNull() ) 736 else if ( qApp->mainWidget() && qApp->mainWidget()->icon() && !qApp->mainWidget()->icon()->isNull() )
737 dlg->setIcon( *qApp->mainWidget()->icon() ); 737 dlg->setIcon( *qApp->mainWidget()->icon() );
738 738
739 dlg->setCaption( QColorDialog::tr( "Select color" ) ); 739 dlg->setCaption( OColorDialog::tr( "Select color" ) );
740 dlg->setColor( initial ); 740 dlg->setColor( initial );
741 dlg->showMaximized(); 741 dlg->showMaximized();
742 int resultCode = dlg->exec(); 742 int resultCode = dlg->exec();
743 QColor::leaveAllocContext(); 743 QColor::leaveAllocContext();
744 QColor result; 744 QColor result;
745 if ( resultCode == QDialog::Accepted ) { 745 if ( resultCode == QDialog::Accepted ) {
746 result = dlg->color(); 746 result = dlg->color();
747 } else { 747 } else {
748 result = initial; 748 result = initial;
749 } 749 }
750 QColor::destroyAllocContext(allocContext); 750 QColor::destroyAllocContext(allocContext);
751 delete dlg; 751 delete dlg;
752 return result; 752 return result;
753} 753}
754 754
755 755
756/*! 756/*!
757 Pops up a modal color dialog, letting the user choose a color and an 757 Pops up a modal color dialog, letting the user choose a color and an
758 alpha channel value. The color+alpha is initially set to \a initial. 758 alpha channel value. The color+alpha is initially set to \a initial.
759 759
760 If \a ok is non-null, \c *ok is set to TRUE if the user clicked OK, 760 If \a ok is non-null, \c *ok is set to TRUE if the user clicked OK,
761 and FALSE if the user clicked Cancel. 761 and FALSE if the user clicked Cancel.
762 762
763 If the user clicks Cancel the \a initial value is returned. 763 If the user clicks Cancel the \a initial value is returned.
764*/ 764*/
765 765
766QRgb QColorDialog::getRgba( QRgb initial, bool *ok, 766QRgb OColorDialog::getRgba( QRgb initial, bool *ok,
767 QWidget *parent, const char* name ) 767 QWidget *parent, const char* name )
768{ 768{
769 int allocContext = QColor::enterAllocContext(); 769 int allocContext = QColor::enterAllocContext();
770 QColorDialog *dlg = new QColorDialog( parent, name, TRUE ); //modal 770 OColorDialog *dlg = new OColorDialog( parent, name, TRUE ); //modal
771 dlg->setColor( initial ); 771 dlg->setColor( initial );
772 dlg->setSelectedAlpha( qAlpha(initial) ); 772 dlg->setSelectedAlpha( qAlpha(initial) );
773 dlg->showMaximized(); 773 dlg->showMaximized();
774 int resultCode = dlg->exec(); 774 int resultCode = dlg->exec();
775 QColor::leaveAllocContext(); 775 QColor::leaveAllocContext();
776 QRgb result = initial; 776 QRgb result = initial;
777 if ( resultCode == QDialog::Accepted ) { 777 if ( resultCode == QDialog::Accepted ) {
778 QRgb c = dlg->color().rgb(); 778 QRgb c = dlg->color().rgb();
779 int alpha = dlg->selectedAlpha(); 779 int alpha = dlg->selectedAlpha();
780 result = qRgba( qRed(c), qGreen(c), qBlue(c), alpha ); 780 result = qRgba( qRed(c), qGreen(c), qBlue(c), alpha );
781 } 781 }
782 if ( ok ) 782 if ( ok )
783 *ok = resultCode == QDialog::Accepted; 783 *ok = resultCode == QDialog::Accepted;
784 784
785 QColor::destroyAllocContext(allocContext); 785 QColor::destroyAllocContext(allocContext);
786 delete dlg; 786 delete dlg;
787 return result; 787 return result;
788} 788}
789 789
790 790
791 791
792 792
793 793
794/*! 794/*!
795 Returns the color currently selected in the dialog. 795 Returns the color currently selected in the dialog.
796 796
797 \sa setColor() 797 \sa setColor()
798*/ 798*/
799 799
800QColor QColorDialog::color() const 800QColor OColorDialog::color() const
801{ 801{
802 return QColor(d->currentColor()); 802 return QColor(d->currentColor());
803} 803}
804 804
805 805
806/*! Destructs the dialog and frees any memory it allocated. 806/*! Destructs the dialog and frees any memory it allocated.
807 807
808*/ 808*/
809 809
810QColorDialog::~QColorDialog() 810OColorDialog::~OColorDialog()
811{ 811{
812 //d inherits QObject, so it is deleted by Qt. 812 //d inherits QObject, so it is deleted by Qt.
813} 813}
814 814
815 815
816/*! 816/*!
817 Sets the color shown in the dialog to \a c. 817 Sets the color shown in the dialog to \a c.
818 818
819 \sa color() 819 \sa color()
820*/ 820*/
821 821
822void QColorDialog::setColor( QColor c ) 822void OColorDialog::setColor( QColor c )
823{ 823{
824 d->setCurrentColor( c.rgb() ); 824 d->setCurrentColor( c.rgb() );
825} 825}
826 826
827 827
828 828
829 829
830/*! 830/*!
831 Sets the initial alpha channel value to \a a, and show the alpha channel 831 Sets the initial alpha channel value to \a a, and show the alpha channel
832 entry box. 832 entry box.
833*/ 833*/
834 834
835void QColorDialog::setSelectedAlpha( int a ) 835void OColorDialog::setSelectedAlpha( int a )
836{ 836{
837 d->showAlpha( TRUE ); 837 d->showAlpha( TRUE );
838 d->setCurrentAlpha( a ); 838 d->setCurrentAlpha( a );
839} 839}
840 840
841 841
842/*! 842/*!
843 Returns the value selected for the alpha channel. 843 Returns the value selected for the alpha channel.
844*/ 844*/
845 845
846int QColorDialog::selectedAlpha() const 846int OColorDialog::selectedAlpha() const
847{ 847{
848 return d->currentAlpha(); 848 return d->currentAlpha();
849} 849}
850 850
851#include "colordialog.moc" 851#include "colordialog.moc"