mirror of
https://github.com/status-im/snorenotify.git
synced 2025-02-09 07:04:19 +00:00
Don't use an image for the close button but draw it. Add a sircle around the close button if it has mouse over.
This commit is contained in:
parent
bb0989b159
commit
b5e77e6d5d
@ -7,10 +7,10 @@ Rectangle {
|
|||||||
signal dismissed()
|
signal dismissed()
|
||||||
signal invoked()
|
signal invoked()
|
||||||
|
|
||||||
property int snoreMargin: body.font.pixelSize
|
property int snoreBaseSize: body.font.pixelSize
|
||||||
|
|
||||||
width: snoreMargin * 30
|
width: snoreBaseSize * 30
|
||||||
height: snoreMargin * 9
|
height: snoreBaseSize * 9
|
||||||
|
|
||||||
|
|
||||||
function update(nTitle, bBody, nImage, nAppIcon, color, textColor, isUpdate)
|
function update(nTitle, bBody, nImage, nAppIcon, color, textColor, isUpdate)
|
||||||
@ -70,8 +70,8 @@ Rectangle {
|
|||||||
font.pointSize: body.font.pointSize * 1.5
|
font.pointSize: body.font.pointSize * 1.5
|
||||||
font.bold: true
|
font.bold: true
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.margins: snoreMargin
|
anchors.margins: snoreBaseSize
|
||||||
anchors.topMargin: snoreMargin / 2
|
anchors.topMargin: snoreBaseSize / 2
|
||||||
anchors.left: image.right
|
anchors.left: image.right
|
||||||
anchors.right: closeButton.left
|
anchors.right: closeButton.left
|
||||||
textFormat: Text.StyledText
|
textFormat: Text.StyledText
|
||||||
@ -88,8 +88,8 @@ Rectangle {
|
|||||||
anchors.top: title.bottom
|
anchors.top: title.bottom
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.left: image.right
|
anchors.left: image.right
|
||||||
anchors.margins: snoreMargin
|
anchors.margins: snoreBaseSize
|
||||||
anchors.topMargin: snoreMargin / 2
|
anchors.topMargin: snoreBaseSize / 2
|
||||||
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
||||||
onLinkActivated: Qt.openUrlExternally(link)
|
onLinkActivated: Qt.openUrlExternally(link)
|
||||||
textFormat: Text.StyledText
|
textFormat: Text.StyledText
|
||||||
@ -103,7 +103,7 @@ Rectangle {
|
|||||||
width: height
|
width: height
|
||||||
smooth: true
|
smooth: true
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.margins: snoreMargin
|
anchors.margins: snoreBaseSize
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
z: 4
|
z: 4
|
||||||
@ -117,25 +117,56 @@ Rectangle {
|
|||||||
smooth: true
|
smooth: true
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.margins: snoreMargin
|
anchors.margins: snoreBaseSize
|
||||||
}
|
}
|
||||||
|
|
||||||
Image {
|
Canvas{
|
||||||
id: closeButton
|
id: closeButton
|
||||||
fillMode: Image.PreserveAspectFit
|
height: root.height * 0.25
|
||||||
height: root.height * 0.20
|
width: root.height * 0.25
|
||||||
width: root.height * 0.20
|
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.margins: snoreMargin
|
anchors.margins: snoreBaseSize
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
z: 91
|
z: 91
|
||||||
source: "resources/close.png"
|
|
||||||
smooth: true
|
onPaint: {
|
||||||
|
var context = getContext("2d");
|
||||||
|
context.lineWidth = snoreBaseSize * 0.25;
|
||||||
|
|
||||||
|
context.beginPath();
|
||||||
|
context.clearRect(0, 0, width, height);
|
||||||
|
context.fill();
|
||||||
|
|
||||||
|
if(mouseAreaCloseButton.containsMouse)
|
||||||
|
{
|
||||||
|
context.beginPath();
|
||||||
|
context.strokeStyle = root.color
|
||||||
|
context.fillStyle = body.color
|
||||||
|
context.globalAlpha = 0.5
|
||||||
|
context.moveTo(width/2 + width/2 , height/2);
|
||||||
|
context.arc(width/2, height/2, width/2 , 0, 2*Math.PI, true)
|
||||||
|
context.fill();
|
||||||
|
context.stroke();
|
||||||
|
}
|
||||||
|
|
||||||
|
var margin = snoreBaseSize * 0.5
|
||||||
|
context.beginPath();
|
||||||
|
context.globalAlpha = 1
|
||||||
|
context.strokeStyle = body.color
|
||||||
|
context.moveTo(margin, margin);
|
||||||
|
context.lineTo(width - margin, height - margin);
|
||||||
|
context.moveTo(width - margin, 0 + margin);
|
||||||
|
context.lineTo(margin, height - margin);
|
||||||
|
context.stroke();
|
||||||
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: mouseAreaCloseButton
|
id: mouseAreaCloseButton
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: root.dismissed()
|
onClicked: root.dismissed()
|
||||||
|
hoverEnabled: true
|
||||||
|
onEntered: parent.requestPaint()
|
||||||
|
onExited: parent.requestPaint()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 725 B |
@ -1,6 +1,5 @@
|
|||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/">
|
<qresource prefix="/">
|
||||||
<file>notification.qml</file>
|
<file>notification.qml</file>
|
||||||
<file>resources/close.png</file>
|
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user