Changeset View
Changeset View
Standalone View
Standalone View
src/TerminalDisplay.cpp
Show First 20 Lines • Show All 125 Lines • ▼ Show 20 Line(s) | 116 | if (_screenWindow != nullptr) { | |||
---|---|---|---|---|---|
126 | _screenWindow->setWindowLines(_lines); | 126 | _screenWindow->setWindowLines(_lines); | ||
127 | } | 127 | } | ||
128 | } | 128 | } | ||
129 | 129 | | |||
130 | const ColorEntry* TerminalDisplay::colorTable() const | 130 | const ColorEntry* TerminalDisplay::colorTable() const | ||
131 | { | 131 | { | ||
132 | return _colorTable; | 132 | return _colorTable; | ||
133 | } | 133 | } | ||
134 | | ||||
135 | void TerminalDisplay::updateScrollBarPalette() | ||||
136 | { | ||||
137 | QColor backgroundColor = _colorTable[DEFAULT_BACK_COLOR]; | ||||
138 | backgroundColor.setAlphaF(_opacity); | ||||
139 | QPalette p = palette(); | ||||
140 | p.setColor(QPalette::Window, backgroundColor); | ||||
141 | | ||||
142 | //this is a workaround to add some readability to old themes like Fusion | ||||
143 | //changing the light value for button a bit makes themes like fusion, windows and oxygen way more readable and pleasing | ||||
144 | QColor buttonColor; | ||||
145 | buttonColor.setHsvF(backgroundColor.hueF(), backgroundColor.saturationF(), backgroundColor.valueF() + (backgroundColor.valueF() < 0.5 ? 0.2 : -0.2)); | ||||
146 | p.setColor(QPalette::Button, buttonColor); | ||||
147 | | ||||
148 | p.setColor(QPalette::WindowText, _colorTable[DEFAULT_FORE_COLOR]); | ||||
149 | p.setColor(QPalette::ButtonText, _colorTable[DEFAULT_FORE_COLOR]); | ||||
150 | _scrollBar->setPalette(p); | ||||
151 | | ||||
152 | } | ||||
153 | | ||||
134 | void TerminalDisplay::setBackgroundColor(const QColor& color) | 154 | void TerminalDisplay::setBackgroundColor(const QColor& color) | ||
135 | { | 155 | { | ||
136 | _colorTable[DEFAULT_BACK_COLOR] = color; | 156 | _colorTable[DEFAULT_BACK_COLOR] = color; | ||
137 | 157 | | |||
138 | QPalette p = palette(); | 158 | QPalette p = palette(); | ||
139 | p.setColor(backgroundRole(), color); | 159 | p.setColor(backgroundRole(), color); | ||
140 | setPalette(p); | 160 | setPalette(p); | ||
141 | 161 | | |||
142 | // Avoid propagating the palette change to the scroll bar | 162 | updateScrollBarPalette(); | ||
143 | _scrollBar->setPalette(QApplication::palette()); | | |||
144 | | ||||
145 | update(); | 163 | update(); | ||
146 | } | 164 | } | ||
147 | QColor TerminalDisplay::getBackgroundColor() const | 165 | QColor TerminalDisplay::getBackgroundColor() const | ||
148 | { | 166 | { | ||
149 | QPalette p = palette(); | 167 | QPalette p = palette(); | ||
150 | return p.color(backgroundRole()); | 168 | return p.color(backgroundRole()); | ||
151 | } | 169 | } | ||
152 | void TerminalDisplay::setForegroundColor(const QColor& color) | 170 | void TerminalDisplay::setForegroundColor(const QColor& color) | ||
153 | { | 171 | { | ||
154 | _colorTable[DEFAULT_FORE_COLOR] = color; | 172 | _colorTable[DEFAULT_FORE_COLOR] = color; | ||
155 | 173 | | |||
174 | updateScrollBarPalette(); | ||||
156 | update(); | 175 | update(); | ||
157 | } | 176 | } | ||
158 | void TerminalDisplay::setColorTable(const ColorEntry table[]) | 177 | void TerminalDisplay::setColorTable(const ColorEntry table[]) | ||
159 | { | 178 | { | ||
160 | for (int i = 0; i < TABLE_COLORS; i++) { | 179 | for (int i = 0; i < TABLE_COLORS; i++) { | ||
161 | _colorTable[i] = table[i]; | 180 | _colorTable[i] = table[i]; | ||
162 | } | 181 | } | ||
163 | 182 | | |||
▲ Show 20 Lines • Show All 230 Lines • ▼ Show 20 Line(s) | 412 | { | |||
394 | // terminal applications are not designed with Right-To-Left in mind, | 413 | // terminal applications are not designed with Right-To-Left in mind, | ||
395 | // so the layout is forced to Left-To-Right | 414 | // so the layout is forced to Left-To-Right | ||
396 | setLayoutDirection(Qt::LeftToRight); | 415 | setLayoutDirection(Qt::LeftToRight); | ||
397 | 416 | | |||
398 | _contentRect = QRect(_margin, _margin, 1, 1); | 417 | _contentRect = QRect(_margin, _margin, 1, 1); | ||
399 | 418 | | |||
400 | // create scroll bar for scrolling output up and down | 419 | // create scroll bar for scrolling output up and down | ||
401 | _scrollBar = new QScrollBar(this); | 420 | _scrollBar = new QScrollBar(this); | ||
421 | _scrollBar->setAutoFillBackground(false); | ||||
402 | // set the scroll bar's slider to occupy the whole area of the scroll bar initially | 422 | // set the scroll bar's slider to occupy the whole area of the scroll bar initially | ||
403 | setScroll(0, 0); | 423 | setScroll(0, 0); | ||
404 | _scrollBar->setCursor(Qt::ArrowCursor); | 424 | _scrollBar->setCursor(Qt::ArrowCursor); | ||
405 | connect(_scrollBar, &QScrollBar::valueChanged, this, &Konsole::TerminalDisplay::scrollBarPositionChanged); | 425 | connect(_scrollBar, &QScrollBar::valueChanged, this, &Konsole::TerminalDisplay::scrollBarPositionChanged); | ||
406 | connect(_scrollBar, &QScrollBar::sliderMoved, this, &Konsole::TerminalDisplay::viewScrolledByUser); | 426 | connect(_scrollBar, &QScrollBar::sliderMoved, this, &Konsole::TerminalDisplay::viewScrolledByUser); | ||
407 | 427 | | |||
408 | // setup timers for blinking text | 428 | // setup timers for blinking text | ||
409 | _blinkTextTimer = new QTimer(this); | 429 | _blinkTextTimer = new QTimer(this); | ||
▲ Show 20 Lines • Show All 340 Lines • ▼ Show 20 Line(s) | 769 | { | |||
750 | setAutoFillBackground(true); | 770 | setAutoFillBackground(true); | ||
751 | } | 771 | } | ||
752 | else | 772 | else | ||
753 | { | 773 | { | ||
754 | setAutoFillBackground(false); | 774 | setAutoFillBackground(false); | ||
755 | }*/ | 775 | }*/ | ||
756 | 776 | | |||
757 | _blendColor = color.rgba(); | 777 | _blendColor = color.rgba(); | ||
778 | updateScrollBarPalette(); | ||||
758 | } | 779 | } | ||
759 | 780 | | |||
760 | void TerminalDisplay::setWallpaper(ColorSchemeWallpaper::Ptr p) | 781 | void TerminalDisplay::setWallpaper(ColorSchemeWallpaper::Ptr p) | ||
761 | { | 782 | { | ||
762 | _wallpaper = p; | 783 | _wallpaper = p; | ||
763 | } | 784 | } | ||
764 | 785 | | |||
765 | void TerminalDisplay::drawBackground(QPainter& painter, const QRect& rect, const QColor& backgroundColor, bool useOpacitySetting) | 786 | void TerminalDisplay::drawBackground(QPainter& painter, const QRect& rect, const QColor& backgroundColor, bool useOpacitySetting) | ||
▲ Show 20 Lines • Show All 3048 Lines • Show Last 20 Lines |