mirror of
https://github.com/KDE/latte-dock.git
synced 2024-12-25 19:21:41 +03:00
send mouse signals from View to containment
--this is side-way path for mouse events and more specific the mouse pressed, released events to be sent from parent window to its qml containment part. This way it is possible to keep the original plasma applet behavior such as original plasma tooltips and provide Latte specific functionality such as animated clicks from indicators. NOTE: An investigation - testing took place in order to check if this approach could be also used for mouseMove events to be used for applets parabolic effect. The result was that this was not possible because there were too many signals and too much calculations too identify for which applet the signal belonged to. The parabolic effect was not fluid in that case and could not catch up.
This commit is contained in:
parent
bcbc822541
commit
6505e8797f
@ -1052,6 +1052,7 @@ void Corona::setBroadcastedBackgroundsEnabled(QString activity, QString screenNa
|
||||
inline void Corona::qmlRegisterTypes() const
|
||||
{
|
||||
qmlRegisterType<QScreen>();
|
||||
qmlRegisterType<Latte::View>();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -40,6 +40,7 @@
|
||||
|
||||
// Qt
|
||||
#include <QAction>
|
||||
#include <QMouseEvent>
|
||||
#include <QQmlContext>
|
||||
#include <QQmlEngine>
|
||||
#include <QQmlProperty>
|
||||
@ -68,7 +69,7 @@ View::View(Plasma::Corona *corona, QScreen *targetScreen, bool byPassWM)
|
||||
m_contextMenu(new ViewPart::ContextMenu(this)),
|
||||
m_effects(new ViewPart::Effects(this)),
|
||||
m_positioner(new ViewPart::Positioner(this)) //needs to be created after Effects because it catches some of its signals
|
||||
{
|
||||
{
|
||||
setTitle(corona->kPackage().metadata().name());
|
||||
setIcon(qGuiApp->windowIcon());
|
||||
setResizeMode(QuickViewSharedEngine::SizeRootObjectToView);
|
||||
@ -1007,7 +1008,7 @@ ViewPart::WindowsTracker *View::windowsTracker() const
|
||||
}
|
||||
|
||||
bool View::event(QEvent *e)
|
||||
{
|
||||
{
|
||||
if (!m_inDelete) {
|
||||
emit eventTriggered(e);
|
||||
|
||||
@ -1036,6 +1037,17 @@ bool View::event(QEvent *e)
|
||||
engine()->trimComponentCache();
|
||||
break;
|
||||
|
||||
case QEvent::MouseButtonPress:
|
||||
if (auto mouseEvent = dynamic_cast<QMouseEvent *>(e)) {
|
||||
emit mousePressed(mouseEvent->x(), mouseEvent->y(), mouseEvent->button());
|
||||
}
|
||||
break;
|
||||
case QEvent::MouseButtonRelease:
|
||||
if (auto mouseEvent = dynamic_cast<QMouseEvent *>(e)) {
|
||||
emit mouseReleased(mouseEvent->x(), mouseEvent->y(), mouseEvent->button());
|
||||
}
|
||||
break;
|
||||
|
||||
case QEvent::PlatformSurface:
|
||||
if (auto pe = dynamic_cast<QPlatformSurfaceEvent *>(e)) {
|
||||
switch (pe->surfaceEventType()) {
|
||||
|
@ -227,6 +227,8 @@ protected:
|
||||
|
||||
signals:
|
||||
void eventTriggered(QEvent *ev);
|
||||
void mousePressed(const int x, const int y, const int button);
|
||||
void mouseReleased(const int x, const int y, const int button);
|
||||
|
||||
void activitiesChanged();
|
||||
void alternativesIsShownChanged();
|
||||
@ -290,6 +292,7 @@ private:
|
||||
bool m_isPreferredForShortcuts{false};
|
||||
bool m_latteTasksArePresent{false};
|
||||
bool m_onPrimary{true};
|
||||
|
||||
int m_fontPixelSize{ -1};
|
||||
int m_editThickness{24};
|
||||
int m_maxThickness{24};
|
||||
|
@ -18,7 +18,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import QtQuick 2.1
|
||||
import QtQuick 2.7
|
||||
import QtQuick.Layouts 1.1
|
||||
import QtGraphicalEffects 1.0
|
||||
|
||||
@ -41,7 +41,8 @@ Item {
|
||||
width: isInternalViewSplitter && !root.inConfigureAppletsMode ? 0 : computeWidth
|
||||
height: isInternalViewSplitter && !root.inConfigureAppletsMode ? 0 : computeHeight
|
||||
|
||||
signal mousePressed(int x, int y);
|
||||
signal mousePressed(int x, int y, int button);
|
||||
signal mouseReleased(int x, int y, int button);
|
||||
|
||||
property bool animationsEnabled: true
|
||||
property bool animationWasSent: false //protection flag for animation broadcasting
|
||||
@ -134,8 +135,8 @@ Item {
|
||||
property Item communicatorAlias: communicator
|
||||
property Item wrapperAlias: wrapper
|
||||
|
||||
property alias containsMouse: appletMouseArea.containsMouse
|
||||
property alias pressed: appletMouseArea.pressed
|
||||
property bool containsMouse: appletMouseArea.containsMouse || appletMouseAreaBottom.containsMouse
|
||||
property bool pressed: viewSignalsConnector.pressed || clickedAnimation.running
|
||||
|
||||
/*onComputeHeightChanged: {
|
||||
if(index==0)
|
||||
@ -448,6 +449,30 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
id: viewSignalsConnector
|
||||
target: root.latteView ? root.latteView : null
|
||||
enabled: !appletItem.isLattePlasmoid && !appletItem.isSeparator && !appletItem.isSpacer && !appletItem.isHidden
|
||||
|
||||
property bool pressed: false
|
||||
|
||||
onMousePressed: {
|
||||
if (appletItem.containsPos(Qt.point(x, y))) {
|
||||
viewSignalsConnector.pressed = true;
|
||||
var local = appletItem.mapFromItem(root, x, y);
|
||||
appletItem.mousePressed(local.x, local.y, button);
|
||||
}
|
||||
}
|
||||
|
||||
onMouseReleased: {
|
||||
if (appletItem.containsPos(Qt.point(x, y))) {
|
||||
viewSignalsConnector.pressed = false;
|
||||
var local = appletItem.mapFromItem(root, x, y);
|
||||
appletItem.mouseReleased(local.x, local.y, button);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///END connections
|
||||
|
||||
//! It is used for any communication needed with the underlying applet
|
||||
@ -494,16 +519,12 @@ Item {
|
||||
propagateComposedEvents: true
|
||||
visible: (!appletMouseArea.visible || !appletMouseArea.enabled) && !root.editMode && !originalAppletBehavior
|
||||
|
||||
property bool pressed: false
|
||||
|
||||
onPressed: {
|
||||
appletItem.activateAppletForNeutralAreas(mouse);
|
||||
pressed = true;
|
||||
mouse.accepted = false;
|
||||
}
|
||||
|
||||
onReleased: {
|
||||
pressed = false;
|
||||
mouse.accepted = false;
|
||||
}
|
||||
}
|
||||
@ -665,10 +686,8 @@ Item {
|
||||
visible: applet && !isLattePlasmoid && !originalAppletBehavior && !appletItem.isSeparator && !communicator.parabolicEffectLocked
|
||||
|
||||
property bool blockWheel: false
|
||||
property bool pressed: false
|
||||
|
||||
onClicked: {
|
||||
pressed = false;
|
||||
mouse.accepted = false;
|
||||
}
|
||||
|
||||
@ -728,7 +747,6 @@ Item {
|
||||
}
|
||||
|
||||
onPositionChanged: {
|
||||
// if(!pressed){
|
||||
if (originalAppletBehavior || !canBeHovered) {
|
||||
mouse.accepted = false;
|
||||
return;
|
||||
@ -774,17 +792,14 @@ Item {
|
||||
}
|
||||
|
||||
onPressed: {
|
||||
appletItem.mousePressed(mouse.x, mouse.y);
|
||||
appletItem.activateAppletForNeutralAreas(mouse);
|
||||
|
||||
pressed = true;
|
||||
//! this is needed for some applets is order to be activated/deactivated correctly
|
||||
//! such case is the "Application Menu". (bug #928)
|
||||
mouse.accepted = false;
|
||||
}
|
||||
|
||||
onReleased: {
|
||||
pressed = false;
|
||||
mouse.accepted = false;
|
||||
}
|
||||
|
||||
@ -902,12 +917,7 @@ Item {
|
||||
SequentialAnimation{
|
||||
id: clickedAnimation
|
||||
alwaysRunToEnd: true
|
||||
running: (appletMouseArea.pressed || appletMouseAreaBottom.pressed) && (root.durationTime > 0) && !indicators.info.providesClickedAnimation
|
||||
|
||||
onStopped: {
|
||||
appletMouseArea.pressed = false;
|
||||
appletMouseAreaBottom.pressed = false;
|
||||
}
|
||||
running: (appletItem.pressed) && (root.durationTime > 0) && !indicators.info.providesClickedAnimation
|
||||
|
||||
ParallelAnimation{
|
||||
PropertyAnimation {
|
||||
|
@ -24,7 +24,8 @@ import org.kde.latte 0.2 as Latte
|
||||
Item {
|
||||
id: level
|
||||
|
||||
signal mousePressed(int x, int y);
|
||||
signal mousePressed(int x, int y, int button);
|
||||
signal mouseReleased(int x, int y, int button);
|
||||
|
||||
property bool isBackground: true
|
||||
property bool isForeground: false
|
||||
|
@ -62,7 +62,12 @@ Loader {
|
||||
enabled: indicators.info.needsMouseEventCoordinates
|
||||
onMousePressed: {
|
||||
var fixedPos = indicatorLoader.mapFromItem(appletItem, x, y);
|
||||
level.mousePressed(Math.round(fixedPos.x), Math.round(fixedPos.y));
|
||||
level.mousePressed(Math.round(fixedPos.x), Math.round(fixedPos.y), button);
|
||||
}
|
||||
|
||||
onMouseReleased: {
|
||||
var fixedPos = indicatorLoader.mapFromItem(appletItem, x, y);
|
||||
level.mouseReleased(Math.round(fixedPos.x), Math.round(fixedPos.y), button);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ PlasmaCore.FrameSvgItem {
|
||||
imagePath: indicator.usePlasmaTabsStyle ? "widgets/tabbar" : "widgets/tasks"
|
||||
rotation: root.reversedEnabled ? 180 : 0
|
||||
|
||||
opacity: state === "hovered" ? 0.9 : 1
|
||||
opacity: 1 //state === "hovered" ? 0.9 : 1
|
||||
|
||||
prefix: {
|
||||
if (indicator.usePlasmaTabsStyle) {
|
||||
|
@ -111,9 +111,13 @@ Item {
|
||||
PropertyAnimation {
|
||||
target: clickedRectangle
|
||||
property: "width"
|
||||
to: Math.max(relevantItem.width, relevantItem.height) * indicator.scaleFactor * 2
|
||||
//! Dont animate above for length
|
||||
to: maxLength * multiplier
|
||||
duration: 700
|
||||
easing.type: Easing.Linear
|
||||
|
||||
readonly property int multiplier: indicator.scaleFactor * 2
|
||||
readonly property int maxLength: Math.min(indicator.currentIconSize*10, Math.max(relevantItem.width, relevantItem.height))
|
||||
}
|
||||
PropertyAnimation {
|
||||
target: clickedRectangle
|
||||
@ -172,9 +176,6 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
clickedCenter.anchors.verticalCenterOffset = fixedY;
|
||||
|
||||
clickedAnimation.start();
|
||||
|
@ -24,7 +24,8 @@ import org.kde.latte 0.2 as Latte
|
||||
Item {
|
||||
id: level
|
||||
|
||||
signal mousePressed(int x, int y);
|
||||
signal mousePressed(int x, int y, int button);
|
||||
signal mouseReleased(int x, int y, int button);
|
||||
|
||||
property bool isBackground: true
|
||||
property bool isForeground: false
|
||||
|
@ -67,7 +67,11 @@ Loader {
|
||||
enabled: indicators.info.needsMouseEventCoordinates
|
||||
onPressed: {
|
||||
var fixedPos = indicatorLoader.mapFromItem(taskItem, mouse.x, mouse.y);
|
||||
level.mousePressed(Math.round(fixedPos.x), Math.round(fixedPos.y));
|
||||
level.mousePressed(Math.round(fixedPos.x), Math.round(fixedPos.y), mouse.button);
|
||||
}
|
||||
onReleased: {
|
||||
var fixedPos = indicatorLoader.mapFromItem(taskItem, mouse.x, mouse.y);
|
||||
level.mousePressed(Math.round(fixedPos.x), Math.round(fixedPos.y), mouse.button);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user