Let the scrollbar follow the app color scheme

TerminalColor::onColorsChanged() used to be called updateScrollbarColors(),
now that KColorSchemeManager is integrated in Konsole, users can choose a
colour scheme for the whole window widget style, where tabs, scrollbar,
findbar, right-click context menu are all the same colour as you'd expect
from any KDE application.

This removes dimming of the scrollbar when the "dim when inactive" option is
disabled, the scrollbar is part of the window GUI, it should follow the same
color scheme.

2a71f063f8
25e07b7e20
72d604c6cc
wilder
Ahmad Samir 5 years ago committed by Kurt Hindenburg
parent d9ea330827
commit 92e19c6305
  1. 49
      src/terminalDisplay/TerminalColor.cpp
  2. 7
      src/terminalDisplay/TerminalColor.h
  3. 2
      src/terminalDisplay/TerminalDisplay.cpp

@ -54,7 +54,6 @@ void TerminalColor::setColorTable(const QColor *table)
{
std::copy(table, table + TABLE_COLORS, m_colorTable);
setBackgroundColor(m_colorTable[DEFAULT_BACK_COLOR]);
onColorsChanged();
}
const QColor *TerminalColor::colorTable() const
@ -69,7 +68,6 @@ void TerminalColor::setOpacity(qreal opacity)
m_opacity = opacity;
m_blendColor = color.rgba();
onColorsChanged();
}
void TerminalColor::visualBell()
@ -91,56 +89,11 @@ QRgb TerminalColor::blendColor() const
void TerminalColor::setBackgroundColor(const QColor &color)
{
m_colorTable[DEFAULT_BACK_COLOR] = color;
onColorsChanged();
}
void TerminalColor::setForegroundColor(const QColor &color)
{
m_colorTable[DEFAULT_FORE_COLOR] = color;
onColorsChanged();
}
bool TerminalColor::event(QEvent *event)
{
switch (event->type()) {
case QEvent::PaletteChange:
case QEvent::ApplicationPaletteChange:
onColorsChanged();
break;
default:
break;
}
return QObject::event(event);
}
void TerminalColor::onColorsChanged()
{
QPalette palette = QApplication::palette();
QColor buttonTextColor = m_colorTable[DEFAULT_FORE_COLOR];
QColor backgroundColor = m_colorTable[DEFAULT_BACK_COLOR];
backgroundColor.setAlphaF(m_opacity);
QColor buttonColor = backgroundColor.toHsv();
if (buttonColor.valueF() < 0.5) {
buttonColor = buttonColor.lighter();
} else {
buttonColor = buttonColor.darker();
}
palette.setColor(QPalette::Button, buttonColor);
palette.setColor(QPalette::Window, backgroundColor);
palette.setColor(QPalette::Base, backgroundColor);
palette.setColor(QPalette::WindowText, buttonTextColor);
palette.setColor(QPalette::ButtonText, buttonTextColor);
QWidget *widget = qobject_cast<QWidget *>(parent());
widget->setPalette(palette);
Q_EMIT onPalette(palette);
widget->update();
}
void TerminalColor::swapFGBGColors()
@ -148,8 +101,6 @@ void TerminalColor::swapFGBGColors()
QColor color = m_colorTable[DEFAULT_BACK_COLOR];
m_colorTable[DEFAULT_BACK_COLOR] = m_colorTable[DEFAULT_FORE_COLOR];
m_colorTable[DEFAULT_FORE_COLOR] = color;
onColorsChanged();
}
}

@ -57,13 +57,6 @@ public Q_SLOTS:
void setBackgroundColor(const QColor &color);
void setForegroundColor(const QColor &color);
Q_SIGNALS:
void onPalette(const QPalette &);
protected:
bool event(QEvent *event) override;
void onColorsChanged();
private Q_SLOTS:
void swapFGBGColors();

@ -252,7 +252,6 @@ TerminalDisplay::TerminalDisplay(QWidget *parent)
// create scroll bar for scrolling output up and down
_scrollBar = new TerminalScrollBar(this);
_scrollBar->setAutoFillBackground(false);
// set the scroll bar's slider to occupy the whole area of the scroll bar initially
_scrollBar->setScroll(0, 0);
_scrollBar->setCursor(Qt::ArrowCursor);
@ -320,7 +319,6 @@ TerminalDisplay::TerminalDisplay(QWidget *parent)
connect(KonsoleSettings::self(), &KonsoleSettings::configChanged, this, &TerminalDisplay::setupHeaderVisibility);
_terminalColor = new TerminalColor(this);
connect(_terminalColor, &TerminalColor::onPalette, _scrollBar, &TerminalScrollBar::setPalette);
_terminalPainter = new TerminalPainter(this);
connect(this, &TerminalDisplay::drawContents, _terminalPainter, &TerminalPainter::drawContents);

Loading…
Cancel
Save