QPoint Window::GetInitialLocation(const QPoint& initialSize) { QWidget* parent = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetParent(shell->GetControl()); QPoint centerPoint(0,0); QRect parentBounds(0,0,0,0); if (parent != nullptr) { parentBounds = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(parent); centerPoint.setX(parentBounds.x() + parentBounds.width()/2); centerPoint.setY(parentBounds.y() - parentBounds.height()/2); } else { parentBounds = Tweaklets::Get(GuiWidgetsTweaklet::KEY) ->GetScreenSize(Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetPrimaryScreenNumber()); centerPoint.setX(parentBounds.width()/2); centerPoint.setY(parentBounds.height()/2); } return QPoint(centerPoint.x() - (initialSize.x() / 2), std::max<int>(parentBounds.y(), std::min<int>(centerPoint.y() - (initialSize.y() * 2 / 3), parentBounds.y() + parentBounds.height() - initialSize.y()))); }
Point Window::GetInitialLocation(const Point& initialSize) { void* parent = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetParent(shell->GetControl()); Point centerPoint(0,0); Rectangle parentBounds(0,0,0,0); if (parent != 0) { parentBounds = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(parent); centerPoint.x = parentBounds.x + parentBounds.width/2; centerPoint.y = parentBounds.y - parentBounds.height/2; } else { parentBounds = Tweaklets::Get(GuiWidgetsTweaklet::KEY) ->GetScreenSize(Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetPrimaryScreenNumber()); centerPoint.x = parentBounds.width/2; centerPoint.y = parentBounds.height/2; } return Point(centerPoint.x - (initialSize.x / 2), std::max<int>(parentBounds.y, std::min<int>(centerPoint.y - (initialSize.y * 2 / 3), parentBounds.y + parentBounds.height - initialSize.y))); }