From 727903b216fd82b5b47e710c70d653cf4a08980d Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Thu, 13 Mar 2014 01:55:42 +0200 Subject: [PATCH] Changed the chat window to a popup with a custom closing button. --- interface/CMakeLists.txt | 7 ++- interface/interface_en.ts | 16 ++--- interface/resources/images/close.svg | 14 +++++ interface/resources/resources.qrc | 5 ++ interface/src/Menu.cpp | 9 +-- interface/src/ui/ChatWindow.cpp | 2 +- interface/ui/chatWindow.ui | 89 ++++++++++++++++++++++------ 7 files changed, 108 insertions(+), 34 deletions(-) create mode 100644 interface/resources/images/close.svg create mode 100644 interface/resources/resources.qrc diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index d049fc0154..1cb0344f86 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -73,8 +73,13 @@ file (GLOB_RECURSE QT_UI_FILES ui/*.ui) # have qt5 wrap them and generate the appropriate header files qt5_wrap_ui(QT_UI_HEADERS "${QT_UI_FILES}") +# grab the resource files in resources +file (GLOB_RECURSE QT_RESOURCE_FILES resources/*.qrc) +# have qt5 wrap them and generate the appropriate source files +qt5_add_resources(QT_RESOURCES "${QT_RESOURCE_FILES}") + # add them to the interface source files -set(INTERFACE_SRCS ${INTERFACE_SRCS} "${QT_UI_HEADERS}") +set(INTERFACE_SRCS ${INTERFACE_SRCS} "${QT_UI_HEADERS}" "${QT_RESOURCES}") set(QM ${TARGET_NAME}_en.qm) set(TS ${TARGET_NAME}_en.ts) diff --git a/interface/interface_en.ts b/interface/interface_en.ts index 175a1f4525..72e5ee3d3e 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) @@ -28,19 +28,19 @@ ChatWindow - + Chat - + Connecting to XMPP... - - + + online now: diff --git a/interface/resources/images/close.svg b/interface/resources/images/close.svg new file mode 100644 index 0000000000..8fe4bf4bdb --- /dev/null +++ b/interface/resources/images/close.svg @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/interface/resources/resources.qrc b/interface/resources/resources.qrc new file mode 100644 index 0000000000..372fa8b1d4 --- /dev/null +++ b/interface/resources/resources.qrc @@ -0,0 +1,5 @@ + + + images/close.svg + + diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index f73da0400a..95b94bdcbf 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -1039,15 +1039,10 @@ void Menu::showChat() { if (!_chatWindow) { _chatWindow = new ChatWindow(); QMainWindow* mainWindow = Application::getInstance()->getWindow(); - - // the height of the title bar is given by frameGeometry().height() - geometry().height() - // however, frameGeometry() is initialised after showing (Qt queries the OS windowing system) - // on the other hand, moving a window after showing it flickers; so just use some reasonable value - int titleBarHeight = 16; _chatWindow->setGeometry(mainWindow->width() - _chatWindow->width(), - mainWindow->geometry().y() + titleBarHeight, + mainWindow->geometry().y(), _chatWindow->width(), - mainWindow->height() - titleBarHeight); + mainWindow->height()); _chatWindow->show(); } _chatWindow->raise(); diff --git a/interface/src/ui/ChatWindow.cpp b/interface/src/ui/ChatWindow.cpp index 5fc5d56430..3a1c26ee35 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::Tool), + QDialog(Application::getInstance()->getGLWidget(), Qt::CustomizeWindowHint), ui(new Ui::ChatWindow), numMessagesAfterLastTimeStamp(0) { diff --git a/interface/ui/chatWindow.ui b/interface/ui/chatWindow.ui index d254efb71a..9959c638b2 100644 --- a/interface/ui/chatWindow.ui +++ b/interface/ui/chatWindow.ui @@ -46,20 +46,53 @@ - - - - 0 - 0 - - - - font-weight: bold; color: palette(shadow); margin-bottom: 4px; - - - online now: - - + + + + + + 0 + 0 + + + + font-weight: bold; color: palette(shadow); margin-bottom: 4px; + + + online now: + + + + + + + + 0 + 0 + + + + + 16 + 16 + + + + Qt::NoFocus + + + + + + + :/images/close.svg:/images/close.svg + + + true + + + + @@ -81,7 +114,7 @@ 0 0 358 - 454 + 452 @@ -133,6 +166,9 @@ QAbstractScrollArea::AdjustToContents + + true + @@ -141,6 +177,25 @@ messagePlainTextEdit messagesScrollArea - - + + + + + + closeButton + clicked() + ChatWindow + accept() + + + 342 + 42 + + + 550 + 42 + + + +