mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-25 23:53:56 -06:00
Add support for displaying setting tooltips with descriptions
This commit is contained in:
parent
b67a2bff31
commit
0d5e10219c
3 changed files with 71 additions and 2 deletions
|
@ -13,6 +13,16 @@ UM.AngledCornerRectangle {
|
||||||
|
|
||||||
cornerSize: UM.Theme.sizes.default_margin.width;
|
cornerSize: UM.Theme.sizes.default_margin.width;
|
||||||
|
|
||||||
|
function showTooltip(item, position, text) {
|
||||||
|
tooltip.text = text;
|
||||||
|
position = item.mapToItem(base, position.x, position.y);
|
||||||
|
tooltip.show(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
function hideTooltip() {
|
||||||
|
tooltip.hide();
|
||||||
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
acceptedButtons: Qt.AllButtons;
|
acceptedButtons: Qt.AllButtons;
|
||||||
|
@ -25,7 +35,7 @@ UM.AngledCornerRectangle {
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
anchors.fill: parent;
|
anchors.fill: parent;
|
||||||
anchors.topMargin: UM.Theme.sizes.default_margin.height;
|
anchors.topMargin: UM.Theme.sizes.default_margin.height;
|
||||||
anchors.bottomMargin: UM.Theme.sizes.default_margin.height;
|
anchors.bottomMargin: UM.Theme.sizes.window_margin.height;
|
||||||
|
|
||||||
spacing: UM.Theme.sizes.default_margin.height;
|
spacing: UM.Theme.sizes.default_margin.height;
|
||||||
|
|
||||||
|
@ -45,6 +55,10 @@ UM.AngledCornerRectangle {
|
||||||
Layout.fillHeight: true;
|
Layout.fillHeight: true;
|
||||||
|
|
||||||
source: header.currentModeFile;
|
source: header.currentModeFile;
|
||||||
|
|
||||||
|
property Item sidebar: base;
|
||||||
|
|
||||||
|
onLoaded: item.configureSettings = base.configureMachinesAction
|
||||||
}
|
}
|
||||||
|
|
||||||
OutputGCodeButton {
|
OutputGCodeButton {
|
||||||
|
@ -53,4 +67,8 @@ UM.AngledCornerRectangle {
|
||||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter;
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SidebarTooltip {
|
||||||
|
id: tooltip;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,8 @@ ScrollView {
|
||||||
model: delegateItem.settingsModel;
|
model: delegateItem.settingsModel;
|
||||||
|
|
||||||
delegate: UM.SettingItem {
|
delegate: UM.SettingItem {
|
||||||
|
id: item;
|
||||||
|
|
||||||
width: UM.Theme.sizes.setting.width;
|
width: UM.Theme.sizes.setting.width;
|
||||||
|
|
||||||
height: model.visible ? UM.Theme.sizes.setting.height : 0;
|
height: model.visible ? UM.Theme.sizes.setting.height : 0;
|
||||||
|
@ -95,6 +97,12 @@ ScrollView {
|
||||||
onItemValueChanged: delegateItem.settingsModel.setSettingValue(index, model.key, value);
|
onItemValueChanged: delegateItem.settingsModel.setSettingValue(index, model.key, value);
|
||||||
onContextMenuRequested: contextMenu.popup();
|
onContextMenuRequested: contextMenu.popup();
|
||||||
|
|
||||||
|
onShowTooltip: {
|
||||||
|
position = { x: UM.Theme.sizes.default_margin.width, y: item.height }
|
||||||
|
sidebar.showTooltip(item, position, model.description);
|
||||||
|
}
|
||||||
|
onHideTooltip: sidebar.hideTooltip();
|
||||||
|
|
||||||
Menu {
|
Menu {
|
||||||
id: contextMenu;
|
id: contextMenu;
|
||||||
|
|
||||||
|
@ -102,7 +110,6 @@ ScrollView {
|
||||||
//: Settings context menu action
|
//: Settings context menu action
|
||||||
text: qsTr("Hide this setting");
|
text: qsTr("Hide this setting");
|
||||||
onTriggered: delegateItem.settingsModel.hideSetting(model.key);
|
onTriggered: delegateItem.settingsModel.hideSetting(model.key);
|
||||||
// onTriggered: settingsList.model.setVisibility(model.key, false);
|
|
||||||
}
|
}
|
||||||
MenuItem {
|
MenuItem {
|
||||||
//: Settings context menu action
|
//: Settings context menu action
|
||||||
|
|
44
qml/SidebarTooltip.qml
Normal file
44
qml/SidebarTooltip.qml
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
import QtQuick 2.2
|
||||||
|
import QtQuick.Controls 1.1
|
||||||
|
import QtQuick.Controls.Styles 1.1
|
||||||
|
import QtQuick.Layouts 1.1
|
||||||
|
|
||||||
|
import UM 1.0 as UM
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: base;
|
||||||
|
|
||||||
|
width: UM.Theme.sizes.tooltip.width;
|
||||||
|
height: label.height + UM.Theme.sizes.tooltip_margins.height * 2;
|
||||||
|
color: UM.Theme.colors.tooltip;
|
||||||
|
|
||||||
|
opacity: 0;
|
||||||
|
Behavior on opacity { NumberAnimation { duration: 100; } }
|
||||||
|
|
||||||
|
property alias text: label.text;
|
||||||
|
|
||||||
|
function show(position) {
|
||||||
|
x = position.x;
|
||||||
|
y = position.y;
|
||||||
|
base.opacity = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
function hide() {
|
||||||
|
base.opacity = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
id: label;
|
||||||
|
anchors {
|
||||||
|
top: parent.top;
|
||||||
|
topMargin: UM.Theme.sizes.tooltip_margins.height;
|
||||||
|
left: parent.left;
|
||||||
|
leftMargin: UM.Theme.sizes.tooltip_margins.width;
|
||||||
|
right: parent.right;
|
||||||
|
rightMargin: UM.Theme.sizes.tooltip_margins.width;
|
||||||
|
}
|
||||||
|
|
||||||
|
// horizontalAlignment: Qt.AlignJustify;
|
||||||
|
wrapMode: Text.Wrap;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue