From 1514e787b28ee09ea28d75828bf41049696fd5c7 Mon Sep 17 00:00:00 2001
From: Kevin Smith <git@kismith.co.uk>
Date: Fri, 1 Jun 2012 16:29:27 +0100
Subject: Fix tab order in invite window.

Resolves: #1128

diff --git a/Swift/QtUI/QtInviteToChatWindow.cpp b/Swift/QtUI/QtInviteToChatWindow.cpp
index 3b8f1fc..ce6dea0 100644
--- a/Swift/QtUI/QtInviteToChatWindow.cpp
+++ b/Swift/QtUI/QtInviteToChatWindow.cpp
@@ -32,18 +32,18 @@ QtInviteToChatWindow::QtInviteToChatWindow(QWidget* parent) : QDialog(parent) {
 	layout->addWidget(reasonLabel);
 	reason_ = new QLineEdit(this);
 	layout->addWidget(reason_);
-	addJIDLine();
 
 	connect(this, SIGNAL(accepted()), this, SLOT(handleAccepting()));
 	connect(this, SIGNAL(rejected()), this, SLOT(handleRejecting()));
 
 
-	QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
+	buttonBox_ = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
 
-	connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
-	connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+	connect(buttonBox_, SIGNAL(accepted()), this, SLOT(accept()));
+	connect(buttonBox_, SIGNAL(rejected()), this, SLOT(reject()));
 
-	layout->addWidget(buttonBox);
+	layout->addWidget(buttonBox_);
+	addJIDLine();
 
 	jids_[0]->setFocus();
 
@@ -86,9 +86,15 @@ void QtInviteToChatWindow::addJIDLine() {
 	QCompleter* completer = new QCompleter(&completions_, this);
 	completer->setCaseSensitivity(Qt::CaseInsensitive);
 	jid->setCompleter(completer);
-	jids_.push_back(jid);
 	jidsLayout_->addWidget(jid);
 	connect(jid, SIGNAL(textChanged(const QString&)), this, SLOT(handleJIDTextChanged()));
+	if (!jids_.empty()) {
+		setTabOrder(jids_.back(), jid);
+	}
+	jids_.push_back(jid);
+	setTabOrder(jid, reason_);
+	setTabOrder(reason_, buttonBox_);
+	//setTabOrder(buttonBox_, jids_[0]);
 }
 
 void QtInviteToChatWindow::handleJIDTextChanged() {
diff --git a/Swift/QtUI/QtInviteToChatWindow.h b/Swift/QtUI/QtInviteToChatWindow.h
index a0167db..dd8743a 100644
--- a/Swift/QtUI/QtInviteToChatWindow.h
+++ b/Swift/QtUI/QtInviteToChatWindow.h
@@ -13,6 +13,7 @@
 
 class QLineEdit;
 class QBoxLayout;
+class QDialogButtonBox;
 
 namespace Swift {
 	class QtInviteToChatWindow : public QDialog, public InviteToChatWindow {
@@ -36,6 +37,7 @@ namespace Swift {
 			QLineEdit* reason_;
 			QBoxLayout* jidsLayout_;
 			std::vector<QLineEdit*> jids_;
+			QDialogButtonBox* buttonBox_;
 	};
 }
 
-- 
cgit v0.10.2-6-g49f6