From aef1bff69eb02f44886ba389a1920eb5bab84e73 Mon Sep 17 00:00:00 2001 From: Hugo Pereira Da Costa Date: Wed, 10 Dec 2014 11:00:34 +0100 Subject: [PATCH] renamed breezedeco to breezedecoration to be in par with class name fixed vertical positionning of buttons --- windec/kdecoration2/CMakeLists.txt | 2 +- windec/kdecoration2/breezebutton.cpp | 9 +++++++ windec/kdecoration2/breezebutton.h | 2 +- .../{breezedeco.cpp => breezedecoration.cpp} | 24 +++++++++++-------- .../{breezedeco.h => breezedecoration.h} | 0 5 files changed, 25 insertions(+), 12 deletions(-) rename windec/kdecoration2/{breezedeco.cpp => breezedecoration.cpp} (97%) rename windec/kdecoration2/{breezedeco.h => breezedecoration.h} (100%) diff --git a/windec/kdecoration2/CMakeLists.txt b/windec/kdecoration2/CMakeLists.txt index 679c74d3..c2f77e68 100644 --- a/windec/kdecoration2/CMakeLists.txt +++ b/windec/kdecoration2/CMakeLists.txt @@ -5,7 +5,7 @@ find_package(KF5 REQUIRED COMPONENTS CoreAddons Config) set(breezedecoration_SRCS breezecolorsettings.cpp breezebutton.cpp - breezedeco.cpp + breezedecoration.cpp breezeimageprovider.cpp ) diff --git a/windec/kdecoration2/breezebutton.cpp b/windec/kdecoration2/breezebutton.cpp index f419e04c..932f0519 100644 --- a/windec/kdecoration2/breezebutton.cpp +++ b/windec/kdecoration2/breezebutton.cpp @@ -73,6 +73,15 @@ namespace Breeze if (!decoration()) { return; } + #if 0 + painter->save(); + painter->setPen( Qt::red ); + painter->setBrush( Qt::NoBrush ); + painter->setRenderHints( QPainter::Antialiasing ); + painter->drawRect( QRectF( geometry() ).adjusted( 0.5, 0.5, -0.5, -0.5 ) ); + painter->restore(); + #endif + // TODO: optimize based on repaintRegion if (type() == KDecoration2::DecorationButtonType::Menu) { diff --git a/windec/kdecoration2/breezebutton.h b/windec/kdecoration2/breezebutton.h index 7dd69e88..dbe55ecd 100644 --- a/windec/kdecoration2/breezebutton.h +++ b/windec/kdecoration2/breezebutton.h @@ -21,7 +21,7 @@ * along with this program. If not, see . */ #include -#include "breezedeco.h" +#include "breezedecoration.h" #include #include diff --git a/windec/kdecoration2/breezedeco.cpp b/windec/kdecoration2/breezedecoration.cpp similarity index 97% rename from windec/kdecoration2/breezedeco.cpp rename to windec/kdecoration2/breezedecoration.cpp index 0884d4d3..cdbae75a 100644 --- a/windec/kdecoration2/breezedeco.cpp +++ b/windec/kdecoration2/breezedecoration.cpp @@ -18,7 +18,7 @@ * along with this program. If not, see . */ -#include "breezedeco.h" +#include "breezedecoration.h" #include "breeze.h" @@ -75,6 +75,7 @@ namespace Breeze updateTitleBar(); auto s = settings(); connect(s.data(), &KDecoration2::DecorationSettings::borderSizeChanged, this, &Decoration::recalculateBorders); + // a change in font might cause the borders to change connect(s.data(), &KDecoration2::DecorationSettings::fontChanged, this, &Decoration::recalculateBorders); connect(s.data(), &KDecoration2::DecorationSettings::spacingChanged, this, &Decoration::recalculateBorders); @@ -176,15 +177,21 @@ namespace Breeze int bottom = c->isMaximizedVertically() || edges.testFlag(Qt::BottomEdge) ? 0 : borderSize(s, true); setBorders(QMargins(left, top, right, bottom)); - const int extSize = s->largeSpacing() / 2; + // extended sizes + const int extSize = s->largeSpacing(); int extSides = 0; int extBottom = 0; - if (s->borderSize() == KDecoration2::BorderSize::None) { + if (s->borderSize() == KDecoration2::BorderSize::None) + { extSides = extSize; extBottom = extSize; + } else if (s->borderSize() == KDecoration2::BorderSize::NoSides) { + extSides = extSize; + } + setResizeOnlyBorders(QMargins(extSides, 0, extSides, extBottom)); } @@ -286,19 +293,16 @@ namespace Breeze //________________________________________________________________ int Decoration::captionHeight() const - { - return borderTop() - settings()->smallSpacing() * (client().data()->isMaximized() ? 2 : 3) - 1; - } + { return borderTop() - settings()->smallSpacing() * (client().data()->isMaximized() ? 1 : 2) - 1; } //________________________________________________________________ QRect Decoration::captionRect() const { const int leftOffset = m_leftButtons->geometry().x() + m_leftButtons->geometry().width(); const int rightOffset = size().width() - m_rightButtons->geometry().x(); - const int offset = qMax(leftOffset, rightOffset); const int yOffset = client().data()->isMaximized() ? 0 : settings()->smallSpacing(); - // below is the spacer - return QRect(offset, yOffset, size().width() - offset * 2, captionHeight()); + + return QRect( leftOffset, yOffset, size().width() - rightOffset, captionHeight()); } //________________________________________________________________ @@ -376,4 +380,4 @@ namespace Breeze } // namespace -#include "breezedeco.moc" +#include "breezedecoration.moc" diff --git a/windec/kdecoration2/breezedeco.h b/windec/kdecoration2/breezedecoration.h similarity index 100% rename from windec/kdecoration2/breezedeco.h rename to windec/kdecoration2/breezedecoration.h