| 1 |
// SPDX-FileCopyrightText: Nheko Contributors |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: GPL-3.0-or-later |
| 4 |
|
| 5 |
pragma ComponentBehavior: Bound |
| 6 |
import "./ui" |
| 7 |
import QtQuick |
| 8 |
import QtQuick.Controls |
| 9 |
import im.nheko // for cursor shape |
| 10 |
|
| 11 |
AbstractButton { |
| 12 |
id: button |
| 13 |
|
| 14 |
property color buttonTextColor: palette.buttonText |
| 15 |
property bool changeColorOnHover: true |
| 16 |
property alias cursor: mouseArea.cursorShape |
| 17 |
property color highlightColor: palette.highlight |
| 18 |
property string image: undefined |
| 19 |
property bool ripple: true |
| 20 |
|
| 21 |
focusPolicy: Qt.NoFocus |
| 22 |
height: 16 |
| 23 |
width: 16 |
| 24 |
|
| 25 |
Image { |
| 26 |
id: buttonImg |
| 27 |
|
| 28 |
// Workaround, can't get icon.source working for now... |
| 29 |
anchors.fill: parent |
| 30 |
fillMode: Image.PreserveAspectFit |
| 31 |
source: button.image != "" ? ("image://colorimage/" + button.image + "?" + ((button.hovered && button.changeColorOnHover) ? button.highlightColor : button.buttonTextColor)) : "" |
| 32 |
sourceSize.height: button.height |
| 33 |
sourceSize.width: button.width |
| 34 |
} |
| 35 |
NhekoCursorShape { |
| 36 |
id: mouseArea |
| 37 |
|
| 38 |
anchors.fill: parent |
| 39 |
cursorShape: Qt.PointingHandCursor |
| 40 |
} |
| 41 |
Ripple { |
| 42 |
color: Qt.rgba(button.buttonTextColor.r, button.buttonTextColor.g, button.buttonTextColor.b, 0.5) |
| 43 |
enabled: button.ripple |
| 44 |
} |
| 45 |
} |