Merge pull request #25809 from Syres916/HotFix_For_Win_and_Wayland_For_First_Run
[Gui] Hotfix for correcting main window position on first run and Safe Mode on Windows and Wayland
This commit is contained in:
@@ -653,6 +653,36 @@ bool MainWindow::setupPythonConsole()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MainWindow::checkFirstRun()
|
||||
{
|
||||
ParameterGrp::handle hGrpRF = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/RecentFiles"
|
||||
);
|
||||
auto RecentFilesCount = hGrpRF->GetInt("RecentFiles");
|
||||
ParameterGrp::handle hGrpFS2024 = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Mod/Start"
|
||||
);
|
||||
auto firstStart = hGrpFS2024->GetBool("FirstStart2024", true); // NOLINT
|
||||
if (firstStart && RecentFilesCount < 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::moveToDefaultPosition(QRect rect, QPoint pos)
|
||||
{
|
||||
int x1 {}, x2 {}, y1 {}, y2 {};
|
||||
// make sure that the main window is not totally out of the visible rectangle
|
||||
rect.getCoords(&x1, &y1, &x2, &y2);
|
||||
const int offsetX = 30;
|
||||
const int offsetY = 10;
|
||||
pos.setX(qMin(qMax(pos.x(), x1 - this->width() + offsetX), x2 - offsetX));
|
||||
pos.setY(qMin(qMax(pos.y(), y1 - offsetY), y2 - offsetY));
|
||||
this->move(pos);
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::updateTreeView(bool show)
|
||||
{
|
||||
if (d->hiddenDockWindows.find("Std_TreeView") == std::string::npos) {
|
||||
@@ -1923,12 +1953,25 @@ void MainWindow::loadWindowSettings()
|
||||
}
|
||||
|
||||
resize(size);
|
||||
int x1 {}, x2 {}, y1 {}, y2 {};
|
||||
// make sure that the main window is not totally out of the visible rectangle
|
||||
rect.getCoords(&x1, &y1, &x2, &y2);
|
||||
pos.setX(qMin(qMax(pos.x(), x1 - this->width() + 30), x2 - 30));
|
||||
pos.setY(qMin(qMax(pos.y(), y1 - 10), y2 - 10));
|
||||
this->move(pos);
|
||||
// TODO: Hotfix to be removed as soon as possible after 1.1.0 Release
|
||||
#ifdef FC_OS_WIN64
|
||||
if (checkFirstRun()) {
|
||||
const int topLeftXY = 10;
|
||||
this->move(topLeftXY, topLeftXY);
|
||||
}
|
||||
else {
|
||||
moveToDefaultPosition(rect, pos);
|
||||
}
|
||||
#else
|
||||
// TODO: Hotfix to be removed as soon as possible after 1.1.0 Release
|
||||
if (QGuiApplication::platformName() == QString::fromStdString("wayland") && checkFirstRun()) {
|
||||
const int topLeftXY = 10;
|
||||
this->move(topLeftXY, topLeftXY);
|
||||
}
|
||||
else { // all Linux x11 and Mac
|
||||
moveToDefaultPosition(rect, pos);
|
||||
}
|
||||
#endif
|
||||
|
||||
Base::StateLocker guard(d->_restoring);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user