diff --git a/interface/interface_en.ts b/interface/interface_en.ts index 80433032dc..23ea3cc3ba 100644 --- a/interface/interface_en.ts +++ b/interface/interface_en.ts @@ -4,22 +4,22 @@ Application - + Export Voxels - + Sparse Voxel Octree Files (*.svo) - + Open Script - + JavaScript Files (*.js) @@ -27,25 +27,25 @@ ChatWindow - - + + Chat - - + + Connecting to XMPP... - - + + online now: - + day %n day @@ -53,7 +53,7 @@ - + hour %n hour @@ -61,7 +61,7 @@ - + minute %n minute @@ -76,7 +76,7 @@ - + %1 online now: @@ -113,18 +113,18 @@ Menu - + Open .ini config file - - + + Text files (*.ini) - + Save .ini config file diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index aed212c692..b08f8f77f1 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -291,7 +292,14 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : ResourceCache::setNetworkAccessManager(_networkAccessManager); ResourceCache::setRequestLimit(3); - _window->setCentralWidget(_glWidget); + QWidget* centralWidget = new QWidget(); + QHBoxLayout* mainLayout = new QHBoxLayout(); + mainLayout->setSpacing(0); + mainLayout->setContentsMargins(0, 0, 0, 0); + centralWidget->setLayout(mainLayout); + _glWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + centralWidget->layout()->addWidget(_glWidget); + _window->setCentralWidget(centralWidget); restoreSizeAndPosition(); diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 71e24e2382..c92d550fd6 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -1041,22 +1041,20 @@ void Menu::showChat() { if (!_chatWindow) { _chatWindow = new ChatWindow(); QMainWindow* mainWindow = Application::getInstance()->getWindow(); - _chatWindow->setGeometry(mainWindow->width() - _chatWindow->width(), - mainWindow->geometry().y(), - _chatWindow->width(), - mainWindow->height()); + QBoxLayout* boxLayout = static_cast(mainWindow->centralWidget()->layout()); + boxLayout->addWidget(_chatWindow, 0, Qt::AlignRight); + } else { + if (!_chatWindow->isVisible()) { + _chatWindow->show(); + } } - if (!_chatWindow->isVisible()) { - _chatWindow->show(); - } - _chatWindow->raise(); } void Menu::toggleChat() { #ifdef HAVE_QXMPP _chatAction->setEnabled(XmppClient::getInstance().getXMPPClient().isConnected()); if (!_chatAction->isEnabled() && _chatWindow) { - _chatWindow->close(); + _chatWindow->hide(); } #endif } diff --git a/interface/src/ui/ChatWindow.cpp b/interface/src/ui/ChatWindow.cpp index d4f257c0f7..103f045cfa 100644 --- a/interface/src/ui/ChatWindow.cpp +++ b/interface/src/ui/ChatWindow.cpp @@ -28,7 +28,7 @@ const int NUM_MESSAGES_TO_TIME_STAMP = 20; const QRegularExpression regexLinks("((?:(?:ftp)|(?:https?))://\\S+)"); ChatWindow::ChatWindow() : - QDialog(Application::getInstance()->getGLWidget(), Qt::CustomizeWindowHint), + QWidget(), ui(new Ui::ChatWindow), numMessagesAfterLastTimeStamp(0) { @@ -39,7 +39,6 @@ ChatWindow::ChatWindow() : ui->messagePlainTextEdit->installEventFilter(this); - setAttribute(Qt::WA_DeleteOnClose); #ifdef HAVE_QXMPP const QXmppClient& xmppClient = XmppClient::getInstance().getXMPPClient(); if (xmppClient.isConnected()) { @@ -72,8 +71,18 @@ ChatWindow::~ChatWindow() { delete ui; } -void ChatWindow::reject() { - hide(); +void ChatWindow::keyPressEvent(QKeyEvent* event) { + QWidget::keyPressEvent(event); + if (event->key() == Qt::Key_Escape) { + hide(); + } +} + +void ChatWindow::showEvent(QShowEvent* event) { + QWidget::showEvent(event); + if (!event->spontaneous()) { + ui->messagePlainTextEdit->setFocus(); + } } bool ChatWindow::eventFilter(QObject* sender, QEvent* event) { diff --git a/interface/src/ui/ChatWindow.h b/interface/src/ui/ChatWindow.h index 57da4da45d..fbf9fc0859 100644 --- a/interface/src/ui/ChatWindow.h +++ b/interface/src/ui/ChatWindow.h @@ -9,9 +9,9 @@ #ifndef __interface__ChatWindow__ #define __interface__ChatWindow__ -#include #include #include +#include #include @@ -26,14 +26,15 @@ namespace Ui { class ChatWindow; } -class ChatWindow : public QDialog { +class ChatWindow : public QWidget { Q_OBJECT public: ChatWindow(); ~ChatWindow(); - virtual void reject(); + virtual void keyPressEvent(QKeyEvent *event); + virtual void showEvent(QShowEvent* event); protected: bool eventFilter(QObject* sender, QEvent* event); diff --git a/interface/ui/chatWindow.ui b/interface/ui/chatWindow.ui index ecb4d79c41..1106fca3cd 100644 --- a/interface/ui/chatWindow.ui +++ b/interface/ui/chatWindow.ui @@ -1,7 +1,7 @@ ChatWindow - + 0 @@ -10,9 +10,18 @@ 608 + + + 400 + 0 + + Chat + + font-family: Helvetica, Arial, sans-serif; + 0 @@ -100,7 +109,7 @@ - margin-top: 12px; font-family: Helvetica, Arial, sans-serif; + margin-top: 12px; Qt::ScrollBarAlwaysOff @@ -114,7 +123,7 @@ 0 0 358 - 452 + 464 @@ -154,6 +163,12 @@ 0 + + + 0 + 60 + + border-color: palette(dark); border-style: solid; border-left-width: 1px; border-right-width: 1px; border-bottom-width: 1px;