Changed the chat window to a popup with a custom closing button.

This commit is contained in:
Dimitar Dobrev 2014-03-13 01:55:42 +02:00
parent 0a69b1b038
commit 727903b216
7 changed files with 108 additions and 34 deletions

View file

@ -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)

View file

@ -4,22 +4,22 @@
<context>
<name>Application</name>
<message>
<location filename="src/Application.cpp" line="1351"/>
<location filename="src/Application.cpp" line="1354"/>
<source>Export Voxels</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="src/Application.cpp" line="1352"/>
<location filename="src/Application.cpp" line="1355"/>
<source>Sparse Voxel Octree Files (*.svo)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="src/Application.cpp" line="3531"/>
<location filename="src/Application.cpp" line="3554"/>
<source>Open Script</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="src/Application.cpp" line="3532"/>
<location filename="src/Application.cpp" line="3555"/>
<source>JavaScript Files (*.js)</source>
<translation type="unfinished"></translation>
</message>
@ -28,19 +28,19 @@
<name>ChatWindow</name>
<message>
<location filename="ui/chatWindow.ui" line="14"/>
<location filename="../build/interface/ui_chatWindow.h" line="114"/>
<location filename="../build/interface/ui_chatWindow.h" line="141"/>
<source>Chat</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/chatWindow.ui" line="41"/>
<location filename="../build/interface/ui_chatWindow.h" line="115"/>
<location filename="../build/interface/ui_chatWindow.h" line="142"/>
<source>Connecting to XMPP...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/chatWindow.ui" line="60"/>
<location filename="../build/interface/ui_chatWindow.h" line="116"/>
<location filename="ui/chatWindow.ui" line="62"/>
<location filename="../build/interface/ui_chatWindow.h" line="143"/>
<source> online now:</source>
<translation type="unfinished"></translation>
</message>

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 15.9 15.9" enable-background="new 0 0 15.9 15.9" xml:space="preserve">
<g>
<g>
<path fill="#666666" d="M15.5,13.7l-1.8,1.8c-0.2,0.2-0.6,0.4-0.9,0.4s-0.7-0.1-0.9-0.4L8,11.6L4,15.5c-0.2,0.2-0.6,0.4-0.9,0.4
s-0.7-0.1-0.9-0.4l-1.8-1.8C0.1,13.5,0,13.1,0,12.8s0.1-0.7,0.4-0.9L4.3,8L0.4,4C0.1,3.8,0,3.4,0,3.1s0.1-0.7,0.4-0.9l1.8-1.8
C2.4,0.1,2.8,0,3.1,0S3.8,0.1,4,0.4L8,4.3l3.9-3.9C12.1,0.1,12.5,0,12.8,0s0.7,0.1,0.9,0.4l1.8,1.8c0.2,0.2,0.4,0.6,0.4,0.9
S15.8,3.8,15.5,4L11.6,8l3.9,3.9c0.2,0.2,0.4,0.6,0.4,0.9S15.8,13.5,15.5,13.7z"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 944 B

View file

@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/">
<file>images/close.svg</file>
</qresource>
</RCC>

View file

@ -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();

View file

@ -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)
{

View file

@ -46,20 +46,53 @@
</widget>
</item>
<item>
<widget class="QLabel" name="numOnlineLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">font-weight: bold; color: palette(shadow); margin-bottom: 4px;</string>
</property>
<property name="text">
<string> online now:</string>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="numOnlineLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">font-weight: bold; color: palette(shadow); margin-bottom: 4px;</string>
</property>
<property name="text">
<string> online now:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="closeButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../resources/resources.qrc">
<normaloff>:/images/close.svg</normaloff>:/images/close.svg</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="usersWidget" native="true"/>
@ -81,7 +114,7 @@
<x>0</x>
<y>0</y>
<width>358</width>
<height>454</height>
<height>452</height>
</rect>
</property>
<property name="styleSheet">
@ -133,6 +166,9 @@
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustToContents</enum>
</property>
<property name="tabChangesFocus">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
@ -141,6 +177,25 @@
<tabstop>messagePlainTextEdit</tabstop>
<tabstop>messagesScrollArea</tabstop>
</tabstops>
<resources/>
<connections/>
<resources>
<include location="../resources/resources.qrc"/>
</resources>
<connections>
<connection>
<sender>closeButton</sender>
<signal>clicked()</signal>
<receiver>ChatWindow</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>342</x>
<y>42</y>
</hint>
<hint type="destinationlabel">
<x>550</x>
<y>42</y>
</hint>
</hints>
</connection>
</connections>
</ui>