summary refs log tree commit diff
path: root/src/Utils.cpp
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-09-21 10:55:24 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-09-21 10:55:24 +0300
commitce26f041adf49d8281cf2248ef840313bc532dc5 (patch)
tree6657272e90457f46304c6958dcb8ac751fc3cb4a /src/Utils.cpp
parentClose dialogs on confirmation (diff)
downloadnheko-ce26f041adf49d8281cf2248ef840313bc532dc5.tar.xz
Add method to center widgets & clean up unused headers
Diffstat (limited to '')
-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); +}