diff options
author | Sami Nurmenniemi <sami.nurmenniemi@qt.io> | 2017-10-23 12:16:08 +0300 |
---|---|---|
committer | Sami Nurmenniemi <sami.nurmenniemi@qt.io> | 2017-11-22 10:41:45 +0000 |
commit | 36944272925a3e91b97e82f6c541ae97af3099f7 (patch) | |
tree | 284d74220c132e6f5161984eb35f3acdde81d06d | |
parent | 7ff2eba7a3b1f63ae50fbed15cff17e12a64dc41 (diff) |
Fix border image drawing for corner cut buttons
Three corrections:
- Previously border was drawn along the border of the rectangle. This
caused half of the pen to remain outside of the rectangle and border
looked strange.
- The default border width should be 2
- Pressed button should show darker screen borders
Task-number: QTBUG-60083
Change-Id: I1677a252bd3fd14b69389bfa568787a1e8c15676
Reviewed-by: Kari Oikarinen <kari.oikarinen@qt.io>
Reviewed-by: Teemu Holappa <teemu.holappa@qt.io>
-rw-r--r-- | src/settingsui/qtbuttonimageproviderplugin/QtButton.qml | 5 | ||||
-rw-r--r-- | src/settingsui/qtbuttonimageproviderplugin/qtbuttonimageprovider.cpp | 26 |
2 files changed, 19 insertions, 12 deletions
diff --git a/src/settingsui/qtbuttonimageproviderplugin/QtButton.qml b/src/settingsui/qtbuttonimageproviderplugin/QtButton.qml index 9501aa1..6fb61f4 100644 --- a/src/settingsui/qtbuttonimageproviderplugin/QtButton.qml +++ b/src/settingsui/qtbuttonimageproviderplugin/QtButton.qml @@ -34,14 +34,15 @@ Image { sourceSize: Qt.size(width, height) property string state: "enabled" property int cutSize: 10 - property color fillColor: "white" - property color borderColor: "black" + property color fillColor: viewSettings.buttonGreenColor + property color borderColor: mouseArea.pressed ? viewSettings.buttonActiveColor : viewSettings.buttonGreenColor property alias text: buttonText.text signal clicked() width: buttonText.contentWidth + cutSize * 4 MouseArea { + id: mouseArea anchors.fill: parent onClicked: root.clicked() } diff --git a/src/settingsui/qtbuttonimageproviderplugin/qtbuttonimageprovider.cpp b/src/settingsui/qtbuttonimageproviderplugin/qtbuttonimageprovider.cpp index c69b053..3879d9b 100644 --- a/src/settingsui/qtbuttonimageproviderplugin/qtbuttonimageprovider.cpp +++ b/src/settingsui/qtbuttonimageproviderplugin/qtbuttonimageprovider.cpp @@ -78,19 +78,25 @@ public: pixmap.fill(Qt::transparent); QPainter painter(&pixmap); - painter.setRenderHint(QPainter::Antialiasing); - painter.setPen(borderColor); + const qreal borderPenWidth = 2; + QPen borderPen(QBrush(borderColor), borderPenWidth); + borderPen.setJoinStyle(Qt::MiterJoin); + painter.setRenderHint(QPainter::Antialiasing, true); + painter.setPen(borderPen); painter.setBrush(fillColor); QPainterPath path; - path.moveTo(cutSize,0); - path.lineTo(pixmap.width(), 0); - path.lineTo(pixmap.width(), pixmap.height()-cutSize); - path.lineTo(pixmap.width()-cutSize, pixmap.height()); - path.lineTo(0, pixmap.height()); - path.lineTo(0, cutSize); - path.lineTo(cutSize, 0); - path.closeSubpath(); + qreal top = borderPenWidth - 1; + qreal left = borderPenWidth - 1; + qreal bottom = pixmap.height() - borderPenWidth; + qreal right = pixmap.width() - borderPenWidth; + path.moveTo(left + cutSize, top); + path.lineTo(right, top); + path.lineTo(right, bottom - cutSize); + path.lineTo(right - cutSize, bottom); + path.lineTo(left, bottom); + path.lineTo(left, top + cutSize); + path.lineTo(left + cutSize, top); painter.drawPath(path); return pixmap; |