upport mnemonic labels

This commit is contained in:
Marco Martin 2018-10-19 13:43:17 +02:00
parent e92ed94d9d
commit 9b6c2cddc7
5 changed files with 40 additions and 17 deletions
src/declarativeimports
kirigamiplasmadesktopstyle
kirigamiplasmastyle
plasmacomponents3

View File

@ -22,6 +22,7 @@ import QtQuick.Window 2.2
import org.kde.plasma.core 2.0 as PlasmaCore
import QtQuick.Controls 1.4 as QtQuickControls
import QtQuick.Controls.Private 1.0 as QtQuickControlsPrivate
import org.kde.kirigami 2.4
pragma Singleton
@ -54,12 +55,12 @@ QtObject {
* * desktop
*/
property QtObject iconSizes: QtObject {
property int small: fontMetrics.roundedIconSize(16 * devicePixelRatio)
property int smallMedium: fontMetrics.roundedIconSize(22 * devicePixelRatio)
property int medium: fontMetrics.roundedIconSize(32 * devicePixelRatio)
property int large: fontMetrics.roundedIconSize(48 * devicePixelRatio)
property int huge: fontMetrics.roundedIconSize(64 * devicePixelRatio)
property int enormous: 128 * devicePixelRatio
property int small: Math.floor(fontMetrics.roundedIconSize(16 * devicePixelRatio) * (Settings.isMobile ? 1.5 : 1))
property int smallMedium: Math.floor(fontMetrics.roundedIconSize(22 * devicePixelRatio) * (Settings.isMobile ? 1.5 : 1))
property int medium: Math.floor(fontMetrics.roundedIconSize(32 * devicePixelRatio) * (Settings.isMobile ? 1.5 : 1))
property int large: Math.floor(fontMetrics.roundedIconSize(48 * devicePixelRatio) * (Settings.isMobile ? 1.5 : 1))
property int huge: Math.floor(fontMetrics.roundedIconSize(64 * devicePixelRatio) * (Settings.isMobile ? 1.5 : 1))
property int enormous: Math.floor(128 * devicePixelRatio * (Settings.isMobile ? 1.5 : 1))
}
/**

View File

@ -21,7 +21,7 @@ pragma Singleton
import QtQuick 2.4
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.kirigami 2.4
QtObject {
/**
@ -49,12 +49,12 @@ QtObject {
* * desktop
*/
property QtObject iconSizes: QtObject {
property int small: units.iconSizes.small
property int smallMedium: units.iconSizes.smallMedium
property int medium: units.iconSizes.medium
property int large: units.iconSizes.large
property int huge: units.iconSizes.huge
property int enormous: units.iconSizes.enormous
property int small: Math.floor(fontMetrics.roundedIconSize(16 * devicePixelRatio) * (Settings.isMobile ? 1.5 : 1))
property int smallMedium: Math.floor(fontMetrics.roundedIconSize(22 * devicePixelRatio) * (Settings.isMobile ? 1.5 : 1))
property int medium: Math.floor(fontMetrics.roundedIconSize(32 * devicePixelRatio) * (Settings.isMobile ? 1.5 : 1))
property int large: Math.floor(fontMetrics.roundedIconSize(48 * devicePixelRatio) * (Settings.isMobile ? 1.5 : 1))
property int huge: Math.floor(fontMetrics.roundedIconSize(64 * devicePixelRatio) * (Settings.isMobile ? 1.5 : 1))
property int enormous: Math.floor(128 * devicePixelRatio * (Settings.isMobile ? 1.5 : 1))
}
/**
@ -63,7 +63,7 @@ QtObject {
* the default font as rendered on the screen, so it takes user-configured font size and DPI
* into account.
*/
property int smallSpacing: units.smallSpacing
property int smallSpacing: Math.floor(gridUnit/4)
/**
* units.largeSpacing is the amount of spacing that should be used inside bigger UI elements,
@ -106,5 +106,20 @@ QtObject {
*/
property variant fontMetrics: TextMetrics {
text: "M"
function roundedIconSize(size) {
if (size < 16) {
return size;
} else if (size < 22) {
return 16;
} else if (size < 32) {
return 22;
} else if (size < 48) {
return 32;
} else if (size < 64) {
return 48;
} else {
return size;
}
}
}
}

View File

@ -38,6 +38,10 @@ T.Button {
hoverEnabled: !Kirigami.Settings.tabletMode
Kirigami.MnemonicData.enabled: control.enabled && control.visible
Kirigami.MnemonicData.controlType: Kirigami.MnemonicData.SecondaryControl
Kirigami.MnemonicData.label: control.text
contentItem: RowLayout {
PlasmaCore.IconItem {
id: icon
@ -50,7 +54,7 @@ T.Button {
Label {
Layout.fillWidth: !icon.visible
visible: text.length > 0
text: control.text
text: control.Kirigami.MnemonicData.richTextLabel
font: control.font
opacity: enabled || control.highlighted || control.checked ? 1 : 0.4
color: theme.buttonTextColor

View File

@ -37,7 +37,6 @@ T.Label {
//TODO: from theme singleton?
color: PlasmaCore.ColorScope.textColor
linkColor: theme.linkColor
textFormat: Text.PlainText
opacity: enabled? 1 : 0.6

View File

@ -38,6 +38,10 @@ T.ToolButton {
hoverEnabled: !Kirigami.Settings.tabletMode
Kirigami.MnemonicData.enabled: control.enabled && control.visible
Kirigami.MnemonicData.controlType: Kirigami.MnemonicData.SecondaryControl
Kirigami.MnemonicData.label: control.text
flat: true
contentItem: RowLayout {
@ -50,7 +54,7 @@ T.ToolButton {
}
Label {
visible: text.length > 0
text: control.text
text: control.Kirigami.MnemonicData.richTextLabel
font: control.font
opacity: enabled || control.highlighted || control.checked ? 1 : 0.4
color: theme.buttonTextColor