2020
2121#include < QApplication>
2222#include < QDebug>
23- #include < QDesktopWidget>
2423#include < QPaintEvent>
2524#include < QPainter>
25+ #include < QScreen>
2626
2727SpringModeRegionPreview::SpringModeRegionPreview (int width, int height, QWidget *parent)
2828 :
@@ -43,8 +43,9 @@ SpringModeRegionPreview::SpringModeRegionPreview(int width, int height, QWidget
4343
4444 if ((tempwidth >= 2 ) && (tempheight >= 2 ))
4545 {
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 );
4849
4950 setGeometry (cw, ch, tempwidth, tempheight);
5051 show ();
@@ -108,8 +109,8 @@ void SpringModeRegionPreview::setSpringWidth(int width)
108109
109110 if ((tempwidth >= 2 ) && (height >= 2 ))
110111 {
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 );
113114
114115 setGeometry (cw, ch, tempwidth, height);
115116 if (!isVisible ())
@@ -133,8 +134,8 @@ void SpringModeRegionPreview::setSpringHeight(int height)
133134
134135 if ((width >= 2 ) && (tempheight >= 2 ))
135136 {
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 );
138139
139140 setGeometry (cw, ch, width, tempheight);
140141 if (!isVisible ())
@@ -153,8 +154,8 @@ void SpringModeRegionPreview::setSpringSize(int width, int height)
153154 int tempwidth = adjustSpringSizeWidth (width);
154155 int tempheight = adjustSpringSizeHeight (height);
155156
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 );
158159
159160 resize (tempwidth, tempheight);
160161 move (cw, ch);
0 commit comments