Changeset View
Changeset View
Standalone View
Standalone View
src/qml/ButtonWithToolTip.qml
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright 2018 Alexander Stippich <a.stippich@gmx.net> | ||||
3 | * | ||||
4 | * This library is free software; you can redistribute it and/or | ||||
5 | * modify it under the terms of the GNU Library General Public | ||||
6 | * License as published by the Free Software Foundation; either | ||||
7 | * version 3 of the License, or (at your option) any later version. | ||||
8 | * | ||||
9 | * This library is distributed in the hope that it will be useful, | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
12 | * Library General Public License for more details. | ||||
13 | * | ||||
14 | * You should have received a copy of the GNU Library General Public License | ||||
15 | * along with this library; see the file COPYING.LIB. If not, write to | ||||
16 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||||
17 | * Boston, MA 02110-1301, USA. | ||||
18 | */ | ||||
19 | | ||||
20 | import QtQuick 2.7 | ||||
21 | import QtQuick.Layouts 1.2 | ||||
22 | import QtGraphicalEffects 1.0 | ||||
23 | import QtQuick.Controls 2.3 | ||||
24 | import org.kde.elisa 1.0 | ||||
25 | | ||||
26 | Button { | ||||
27 | id: buttonWithToolTip | ||||
28 | | ||||
29 | contentItem: Image { | ||||
30 | anchors.fill: parent | ||||
31 | | ||||
32 | source: buttonWithToolTip.action.icon.name != "" ? ('image://icon/' + buttonWithToolTip.action.icon.name) : Qt.resolvedUrl(buttonWithToolTip.action.icon.source) | ||||
33 | | ||||
34 | sourceSize.width: buttonWithToolTip.width | ||||
35 | sourceSize.height: buttonWithToolTip.height | ||||
36 | | ||||
37 | fillMode: Image.PreserveAspectFit | ||||
38 | opacity: buttonWithToolTip.action.enabled ? 1 : 0.6 | ||||
39 | } | ||||
40 | | ||||
41 | background: Rectangle { | ||||
42 | color: "transparent" | ||||
43 | border.color: (parent.hovered || parent.activeFocus) ? myPalette.highlight : "transparent" | ||||
44 | border.width: 1 | ||||
45 | } | ||||
46 | | ||||
47 | ToolTip.visible: hovered | ||||
48 | ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval | ||||
49 | ToolTip.text: buttonWithToolTip.action.text | ||||
50 | } |