diff --git a/kdecoration/CMakeLists.txt b/kdecoration/CMakeLists.txt --- a/kdecoration/CMakeLists.txt +++ b/kdecoration/CMakeLists.txt @@ -35,7 +35,8 @@ breezedecoration.cpp breezeexceptionlist.cpp breezesettingsprovider.cpp - breezesizegrip.cpp) + breezesizegrip.cpp + breezetab.cpp) kconfig_add_kcfg_files(breezedecoration_SRCS breezesettings.kcfgc) diff --git a/kdecoration/breeze.json b/kdecoration/breeze.json --- a/kdecoration/breeze.json +++ b/kdecoration/breeze.json @@ -52,7 +52,8 @@ ] }, "org.kde.kdecoration2": { + "WindowTabbing": true, "blur": false, "kcmodule": true } -} \ No newline at end of file +} diff --git a/kdecoration/breezedecoration.h b/kdecoration/breezedecoration.h --- a/kdecoration/breezedecoration.h +++ b/kdecoration/breezedecoration.h @@ -37,6 +37,7 @@ { class DecorationButton; class DecorationButtonGroup; + class DecorationTabGroup; } namespace Breeze @@ -112,6 +113,7 @@ QPair captionRect( void ) const; void createButtons(); + void createTabGroup(); void paintTitleBar(QPainter *painter, const QRect &repaintRegion); void createShadow(); @@ -137,6 +139,7 @@ QList m_buttons; KDecoration2::DecorationButtonGroup *m_leftButtons = nullptr; KDecoration2::DecorationButtonGroup *m_rightButtons = nullptr; + KDecoration2::DecorationTabGroup *m_tab = nullptr; //* size grip widget SizeGrip *m_sizeGrip = nullptr; diff --git a/kdecoration/breezedecoration.cpp b/kdecoration/breezedecoration.cpp --- a/kdecoration/breezedecoration.cpp +++ b/kdecoration/breezedecoration.cpp @@ -28,11 +28,13 @@ #include "breezebutton.h" #include "breezesizegrip.h" +#include "breezetab.h" #include #include #include #include +#include #include #include @@ -208,6 +210,7 @@ connect(c, &KDecoration2::DecoratedClient::shadedChanged, this, &Decoration::updateButtonsGeometry); createButtons(); + createTabGroup(); createShadow(); } @@ -358,6 +361,11 @@ setResizeOnlyBorders(QMargins(extSides, 0, extSides, extBottom)); } + void Decoration::createTabGroup() + { + m_tab = new KDecoration2::DecorationTabGroup(this); + } + //________________________________________________________________ void Decoration::createButtons() { @@ -538,9 +546,26 @@ // draw caption painter->setFont(s->font()); painter->setPen( fontColor() ); - const auto cR = captionRect(); - const QString caption = painter->fontMetrics().elidedText(c->caption(), Qt::ElideMiddle, cR.first.width()); - painter->drawText(cR.first, cR.second | Qt::TextSingleLine, caption); + if (c->tabCount() == 0) { + const auto cR = captionRect(); + const QString caption = painter->fontMetrics().elidedText(c->caption(), Qt::ElideMiddle, cR.first.width()); + painter->drawText(cR.first, cR.second | Qt::TextSingleLine, caption); + } + + if (c->tabCount() > 0) { + QRect tabRect = titleRect; + tabRect.setWidth(tabRect.width() + - m_rightButtons->geometry().width() + - m_leftButtons->geometry().width() + ); + tabRect.setLeft(m_leftButtons->geometry().width() + 2*settings()->largeSpacing()); + tabRect.setHeight(tabRect.height()-Metrics::TitleBar_ButtonSpacing); + m_tab->setGeometry(tabRect); + m_tab->createTabs(&Tab::create); + painter->setBrush(titleBarColor().darker(130)); + m_tab->paint(painter,repaintRegion); + } + // draw all buttons m_leftButtons->paint(painter, repaintRegion); diff --git a/kdecoration/breezetab.h b/kdecoration/breezetab.h new file mode 100644 --- /dev/null +++ b/kdecoration/breezetab.h @@ -0,0 +1,25 @@ +#ifndef BREEZE_TABS_H +#define BREEZE_TABS_H + +#include + +namespace Breeze +{ + + class Tab : public KDecoration2::DecorationTab + { + Q_OBJECT + + public: + explicit Tab(KDecoration2::DecoratedClient *client, QObject *parent); + + virtual ~Tab() = default; + + static Tab *create(KDecoration2::DecoratedClient *client, QObject *parent); + + void paint(QPainter *painter, const QRect &repaintArea) override; + +}; +} // namespace + +#endif diff --git a/kdecoration/breezetab.cpp b/kdecoration/breezetab.cpp new file mode 100644 --- /dev/null +++ b/kdecoration/breezetab.cpp @@ -0,0 +1,40 @@ +#include "breezetab.h" +#include "breeze.h" + +#include + +namespace Breeze +{ + +Tab::Tab(KDecoration2::DecoratedClient *client, QObject *parent) + :DecorationTab(client, parent) +{ +} + +void Tab::paint(QPainter *painter, const QRect &repaintArea) +{ + Q_UNUSED(repaintArea); + QColor fontColor(painter->pen().color()); + if (isActive()) { + painter->setPen(Qt::NoPen); + painter->drawRoundedRect(geometry(), Metrics::Frame_FrameRadius, Metrics::Frame_FrameRadius); + } else { + painter->setPen(painter->brush().color().darker(160)); + QLineF l1(geometry().topLeft(),geometry().bottomLeft()); + painter->drawLine(l1); + QLineF l2(geometry().topRight(),geometry().bottomRight()); + painter->drawLine(l2); + } + painter->setPen(fontColor); + const QString caption = painter->fontMetrics().elidedText(client()->caption(), Qt::ElideMiddle, geometry().width()); + painter->drawText(geometry(), Qt::AlignCenter | Qt::TextSingleLine, caption); +} + +Tab *Tab::create(KDecoration2::DecoratedClient *client, QObject *parent) +{ + Tab *dummyTab = new Tab(client, parent); + return dummyTab; +} + + +}