| 1 |
// SPDX-FileCopyrightText: Nheko Contributors |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: GPL-3.0-or-later |
| 4 |
|
| 5 |
import QtQuick |
| 6 |
import QtQuick.Controls |
| 7 |
import QtQuick.Layouts |
| 8 |
import QtQuick.Effects |
| 9 |
import im.nheko |
| 10 |
|
| 11 |
// FIXME(Nico): Don't use hardcoded colors. |
| 12 |
Button { |
| 13 |
id: control |
| 14 |
|
| 15 |
implicitHeight: Math.ceil(control.contentItem.implicitHeight * 1.70) |
| 16 |
implicitWidth: Math.ceil(control.contentItem.implicitWidth + control.contentItem.implicitHeight) |
| 17 |
hoverEnabled: true |
| 18 |
|
| 19 |
property string iconImage: "" |
| 20 |
|
| 21 |
MultiEffect { |
| 22 |
anchors.fill: control.background |
| 23 |
shadowHorizontalOffset: 3 |
| 24 |
shadowVerticalOffset: 3 |
| 25 |
shadowBlur: 8 |
| 26 |
shadowEnabled: true |
| 27 |
shadowColor: "#80000000" |
| 28 |
source: control.background |
| 29 |
} |
| 30 |
|
| 31 |
contentItem: RowLayout { |
| 32 |
spacing: 0 |
| 33 |
anchors.centerIn: parent |
| 34 |
Image { |
| 35 |
Layout.leftMargin: Nheko.paddingMedium |
| 36 |
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter |
| 37 |
Layout.preferredHeight: fontMetrics.font.pixelSize * 1.5 |
| 38 |
Layout.preferredWidth: fontMetrics.font.pixelSize * 1.5 |
| 39 |
visible: !!iconImage |
| 40 |
source: iconImage |
| 41 |
} |
| 42 |
|
| 43 |
Text { |
| 44 |
Layout.alignment: Qt.AlignHCenter |
| 45 |
text: control.text |
| 46 |
//font: control.font |
| 47 |
font.capitalization: Font.AllUppercase |
| 48 |
font.pointSize: Math.ceil(fontMetrics.font.pointSize * 1.5) |
| 49 |
//font.capitalization: Font.AllUppercase |
| 50 |
color: palette.light |
| 51 |
horizontalAlignment: Text.AlignHCenter |
| 52 |
verticalAlignment: Text.AlignVCenter |
| 53 |
elide: Text.ElideRight |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
background: Rectangle { |
| 58 |
//height: control.contentItem.implicitHeight * 2 |
| 59 |
//width: control.contentItem.implicitWidth * 2 |
| 60 |
radius: height / 8 |
| 61 |
color: Qt.lighter(palette.dark, control.down ? 1.4 : (control.hovered ? 1.2 : 1)) |
| 62 |
} |
| 63 |
|
| 64 |
} |