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,9 +19,11 @@
- 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)
- bug fix: server window stop updating after minimized, coded by AronVietti (#355, #383)
- add send button to chat window (#384)
- 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();
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)
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 -------------------------------------------------------------
QObject::connect ( edtLocalInputText, &QLineEdit::textChanged,
this, &CChatDlg::OnLocalInputTextTextChanged );
QObject::connect ( edtLocalInputText, &QLineEdit::returnPressed,
this, &CChatDlg::OnLocalInputTextReturnPressed );
QObject::connect ( butClear, &QPushButton::pressed,
this, &CChatDlg::OnClearPressed );
QObject::connect ( butSend, &QPushButton::clicked,
this, &CChatDlg::OnSendText );
}
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
emit NewLocalInputText ( edtLocalInputText->text() );
edtLocalInputText->clear();
}
void CChatDlg::OnClearPressed()
void CChatDlg::OnClearChatHistory()
{
// clear chat window
txvChatWindow->clear();

View File

@ -26,6 +26,7 @@
#include <QString>
#include <QLineEdit>
#include <QPushButton>
#include <QMenuBar>
#include <QWhatsThis>
#include <QLayout>
#include <QAccessible>
@ -44,9 +45,9 @@ public:
void AddChatText ( QString strChatText );
public slots:
void OnLocalInputTextReturnPressed();
void OnSendText();
void OnLocalInputTextTextChanged ( const QString& strNewText );
void OnClearPressed();
void OnClearChatHistory();
void keyPressEvent ( QKeyEvent *e ) // block escape key
{ 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>
<widget class="QDialog" name="CChatDlgBase" >
<property name="geometry" >
<widget class="QDialog" name="CChatDlgBase">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
@ -9,70 +10,51 @@
<height>405</height>
</rect>
</property>
<property name="sizePolicy" >
<sizepolicy vsizetype="Minimum" hsizetype="Minimum" >
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle" >
<property name="windowTitle">
<string>Chat</string>
</property>
<property name="windowIcon" >
<iconset resource="resources.qrc" >:/png/main/res/fronticon.png</iconset>
<property name="windowIcon">
<iconset resource="resources.qrc">
<normaloff>:/png/main/res/fronticon.png</normaloff>:/png/main/res/fronticon.png</iconset>
</property>
<property name="sizeGripEnabled" >
<property name="sizeGripEnabled">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" >
<layout class="QVBoxLayout">
<item>
<widget class="QTextBrowser" name="txvChatWindow" >
<property name="textInteractionFlags" >
<widget class="QTextBrowser" name="txvChatWindow">
<property name="acceptDrops">
<bool>false</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::NoTextInteraction|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
<property name="openLinks">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="edtLocalInputText" />
</item>
<item>
<layout class="QHBoxLayout" >
<layout class="QHBoxLayout" name="horizontalLayout">
<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>
<widget class="QLineEdit" name="edtLocalInputText"/>
</item>
<item>
<widget class="QPushButton" name="butClear" >
<property name="text" >
<string>Cl&amp;ear</string>
<widget class="QPushButton" name="butSend">
<property name="text">
<string>&amp;Send</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonClose" >
<property name="text" >
<string>&amp;Close</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
<property name="default" >
<bool>false</bool>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
@ -81,30 +63,10 @@
</layout>
</widget>
<tabstops>
<tabstop>edtLocalInputText</tabstop>
<tabstop>txvChatWindow</tabstop>
<tabstop>butClear</tabstop>
<tabstop>buttonClose</tabstop>
</tabstops>
<resources>
<include location="resources.qrc" />
<include location="resources.qrc"/>
</resources>
<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>
<connections/>
</ui>