summary refs log tree commit diff
path: root/src/Utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Utils.cpp')
-rw-r--r--src/Utils.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/Utils.cpp b/src/Utils.cpp

index 41be9e08..5feb5608 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp
@@ -384,3 +384,18 @@ utils::linkColor() return QPalette().color(QPalette::Link).name(); } + +void +utils::centerWidget(QWidget *widget, QWidget *parent) +{ + if (parent) { + widget->move(parent->geometry().center() - widget->rect().center()); + return; + } + + const QRect screenGeometry = QApplication::desktop()->screenGeometry(); + const int x = (screenGeometry.width() - widget->width()) / 2; + const int y = (screenGeometry.height() - widget->height()) / 2; + + widget->move(x, y); +}