OpenMW-CS: Update the "Grow Limit Screen" feature
Feature description:
When "Grow then Scroll" option is selected, the window size grows to the width of the virtual desktop.
If this option is selected the the window growth is limited to the current screen.
We have such code to implement it:
QDesktopWidget* dw = QApplication::desktop();
QRect rect;
if (isGrowLimit)
rect = dw->screenGeometry(this);
else
rect = QGuiApplication::screens().at(dw->screenNumber(this))->geometry();
The problem is that QDesktopWidget is deprecated in Qt5 and removed from Qt6. And there seem to be no direct replacement for screenNumber function.
Judging by feature description, an updated code should look like this:
QRect desktopRect()
{
QRegion virtualGeometry;
for (auto screen : QGuiApplication::screens())
{
virtualGeometry += screen->geometry();
}
return virtualGeometry.boundingRect();
}
...
QRect rect;
if (isGrowLimit)
rect = QApplication::screenAt(pos())->geometry();
else
rect = desktopRect();
When using the grow limit, detect a screen where growing widget is located and use only it. When using no grow limit, take the virtual screen (which consists of all enabled screens) and allow to use the whole its space.
If I understood correctly, I need a virtual desktop which consists of multiple real screens. But I have only one, so I can not test if it works.
Edited by Andrei Kortunov