Add send button to chat window #384

This commit is contained in:
Volker Fischer 2020-06-21 14:45:11 +02:00
parent 0111f04c69
commit 6cac92f1b0
4 changed files with 58 additions and 80 deletions

View file

@ -19,7 +19,9 @@
- the local pan middle position is no longer attenuated in Mono-in/Stereo-out mode (#353) - the local pan middle position is no longer attenuated in Mono-in/Stereo-out mode (#353)
- added some protections to the code, coded by atsampson (#380, #381, #382) - add some protections to the code, coded by atsampson (#380, #381, #382)
- add send button to chat window (#384)
- bug fix: server window stop updating after minimized, coded by AronVietti (#355, #383) - bug fix: server window stop updating after minimized, coded by AronVietti (#355, #383)

View file

@ -52,19 +52,32 @@ CChatDlg::CChatDlg ( QWidget* parent, Qt::WindowFlags f ) :
txvChatWindow->clear(); txvChatWindow->clear();
edtLocalInputText->clear(); edtLocalInputText->clear();
// we do not want to show a curser in the chat history
txvChatWindow->setCursorWidth ( 0 );
// set a placeholder text to make sure where to type the message in (#384) // set a placeholder text to make sure where to type the message in (#384)
edtLocalInputText->setPlaceholderText ( tr ( "Type a message here" ) ); edtLocalInputText->setPlaceholderText ( tr ( "Type a message here" ) );
// Menu -------------------------------------------------------------------
QMenuBar* pMenu = new QMenuBar ( this );
QMenu* pEditMenu = new QMenu ( tr ( "&Edit" ), this );
pEditMenu->addAction ( tr ( "Cl&ear Chat History" ), this,
SLOT ( OnClearChatHistory() ), QKeySequence ( Qt::CTRL + Qt::Key_E ) );
pMenu->addMenu ( pEditMenu );
// Now tell the layout about the menu
layout()->setMenuBar ( pMenu );
// Connections ------------------------------------------------------------- // Connections -------------------------------------------------------------
QObject::connect ( edtLocalInputText, &QLineEdit::textChanged, QObject::connect ( edtLocalInputText, &QLineEdit::textChanged,
this, &CChatDlg::OnLocalInputTextTextChanged ); this, &CChatDlg::OnLocalInputTextTextChanged );
QObject::connect ( edtLocalInputText, &QLineEdit::returnPressed, QObject::connect ( butSend, &QPushButton::clicked,
this, &CChatDlg::OnLocalInputTextReturnPressed ); this, &CChatDlg::OnSendText );
QObject::connect ( butClear, &QPushButton::pressed,
this, &CChatDlg::OnClearPressed );
} }
void CChatDlg::OnLocalInputTextTextChanged ( const QString& strNewText ) void CChatDlg::OnLocalInputTextTextChanged ( const QString& strNewText )
@ -77,14 +90,14 @@ void CChatDlg::OnLocalInputTextTextChanged ( const QString& strNewText )
} }
} }
void CChatDlg::OnLocalInputTextReturnPressed() void CChatDlg::OnSendText()
{ {
// send new text and clear line afterwards // send new text and clear line afterwards
emit NewLocalInputText ( edtLocalInputText->text() ); emit NewLocalInputText ( edtLocalInputText->text() );
edtLocalInputText->clear(); edtLocalInputText->clear();
} }
void CChatDlg::OnClearPressed() void CChatDlg::OnClearChatHistory()
{ {
// clear chat window // clear chat window
txvChatWindow->clear(); txvChatWindow->clear();

View file

@ -26,6 +26,7 @@
#include <QString> #include <QString>
#include <QLineEdit> #include <QLineEdit>
#include <QPushButton> #include <QPushButton>
#include <QMenuBar>
#include <QWhatsThis> #include <QWhatsThis>
#include <QLayout> #include <QLayout>
#include <QAccessible> #include <QAccessible>
@ -44,9 +45,9 @@ public:
void AddChatText ( QString strChatText ); void AddChatText ( QString strChatText );
public slots: public slots:
void OnLocalInputTextReturnPressed(); void OnSendText();
void OnLocalInputTextTextChanged ( const QString& strNewText ); void OnLocalInputTextTextChanged ( const QString& strNewText );
void OnClearPressed(); void OnClearChatHistory();
void keyPressEvent ( QKeyEvent *e ) // block escape key void keyPressEvent ( QKeyEvent *e ) // block escape key
{ if ( e->key() != Qt::Key_Escape ) QDialog::keyPressEvent ( e ); } { if ( e->key() != Qt::Key_Escape ) QDialog::keyPressEvent ( e ); }

View file

@ -1,7 +1,8 @@
<ui version="4.0" > <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CChatDlgBase</class> <class>CChatDlgBase</class>
<widget class="QDialog" name="CChatDlgBase" > <widget class="QDialog" name="CChatDlgBase">
<property name="geometry" > <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
@ -9,70 +10,51 @@
<height>405</height> <height>405</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy" > <property name="sizePolicy">
<sizepolicy vsizetype="Minimum" hsizetype="Minimum" > <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="windowTitle" > <property name="windowTitle">
<string>Chat</string> <string>Chat</string>
</property> </property>
<property name="windowIcon" > <property name="windowIcon">
<iconset resource="resources.qrc" >:/png/main/res/fronticon.png</iconset> <iconset resource="resources.qrc">
<normaloff>:/png/main/res/fronticon.png</normaloff>:/png/main/res/fronticon.png</iconset>
</property> </property>
<property name="sizeGripEnabled" > <property name="sizeGripEnabled">
<bool>true</bool> <bool>true</bool>
</property> </property>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout">
<item> <item>
<widget class="QTextBrowser" name="txvChatWindow" > <widget class="QTextBrowser" name="txvChatWindow">
<property name="textInteractionFlags" > <property name="acceptDrops">
<bool>false</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::NoTextInteraction|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set> <set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::NoTextInteraction|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property> </property>
</widget> <property name="openLinks">
</item>
<item>
<widget class="QLineEdit" name="edtLocalInputText" />
</item>
<item>
<layout class="QHBoxLayout" >
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>181</width>
<height>27</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="butClear" >
<property name="text" >
<string>Cl&amp;ear</string>
</property>
<property name="autoDefault" >
<bool>false</bool> <bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="buttonClose" > <layout class="QHBoxLayout" name="horizontalLayout">
<property name="text" > <item>
<string>&amp;Close</string> <widget class="QLineEdit" name="edtLocalInputText"/>
</item>
<item>
<widget class="QPushButton" name="butSend">
<property name="text">
<string>&amp;Send</string>
</property> </property>
<property name="autoDefault" > <property name="autoDefault">
<bool>false</bool> <bool>true</bool>
</property> </property>
<property name="default" > <property name="default">
<bool>false</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
@ -81,30 +63,10 @@
</layout> </layout>
</widget> </widget>
<tabstops> <tabstops>
<tabstop>edtLocalInputText</tabstop>
<tabstop>txvChatWindow</tabstop> <tabstop>txvChatWindow</tabstop>
<tabstop>butClear</tabstop>
<tabstop>buttonClose</tabstop>
</tabstops> </tabstops>
<resources> <resources>
<include location="resources.qrc" /> <include location="resources.qrc"/>
</resources> </resources>
<connections> <connections/>
<connection>
<sender>buttonClose</sender>
<signal>clicked()</signal>
<receiver>CChatDlgBase</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel" >
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections>
</ui> </ui>