Skip to content

Commit edce605

Browse files
authored
Merge pull request #292 from Bali10050/feature
Feature
2 parents b37438a + f4c6dde commit edce605

File tree

3 files changed

+41
-7
lines changed

3 files changed

+41
-7
lines changed

kdecoration/darklybutton.cpp

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ void Button::paint(QPainter *painter, const QRectF &repaintRegion)
154154
//__________________________________________________________________
155155
void Button::drawIcon(QPainter *painter) const
156156
{
157+
auto d = qobject_cast<Decoration *>(decoration());
157158
painter->setRenderHints(QPainter::Antialiasing);
158159

159160
/*
@@ -166,7 +167,9 @@ void Button::drawIcon(QPainter *painter) const
166167

167168
const qreal width(rect.width());
168169
painter->scale(width / 20, width / 20);
169-
painter->translate(1, 1);
170+
auto c = decoration()->window();
171+
if ( (c && c->isMaximized()) && d->internalSettings()->floatingTitlebar() ) painter->translate(1, 2);
172+
else painter->translate(1, 1);
170173

171174
// render background
172175
const QColor backgroundColor(this->backgroundColor());
@@ -223,7 +226,6 @@ void Button::drawIcon(QPainter *painter) const
223226

224227
// center dot
225228
QColor backgroundColor(this->backgroundColor());
226-
auto d = qobject_cast<Decoration *>(decoration());
227229
if (!backgroundColor.isValid() && d) {
228230
backgroundColor = d->titleBarColor();
229231
}
@@ -270,6 +272,28 @@ void Button::drawIcon(QPainter *painter) const
270272
break;
271273
}
272274

275+
case DecorationButtonType::ExcludeFromCapture: {
276+
// A spy hat (like view-private.svg icon)
277+
const qreal cx = 9, cy = 9;
278+
// Hat crown with dip/crease at top (filled)
279+
std::array crownPoints{QPointF(cx - 4.1, cy - 2.5),
280+
QPointF(cx - 3.2, cy - 6.1),
281+
QPointF(cx, cy - 5),
282+
QPointF(cx + 3.2, cy - 6.1),
283+
QPointF(cx + 4.1, cy - 2.5)};
284+
painter->setBrush(pen.color());
285+
painter->drawPolygon(crownPoints.data(), crownPoints.size());
286+
painter->setBrush(Qt::NoBrush);
287+
// Hat brim
288+
painter->drawLine(QPointF(cx - 6.2, cy - 0.5), QPointF(cx + 6.2, cy - 0.5));
289+
// Glasses' lenses
290+
painter->drawEllipse(QPointF(cx - 4, cy + 3.8), 2.3, 2.3);
291+
painter->drawEllipse(QPointF(cx + 4, cy + 3.8), 2.3, 2.3);
292+
// Bridge between lenses
293+
painter->drawLine(QPointF(cx - 1.5, cy + 3.8), QPointF(cx + 1.5, cy + 3.8));
294+
break;
295+
}
296+
273297
case DecorationButtonType::ApplicationMenu: {
274298
painter->drawRect(QRectF(3.5, 4.5, 11, 1));
275299
painter->drawRect(QRectF(3.5, 8.5, 11, 1));
@@ -308,7 +332,8 @@ QColor Button::foregroundColor() const
308332
} else if (type() == DecorationButtonType::Close && d->internalSettings()->outlineCloseButton()) {
309333
return d->titleBarColor();
310334

311-
} else if ((type() == DecorationButtonType::KeepBelow || type() == DecorationButtonType::KeepAbove || type() == DecorationButtonType::Shade)
335+
} else if ((type() == DecorationButtonType::KeepBelow || type() == DecorationButtonType::KeepAbove || type() == DecorationButtonType::Shade
336+
|| type() == DecorationButtonType::ExcludeFromCapture)
312337
&& isChecked()) {
313338
return d->titleBarColor();
314339

@@ -341,7 +366,8 @@ QColor Button::backgroundColor() const
341366
} else if ((type() == DecorationButtonType::KeepBelow || type() == DecorationButtonType::KeepAbove || type() == DecorationButtonType::Shade)
342367
&& isChecked()) {
343368
return d->fontColor();
344-
369+
} else if (type() == DecorationButtonType::ExcludeFromCapture && isChecked()) {
370+
return c->color(ColorGroup::Warning, ColorRole::Foreground);
345371
} else if (m_animation->state() == QAbstractAnimation::Running) {
346372
if (type() == DecorationButtonType::Close) {
347373
if (d->internalSettings()->outlineCloseButton()) {

kdecoration/darklydecoration.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ if (m_internalSettings->floatingTitlebar()){
674674
auto btn = static_cast<Button *>(button);
675675

676676
// vertical offset reduced to move buttons up
677-
const int verticalOffset = (isTopEdge() ? s->smallSpacing() * Metrics::TitleBar_TopMargin : 0) + 1;
677+
const int verticalOffset = (isTopEdge() ? s->smallSpacing() * Metrics::TitleBar_TopMargin : 0) + (isMaximized() ? 0 : 1);
678678

679679
const QSizeF preferredSize = btn->preferredSize();
680680
const int bHeight = preferredSize.height() + verticalOffset;
@@ -692,7 +692,7 @@ if (m_internalSettings->floatingTitlebar()){
692692
m_leftButtons->setSpacing(s->smallSpacing() * Metrics::TitleBar_ButtonSpacing);
693693

694694
// padding
695-
const int vPadding = (isTopEdge() ? 0 : s->smallSpacing() * Metrics::TitleBar_TopMargin) + 1;
695+
int vPadding = (isTopEdge() ? 0 : s->smallSpacing() * Metrics::TitleBar_TopMargin) + (isMaximized() ? 0 : 1);
696696
const int hPadding = s->smallSpacing() * Metrics::TitleBar_SideMargin;
697697

698698
if (isLeftEdge()) {
@@ -719,7 +719,7 @@ if (m_internalSettings->floatingTitlebar()){
719719
m_rightButtons->setSpacing(s->smallSpacing() * Metrics::TitleBar_ButtonSpacing);
720720

721721
// padding
722-
const int vPadding = (isTopEdge() ? 0 : s->smallSpacing() * Metrics::TitleBar_TopMargin) + 1;
722+
int vPadding = (isTopEdge() ? 0 : s->smallSpacing() * Metrics::TitleBar_TopMargin) + (isMaximized() ? 0 : 1);
723723
const int hPadding = s->smallSpacing() * Metrics::TitleBar_SideMargin;
724724

725725
if (isRightEdge()) {

kstyle/darklystyle.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,12 @@ void Style::polish(QWidget *widget)
389389

390390
while (parent) {
391391
if (parent->inherits("KMessageWidget")) {
392+
for (QWidget* p = parent->parentWidget(); p; p = p->parentWidget()) {
393+
if (p->inherits("KateMessageWidget")) {
394+
return;
395+
}
396+
}
397+
392398
if (!parent->property("_darklyRoundedOverlay").isValid())
393399
{
394400
auto overlay = new RoundedOuterOutlineOverlay(parent, _isDolphin, StyleConfigData::cornerRadius(), StyleConfigData::cornerRadius() * 2);
@@ -4401,8 +4407,10 @@ bool Style::drawFrameTabBarBasePrimitive(const QStyleOption *option, QPainter *p
44014407
if (!tabOption)
44024408
return true;
44034409

4410+
if (_isDolphin || _isKonsole){
44044411
QColor backgroundColor = _helper->transparentBarBgColor(widget->palette().color(QPalette::Window), painter, widget->rect(), BarType::TabBar);
44054412
painter->fillRect(widget->rect(), backgroundColor);
4413+
}
44064414

44074415
return true;
44084416
}

0 commit comments

Comments
 (0)