Changed the dock widget for the chat so that it replicates the agreed

upon design.
This commit is contained in:
Dimitar Dobrev 2014-03-24 17:37:34 +02:00
parent 5073439007
commit e27f191413
3 changed files with 177 additions and 173 deletions

View file

@ -27,25 +27,25 @@
<context> <context>
<name>ChatWindow</name> <name>ChatWindow</name>
<message> <message>
<location filename="ui/chatWindow.ui" line="20"/> <location filename="ui/chatWindow.ui" line="26"/>
<location filename="../build/interface/ui_chatWindow.h" line="146"/> <location filename="../build/interface/ui_chatWindow.h" line="152"/>
<source>Chat</source> <source>Chat</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="ui/chatWindow.ui" line="50"/> <location filename="ui/chatWindow.ui" line="54"/>
<location filename="../build/interface/ui_chatWindow.h" line="147"/> <location filename="../build/interface/ui_chatWindow.h" line="153"/>
<source>Connecting to XMPP...</source> <source>Connecting to XMPP...</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="ui/chatWindow.ui" line="71"/> <location filename="ui/chatWindow.ui" line="75"/>
<location filename="../build/interface/ui_chatWindow.h" line="148"/> <location filename="../build/interface/ui_chatWindow.h" line="154"/>
<source> online now:</source> <source> online now:</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message numerus="yes"> <message numerus="yes">
<location filename="src/ui/ChatWindow.cpp" line="136"/> <location filename="src/ui/ChatWindow.cpp" line="135"/>
<source>day</source> <source>day</source>
<translation> <translation>
<numerusform>%n day</numerusform> <numerusform>%n day</numerusform>
@ -53,7 +53,7 @@
</translation> </translation>
</message> </message>
<message numerus="yes"> <message numerus="yes">
<location filename="src/ui/ChatWindow.cpp" line="136"/> <location filename="src/ui/ChatWindow.cpp" line="135"/>
<source>hour</source> <source>hour</source>
<translation> <translation>
<numerusform>%n hour</numerusform> <numerusform>%n hour</numerusform>
@ -61,7 +61,7 @@
</translation> </translation>
</message> </message>
<message numerus="yes"> <message numerus="yes">
<location filename="src/ui/ChatWindow.cpp" line="136"/> <location filename="src/ui/ChatWindow.cpp" line="135"/>
<source>minute</source> <source>minute</source>
<translation> <translation>
<numerusform>%n minute</numerusform> <numerusform>%n minute</numerusform>
@ -76,7 +76,7 @@
</translation> </translation>
</message> </message>
<message> <message>
<location filename="src/ui/ChatWindow.cpp" line="192"/> <location filename="src/ui/ChatWindow.cpp" line="191"/>
<source>%1 online now:</source> <source>%1 online now:</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>

View file

@ -30,10 +30,10 @@ ChatWindow::ChatWindow() :
ui(new Ui::ChatWindow), ui(new Ui::ChatWindow),
numMessagesAfterLastTimeStamp(0) numMessagesAfterLastTimeStamp(0)
{ {
QWidget* widget = new QWidget(); ui->setupUi(this);
setWidget(widget);
// remove the title bar (see the Qt docs on setTitleBarWidget)
ui->setupUi(widget); setTitleBarWidget(new QWidget());
FlowLayout* flowLayout = new FlowLayout(0, 4, 4); FlowLayout* flowLayout = new FlowLayout(0, 4, 4);
ui->usersWidget->setLayout(flowLayout); ui->usersWidget->setLayout(flowLayout);
@ -42,8 +42,6 @@ ChatWindow::ChatWindow() :
ui->messagesGridLayout->setColumnStretch(1, 3); ui->messagesGridLayout->setColumnStretch(1, 3);
ui->messagePlainTextEdit->installEventFilter(this); ui->messagePlainTextEdit->installEventFilter(this);
ui->closeButton->hide();
#ifdef HAVE_QXMPP #ifdef HAVE_QXMPP
const QXmppClient& xmppClient = XmppClient::getInstance().getXMPPClient(); const QXmppClient& xmppClient = XmppClient::getInstance().getXMPPClient();
@ -78,15 +76,16 @@ ChatWindow::~ChatWindow() {
} }
void ChatWindow::keyPressEvent(QKeyEvent* event) { void ChatWindow::keyPressEvent(QKeyEvent* event) {
QWidget::keyPressEvent(event); QDockWidget::keyPressEvent(event);
if (event->key() == Qt::Key_Escape) { if (event->key() == Qt::Key_Escape) {
hide(); hide();
} }
} }
void ChatWindow::showEvent(QShowEvent* event) { void ChatWindow::showEvent(QShowEvent* event) {
QWidget::showEvent(event); QDockWidget::showEvent(event);
if (!event->spontaneous()) { if (!event->spontaneous()) {
activateWindow();
ui->messagePlainTextEdit->setFocus(); ui->messagePlainTextEdit->setFocus();
} }
} }

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>ChatWindow</class> <class>ChatWindow</class>
<widget class="QWidget" name="ChatWindow"> <widget class="QDockWidget" name="ChatWindow">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
@ -13,180 +13,185 @@
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>400</width> <width>400</width>
<height>0</height> <height>238</height>
</size> </size>
</property> </property>
<property name="windowTitle">
<string>Chat</string>
</property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">font-family: Helvetica, Arial, sans-serif;</string> <string notr="true">font-family: Helvetica, Arial, sans-serif;</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <property name="features">
<property name="spacing"> <set>QDockWidget::NoDockWidgetFeatures</set>
<number>0</number> </property>
</property> <property name="windowTitle">
<property name="leftMargin"> <string>Chat</string>
<number>8</number> </property>
</property> <widget class="QWidget" name="dockWidgetContents">
<property name="topMargin"> <layout class="QVBoxLayout" name="verticalLayout">
<number>8</number> <property name="spacing">
</property> <number>0</number>
<property name="rightMargin"> </property>
<number>8</number> <property name="leftMargin">
</property> <number>8</number>
<property name="bottomMargin"> </property>
<number>8</number> <property name="topMargin">
</property> <number>8</number>
<item> </property>
<widget class="QLabel" name="connectingToXMPPLabel"> <property name="rightMargin">
<property name="sizePolicy"> <number>8</number>
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> </property>
<horstretch>0</horstretch> <property name="bottomMargin">
<verstretch>0</verstretch> <number>8</number>
</sizepolicy> </property>
</property> <item>
<property name="text"> <widget class="QLabel" name="connectingToXMPPLabel">
<string>Connecting to XMPP...</string> <property name="sizePolicy">
</property> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<property name="alignment"> <horstretch>0</horstretch>
<set>Qt::AlignCenter</set> <verstretch>0</verstretch>
</property> </sizepolicy>
</widget> </property>
</item> <property name="text">
<item> <string>Connecting to XMPP...</string>
<layout class="QHBoxLayout" name="horizontalLayout"> </property>
<item> <property name="alignment">
<widget class="QLabel" name="numOnlineLabel"> <set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<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"/>
</item>
<item>
<widget class="QScrollArea" name="messagesScrollArea">
<property name="styleSheet">
<string notr="true">margin-top: 12px;</string>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>382</width>
<height>16</height>
</rect>
</property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">font-weight: bold; color: palette(shadow); margin-bottom: 4px;</string> <string notr="true">margin-top: 0px;</string>
</property>
<property name="text">
<string> online now:</string>
</property> </property>
<layout class="QGridLayout" name="messagesGridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
</layout>
</widget> </widget>
</item> </widget>
<item> </item>
<widget class="QPushButton" name="closeButton"> <item>
<property name="sizePolicy"> <widget class="QPlainTextEdit" name="messagePlainTextEdit">
<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"/>
</item>
<item>
<widget class="QScrollArea" name="messagesScrollArea">
<property name="styleSheet">
<string notr="true">margin-top: 12px;</string>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>382</width>
<height>16</height>
</rect>
</property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="styleSheet"> <property name="minimumSize">
<string notr="true">margin-top: 0px;</string> <size>
<width>0</width>
<height>60</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">border-color: palette(dark); border-style: solid; border-left-width: 1px; border-right-width: 1px; border-bottom-width: 1px;</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustToContents</enum>
</property>
<property name="tabChangesFocus">
<bool>true</bool>
</property> </property>
<layout class="QGridLayout" name="messagesGridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
</layout>
</widget> </widget>
</widget> </item>
</item> </layout>
<item> </widget>
<widget class="QPlainTextEdit" name="messagePlainTextEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>60</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">border-color: palette(dark); border-style: solid; border-left-width: 1px; border-right-width: 1px; border-bottom-width: 1px;</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustToContents</enum>
</property>
<property name="tabChangesFocus">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget> </widget>
<tabstops> <tabstops>
<tabstop>messagePlainTextEdit</tabstop> <tabstop>messagePlainTextEdit</tabstop>