diff options
author | Katarina Behrens <Katarina.Behrens@cib.de> | 2018-07-02 11:41:10 +0200 |
---|---|---|
committer | Katarina Behrens <Katarina.Behrens@cib.de> | 2018-07-03 14:10:49 +0200 |
commit | 63f0dbdd61df0bf390d201b4ea4215b0077a2f9d (patch) | |
tree | 5ebda03e9f6fdfce9034ab8642ebe1ecd11f95e6 | |
parent | dc8f347f5fed638f07ef88246950460e3ed284d1 (diff) |
Draw button focus so that it doesn't obscure the actual button
Change-Id: I0df51b8dfd75dd966639d0893c379f2038c949ff
-rw-r--r-- | vcl/unx/kde5/KDE5SalGraphics.cxx | 36 | ||||
-rw-r--r-- | vcl/unx/kde5/KDE5SalGraphics.hxx | 6 |
2 files changed, 33 insertions, 9 deletions
diff --git a/vcl/unx/kde5/KDE5SalGraphics.cxx b/vcl/unx/kde5/KDE5SalGraphics.cxx index 75e7c8664ab4..9377a134fdc4 100644 --- a/vcl/unx/kde5/KDE5SalGraphics.cxx +++ b/vcl/unx/kde5/KDE5SalGraphics.cxx @@ -81,6 +81,7 @@ void QImage2BitmapBuffer(QImage* pImg, BitmapBuffer* pBuf) KDE5SalGraphics::KDE5SalGraphics() : SvpSalGraphics() { + initStyles(); } bool KDE5SalGraphics::IsNativeControlSupported(ControlType type, ControlPart part) @@ -218,12 +219,6 @@ bool KDE5SalGraphics::drawNativeControl(ControlType type, ControlPart part, case ControlType::Tooltip: m_image->fill(QApplication::palette().color(QPalette::ToolTipBase).rgb()); break; - case ControlType::Pushbutton: - if (nControlState & ControlState::FOCUSED) - m_image->fill(QApplication::palette().color(QPalette::Highlight).rgb()); - else - m_image->fill(QApplication::palette().color(QPalette::Button).rgb()); - break; case ControlType::Scrollbar: if ((part == ControlPart::DrawBackgroundVert) || (part == ControlPart::DrawBackgroundHorz)) @@ -241,9 +236,21 @@ bool KDE5SalGraphics::drawNativeControl(ControlType type, ControlPart part, if (type == ControlType::Pushbutton) { - QStyleOptionButton option; - draw(QStyle::CE_PushButton, &option, m_image.get(), - vclStateValue2StateFlag(nControlState, value)); + if (part == ControlPart::Entire) + { + QStyleOptionButton option; + draw(QStyle::CE_PushButton, &option, m_image.get(), + vclStateValue2StateFlag(nControlState, value)); + } + else if (part == ControlPart::Focus) + { + QStyleOptionButton option; + option.state = QStyle::State_HasFocus; + option.rect = m_image->rect(); + QPainter painter(m_image.get()); + m_focusedButton->style()->drawControl(QStyle::CE_PushButton, &option, &painter, + m_focusedButton.get()); + } } else if (type == ControlType::Menubar) { @@ -991,4 +998,15 @@ bool KDE5SalGraphics::hitTestNativeControl(ControlType nType, ControlPart nPart, return false; } +void KDE5SalGraphics::initStyles() +{ + // button focus + m_focusedButton.reset(new QPushButton()); + QString aHighlightColor = QApplication::palette().color(QPalette::Highlight).name(); + QString focusStyleSheet("background-color: rgb(0,0,0,0%); border: 1px; border-radius: 2px; " + "border-color: %1; border-style:solid;"); + focusStyleSheet.replace("%1", aHighlightColor); + m_focusedButton->setStyleSheet(focusStyleSheet); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/kde5/KDE5SalGraphics.hxx b/vcl/unx/kde5/KDE5SalGraphics.hxx index 77121459e8be..e70159ba9568 100644 --- a/vcl/unx/kde5/KDE5SalGraphics.hxx +++ b/vcl/unx/kde5/KDE5SalGraphics.hxx @@ -25,6 +25,7 @@ #include <headless/svpgdi.hxx> #include <QtGui/QImage> +#include <QtWidgets/QPushButton> class KDE5SalFrame; @@ -49,6 +50,11 @@ public: std::unique_ptr<QImage> m_image; QRect lastPopupRect; + +private: + void initStyles(); + + std::unique_ptr<QPushButton> m_focusedButton; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |