summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-01-16 19:56:10 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-01-20 21:40:49 (GMT)
commit004dfd8d4305b767b624be10072597ef3e311753 (patch)
tree7f9a70ce336e9eca3bc78397640530939e55fa20 /Swift/QtUI
parent03d69bfd11549e1c8dcbf3b5300029ba9892cf8a (diff)
downloadswift-contrib-004dfd8d4305b767b624be10072597ef3e311753.zip
swift-contrib-004dfd8d4305b767b624be10072597ef3e311753.tar.bz2
Use a dedicated Join MUC dialog.
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/MUCSearch/MUCSearchEmptyItem.cpp38
-rw-r--r--Swift/QtUI/MUCSearch/MUCSearchEmptyItem.h25
-rw-r--r--Swift/QtUI/MUCSearch/MUCSearchModel.cpp16
-rw-r--r--Swift/QtUI/MUCSearch/MUCSearchServiceItem.h6
-rw-r--r--Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp168
-rw-r--r--Swift/QtUI/MUCSearch/QtMUCSearchWindow.h23
-rw-r--r--Swift/QtUI/MUCSearch/QtMUCSearchWindow.ui266
-rw-r--r--Swift/QtUI/QtJoinMUCWindow.cpp53
-rw-r--r--Swift/QtUI/QtJoinMUCWindow.h32
-rw-r--r--Swift/QtUI/QtJoinMUCWindow.ui116
-rw-r--r--Swift/QtUI/QtMainWindow.cpp5
-rw-r--r--Swift/QtUI/QtUIFactory.cpp9
-rw-r--r--Swift/QtUI/QtUIFactory.h3
-rw-r--r--Swift/QtUI/SConscript3
14 files changed, 446 insertions, 317 deletions
diff --git a/Swift/QtUI/MUCSearch/MUCSearchEmptyItem.cpp b/Swift/QtUI/MUCSearch/MUCSearchEmptyItem.cpp
new file mode 100644
index 0000000..b1b4175
--- /dev/null
+++ b/Swift/QtUI/MUCSearch/MUCSearchEmptyItem.cpp
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include <Swift/QtUI/MUCSearch/MUCSearchEmptyItem.h>
+
+#include <Swift/QtUI/MUCSearch/MUCSearchServiceItem.h>
+#include <QFont>
+#include <QColor>
+
+namespace Swift {
+MUCSearchEmptyItem::MUCSearchEmptyItem(MUCSearchServiceItem* parent) : parent(parent) {
+ parent->addRoom(this);
+}
+
+MUCSearchServiceItem* MUCSearchEmptyItem::getParent() {
+ return parent;
+}
+
+QVariant MUCSearchEmptyItem::data(int role) {
+ switch (role) {
+ case Qt::DisplayRole:
+ return QVariant("No rooms found");
+ case Qt::FontRole: {
+ QFont font;
+ font.setItalic(true);
+ return font;
+ }
+ case Qt::ForegroundRole:
+ return QColor(Qt::gray);
+ default:
+ return QVariant();
+ }
+}
+
+}
diff --git a/Swift/QtUI/MUCSearch/MUCSearchEmptyItem.h b/Swift/QtUI/MUCSearch/MUCSearchEmptyItem.h
new file mode 100644
index 0000000..d752ae3
--- /dev/null
+++ b/Swift/QtUI/MUCSearch/MUCSearchEmptyItem.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#pragma once
+
+#include <Swift/QtUI/MUCSearch/MUCSearchItem.h>
+
+namespace Swift {
+ class MUCSearchServiceItem;
+
+ class MUCSearchEmptyItem : public MUCSearchItem {
+ public:
+ MUCSearchEmptyItem(MUCSearchServiceItem* parent);
+
+ MUCSearchServiceItem* getParent();
+
+ QVariant data(int role);
+
+ private:
+ MUCSearchServiceItem* parent;
+ };
+}
diff --git a/Swift/QtUI/MUCSearch/MUCSearchModel.cpp b/Swift/QtUI/MUCSearch/MUCSearchModel.cpp
index 2526039..c657190 100644
--- a/Swift/QtUI/MUCSearch/MUCSearchModel.cpp
+++ b/Swift/QtUI/MUCSearch/MUCSearchModel.cpp
@@ -5,6 +5,7 @@
*/
#include "Swift/QtUI/MUCSearch/MUCSearchModel.h"
+#include "Swift/QtUI/MUCSearch/MUCSearchEmptyItem.h"
namespace Swift {
@@ -39,7 +40,6 @@ QModelIndex MUCSearchModel::index(int row, int column, const QModelIndex & paren
if (parent.isValid()) {
MUCSearchServiceItem* parentItem = static_cast<MUCSearchServiceItem*>(parent.internalPointer());
return row < parentItem->rowCount() ? createIndex(row, column, parentItem->getItem(row)) : QModelIndex();
-
} else {
return row < services_.size() ? createIndex(row, column, services_[row]) : QModelIndex();
}
@@ -55,10 +55,17 @@ QModelIndex MUCSearchModel::parent(const QModelIndex& index) const {
if (!item) {
return QModelIndex();
}
- if (dynamic_cast<MUCSearchServiceItem*>(item)) {
+ else if (dynamic_cast<MUCSearchServiceItem*>(item)) {
return QModelIndex();
}
- MUCSearchServiceItem* parent = dynamic_cast<MUCSearchRoomItem*>(item)->getParent();
+
+ MUCSearchServiceItem* parent = NULL;
+ if (MUCSearchRoomItem* roomItem = dynamic_cast<MUCSearchRoomItem*>(item)) {
+ parent = roomItem->getParent();
+ }
+ else if (MUCSearchEmptyItem* emptyItem = dynamic_cast<MUCSearchEmptyItem*>(item)) {
+ parent = emptyItem->getParent();
+ }
if (parent) {
int row = services_.indexOf(parent);
return createIndex(row, 1, parent);
@@ -74,7 +81,8 @@ int MUCSearchModel::rowCount(const QModelIndex& parentIndex) const {
}
if (dynamic_cast<MUCSearchServiceItem*>(static_cast<MUCSearchItem*>(parentIndex.internalPointer()))) {
return services_[parentIndex.row()]->rowCount();
- } else {
+ }
+ else {
return 0;
}
}
diff --git a/Swift/QtUI/MUCSearch/MUCSearchServiceItem.h b/Swift/QtUI/MUCSearch/MUCSearchServiceItem.h
index 860792f..411727d 100644
--- a/Swift/QtUI/MUCSearch/MUCSearchServiceItem.h
+++ b/Swift/QtUI/MUCSearch/MUCSearchServiceItem.h
@@ -15,9 +15,9 @@ namespace Swift {
class MUCSearchServiceItem : public MUCSearchItem {
public:
MUCSearchServiceItem(const QString& jidString) : jidString_(jidString) {}
- void addRoom(MUCSearchRoomItem* room) {rooms_.push_back(room);}
+ void addRoom(MUCSearchItem* room) {rooms_.push_back(room);}
int rowCount() {return rooms_.count();}
- MUCSearchRoomItem* getItem(int i) {return rooms_[i];}
+ MUCSearchItem* getItem(int i) {return rooms_[i];}
QVariant data(int role) {
switch (role) {
case Qt::DisplayRole: return QVariant(jidString_);
@@ -26,7 +26,7 @@ namespace Swift {
}
QString getHost() {return jidString_;}
private:
- QList<MUCSearchRoomItem*> rooms_;
+ QList<MUCSearchItem*> rooms_;
QString jidString_;
};
}
diff --git a/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp
index 7d2caba..3bdc433 100644
--- a/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp
+++ b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp
@@ -10,43 +10,42 @@
#include <QMovie>
#include <QScrollBar>
#include <QTimer>
+#include <QPushButton>
-#include "Swift/Controllers/UIEvents/UIEventStream.h"
#include "Swift/Controllers/UIEvents/JoinMUCUIEvent.h"
#include "Swift/Controllers/UIEvents/AddMUCBookmarkUIEvent.h"
#include "Swift/QtUI/MUCSearch/MUCSearchModel.h"
#include "Swift/QtUI/MUCSearch/MUCSearchDelegate.h"
+#include "Swift/QtUI/MUCSearch/MUCSearchEmptyItem.h"
#include "Swift/QtUI/QtSwiftUtil.h"
namespace Swift {
-QtMUCSearchWindow::QtMUCSearchWindow(UIEventStream* eventStream) {
+QtMUCSearchWindow::QtMUCSearchWindow() {
+ ui_.setupUi(this);
#ifndef Q_WS_MAC
setWindowIcon(QIcon(":/logo-icon-16.png"));
#endif
- eventStream_ = eventStream;
- setupUi(this);
- showEmptyRooms_->hide();
- filterLabel_->hide();
- filter_->hide();
+ setModal(true);
+ ui_.filter_->hide();
model_ = new MUCSearchModel();
delegate_ = new MUCSearchDelegate();
- results_->setModel(model_);
- results_->setItemDelegate(delegate_);
- results_->setHeaderHidden(true);
-#ifdef SWIFT_PLATFORM_MACOSX
- results_->setAlternatingRowColors(true);
-#endif
- connect(service_, SIGNAL(activated(const QString&)), this, SLOT(handleSearch(const QString&)));
- connect(room_, SIGNAL(returnPressed()), this, SLOT(handleJoin()));
- connect(nickName_, SIGNAL(returnPressed()), room_, SLOT(setFocus()));
- connect(searchButton_, SIGNAL(clicked()), this, SLOT(handleSearch()));
- connect(joinButton_, SIGNAL(clicked()), this, SLOT(handleJoin()));
- connect(results_, SIGNAL(clicked(const QModelIndex&)), this, SLOT(handleSelected(const QModelIndex&)));
- connect(results_, SIGNAL(activated(const QModelIndex&)), this, SLOT(handleActivated(const QModelIndex&)));
- throbber_ = new QLabel("Searching", results_);
+ ui_.results_->setModel(model_);
+ ui_.results_->setItemDelegate(delegate_);
+ ui_.results_->setHeaderHidden(true);
+ ui_.results_->setRootIsDecorated(true);
+ ui_.results_->setAnimated(true);
+ ui_.results_->setAlternatingRowColors(true);
+ connect(ui_.service_, SIGNAL(activated(const QString&)), this, SLOT(handleSearch(const QString&)));
+ connect(ui_.results_, SIGNAL(activated(const QModelIndex&)), this, SLOT(handleActivated(const QModelIndex&)));
+ // Not using a button box, because i can't seem to be able to make the ok button non-default (on mac)
+ connect(ui_.okButton, SIGNAL(clicked()), this, SLOT(accept()));
+ connect(ui_.cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
+
+ throbber_ = new QLabel("Searching", ui_.results_);
throbber_->setMovie(new QMovie(":/icons/throbber.gif", QByteArray(), throbber_));
throbber_->setToolTip("Searching");
+
hasHadScrollBars_ = false;
updateThrobberPosition();
setSearchInProgress(false);
@@ -62,8 +61,8 @@ void QtMUCSearchWindow::resizeEvent(QResizeEvent* /*event*/) {
void QtMUCSearchWindow::updateThrobberPosition() {
bool isShown = throbber_->isVisible();
- int resultWidth = results_->width();
- int resultHeight = results_->height();
+ int resultWidth = ui_.results_->width();
+ int resultHeight = ui_.results_->height();
//throbberWidth = throbber_->movie()->scaledSize().width();
//throbberHeight = throbber_->movie()->scaledSize().height();
int throbberWidth = 16; /* This is nasty, but the above doesn't work! */
@@ -72,99 +71,43 @@ void QtMUCSearchWindow::updateThrobberPosition() {
* because if you listen for the expanded/collapsed signals, you seem to get them before the scrollbars are updated.
* This seems an acceptable workaround.
*/
- hasHadScrollBars_ |= results_->verticalScrollBar()->isVisible();
- int hMargin = hasHadScrollBars_ ? results_->verticalScrollBar()->width() + 2 : 2;
+ hasHadScrollBars_ |= ui_.results_->verticalScrollBar()->isVisible();
+ int hMargin = hasHadScrollBars_ ? ui_.results_->verticalScrollBar()->width() + 2 : 2;
int vMargin = 2; /* We don't get horizontal scrollbars */
throbber_->setGeometry(QRect(resultWidth - throbberWidth - hMargin, resultHeight - throbberHeight - vMargin, throbberWidth, throbberHeight)); /* include margins */
throbber_->setVisible(isShown);
}
-void QtMUCSearchWindow::addSavedServices(const std::vector<JID>& services) {
- service_->clear();
- foreach (JID jid, services) {
- service_->addItem(P2QSTRING(jid.toString()));
+void QtMUCSearchWindow::addSavedServices(const std::list<JID>& services) {
+ ui_.service_->clear();
+ foreach (const JID& jid, services) {
+ ui_.service_->addItem(P2QSTRING(jid.toString()));
}
- service_->clearEditText();
-}
-
-void QtMUCSearchWindow::handleActivated(const QModelIndex& index) {
- if (!index.isValid()) {
- return;
+ if (!services.empty()) {
+ ui_.service_->setEditText(P2QSTRING(services.begin()->toString()));
}
- MUCSearchRoomItem* roomItem = dynamic_cast<MUCSearchRoomItem*>(static_cast<MUCSearchItem*>(index.internalPointer()));
- if (roomItem) {
- handleSelected(index);
- handleJoin();
+ else {
+ ui_.service_->clearEditText();
}
}
-void QtMUCSearchWindow::handleSelected(const QModelIndex& current) {
- if (!current.isValid()) {
+void QtMUCSearchWindow::handleActivated(const QModelIndex& index) {
+ if (!index.isValid()) {
return;
- }
- MUCSearchRoomItem* roomItem = dynamic_cast<MUCSearchRoomItem*>(static_cast<MUCSearchItem*>(current.internalPointer()));
- if (roomItem) {
- room_->setText(roomItem->getNode() + "@" + roomItem->getParent()->getHost());
}
-
-}
-
-void QtMUCSearchWindow::handleSearch(const QString& text) {
- if (text.isEmpty()) {
- return;
+ if (dynamic_cast<MUCSearchRoomItem*>(static_cast<MUCSearchItem*>(index.internalPointer()))) {
+ accept();
}
- onAddService(JID(Q2PSTRING(text)));
}
void QtMUCSearchWindow::handleSearch() {
- handleSearch(service_->currentText());
-}
-
-
-void QtMUCSearchWindow::handleJoin() {
- if (room_->text().isEmpty()) {
- handleSelected(results_->currentIndex());
- }
- if (room_->text().isEmpty()) {
- return;
- }
- boost::optional<String> maybeNick;
- if (!nickName_->text().isEmpty()) {
- lastSetNick_ = Q2PSTRING(nickName_->text());
- maybeNick = lastSetNick_;
- }
-
- JID room(Q2PSTRING(room_->text()));
- if (joinAutomatically_->isChecked()) {
- createAutoJoin(room, maybeNick);
- }
- eventStream_->send(boost::shared_ptr<UIEvent>(new JoinMUCUIEvent(room, maybeNick)));
- hide();
+ handleSearch(ui_.service_->currentText());
}
-void QtMUCSearchWindow::createAutoJoin(const JID& room, boost::optional<String> passedNick) {
- String nick = lastSetNick_;
- if (passedNick) {
- nick = passedNick.get();
+void QtMUCSearchWindow::handleSearch(const QString& service) {
+ if (!service.isEmpty()) {
+ onSearchService(JID(Q2PSTRING(service)));
}
- MUCBookmark bookmark(room, room.getNode());
- bookmark.setAutojoin(true);
- if (!nick.isEmpty()) {
- bookmark.setNick(nick);
- }
- //if (!password.isEmpty()) {
- // bookmark.setPassword(password);
- //}
- eventStream_->send(boost::shared_ptr<UIEvent>(new AddMUCBookmarkUIEvent(bookmark)));
-}
-
-void QtMUCSearchWindow::setNick(const String& nick) {
- nickName_->setText(P2QSTRING(nick));
- lastSetNick_ = nick;
-}
-
-void QtMUCSearchWindow::setMUC(const String& nick) {
- room_->setText(P2QSTRING(nick));
}
void QtMUCSearchWindow::show() {
@@ -179,11 +122,16 @@ void QtMUCSearchWindow::clearList() {
void QtMUCSearchWindow::addService(const MUCService& service) {
updateThrobberPosition();
MUCSearchServiceItem* serviceItem = new MUCSearchServiceItem(P2QSTRING(service.getJID().toString()));
- foreach (MUCService::MUCRoom room, service.getRooms()) {
- new MUCSearchRoomItem(P2QSTRING(room.getNode()), serviceItem);
+ if (service.getRooms().size() > 0) {
+ foreach (MUCService::MUCRoom room, service.getRooms()) {
+ new MUCSearchRoomItem(P2QSTRING(room.getNode()), serviceItem);
+ }
+ }
+ else {
+ new MUCSearchEmptyItem(serviceItem);
}
model_->addService(serviceItem);
- results_->expandAll();
+ ui_.results_->expandAll();
}
void QtMUCSearchWindow::setSearchInProgress(bool searching) {
@@ -195,4 +143,24 @@ void QtMUCSearchWindow::setSearchInProgress(bool searching) {
throbber_->setVisible(searching);
}
+void QtMUCSearchWindow::accept() {
+ QModelIndexList selection = ui_.results_->selectionModel()->selectedIndexes();
+ if (selection.isEmpty()) {
+ onFinished(boost::optional<JID>());
+ }
+ else {
+ QModelIndex selectedItem = selection[0];
+ MUCSearchRoomItem* item = dynamic_cast<MUCSearchRoomItem*>(static_cast<MUCSearchItem*>(selectedItem.internalPointer()));
+ if (item) {
+ onFinished(JID(Q2PSTRING(item->getNode()), Q2PSTRING(item->getParent()->getHost())));
+ }
+ }
+ QDialog::accept();
+}
+
+void QtMUCSearchWindow::reject() {
+ onFinished(boost::optional<JID>());
+ QDialog::reject();
+}
+
}
diff --git a/Swift/QtUI/MUCSearch/QtMUCSearchWindow.h b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.h
index b8cf953..cb4585d 100644
--- a/Swift/QtUI/MUCSearch/QtMUCSearchWindow.h
+++ b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.h
@@ -13,37 +13,36 @@
namespace Swift {
class MUCSearchModel;
class MUCSearchDelegate;
- class UIEventStream;
- class QtMUCSearchWindow : public QWidget, public MUCSearchWindow, private Ui::QtMUCSearchWindow {
+
+ class QtMUCSearchWindow : public QDialog, public MUCSearchWindow {
Q_OBJECT
public:
- QtMUCSearchWindow(UIEventStream* eventStream);
+ QtMUCSearchWindow();
virtual ~QtMUCSearchWindow();
- virtual void setNick(const String& nick);
- virtual void setMUC(const String& nick);
virtual void clearList();
virtual void addService(const MUCService& service);
- virtual void addSavedServices(const std::vector<JID>& services);
+ virtual void addSavedServices(const std::list<JID>& services);
virtual void setSearchInProgress(bool searching);
virtual void show();
+ virtual void accept();
+ virtual void reject();
+
protected:
virtual void resizeEvent(QResizeEvent* event);
+
private slots:
- void handleSearch(const QString& text);
void handleSearch();
- void handleJoin();
- void handleSelected(const QModelIndex& current);
+ void handleSearch(const QString&);
void handleActivated(const QModelIndex& index);
void updateThrobberPosition();
+
private:
- void createAutoJoin(const JID& room, boost::optional<String> passedNick);
+ Ui::QtMUCSearchWindow ui_;
MUCSearchModel* model_;
MUCSearchDelegate* delegate_;
- UIEventStream* eventStream_;
QLabel* throbber_;
- String lastSetNick_;
bool hasHadScrollBars_;
};
}
diff --git a/Swift/QtUI/MUCSearch/QtMUCSearchWindow.ui b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.ui
index ef2524b..f1a1fd5 100644
--- a/Swift/QtUI/MUCSearch/QtMUCSearchWindow.ui
+++ b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.ui
@@ -1,212 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QtMUCSearchWindow</class>
- <widget class="QWidget" name="QtMUCSearchWindow">
+ <widget class="QDialog" name="QtMUCSearchWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>523</width>
- <height>531</height>
+ <height>368</height>
</rect>
</property>
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
<property name="windowTitle">
- <string>Find Room</string>
+ <string>Dialog</string>
</property>
- <layout class="QVBoxLayout" name="verticalLayout_4">
- <item>
- <layout class="QVBoxLayout" name="verticalLayout_3">
- <property name="sizeConstraint">
- <enum>QLayout::SetDefaultConstraint</enum>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Service:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QComboBox" name="service_">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>2</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QLineEdit" name="filter_">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="frame">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="3">
+ <widget class="QTreeView" name="results_"/>
+ </item>
+ <item row="2" column="0" colspan="3">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
<item>
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Available Rooms</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QTreeView" name="results_"/>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <widget class="QLabel" name="label_5">
- <property name="text">
- <string>Your nickname:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="nickName_"/>
- </item>
- <item>
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Search another service:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QComboBox" name="service_">
- <property name="editable">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="searchButton_">
- <property name="text">
- <string>Search</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <spacer name="verticalSpacer_2">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QLabel" name="filterLabel_">
- <property name="text">
- <string>Only show rooms matching:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="filter_"/>
- </item>
- <item>
- <widget class="QCheckBox" name="showEmptyRooms_">
- <property name="enabled">
- <bool>true</bool>
- </property>
- <property name="text">
- <string>Show Empty Rooms</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer_3">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>18</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>Join Room Directly:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="room_"/>
- </item>
- <item>
- <widget class="QCheckBox" name="joinAutomatically_">
- <property name="text">
- <string>Join automatically in future</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
+ <widget class="QPushButton" name="cancelButton">
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ </widget>
</item>
<item>
- <layout class="QHBoxLayout" name="horizontalLayout_3">
- <item>
- <spacer name="horizontalSpacer_2">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="joinButton_">
- <property name="text">
- <string>Join Room</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer_3">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
+ <widget class="QPushButton" name="okButton">
+ <property name="text">
+ <string>Ok</string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ </widget>
</item>
</layout>
</item>
diff --git a/Swift/QtUI/QtJoinMUCWindow.cpp b/Swift/QtUI/QtJoinMUCWindow.cpp
new file mode 100644
index 0000000..55b285b
--- /dev/null
+++ b/Swift/QtUI/QtJoinMUCWindow.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include "QtJoinMUCWindow.h"
+#include "QtSwiftUtil.h"
+
+namespace Swift {
+
+QtJoinMUCWindow::QtJoinMUCWindow() {
+ ui.setupUi(this);
+ connect(ui.room, SIGNAL(returnPressed()), this, SLOT(handleJoin()));
+ connect(ui.searchButton, SIGNAL(clicked()), this, SLOT(handleSearch()));
+ connect(ui.joinButton, SIGNAL(clicked()), this, SLOT(handleJoin()));
+}
+
+void QtJoinMUCWindow::handleJoin() {
+ if (ui.room->text().isEmpty()) {
+ // TODO: Error
+ return;
+ }
+ if (ui.nickName->text().isEmpty()) {
+ // TODO: Error
+ return;
+ }
+
+ lastSetNick = Q2PSTRING(ui.nickName->text());
+ JID room(Q2PSTRING(ui.room->text()));
+ onJoinMUC(room, lastSetNick, ui.joinAutomatically->isChecked());
+ hide();
+}
+
+void QtJoinMUCWindow::handleSearch() {
+ onSearchMUC();
+}
+
+void QtJoinMUCWindow::setNick(const String& nick) {
+ ui.nickName->setText(P2QSTRING(nick));
+ lastSetNick = nick;
+}
+
+void QtJoinMUCWindow::setMUC(const String& nick) {
+ ui.room->setText(P2QSTRING(nick));
+}
+
+void QtJoinMUCWindow::show() {
+ QWidget::show();
+ QWidget::activateWindow();
+}
+
+}
diff --git a/Swift/QtUI/QtJoinMUCWindow.h b/Swift/QtUI/QtJoinMUCWindow.h
new file mode 100644
index 0000000..2d12319
--- /dev/null
+++ b/Swift/QtUI/QtJoinMUCWindow.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/String.h>
+#include <Swift/Controllers/UIInterfaces/JoinMUCWindow.h>
+#include <Swift/QtUI/ui_QtJoinMUCWindow.h>
+
+namespace Swift {
+ class QtJoinMUCWindow : public QWidget, public JoinMUCWindow {
+ Q_OBJECT
+ public:
+ QtJoinMUCWindow();
+
+ virtual void setNick(const String& nick);
+ virtual void setMUC(const String& nick);
+
+ virtual void show();
+
+ private slots:
+ void handleJoin();
+ void handleSearch();
+
+ private:
+ Ui::QtJoinMUCWindow ui;
+ String lastSetNick;
+ };
+}
diff --git a/Swift/QtUI/QtJoinMUCWindow.ui b/Swift/QtUI/QtJoinMUCWindow.ui
new file mode 100644
index 0000000..2f3608a
--- /dev/null
+++ b/Swift/QtUI/QtJoinMUCWindow.ui
@@ -0,0 +1,116 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>QtJoinMUCWindow</class>
+ <widget class="QWidget" name="QtJoinMUCWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>398</width>
+ <height>172</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="windowTitle">
+ <string>Join Room</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>Room:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QToolButton" name="searchButton">
+ <property name="text">
+ <string>Search ...</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>Nickname:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" colspan="2">
+ <widget class="QLineEdit" name="nickName"/>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="room">
+ <property name="text">
+ <string/>
+ </property>
+ <property name="placeholderText">
+ <string>swift@rooms.swift.im</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>36</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="joinAutomatically">
+ <property name="text">
+ <string>Join automatically in future</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="joinButton">
+ <property name="text">
+ <string>Join Room</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <tabstops>
+ <tabstop>room</tabstop>
+ <tabstop>nickName</tabstop>
+ <tabstop>joinAutomatically</tabstop>
+ <tabstop>joinButton</tabstop>
+ <tabstop>searchButton</tabstop>
+ </tabstops>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/Swift/QtUI/QtMainWindow.cpp b/Swift/QtUI/QtMainWindow.cpp
index 21d1474..0411c0b 100644
--- a/Swift/QtUI/QtMainWindow.cpp
+++ b/Swift/QtUI/QtMainWindow.cpp
@@ -8,6 +8,7 @@
#include <boost/optional.hpp>
#include <boost/bind.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
#include <QBoxLayout>
#include <QComboBox>
@@ -24,9 +25,9 @@
#include "QtSwiftUtil.h"
#include "QtTabWidget.h"
#include "Roster/QtTreeWidget.h"
+#include "Swift/Controllers/UIEvents/RequestJoinMUCUIEvent.h"
#include "Swift/Controllers/UIEvents/RequestAddUserDialogUIEvent.h"
#include "Swift/Controllers/UIEvents/RequestChatWithUserDialogUIEvent.h"
-#include "Swift/Controllers/UIEvents/RequestMUCSearchUIEvent.h"
#include "Swift/Controllers/UIEvents/JoinMUCUIEvent.h"
#include "Swift/Controllers/UIEvents/ToggleShowOfflineUIEvent.h"
@@ -143,7 +144,7 @@ void QtMainWindow::handleSignOutAction() {
}
void QtMainWindow::handleJoinMUCAction() {
- uiEventStream_->send(boost::shared_ptr<UIEvent>(new RequestMUCSearchUIEvent()));
+ uiEventStream_->send(boost::make_shared<RequestJoinMUCUIEvent>());
}
void QtMainWindow::handleStatusChanged(StatusShow::Type showType, const QString &statusMessage) {
diff --git a/Swift/QtUI/QtUIFactory.cpp b/Swift/QtUI/QtUIFactory.cpp
index 25a508e..8cb9863 100644
--- a/Swift/QtUI/QtUIFactory.cpp
+++ b/Swift/QtUI/QtUIFactory.cpp
@@ -16,6 +16,7 @@
#include "QtSettingsProvider.h"
#include "QtMainWindow.h"
#include "QtChatWindow.h"
+#include "QtJoinMUCWindow.h"
#include "QtChatWindowFactory.h"
#include "QtSwiftUtil.h"
#include "MUCSearch/QtMUCSearchWindow.h"
@@ -70,8 +71,8 @@ ChatListWindow* QtUIFactory::createChatListWindow(UIEventStream*) {
return lastMainWindow->getChatListWindow();
}
-MUCSearchWindow* QtUIFactory::createMUCSearchWindow(UIEventStream* eventStream) {
- return new QtMUCSearchWindow(eventStream);
+MUCSearchWindow* QtUIFactory::createMUCSearchWindow() {
+ return new QtMUCSearchWindow();
}
ChatWindow* QtUIFactory::createChatWindow(const JID& contact, UIEventStream* eventStream) {
@@ -82,4 +83,8 @@ UserSearchWindow* QtUIFactory::createUserSearchWindow(UserSearchWindow::Type typ
return new QtUserSearchWindow(eventStream, type);
};
+JoinMUCWindow* QtUIFactory::createJoinMUCWindow() {
+ return new QtJoinMUCWindow();
+}
+
}
diff --git a/Swift/QtUI/QtUIFactory.h b/Swift/QtUI/QtUIFactory.h
index 6ddc316..4d80338 100644
--- a/Swift/QtUI/QtUIFactory.h
+++ b/Swift/QtUI/QtUIFactory.h
@@ -31,9 +31,10 @@ namespace Swift {
virtual LoginWindow* createLoginWindow(UIEventStream* eventStream);
virtual EventWindow* createEventWindow();
virtual ChatListWindow* createChatListWindow(UIEventStream*);
- virtual MUCSearchWindow* createMUCSearchWindow(UIEventStream* eventStream);
+ virtual MUCSearchWindow* createMUCSearchWindow();
virtual ChatWindow* createChatWindow(const JID &contact, UIEventStream* eventStream);
virtual UserSearchWindow* createUserSearchWindow(UserSearchWindow::Type type, UIEventStream* eventStream);
+ virtual JoinMUCWindow* createJoinMUCWindow();
private slots:
void handleLoginWindowGeometryChanged();
diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript
index c0730dc..b0072a6 100644
--- a/Swift/QtUI/SConscript
+++ b/Swift/QtUI/SConscript
@@ -92,6 +92,7 @@ sources = [
"SystemMessageSnippet.cpp",
"QtElidingLabel.cpp",
"QtLineEdit.cpp",
+ "QtJoinMUCWindow.cpp",
"Roster/RosterModel.cpp",
"Roster/QtTreeWidget.cpp",
# "Roster/QtTreeWidgetItem.cpp",
@@ -110,6 +111,7 @@ sources = [
"MUCSearch/QtMUCSearchWindow.cpp",
"MUCSearch/MUCSearchModel.cpp",
"MUCSearch/MUCSearchRoomItem.cpp",
+ "MUCSearch/MUCSearchEmptyItem.cpp",
"MUCSearch/MUCSearchDelegate.cpp",
"UserSearch/QtUserSearchWindow.cpp",
"UserSearch/UserSearchModel.cpp",
@@ -147,6 +149,7 @@ myenv.Uic4("UserSearch/QtUserSearchFieldsPage.ui")
myenv.Uic4("UserSearch/QtUserSearchResultsPage.ui")
myenv.Uic4("QtAddContactDialog.ui")
myenv.Uic4("QtBookmarkDetailWindow.ui")
+myenv.Uic4("QtJoinMUCWindow.ui")
myenv.Qrc("DefaultTheme.qrc")
myenv.Qrc("Swift.qrc")