Libplasma

ToolButton.qml
1/*
2 SPDX-FileCopyrightText: 2016 Marco Martin <mart@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7import QtQuick
8import QtQuick.Layouts
9import QtQuick.Templates as T
10import org.kde.kirigami as Kirigami
11import "private" as Private
12
13T.ToolButton {
14 id: control
15
16 implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
17 implicitContentWidth + leftPadding + rightPadding)
18 implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
19 implicitContentHeight + topPadding + bottomPadding)
20
21 topPadding: (background as Private.ButtonBackground)?.topMargin ?? undefined
22 leftPadding: (background as Private.ButtonBackground)?.leftMargin ?? undefined
23 rightPadding: (background as Private.ButtonBackground)?.rightMargin ?? undefined
24 bottomPadding: (background as Private.ButtonBackground)?.bottomMargin ?? undefined
25
26 spacing: Kirigami.Units.smallSpacing
27
28 hoverEnabled: !Kirigami.Settings.tabletMode
29
30 Accessible.onPressAction: clicked()
31
32 Kirigami.MnemonicData.enabled: control.enabled && control.visible
33 Kirigami.MnemonicData.controlType: Kirigami.MnemonicData.SecondaryControl
34 Kirigami.MnemonicData.label: control.text
35
36 // KF6 TODO: investigate setting this by default
37 // focusPolicy: Qt.TabFocus
38
39 Shortcut {
40 //in case of explicit & the button manages it by itself
41 enabled: !(RegExp(/\&[^\&]/).test(control.text))
42 sequence: control.Kirigami.MnemonicData.sequence
43 onActivated: control.clicked()
44 }
45
46 flat: true
47
48 Kirigami.Theme.inherit: flat
49 Kirigami.Theme.colorSet: Kirigami.Theme.Button
50
51 contentItem: Private.ButtonContent {
52 labelText: control.Kirigami.MnemonicData.richTextLabel
53 button: control
54 }
55
56 background: Private.ButtonBackground {
57 button: control
58 }
59}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:10:41 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.