add new options to indicators interface

--providesHoveredAnimation, in order to disable
the Latte one
--providesClickedAnimation, in order to disable
the Latte one
--needsMouseEventCoordinates, in order to know
when the mouse pressed e.g. creating animations
like the android way
pull/5/head
Michail Vourlakos 6 years ago
parent 20a57f3c15
commit d95d861b64

@ -48,6 +48,51 @@ void Info::setNeedsIconColors(bool needs)
emit needsIconColorsChanged();
}
bool Info::needsMouseEventCoordinates() const
{
return m_needsMouseEventCoordinates;
}
void Info::setNeedsMouseEventCoordinates(bool needs)
{
if (m_needsMouseEventCoordinates == needs) {
return;
}
m_needsMouseEventCoordinates = needs;
emit needsMouseEventCoordinatesChanged();
}
bool Info::providesClickedAnimation() const
{
return m_providesClickedAnimation;
}
void Info::setProvidesClickedAnimation(bool provides)
{
if (m_providesClickedAnimation == provides) {
return;
}
m_providesClickedAnimation = provides;
emit providesClickedAnimationChanged();
}
bool Info::providesHoveredAnimation() const
{
return m_providesHoveredAnimation;
}
void Info::setProvidesHoveredAnimation(bool provides)
{
if (m_providesHoveredAnimation == provides) {
return;
}
m_providesHoveredAnimation = provides;
emit providesHoveredAnimationChanged();
}
bool Info::providesFrontLayer() const
{
return m_providesFrontLayer;

@ -35,6 +35,9 @@ class Info: public QObject
{
Q_OBJECT
Q_PROPERTY(bool needsIconColors READ needsIconColors WRITE setNeedsIconColors NOTIFY needsIconColorsChanged)
Q_PROPERTY(bool needsMouseEventCoordinates READ needsMouseEventCoordinates WRITE setNeedsMouseEventCoordinates NOTIFY needsMouseEventCoordinatesChanged)
Q_PROPERTY(bool providesClickedAnimation READ providesClickedAnimation WRITE setProvidesClickedAnimation NOTIFY providesClickedAnimationChanged)
Q_PROPERTY(bool providesHoveredAnimation READ providesHoveredAnimation WRITE setProvidesHoveredAnimation NOTIFY providesHoveredAnimationChanged)
Q_PROPERTY(bool providesFrontLayer READ providesFrontLayer WRITE setProvidesFrontLayer NOTIFY providesFrontLayerChanged)
Q_PROPERTY(int extraMaskThickness READ extraMaskThickness WRITE setExtraMaskThickness NOTIFY extraMaskThicknessChanged)
@ -49,6 +52,15 @@ public:
bool needsIconColors() const;
void setNeedsIconColors(bool needs);
bool needsMouseEventCoordinates() const;
void setNeedsMouseEventCoordinates(bool needs);
bool providesClickedAnimation() const;
void setProvidesClickedAnimation(bool provides);
bool providesHoveredAnimation() const;
void setProvidesHoveredAnimation(bool provides);
bool providesFrontLayer() const;
void setProvidesFrontLayer(bool front);
@ -66,10 +78,16 @@ signals:
void minLengthPaddingChanged();
void minThicknessPaddingChanged();
void needsIconColorsChanged();
void needsMouseEventCoordinatesChanged();
void providesClickedAnimationChanged();
void providesHoveredAnimationChanged();
void providesFrontLayerChanged();
private:
bool m_needsIconColors{false};
bool m_needsMouseEventCoordinates{false};
bool m_providesClickedAnimation{false};
bool m_providesHoveredAnimation{false};
bool m_providesFrontLayer{false};
int m_extraMaskThickness{0};

@ -41,6 +41,8 @@ Item {
width: isInternalViewSplitter && !root.inConfigureAppletsMode ? 0 : computeWidth
height: isInternalViewSplitter && !root.inConfigureAppletsMode ? 0 : computeHeight
signal mousePressed(int x, int y);
property bool animationsEnabled: true
property bool animationWasSent: false //protection flag for animation broadcasting
property bool canBeHovered: true
@ -653,7 +655,7 @@ Item {
anchors.fill: parent
enabled: applet && !latteApplet && canBeHovered && !originalAppletBehavior && !communicator.parabolicEffectLocked
hoverEnabled: latteApplet ? false : true
propagateComposedEvents: true
// propagateComposedEvents: true
//! a way must be found in order for this be enabled
//! only to support springloading for plasma 5.10
@ -772,6 +774,7 @@ Item {
}
onPressed: {
appletItem.mousePressed(mouse.x, mouse.y);
appletItem.activateAppletForNeutralAreas(mouse);
pressed = true;
@ -899,7 +902,7 @@ Item {
SequentialAnimation{
id: clickedAnimation
alwaysRunToEnd: true
running: (appletMouseArea.pressed || appletMouseAreaBottom.pressed) && (root.durationTime > 0)
running: (appletMouseArea.pressed || appletMouseAreaBottom.pressed) && (root.durationTime > 0) && !indicators.info.providesClickedAnimation
onStopped: {
appletMouseArea.pressed = false;

@ -570,7 +570,7 @@ Item{
anchors.fill: _wrapperContainer
source: _wrapperContainer
enabled: opacity != 0 ? true : false
enabled: !indicators.info.providesHoveredAnimation && opacity != 0 ? true : false
opacity: appletMouseArea.containsMouse ? 1 : 0
brightness: 0.25
contrast: 0.15

@ -88,4 +88,14 @@ Item{
//! grouped options
readonly property Item shared: indicators
readonly property QtObject configuration: indicators.configuration
Connections {
target: appletIsValid /*&& indicators.info.needsMouseEventCoordinates*/ ? appletItem : null
onMousePressed: {
console.log(x + " _ " + y);
var fixedPos = level.mapFromItem(appletItem, x, y);
console.log("f: " + fixedPos.x + " _ " + fixedPos.y);
level.mousePressed(fixedPos.x, fixedPos.y);
}
}
}

@ -24,6 +24,8 @@ import org.kde.latte 0.2 as Latte
Item {
id: level
signal mousePressed(int x, int y);
property bool isBackground: true
property bool isForeground: false

@ -19,11 +19,19 @@
import QtQuick 2.7
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.latte 0.2 as Latte
Loader {
id: indicatorLoader
anchors.fill: parent
anchors.bottom: (plasmoid.location === PlasmaCore.Types.BottomEdge) ? parent.bottom : undefined
anchors.top: (plasmoid.location === PlasmaCore.Types.TopEdge) ? parent.top : undefined
anchors.left: (plasmoid.location === PlasmaCore.Types.LeftEdge) ? parent.left : undefined
anchors.right: (plasmoid.location === PlasmaCore.Types.RightEdge) ? parent.right : undefined
anchors.horizontalCenter: root.isHorizontal ? parent.horizontalCenter : undefined
anchors.verticalCenter: root.isVertical ? parent.verticalCenter : undefined
active: level.bridge && level.bridge.active && (level.isBackground || (level.isForeground && indicators.info.providesFrontLayer))
sourceComponent: {
@ -34,5 +42,37 @@ Loader {
return indicators.indicatorComponent;
}
width: {
if (locked) {
return visualLockedWidth;
}
return root.isHorizontal ? appletItem.wrapperAlias.width - 2*appletItem.wrapperAlias.zoomScale*root.lengthExtMargin : appletItem.wrapperAlias.width;
}
height: {
if (locked) {
return visualLockedHeight;
}
return root.vertical ? appletItem.wrapperAlias.height - 2*appletItem.wrapperAlias.zoomScale*root.lengthExtMargin : appletItem.wrapperAlias.height;
}
readonly property bool locked: appletItem.lockZoom || root.zoomFactor === 1
property real visualLockedWidth: root.iconSize + root.internalWidthMargins
property real visualLockedHeight: root.iconSize + root.internalHeightMargins
//! Communications !//
property Item level
Connections {
target: appletItem
enabled: indicators.info.needsMouseEventCoordinates
onMousePressed: {
var fixedPos = indicatorLoader.mapFromItem(appletItem, x, y);
level.mousePressed(Math.round(fixedPos.x), Math.round(fixedPos.y));
}
}
}

@ -43,9 +43,19 @@ Item{
readonly property Item info: Item{
readonly property bool needsIconColors: metricsLoader.active && metricsLoader.item && metricsLoader.item.hasOwnProperty("needsIconColors")
&& metricsLoader.item.needsIconColors
readonly property bool needsMouseEventCoordinates: metricsLoader.active && metricsLoader.item && metricsLoader.item.hasOwnProperty("needsMouseEventCoordinates")
&& metricsLoader.item.needsMouseEventCoordinates
readonly property bool providesFrontLayer: metricsLoader.active && metricsLoader.item && metricsLoader.item.hasOwnProperty("providesFrontLayer")
&& metricsLoader.item.providesFrontLayer
readonly property bool providesHoveredAnimation: metricsLoader.active && metricsLoader.item && metricsLoader.item.hasOwnProperty("providesHoveredAnimation")
&& metricsLoader.item.providesHoveredAnimation
readonly property bool providesClickedAnimation: metricsLoader.active && metricsLoader.item && metricsLoader.item.hasOwnProperty("providesClickedAnimation")
&& metricsLoader.item.providesClickedAnimation
readonly property int extraMaskThickness: {
if (metricsLoader.active && metricsLoader.item && metricsLoader.item.hasOwnProperty("extraMaskThickness")) {
return metricsLoader.item.extraMaskThickness;
@ -95,6 +105,27 @@ Item{
value: managerIndicator.info.needsIconColors
}
Binding{
target: latteView && latteView.indicator ? latteView.indicator.info : null
property:"needsMouseEventCoordinates"
when: latteView && latteView.indicator
value: managerIndicator.info.needsMouseEventCoordinates
}
Binding{
target: latteView && latteView.indicator ? latteView.indicator.info : null
property:"providesClickedAnimation"
when: latteView && latteView.indicator
value: managerIndicator.info.providesClickedAnimation
}
Binding{
target: latteView && latteView.indicator ? latteView.indicator.info : null
property:"providesHoveredAnimation"
when: latteView && latteView.indicator
value: managerIndicator.info.providesHoveredAnimation
}
Binding{
target: latteView && latteView.indicator ? latteView.indicator.info : null
property:"providesFrontLayer"

@ -349,6 +349,12 @@ DragDrop.DropArea {
property int lengthMargin: lengthIntMargin + lengthExtMargin
property int lengthMargins: 2 * lengthMargin
property int widthMargins: root.isVertical ? thickMargins : lengthMargins
property int heightMargins: root.isHorizontal ? thickMargins : lengthMargins
property int internalWidthMargins: root.isVertical ? thickMargins : 2 * lengthIntMargin
property int internalHeightMargins: root.isHorizontal ? thickMargins : 2 * lengthIntMargin
///FIXME: <delete both> I can't remember why this is needed, maybe for the anchorings!!! In order for the Double Layout to not mess the anchorings...
//property int layoutsContainer.mainLayoutPosition: !plasmoid.immutable ? Latte.Types.Center : (root.isVertical ? Latte.Types.Top : Latte.Types.Left)
//property int panelAlignment: plasmoid.configuration.panelPosition !== Latte.Types.Justify ? plasmoid.configuration.panelPosition : layoutsContainer.mainLayoutPosition

@ -41,8 +41,13 @@ Item{
readonly property Item info: Item{
readonly property bool needsIconColors: false
readonly property bool needsMouseEventCoordinates: false
readonly property bool providesFrontLayer: false
readonly property bool providesHoveredAnimation: false
readonly property bool providesClickedAnimation: false
readonly property int extraMaskThickness: 0
readonly property real minThicknessPadding: 0
readonly property real minLengthPadding:0
}
IndicatorOptions.Latte {

@ -512,7 +512,7 @@ Item{
source: badgesLoader.active ? badgesLoader : iconImageBuffer
visible: !isSeparator
opacity: taskItem.containsMouse && !clickedAnimation.running ? 1 : 0
opacity: taskItem.containsMouse && !clickedAnimation.running && !indicators.info.providesHoveredAnimation ? 1 : 0
brightness: 0.30
contrast: 0.1

@ -66,7 +66,7 @@ SequentialAnimation{
onPressedChanged: {
if( !running && pressed&&
if(!running && pressed && !indicators.info.providesClickedAnimation &&
((taskItem.lastButtonClicked == Qt.LeftButton)||(taskItem.lastButtonClicked == Qt.MidButton)) ){
//taskItem.animationStarted();
start();

@ -24,6 +24,8 @@ import org.kde.latte 0.2 as Latte
Item {
id: level
signal mousePressed(int x, int y);
property bool isBackground: true
property bool isForeground: false

@ -58,5 +58,16 @@ Loader {
property real visualLockedWidth: root.iconSize + root.internalWidthMargins
property real visualLockedHeight: root.iconSize + root.internalHeightMargins
//! Connections !//
property Item level
Connections {
target: taskItem
enabled: indicators.info.needsMouseEventCoordinates
onPressed: {
var fixedPos = indicatorLoader.mapFromItem(taskItem, mouse.x, mouse.y);
level.mousePressed(Math.round(fixedPos.x), Math.round(fixedPos.y));
}
}
}

Loading…
Cancel
Save