Changeset View
Changeset View
Standalone View
Standalone View
src/controls/private/PrivateActionToolButton.qml
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | * SPDX-FileCopyrightText: 2016 Marco Martin <mart@kde.org> | 2 | * SPDX-FileCopyrightText: 2016 Marco Martin <mart@kde.org> | ||
3 | * | 3 | * | ||
4 | * SPDX-License-Identifier: LGPL-2.0-or-later | 4 | * SPDX-License-Identifier: LGPL-2.0-or-later | ||
5 | */ | 5 | */ | ||
6 | 6 | | |||
7 | import QtQuick 2.7 | 7 | import QtQuick 2.7 | ||
8 | import QtQuick.Layouts 1.2 | 8 | import QtQuick.Layouts 1.2 | ||
9 | import QtQuick.Controls 2.4 as Controls | 9 | import QtQuick.Controls 2.4 as Controls | ||
10 | import org.kde.kirigami 2.4 | 10 | import org.kde.kirigami 2.4 | ||
11 | 11 | | |||
12 | Controls.ToolButton { | 12 | Controls.ToolButton { | ||
13 | id: control | 13 | id: control | ||
14 | 14 | | |||
15 | signal menuAboutToShow | 15 | signal menuAboutToShow | ||
16 | 16 | | |||
17 | implicitWidth: menuArrow.visible || (showText && ( kirigamiAction ? kirigamiAction.text.length > 0 : text.length > 0)) | 17 | implicitWidth: { | ||
18 | ? Math.max(layout.implicitWidth + Units.largeSpacing*2, background.implicitWidth) | 18 | if (!menuArrow.visible) { | ||
19 | : implicitHeight | 19 | if (!showText || display == Controls.Button.IconOnly) { | ||
20 | return implicitHeight | ||||
21 | } | ||||
22 | | ||||
23 | var textLength = kirigamiAction ? kirigamiAction.text.length : text.length | ||||
24 | if (textLength == 0) { | ||||
25 | return implicitHeight | ||||
26 | } | ||||
27 | } | ||||
28 | | ||||
29 | return Math.max(layout.implicitWidth + Units.largeSpacing * 2, background.implicitWidth) | ||||
30 | } | ||||
20 | 31 | | |||
21 | Theme.colorSet: Theme.Button | 32 | Theme.colorSet: Theme.Button | ||
22 | Theme.inherit: kirigamiAction && kirigamiAction.icon.color.a === 0 | 33 | Theme.inherit: kirigamiAction && kirigamiAction.icon.color.a === 0 | ||
23 | Theme.backgroundColor: kirigamiAction && kirigamiAction.icon.color.a ? kirigamiAction.icon.color : undefined | 34 | Theme.backgroundColor: kirigamiAction && kirigamiAction.icon.color.a ? kirigamiAction.icon.color : undefined | ||
24 | Theme.textColor: kirigamiAction && !flat && kirigamiAction.icon.color.a ? Theme.highlightedTextColor : undefined | 35 | Theme.textColor: kirigamiAction && !flat && kirigamiAction.icon.color.a ? Theme.highlightedTextColor : undefined | ||
25 | 36 | | |||
26 | hoverEnabled: true | 37 | hoverEnabled: true | ||
27 | flat: !control.kirigamiAction || !control.kirigamiAction.icon.color.a | 38 | flat: !control.kirigamiAction || !control.kirigamiAction.icon.color.a | ||
▲ Show 20 Lines • Show All 104 Lines • Show Last 20 Lines |