Update chat menu to properly position itself when opening

The previous implementation seemed to assume a full-screen main window -
it will now open on the right side of the window, vertically centered,
regardless of where the main window is.
This commit is contained in:
Ryan Huffman 2014-04-10 11:46:28 -07:00
parent 5099a0e061
commit 2d481dda4e

View file

@ -1206,12 +1206,12 @@ void Menu::showChat() {
mainWindow->addDockWidget(Qt::NoDockWidgetArea, _chatWindow = new ChatWindow());
}
if (!_chatWindow->toggleViewAction()->isChecked()) {
int width = _chatWindow->width();
int y = qMax((mainWindow->height() - _chatWindow->height()) / 2, 0);
_chatWindow->move(mainWindow->width(), y);
const QRect& windowGeometry = mainWindow->geometry();
_chatWindow->move(windowGeometry.topRight().x() - _chatWindow->width(),
windowGeometry.topRight().y() + (windowGeometry.height() / 2) - (_chatWindow->height() / 2));
_chatWindow->resize(0, _chatWindow->height());
_chatWindow->toggleViewAction()->trigger();
}
}