Skip to content

Commit 04c094c

Browse files
committed
Make the server list accessible.
1 parent b448184 commit 04c094c

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

src/connectdlg.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424

2525
#include "connectdlg.h"
2626

27+
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
28+
# include <QAccessible>
29+
# include <QAccessibleAnnouncementEvent>
30+
#endif
31+
2732
/* Implementation *************************************************************/
2833

2934
// mapVersionStr - converts a version number to a sortable string
@@ -243,6 +248,7 @@ CConnectDlg::CConnectDlg ( CClientSettings* pNSetP, const bool bNewShowCompleteR
243248

244249
// to get default return key behaviour working
245250
QObject::connect ( lvwServers, &QTreeWidget::activated, this, &CConnectDlg::OnConnectClicked );
251+
QObject::connect ( lvwServers, &QTreeWidget::currentItemChanged, this, &CConnectDlg::OnCurrentServerItemChanged );
246252

247253
// line edit
248254
QObject::connect ( edtFilter, &QLineEdit::textEdited, this, &CConnectDlg::OnFilterTextEdited );
@@ -567,6 +573,7 @@ void CConnectDlg::SetConnClientsList ( const CHostAddress& InetAddr, const CVect
567573

568574
if ( vecChanInfo[i].eCountry != QLocale::AnyCountry )
569575
{
576+
pNewChildListViewItem->setData ( LVC_NAME, Qt::UserRole, QLocale::countryToString ( vecChanInfo[i].eCountry ) );
570577
// try to load the country flag icon
571578
QPixmap CountryFlagPixmap ( CLocale::GetCountryFlagIconsResourceReference ( vecChanInfo[i].eCountry ) );
572579

@@ -1106,3 +1113,30 @@ void CConnectDlg::UpdateDirectoryComboBox()
11061113
}
11071114
}
11081115
}
1116+
1117+
void CConnectDlg::OnCurrentServerItemChanged ( QTreeWidgetItem* current, QTreeWidgetItem* )
1118+
{
1119+
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
1120+
if ( !current )
1121+
return;
1122+
1123+
QString announcement;
1124+
if ( current->parent() )
1125+
{
1126+
// It's a client
1127+
announcement = current->text ( LVC_NAME );
1128+
QVariant countryData = current->data ( LVC_NAME, Qt::UserRole );
1129+
if ( countryData.isValid() )
1130+
{
1131+
announcement += ", " + countryData.toString();
1132+
}
1133+
}
1134+
else
1135+
{
1136+
// It's a server
1137+
announcement = current->text ( LVC_NAME ) + ", " + current->text ( LVC_CLIENTS ) + ", " + current->text ( LVC_LOCATION ) + ", " +
1138+
tr ( "Ping" ) + " " + current->text ( LVC_PING );
1139+
}
1140+
QAccessible::updateAccessibility ( new QAccessibleAnnouncementEvent ( lvwServers, announcement ) );
1141+
#endif
1142+
}

src/connectdlg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ public slots:
132132
void OnDeleteServerAddrClicked();
133133
void OnTimerPing();
134134
void OnTimerReRequestServList();
135+
void OnCurrentServerItemChanged ( QTreeWidgetItem* current, QTreeWidgetItem* previous );
135136

136137
signals:
137138
void ReqServerListQuery ( CHostAddress InetAddr );

0 commit comments

Comments
 (0)