anchor thin tooltips on their visual parents

BUG:447631
work/m_layershell
Michail Vourlakos 3 years ago
parent 8bd168a5a5
commit 9351277cd7

@ -61,10 +61,10 @@ Item {
if (isParabolicEnabled) {
if (root.isHorizontal){
appletItem.layouts.currentSpot = mouseX;
appletItem.layouts.currentSpot = Math.round(mouseX);
calculateParabolicScales(mouseX);
} else{
appletItem.layouts.currentSpot = mouseY;
appletItem.layouts.currentSpot = Math.round(mouseY);
calculateParabolicScales(mouseY);
}
}
@ -84,14 +84,14 @@ Item {
if (root.isHorizontal){
var step = Math.abs(appletItem.layouts.currentSpot-mouseX);
if (step >= appletItem.animations.hoverPixelSensitivity){
appletItem.layouts.currentSpot = mouseX;
appletItem.layouts.currentSpot = Math.round(mouseX);
calculateParabolicScales(mouseX);
}
}
else{
var step = Math.abs(appletItem.layouts.currentSpot-mouseY);
if (step >= appletItem.animations.hoverPixelSensitivity){
appletItem.layouts.currentSpot = mouseY;
appletItem.layouts.currentSpot = Math.round(mouseY);
calculateParabolicScales(mouseY);
}
}

@ -4,13 +4,16 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
import QtQuick 2.0
import QtQuick 2.7
import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
Item{
id: visual
//used from LatteCore.Dialog Tooltips in order to be anchored properly to their visual parent
signal anchoredTooltipPositionChanged();
width: root.isVertical ? thickness : size
height: root.isVertical ? size : thickness
@ -26,6 +29,12 @@ Item{
//border.color: "green"
//color: "transparent"
Connections {
target: appletItem.layouts
enabled: parabolic.isEnabled && appletItem.containsMouse
onCurrentSpotChanged: visual.anchoredTooltipPositionChanged();
}
states:[
State{
name: "bottom"

@ -11,6 +11,7 @@ import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.latte.core 0.2 as LatteCore
import org.kde.latte.abilities.definition 0.1 as AbilityDefinition
AbilityDefinition.ThinTooltip {
@ -108,7 +109,7 @@ AbilityDefinition.ThinTooltip {
}
}
PlasmaCore.Dialog{
LatteCore.Dialog{
id: _tooltipDialog
type: PlasmaCore.Dialog.Tooltip
flags: Qt.WindowStaysOnTopHint | Qt.WindowDoesNotAcceptFocus | Qt.ToolTip

@ -100,6 +100,13 @@ Item{
readonly property bool isHorizontal: !isVertical
readonly property bool isVertical: plasmoid.formFactor === PlasmaCore.Types.Vertical
readonly property bool parabolicAreaContainsMouse: parabolicEventsAreaLoader.active && parabolicEventsAreaLoader.item.containsMouse
readonly property int parabolicAreaLastMousePos: {
if (parabolicEventsAreaLoader.active) {
return Math.round(plasmoid.formFactor === PlasmaCore.Types.Horizontal ? parabolicEventsAreaLoader.item.lastMouseX : parabolicEventsAreaLoader.lastMouseY);
}
return 0;
}
readonly property int location: {
if (plasmoid.location === PlasmaCore.Types.LeftEdge

@ -4,19 +4,28 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
import QtQuick 2.0
import QtQuick 2.7
import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
Item{
id: visual
//used from LatteCore.Dialog Tooltips in order to be anchored properly to their visual parent
signal anchoredTooltipPositionChanged();
width: abilityItem.isVertical ? thickness : size
height: abilityItem.isVertical ? size : thickness
property int size: 1
property int thickness: 64
Connections {
target: abilityItem
enabled: abilityItem.abilities.parabolic.isEnabled && abilityItem.containsMouse
onParabolicAreaLastMousePosChanged: visual.anchoredTooltipPositionChanged();
}
states:[
State{
name: "bottom"

@ -16,6 +16,7 @@ namespace Quick {
Dialog::Dialog(QQuickItem *parent)
: PlasmaQuick::Dialog(parent)
{
connect(this, &PlasmaQuick::Dialog::visualParentChanged, this, &Dialog::onVisualParentChanged);
}
bool Dialog::containsMouse() const
@ -66,6 +67,31 @@ int Dialog::appletsPopUpMargin() const
return margin.isValid() ? margin.toInt() : -1;
}
void Dialog::onVisualParentChanged()
{
// clear mode
for (auto &c : m_visualParentConnections) {
disconnect(c);
}
if (!visualParent() || !flags().testFlag(Qt::ToolTip) || !visualParent()->metaObject()) {
return;
}
bool hassignal = (visualParent()->metaObject()->indexOfSignal(QMetaObject::normalizedSignature("anchoredTooltipPositionChanged()")) != -1);
if (hassignal) {
m_visualParentConnections[0] = connect(visualParent(), SIGNAL(anchoredTooltipPositionChanged()) , this, SLOT(updateGeometry()));
}
}
void Dialog::updateGeometry()
{
if (visualParent()) {
setPosition(popupPosition(visualParent(), size()));
}
}
void Dialog::updatePopUpEnabledBorders()
{
QRect appletslayoutgeometry = appletsLayoutGeometryFromContainment();

@ -47,6 +47,9 @@ private slots:
void setContainsMouse(bool contains);
void updatePopUpEnabledBorders();
void onVisualParentChanged();
void updateGeometry();
private:
bool isRespectingAppletsLayoutGeometry() const;
QRect appletsLayoutGeometryFromContainment() const;
@ -58,6 +61,7 @@ private:
Plasma::Types::Location m_edge{Plasma::Types::BottomEdge};
std::array<QMetaObject::Connection, 2> m_visualParentConnections;
};

Loading…
Cancel
Save