-rw-r--r-- | libqtaux/qcolordialog.cpp | 8 |
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 @@ -351,400 +351,400 @@ void QWellArray::setCurrent( int row, int col ) /*! Sets the currently selected cell to \a row, \a col. If \a row or \a col are less than zero, the current cell is unselected. Does not set the position of the focus indicator. */ void QWellArray::setSelected( int row, int col ) { if ( (selRow == row) && (selCol == col) ) return; int oldRow = selRow; int oldCol = selCol; if ( row < 0 || col < 0 ) row = col = -1; selCol = col; selRow = row; updateCell( oldRow, oldCol ); updateCell( selRow, selCol ); if ( row >= 0 ) emit selected( row, col ); if ( isVisible() && parentWidget() && parentWidget()->inherits("QPopupMenu") ) parentWidget()->close(); } /*!\reimp */ void QWellArray::focusInEvent( QFocusEvent* ) { updateCell( curRow, curCol ); } /*! Sets the size of the well array to be \c rows cells by \c cols. Resets any brush info set by setCellBrush(). Must be called by reimplementors. */ void QWellArray::setDimension( int rows, int cols ) { nRows = rows; nCols = cols; if ( d ) { if ( d->brush ) delete[] d->brush; delete d; d = 0; } setNumCols( nCols ); setNumRows( nRows ); } void QWellArray::setCellBrush( int row, int col, const QBrush &b ) { if ( !d ) { d = new QWellArrayData; d->brush = new QBrush[nRows*nCols]; } if ( row >= 0 && row < nRows && col >= 0 && col < nCols ) d->brush[row*nCols+col] = b; #ifdef CHECK_RANGE else qWarning( "QWellArray::setCellBrush( %d, %d ) out of range", row, col ); #endif } /*! Returns the brush set for the cell at \a row, \a col. If no brush is set, \c NoBrush is returned. */ QBrush QWellArray::cellBrush( int row, int col ) { if ( d && row >= 0 && row < nRows && col >= 0 && col < nCols ) return d->brush[row*nCols+col]; return NoBrush; } /*!\reimp */ void QWellArray::focusOutEvent( QFocusEvent* ) { updateCell( curRow, curCol ); } /*\reimp */ void QWellArray::keyPressEvent( QKeyEvent* e ) { switch( e->key() ) { // Look at the key code case Key_Left: // If 'left arrow'-key, if( curCol > 0 ) { // and cr't not in leftmost col setCurrent( curRow, curCol - 1); // set cr't to next left column int edge = leftCell(); // find left edge if ( curCol < edge ) // if we have moved off edge, setLeftCell( edge - 1 ); // scroll view to rectify } break; case Key_Right: // Correspondingly... if( curCol < numCols()-1 ) { setCurrent( curRow, curCol + 1); int edge = lastColVisible(); if ( curCol >= edge ) setLeftCell( leftCell() + 1 ); } break; case Key_Up: if( curRow > 0 ) { setCurrent( curRow - 1, curCol); int edge = topCell(); if ( curRow < edge ) setTopCell( edge - 1 ); } else if ( smallStyle ) focusNextPrevChild( FALSE ); break; case Key_Down: if( curRow < numRows()-1 ) { setCurrent( curRow + 1, curCol); int edge = lastRowVisible(); if ( curRow >= edge ) setTopCell( topCell() + 1 ); } else if ( smallStyle ) focusNextPrevChild( TRUE ); break; case Key_Space: case Key_Return: case Key_Enter: setSelected( curRow, curCol ); break; default: // If not an interesting key, e->ignore(); // we don't accept the event return; } } //////////// QWellArray END static bool initrgb = FALSE; static QRgb stdrgb[6*8]; static QRgb cusrgb[2*8]; static void initRGB() { if ( initrgb ) return; initrgb = TRUE; int i = 0; for ( int g = 0; g < 4; g++ ) for ( int r = 0; r < 4; r++ ) for ( int b = 0; b < 3; b++ ) stdrgb[i++] = qRgb( r*255/3, g*255/3, b*255/2 ); for ( i = 0; i < 2*8; i++ ) cusrgb[i] = qRgb(0xff,0xff,0xff); } /*! Returns the number of custom colors supported by QColorDialog. All color dialogs share the same custom colors. */ int QColorDialog::customCount() { return 2*8; } /*! Returns custom color number \a i as a QRgb. */ QRgb QColorDialog::customColor( int i ) { initRGB(); if ( i < 0 || i >= customCount() ) { #ifdef CHECK_RANGE qWarning( "QColorDialog::customColor() index %d out of range", i ); -#endif +#endif i = 0; } return cusrgb[i]; } /*! Sets custom color number \a i to the QRgb value \a c. */ void QColorDialog::setCustomColor( int i, QRgb c ) { initRGB(); if ( i < 0 || i >= customCount() ) { #ifdef CHECK_RANGE qWarning( "QColorDialog::customColor() index %d out of range", i ); -#endif +#endif return; } cusrgb[i] = c; } static inline void rgb2hsv( QRgb rgb, int&h, int&s, int&v ) { QColor c; c.setRgb( rgb ); c.getHsv(h,s,v); } class QColorWell : public QWellArray { public: QColorWell( QWidget *parent, int r, int c, QRgb *vals ) :QWellArray( parent, "" ), values( vals ), mousePressed( FALSE ), oldCurrent( -1, -1 ) { setDimension(r,c); setWFlags( WResizeNoErase ); } QSizePolicy sizePolicy() const; protected: void drawContents( QPainter *, int row, int col, const QRect& ); void drawContents( QPainter *p ) { QWellArray::drawContents(p); } void mousePressEvent( QMouseEvent *e ); void mouseMoveEvent( QMouseEvent *e ); void mouseReleaseEvent( QMouseEvent *e ); #ifndef QT_NO_DRAGANDDROP void dragEnterEvent( QDragEnterEvent *e ); void dragLeaveEvent( QDragLeaveEvent *e ); void dragMoveEvent( QDragMoveEvent *e ); void dropEvent( QDropEvent *e ); #endif private: QRgb *values; bool mousePressed; QPoint pressPos; QPoint oldCurrent; }; QSizePolicy QColorWell::sizePolicy() const { return QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); } void QColorWell::drawContents( QPainter *p, int row, int col, const QRect &r ) { int i = row + col*numRows(); p->fillRect( r, QColor( values[i] ) ); } void QColorWell::mousePressEvent( QMouseEvent *e ) { oldCurrent = QPoint( selectedRow(), selectedColumn() ); QWellArray::mousePressEvent( e ); mousePressed = TRUE; pressPos = e->pos(); } void QColorWell::mouseMoveEvent( QMouseEvent *e ) { QWellArray::mouseMoveEvent( e ); #ifndef QT_NO_DRAGANDDROP if ( !mousePressed ) return; if ( ( pressPos - e->pos() ).manhattanLength() > QApplication::startDragDistance() ) { setCurrent( oldCurrent.x(), oldCurrent.y() ); int i = findRow( e->y() ) + findCol( e->x() ) * numRows(); QColor col( values[ i ] ); QColorDrag *drg = new QColorDrag( col, this ); QPixmap pix( cellWidth(), cellHeight() ); pix.fill( col ); QPainter p( &pix ); p.drawRect( 0, 0, pix.width(), pix.height() ); p.end(); drg->setPixmap( pix ); mousePressed = FALSE; drg->dragCopy(); } #endif } #ifndef QT_NO_DRAGANDDROP void QColorWell::dragEnterEvent( QDragEnterEvent *e ) { setFocus(); if ( QColorDrag::canDecode( e ) ) e->accept(); else e->ignore(); } void QColorWell::dragLeaveEvent( QDragLeaveEvent * ) { if ( hasFocus() ) parentWidget()->setFocus(); } void QColorWell::dragMoveEvent( QDragMoveEvent *e ) { if ( QColorDrag::canDecode( e ) ) { setCurrent( findRow( e->pos().y() ), findCol( e->pos().x() ) ); e->accept(); } else e->ignore(); } void QColorWell::dropEvent( QDropEvent *e ) { if ( QColorDrag::canDecode( e ) ) { int i = findRow( e->pos().y() ) + findCol( e->pos().x() ) * numRows(); QColor col; QColorDrag::decode( e, col ); values[ i ] = col.rgb(); repaint( FALSE ); e->accept(); } else { e->ignore(); } } #endif // QT_NO_DRAGANDDROP void QColorWell::mouseReleaseEvent( QMouseEvent *e ) { if ( !mousePressed ) return; QWellArray::mouseReleaseEvent( e ); mousePressed = FALSE; } class QColorPicker : public QFrame { Q_OBJECT public: QColorPicker(QWidget* parent=0, const char* name=0); ~QColorPicker(); public slots: void setCol( int h, int s ); signals: void newCol( int h, int s ); protected: QSize sizeHint() const; QSizePolicy sizePolicy() const; void drawContents(QPainter* p); void mouseMoveEvent( QMouseEvent * ); void mousePressEvent( QMouseEvent * ); private: int hue; int sat; QPoint colPt(); int huePt( const QPoint &pt ); int satPt( const QPoint &pt ); void setCol( const QPoint &pt ); QPixmap *pix; }; static int pWidth = 200; static int pHeight = 200; class QColorLuminancePicker : public QWidget { Q_OBJECT public: QColorLuminancePicker(QWidget* parent=0, const char* name=0); ~QColorLuminancePicker(); public slots: void setCol( int h, int s, int v ); void setCol( int h, int s ); signals: void newHsv( int h, int s, int v ); protected: // QSize sizeHint() const; // QSizePolicy sizePolicy() const; void paintEvent( QPaintEvent*); void mouseMoveEvent( QMouseEvent * ); void mousePressEvent( QMouseEvent * ); private: enum { foff = 3, coff = 4 }; //frame and contents offset int val; int hue; @@ -914,384 +914,386 @@ void QColorPicker::mouseMoveEvent( QMouseEvent *m ) { QPoint p = m->pos() - contentsRect().topLeft(); setCol( p ); emit newCol( hue, sat ); } void QColorPicker::mousePressEvent( QMouseEvent *m ) { QPoint p = m->pos() - contentsRect().topLeft(); setCol( p ); emit newCol( hue, sat ); } void QColorPicker::drawContents(QPainter* p) { QRect r = contentsRect(); p->drawPixmap( r.topLeft(), *pix ); QPoint pt = colPt() + r.topLeft(); p->setPen( QPen(black) ); p->fillRect( pt.x()-9, pt.y(), 20, 2, black ); p->fillRect( pt.x(), pt.y()-9, 2, 20, black ); } class QColorShowLabel; class QColIntValidator: public QIntValidator { public: QColIntValidator( int bottom, int top, QWidget * parent, const char *name = 0 ) :QIntValidator( bottom, top, parent, name ) {} QValidator::State validate( QString &, int & ) const; }; QValidator::State QColIntValidator::validate( QString &s, int &pos ) const { State state = QIntValidator::validate(s,pos); if ( state == Valid ) { long int val = s.toLong(); // This is not a general solution, assumes that top() > 0 and // bottom >= 0 if ( val < 0 ) { s = "0"; pos = 1; } else if ( val > top() ) { s.setNum( top() ); pos = s.length(); } } return state; } class QColNumLineEdit : public QLineEdit { public: QColNumLineEdit( QWidget *parent, const char* name = 0 ) : QLineEdit( parent, name ) { setMaxLength( 3 );} QSize sizeHint() const { return QSize( 30, //##### QLineEdit::sizeHint().height() ); } void setNum( int i ) { QString s; s.setNum(i); bool block = signalsBlocked(); blockSignals(TRUE); setText( s ); blockSignals(block); } int val() const { return text().toInt(); } }; class QColorShower : public QWidget { Q_OBJECT public: QColorShower( QWidget *parent, const char *name = 0 ); //things that don't emit signals void setHsv( int h, int s, int v ); int currentAlpha() const { return alphaEd->val(); } void setCurrentAlpha( int a ) { alphaEd->setNum( a ); } void showAlpha( bool b ); QRgb currentColor() const { return curCol; } public slots: void setRgb( QRgb rgb ); signals: void newCol( QRgb rgb ); private slots: void rgbEd(); void hsvEd(); private: void showCurrentColor(); int hue, sat, val; QRgb curCol; QColNumLineEdit *hEd; QColNumLineEdit *sEd; QColNumLineEdit *vEd; QColNumLineEdit *rEd; QColNumLineEdit *gEd; QColNumLineEdit *bEd; QColNumLineEdit *alphaEd; QLabel *alphaLab; QColorShowLabel *lab; bool rgbOriginal; }; class QColorShowLabel : public QFrame { Q_OBJECT public: QColorShowLabel( QWidget *parent ) :QFrame( parent ) { setFrameStyle( QFrame::Panel|QFrame::Sunken ); setBackgroundMode( PaletteBackground ); setAcceptDrops( TRUE ); mousePressed = FALSE; } void setColor( QColor c ) { col = c; } signals: void colorDropped( QRgb ); protected: void drawContents( QPainter *p ); void mousePressEvent( QMouseEvent *e ); void mouseMoveEvent( QMouseEvent *e ); void mouseReleaseEvent( QMouseEvent *e ); #ifndef QT_NO_DRAGANDDROP void dragEnterEvent( QDragEnterEvent *e ); void dragLeaveEvent( QDragLeaveEvent *e ); void dropEvent( QDropEvent *e ); #endif private: QColor col; bool mousePressed; QPoint pressPos; }; void QColorShowLabel::drawContents( QPainter *p ) { p->fillRect( contentsRect(), col ); } void QColorShower::showAlpha( bool b ) { if ( b ) { alphaLab->show(); alphaEd->show(); } else { alphaLab->hide(); alphaEd->hide(); } } void QColorShowLabel::mousePressEvent( QMouseEvent *e ) { mousePressed = TRUE; pressPos = e->pos(); } void QColorShowLabel::mouseMoveEvent( QMouseEvent *e ) { #ifndef QT_NO_DRAGANDDROP if ( !mousePressed ) return; if ( ( pressPos - e->pos() ).manhattanLength() > QApplication::startDragDistance() ) { QColorDrag *drg = new QColorDrag( col, this ); QPixmap pix( 30, 20 ); pix.fill( col ); QPainter p( &pix ); p.drawRect( 0, 0, pix.width(), pix.height() ); p.end(); drg->setPixmap( pix ); mousePressed = FALSE; drg->dragCopy(); } +#else + Q_UNUSED( e ) #endif } #ifndef QT_NO_DRAGANDDROP void QColorShowLabel::dragEnterEvent( QDragEnterEvent *e ) { if ( QColorDrag::canDecode( e ) ) e->accept(); else e->ignore(); } void QColorShowLabel::dragLeaveEvent( QDragLeaveEvent * ) { } void QColorShowLabel::dropEvent( QDropEvent *e ) { if ( QColorDrag::canDecode( e ) ) { QColorDrag::decode( e, col ); repaint( FALSE ); emit colorDropped( col.rgb() ); e->accept(); } else { e->ignore(); } } #endif // QT_NO_DRAGANDDROP void QColorShowLabel::mouseReleaseEvent( QMouseEvent * ) { if ( !mousePressed ) return; mousePressed = FALSE; } QColorShower::QColorShower( QWidget *parent, const char *name ) :QWidget( parent, name) { curCol = qRgb( -1, -1, -1 ); QColIntValidator *val256 = new QColIntValidator( 0, 255, this ); QColIntValidator *val360 = new QColIntValidator( 0, 360, this ); QGridLayout *gl = new QGridLayout( this, 1, 1, 6 ); lab = new QColorShowLabel( this ); lab->setMinimumWidth( 60 ); //### gl->addMultiCellWidget(lab, 0,-1,0,0); connect( lab, SIGNAL( colorDropped(QRgb) ), this, SIGNAL( newCol(QRgb) ) ); connect( lab, SIGNAL( colorDropped(QRgb) ), this, SLOT( setRgb(QRgb) ) ); hEd = new QColNumLineEdit( this ); hEd->setValidator( val360 ); QLabel *l = new QLabel( hEd, QColorDialog::tr("Hu&e:"), this ); l->setAlignment( AlignRight|AlignVCenter ); gl->addWidget( l, 0, 1 ); gl->addWidget( hEd, 0, 2 ); sEd = new QColNumLineEdit( this ); sEd->setValidator( val256 ); l = new QLabel( sEd, QColorDialog::tr("&Sat:"), this ); l->setAlignment( AlignRight|AlignVCenter ); gl->addWidget( l, 1, 1 ); gl->addWidget( sEd, 1, 2 ); vEd = new QColNumLineEdit( this ); vEd->setValidator( val256 ); l = new QLabel( vEd, QColorDialog::tr("&Val:"), this ); l->setAlignment( AlignRight|AlignVCenter ); gl->addWidget( l, 2, 1 ); gl->addWidget( vEd, 2, 2 ); rEd = new QColNumLineEdit( this ); rEd->setValidator( val256 ); l = new QLabel( rEd, QColorDialog::tr("&Red:"), this ); l->setAlignment( AlignRight|AlignVCenter ); gl->addWidget( l, 0, 3 ); gl->addWidget( rEd, 0, 4 ); gEd = new QColNumLineEdit( this ); gEd->setValidator( val256 ); l = new QLabel( gEd, QColorDialog::tr("&Green:"), this ); l->setAlignment( AlignRight|AlignVCenter ); gl->addWidget( l, 1, 3 ); gl->addWidget( gEd, 1, 4 ); bEd = new QColNumLineEdit( this ); bEd->setValidator( val256 ); l = new QLabel( bEd, QColorDialog::tr("Bl&ue:"), this ); l->setAlignment( AlignRight|AlignVCenter ); gl->addWidget( l, 2, 3 ); gl->addWidget( bEd, 2, 4 ); alphaEd = new QColNumLineEdit( this ); alphaEd->setValidator( val256 ); alphaLab = new QLabel( alphaEd, QColorDialog::tr("A&lpha channel:"), this ); alphaLab->setAlignment( AlignRight|AlignVCenter ); gl->addMultiCellWidget( alphaLab, 3, 3, 1, 3 ); gl->addWidget( alphaEd, 3, 4 ); alphaEd->hide(); alphaLab->hide(); connect( hEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) ); connect( sEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) ); connect( vEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) ); connect( rEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) ); connect( gEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) ); connect( bEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) ); } void QColorShower::showCurrentColor() { lab->setColor( currentColor() ); lab->repaint(FALSE); //### } void QColorShower::rgbEd() { rgbOriginal = TRUE; curCol = qRgb( rEd->val(), gEd->val(), bEd->val() ); rgb2hsv(currentColor(), hue, sat, val ); hEd->setNum( hue ); sEd->setNum( sat ); vEd->setNum( val ); showCurrentColor(); emit newCol( currentColor() ); } void QColorShower::hsvEd() { rgbOriginal = FALSE; hue = hEd->val(); sat = sEd->val(); val = vEd->val(); curCol = QColor( hue, sat, val, QColor::Hsv ).rgb(); rEd->setNum( qRed(currentColor()) ); gEd->setNum( qGreen(currentColor()) ); bEd->setNum( qBlue(currentColor()) ); showCurrentColor(); emit newCol( currentColor() ); } void QColorShower::setRgb( QRgb rgb ) { rgbOriginal = TRUE; curCol = rgb; rgb2hsv( currentColor(), hue, sat, val ); hEd->setNum( hue ); sEd->setNum( sat ); vEd->setNum( val ); rEd->setNum( qRed(currentColor()) ); gEd->setNum( qGreen(currentColor()) ); bEd->setNum( qBlue(currentColor()) ); showCurrentColor(); } void QColorShower::setHsv( int h, int s, int v ) { rgbOriginal = FALSE; hue = h; val = v; sat = s; //Range check### curCol = QColor( hue, sat, val, QColor::Hsv ).rgb(); hEd->setNum( hue ); sEd->setNum( sat ); vEd->setNum( val ); rEd->setNum( qRed(currentColor()) ); gEd->setNum( qGreen(currentColor()) ); bEd->setNum( qBlue(currentColor()) ); showCurrentColor(); } class QColorDialogPrivate : public QObject { Q_OBJECT public: QColorDialogPrivate( QColorDialog *p ); QRgb currentColor() const { return cs->currentColor(); } void setCurrentColor( QRgb rgb ); @@ -1440,193 +1442,193 @@ QColorDialogPrivate::QColorDialogPrivate( QColorDialog *dialog ) : else buttons = new QHBoxLayout( leftLay ); QPushButton *ok, *cancel; ok = new QPushButton( QColorDialog::tr("OK"), dialog ); connect( ok, SIGNAL(clicked()), dialog, SLOT(accept()) ); ok->setDefault(TRUE); cancel = new QPushButton( QColorDialog::tr("Cancel"), dialog ); connect( cancel, SIGNAL(clicked()), dialog, SLOT(reject()) ); buttons->addWidget( ok ); buttons->addWidget( cancel ); buttons->addStretch(); if ( !compact ) { QPushButton *addCusBt = new QPushButton( QColorDialog::tr("&Add To Custom Colors"), dialog ); rightLay->addWidget( addCusBt ); connect( addCusBt, SIGNAL(clicked()), this, SLOT(addCustom()) ); } } void QColorDialogPrivate::addCustom() { cusrgb[nextCust] = cs->currentColor(); custom->repaint( FALSE ); //### nextCust = (nextCust+1) % 16; } // BEING REVISED: jo /*! \class QColorDialog qcolordialog.h \brief The QColorDialog class provides a dialog widget for specifying colors. \ingroup dialogs The color dialog's function is to allow users to choose colors - for instance, you might use this in a drawing program to allow the user to set the brush color. This version of Qt only provides modal color dialogs. The static getColor() function shows the dialog and allows the user to specify a color, while getRgba() does the same but allows the user to specify a color with an alpha channel (transparency) value. The user can store customCount() different custom colors. The custom colors are shared by all color dialogs, and remembered during the execution of the program. Use setCustomColor() to set the custom colors, and customColor() to get them. <img src=qcolordlg-m.png> <img src=qcolordlg-w.png> */ /*! Constructs a default color dialog. Use setColor() for setting an initial value. \sa getColor() */ QColorDialog::QColorDialog(QWidget* parent, const char* name, bool modal) : QDialog(parent, name, modal ) { setSizeGripEnabled( TRUE ); d = new QColorDialogPrivate( this ); } /*! Pops up a modal color dialog letting the user choose a color and returns that color. The color is initially set to \a initial. Returns an \link QColor::isValid() invalid\endlink color if the user cancels the dialog. All colors allocated by the dialog will be deallocated before this function returns. */ QColor QColorDialog::getColor( QColor initial, QWidget *parent, const char *name ) { int allocContext = QColor::enterAllocContext(); QColorDialog *dlg = new QColorDialog( parent, name, TRUE ); //modal if ( parent && parent->icon() && !parent->icon()->isNull() ) dlg->setIcon( *parent->icon() ); else if ( qApp->mainWidget() && qApp->mainWidget()->icon() && !qApp->mainWidget()->icon()->isNull() ) dlg->setIcon( *qApp->mainWidget()->icon() ); dlg->setCaption( QColorDialog::tr( "Select color" ) ); dlg->setColor( initial ); int resultCode = dlg->exec(); QColor::leaveAllocContext(); QColor result; if ( resultCode == QDialog::Accepted ) result = dlg->color(); QColor::destroyAllocContext(allocContext); delete dlg; return result; } /*! Pops up a modal color dialog, letting the user choose a color and an alpha channel value. The color+alpha is initially set to \a initial. If \a ok is non-null, \c *ok is set to TRUE if the user clicked OK, and FALSE if the user clicked Cancel. If the user clicks Cancel the \a initial value is returned. */ QRgb QColorDialog::getRgba( QRgb initial, bool *ok, QWidget *parent, const char* name ) { int allocContext = QColor::enterAllocContext(); QColorDialog *dlg = new QColorDialog( parent, name, TRUE ); //modal dlg->setColor( initial ); dlg->setSelectedAlpha( qAlpha(initial) ); int resultCode = dlg->exec(); QColor::leaveAllocContext(); QRgb result = initial; if ( resultCode == QDialog::Accepted ) { QRgb c = dlg->color().rgb(); int alpha = dlg->selectedAlpha(); result = qRgba( qRed(c), qGreen(c), qBlue(c), alpha ); } if ( ok ) *ok = resultCode == QDialog::Accepted; QColor::destroyAllocContext(allocContext); delete dlg; return result; } /*! Returns the color currently selected in the dialog. \sa setColor() */ QColor QColorDialog::color() const { return QColor(d->currentColor()); } /*! Destructs the dialog and frees any memory it allocated. */ QColorDialog::~QColorDialog() { //d inherits QObject, so it is deleted by Qt. } /*! Sets the color shown in the dialog to \a c. \sa color() */ void QColorDialog::setColor( QColor c ) { d->setCurrentColor( c.rgb() ); } /*! Sets the initial alpha channel value to \a a, and show the alpha channel entry box. */ void QColorDialog::setSelectedAlpha( int a ) { d->showAlpha( TRUE ); d->setCurrentAlpha( a ); } /*! Returns the value selected for the alpha channel. */ int QColorDialog::selectedAlpha() const { return d->currentAlpha(); } -#include "qcolordialog.moc"
\ No newline at end of file +#include "qcolordialog.moc" |