added clear button to chat dialog, improvements for accessiblity for chat dialog

This commit is contained in:
Volker Fischer 2009-11-30 22:16:31 +00:00
parent 278a252822
commit 7156763e4b
3 changed files with 41 additions and 20 deletions

View file

@ -31,17 +31,26 @@ CChatDlg::CChatDlg ( QWidget* parent, Qt::WindowFlags f ) :
{ {
setupUi ( this ); setupUi ( this );
// add help text to controls -----------------------------------------------
lineEditLocalInputText->setAccessibleName ( "New chat text edit box" );
TextViewChatWindow->setAccessibleName ( "Chat history" );
// clear chat window and edit line // clear chat window and edit line
TextViewChatWindow->clear(); TextViewChatWindow->clear();
lineEditLocalInputText->clear(); lineEditLocalInputText->clear();
// Connections ------------------------------------------------------------- // Connections -------------------------------------------------------------
QObject::connect ( lineEditLocalInputText, SIGNAL ( textChanged ( const QString& ) ), QObject::connect ( lineEditLocalInputText,
SIGNAL ( textChanged ( const QString& ) ),
this, SLOT ( OnChatTextChanged ( const QString& ) ) ); this, SLOT ( OnChatTextChanged ( const QString& ) ) );
QObject::connect ( lineEditLocalInputText, SIGNAL ( returnPressed() ), QObject::connect ( lineEditLocalInputText, SIGNAL ( returnPressed() ),
this, SLOT ( OnNewLocalInputText() ) ); this, SLOT ( OnNewLocalInputText() ) );
QObject::connect ( pbClear, SIGNAL ( pressed() ),
this, SLOT ( OnClearButtonPressed() ) );
} }
void CChatDlg::OnChatTextChanged ( const QString& strNewText ) void CChatDlg::OnChatTextChanged ( const QString& strNewText )
@ -61,8 +70,18 @@ void CChatDlg::OnNewLocalInputText()
lineEditLocalInputText->clear(); lineEditLocalInputText->clear();
} }
void CChatDlg::OnClearButtonPressed()
{
// clear chat window
TextViewChatWindow->clear();
}
void CChatDlg::AddChatText ( QString strChatText ) void CChatDlg::AddChatText ( QString strChatText )
{ {
// add new text in chat window // add new text in chat window
TextViewChatWindow->append ( strChatText ); TextViewChatWindow->append ( strChatText );
// notify accessibility plugin that text has changed
QAccessible::updateAccessibility ( TextViewChatWindow, 0,
QAccessible::ValueChanged );
} }

View file

@ -28,6 +28,7 @@
#include <qpushbutton.h> #include <qpushbutton.h>
#include <qwhatsthis.h> #include <qwhatsthis.h>
#include <qlayout.h> #include <qlayout.h>
#include <qaccessible.h>
#include "global.h" #include "global.h"
#ifdef _WIN32 #ifdef _WIN32
# include "../windows/moc/chatdlgbase.h" # include "../windows/moc/chatdlgbase.h"
@ -49,6 +50,7 @@ public:
public slots: public slots:
void OnNewLocalInputText(); void OnNewLocalInputText();
void OnChatTextChanged ( const QString& strNewText ); void OnChatTextChanged ( const QString& strNewText );
void OnClearButtonPressed();
signals: signals:
void NewLocalInputText ( QString strNewText ); void NewLocalInputText ( QString strNewText );

View file

@ -26,28 +26,17 @@
</property> </property>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<item> <item>
<widget class="QTextBrowser" name="TextViewChatWindow" /> <widget class="QTextBrowser" name="TextViewChatWindow" >
<property name="textInteractionFlags" >
<set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::NoTextInteraction|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="lineEditLocalInputText" /> <widget class="QLineEdit" name="lineEditLocalInputText" />
</item> </item>
<item> <item>
<layout class="QHBoxLayout" > <layout class="QHBoxLayout" >
<property name="spacing" >
<number>6</number>
</property>
<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>
<item> <item>
<spacer> <spacer>
<property name="orientation" > <property name="orientation" >
@ -58,12 +47,22 @@
</property> </property>
<property name="sizeHint" > <property name="sizeHint" >
<size> <size>
<width>20</width> <width>181</width>
<height>20</height> <height>27</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </item>
<item>
<widget class="QPushButton" name="pbClear" >
<property name="text" >
<string>Cl&amp;ear</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
</widget>
</item>
<item> <item>
<widget class="QPushButton" name="buttonClose" > <widget class="QPushButton" name="buttonClose" >
<property name="text" > <property name="text" >
@ -83,8 +82,9 @@
</widget> </widget>
<tabstops> <tabstops>
<tabstop>lineEditLocalInputText</tabstop> <tabstop>lineEditLocalInputText</tabstop>
<tabstop>buttonClose</tabstop>
<tabstop>TextViewChatWindow</tabstop> <tabstop>TextViewChatWindow</tabstop>
<tabstop>pbClear</tabstop>
<tabstop>buttonClose</tabstop>
</tabstops> </tabstops>
<resources> <resources>
<include location="resources.qrc" /> <include location="resources.qrc" />