20
20
21
21
#include < QApplication>
22
22
#include < QDebug>
23
- #include < QDesktopWidget>
24
23
#include < QPaintEvent>
25
24
#include < QPainter>
25
+ #include < QScreen>
26
26
27
27
SpringModeRegionPreview::SpringModeRegionPreview (int width, int height, QWidget *parent)
28
28
:
@@ -43,8 +43,9 @@ SpringModeRegionPreview::SpringModeRegionPreview(int width, int height, QWidget
43
43
44
44
if ((tempwidth >= 2 ) && (tempheight >= 2 ))
45
45
{
46
- int cw = (qApp->desktop ()->width () / 2 ) - (tempwidth / 2 );
47
- int ch = (qApp->desktop ()->height () / 2 ) - (tempheight / 2 );
46
+ // TODO create a simple class representing display fopr calculating cursor locations
47
+ int cw = (QGuiApplication::primaryScreen ()->virtualGeometry ().width () / 2 ) - (tempwidth / 2 );
48
+ int ch = (QGuiApplication::primaryScreen ()->virtualGeometry ().height () / 2 ) - (tempheight / 2 );
48
49
49
50
setGeometry (cw, ch, tempwidth, tempheight);
50
51
show ();
@@ -108,8 +109,8 @@ void SpringModeRegionPreview::setSpringWidth(int width)
108
109
109
110
if ((tempwidth >= 2 ) && (height >= 2 ))
110
111
{
111
- int cw = (qApp-> desktop ()->width () / 2 ) - (tempwidth / 2 );
112
- int ch = (qApp-> desktop ()->height () / 2 ) - (height / 2 );
112
+ int cw = (QGuiApplication::primaryScreen ()->virtualGeometry (). width () / 2 ) - (tempwidth / 2 );
113
+ int ch = (QGuiApplication::primaryScreen ()->virtualGeometry (). height () / 2 ) - (height / 2 );
113
114
114
115
setGeometry (cw, ch, tempwidth, height);
115
116
if (!isVisible ())
@@ -133,8 +134,8 @@ void SpringModeRegionPreview::setSpringHeight(int height)
133
134
134
135
if ((width >= 2 ) && (tempheight >= 2 ))
135
136
{
136
- int cw = (qApp-> desktop ()->width () / 2 ) - (width / 2 );
137
- int ch = (qApp-> desktop ()->height () / 2 ) - (tempheight / 2 );
137
+ int cw = (QGuiApplication::primaryScreen ()->virtualGeometry (). width () / 2 ) - (width / 2 );
138
+ int ch = (QGuiApplication::primaryScreen ()->virtualGeometry (). height () / 2 ) - (tempheight / 2 );
138
139
139
140
setGeometry (cw, ch, width, tempheight);
140
141
if (!isVisible ())
@@ -153,8 +154,8 @@ void SpringModeRegionPreview::setSpringSize(int width, int height)
153
154
int tempwidth = adjustSpringSizeWidth (width);
154
155
int tempheight = adjustSpringSizeHeight (height);
155
156
156
- int cw = (qApp-> desktop ()->width () / 2 ) - (tempwidth / 2 );
157
- int ch = (qApp-> desktop ()->height () / 2 ) - (height / 2 );
157
+ int cw = (QGuiApplication::primaryScreen ()->virtualGeometry (). width () / 2 ) - (tempwidth / 2 );
158
+ int ch = (QGuiApplication::primaryScreen ()->virtualGeometry (). height () / 2 ) - (height / 2 );
158
159
159
160
resize (tempwidth, tempheight);
160
161
move (cw, ch);
0 commit comments