From a2d331cc561f7794e2c985eb5936ee5a61d65fd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sun, 23 May 2010 20:45:33 +0000 Subject: [PATCH] Make Aurorae themes with title on left/right somewhat work for shaded windows. svn path=/trunk/KDE/kdebase/workspace/; revision=1129816 --- clients/aurorae/src/lib/auroraescene.cpp | 29 ++++++++++++++++++++++-- clients/aurorae/src/lib/auroraetab.cpp | 15 ++++++------ 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/clients/aurorae/src/lib/auroraescene.cpp b/clients/aurorae/src/lib/auroraescene.cpp index d1eb8c7f3b..e24a78d4ad 100644 --- a/clients/aurorae/src/lib/auroraescene.cpp +++ b/clients/aurorae/src/lib/auroraescene.cpp @@ -332,8 +332,12 @@ void AuroraeScene::updateLayout() const int right = sceneRect().width() - m_rightButtons->preferredWidth() - config.paddingRight(); const qreal titleHeight = qMax((qreal)config.titleHeight(), config.buttonHeight()*m_theme->buttonSizeFactor() + config.buttonMarginTop()); + DecorationPosition decoPos = (DecorationPosition)config.decorationPosition(); + if (isShade()) { + decoPos = DecorationTop; + } if (m_maximizeMode == KDecorationDefines::MaximizeFull) { // TODO: check option - switch ((DecorationPosition)config.decorationPosition()) { + switch (decoPos) { case DecorationTop: { const int top = genericTop + config.titleEdgeTopMaximized(); m_leftButtons->setGeometry(QRectF(QPointF(left + config.titleEdgeLeftMaximized(), top), @@ -393,7 +397,7 @@ void AuroraeScene::updateLayout() } m_title->layout()->invalidate(); } else { - switch ((DecorationPosition)config.decorationPosition()) { + switch (decoPos) { case DecorationTop: { const int top = genericTop + config.titleEdgeTop(); m_leftButtons->setGeometry(QRectF(QPointF(left + config.titleEdgeLeft(), top), m_leftButtons->size())); @@ -734,6 +738,27 @@ void AuroraeScene::setShade(bool shade) } } } + if ((DecorationPosition)m_theme->themeConfig().decorationPosition() != DecorationTop) { + Qt::Orientation orientation = Qt::Horizontal; + switch ((DecorationPosition)m_theme->themeConfig().decorationPosition()) { + case DecorationLeft: // fall through + case DecorationRight: + orientation = Qt::Vertical; + break; + case DecorationTop: // fall through + case DecorationBottom: // fall through + default: // fall through + orientation = Qt::Horizontal; + break; + } + if (m_shade) { + orientation = Qt::Horizontal; + } + static_cast(m_rightButtons->layout())->setOrientation(orientation); + static_cast(m_leftButtons->layout())->setOrientation(orientation); + static_cast(m_title->layout())->setOrientation(orientation); + updateLayout(); + } } int AuroraeScene::leftButtonsWidth() const diff --git a/clients/aurorae/src/lib/auroraetab.cpp b/clients/aurorae/src/lib/auroraetab.cpp index 2a11ff8bda..cab8bed498 100644 --- a/clients/aurorae/src/lib/auroraetab.cpp +++ b/clients/aurorae/src/lib/auroraetab.cpp @@ -94,6 +94,7 @@ void AuroraeTab::paint(QPainter *painter, const QStyleOptionGraphicsItem *option const bool useTabs = (s->tabCount() > 1); const bool focused = s->isFocusedTab(m_index); const ThemeConfig &conf = m_theme->themeConfig(); + const DecorationPosition decoPos = s->isShade() ? DecorationTop : m_theme->decorationPosition(); if (useTabs) { painter->save(); Plasma::FrameSvg *decoration = m_theme->decoration(); @@ -102,8 +103,7 @@ void AuroraeTab::paint(QPainter *painter, const QStyleOptionGraphicsItem *option painter->setPen(color); QPointF point1 = rect().topRight(); QPointF point2 = rect().bottomRight(); - if (m_theme->decorationPosition() == DecorationLeft || - m_theme->decorationPosition() == DecorationRight) { + if (decoPos == DecorationLeft || decoPos == DecorationRight) { point1 = rect().topRight(); point2 = rect().topLeft(); } @@ -144,8 +144,7 @@ void AuroraeTab::paint(QPainter *painter, const QStyleOptionGraphicsItem *option } qreal w = rect().width(); qreal h = rect().height(); - if (m_theme->themeConfig().decorationPosition() == DecorationLeft || - m_theme->themeConfig().decorationPosition() == DecorationRight) { + if (decoPos == DecorationLeft || decoPos == DecorationRight) { h = rect().width(); w = rect().height(); } @@ -159,10 +158,10 @@ void AuroraeTab::paint(QPainter *painter, const QStyleOptionGraphicsItem *option haloRect.setWidth(w); } painter->save(); - if (m_theme->themeConfig().decorationPosition() == DecorationLeft) { + if (decoPos == DecorationLeft) { painter->translate(rect().bottomLeft()); painter->rotate(270); - } else if (m_theme->themeConfig().decorationPosition() == DecorationRight) { + } else if (decoPos == DecorationRight) { painter->translate(rect().topRight()); painter->rotate(90); } @@ -209,10 +208,10 @@ void AuroraeTab::paint(QPainter *painter, const QStyleOptionGraphicsItem *option p.fillRect(r, alphaGradient); } p.end(); - if (m_theme->themeConfig().decorationPosition() == DecorationLeft) { + if (decoPos == DecorationLeft) { painter->translate(rect().bottomLeft()); painter->rotate(270); - } else if (m_theme->themeConfig().decorationPosition() == DecorationRight) { + } else if (decoPos == DecorationRight) { painter->translate(rect().topRight()); painter->rotate(90); }