summaryrefslogtreecommitdiff
path: root/libopie/colordialog.cpp
authorzecke <zecke>2003-04-13 16:57:28 (UTC)
committer zecke <zecke>2003-04-13 16:57:28 (UTC)
commit0b311079ff19798866291034663757103c6ba935 (patch) (side-by-side diff)
tree70ddccf3a3147475050fa06cc2d807a71ab1d5ee /libopie/colordialog.cpp
parent1537ccb435ca725c793db6e94e0b9e83484b57e7 (diff)
downloadopie-0b311079ff19798866291034663757103c6ba935.zip
opie-0b311079ff19798866291034663757103c6ba935.tar.gz
opie-0b311079ff19798866291034663757103c6ba935.tar.bz2
Jumbo API documentation update
and some API fixed ColorDialog is now OColorDialog!!! keep the namespace tidy! ColorPopupMenu is now OColorPopupMenu!!! keep the namespace tidy ColorDialog TT couldn't break bc we can so make it const QColor& OTimePicker add some convience methods more I might have forgot
Diffstat (limited to 'libopie/colordialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/colordialog.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/libopie/colordialog.cpp b/libopie/colordialog.cpp
index 684d6ea..35f15d6 100644
--- a/libopie/colordialog.cpp
+++ b/libopie/colordialog.cpp
@@ -48,24 +48,29 @@
#include "qvalidator.h"
#include "qdragobject.h"
#include "qapplication.h"
#include "qdragobject.h"
static inline void rgb2hsv( QRgb rgb, int&h, int&s, int&v )
{
QColor c;
c.setRgb( rgb );
c.getHsv(h,s,v);
}
+/*
+ * avoid clashes with the original Qt
+ */
+namespace {
+
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 );
@@ -598,55 +603,57 @@ void QColorShower::setHsv( int h, int s, int v )
hEd->setNum( hue );
sEd->setNum( sat );
vEd->setNum( val );
rEd->setNum( qRed(currentColor()) );
gEd->setNum( qGreen(currentColor()) );
bEd->setNum( qBlue(currentColor()) );
showCurrentColor();
}
+}
+
class OColorDialogPrivate : public QObject
{
Q_OBJECT
public:
OColorDialogPrivate( OColorDialog *p );
QRgb currentColor() const { return cs->currentColor(); }
- void setCurrentColor( QRgb rgb );
+ void setCurrentColor( const QRgb& rgb );
int currentAlpha() const { return cs->currentAlpha(); }
void setCurrentAlpha( int a ) { cs->setCurrentAlpha( a ); }
void showAlpha( bool b ) { cs->showAlpha( b ); }
private slots:
void newHsv( int h, int s, int v );
void newColorTypedIn( QRgb rgb );
private:
QColorPicker *cp;
QColorLuminancePicker *lp;
QColorShower *cs;
};
//sets all widgets to display h,s,v
void OColorDialogPrivate::newHsv( int h, int s, int v )
{
cs->setHsv( h, s, v );
cp->setCol( h, s );
lp->setCol( h, s, v );
}
//sets all widgets to display rgb
-void OColorDialogPrivate::setCurrentColor( QRgb rgb )
+void OColorDialogPrivate::setCurrentColor( const QRgb& rgb )
{
cs->setRgb( rgb );
newColorTypedIn( rgb );
}
//sets all widgets exept cs to display rgb
void OColorDialogPrivate::newColorTypedIn( QRgb rgb )
{
int h, s, v;
rgb2hsv(rgb, h, s, v );
cp->setCol( h, s );
lp->setCol( h, s, v);
@@ -717,25 +724,25 @@ OColorDialog::OColorDialog(QWidget* parent, const char* name, bool modal) :
{
d = new OColorDialogPrivate( 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 OColorDialog::getColor( QColor initial, QWidget *parent,
+QColor OColorDialog::getColor( const QColor& initial, QWidget *parent,
const char *name )
{
int allocContext = QColor::enterAllocContext();
OColorDialog *dlg = new OColorDialog( 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( OColorDialog::tr( "Select color" ) );
dlg->setColor( initial );
dlg->showMaximized();
@@ -754,25 +761,25 @@ QColor OColorDialog::getColor( QColor initial, QWidget *parent,
/*!
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 OColorDialog::getRgba( QRgb initial, bool *ok,
+QRgb OColorDialog::getRgba( const QRgb& initial, bool *ok,
QWidget *parent, const char* name )
{
int allocContext = QColor::enterAllocContext();
OColorDialog *dlg = new OColorDialog( parent, name, TRUE ); //modal
dlg->setColor( initial );
dlg->setSelectedAlpha( qAlpha(initial) );
dlg->showMaximized();
int resultCode = dlg->exec();
QColor::leaveAllocContext();
QRgb result = initial;
if ( resultCode == QDialog::Accepted ) {
QRgb c = dlg->color().rgb();
@@ -810,25 +817,25 @@ QColor OColorDialog::color() const
OColorDialog::~OColorDialog()
{
//d inherits QObject, so it is deleted by Qt.
}
/*!
Sets the color shown in the dialog to \a c.
\sa color()
*/
-void OColorDialog::setColor( QColor c )
+void OColorDialog::setColor( const QColor& c )
{
d->setCurrentColor( c.rgb() );
}
/*!
Sets the initial alpha channel value to \a a, and show the alpha channel
entry box.
*/