Hello, currently, the "join chatroom" dialog of Jabber looks quite confusing, starting from the fact you have to "switch dialog" if you want to list the available chatrooms...
The attached patch does the following: - places the "nick" lineedit on the top of the dialog - adds a "query" button next to the server lineedit, and a list with them below it; this way, the extra dialog is no more needed - adds a "cancel" button to the dialog (or close? not sure; not a big deal anyway) - changes the way the Jabber services are "scanned" for chatroom services: instead of a JT_GetServices task, a JT_DiscoItems one is run. This is also what is used for the "services" dialog, and thus the automatic chatroom service filling (now a combobox instead of a lineedit) works (at least with jabber.linux.it and kdetalk.net, testers for other servers are welcome). - disable the "join" button if at least one of nick, server and chatroom lineedits is empty - double click on a chatroom writes it in the chatroom lineedit, and if nick and server ones are not empty, the "join" action is started I should have not forgotten anything so... comments? -- Pino Toscano
Index: ui/dlgjabberchatjoin.cpp
===================================================================
--- ui/dlgjabberchatjoin.cpp (revisione 858346)
+++ ui/dlgjabberchatjoin.cpp (copia locale)
@@ -18,22 +18,23 @@
#include <kdebug.h>
#include <klocale.h>
+#include <kmessagebox.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include "jabberaccount.h"
#include "jabberclient.h"
-#include "dlgjabberchatroomslist.h"
+#include "xmpp_tasks.h"
+
#include "dlgjabberchatjoin.h"
dlgJabberChatJoin::dlgJabberChatJoin(JabberAccount *account, QWidget* parent)
: KDialog(parent), m_account(account)
{
setCaption( i18n("Join Jabber Groupchat") );
- setButtons( KDialog::User1 | KDialog::User2 );
+ setButtons( KDialog::Cancel | KDialog::User1 );
setButtonGuiItem( KDialog::User1, KGuiItem( i18n("Join") ) );
- setButtonGuiItem( KDialog::User2, KGuiItem( i18n("Browser") ) );
QWidget *mainWidget = new QWidget(this);
m_ui.setupUi(mainWidget);
@@ -43,7 +44,13 @@
checkDefaultChatroomServer();
connect(this, SIGNAL(user1Clicked()), this, SLOT(slotJoin()));
- connect(this, SIGNAL(user2Clicked()), this, SLOT(slotBowse()));
+ connect(m_ui.pbQuery, SIGNAL(clicked()), this, SLOT(slotQuery()));
+ connect(m_ui.tblChatRoomsList, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(slotDoubleClick(QTreeWidgetItem *)));
+ connect(m_ui.leServer, SIGNAL(textChanged(QString)), this, SLOT(slotCheckData()));
+ connect(m_ui.leRoom, SIGNAL(textChanged(QString)), this, SLOT(slotCheckData()));
+ connect(m_ui.leNick, SIGNAL(textChanged(QString)), this, SLOT(slotCheckData()));
+
+ slotCheckData();
}
dlgJabberChatJoin::~dlgJabberChatJoin()
@@ -59,23 +66,10 @@
return;
}
- m_account->client()->joinGroupChat(m_ui.leServer->text(), m_ui.leRoom->text(), m_ui.leNick->text());
+ m_account->client()->joinGroupChat(m_ui.leServer->currentText(), m_ui.leRoom->text(), m_ui.leNick->text());
accept();
}
-void dlgJabberChatJoin::slotBowse()
-{
- if(!m_account->isConnected())
- {
- m_account->errorConnectFirst();
- return;
- }
-
- dlgJabberChatRoomsList *crl = new dlgJabberChatRoomsList(m_account, m_ui.leServer->text() , m_ui.leNick->text());
- crl->show();
- accept();
-}
-
/*
TODO : Used to look for the default chat server,
this is duplicate with dlgjabberservices.cpp
@@ -86,7 +80,7 @@
void dlgJabberChatJoin::checkDefaultChatroomServer()
{
- XMPP::JT_GetServices *serviceTask = new XMPP::JT_GetServices(m_account->client()->rootTask());
+ XMPP::JT_DiscoItems *serviceTask = new JT_DiscoItems(m_account->client()->rootTask());
connect(serviceTask, SIGNAL (finished()), this, SLOT (slotQueryFinished()));
serviceTask->get(m_account->server());
@@ -95,16 +89,12 @@
void dlgJabberChatJoin::slotQueryFinished()
{
- XMPP::JT_GetServices *task = (XMPP::JT_GetServices*)sender();
- if (!task->success ())
+ XMPP::JT_DiscoItems *task = (JT_DiscoItems *)sender();
+ if (!task->success())
return;
-
- if(!m_ui.leServer->text().isEmpty())
- { //the user already started to type the server manyally. abort auto-detect
- return;
- }
- for (XMPP::AgentList::const_iterator it = task->agents().begin(); it != task->agents().end(); ++it)
+ const XMPP::DiscoList &list = task->items();
+ for (XMPP::DiscoList::ConstIterator it = list.begin(); it != list.end(); ++it)
{
XMPP::JT_DiscoInfo *discoTask = new XMPP::JT_DiscoInfo(m_account->client()->rootTask());
connect(discoTask, SIGNAL (finished()), this, SLOT (slotDiscoFinished()));
@@ -121,18 +111,68 @@
if (!task->success())
return;
- if(!m_ui.leServer->text().isEmpty())
- { //the user already started to type the server manyally. abort auto-detect
+ if (task->item().features().canGroupchat() && !task->item().features().isGateway())
+ {
+ const QString text = m_ui.leServer->currentText();
+ const bool wasEmpty = m_ui.leServer->count() == 0;
+ m_ui.leServer->addItem(task->item().jid().full());
+ // the combobox was empty, and the edit text was not empty,
+ // so restore the previous edit text
+ if (wasEmpty && !text.isEmpty())
+ {
+ m_ui.leServer->setEditText(text);
+ }
+ }
+}
+
+void dlgJabberChatJoin::slotQuery()
+{
+ XMPP::JT_DiscoItems *discoTask = new XMPP::JT_DiscoItems(m_account->client()->rootTask());
+ connect (discoTask, SIGNAL(finished()), this, SLOT(slotChatRooomsQueryFinished()));
+
+ m_ui.tblChatRoomsList->clear();
+
+ discoTask->get(m_ui.leServer->currentText());
+ discoTask->go(true);
+}
+
+void dlgJabberChatJoin::slotChatRooomsQueryFinished()
+{
+ XMPP::JT_DiscoItems *task = (XMPP::JT_DiscoItems*)sender();
+ if (!task->success())
+ {
+ KMessageBox::queuedMessageBox(this, KMessageBox::Error, i18n("Unable to retrieve the list of chat rooms."), i18n("Jabber Error"));
return;
}
+ const XMPP::DiscoList& items = task->items();
- if (task->item().features().canGroupchat() && !task->item().features().isGateway())
+ for (XMPP::DiscoList::const_iterator it = items.begin(); it != items.end(); ++it)
{
- m_ui.leServer->setText(task->item().jid().full());
+ const XMPP::DiscoItem &di = *it;
+ QTreeWidgetItem *item = new QTreeWidgetItem();
+ item->setText(0, di.jid().user());
+ item->setText(1, di.name());
+ m_ui.tblChatRoomsList->addTopLevelItem(item);
}
+ m_ui.tblChatRoomsList->sortItems(0, Qt::AscendingOrder);
}
+void dlgJabberChatJoin::slotDoubleClick(QTreeWidgetItem *item)
+{
+ m_ui.leRoom->setText(item->text(0));
+ if (!(m_ui.leServer->currentText().isEmpty() || m_ui.leNick->text().isEmpty()))
+ {
+ slotJoin();
+ }
+}
+
+void dlgJabberChatJoin::slotCheckData()
+{
+ bool enableJoinButton = !(m_ui.leServer->currentText().isEmpty() || m_ui.leRoom->text().isEmpty() || m_ui.leNick->text().isEmpty());
+ enableButton(User1, enableJoinButton);
+}
+
// end todo
#include "dlgjabberchatjoin.moc"
Index: ui/dlgjabberchatjoin.h
===================================================================
--- ui/dlgjabberchatjoin.h (revisione 858346)
+++ ui/dlgjabberchatjoin.h (copia locale)
@@ -36,7 +36,7 @@
public slots:
/*$PUBLIC_SLOTS$*/
virtual void slotJoin();
- virtual void slotBowse();
+ virtual void slotQuery();
protected:
/*$PROTECTED_FUNCTIONS$*/
@@ -56,6 +56,9 @@
private slots:
void slotQueryFinished();
void slotDiscoFinished();
+ void slotChatRooomsQueryFinished();
+ void slotCheckData();
+ void slotDoubleClick(QTreeWidgetItem *item);
// end todo.
Index: ui/dlgchatjoin.ui
===================================================================
--- ui/dlgchatjoin.ui (revisione 858346)
+++ ui/dlgchatjoin.ui (copia locale)
@@ -9,54 +9,71 @@
<height>315</height>
</rect>
</property>
- <layout class="QVBoxLayout" >
- <item>
- <layout class="QGridLayout" >
- <item row="0" column="0" >
- <widget class="QLabel" name="label" >
- <property name="text" >
- <string>Room:</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1" >
- <widget class="KLineEdit" name="leRoom" />
- </item>
- <item row="1" column="0" >
- <widget class="QLabel" name="label_2" >
- <property name="text" >
- <string>Server:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1" >
- <widget class="KLineEdit" name="leServer" />
- </item>
- <item row="2" column="0" >
- <widget class="QLabel" name="label_3" >
- <property name="text" >
- <string>Nick:</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1" >
- <widget class="KLineEdit" name="leNick" />
- </item>
- </layout>
+ <layout class="QGridLayout" name="gridLayout" >
+ <item row="0" column="0" >
+ <widget class="QLabel" name="label_3" >
+ <property name="text" >
+ <string>Nick:</string>
+ </property>
+ </widget>
</item>
- <item>
- <spacer>
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
+ <item row="0" column="1" colspan="2" >
+ <widget class="KLineEdit" name="leNick" />
+ </item>
+ <item row="1" column="0" >
+ <widget class="QLabel" name="label_2" >
+ <property name="text" >
+ <string>Server:</string>
</property>
- <property name="sizeHint" >
- <size>
- <width>20</width>
- <height>40</height>
- </size>
+ </widget>
+ </item>
+ <item row="1" column="1" >
+ <widget class="QComboBox" name="leServer" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="MinimumExpanding" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
- </spacer>
+ <property name="editable" >
+ <bool>true</bool>
+ </property>
+ </widget>
</item>
+ <item row="1" column="2" >
+ <widget class="QPushButton" name="pbQuery" >
+ <property name="text" >
+ <string>&Query</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" colspan="2" >
+ <widget class="QTreeWidget" name="tblChatRoomsList" >
+ <property name="rootIsDecorated" >
+ <bool>false</bool>
+ </property>
+ <column>
+ <property name="text" >
+ <string>Chatroom Name</string>
+ </property>
+ </column>
+ <column>
+ <property name="text" >
+ <string>Chatroom Description</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ <item row="3" column="0" >
+ <widget class="QLabel" name="label" >
+ <property name="text" >
+ <string>Room:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1" colspan="2" >
+ <widget class="KLineEdit" name="leRoom" />
+ </item>
</layout>
</widget>
<customwidgets>
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ kopete-devel mailing list [email protected] https://mail.kde.org/mailman/listinfo/kopete-devel
