summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Martin <[email protected]>2018-03-10 10:57:05 -0500
committerKurt Hindenburg <[email protected]>2018-03-10 10:58:17 -0500
commit2a71f063f8802a88171c87cfb63941317775d3d3 (patch)
treeab7f638cdabc2dea72702b00764ce22a89c98a57
parentb85c469efc606f4777aabc62d637733959dfe664 (diff)
use the terminal color scheme for the scrollbar
Summary: As discussed with VDG, color the scrollbar with the same colors as the terminal color scheme itself. It looks way cleaner and modern Test Plan: tested with several color schemes and several styles Reviewers: #konsole, #vdg, hindenburg Reviewed By: #konsole, #vdg, hindenburg Subscribers: hindenburg, zzag, ngraham Tags: #konsole Differential Revision: https://phabricator.kde.org/D11184
-rw-r--r--src/TerminalDisplay.cpp27
-rw-r--r--src/TerminalDisplay.h2
2 files changed, 26 insertions, 3 deletions
diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp
index 3fcd312..0a9b3cd 100644
--- a/src/TerminalDisplay.cpp
+++ b/src/TerminalDisplay.cpp
@@ -131,6 +131,26 @@ const ColorEntry* TerminalDisplay::colorTable() const
{
return _colorTable;
}
+
+void TerminalDisplay::updateScrollBarPalette()
+{
+ QColor backgroundColor = _colorTable[DEFAULT_BACK_COLOR];
+ backgroundColor.setAlphaF(_opacity);
+ QPalette p = palette();
+ p.setColor(QPalette::Window, backgroundColor);
+
+ //this is a workaround to add some readability to old themes like Fusion
+ //changing the light value for button a bit makes themes like fusion, windows and oxygen way more readable and pleasing
+ QColor buttonColor;
+ buttonColor.setHsvF(backgroundColor.hueF(), backgroundColor.saturationF(), backgroundColor.valueF() + (backgroundColor.valueF() < 0.5 ? 0.2 : -0.2));
+ p.setColor(QPalette::Button, buttonColor);
+
+ p.setColor(QPalette::WindowText, _colorTable[DEFAULT_FORE_COLOR]);
+ p.setColor(QPalette::ButtonText, _colorTable[DEFAULT_FORE_COLOR]);
+ _scrollBar->setPalette(p);
+
+}
+
void TerminalDisplay::setBackgroundColor(const QColor& color)
{
_colorTable[DEFAULT_BACK_COLOR] = color;
@@ -139,9 +159,7 @@ void TerminalDisplay::setBackgroundColor(const QColor& color)
p.setColor(backgroundRole(), color);
setPalette(p);
- // Avoid propagating the palette change to the scroll bar
- _scrollBar->setPalette(QApplication::palette());
-
+ updateScrollBarPalette();
update();
}
QColor TerminalDisplay::getBackgroundColor() const
@@ -153,6 +171,7 @@ void TerminalDisplay::setForegroundColor(const QColor& color)
{
_colorTable[DEFAULT_FORE_COLOR] = color;
+ updateScrollBarPalette();
update();
}
void TerminalDisplay::setColorTable(const ColorEntry table[])
@@ -399,6 +418,7 @@ TerminalDisplay::TerminalDisplay(QWidget* parent)
// create scroll bar for scrolling output up and down
_scrollBar = new QScrollBar(this);
+ _scrollBar->setAutoFillBackground(false);
// set the scroll bar's slider to occupy the whole area of the scroll bar initially
setScroll(0, 0);
_scrollBar->setCursor(Qt::ArrowCursor);
@@ -755,6 +775,7 @@ void TerminalDisplay::setOpacity(qreal opacity)
}*/
_blendColor = color.rgba();
+ updateScrollBarPalette();
}
void TerminalDisplay::setWallpaper(ColorSchemeWallpaper::Ptr p)
diff --git a/src/TerminalDisplay.h b/src/TerminalDisplay.h
index 69a208e..112546a 100644
--- a/src/TerminalDisplay.h
+++ b/src/TerminalDisplay.h
@@ -757,6 +757,8 @@ protected:
void inputMethodEvent(QInputMethodEvent *event) Q_DECL_OVERRIDE;
QVariant inputMethodQuery(Qt::InputMethodQuery query) const Q_DECL_OVERRIDE;
+ void updateScrollBarPalette();
+
protected Q_SLOTS:
void scrollBarPositionChanged(int value);