Add method to center widgets & clean up unused headers

This commit is contained in:
Konstantinos Sideris 2018-09-21 10:55:24 +03:00
parent ecc346a6da
commit ce26f041ad
11 changed files with 28 additions and 36 deletions

View file

@ -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);
}