diff --git a/clients/aurorae/src/aurorae.cpp b/clients/aurorae/src/aurorae.cpp index 6af9533bc1..ba94274d03 100644 --- a/clients/aurorae/src/aurorae.cpp +++ b/clients/aurorae/src/aurorae.cpp @@ -694,12 +694,44 @@ void AuroraeClient::paintEvent(QPaintEvent *event) frame->resizeFrame(rect.size()); frame->paintFrame(&painter, rect, sourceRect); + painter.setFont(options()->font(isActive())); + if (conf.useTextShadow()) { + // shadow code is inspired by Qt FAQ: How can I draw shadows behind text? + // see http://www.qtsoftware.com/developer/faqs/faq.2007-07-27.3052836051 + const ThemeConfig &conf = AuroraeFactory::instance()->themeConfig(); + painter.save(); + if (isActive()) { + painter.setPen(conf.activeTextShadowColor()); + } + else { + painter.setPen(conf.inactiveTextShadowColor()); + } + int dx = conf.textShadowOffsetX(); + int dy = conf.textShadowOffsetY(); + painter.setOpacity(0.5); + painter.drawText(titleRect().translated(dx, dy), + conf.alignment() | conf.verticalAlignment() | Qt::TextSingleLine, + caption()); + painter.setOpacity(0.2); + painter.drawText(titleRect().translated(dx+1, dy), + conf.alignment() | conf.verticalAlignment() | Qt::TextSingleLine, + caption()); + painter.drawText(titleRect().translated(dx-1, dy), + conf.alignment() | conf.verticalAlignment() | Qt::TextSingleLine, + caption()); + painter.drawText(titleRect().translated(dx, dy+1), + conf.alignment() | conf.verticalAlignment() | Qt::TextSingleLine, + caption()); + painter.drawText(titleRect().translated(dx, dy-1), + conf.alignment() | conf.verticalAlignment() | Qt::TextSingleLine, + caption()); + painter.restore(); + } if (isActive()) { painter.setPen(conf.activeTextColor()); } else { painter.setPen(conf.inactiveTextColor()); } - painter.setFont(options()->font(isActive())); painter.drawText(titleRect(), conf.alignment() | conf.verticalAlignment() | Qt::TextSingleLine, caption()); } diff --git a/clients/aurorae/src/config/config.cpp b/clients/aurorae/src/config/config.cpp index 0101edc7ed..b5cdc1540d 100644 --- a/clients/aurorae/src/config/config.cpp +++ b/clients/aurorae/src/config/config.cpp @@ -428,19 +428,51 @@ void ThemeDelegate::paintDeco(QPainter *painter, bool active, const QStyleOption int titleRight = x; // draw text - painter->save(); - if (active) { - painter->setPen(themeConfig->activeTextColor()); - } - else { - painter->setPen(themeConfig->inactiveTextColor()); - } y = option.rect.top() + topMargin + themeConfig->paddingTop() + themeConfig->titleEdgeTop(); QRectF titleRect(QPointF(titleLeft, y), QPointF(titleRight, y + themeConfig->titleHeight())); QString caption = i18n("Active Window"); if (!active) { caption = i18n("Inactive Window"); } + painter->setFont(KGlobalSettings::windowTitleFont()); + if (themeConfig->useTextShadow()) { + // shadow code is inspired by Qt FAQ: How can I draw shadows behind text? + // see http://www.qtsoftware.com/developer/faqs/faq.2007-07-27.3052836051 + painter->save(); + if (active) { + painter->setPen(themeConfig->activeTextShadowColor()); + } + else { + painter->setPen(themeConfig->inactiveTextShadowColor()); + } + int dx = themeConfig->textShadowOffsetX(); + int dy = themeConfig->textShadowOffsetY(); + painter->setOpacity(0.5); + painter->drawText(titleRect.translated(dx, dy), + themeConfig->alignment() | themeConfig->verticalAlignment() | Qt::TextSingleLine, + caption); + painter->setOpacity(0.2); + painter->drawText(titleRect.translated(dx+1, dy), + themeConfig->alignment() | themeConfig->verticalAlignment() | Qt::TextSingleLine, + caption); + painter->drawText(titleRect.translated(dx-1, dy), + themeConfig->alignment() | themeConfig->verticalAlignment() | Qt::TextSingleLine, + caption); + painter->drawText(titleRect.translated(dx, dy+1), + themeConfig->alignment() | themeConfig->verticalAlignment() | Qt::TextSingleLine, + caption); + painter->drawText(titleRect.translated(dx, dy-1), + themeConfig->alignment() | themeConfig->verticalAlignment() | Qt::TextSingleLine, + caption); + painter->restore(); + painter->save(); + } + if (active) { + painter->setPen(themeConfig->activeTextColor()); + } + else { + painter->setPen(themeConfig->inactiveTextColor()); + } painter->drawText(titleRect, themeConfig->alignment() | themeConfig->verticalAlignment() | Qt::TextSingleLine, caption); diff --git a/clients/aurorae/src/themeconfig.cpp b/clients/aurorae/src/themeconfig.cpp index cc5b0f8135..872f3320e6 100644 --- a/clients/aurorae/src/themeconfig.cpp +++ b/clients/aurorae/src/themeconfig.cpp @@ -31,6 +31,11 @@ void ThemeConfig::load(KConfig *conf) KConfigGroup general(conf, "General"); m_activeTextColor = general.readEntry("ActiveTextColor", QColor(Qt::black)); m_inactiveTextColor = general.readEntry("InactiveTextColor", QColor(Qt::black)); + m_useTextShadow = general.readEntry("UseTextShadow", false); + m_activeTextShadowColor = general.readEntry("ActiveTextShadowColor", QColor(Qt::white)); + m_inactiveTextShadowColor = general.readEntry("InactiveTextShadowColor", QColor(Qt::white)); + m_textShadowOffsetX = general.readEntry("TextShadowOffsetX", 0); + m_textShadowOffsetY = general.readEntry("TextShadowOffsetY", 0); QString alignment = (general.readEntry("TitleAlignment", "Left")).toLower(); if (alignment == "left") { m_alignment = Qt::AlignLeft; diff --git a/clients/aurorae/src/themeconfig.h b/clients/aurorae/src/themeconfig.h index 73e52f8130..2cbc706af2 100644 --- a/clients/aurorae/src/themeconfig.h +++ b/clients/aurorae/src/themeconfig.h @@ -40,6 +40,21 @@ public: QColor inactiveTextColor() const { return m_inactiveTextColor; } + QColor activeTextShadowColor() const { + return m_activeTextShadowColor; + } + QColor inactiveTextShadowColor() const { + return m_inactiveTextShadowColor; + } + int textShadowOffsetX() const { + return m_textShadowOffsetX; + } + int textShadowOffsetY() const { + return m_textShadowOffsetY; + } + bool useTextShadow() const { + return m_useTextShadow; + } // Alignment Qt::Alignment alignment() const { return m_alignment; @@ -152,6 +167,11 @@ public: private: QColor m_activeTextColor; QColor m_inactiveTextColor; + QColor m_activeTextShadowColor; + QColor m_inactiveTextShadowColor; + int m_textShadowOffsetX; + int m_textShadowOffsetY; + bool m_useTextShadow; Qt::Alignment m_alignment; Qt::Alignment m_verticalAlignment; // borders diff --git a/clients/aurorae/theme-description b/clients/aurorae/theme-description index 709882ac49..796b94093e 100644 --- a/clients/aurorae/theme-description +++ b/clients/aurorae/theme-description @@ -89,6 +89,11 @@ TitleVerticalAlignment=Center # vertical alignment of window title Animation=0 # animation duration in msec when hovering a button ActiveTextColor=0,0,0,255 # title text color of active window InactiveTextColor=0,0,0,255 # title text color of inactive window +UseTextShadow=false # Draw Shadow behind title text +ActiveTextShadowColor=255,255,255,255 # Shadow text color of active window +InactiveTextShadowColor=255,255,255,255 # Shadow text color of active window +TextShadowOffsetX=0 # Offset of shadow in x direction +TextShadowOffsetY=0 # Offset of shadow in y direction LeftButtons=MS # buttons in left button group (see http://api.kde.org/4.x-api/kdebase-workspace-apidocs/kwin/lib/html/classKDecorationOptions.html#8ad12d76c93c5f1a12ea07b30f92d2fa) RightButtons=HIA__X # buttons in right button group Shadow=true # decoration provides shadows: you have to add padding diff --git a/clients/aurorae/themes/example-deco/example-decorc b/clients/aurorae/themes/example-deco/example-decorc index f29d10f4f7..2c78d9e35e 100644 --- a/clients/aurorae/themes/example-deco/example-decorc +++ b/clients/aurorae/themes/example-deco/example-decorc @@ -1,6 +1,11 @@ [General] ActiveTextColor=0,0,0,255 InactiveTextColor=178,178,178,178 +UseTextShadow=true +ActiveTextShadowColor=178,178,178 +InactiveTextShadowColor=0,0,0,255 +TextShadowOffsetX=1 +TextShadowOffsetY=1 TitleAlignment=Center TitleVerticalAlignment=Bottom Animation=200