From 881ecb07cd3268d2622d9a8249e09018132e8cdd Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Thu, 13 Mar 2014 23:00:01 +0200 Subject: [PATCH 1/2] Changed the font of the entire chat window to Helvetica/Arial. --- interface/interface_en.ts | 10 +++++----- interface/ui/chatWindow.ui | 13 +++++++++++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/interface/interface_en.ts b/interface/interface_en.ts index 80433032dc..b6e35f3f5f 100644 --- a/interface/interface_en.ts +++ b/interface/interface_en.ts @@ -28,19 +28,19 @@ ChatWindow - + Chat - - + + Connecting to XMPP... - - + + online now: diff --git a/interface/ui/chatWindow.ui b/interface/ui/chatWindow.ui index ecb4d79c41..22f2dcd5dd 100644 --- a/interface/ui/chatWindow.ui +++ b/interface/ui/chatWindow.ui @@ -13,6 +13,9 @@ Chat + + font-family: Helvetica, Arial, sans-serif; + 0 @@ -100,7 +103,7 @@ - margin-top: 12px; font-family: Helvetica, Arial, sans-serif; + margin-top: 12px; Qt::ScrollBarAlwaysOff @@ -114,7 +117,7 @@ 0 0 358 - 452 + 464 @@ -154,6 +157,12 @@ 0 + + + 0 + 60 + + border-color: palette(dark); border-style: solid; border-left-width: 1px; border-right-width: 1px; border-bottom-width: 1px; From 85a15a2284513d2a0a3481dc5aaf7ddcd8af1251 Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Fri, 14 Mar 2014 00:43:02 +0200 Subject: [PATCH 2/2] Moved the chat from a window to a built-in panel. --- interface/interface_en.ts | 30 +++++++++++++++--------------- interface/src/Application.cpp | 10 +++++++++- interface/src/Menu.cpp | 16 +++++++--------- interface/src/ui/ChatWindow.cpp | 17 +++++++++++++---- interface/src/ui/ChatWindow.h | 7 ++++--- interface/ui/chatWindow.ui | 8 +++++++- 6 files changed, 55 insertions(+), 33 deletions(-) diff --git a/interface/interface_en.ts b/interface/interface_en.ts index b6e35f3f5f..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 22f2dcd5dd..1106fca3cd 100644 --- a/interface/ui/chatWindow.ui +++ b/interface/ui/chatWindow.ui @@ -1,7 +1,7 @@ ChatWindow - + 0 @@ -10,6 +10,12 @@ 608 + + + 400 + 0 + + Chat