[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Re: [PATCH] KTip
From: Daniel Molkentin <daniel.molkentin () s2002 ! tu-chemnitz ! de>
Date: 2002-10-21 15:08:29
[Download RAW message or body]
grml...
["ktip.diff" (text/x-diff)]
--- ktip.cpp· Tue Jul 9 00:26:31 2002
+++ ktip.diff· Mon Oct 21 10:30:26 2002
@@ -174,6 +174,18 @@
_tipText->mimeSourceFactory()->addFilePath(KGlobal::dirs()->findResourceDir("data", \
"kdewizard/pics")+"kdewizard/pics/"); _tipText->setFrameStyle(QFrame::NoFrame | \
QFrame::Plain); _tipText->setHScrollBarMode(QScrollView::AlwaysOff);
+ _tipText->setLinkUnderline(false);
+
+ QStyleSheet *sheet = _tipText->styleSheet();
+ QStyleSheetItem *item = sheet->item("a");
+ item->setFontWeight(QFont::Bold);
+ _tipText->setStyleSheet(sheet);
+ QPalette pal = _tipText->palette();
+ QColorGroup cg = pal.active();
+ cg.setColor(QColorGroup::Link, QColor(49, 121, 172));
+ pal.setActive(cg);
+ _tipText->setPalette(pal);
+
QStringList icons = KGlobal::dirs()->resourceDirs("icon");
QStringList::Iterator it;
for (it = icons.begin(); it != icons.end(); ++it)
["ktipstyledep.diff" (text/x-diff)]
--- ktip.cpp· Tue Jul 9 00:26:31 2002
+++ ktip.styledep· Mon Oct 21 10:32:16 2002
@@ -29,6 +29,7 @@
#include <qlayout.h>
#include <qpushbutton.h>
#include <qtextstream.h>
+#include <qimage.h>
·
#include <kaboutdata.h>
#include <kapplication.h>
@@ -43,6 +44,8 @@
#include <kstandarddirs.h>
#include <kstdguiitem.h>
#include <ktextbrowser.h>
+#include <kimageeffect.h>
+#include <kglobalsettings.h>
·
#include "ktip.h"
·
@@ -127,6 +132,35 @@
KTipDialog::KTipDialog(KTipDatabase *db, QWidget *parent, const char *name)
: KDialog(parent, name)
{
+ /**
+ * Parent is 0L when TipDialog is used as a mainWidget. This should
+ * be the case only in ktip, so let's use the ktip layout.
+ */
+ bool isTipDialog = (parent != 0);
+·
+· QImage img;
+·
+ if (!isTipDialog)
+ {
+· int r,g,b;
+· _picColor = KGlobalSettings::activeTitleColor();
+· img = QImage(locate("data", "kdewizard/pics/wizard_small.png"));
+· // grep for the first pixel and look try to tint
+· uchar *bits = img.bits();
+· KGlobalSettings::activeTitleColor().rgb(&r,&g,&b);
+· r += (uint)((bits[0]-r)*0.5);
+· g += (uint)((bits[1]-g)*0.5);
+· b += (uint)((bits[2]-b)*0.5);
+· // ignore Alpha Channel
+
+· _blendedColor = QColor(r,g,b);
+ }
+ else
+· _blendedColor = KGlobalSettings::activeTitleColor();
+
+ _baseColor = KGlobalSettings::alternateBackgroundColor();
+ _textColor = KGlobalSettings::textColor();
+·
_database = db;
·
setCaption(i18n("Tip of the Day"));
@@ -134,25 +168,19 @@
·
QVBoxLayout *vbox = new QVBoxLayout(this, marginHint(), spacingHint());
·
- /**
- * Parent is 0L when TipDialog is used as a mainWidget. This should
- * be the case only in ktip, so let's use the ktip layout.
- */
- bool isTipDialog = (parent != 0);
-
- if (isTipDialog)
+ if (isTipDialog)
{
· QHBoxLayout *pl = new QHBoxLayout(vbox, 0, 0);
·
· QLabel *bulb = new QLabel(this);
- bulb->setPixmap(locate("data", "kdeui/pics/ktip-bulb.png"));
+· bulb->setPixmap(locate("data", "kdeui/pics/ktip-bulb.png"));
· pl->addWidget(bulb);
·
- QLabel *titlePane = new QLabel(this);
+· QLabel *titlePane = new QLabel(this);
· titlePane->setBackgroundPixmap(locate("data", \
"kdeui/pics/ktip-background.png"));
- titlePane->setText(i18n("Did you know...?\n"));
-· titlePane->setFont(QFont(KGlobalSettings::generalFont().family(), 20, \
QFont::Bold));
- titlePane->setAlignment(QLabel::AlignCenter);
+· titlePane->setText(i18n("Did you know...?\n"));
+· titlePane->setFont(QFont(KGlobalSettings::generalFont().family(), 20, \
QFont::Bold)); +· titlePane->setAlignment(QLabel::AlignCenter);
· pl->addWidget(titlePane, 100);
}
·
@@ -163,17 +191,34 @@
·
QHBox *tl = new QHBox(hbox);
tl->setMargin(7);
- tl->setBackgroundColor(QColor(49, 121, 172));
+ tl->setBackgroundColor(_blendedColor);
·
QHBox *topLeft = new QHBox(tl);
topLeft->setMargin(15);
- QColor bgColor(213, 222, 238);
- topLeft->setBackgroundColor(bgColor);
+ topLeft->setBackgroundColor(_baseColor);
·
_tipText = new KTextBrowser(topLeft);
- _tipText->mimeSourceFactory()->addFilePath(KGlobal::dirs()->findResourceDir("data", \
"kdewizard/pics")+"kdewizard/pics/"); +····
+ _tipText->mimeSourceFactory()->addFilePath(
+· KGlobal::dirs()->findResourceDir("data", \
"kdewizard/pics")+"kdewizard/pics/"); _tipText->setFrameStyle(QFrame::NoFrame | \
QFrame::Plain); _tipText->setHScrollBarMode(QScrollView::AlwaysOff);
+ _tipText->setLinkUnderline(false);
+
+ QStyleSheet *sheet = _tipText->styleSheet();
+ QStyleSheetItem *item = sheet->item("a");
+ item->setFontWeight(QFont::Bold);
+ _tipText->setStyleSheet(sheet);
+ QPalette pal = _tipText->palette();
+ QColorGroup cg = pal.active();
+ cg.setColor(QColorGroup::Link, _blendedColor);
+ pal.setActive(cg);
+· cg = pal.inactive();
+ cg.setColor(QColorGroup::Link, _blendedColor);
+· pal.setInactive(cg);
+ pal.setActive(cg);
+ _tipText->setPalette(pal);
+
QStringList icons = KGlobal::dirs()->resourceDirs("icon");
QStringList::Iterator it;
for (it = icons.begin(); it != icons.end(); ++it)
@@ -181,16 +226,17 @@
·
if (!isTipDialog)
{
- QLabel *l = new QLabel(hbox);
-· l->setPixmap(locate("data", "kdewizard/pics/wizard_small.png"));
- l->setBackgroundColor(QColor(49, 121, 172));
+· QLabel *l = new QLabel(hbox);
+· KImageEffect::blend(_picColor, img, 0.5);
+· l->setPixmap(img);
+· l->setBackgroundColor(_blendedColor);
· l->setAlignment(Qt::AlignRight | Qt::AlignBottom);
·
· resize(550, 230);
QSize sh = size();
· QRect rect = KApplication::desktop()->screenGeometry();
move(rect.x() + (rect.width() - sh.width())/2,
-· · rect.y() + (rect.height() - sh.height())/2);
+· rect.y() + (rect.height() - sh.height())/2);
}
·
KSeparator* sep = new KSeparator( KSeparator::HLine, this);
@@ -254,13 +300,20 @@
void KTipDialog::prevTip()
{
_database->prevTip();
- _tipText->setText(QString::fromLatin1("<qt text=\"%1\" \
bgcolor=\"%2\">%3</qt>").arg(QColor(0, 0, 0).name()).arg(QColor(213, 222, \
238).name()).arg(i18n(_database->tip().utf8()))); + \
_tipText->setText(QString::fromLatin1( +· "<qt text=\"%1\" \
bgcolor=\"%2\">%3</qt>") +· .arg(_textColor.name())
+· .arg(_baseColor.name())
+· .arg(i18n(_database->tip().utf8())));
}
·
void KTipDialog::nextTip()
{
_database->nextTip();
- _tipText->setText(QString::fromLatin1("<qt text=\"%1\" \
bgcolor=\"%2\">%3</qt>").arg(QColor(0, 0, 0).name()).arg(QColor(213, 222, \
238).name()).arg(i18n(_database->tip().utf8()))); + \
_tipText->setText(QString::fromLatin1("<qt text=\"%1\" bgcolor=\"%2\">%3</qt>") +· \
· · .arg(_textColor.name()) +· · · \
.arg(_baseColor.name()) +· · · .arg(i18n(_database->tip().utf8())));
}
·
void KTipDialog::showOnStart(bool on)
["wizard_small.png" (image/png)]
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic