-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathQvkWinInfo.cpp
161 lines (121 loc) · 3.04 KB
/
QvkWinInfo.cpp
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#include "QvkWinInfo.h"
#include <QDebug>
#include <QTimer>
#include <QPaintEvent>
#include <QPainter>
#include <QDesktopServices>
#include <QDesktopWidget>
#include <QApplication>
using namespace std;
QvkWinInfo::QvkWinInfo()
{
myX = 0;
myY = 0;
myWidth = 0;
myHeight = 0;
setWindowFlags( Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint );
resize ( 50, 50 );
QRegion Fenster( 0,
0,
50,
50,
QRegion::Rectangle );
QRegion mouseHole( 21,
21,
8,
8,
QRegion::Rectangle );
QRegion Rechteck_LO( 0,
0,
23,
23,
QRegion::Rectangle );
QRegion Rechteck_RO( 27,
0,
23,
23,
QRegion::Rectangle );
QRegion Rechteck_LU( 0,
27,
23,
23,
QRegion::Rectangle );
QRegion Rechteck_RU( 27,
27,
23,
23,
QRegion::Rectangle );
QRegion r1 = Fenster.QRegion::subtract( mouseHole );
QRegion r2 = r1.QRegion::subtract( Rechteck_LO );
QRegion r3 = r2.QRegion::subtract( Rechteck_RO );
QRegion r4 = r3.QRegion::subtract( Rechteck_LU );
QRegion r5 = r4.QRegion::subtract( Rechteck_RU );
this->setMask( r5 );
lastWinID = this->winId();
//qDebug() << "lastWinID:" << lastWinID;
windowTimer = new QTimer( this );
connect( windowTimer, SIGNAL( timeout() ), this, SLOT( selectWindow() ) );
windowTimer->start( 500 );
mouseTimer = new QTimer( this );
connect( mouseTimer, SIGNAL( timeout() ), this, SLOT( mousePosition() ) );
mouseTimer->start( 20 );
show();
}
QvkWinInfo::~QvkWinInfo()
{
}
void QvkWinInfo::paintEvent( QPaintEvent *event )
{
(void)event;
QPainter painter( this );
painter.setPen( QPen( Qt::blue, 4 ) );
painter.drawLine( 50/2, 0, 50/2, 50);
painter.drawLine( 0, 50/2, 50, 50/2);
}
void QvkWinInfo::mousePosition()
{
QCursor cursor;
//qDebug() << "X:" << cursor.pos().x() << "Y:" << cursor.pos().y();
move( cursor.pos().x() - 25 , cursor.pos().y() - 25 );
}
void QvkWinInfo::selectWindow()
{
newWinID = QxtWindowSystem::activeWindow();
//qDebug() << "newWinID:" << newWinID;
if ( lastWinID != newWinID )
{
windowTimer->stop();
mouseTimer->stop();
myX = QxtWindowSystem::windowGeometry( newWinID ).x();
myY = QxtWindowSystem::windowGeometry( newWinID ).y();
myWidth = QxtWindowSystem::windowGeometry( newWinID ).width();
myHeight = QxtWindowSystem::windowGeometry( newWinID ).height();
emit windowChanged();
this->close();
delete this;
}
}
QString QvkWinInfo::x()
{
return QString::number( myX );
}
QString QvkWinInfo::y()
{
return QString::number( myY );
}
QString QvkWinInfo::width()
{
return QString::number( myWidth );
}
QString QvkWinInfo::height()
{
return QString::number( myHeight );
}
QString QvkWinInfo::WinID()
{
return QString().number( newWinID );
}
WId QvkWinInfo::getWinID()
{
return newWinID;
}