summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-06-10 16:49:49 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-06-10 16:49:49 (GMT)
commit7214d768dca85a6d43892169d5008898249dce73 (patch)
tree0f8b2820c9cb58f058263c78306987d934fec526 /Swift/QtUI/QtMainWindow.cpp
parentfd89da91d12b270d56f60544cad6f1ddc809af28 (diff)
downloadswift-7214d768dca85a6d43892169d5008898249dce73.zip
swift-7214d768dca85a6d43892169d5008898249dce73.tar.bz2
Moved UI/Qt -> Swift/QtUI.
Diffstat (limited to 'Swift/QtUI/QtMainWindow.cpp')
-rw-r--r--Swift/QtUI/QtMainWindow.cpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/Swift/QtUI/QtMainWindow.cpp b/Swift/QtUI/QtMainWindow.cpp
new file mode 100644
index 0000000..a9ffc51
--- /dev/null
+++ b/Swift/QtUI/QtMainWindow.cpp
@@ -0,0 +1,71 @@
+#include "QtMainWindow.h"
+
+#include "QtJoinMUCDialog.h"
+#include "QtSwiftUtil.h"
+#include "QtTreeWidgetFactory.h"
+#include "QtTreeWidget.h"
+#include "QtStatusWidget.h"
+
+#include <QBoxLayout>
+#include <QComboBox>
+#include <QLineEdit>
+#include <QListWidget>
+#include <QListWidgetItem>
+#include <QPushButton>
+#include <QMenuBar>
+#include <QToolBar>
+
+namespace Swift {
+
+QtMainWindow::QtMainWindow(QtTreeWidgetFactory *treeWidgetFactory) : QWidget() {
+ setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
+ QBoxLayout *mainLayout = new QBoxLayout(QBoxLayout::TopToBottom, this);
+ mainLayout->setContentsMargins(0,0,0,0);
+ mainLayout->setSpacing(0);
+ statusWidget_ = new QtStatusWidget(this);
+ connect(statusWidget_, SIGNAL(onChangeStatusRequest(StatusShow::Type, const QString&)), this, SLOT(handleStatusChanged(StatusShow::Type, const QString&)));
+ mainLayout->addWidget(statusWidget_);
+ treeWidget_ = dynamic_cast<QtTreeWidget*>(treeWidgetFactory->createTreeWidget());
+ mainLayout->addWidget(treeWidget_);
+
+ this->setLayout(mainLayout);
+
+ QMenu* viewMenu = new QMenu(tr("View"), this);
+ menus_.push_back(viewMenu);
+ QAction* showOfflineAction = new QAction("Show offline contacts", this);
+ showOfflineAction->setCheckable(true);
+ showOfflineAction->setChecked(false);
+ connect(showOfflineAction, SIGNAL(toggled(bool)), SLOT(handleShowOfflineToggled(bool)));
+ viewMenu->addAction(showOfflineAction);
+
+ QMenu* chatMenu = new QMenu(tr("Chat"), this);
+ menus_.push_back(chatMenu);
+ QAction* joinMUCAction = new QAction("Join chatroom", this);
+ connect(joinMUCAction, SIGNAL(triggered()), SLOT(handleJoinMUCAction()));
+ chatMenu->addAction(joinMUCAction);
+}
+
+TreeWidget* QtMainWindow::getTreeWidget() {
+ return treeWidget_;
+}
+
+void QtMainWindow::handleJoinMUCAction() {
+ QtJoinMUCDialog* joinMUC = new QtJoinMUCDialog("jabber@conference.jabber.org", "SwiftUser", this);
+ connect(joinMUC, SIGNAL(onJoinCommand(const JID&, const QString&)), SLOT(handleJoinMUCDialogComplete(const JID&, const QString&)));
+ joinMUC->show();
+}
+
+void QtMainWindow::handleJoinMUCDialogComplete(const JID& muc, const QString& nick) {
+ onJoinMUCRequest(muc, Q2PSTRING(nick));
+}
+
+void QtMainWindow::handleStatusChanged(StatusShow::Type showType, const QString &statusMessage) {
+ onChangeStatusRequest(showType, Q2PSTRING(statusMessage));
+}
+
+void QtMainWindow::handleShowOfflineToggled(bool state) {
+ onShowOfflineToggled(state);
+}
+
+}
+