From 6cac92f1b0608f2e1f792d9b13165cf807d49feb Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Sun, 21 Jun 2020 14:45:11 +0200 Subject: [PATCH] Add send button to chat window #384 --- ChangeLog | 6 ++- src/chatdlg.cpp | 27 ++++++++---- src/chatdlg.h | 5 ++- src/chatdlgbase.ui | 100 ++++++++++++++------------------------------- 4 files changed, 58 insertions(+), 80 deletions(-) diff --git a/ChangeLog b/ChangeLog index a1cebe79..093d80ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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) diff --git a/src/chatdlg.cpp b/src/chatdlg.cpp index a8833e53..e2555bf0 100755 --- a/src/chatdlg.cpp +++ b/src/chatdlg.cpp @@ -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(); diff --git a/src/chatdlg.h b/src/chatdlg.h index 32485aa7..648d353d 100755 --- a/src/chatdlg.h +++ b/src/chatdlg.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -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 ); } diff --git a/src/chatdlgbase.ui b/src/chatdlgbase.ui index 0d9addec..876256af 100755 --- a/src/chatdlgbase.ui +++ b/src/chatdlgbase.ui @@ -1,7 +1,8 @@ - + + CChatDlgBase - - + + 0 0 @@ -9,70 +10,51 @@ 405 - - + + 0 0 - + Chat - - :/png/main/res/fronticon.png + + + :/png/main/res/fronticon.png:/png/main/res/fronticon.png - + true - + - - + + + false + + Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::NoTextInteraction|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + false + - - - - + - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 181 - 27 - - - + - - - Cl&ear + + + &Send - - false + + true - - - - - - &Close - - - false - - - false + + true @@ -81,30 +63,10 @@ - edtLocalInputText txvChatWindow - butClear - buttonClose - + - - - buttonClose - clicked() - CChatDlgBase - accept() - - - 20 - 20 - - - 20 - 20 - - - - +