Commit 2a71f063 authored by Marco Martin's avatar Marco Martin Committed by Kurt Hindenburg

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
parent b85c469e
......@@ -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)
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment