1
0
mirror of https://github.com/jaredtao/TaoQuick.git synced 2025-01-17 20:12:54 +08:00

update brust

This commit is contained in:
jared 2021-07-06 10:18:00 +08:00
parent 6099ee790f
commit f13053db7d
3 changed files with 28 additions and 21 deletions

View File

@ -49,7 +49,7 @@ public slots:
}
signals:
void isMaxChanged(bool isMax);
void mousePressed(int x, int y, Qt::MouseButton button);
void mousePressed(int xPos, int yPos, int button);
protected:
# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)

View File

@ -1,6 +1,6 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Window 2.9
import TaoQuick 1.0
Popup {
@ -8,9 +8,19 @@ Popup {
width: 600
height: 340
function show() {
function showParentCenter() {
x = (parent.width - width) / 2
y = (parent.height - height) / 2
open()
}
function showScreenCenter() {
var globalX = (Screen.desktopAvailableWidth - width) / 2
var globalY = (Screen.desktopAvailableHeight - height) / 2
var pos = parent.mapFromGlobal(globalX, globalY)
x = pos.x
y = pos.y
open()
}
}

View File

@ -3,23 +3,20 @@ import QtQuick.Controls 2.2
Item {
id: clickShow
// MouseArea {
// anchors.fill: parent
// hoverEnabled: false
// acceptedButtons: Qt.AllButtons
// onDoubleClicked: { mouse.accepted = false;}
// onPositionChanged: { mouse.accepted = false;}
// onPressed: {
// brust(mouseX, mouseY, mouse.button)
// mouse.accepted = false;
// }
// onPressAndHold: { mouse.accepted = false; }
// onClicked: { mouse.accepted = false;}
// onReleased: { mouse.accepted = false;}
// onWheel: { wheel.accepted = false; }
// Component.onCompleted: {
// view.mousePressed.connect(brust)
// }
Component.onCompleted: {
view.mousePressed.connect(brust)
Connections {
target: view
ignoreUnknownSignals: true
//Qt5.15 and after
function onMousePressed(xPos, yPos, button) {
clickShow.brust(xPos, yPos, button)
}
//5.12 and before
onMousePressed: {
clickShow.brust(xPos, yPos, button)
}
}
Component {
id: brushComp
@ -94,8 +91,8 @@ Item {
id: brushAnimation
}
function brust(x, y, button)
function brust(xPos, yPos, button)
{
brushComp.createObject(clickShow, {x: x, y: y, circleColor: getButtonColor(button)})
brushComp.createObject(clickShow, {x: xPos, y: yPos, circleColor: getButtonColor(button)})
}
}