--nextPart1280351.ZfkO4lMfac Content-Type: multipart/mixed; boundary="Boundary-01=_LIdqBGoBJhCnSwa" Content-Transfer-Encoding: 7bit Content-Disposition: inline --Boundary-01=_LIdqBGoBJhCnSwa Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Sunday 28 November 2004 13:15, Olaf Schmidt wrote: > [Gunnar Schmi Dt, Donnerstag, 25. November 2004 14:57] > > > The second version (kdelibs2.diff and kdebase2.diff) adds an > > additional second color to the icon effect, so that both colors are > > defined with the icon effect. This has the advantage that it does not > > add a dependency between the color scheme and the icon theme, but it > > also requires some more changes to the API (i.e., the second color > > needs to be added). > > If this is BC, then I would strongly suggest using this version. Well, actually I had made a small mistake so that it was not BC, but now I= =20 have corrected the patch, so that it should be BC now. > But you would also need to make sure the second colour is included > in meta themes. > [...] I do not know how difficult it would be to extend the meta themes without=20 breaking the compatibility of the theme files. In either case we do need=20 both the icon effects and the font sizes (which are currently missing,=20 too). Gunnar Schmi Dt =2D-=20 Co-maintainer of the KDE Accessibility Project Maintainer of the kdeaccessibility package http://accessibility.kde.org/ --Boundary-01=_LIdqBGoBJhCnSwa Content-Type: text/x-diff; charset="utf-8"; name="kdelibs2n.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="kdelibs2n.diff" Index: kdecore/kiconeffect.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/kde/kdelibs/kdecore/kiconeffect.cpp,v retrieving revision 1.47 diff -u -p -r1.47 kiconeffect.cpp =2D-- kdecore/kiconeffect.cpp 7 Sep 2004 11:42:17 -0000 1.47 +++ kdecore/kiconeffect.cpp 28 Nov 2004 12:27:57 -0000 @@ -43,6 +43,7 @@ class KIconEffectPrivate { public: QString mKey[6][3]; + QColor mColor2[6][3]; }; =20 KIconEffect::KIconEffect() @@ -80,6 +81,7 @@ void KIconEffect::init() QString _desaturate("desaturate"); QString _togamma("togamma"); QString _none("none"); + QString _tomonochrome("tomonochrome"); =20 KConfigGroupSaver cs(config, "default"); =20 @@ -99,6 +101,9 @@ void KIconEffect::init() mColor[i][0] =3D QColor(144,128,248); mColor[i][1] =3D QColor(169,156,255); mColor[i][2] =3D QColor(34,202,0); + d->mColor2[i][0] =3D QColor(0,0,0); + d->mColor2[i][1] =3D QColor(0,0,0); + d->mColor2[i][2] =3D QColor(0,0,0); =20 config->setGroup(*it + "Icons"); for (it2=3Dstates.begin(), j=3D0; it2!=3Dstates.end(); it2++, j++) @@ -112,6 +117,8 @@ void KIconEffect::init() effect =3D DeSaturate; else if (tmp =3D=3D _togamma) effect =3D ToGamma; + else if (tmp =3D=3D _tomonochrome) + effect =3D ToMonochrome; else if (tmp =3D=3D _none) effect =3D NoEffect; else @@ -120,6 +127,7 @@ void KIconEffect::init() mEffect[i][j] =3D effect; mValue[i][j] =3D config->readDoubleNumEntry(*it2 + "Value"); mColor[i][j] =3D config->readColorEntry(*it2 + "Color"); + d->mColor2[i][j] =3D config->readColorEntry(*it2 + "Color2"); mTrans[i][j] =3D config->readBoolEntry(*it2 + "SemiTransparent"); =20 } @@ -150,11 +158,16 @@ QString KIconEffect::fingerprint(int gro cached +=3D ':'; cached +=3D mTrans[group][state] ? QString::fromLatin1("trans") : QString::fromLatin1("notrans"); =2D if (mEffect[group][state] =3D=3D Colorize) + if (mEffect[group][state] =3D=3D Colorize || mEffect[group][state]= =3D=3D ToMonochrome) { cached +=3D ':'; cached +=3D mColor[group][state].name(); } + if (mEffect[group][state] =3D=3D ToMonochrome) + { + cached +=3D ':'; + cached +=3D d->mColor2[group][state].name(); + } =20 d->mKey[group][state] =3D cached; =20 } @@ -175,11 +188,16 @@ QImage KIconEffect::apply(QImage image,=20 return image; } return apply(image, mEffect[group][state], mValue[group][state], =2D mColor[group][state], mTrans[group][state]); + mColor[group][state], d->mColor2[group][state], mTrans[group][state]); } =20 QImage KIconEffect::apply(QImage image, int effect, float value, const QCo= lor col, bool trans) const { + apply (image, effect, value, col, KGlobalSettings::baseColor(), trans); +} + +QImage KIconEffect::apply(QImage image, int effect, float value, const QCo= lor col, const QColor col2, bool trans) const +{ if (effect >=3D LastEffect ) { kdDebug(265) << "Illegal icon effect: " << effect << "\n"; @@ -203,6 +221,9 @@ QImage KIconEffect::apply(QImage image,=20 case ToGamma: toGamma(image, value); break; + case ToMonochrome: + toMonochrome(image, col, col2, value); + break; } if (trans =3D=3D true) { @@ -224,12 +245,18 @@ QPixmap KIconEffect::apply(QPixmap pixma return pixmap; } return apply(pixmap, mEffect[group][state], mValue[group][state], =2D mColor[group][state], mTrans[group][state]); + mColor[group][state], d->mColor2[group][state], mTrans[group][state]); } =20 QPixmap KIconEffect::apply(QPixmap pixmap, int effect, float value, const QColor col, bool trans) const { + apply (pixmap, effect, value, col, KGlobalSettings::baseColor(), trans= ); +} + +QPixmap KIconEffect::apply(QPixmap pixmap, int effect, float value, + const QColor col, const QColor col2, bool trans) const +{ QPixmap result; =20 if (effect >=3D LastEffect ) @@ -246,7 +273,7 @@ QPixmap KIconEffect::apply(QPixmap pixma else if ( effect !=3D NoEffect ) { QImage tmpImg =3D pixmap.convertToImage(); =2D tmpImg =3D apply(tmpImg, effect, value, col, trans); + tmpImg =3D apply(tmpImg, effect, value, col, col2, trans); result.convertFromImage(tmpImg); } else @@ -321,6 +348,40 @@ void KIconEffect::colorize(QImage &img,=20 } } =20 +void KIconEffect::toMonochrome(QImage &img, const QColor &black, const QCo= lor &white, float value) { + int pixels =3D (img.depth() > 8) ? img.width()*img.height() : img.numCo= lors(); + unsigned int *data =3D img.depth() > 8 ? (unsigned int *) img.bits() + : (unsigned int *) img.colorTable(); + int rval, gval, bval, alpha, i; + int rw =3D white.red(), gw =3D white.green(), bw =3D white.blue(); + int rb =3D black.red(), gb =3D black.green(), bb =3D black.blue(); + =20 + double values =3D 0, sum =3D 0; + // Step 1: determine the average brightness + for (i=3D0; i(value*rb+(1.0-value)*qRed(data[i])); + gval =3D static_cast(value*gb+(1.0-value)*qGreen(data[i])); + bval =3D static_cast(value*bb+(1.0-value)*qBlue(data[i])); + } + else { + rval =3D static_cast(value*rw+(1.0-value)*qRed(data[i])); + gval =3D static_cast(value*gw+(1.0-value)*qGreen(data[i])); + bval =3D static_cast(value*bw+(1.0-value)*qBlue(data[i])); + } + =20 + alpha =3D qAlpha(data[i]); + data[i] =3D qRgba(rval, gval, bval, alpha); + } +} + void KIconEffect::deSaturate(QImage &img, float value) { int pixels =3D (img.depth() > 8) ? img.width()*img.height() Index: kdecore/kiconeffect.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/kde/kdelibs/kdecore/kiconeffect.h,v retrieving revision 1.25 diff -u -p -r1.25 kiconeffect.h =2D-- kdecore/kiconeffect.h 9 Sep 2004 15:23:51 -0000 1.25 +++ kdecore/kiconeffect.h 28 Nov 2004 12:27:57 -0000 @@ -52,8 +52,9 @@ public: * @li Colorize: Tints the icon with an other color * @li ToGamma: Change the gamma value of the icon * @li DeSaturate: Reduce the saturation of the icon + * @li ToMonochrome: Produces a monochrome icon */ =2D enum Effects { NoEffect, ToGray, Colorize, ToGamma, DeSaturate, Last= Effect }; + enum Effects { NoEffect, ToGray, Colorize, ToGamma, DeSaturate, ToMono= chrome, LastEffect }; =20 /** * Rereads configuration. @@ -102,6 +103,7 @@ public: */ // KDE4: make them references QImage apply(QImage src, int effect, float value, const QColor rgb, bo= ol trans) const; + QImage apply(QImage src, int effect, float value, const QColor rgb, co= nst QColor rgb2, bool trans) const; =20 /** * Applies an effect to a pixmap. @@ -122,6 +124,7 @@ public: * @return A pixmap with the effect applied. */ QPixmap apply(QPixmap src, int effect, float value, const QColor rgb, = bool trans) const; + QPixmap apply(QPixmap src, int effect, float value, const QColor rgb, = const QColor rgb2, bool trans) const; =20 /** * Returns an image twice as large, consisting of 2x2 pixels. @@ -162,6 +165,16 @@ public: static void colorize(QImage &image, const QColor &col, float value); =20 /** + * Produces a monochrome icon with a given foreground and background c= olor + * + * @param image The image + * @param white The color with which the white parts of @p image are p= ainted + * @param black The color with which the black parts of @p image are p= ainted + * @param value Strength of the effect. 0 <=3D @p value <=3D 1 + */ + static void toMonochrome(QImage &image, const QColor &black, const QCo= lor &white, float value); + + /** * Desaturates an image. * * @param image The image --Boundary-01=_LIdqBGoBJhCnSwa Content-Type: text/x-diff; charset="utf-8"; name="kdebase2.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="kdebase2.diff" Index: kcontrol/icons/icons.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/kde/kdebase/kcontrol/icons/icons.cpp,v retrieving revision 1.37 diff -u -p -r1.37 icons.cpp =2D-- kcontrol/icons/icons.cpp 22 Oct 2004 19:11:15 -0000 1.37 +++ kcontrol/icons/icons.cpp 25 Nov 2004 13:18:55 -0000 @@ -163,6 +163,9 @@ void KIconConfig::initDefaults() mDefaultEffect[0].color =3D QColor(144,128,248); mDefaultEffect[1].color =3D QColor(169,156,255); mDefaultEffect[2].color =3D QColor(34,202,0); + mDefaultEffect[0].color2 =3D QColor(0,0,0); + mDefaultEffect[1].color2 =3D QColor(0,0,0); + mDefaultEffect[2].color2 =3D QColor(0,0,0); =20 const int defDefSizes[] =3D { 32, 22, 22, 16, 32 }; =20 @@ -250,12 +253,15 @@ void KIconConfig::read() effect =3D KIconEffect::ToGamma; else if (tmp =3D=3D "desaturate") effect =3D KIconEffect::DeSaturate; + else if (tmp =3D=3D "tomonochrome") + effect =3D KIconEffect::ToMonochrome; else if (tmp =3D=3D "none") effect =3D KIconEffect::NoEffect; else continue; mEffects[i][j].type =3D effect; mEffects[i][j].value =3D mpConfig->readDoubleNumEntry(*it2 + "Value"); mEffects[i][j].color =3D mpConfig->readColorEntry(*it2 + "Color"); + mEffects[i][j].color2 =3D mpConfig->readColorEntry(*it2 + "Color2"); mEffects[i][j].transparant =3D mpConfig->readBoolEntry(*it2 + "SemiTr= ansparent"); } } @@ -309,7 +315,7 @@ void KIconConfig::preview(int i) Effect &effect =3D mEffects[viewedGroup][i]; =20 img =3D mpEffect->apply(img, effect.type, =2D effect.value, effect.color, effect.transparant); + effect.value, effect.color, effect.color2, effect.transparant); pm.convertFromImage(img); mpPreview[i]->setPixmap(pm); } @@ -359,6 +365,9 @@ void KIconConfig::save() case KIconEffect::DeSaturate: tmp =3D "desaturate"; break; + case KIconEffect::ToMonochrome: + tmp =3D "tomonochrome"; + break; default: tmp =3D "none"; break; @@ -366,6 +375,7 @@ void KIconConfig::save() mpConfig->writeEntry(*it2 + "Effect", tmp, true, true); mpConfig->writeEntry(*it2 + "Value", mEffects[i][j].value, true, true= ); mpConfig->writeEntry(*it2 + "Color", mEffects[i][j].color, tru= e, true); + mpConfig->writeEntry(*it2 + "Color2", mEffects[i][j].color2, t= rue, true); mpConfig->writeEntry(*it2 + "SemiTransparent", mEffects[i][j].= transparant, true, true); } } @@ -526,6 +536,7 @@ KIconEffectSetupDialog::KIconEffectSetup mpEffectBox->insertItem(i18n("Colorize")); mpEffectBox->insertItem(i18n("Gamma")); mpEffectBox->insertItem(i18n("Desaturate")); + mpEffectBox->insertItem(i18n("To Monochrome")); mpEffectBox->setMinimumWidth( 100 ); connect(mpEffectBox, SIGNAL(highlighted(int)), SLOT(slotEffectType(int= ))); top->addMultiCellWidget(mpEffectBox, 1, 2, 0, 0, Qt::AlignLeft); @@ -566,6 +577,14 @@ KIconEffectSetupDialog::KIconEffectSetup SLOT(slotEffectColor(const QColor &))); grid->addWidget(mpEColButton, 2, 1); =20 + mpEffectColor2 =3D new QLabel(i18n("&Second color:"), mpEffectGroup); + grid->addWidget(mpEffectColor2, 3, 0); + mpECol2Button =3D new KColorButton(mpEffectGroup); + mpEffectColor->setBuddy( mpECol2Button ); + connect(mpECol2Button, SIGNAL(changed(const QColor &)), + SLOT(slotEffectColor2(const QColor &))); + grid->addWidget(mpECol2Button, 3, 1); + init(); preview(); } @@ -579,9 +598,11 @@ void KIconEffectSetupDialog::init() { mpEffectBox->setCurrentItem(mEffect.type); mpEffectSlider->setEnabled(mEffect.type !=3D KIconEffect::NoEffect); =2D mpEColButton->setEnabled(mEffect.type =3D=3D KIconEffect::Colorize); + mpEColButton->setEnabled(mEffect.type =3D=3D KIconEffect::Colorize || = mEffect.type =3D=3D KIconEffect::ToMonochrome); + mpECol2Button->setEnabled(mEffect.type =3D=3D KIconEffect::ToMonochrom= e); mpEffectSlider->setValue((int) (100.0 * mEffect.value + 0.5)); mpEColButton->setColor(mEffect.color); + mpECol2Button->setColor(mEffect.color2); mpSTCheck->setChecked(mEffect.transparant); } =20 @@ -597,13 +618,21 @@ void KIconEffectSetupDialog::slotEffectC preview(); } =20 +void KIconEffectSetupDialog::slotEffectColor2(const QColor &col) +{ + mEffect.color2 =3D col; + preview(); +} + void KIconEffectSetupDialog::slotEffectType(int type) { mEffect.type =3D type; mpEffectGroup->setEnabled(mEffect.type !=3D KIconEffect::NoEffect); mpEffectSlider->setEnabled(mEffect.type !=3D KIconEffect::NoEffect); =2D mpEffectColor->setEnabled(mEffect.type =3D=3D KIconEffect::Colorize); =2D mpEColButton->setEnabled(mEffect.type =3D=3D KIconEffect::Colorize); + mpEffectColor->setEnabled(mEffect.type =3D=3D KIconEffect::Colorize ||= mEffect.type =3D=3D KIconEffect::ToMonochrome); + mpEColButton->setEnabled(mEffect.type =3D=3D KIconEffect::Colorize || = mEffect.type =3D=3D KIconEffect::ToMonochrome); + mpEffectColor2->setEnabled(mEffect.type =3D=3D KIconEffect::ToMonochro= me); + mpECol2Button->setEnabled(mEffect.type =3D=3D KIconEffect::ToMonochrom= e); preview(); } =20 @@ -625,7 +654,7 @@ void KIconEffectSetupDialog::preview() QPixmap pm; QImage img =3D mExample.copy(); img =3D mpEffect->apply(img, mEffect.type, =2D mEffect.value, mEffect.color, mEffect.transparant); + mEffect.value, mEffect.color, mEffect.color2, mEffect.transparan= t); pm.convertFromImage(img); mpPreview->setPixmap(pm); } Index: kcontrol/icons/icons.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/kde/kdebase/kcontrol/icons/icons.h,v retrieving revision 1.13 diff -u -p -r1.13 icons.h =2D-- kcontrol/icons/icons.h 22 Oct 2004 19:11:15 -0000 1.13 +++ kcontrol/icons/icons.h 25 Nov 2004 13:18:55 -0000 @@ -44,6 +44,7 @@ struct Effect=20 int type; float value; QColor color; + QColor color2; bool transparant; }; =20 @@ -128,6 +129,7 @@ protected: protected slots: void slotEffectValue(int value); void slotEffectColor(const QColor &col); + void slotEffectColor2(const QColor &col); void slotEffectType(int type); void slotSTCheck(bool b); void slotDefault(); @@ -138,11 +140,12 @@ private: QCheckBox *mpSTCheck; QSlider *mpEffectSlider; KColorButton *mpEColButton; + KColorButton *mpECol2Button; Effect mEffect; Effect mDefaultEffect; QImage mExample; QGroupBox *mpEffectGroup; =2D QLabel *mpPreview, *mpEffectLabel, *mpEffectColor; + QLabel *mpPreview, *mpEffectLabel, *mpEffectColor, *mpEffectColor2; }; =20 =20 #endif --Boundary-01=_LIdqBGoBJhCnSwa-- --nextPart1280351.ZfkO4lMfac Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) iD8DBQBBqdISsxZ93p+gHn4RAkJuAKDqmP/MWDeI1vrWvUBdmsf5RpfBAACcCBpZ dzK9xejMNzvigsCYX86t430= =7rX1 -----END PGP SIGNATURE----- --nextPart1280351.ZfkO4lMfac--