Skip to content

Commit eb7804b

Browse files
committed
Repair tooltip in jaspControl
1 parent bdb29bc commit eb7804b

File tree

4 files changed

+15
-44
lines changed

4 files changed

+15
-44
lines changed

QMLComponents/components/JASP/Controls/CheckBox.qml

+4-21
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@
1616
// <http://www.gnu.org/licenses/>.
1717
//
1818

19-
import QtQuick 2.11
20-
import QtQuick.Controls 2.4
21-
import QtQuick.Layouts 1.3 as L
22-
import JASP 1.0
19+
import QtQuick
20+
import QtQuick.Controls as QtC
21+
import JASP
2322

2423

2524
CheckBoxBase
@@ -44,7 +43,6 @@ CheckBoxBase
4443
property alias fontInfo: label.fontInfo
4544
property alias label: control.text
4645
property alias labelTextFormat: label.textFormat
47-
property string toolTip: ""
4846
property alias checked: control.checked
4947
property bool childrenOnSameRow: false
5048
property alias columns: childControlsArea.columns
@@ -54,22 +52,7 @@ CheckBoxBase
5452
function click() { control.toggle(); }
5553
function toggle() { control.toggle(); }
5654

57-
MouseArea
58-
{
59-
id: hoverMe
60-
anchors.fill: parent
61-
hoverEnabled: true
62-
}
63-
64-
ToolTip
65-
{
66-
text: checkBox.toolTip
67-
timeout: jaspTheme.toolTipTimeout
68-
delay: jaspTheme.toolTipDelay
69-
visible: checkBox.toolTip !== "" && (hoverMe.containsMouse || control.hovered)
70-
}
71-
72-
CheckBox
55+
QtC.CheckBox
7356
{
7457
id: control
7558
padding: jaspTheme.jaspControlPadding

QMLComponents/components/JASP/Controls/RadioButton.qml

+4-20
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
// <http://www.gnu.org/licenses/>.
1717
//
1818

19-
import QtQuick 2.11
20-
import QtQuick.Controls 2.4
21-
import JASP 1.0
19+
import QtQuick
20+
import QtQuick.Controls as QtC
21+
import JASP
2222

2323

2424
RadioButtonBase
@@ -41,7 +41,6 @@ RadioButtonBase
4141
property alias childrenArea: childControlsArea
4242
property alias text: control.text
4343
property alias label: control.text
44-
property string toolTip: ""
4544
property alias checked: control.checked
4645
property alias value: radioButton.name
4746
property bool childrenOnSameRow: false
@@ -52,22 +51,7 @@ RadioButtonBase
5251
function click() { clicked(); }
5352
onClicked: { radioButton.clickHandler(); }
5453

55-
MouseArea
56-
{
57-
id: hoverMe
58-
anchors.fill: parent
59-
hoverEnabled: true
60-
}
61-
62-
ToolTip
63-
{
64-
text: radioButton.toolTip
65-
timeout: jaspTheme.toolTipTimeout
66-
delay: jaspTheme.toolTipDelay
67-
visible: radioButton.toolTip !== "" && (hoverMe.containsMouse || control.hovered)
68-
}
69-
70-
RadioButton
54+
QtC.RadioButton
7155
{
7256
id: control
7357
padding: jaspTheme.jaspControlPadding

QMLComponents/controls/jaspcontrol.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@ const QStringList JASPControl::_optionReservedNames = {"data", "version"};
1313
QMap<QQmlEngine*, QQmlComponent*> JASPControl::_mouseAreaComponentMap;
1414
QByteArray JASPControl::_mouseAreaDef = "\
1515
import QtQuick\n\
16+
import QtQuick.Controls\n\
1617
MouseArea {\n\
1718
z: 5\n\
1819
anchors.fill: parent\n\
1920
acceptedButtons: Qt.NoButton\n\
21+
ToolTip.timeout: jaspTheme.toolTipTimeout\n\
22+
ToolTip.delay: jaspTheme.toolTipDelay\n\
23+
ToolTip.text: parent ? parent.toolTip : ''\n\
24+
ToolTip.visible: ToolTip.text && containsMouse\n\
2025
}";
2126

2227
QQmlComponent* JASPControl::getMouseAreaComponent(QQmlEngine* engine)
@@ -53,7 +58,6 @@ JASPControl::JASPControl(QQuickItem *parent) : QQuickItem(parent)
5358
connect(this, &JASPControl::indentChanged, [this] () { QQmlProperty(this, "Layout.leftMargin", qmlContext(this)).write( (indent() && JaspTheme::currentTheme()) ? JaspTheme::currentTheme()->indentationLength() : 0); });
5459
connect(this, &JASPControl::debugChanged, [this] () { _setBackgroundColor(); _setVisible(); } );
5560
connect(this, &JASPControl::parentDebugChanged, [this] () { _setBackgroundColor(); _setVisible(); } );
56-
connect(this, &JASPControl::toolTipChanged, [this] () { QQmlProperty(this, "ToolTip.text", qmlContext(this)).write(toolTip()); } );
5761
connect(this, &JASPControl::boundValueChanged, this, &JASPControl::_resetBindingValue);
5862
connect(this, &JASPControl::activeFocusChanged, this, &JASPControl::_setFocus);
5963
connect(this, &JASPControl::activeFocusChanged, this, &JASPControl::_notifyFormOfActiveFocus);
@@ -707,7 +711,7 @@ JASPControl *JASPControl::parentListViewEx() const
707711
bool JASPControl::hovered() const
708712
{
709713
if (_mouseAreaObj)
710-
return _mouseAreaObj->property("hovered").toBool();
714+
return _mouseAreaObj->property("containsMouse").toBool();
711715
else
712716
return false;
713717
}

QMLComponents/jasptheme.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ private slots:
721721
theme_timeType _hoverTime = 400,
722722
_fileMenuSlideDuration = 150,
723723
_toolTipDelay = 500,
724-
_toolTipTimeout =60000;
724+
_toolTipTimeout = 5000;
725725

726726
QFont _font,
727727
_fontLink,

0 commit comments

Comments
 (0)