summaryrefslogtreecommitdiff
authorzecke <zecke>2004-09-10 11:07:29 (UTC)
committer zecke <zecke>2004-09-10 11:07:29 (UTC)
commit0c2d61cebde30e1a6eea86beb5b28a3600de0f75 (patch) (unidiff)
tree1b1e4b2fc09f92c08254a285d3a89d82b9174cb9
parent00b7879d0d886b642b1f1102e3a811e67f928df7 (diff)
downloadopie-0c2d61cebde30e1a6eea86beb5b28a3600de0f75.zip
opie-0c2d61cebde30e1a6eea86beb5b28a3600de0f75.tar.gz
opie-0c2d61cebde30e1a6eea86beb5b28a3600de0f75.tar.bz2
No unused parameters, added a newline at the end
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libqtaux/qcolordialog.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/libqtaux/qcolordialog.cpp b/libqtaux/qcolordialog.cpp
index ccef0ad..830fef6 100644
--- a/libqtaux/qcolordialog.cpp
+++ b/libqtaux/qcolordialog.cpp
@@ -447,208 +447,208 @@ QBrush QWellArray::cellBrush( int row, int col )
447void QWellArray::focusOutEvent( QFocusEvent* ) 447void QWellArray::focusOutEvent( QFocusEvent* )
448{ 448{
449 updateCell( curRow, curCol ); 449 updateCell( curRow, curCol );
450} 450}
451 451
452/*\reimp 452/*\reimp
453*/ 453*/
454void QWellArray::keyPressEvent( QKeyEvent* e ) 454void QWellArray::keyPressEvent( QKeyEvent* e )
455{ 455{
456 switch( e->key() ) { // Look at the key code 456 switch( e->key() ) { // Look at the key code
457 case Key_Left: // If 'left arrow'-key, 457 case Key_Left: // If 'left arrow'-key,
458 if( curCol > 0 ) { // and cr't not in leftmost col 458 if( curCol > 0 ) { // and cr't not in leftmost col
459 setCurrent( curRow, curCol - 1);// set cr't to next left column 459 setCurrent( curRow, curCol - 1);// set cr't to next left column
460 int edge = leftCell(); // find left edge 460 int edge = leftCell(); // find left edge
461 if ( curCol < edge ) // if we have moved off edge, 461 if ( curCol < edge ) // if we have moved off edge,
462 setLeftCell( edge - 1 );// scroll view to rectify 462 setLeftCell( edge - 1 );// scroll view to rectify
463 } 463 }
464 break; 464 break;
465 case Key_Right: // Correspondingly... 465 case Key_Right: // Correspondingly...
466 if( curCol < numCols()-1 ) { 466 if( curCol < numCols()-1 ) {
467 setCurrent( curRow, curCol + 1); 467 setCurrent( curRow, curCol + 1);
468 int edge = lastColVisible(); 468 int edge = lastColVisible();
469 if ( curCol >= edge ) 469 if ( curCol >= edge )
470 setLeftCell( leftCell() + 1 ); 470 setLeftCell( leftCell() + 1 );
471 } 471 }
472 break; 472 break;
473 case Key_Up: 473 case Key_Up:
474 if( curRow > 0 ) { 474 if( curRow > 0 ) {
475 setCurrent( curRow - 1, curCol); 475 setCurrent( curRow - 1, curCol);
476 int edge = topCell(); 476 int edge = topCell();
477 if ( curRow < edge ) 477 if ( curRow < edge )
478 setTopCell( edge - 1 ); 478 setTopCell( edge - 1 );
479 } else if ( smallStyle ) 479 } else if ( smallStyle )
480 focusNextPrevChild( FALSE ); 480 focusNextPrevChild( FALSE );
481 break; 481 break;
482 case Key_Down: 482 case Key_Down:
483 if( curRow < numRows()-1 ) { 483 if( curRow < numRows()-1 ) {
484 setCurrent( curRow + 1, curCol); 484 setCurrent( curRow + 1, curCol);
485 int edge = lastRowVisible(); 485 int edge = lastRowVisible();
486 if ( curRow >= edge ) 486 if ( curRow >= edge )
487 setTopCell( topCell() + 1 ); 487 setTopCell( topCell() + 1 );
488 } else if ( smallStyle ) 488 } else if ( smallStyle )
489 focusNextPrevChild( TRUE ); 489 focusNextPrevChild( TRUE );
490 break; 490 break;
491 case Key_Space: 491 case Key_Space:
492 case Key_Return: 492 case Key_Return:
493 case Key_Enter: 493 case Key_Enter:
494 setSelected( curRow, curCol ); 494 setSelected( curRow, curCol );
495 break; 495 break;
496 default: // If not an interesting key, 496 default: // If not an interesting key,
497 e->ignore(); // we don't accept the event 497 e->ignore(); // we don't accept the event
498 return; 498 return;
499 } 499 }
500 500
501} 501}
502 502
503//////////// QWellArray END 503//////////// QWellArray END
504 504
505static bool initrgb = FALSE; 505static bool initrgb = FALSE;
506static QRgb stdrgb[6*8]; 506static QRgb stdrgb[6*8];
507static QRgb cusrgb[2*8]; 507static QRgb cusrgb[2*8];
508 508
509 509
510static void initRGB() 510static void initRGB()
511{ 511{
512 if ( initrgb ) 512 if ( initrgb )
513 return; 513 return;
514 initrgb = TRUE; 514 initrgb = TRUE;
515 int i = 0; 515 int i = 0;
516 for ( int g = 0; g < 4; g++ ) 516 for ( int g = 0; g < 4; g++ )
517 for ( int r = 0; r < 4; r++ ) 517 for ( int r = 0; r < 4; r++ )
518 for ( int b = 0; b < 3; b++ ) 518 for ( int b = 0; b < 3; b++ )
519 stdrgb[i++] = qRgb( r*255/3, g*255/3, b*255/2 ); 519 stdrgb[i++] = qRgb( r*255/3, g*255/3, b*255/2 );
520 520
521 for ( i = 0; i < 2*8; i++ ) 521 for ( i = 0; i < 2*8; i++ )
522 cusrgb[i] = qRgb(0xff,0xff,0xff); 522 cusrgb[i] = qRgb(0xff,0xff,0xff);
523} 523}
524 524
525/*! 525/*!
526 Returns the number of custom colors supported by 526 Returns the number of custom colors supported by
527 QColorDialog. All color dialogs share the same custom colors. 527 QColorDialog. All color dialogs share the same custom colors.
528*/ 528*/
529int QColorDialog::customCount() 529int QColorDialog::customCount()
530{ 530{
531 return 2*8; 531 return 2*8;
532} 532}
533 533
534/*! 534/*!
535 Returns custom color number \a i as a QRgb. 535 Returns custom color number \a i as a QRgb.
536 */ 536 */
537QRgb QColorDialog::customColor( int i ) 537QRgb QColorDialog::customColor( int i )
538{ 538{
539 initRGB(); 539 initRGB();
540 if ( i < 0 || i >= customCount() ) { 540 if ( i < 0 || i >= customCount() ) {
541#ifdef CHECK_RANGE 541#ifdef CHECK_RANGE
542 qWarning( "QColorDialog::customColor() index %d out of range", i ); 542 qWarning( "QColorDialog::customColor() index %d out of range", i );
543 #endif 543#endif
544 i = 0; 544 i = 0;
545 } 545 }
546 return cusrgb[i]; 546 return cusrgb[i];
547} 547}
548 548
549/*! 549/*!
550 Sets custom color number \a i to the QRgb value \a c. 550 Sets custom color number \a i to the QRgb value \a c.
551*/ 551*/
552void QColorDialog::setCustomColor( int i, QRgb c ) 552void QColorDialog::setCustomColor( int i, QRgb c )
553{ 553{
554 initRGB(); 554 initRGB();
555 if ( i < 0 || i >= customCount() ) { 555 if ( i < 0 || i >= customCount() ) {
556#ifdef CHECK_RANGE 556#ifdef CHECK_RANGE
557 qWarning( "QColorDialog::customColor() index %d out of range", i ); 557 qWarning( "QColorDialog::customColor() index %d out of range", i );
558 #endif 558#endif
559 return; 559 return;
560 } 560 }
561 cusrgb[i] = c; 561 cusrgb[i] = c;
562} 562}
563 563
564static inline void rgb2hsv( QRgb rgb, int&h, int&s, int&v ) 564static inline void rgb2hsv( QRgb rgb, int&h, int&s, int&v )
565{ 565{
566 QColor c; 566 QColor c;
567 c.setRgb( rgb ); 567 c.setRgb( rgb );
568 c.getHsv(h,s,v); 568 c.getHsv(h,s,v);
569} 569}
570 570
571class QColorWell : public QWellArray 571class QColorWell : public QWellArray
572{ 572{
573public: 573public:
574 QColorWell( QWidget *parent, int r, int c, QRgb *vals ) 574 QColorWell( QWidget *parent, int r, int c, QRgb *vals )
575 :QWellArray( parent, "" ), values( vals ), mousePressed( FALSE ), oldCurrent( -1, -1 ) 575 :QWellArray( parent, "" ), values( vals ), mousePressed( FALSE ), oldCurrent( -1, -1 )
576 { setDimension(r,c); setWFlags( WResizeNoErase ); } 576 { setDimension(r,c); setWFlags( WResizeNoErase ); }
577 QSizePolicy sizePolicy() const; 577 QSizePolicy sizePolicy() const;
578 578
579protected: 579protected:
580 void drawContents( QPainter *, int row, int col, const QRect& ); 580 void drawContents( QPainter *, int row, int col, const QRect& );
581 void drawContents( QPainter *p ) { QWellArray::drawContents(p); } 581 void drawContents( QPainter *p ) { QWellArray::drawContents(p); }
582 void mousePressEvent( QMouseEvent *e ); 582 void mousePressEvent( QMouseEvent *e );
583 void mouseMoveEvent( QMouseEvent *e ); 583 void mouseMoveEvent( QMouseEvent *e );
584 void mouseReleaseEvent( QMouseEvent *e ); 584 void mouseReleaseEvent( QMouseEvent *e );
585#ifndef QT_NO_DRAGANDDROP 585#ifndef QT_NO_DRAGANDDROP
586 void dragEnterEvent( QDragEnterEvent *e ); 586 void dragEnterEvent( QDragEnterEvent *e );
587 void dragLeaveEvent( QDragLeaveEvent *e ); 587 void dragLeaveEvent( QDragLeaveEvent *e );
588 void dragMoveEvent( QDragMoveEvent *e ); 588 void dragMoveEvent( QDragMoveEvent *e );
589 void dropEvent( QDropEvent *e ); 589 void dropEvent( QDropEvent *e );
590#endif 590#endif
591 591
592private: 592private:
593 QRgb *values; 593 QRgb *values;
594 bool mousePressed; 594 bool mousePressed;
595 QPoint pressPos; 595 QPoint pressPos;
596 QPoint oldCurrent; 596 QPoint oldCurrent;
597 597
598}; 598};
599 599
600QSizePolicy QColorWell::sizePolicy() const 600QSizePolicy QColorWell::sizePolicy() const
601{ 601{
602 return QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); 602 return QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
603} 603}
604 604
605void QColorWell::drawContents( QPainter *p, int row, int col, const QRect &r ) 605void QColorWell::drawContents( QPainter *p, int row, int col, const QRect &r )
606{ 606{
607 int i = row + col*numRows(); 607 int i = row + col*numRows();
608 p->fillRect( r, QColor( values[i] ) ); 608 p->fillRect( r, QColor( values[i] ) );
609} 609}
610 610
611void QColorWell::mousePressEvent( QMouseEvent *e ) 611void QColorWell::mousePressEvent( QMouseEvent *e )
612{ 612{
613 oldCurrent = QPoint( selectedRow(), selectedColumn() ); 613 oldCurrent = QPoint( selectedRow(), selectedColumn() );
614 QWellArray::mousePressEvent( e ); 614 QWellArray::mousePressEvent( e );
615 mousePressed = TRUE; 615 mousePressed = TRUE;
616 pressPos = e->pos(); 616 pressPos = e->pos();
617} 617}
618 618
619void QColorWell::mouseMoveEvent( QMouseEvent *e ) 619void QColorWell::mouseMoveEvent( QMouseEvent *e )
620{ 620{
621 QWellArray::mouseMoveEvent( e ); 621 QWellArray::mouseMoveEvent( e );
622#ifndef QT_NO_DRAGANDDROP 622#ifndef QT_NO_DRAGANDDROP
623 if ( !mousePressed ) 623 if ( !mousePressed )
624 return; 624 return;
625 if ( ( pressPos - e->pos() ).manhattanLength() > QApplication::startDragDistance() ) { 625 if ( ( pressPos - e->pos() ).manhattanLength() > QApplication::startDragDistance() ) {
626 setCurrent( oldCurrent.x(), oldCurrent.y() ); 626 setCurrent( oldCurrent.x(), oldCurrent.y() );
627 int i = findRow( e->y() ) + findCol( e->x() ) * numRows(); 627 int i = findRow( e->y() ) + findCol( e->x() ) * numRows();
628 QColor col( values[ i ] ); 628 QColor col( values[ i ] );
629 QColorDrag *drg = new QColorDrag( col, this ); 629 QColorDrag *drg = new QColorDrag( col, this );
630 QPixmap pix( cellWidth(), cellHeight() ); 630 QPixmap pix( cellWidth(), cellHeight() );
631 pix.fill( col ); 631 pix.fill( col );
632 QPainter p( &pix ); 632 QPainter p( &pix );
633 p.drawRect( 0, 0, pix.width(), pix.height() ); 633 p.drawRect( 0, 0, pix.width(), pix.height() );
634 p.end(); 634 p.end();
635 drg->setPixmap( pix ); 635 drg->setPixmap( pix );
636 mousePressed = FALSE; 636 mousePressed = FALSE;
637 drg->dragCopy(); 637 drg->dragCopy();
638 } 638 }
639#endif 639#endif
640} 640}
641 641
642#ifndef QT_NO_DRAGANDDROP 642#ifndef QT_NO_DRAGANDDROP
643void QColorWell::dragEnterEvent( QDragEnterEvent *e ) 643void QColorWell::dragEnterEvent( QDragEnterEvent *e )
644{ 644{
645 setFocus(); 645 setFocus();
646 if ( QColorDrag::canDecode( e ) ) 646 if ( QColorDrag::canDecode( e ) )
647 e->accept(); 647 e->accept();
648 else 648 else
649 e->ignore(); 649 e->ignore();
650} 650}
651 651
652void QColorWell::dragLeaveEvent( QDragLeaveEvent * ) 652void QColorWell::dragLeaveEvent( QDragLeaveEvent * )
653{ 653{
654 if ( hasFocus() ) 654 if ( hasFocus() )
@@ -1010,192 +1010,194 @@ public:
1010public slots: 1010public slots:
1011 void setRgb( QRgb rgb ); 1011 void setRgb( QRgb rgb );
1012 1012
1013signals: 1013signals:
1014 void newCol( QRgb rgb ); 1014 void newCol( QRgb rgb );
1015private slots: 1015private slots:
1016 void rgbEd(); 1016 void rgbEd();
1017 void hsvEd(); 1017 void hsvEd();
1018private: 1018private:
1019 void showCurrentColor(); 1019 void showCurrentColor();
1020 int hue, sat, val; 1020 int hue, sat, val;
1021 QRgb curCol; 1021 QRgb curCol;
1022 QColNumLineEdit *hEd; 1022 QColNumLineEdit *hEd;
1023 QColNumLineEdit *sEd; 1023 QColNumLineEdit *sEd;
1024 QColNumLineEdit *vEd; 1024 QColNumLineEdit *vEd;
1025 QColNumLineEdit *rEd; 1025 QColNumLineEdit *rEd;
1026 QColNumLineEdit *gEd; 1026 QColNumLineEdit *gEd;
1027 QColNumLineEdit *bEd; 1027 QColNumLineEdit *bEd;
1028 QColNumLineEdit *alphaEd; 1028 QColNumLineEdit *alphaEd;
1029 QLabel *alphaLab; 1029 QLabel *alphaLab;
1030 QColorShowLabel *lab; 1030 QColorShowLabel *lab;
1031 bool rgbOriginal; 1031 bool rgbOriginal;
1032}; 1032};
1033 1033
1034class QColorShowLabel : public QFrame 1034class QColorShowLabel : public QFrame
1035{ 1035{
1036 Q_OBJECT 1036 Q_OBJECT
1037 1037
1038public: 1038public:
1039 QColorShowLabel( QWidget *parent ) :QFrame( parent ) { 1039 QColorShowLabel( QWidget *parent ) :QFrame( parent ) {
1040 setFrameStyle( QFrame::Panel|QFrame::Sunken ); 1040 setFrameStyle( QFrame::Panel|QFrame::Sunken );
1041 setBackgroundMode( PaletteBackground ); 1041 setBackgroundMode( PaletteBackground );
1042 setAcceptDrops( TRUE ); 1042 setAcceptDrops( TRUE );
1043 mousePressed = FALSE; 1043 mousePressed = FALSE;
1044 } 1044 }
1045 void setColor( QColor c ) { col = c; } 1045 void setColor( QColor c ) { col = c; }
1046 1046
1047signals: 1047signals:
1048 void colorDropped( QRgb ); 1048 void colorDropped( QRgb );
1049 1049
1050protected: 1050protected:
1051 void drawContents( QPainter *p ); 1051 void drawContents( QPainter *p );
1052 void mousePressEvent( QMouseEvent *e ); 1052 void mousePressEvent( QMouseEvent *e );
1053 void mouseMoveEvent( QMouseEvent *e ); 1053 void mouseMoveEvent( QMouseEvent *e );
1054 void mouseReleaseEvent( QMouseEvent *e ); 1054 void mouseReleaseEvent( QMouseEvent *e );
1055#ifndef QT_NO_DRAGANDDROP 1055#ifndef QT_NO_DRAGANDDROP
1056 void dragEnterEvent( QDragEnterEvent *e ); 1056 void dragEnterEvent( QDragEnterEvent *e );
1057 void dragLeaveEvent( QDragLeaveEvent *e ); 1057 void dragLeaveEvent( QDragLeaveEvent *e );
1058 void dropEvent( QDropEvent *e ); 1058 void dropEvent( QDropEvent *e );
1059#endif 1059#endif
1060 1060
1061private: 1061private:
1062 QColor col; 1062 QColor col;
1063 bool mousePressed; 1063 bool mousePressed;
1064 QPoint pressPos; 1064 QPoint pressPos;
1065 1065
1066}; 1066};
1067 1067
1068void QColorShowLabel::drawContents( QPainter *p ) 1068void QColorShowLabel::drawContents( QPainter *p )
1069{ 1069{
1070 p->fillRect( contentsRect(), col ); 1070 p->fillRect( contentsRect(), col );
1071} 1071}
1072 1072
1073void QColorShower::showAlpha( bool b ) 1073void QColorShower::showAlpha( bool b )
1074{ 1074{
1075 if ( b ) { 1075 if ( b ) {
1076 alphaLab->show(); 1076 alphaLab->show();
1077 alphaEd->show(); 1077 alphaEd->show();
1078 } else { 1078 } else {
1079 alphaLab->hide(); 1079 alphaLab->hide();
1080 alphaEd->hide(); 1080 alphaEd->hide();
1081 } 1081 }
1082} 1082}
1083 1083
1084void QColorShowLabel::mousePressEvent( QMouseEvent *e ) 1084void QColorShowLabel::mousePressEvent( QMouseEvent *e )
1085{ 1085{
1086 mousePressed = TRUE; 1086 mousePressed = TRUE;
1087 pressPos = e->pos(); 1087 pressPos = e->pos();
1088} 1088}
1089 1089
1090void QColorShowLabel::mouseMoveEvent( QMouseEvent *e ) 1090void QColorShowLabel::mouseMoveEvent( QMouseEvent *e )
1091{ 1091{
1092#ifndef QT_NO_DRAGANDDROP 1092#ifndef QT_NO_DRAGANDDROP
1093 if ( !mousePressed ) 1093 if ( !mousePressed )
1094 return; 1094 return;
1095 if ( ( pressPos - e->pos() ).manhattanLength() > QApplication::startDragDistance() ) { 1095 if ( ( pressPos - e->pos() ).manhattanLength() > QApplication::startDragDistance() ) {
1096 QColorDrag *drg = new QColorDrag( col, this ); 1096 QColorDrag *drg = new QColorDrag( col, this );
1097 QPixmap pix( 30, 20 ); 1097 QPixmap pix( 30, 20 );
1098 pix.fill( col ); 1098 pix.fill( col );
1099 QPainter p( &pix ); 1099 QPainter p( &pix );
1100 p.drawRect( 0, 0, pix.width(), pix.height() ); 1100 p.drawRect( 0, 0, pix.width(), pix.height() );
1101 p.end(); 1101 p.end();
1102 drg->setPixmap( pix ); 1102 drg->setPixmap( pix );
1103 mousePressed = FALSE; 1103 mousePressed = FALSE;
1104 drg->dragCopy(); 1104 drg->dragCopy();
1105 } 1105 }
1106#else
1107 Q_UNUSED( e )
1106#endif 1108#endif
1107} 1109}
1108 1110
1109#ifndef QT_NO_DRAGANDDROP 1111#ifndef QT_NO_DRAGANDDROP
1110void QColorShowLabel::dragEnterEvent( QDragEnterEvent *e ) 1112void QColorShowLabel::dragEnterEvent( QDragEnterEvent *e )
1111{ 1113{
1112 if ( QColorDrag::canDecode( e ) ) 1114 if ( QColorDrag::canDecode( e ) )
1113 e->accept(); 1115 e->accept();
1114 else 1116 else
1115 e->ignore(); 1117 e->ignore();
1116} 1118}
1117 1119
1118void QColorShowLabel::dragLeaveEvent( QDragLeaveEvent * ) 1120void QColorShowLabel::dragLeaveEvent( QDragLeaveEvent * )
1119{ 1121{
1120} 1122}
1121 1123
1122void QColorShowLabel::dropEvent( QDropEvent *e ) 1124void QColorShowLabel::dropEvent( QDropEvent *e )
1123{ 1125{
1124 if ( QColorDrag::canDecode( e ) ) { 1126 if ( QColorDrag::canDecode( e ) ) {
1125 QColorDrag::decode( e, col ); 1127 QColorDrag::decode( e, col );
1126 repaint( FALSE ); 1128 repaint( FALSE );
1127 emit colorDropped( col.rgb() ); 1129 emit colorDropped( col.rgb() );
1128 e->accept(); 1130 e->accept();
1129 } else { 1131 } else {
1130 e->ignore(); 1132 e->ignore();
1131 } 1133 }
1132} 1134}
1133#endif // QT_NO_DRAGANDDROP 1135#endif // QT_NO_DRAGANDDROP
1134 1136
1135void QColorShowLabel::mouseReleaseEvent( QMouseEvent * ) 1137void QColorShowLabel::mouseReleaseEvent( QMouseEvent * )
1136{ 1138{
1137 if ( !mousePressed ) 1139 if ( !mousePressed )
1138 return; 1140 return;
1139 mousePressed = FALSE; 1141 mousePressed = FALSE;
1140} 1142}
1141 1143
1142QColorShower::QColorShower( QWidget *parent, const char *name ) 1144QColorShower::QColorShower( QWidget *parent, const char *name )
1143 :QWidget( parent, name) 1145 :QWidget( parent, name)
1144{ 1146{
1145 curCol = qRgb( -1, -1, -1 ); 1147 curCol = qRgb( -1, -1, -1 );
1146 QColIntValidator *val256 = new QColIntValidator( 0, 255, this ); 1148 QColIntValidator *val256 = new QColIntValidator( 0, 255, this );
1147 QColIntValidator *val360 = new QColIntValidator( 0, 360, this ); 1149 QColIntValidator *val360 = new QColIntValidator( 0, 360, this );
1148 1150
1149 QGridLayout *gl = new QGridLayout( this, 1, 1, 6 ); 1151 QGridLayout *gl = new QGridLayout( this, 1, 1, 6 );
1150 lab = new QColorShowLabel( this ); 1152 lab = new QColorShowLabel( this );
1151 lab->setMinimumWidth( 60 ); //### 1153 lab->setMinimumWidth( 60 ); //###
1152 gl->addMultiCellWidget(lab, 0,-1,0,0); 1154 gl->addMultiCellWidget(lab, 0,-1,0,0);
1153 connect( lab, SIGNAL( colorDropped(QRgb) ), 1155 connect( lab, SIGNAL( colorDropped(QRgb) ),
1154 this, SIGNAL( newCol(QRgb) ) ); 1156 this, SIGNAL( newCol(QRgb) ) );
1155 connect( lab, SIGNAL( colorDropped(QRgb) ), 1157 connect( lab, SIGNAL( colorDropped(QRgb) ),
1156 this, SLOT( setRgb(QRgb) ) ); 1158 this, SLOT( setRgb(QRgb) ) );
1157 1159
1158 hEd = new QColNumLineEdit( this ); 1160 hEd = new QColNumLineEdit( this );
1159 hEd->setValidator( val360 ); 1161 hEd->setValidator( val360 );
1160 QLabel *l = new QLabel( hEd, QColorDialog::tr("Hu&e:"), this ); 1162 QLabel *l = new QLabel( hEd, QColorDialog::tr("Hu&e:"), this );
1161 l->setAlignment( AlignRight|AlignVCenter ); 1163 l->setAlignment( AlignRight|AlignVCenter );
1162 gl->addWidget( l, 0, 1 ); 1164 gl->addWidget( l, 0, 1 );
1163 gl->addWidget( hEd, 0, 2 ); 1165 gl->addWidget( hEd, 0, 2 );
1164 1166
1165 sEd = new QColNumLineEdit( this ); 1167 sEd = new QColNumLineEdit( this );
1166 sEd->setValidator( val256 ); 1168 sEd->setValidator( val256 );
1167 l = new QLabel( sEd, QColorDialog::tr("&Sat:"), this ); 1169 l = new QLabel( sEd, QColorDialog::tr("&Sat:"), this );
1168 l->setAlignment( AlignRight|AlignVCenter ); 1170 l->setAlignment( AlignRight|AlignVCenter );
1169 gl->addWidget( l, 1, 1 ); 1171 gl->addWidget( l, 1, 1 );
1170 gl->addWidget( sEd, 1, 2 ); 1172 gl->addWidget( sEd, 1, 2 );
1171 1173
1172 vEd = new QColNumLineEdit( this ); 1174 vEd = new QColNumLineEdit( this );
1173 vEd->setValidator( val256 ); 1175 vEd->setValidator( val256 );
1174 l = new QLabel( vEd, QColorDialog::tr("&Val:"), this ); 1176 l = new QLabel( vEd, QColorDialog::tr("&Val:"), this );
1175 l->setAlignment( AlignRight|AlignVCenter ); 1177 l->setAlignment( AlignRight|AlignVCenter );
1176 gl->addWidget( l, 2, 1 ); 1178 gl->addWidget( l, 2, 1 );
1177 gl->addWidget( vEd, 2, 2 ); 1179 gl->addWidget( vEd, 2, 2 );
1178 1180
1179 rEd = new QColNumLineEdit( this ); 1181 rEd = new QColNumLineEdit( this );
1180 rEd->setValidator( val256 ); 1182 rEd->setValidator( val256 );
1181 l = new QLabel( rEd, QColorDialog::tr("&Red:"), this ); 1183 l = new QLabel( rEd, QColorDialog::tr("&Red:"), this );
1182 l->setAlignment( AlignRight|AlignVCenter ); 1184 l->setAlignment( AlignRight|AlignVCenter );
1183 gl->addWidget( l, 0, 3 ); 1185 gl->addWidget( l, 0, 3 );
1184 gl->addWidget( rEd, 0, 4 ); 1186 gl->addWidget( rEd, 0, 4 );
1185 1187
1186 gEd = new QColNumLineEdit( this ); 1188 gEd = new QColNumLineEdit( this );
1187 gEd->setValidator( val256 ); 1189 gEd->setValidator( val256 );
1188 l = new QLabel( gEd, QColorDialog::tr("&Green:"), this ); 1190 l = new QLabel( gEd, QColorDialog::tr("&Green:"), this );
1189 l->setAlignment( AlignRight|AlignVCenter ); 1191 l->setAlignment( AlignRight|AlignVCenter );
1190 gl->addWidget( l, 1, 3 ); 1192 gl->addWidget( l, 1, 3 );
1191 gl->addWidget( gEd, 1, 4 ); 1193 gl->addWidget( gEd, 1, 4 );
1192 1194
1193 bEd = new QColNumLineEdit( this ); 1195 bEd = new QColNumLineEdit( this );
1194 bEd->setValidator( val256 ); 1196 bEd->setValidator( val256 );
1195 l = new QLabel( bEd, QColorDialog::tr("Bl&ue:"), this ); 1197 l = new QLabel( bEd, QColorDialog::tr("Bl&ue:"), this );
1196 l->setAlignment( AlignRight|AlignVCenter ); 1198 l->setAlignment( AlignRight|AlignVCenter );
1197 gl->addWidget( l, 2, 3 ); 1199 gl->addWidget( l, 2, 3 );
1198 gl->addWidget( bEd, 2, 4 ); 1200 gl->addWidget( bEd, 2, 4 );
1199 1201
1200 alphaEd = new QColNumLineEdit( this ); 1202 alphaEd = new QColNumLineEdit( this );
1201 alphaEd->setValidator( val256 ); 1203 alphaEd->setValidator( val256 );
@@ -1536,97 +1538,97 @@ QColor QColorDialog::getColor( QColor initial, QWidget *parent,
1536 1538
1537/*! 1539/*!
1538 Pops up a modal color dialog, letting the user choose a color and an 1540 Pops up a modal color dialog, letting the user choose a color and an
1539 alpha channel value. The color+alpha is initially set to \a initial. 1541 alpha channel value. The color+alpha is initially set to \a initial.
1540 1542
1541 If \a ok is non-null, \c *ok is set to TRUE if the user clicked OK, 1543 If \a ok is non-null, \c *ok is set to TRUE if the user clicked OK,
1542 and FALSE if the user clicked Cancel. 1544 and FALSE if the user clicked Cancel.
1543 1545
1544 If the user clicks Cancel the \a initial value is returned. 1546 If the user clicks Cancel the \a initial value is returned.
1545*/ 1547*/
1546 1548
1547QRgb QColorDialog::getRgba( QRgb initial, bool *ok, 1549QRgb QColorDialog::getRgba( QRgb initial, bool *ok,
1548 QWidget *parent, const char* name ) 1550 QWidget *parent, const char* name )
1549{ 1551{
1550 int allocContext = QColor::enterAllocContext(); 1552 int allocContext = QColor::enterAllocContext();
1551 QColorDialog *dlg = new QColorDialog( parent, name, TRUE ); //modal 1553 QColorDialog *dlg = new QColorDialog( parent, name, TRUE ); //modal
1552 dlg->setColor( initial ); 1554 dlg->setColor( initial );
1553 dlg->setSelectedAlpha( qAlpha(initial) ); 1555 dlg->setSelectedAlpha( qAlpha(initial) );
1554 int resultCode = dlg->exec(); 1556 int resultCode = dlg->exec();
1555 QColor::leaveAllocContext(); 1557 QColor::leaveAllocContext();
1556 QRgb result = initial; 1558 QRgb result = initial;
1557 if ( resultCode == QDialog::Accepted ) { 1559 if ( resultCode == QDialog::Accepted ) {
1558 QRgb c = dlg->color().rgb(); 1560 QRgb c = dlg->color().rgb();
1559 int alpha = dlg->selectedAlpha(); 1561 int alpha = dlg->selectedAlpha();
1560 result = qRgba( qRed(c), qGreen(c), qBlue(c), alpha ); 1562 result = qRgba( qRed(c), qGreen(c), qBlue(c), alpha );
1561 } 1563 }
1562 if ( ok ) 1564 if ( ok )
1563 *ok = resultCode == QDialog::Accepted; 1565 *ok = resultCode == QDialog::Accepted;
1564 1566
1565 QColor::destroyAllocContext(allocContext); 1567 QColor::destroyAllocContext(allocContext);
1566 delete dlg; 1568 delete dlg;
1567 return result; 1569 return result;
1568} 1570}
1569 1571
1570 1572
1571 1573
1572 1574
1573 1575
1574/*! 1576/*!
1575 Returns the color currently selected in the dialog. 1577 Returns the color currently selected in the dialog.
1576 1578
1577 \sa setColor() 1579 \sa setColor()
1578*/ 1580*/
1579 1581
1580QColor QColorDialog::color() const 1582QColor QColorDialog::color() const
1581{ 1583{
1582 return QColor(d->currentColor()); 1584 return QColor(d->currentColor());
1583} 1585}
1584 1586
1585 1587
1586/*! Destructs the dialog and frees any memory it allocated. 1588/*! Destructs the dialog and frees any memory it allocated.
1587 1589
1588*/ 1590*/
1589 1591
1590QColorDialog::~QColorDialog() 1592QColorDialog::~QColorDialog()
1591{ 1593{
1592 //d inherits QObject, so it is deleted by Qt. 1594 //d inherits QObject, so it is deleted by Qt.
1593} 1595}
1594 1596
1595 1597
1596/*! 1598/*!
1597 Sets the color shown in the dialog to \a c. 1599 Sets the color shown in the dialog to \a c.
1598 1600
1599 \sa color() 1601 \sa color()
1600*/ 1602*/
1601 1603
1602void QColorDialog::setColor( QColor c ) 1604void QColorDialog::setColor( QColor c )
1603{ 1605{
1604 d->setCurrentColor( c.rgb() ); 1606 d->setCurrentColor( c.rgb() );
1605} 1607}
1606 1608
1607 1609
1608 1610
1609 1611
1610/*! 1612/*!
1611 Sets the initial alpha channel value to \a a, and show the alpha channel 1613 Sets the initial alpha channel value to \a a, and show the alpha channel
1612 entry box. 1614 entry box.
1613*/ 1615*/
1614 1616
1615void QColorDialog::setSelectedAlpha( int a ) 1617void QColorDialog::setSelectedAlpha( int a )
1616{ 1618{
1617 d->showAlpha( TRUE ); 1619 d->showAlpha( TRUE );
1618 d->setCurrentAlpha( a ); 1620 d->setCurrentAlpha( a );
1619} 1621}
1620 1622
1621 1623
1622/*! 1624/*!
1623 Returns the value selected for the alpha channel. 1625 Returns the value selected for the alpha channel.
1624*/ 1626*/
1625 1627
1626int QColorDialog::selectedAlpha() const 1628int QColorDialog::selectedAlpha() const
1627{ 1629{
1628 return d->currentAlpha(); 1630 return d->currentAlpha();
1629} 1631}
1630 1632
1631 1633
1632#include "qcolordialog.moc" \ No newline at end of file 1634#include "qcolordialog.moc"