Commit 3e652002 authored by snooxx's avatar snooxx Committed by Tomaz Canabrava
Browse files

Revert "Let the scrollbar follow the app color scheme"

This reverts commit 92e19c63.

The code to adapt the scrollbar color to the terminal color scheme will
still be needed in a subsequent patch. There it will be restricted to
the Breeze widget style and thus retain the behavior of the reverted
patch for non-Breeze styles.
parent 04ea3fec
......@@ -54,6 +54,7 @@ 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
......@@ -68,6 +69,7 @@ void TerminalColor::setOpacity(qreal opacity)
m_opacity = opacity;
m_blendColor = color.rgba();
onColorsChanged();
}
void TerminalColor::visualBell()
......@@ -89,11 +91,56 @@ 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()
......@@ -101,6 +148,8 @@ 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,6 +57,13 @@ 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,6 +252,7 @@ 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);
......@@ -319,6 +320,7 @@ 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);
......
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