diff options
| author | Richard Maudsley <richard.maudsley@isode.com> | 2014-05-19 11:18:52 (GMT) | 
|---|---|---|
| committer | Swift Review <review@swift.im> | 2014-07-09 10:19:41 (GMT) | 
| commit | 05d9e618e4c756e50b633448f0546614a645a13d (patch) | |
| tree | 5a05e5c2c939c240a58c4aa468af0806a7ed8822 /Swift/QtUI/QtMainWindow.cpp | |
| parent | acac7962ba04c083377f62f4265ecc754176f74e (diff) | |
| download | swift-contrib-05d9e618e4c756e50b633448f0546614a645a13d.zip swift-contrib-05d9e618e4c756e50b633448f0546614a645a13d.tar.bz2 | |
Add dialog to send AdHoc's to target specific JID's. Fix multi-item Form rendering.
Test-Information:
Use AdHoc bot that presents a multi-item form and check that it is rendered correctly. Check that entering invalid JID and node parameters in the dialog do not cause malfunction. Check that canceling the JID prompt closes the dialog without sending any server commands.
Change-Id: I10e6f4c7eccd1a35c8c885d548994b5f57fdbf66
Diffstat (limited to 'Swift/QtUI/QtMainWindow.cpp')
| -rw-r--r-- | Swift/QtUI/QtMainWindow.cpp | 12 | 
1 files changed, 11 insertions, 1 deletions
| diff --git a/Swift/QtUI/QtMainWindow.cpp b/Swift/QtUI/QtMainWindow.cpp index 31a8234..1db8c77 100644 --- a/Swift/QtUI/QtMainWindow.cpp +++ b/Swift/QtUI/QtMainWindow.cpp @@ -8,81 +8,82 @@  #include <boost/optional.hpp>  #include <boost/bind.hpp>  #include <boost/smart_ptr/make_shared.hpp>  #include <QBoxLayout>  #include <QComboBox>  #include <QLineEdit>  #include <QListWidget>  #include <QListWidgetItem>  #include <QPushButton>  #include <QMenuBar>  #include <QToolBar>  #include <QAction>  #include <QTabWidget>  #include <Swiften/Base/Platform.h>  #include <Swift/Controllers/UIEvents/RequestJoinMUCUIEvent.h>  #include <Swift/Controllers/UIEvents/RequestHistoryUIEvent.h>  #include <Swift/Controllers/UIEvents/RequestAddUserDialogUIEvent.h>  #include <Swift/Controllers/UIEvents/RequestChatWithUserDialogUIEvent.h>  #include <Swift/Controllers/UIEvents/RequestProfileEditorUIEvent.h>  #include <Swift/Controllers/UIEvents/JoinMUCUIEvent.h>  #include <Swift/Controllers/UIEvents/RequestAdHocUIEvent.h>  #include <Swift/Controllers/UIEvents/RequestBlockListDialogUIEvent.h>  #include <Swift/Controllers/SettingConstants.h>  #include <Swift/QtUI/Roster/QtFilterWidget.h>  #include <Swift/QtUI/QtSwiftUtil.h>  #include <Swift/QtUI/QtTabWidget.h>  #include <Swift/QtUI/QtSettingsProvider.h>  #include <Swift/QtUI/QtLoginWindow.h>  #include <Swift/QtUI/Roster/QtRosterWidget.h>  #include <Swift/QtUI/QtUISettingConstants.h> +#include <Swift/QtUI/QtAdHocCommandWithJIDWindow.h>  #if defined(SWIFTEN_PLATFORM_MACOSX)  #include <Swift/QtUI/CocoaUIHelpers.h>  #elif defined(SWIFTEN_PLATFORM_WINDOWS)  #include <Swift/QtUI/WinUIHelpers.h>  #else  #include <Swift/QtUI/QtCertificateViewerDialog.h>  #endif  namespace Swift { -QtMainWindow::QtMainWindow(SettingsProvider* settings, UIEventStream* uiEventStream, QtLoginWindow::QtMenus loginMenus, StatusCache* statusCache, bool emoticonsExist) : QWidget(), MainWindow(false), loginMenus_(loginMenus) { +QtMainWindow::QtMainWindow(SettingsProvider* settings, UIEventStream* uiEventStream, QtLoginWindow::QtMenus loginMenus, StatusCache* statusCache, bool emoticonsExist, bool enableAdHocCommandOnJID) : QWidget(), MainWindow(false), loginMenus_(loginMenus) {  	uiEventStream_ = uiEventStream;  	settings_ = settings;  	setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));  	QBoxLayout *mainLayout = new QBoxLayout(QBoxLayout::TopToBottom, this);  	mainLayout->setContentsMargins(0,0,0,0);  	mainLayout->setSpacing(0);  	meView_ = new QtRosterHeader(settings, statusCache, this);  	mainLayout->addWidget(meView_);  	connect(meView_, SIGNAL(onChangeStatusRequest(StatusShow::Type, const QString&)), this, SLOT(handleStatusChanged(StatusShow::Type, const QString&)));  	connect(meView_, SIGNAL(onEditProfileRequest()), this, SLOT(handleEditProfileRequest()));  	connect(meView_, SIGNAL(onShowCertificateInfo()), this, SLOT(handleShowCertificateInfo()));  	tabs_ = new QtTabWidget(this);  #if QT_VERSION >= 0x040500  	tabs_->setDocumentMode(true);  #endif  	tabs_->setTabPosition(QTabWidget::South);  	mainLayout->addWidget(tabs_);  	contactsTabWidget_ = new QWidget(this);  	contactsTabWidget_->setContentsMargins(0, 0, 0, 0);  	QBoxLayout *contactTabLayout = new QBoxLayout(QBoxLayout::TopToBottom, contactsTabWidget_);  	contactsTabWidget_->setLayout(contactTabLayout);  	contactTabLayout->setSpacing(0);  	contactTabLayout->setContentsMargins(0, 0, 0, 0);  	treeWidget_ = new QtRosterWidget(uiEventStream_, settings_, this);  	contactTabLayout->addWidget(treeWidget_);  	new QtFilterWidget(this, treeWidget_, uiEventStream_, contactTabLayout);  	tabs_->addTab(contactsTabWidget_, tr("&Contacts"));  	eventWindow_ = new QtEventWindow(uiEventStream_);  	connect(eventWindow_, SIGNAL(onNewEventCountUpdated(int)), this, SLOT(handleEventCountUpdated(int))); @@ -143,70 +144,75 @@ QtMainWindow::QtMainWindow(SettingsProvider* settings, UIEventStream* uiEventStr  	//compactRosterAction_->setChecked(false);  	//connect(compactRosterAction_, SIGNAL(toggled(bool)), uiPreferences_, SLOT(setCompactRosters(bool)));  	//viewMenu->addAction(compactRosterAction_);  	QMenu* actionsMenu = new QMenu(tr("&Actions"), this);  	menus_.push_back(actionsMenu);  	QAction* editProfileAction = new QAction(tr("Edit &Profile…"), this);  	connect(editProfileAction, SIGNAL(triggered()), SLOT(handleEditProfileAction()));  	actionsMenu->addAction(editProfileAction);  	QAction* joinMUCAction = new QAction(tr("Enter &Room…"), this);  	connect(joinMUCAction, SIGNAL(triggered()), SLOT(handleJoinMUCAction()));  	actionsMenu->addAction(joinMUCAction);  #ifdef SWIFT_EXPERIMENTAL_HISTORY  	QAction* viewLogsAction = new QAction(tr("&View History…"), this);  	connect(viewLogsAction, SIGNAL(triggered()), SLOT(handleViewLogsAction()));  	actionsMenu->addAction(viewLogsAction);  #endif  	openBlockingListEditor_ = new QAction(tr("Edit &Blocking List…"), this);  	connect(openBlockingListEditor_, SIGNAL(triggered()), SLOT(handleEditBlockingList()));  	actionsMenu->addAction(openBlockingListEditor_);  	openBlockingListEditor_->setVisible(false);  	addUserAction_ = new QAction(tr("&Add Contact…"), this);  	addUserAction_->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D));  	addUserAction_->setShortcutContext(Qt::ApplicationShortcut);  	connect(addUserAction_, SIGNAL(triggered(bool)), this, SLOT(handleAddUserActionTriggered(bool)));  	actionsMenu->addAction(addUserAction_);  	editUserAction_ = new QAction(tr("&Edit Selected Contact…"), this);  	connect(editUserAction_, SIGNAL(triggered(bool)), treeWidget_, SLOT(handleEditUserActionTriggered(bool)));  	actionsMenu->addAction(editUserAction_);  	editUserAction_->setEnabled(false);  	chatUserAction_ = new QAction(tr("Start &Chat…"), this);  	chatUserAction_->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_N));  	chatUserAction_->setShortcutContext(Qt::ApplicationShortcut);  	connect(chatUserAction_, SIGNAL(triggered(bool)), this, SLOT(handleChatUserActionTriggered(bool)));  	actionsMenu->addAction(chatUserAction_); +	if (enableAdHocCommandOnJID) { +		otherAdHocAction_ = new QAction(tr("Run Other Command"), this); +		connect(otherAdHocAction_, SIGNAL(triggered()), this, SLOT(handleOtherAdHocActionTriggered())); +		actionsMenu->addAction(otherAdHocAction_); +	}  	serverAdHocMenu_ = new QMenu(tr("Run Server Command"), this);  	actionsMenu->addMenu(serverAdHocMenu_);  	actionsMenu->addSeparator();  	QAction* signOutAction = new QAction(tr("&Sign Out"), this);  	connect(signOutAction, SIGNAL(triggered()), SLOT(handleSignOutAction()));  	actionsMenu->addAction(signOutAction);  	toggleRequestDeliveryReceipts_ = new QAction(tr("&Request Delivery Receipts"), this);  	toggleRequestDeliveryReceipts_->setCheckable(true);  	toggleRequestDeliveryReceipts_->setChecked(settings_->getSetting(SettingConstants::REQUEST_DELIVERYRECEIPTS));  	connect(toggleRequestDeliveryReceipts_, SIGNAL(toggled(bool)), SLOT(handleToggleRequestDeliveryReceipts(bool)));  	QList< QAction* > generalMenuActions = loginMenus_.generalMenu->actions();  	loginMenus_.generalMenu->insertAction(generalMenuActions.at(generalMenuActions.count()-2),toggleRequestDeliveryReceipts_);  	treeWidget_->onSomethingSelectedChanged.connect(boost::bind(&QAction::setEnabled, editUserAction_, _1));  	setAvailableAdHocCommands(std::vector<DiscoItems::Item>());  	QAction* adHocAction = new QAction(tr("Collecting commands..."), this);  	adHocAction->setEnabled(false);  	serverAdHocMenu_->addAction(adHocAction);  	serverAdHocCommandActions_.append(adHocAction);  	settings_->onSettingChanged.connect(boost::bind(&QtMainWindow::handleSettingChanged, this, _1));  }  QtMainWindow::~QtMainWindow() {  	settings_->onSettingChanged.disconnect(boost::bind(&QtMainWindow::handleSettingChanged, this, _1));  }  void QtMainWindow::handleTabChanged(int index) {  	settings_->storeSetting(QtUISettingConstants::CURRENT_ROSTER_TAB, index);  }  void QtMainWindow::handleToggleRequestDeliveryReceipts(bool enabled) { @@ -237,70 +243,74 @@ void QtMainWindow::handleEditProfileRequest() {  	uiEventStream_->send(boost::make_shared<RequestProfileEditorUIEvent>());  }  void QtMainWindow::handleEventCountUpdated(int count) {  	QColor eventTabColor = (count == 0) ? QColor() : QColor(255, 0, 0); // invalid resets to default  	int eventIndex = 2;  	tabs_->tabBar()->setTabTextColor(eventIndex, eventTabColor);  	QString text = tr("&Notices");  	if (count > 0) {  		text += QString(" (%1)").arg(count);  	}  	tabs_->setTabText(eventIndex, text);  }  void QtMainWindow::handleChatCountUpdated(int count) {  	QColor chatTabColor = (count == 0) ? QColor() : QColor(255, 0, 0); // invalid resets to default  	int chatIndex = 1;  	tabs_->tabBar()->setTabTextColor(chatIndex, chatTabColor);  	QString text = tr("&Chats");  	if (count > 0) {  		text += QString(" (%1)").arg(count);  	}  	tabs_->setTabText(chatIndex, text);  }  void QtMainWindow::handleAddUserActionTriggered(bool /*checked*/) {  	boost::shared_ptr<UIEvent> event(new RequestAddUserDialogUIEvent());  	uiEventStream_->send(event);  }  void QtMainWindow::handleChatUserActionTriggered(bool /*checked*/) {  	boost::shared_ptr<UIEvent> event(new RequestChatWithUserDialogUIEvent());  	uiEventStream_->send(event);  } +void QtMainWindow::handleOtherAdHocActionTriggered() { +	new QtAdHocCommandWithJIDWindow(uiEventStream_); +} +  void QtMainWindow::handleSignOutAction() {  	loginMenus_.generalMenu->removeAction(toggleRequestDeliveryReceipts_);  	onSignOutRequest();  }  void QtMainWindow::handleEditProfileAction() {  	uiEventStream_->send(boost::make_shared<RequestProfileEditorUIEvent>());  }  void QtMainWindow::handleJoinMUCAction() {  	uiEventStream_->send(boost::make_shared<RequestJoinMUCUIEvent>());  }  void QtMainWindow::handleViewLogsAction() {  	uiEventStream_->send(boost::make_shared<RequestHistoryUIEvent>());  }  void QtMainWindow::handleStatusChanged(StatusShow::Type showType, const QString &statusMessage) {  	onChangeStatusRequest(showType, Q2PSTRING(statusMessage));  }  void QtMainWindow::handleSettingChanged(const std::string& settingPath) {  	if (settingPath == SettingConstants::SHOW_OFFLINE.getKey()) {  		handleShowOfflineToggled(settings_->getSetting(SettingConstants::SHOW_OFFLINE));  	}  	if (settingPath == QtUISettingConstants::SHOW_EMOTICONS.getKey()) {  		handleShowEmoticonsToggled(settings_->getSetting(QtUISettingConstants::SHOW_EMOTICONS));  	}  	if (settingPath == SettingConstants::REQUEST_DELIVERYRECEIPTS.getKey()) {  		toggleRequestDeliveryReceipts_->setChecked(settings_->getSetting(SettingConstants::REQUEST_DELIVERYRECEIPTS));  	}  	if (settingPath == QtUISettingConstants::COMPACT_ROSTER.getKey()) {  		handleCompactRosterToggled(settings_->getSetting(QtUISettingConstants::COMPACT_ROSTER));  	}  } | 
 Swift
 Swift