|
|
|
|
@ -173,10 +173,10 @@ namespace Breeze |
|
|
|
|
connect(client().data(), &KDecoration2::DecoratedClient::maximizedChanged, this, &Decoration::updateTitleBar); |
|
|
|
|
connect(client().data(), &KDecoration2::DecoratedClient::maximizedChanged, this, &Decoration::setOpaque); |
|
|
|
|
|
|
|
|
|
connect(client().data(), &KDecoration2::DecoratedClient::widthChanged, this, &Decoration::updateButtonPositions); |
|
|
|
|
connect(client().data(), &KDecoration2::DecoratedClient::maximizedChanged, this, &Decoration::updateButtonPositions); |
|
|
|
|
connect(client().data(), &KDecoration2::DecoratedClient::widthChanged, this, &Decoration::updateButtonsGeometry); |
|
|
|
|
connect(client().data(), &KDecoration2::DecoratedClient::maximizedChanged, this, &Decoration::updateButtonsGeometry); |
|
|
|
|
connect(client().data(), &KDecoration2::DecoratedClient::shadedChanged, this, &Decoration::recalculateBorders); |
|
|
|
|
connect(client().data(), &KDecoration2::DecoratedClient::shadedChanged, this, &Decoration::updateButtonPositions); |
|
|
|
|
connect(client().data(), &KDecoration2::DecoratedClient::shadedChanged, this, &Decoration::updateButtonsGeometry); |
|
|
|
|
|
|
|
|
|
createButtons(); |
|
|
|
|
createShadow(); |
|
|
|
|
@ -284,10 +284,10 @@ namespace Breeze |
|
|
|
|
// padding below
|
|
|
|
|
// extra pixel is used for the active window outline
|
|
|
|
|
const int baseSize = settings()->smallSpacing(); |
|
|
|
|
top += baseSize*Metrics::TitleBar_TopMargin + 1; |
|
|
|
|
top += baseSize*Metrics::TitleBar_BottomMargin + 1; |
|
|
|
|
|
|
|
|
|
// padding above
|
|
|
|
|
if (!isMaximized()) top += baseSize*TitleBar_BottomMargin; |
|
|
|
|
top += baseSize*TitleBar_TopMargin; |
|
|
|
|
|
|
|
|
|
int bottom = isMaximizedVertically() || c->isShaded() || edges.testFlag(Qt::BottomEdge) ? 0 : borderSize(true); |
|
|
|
|
setBorders(QMargins(left, top, right, bottom)); |
|
|
|
|
@ -315,14 +315,26 @@ namespace Breeze |
|
|
|
|
{ |
|
|
|
|
m_leftButtons = new KDecoration2::DecorationButtonGroup(KDecoration2::DecorationButtonGroup::Position::Left, this, &Button::create); |
|
|
|
|
m_rightButtons = new KDecoration2::DecorationButtonGroup(KDecoration2::DecorationButtonGroup::Position::Right, this, &Button::create); |
|
|
|
|
updateButtonPositions(); |
|
|
|
|
updateButtonsGeometry(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//________________________________________________________________
|
|
|
|
|
void Decoration::updateButtonPositions() |
|
|
|
|
void Decoration::updateButtonsGeometry() |
|
|
|
|
{ |
|
|
|
|
auto s = settings(); |
|
|
|
|
const int vPadding = (isMaximized() ? 0 : s->smallSpacing()*Metrics::TitleBar_TopMargin) + (captionHeight()-buttonHeight())/2; |
|
|
|
|
|
|
|
|
|
// adjust button position
|
|
|
|
|
const int bHeight = captionHeight() + (isMaximized() ? s->smallSpacing()*Metrics::TitleBar_TopMargin:0); |
|
|
|
|
const int bWidth = buttonHeight(); |
|
|
|
|
const int verticalOffset = (isMaximized() ? s->smallSpacing()*Metrics::TitleBar_TopMargin:0) + (captionHeight()-buttonHeight())/2; |
|
|
|
|
foreach( const QPointer<KDecoration2::DecorationButton>& button, m_leftButtons->buttons() + m_rightButtons->buttons() ) |
|
|
|
|
{ |
|
|
|
|
button.data()->setGeometry( QRectF( QPoint( 0, 0 ), QSizeF( bWidth, bHeight ) ) ); |
|
|
|
|
static_cast<Button*>( button.data() )->setVerticalOffset( verticalOffset ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// adjust buttons position
|
|
|
|
|
const int vPadding = isMaximized() ? 0 : s->smallSpacing()*Metrics::TitleBar_TopMargin; |
|
|
|
|
const int hPadding = isMaximized() ? 0 : s->smallSpacing()*Metrics::TitleBar_SideMargin; |
|
|
|
|
|
|
|
|
|
m_rightButtons->setSpacing(s->smallSpacing()*Metrics::TitleBar_ButtonSpacing); |
|
|
|
|
@ -430,19 +442,14 @@ namespace Breeze |
|
|
|
|
|
|
|
|
|
//________________________________________________________________
|
|
|
|
|
int Decoration::captionHeight() const |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
return isMaximized() ? |
|
|
|
|
borderTop() - settings()->smallSpacing()*Metrics::TitleBar_BottomMargin - 1: |
|
|
|
|
borderTop() - settings()->smallSpacing()*(Metrics::TitleBar_BottomMargin + Metrics::TitleBar_TopMargin ) - 1; |
|
|
|
|
} |
|
|
|
|
{ return borderTop() - settings()->smallSpacing()*(Metrics::TitleBar_BottomMargin + Metrics::TitleBar_TopMargin ) - 1; } |
|
|
|
|
|
|
|
|
|
//________________________________________________________________
|
|
|
|
|
QRect Decoration::captionRect() const |
|
|
|
|
{ |
|
|
|
|
const int leftOffset = m_leftButtons->geometry().x() + m_leftButtons->geometry().width() + Metrics::TitleBar_SideMargin*settings()->smallSpacing(); |
|
|
|
|
const int rightOffset = size().width() - m_rightButtons->geometry().x() + Metrics::TitleBar_SideMargin*settings()->smallSpacing(); |
|
|
|
|
const int yOffset = isMaximized() ? 0 : settings()->smallSpacing()*Metrics::TitleBar_TopMargin; |
|
|
|
|
const int yOffset = settings()->smallSpacing()*Metrics::TitleBar_TopMargin; |
|
|
|
|
|
|
|
|
|
QRect boundingRect( settings()->fontMetrics().boundingRect( client().data()->caption()).toRect() ); |
|
|
|
|
boundingRect.setTop( yOffset ); |
|
|
|
|
|