[Libreoffice-commits] core.git: Branch 'feature/qt5+kde5' - vcl/unx

Katarina Behrens Katarina.Behrens at cib.de
Mon Jul 2 09:47:12 UTC 2018


 vcl/unx/kde5/KDE5SalGraphics.cxx |   36 +++++++++++++++++++++++++++---------
 vcl/unx/kde5/KDE5SalGraphics.hxx |    6 ++++++
 2 files changed, 33 insertions(+), 9 deletions(-)

New commits:
commit 72a2500327ef6aaa3854b248fef5bfc1ccc99101
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date:   Mon Jul 2 11:41:10 2018 +0200

    Draw button focus so that it doesn't obscure the actual button
    
    Change-Id: I0df51b8dfd75dd966639d0893c379f2038c949ff

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: */


More information about the Libreoffice-commits mailing list