-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.qml
More file actions
138 lines (115 loc) · 3.18 KB
/
main.qml
File metadata and controls
138 lines (115 loc) · 3.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import QtQuick
import QtQuick.Controls
Window {
id:quickWin
width: 48/screen.devicePixelRatio
height: 48/screen.devicePixelRatio
visible: true
flags: Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint
color: colorSet.transparent
ColorSetting{
id:colorSet
}
Rectangle{
id:rectOut
color: colorSet.keyColor
opacity: 0.25
width: quickWin.width
height: quickWin.height
anchors.top: quickWin.top
anchors.left: quickWin.left
radius: 4
}
Rectangle{
id:rectIn
color: "#1d262f"
anchors.centerIn: rectOut
width: 36/screen.devicePixelRatio
height: 36/screen.devicePixelRatio
radius: 18/screen.devicePixelRatio
Text{
id:textIn
anchors.centerIn: rectIn
color:colorSet.keyColor
//font.family: "Helvetica"
font.pointSize: 9
font.bold :true
text: "35"
}
PropertyAnimation{
id:rectInAnimationBigger
target: rectIn
properties: "radius"
to:4/screen.devicePixelRatio
easing.type: Easing.InOutQuad
}
PropertyAnimation{
id:rectInAnimationSmaller
target: rectIn
properties: "radius"
to:18/screen.devicePixelRatio
easing.type: Easing.InOutQuad
}
}
MouseArea{
id:animationControl
anchors.fill: rectOut
hoverEnabled: true
onEntered: {
rectInAnimationBigger.start()
}
onExited: {
rectInAnimationSmaller.start()
}
}
MouseArea { //为窗口添加鼠标事件
anchors.fill: rectOut
acceptedButtons: Qt.LeftButton //只处理鼠标左键
property point clickPos: "0,0"
onPressed:(mouse) => { //接收鼠标按下事件
clickPos = Qt.point(mouse.x,mouse.y)
}
onPositionChanged: (mouse) =>{ //鼠标按下后改变位置
//鼠标偏移量
var delta = Qt.point(mouse.x-clickPos.x, mouse.y-clickPos.y)
//如果mainwindow继承自QWidget,用setPos
quickWin.setX(quickWin.x+delta.x)
quickWin.setY(quickWin.y+delta.y)
}
onDoubleClicked: {
if(mainWindow.height === 0 ||!mainWindow.visible){
//screenshotBackWin.show()
mainWindow.showWithAnimation()
console.log("show")
}
else{
//screenshotBackWin.hide()
mainWindow.hideWithAnimation();
console.log("hide");
}
}
}
MainWindow{
id:mainWindow
x:quickWin.x + 50
y:quickWin.y + 50
}
FullScreenWindow{
x:0
y:0
id:screenshotBackWin
}
function showTranslateResultTxt(param)
{
mainWindow.showTranslateResultTxt();
}
function updateInputText(param)
{
mainWindow.updateInputTxt();
mainWindow.tranlate();
}
function showScreenShotWindow(param)
{
screenshotBackWin.show();
}
}