From 3907c563df14c25c150d93dab5156f2347c622da Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Wed, 26 Mar 2014 23:44:31 +0200 Subject: [PATCH] Put the chat window above the 3D view and animated its showing. --- interface/interface_en.ts | 20 ++++++++++---------- interface/src/Menu.cpp | 24 ++++++++++++++++++------ interface/ui/chatWindow.ui | 3 +++ 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/interface/interface_en.ts b/interface/interface_en.ts index 5031083497..56fdd669ed 100644 --- a/interface/interface_en.ts +++ b/interface/interface_en.ts @@ -27,20 +27,20 @@ ChatWindow - - + + Chat - - + + Connecting to XMPP... - - + + online now: @@ -113,18 +113,18 @@ Menu - + Open .ini config file - - + + Text files (*.ini) - + Save .ini config file diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 47c6d040be..229b2e9611 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include #include #include @@ -1103,13 +1105,23 @@ void Menu::showMetavoxelEditor() { } void Menu::showChat() { + QMainWindow* mainWindow = Application::getInstance()->getWindow(); if (!_chatWindow) { - Application::getInstance()->getWindow()->addDockWidget(Qt::RightDockWidgetArea, _chatWindow = new ChatWindow()); - - } else { - if (!_chatWindow->toggleViewAction()->isChecked()) { - _chatWindow->toggleViewAction()->trigger(); - } + 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); + _chatWindow->resize(0, _chatWindow->height()); + _chatWindow->toggleViewAction()->trigger(); + + QPropertyAnimation* slideAnimation = new QPropertyAnimation(_chatWindow, "geometry", _chatWindow); + slideAnimation->setStartValue(_chatWindow->geometry()); + slideAnimation->setEndValue(QRect(mainWindow->width() - width, _chatWindow->y(), + width, _chatWindow->height())); + slideAnimation->setDuration(250); + slideAnimation->start(QAbstractAnimation::DeleteWhenStopped); } } diff --git a/interface/ui/chatWindow.ui b/interface/ui/chatWindow.ui index 32ae426484..60a0c6badd 100644 --- a/interface/ui/chatWindow.ui +++ b/interface/ui/chatWindow.ui @@ -22,6 +22,9 @@ QDockWidget::NoDockWidgetFeatures + + Qt::NoDockWidgetArea + Chat