Commit 56ddfe70 authored by Leander Schulten's avatar Leander Schulten
Browse files

If the text is wider when the controlItemBlock, the text is now moving when...

If the text is wider when the controlItemBlock, the text is now moving when the mouse hovers over the item so that the whole text can be read
parent 784d26c1
...@@ -3,6 +3,7 @@ import QtQuick.Controls 2.0 ...@@ -3,6 +3,7 @@ import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0 import QtQuick.Layouts 1.0
import QtGraphicalEffects 1.0 import QtGraphicalEffects 1.0
import custom.licht 1.0 import custom.licht 1.0
import QtQml 2.11
ControlItem{ ControlItem{
id:item id:item
...@@ -13,13 +14,65 @@ ControlItem{ ...@@ -13,13 +14,65 @@ ControlItem{
ControlItemBlock{ ControlItemBlock{
blockWidth: 1 blockWidth: 1
id:withRef
clip:true
Label{ Label{
anchors.fill: parent id: textLabel
width: Math.max(implicitWidth,withRef.width)
leftPadding: 4
rightPadding: 4
anchors.top: parent.top
anchors.bottom: parent.bottom
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
text: controlData?controlData.name:"null" text: controlData?controlData.name:"null"
elide: "ElideRight" //elide: "ElideRight"
font.pointSize: 12 font.pointSize: 12
Behavior on x{
NumberAnimation {
alwaysRunToEnd: true
duration: (textLabel.implicitWidth- withRef.width)*15
}
}
Timer{
id:timer
}
onXChanged: {
if( x === withRef.width-textLabel.implicitWidth){ //end of animation
if(!mouseArea.containsMouse){
timer.interval = 500;
timer.triggered.connect(function(){
textLabel.x = 0;
});
timer.start();
}
}
}
MouseArea{
id:mouseArea
anchors.fill: parent
anchors.topMargin: 18
anchors.bottomMargin: 18
hoverEnabled: textLabel.implicitWidth > withRef.width
acceptedButtons: Qt.NoButton
preventStealing: true
propagateComposedEvents: true
onEntered: {
if(textLabel.implicitWidth > withRef.width){
textLabel.x = withRef.width-textLabel.implicitWidth;
}
}
onExited: {
if(textLabel.x === withRef.width-textLabel.implicitWidth){
textLabel.x = 0;
}
}
/*Rectangle{
anchors.fill: parent
color: "blue"
}*/
}
} }
} }
ControlItemBlock{ ControlItemBlock{
......
...@@ -114,9 +114,9 @@ void ControlItem::hoverMoveEvent(QHoverEvent *event){ ...@@ -114,9 +114,9 @@ void ControlItem::hoverMoveEvent(QHoverEvent *event){
event->accept(); event->accept();
auto oldManLength = std::sqrt(std::pow(width() - event->oldPosF().x(),2) + std::pow(event->oldPosF().y(),2)); auto oldManLength = std::sqrt(std::pow(width() - event->oldPosF().x(),2) + std::pow(event->oldPosF().y(),2));
auto newManLength = std::sqrt(std::pow(width() - event->posF().x(),2) + std::pow(event->posF().y(),2)); auto newManLength = std::sqrt(std::pow(width() - event->posF().x(),2) + std::pow(event->posF().y(),2));
if(oldManLength<40&&newManLength>=40) if(oldManLength<40&&newManLength>=41)
emit settingVisibleChange(false); emit settingVisibleChange(false);
else if(oldManLength>40&&newManLength<=40) else if(/*oldManLength>40&&*/newManLength<=40)
emit settingVisibleChange(true); emit settingVisibleChange(true);
} }
void ControlItem::hoverLeaveEvent(QHoverEvent *event){ void ControlItem::hoverLeaveEvent(QHoverEvent *event){
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment