Commit 92e19c63 authored by Ahmad Samir's avatar Ahmad Samir Committed by Kurt Hindenburg
Browse files

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.

2a71f063
25e07b7e
72d604c6
parent d9ea3308
Pipeline #91395 passed with stage
in 1 minute and 50 seconds
......@@ -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);
......
Supports Markdown
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