From 6fd1bf7edb9941a9f9a0b3ba2721a48d5fb82dbe Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Fri, 28 Mar 2014 18:44:06 +0200 Subject: [PATCH] Simplified the new goToUser function. --- interface/interface_en.ts | 8 +++---- interface/src/Menu.cpp | 41 +++++++++++---------------------- interface/src/Menu.h | 2 +- interface/src/ui/ChatWindow.cpp | 2 +- 4 files changed, 20 insertions(+), 33 deletions(-) diff --git a/interface/interface_en.ts b/interface/interface_en.ts index 56fdd669ed..519e2b61c1 100644 --- a/interface/interface_en.ts +++ b/interface/interface_en.ts @@ -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 229b2e9611..e217424cbe 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -20,8 +20,6 @@ #include #include #include -#include -#include #include #include #include @@ -925,19 +923,18 @@ void Menu::goTo() { gotoDialog.resize(gotoDialog.parentWidget()->size().width() * DIALOG_RATIO_OF_WINDOW, gotoDialog.size().height()); int dialogReturn = gotoDialog.exec(); - goToUser(dialogReturn == QDialog::Accepted && !gotoDialog.textValue().isEmpty(), - gotoDialog.textValue()); -} - -void Menu::goToUser(bool go, const QString& user) { - if (go) { - LocationManager* manager = &LocationManager::getInstance(); - manager->goTo(user); - connect(manager, &LocationManager::multipleDestinationsFound, this, &Menu::multipleDestinationsDecision); + if (dialogReturn == QDialog::Accepted && !gotoDialog.textValue().isEmpty()) { + goToUser(gotoDialog.textValue()); } sendFakeEnterEvent(); } +void Menu::goToUser(const QString& user) { + LocationManager* manager = &LocationManager::getInstance(); + manager->goTo(user); + connect(manager, &LocationManager::multipleDestinationsFound, this, &Menu::multipleDestinationsDecision); +} + void Menu::multipleDestinationsDecision(const QJsonObject& userData, const QJsonObject& placeData) { QMessageBox msgBox; msgBox.setText("Both user and location exists with same name"); @@ -1105,23 +1102,13 @@ void Menu::showMetavoxelEditor() { } void Menu::showChat() { - QMainWindow* mainWindow = Application::getInstance()->getWindow(); if (!_chatWindow) { - 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); + Application::getInstance()->getWindow()->addDockWidget(Qt::RightDockWidgetArea, _chatWindow = new ChatWindow()); + + } else { + if (!_chatWindow->toggleViewAction()->isChecked()) { + _chatWindow->toggleViewAction()->trigger(); + } } } diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 41bd1b85fd..c7c4c6ecea 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -122,7 +122,7 @@ public slots: void importSettings(); void exportSettings(); void goTo(); - void goToUser(bool go, const QString& user); + void goToUser(const QString& user); void pasteToVoxel(); void toggleLoginMenuItem(); diff --git a/interface/src/ui/ChatWindow.cpp b/interface/src/ui/ChatWindow.cpp index ae49e82b17..76e9c4ec2d 100644 --- a/interface/src/ui/ChatWindow.cpp +++ b/interface/src/ui/ChatWindow.cpp @@ -117,7 +117,7 @@ bool ChatWindow::eventFilter(QObject* sender, QEvent* event) { return false; } QString user = sender->property("user").toString(); - Menu::getInstance()->goToUser(true, user); + Menu::getInstance()->goToUser(user); } return false; }