kcms/rules: show explanatory text with contextual help button, not tooltip
Tooltips don't work when using the system with touch, and these here are also a bit annoying with a pointing device since they appear instantly on hover and take up a lot of space, so they unexpectedly pop up and cover UI elements a lot. To improve this, use a KCM.ContextualHelpButton inline in the list items to show the explanation when clicked or hovered, just like we do in most other places in other KCMs. To make this work, the internal line breaks in the explanatory text had to be removed to make the text flow properly with an arbitrarily-sized tooltip.
This commit is contained in:
parent
e2d690e0aa
commit
afdf3ad106
3 changed files with 48 additions and 33 deletions
|
@ -8,6 +8,7 @@ import QtQuick
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import QtQuick.Controls as QQC2
|
import QtQuick.Controls as QQC2
|
||||||
import org.kde.kirigami 2.10 as Kirigami
|
import org.kde.kirigami 2.10 as Kirigami
|
||||||
|
import org.kde.kcm 1.6 as KCM
|
||||||
|
|
||||||
Kirigami.AbstractListItem {
|
Kirigami.AbstractListItem {
|
||||||
id: ruleDelegate
|
id: ruleDelegate
|
||||||
|
@ -31,15 +32,26 @@ Kirigami.AbstractListItem {
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
Layout.preferredWidth: 10 * Kirigami.Units.gridUnit
|
||||||
|
spacing: Kirigami.Units.smallSpacing
|
||||||
|
|
||||||
QQC2.Label {
|
QQC2.Label {
|
||||||
text: model.name
|
text: model.name
|
||||||
horizontalAlignment: Text.AlignLeft
|
horizontalAlignment: Text.AlignLeft
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
Layout.preferredWidth: 10 * Kirigami.Units.gridUnit
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KCM.ContextualHelpButton {
|
||||||
|
Layout.preferredHeight: Kirigami.Units.gridUnit * 2
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
visible: model.description.length > 0
|
||||||
|
toolTipText: model.description
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
// This layout keeps the width constant between delegates, independent of items visibility
|
// This layout keeps the width constant between delegates, independent of items visibility
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
|
@ -211,10 +211,6 @@ ScrollViewKCM {
|
||||||
Layout.preferredWidth: implicitWidth
|
Layout.preferredWidth: implicitWidth
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
QQC2.ToolTip {
|
|
||||||
text: model.description
|
|
||||||
visible: hovered && (model.description.length > 0)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
QQC2.Label {
|
QQC2.Label {
|
||||||
id: suggestedLabel
|
id: suggestedLabel
|
||||||
|
@ -229,6 +225,13 @@ ScrollViewKCM {
|
||||||
visible: hovered && suggestedLabel.truncated
|
visible: hovered && suggestedLabel.truncated
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ContextualHelpButton {
|
||||||
|
Layout.rightMargin: Kirigami.Units.largeSpacing
|
||||||
|
visible: model.description.length > 0
|
||||||
|
toolTipText: model.description
|
||||||
|
}
|
||||||
|
|
||||||
QQC2.ToolButton {
|
QQC2.ToolButton {
|
||||||
icon.name: (model.enabled) ? "dialog-ok-apply" : "list-add"
|
icon.name: (model.enabled) ? "dialog-ok-apply" : "list-add"
|
||||||
onClicked: addProperty();
|
onClicked: addProperty();
|
||||||
|
|
|
@ -524,9 +524,9 @@ void RulesModel::populateRuleList()
|
||||||
RulePolicy::SetRule, RuleItem::Boolean,
|
RulePolicy::SetRule, RuleItem::Boolean,
|
||||||
i18n("Ignore requested geometry"), i18n("Size & Position"),
|
i18n("Ignore requested geometry"), i18n("Size & Position"),
|
||||||
QIcon::fromTheme("view-time-schedule-baselined-remove"),
|
QIcon::fromTheme("view-time-schedule-baselined-remove"),
|
||||||
i18n("Windows can ask to appear in a certain position.\n"
|
i18n("Windows can ask to appear in a certain position. "
|
||||||
"By default this overrides the placement strategy\n"
|
"By default this overrides the placement strategy "
|
||||||
"what might be nasty if the client abuses the feature\n"
|
"what might be nasty if the client abuses the feature "
|
||||||
"to unconditionally popup in the middle of your screen.")));
|
"to unconditionally popup in the middle of your screen.")));
|
||||||
ignoregeometry->setFlag(RuleItem::AffectsWarning);
|
ignoregeometry->setFlag(RuleItem::AffectsWarning);
|
||||||
|
|
||||||
|
@ -544,10 +544,10 @@ void RulesModel::populateRuleList()
|
||||||
RulePolicy::ForceRule, RuleItem::Boolean,
|
RulePolicy::ForceRule, RuleItem::Boolean,
|
||||||
i18n("Obey geometry restrictions"), i18n("Size & Position"),
|
i18n("Obey geometry restrictions"), i18n("Size & Position"),
|
||||||
QIcon::fromTheme("transform-crop-and-resize"),
|
QIcon::fromTheme("transform-crop-and-resize"),
|
||||||
i18n("Eg. terminals or video players can ask to keep a certain aspect ratio\n"
|
i18n("Eg. terminals or video players can ask to keep a certain aspect ratio "
|
||||||
"or only grow by values larger than one\n"
|
"or only grow by values larger than one "
|
||||||
"(eg. by the dimensions of one character).\n"
|
"(eg. by the dimensions of one character). "
|
||||||
"This may be pointless and the restriction prevents arbitrary dimensions\n"
|
"This may be pointless and the restriction prevents arbitrary dimensions "
|
||||||
"like your complete screen area.")));
|
"like your complete screen area.")));
|
||||||
|
|
||||||
// Arrangement & Access
|
// Arrangement & Access
|
||||||
|
@ -611,10 +611,10 @@ void RulesModel::populateRuleList()
|
||||||
RulePolicy::ForceRule, RuleItem::Option,
|
RulePolicy::ForceRule, RuleItem::Option,
|
||||||
i18n("Focus stealing prevention"), i18n("Appearance & Fixes"),
|
i18n("Focus stealing prevention"), i18n("Appearance & Fixes"),
|
||||||
QIcon::fromTheme("preferences-system-windows-effect-glide"),
|
QIcon::fromTheme("preferences-system-windows-effect-glide"),
|
||||||
i18n("KWin tries to prevent windows from taking the focus\n"
|
i18n("KWin tries to prevent windows from taking the focus "
|
||||||
"(\"activate\") while you're working in another window,\n"
|
"(\"activate\") while you're working in another window, "
|
||||||
"but this may sometimes fail or superact.\n"
|
"but this may sometimes fail or superact. "
|
||||||
"\"None\" will unconditionally allow this window to get the focus while\n"
|
"\"None\" will unconditionally allow this window to get the focus while "
|
||||||
"\"Extreme\" will completely prevent it from taking the focus.")));
|
"\"Extreme\" will completely prevent it from taking the focus.")));
|
||||||
fsplevel->setOptionsData(focusModelData());
|
fsplevel->setOptionsData(focusModelData());
|
||||||
|
|
||||||
|
@ -622,10 +622,10 @@ void RulesModel::populateRuleList()
|
||||||
RulePolicy::ForceRule, RuleItem::Option,
|
RulePolicy::ForceRule, RuleItem::Option,
|
||||||
i18n("Focus protection"), i18n("Appearance & Fixes"),
|
i18n("Focus protection"), i18n("Appearance & Fixes"),
|
||||||
QIcon::fromTheme("preferences-system-windows-effect-minimize"),
|
QIcon::fromTheme("preferences-system-windows-effect-minimize"),
|
||||||
i18n("This controls the focus protection of the currently active window.\n"
|
i18n("This controls the focus protection of the currently active window. "
|
||||||
"None will always give the focus away,\n"
|
"None will always give the focus away, "
|
||||||
"Extreme will keep it.\n"
|
"Extreme will keep it. "
|
||||||
"Otherwise it's interleaved with the stealing prevention\n"
|
"Otherwise it's interleaved with the stealing prevention "
|
||||||
"assigned to the window that wants the focus.")));
|
"assigned to the window that wants the focus.")));
|
||||||
fpplevel->setOptionsData(focusModelData());
|
fpplevel->setOptionsData(focusModelData());
|
||||||
|
|
||||||
|
@ -633,21 +633,21 @@ void RulesModel::populateRuleList()
|
||||||
RulePolicy::ForceRule, RuleItem::Boolean,
|
RulePolicy::ForceRule, RuleItem::Boolean,
|
||||||
i18n("Accept focus"), i18n("Appearance & Fixes"),
|
i18n("Accept focus"), i18n("Appearance & Fixes"),
|
||||||
QIcon::fromTheme("preferences-desktop-cursors"),
|
QIcon::fromTheme("preferences-desktop-cursors"),
|
||||||
i18n("Windows may prevent to get the focus (activate) when being clicked.\n"
|
i18n("Windows may prevent to get the focus (activate) when being clicked. "
|
||||||
"On the other hand you might wish to prevent a window\n"
|
"On the other hand you might wish to prevent a window "
|
||||||
"from getting focused on a mouse click.")));
|
"from getting focused on a mouse click.")));
|
||||||
|
|
||||||
addRule(new RuleItem(QLatin1String("disableglobalshortcuts"),
|
addRule(new RuleItem(QLatin1String("disableglobalshortcuts"),
|
||||||
RulePolicy::ForceRule, RuleItem::Boolean,
|
RulePolicy::ForceRule, RuleItem::Boolean,
|
||||||
i18n("Ignore global shortcuts"), i18n("Appearance & Fixes"),
|
i18n("Ignore global shortcuts"), i18n("Appearance & Fixes"),
|
||||||
QIcon::fromTheme("input-keyboard-virtual-off"),
|
QIcon::fromTheme("input-keyboard-virtual-off"),
|
||||||
i18n("When used, a window will receive\n"
|
i18n("When used, a window will receive "
|
||||||
"all keyboard inputs while it is active, including Alt+Tab etc.\n"
|
"all keyboard inputs while it is active, including Alt+Tab etc. "
|
||||||
"This is especially interesting for emulators or virtual machines.\n"
|
"This is especially interesting for emulators or virtual machines. "
|
||||||
"\n"
|
"\n"
|
||||||
"Be warned:\n"
|
"Be warned: "
|
||||||
"you won't be able to Alt+Tab out of the window\n"
|
"you won't be able to Alt+Tab out of the window "
|
||||||
"nor use any other global shortcut (such as Alt+F2 to show KRunner)\n"
|
"nor use any other global shortcut (such as Alt+F2 to show KRunner) "
|
||||||
"while it's active!")));
|
"while it's active!")));
|
||||||
|
|
||||||
addRule(new RuleItem(QLatin1String("closeable"),
|
addRule(new RuleItem(QLatin1String("closeable"),
|
||||||
|
|
Loading…
Reference in a new issue