summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Maudsley <richard.maudsley@isode.com>2014-03-24 09:53:37 (GMT)
committerSwift Review <review@swift.im>2014-04-02 11:45:22 (GMT)
commit1a35178bcad7c30e50a19e4017d021fb0485ccf0 (patch)
tree3d52cee147d6c3f70866a1b5a4c4ae942bb3d48b /Swift/QtUI/UserSearch/QtSuggestingJIDInput.cpp
parentc9275affd040ee1ca7c1d599b28df3b363bef888 (diff)
downloadswift-contrib-1a35178bcad7c30e50a19e4017d021fb0485ccf0.zip
swift-contrib-1a35178bcad7c30e50a19e4017d021fb0485ccf0.tar.bz2
Automatically moving user into the chat list when you select from the population drop-down.
Change-Id: I69b44e0e1dda2fa513d2d867ed10e5a8046ff0e9
Diffstat (limited to 'Swift/QtUI/UserSearch/QtSuggestingJIDInput.cpp')
-rw-r--r--Swift/QtUI/UserSearch/QtSuggestingJIDInput.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/Swift/QtUI/UserSearch/QtSuggestingJIDInput.cpp b/Swift/QtUI/UserSearch/QtSuggestingJIDInput.cpp
index ca65dca..de935d9 100644
--- a/Swift/QtUI/UserSearch/QtSuggestingJIDInput.cpp
+++ b/Swift/QtUI/UserSearch/QtSuggestingJIDInput.cpp
@@ -99,71 +99,72 @@ void QtSuggestingJIDInput::keyPressEvent(QKeyEvent* event) {
}
} else if (event->key() == Qt::Key_Return && treeViewPopup_->isVisible()) {
QModelIndex index = treeViewPopup_->currentIndex();
if (!contactListModel_->getList().empty() && index.isValid()) {
currentContact_ = &contactListModel_->getList()[index.row()];
setText(P2QSTRING(currentContact_->jid.toString()));
hidePopup();
clearFocus();
} else {
currentContact_ = NULL;
}
editingDone();
} else {
QLineEdit::keyPressEvent(event);
}
}
void QtSuggestingJIDInput::handleApplicationFocusChanged(QWidget* /*old*/, QWidget* /*now*/) {
/* Using the now argument gives use the wrong widget. This is part of the code needed
to prevent stealing of focus when opening a the suggestion window. */
QWidget* now = qApp->focusWidget();
if (!now || (now != treeViewPopup_ && now != this && !now->isAncestorOf(this) && !now->isAncestorOf(treeViewPopup_) && !this->isAncestorOf(now) && !treeViewPopup_->isAncestorOf(now))) {
hidePopup();
}
}
void QtSuggestingJIDInput::handleSettingsChanged(const std::string& setting) {
if (setting == QtUISettingConstants::COMPACT_ROSTER.getKey()) {
contactListDelegate_->setCompact(settings_->getSetting(QtUISettingConstants::COMPACT_ROSTER));
}
}
void QtSuggestingJIDInput::handleClicked(const QModelIndex& index) {
if (index.isValid()) {
currentContact_ = &contactListModel_->getList()[index.row()];
- setText(P2QSTRING(currentContact_->jid.toString()));
+ setText("");
+ onUserSelected(currentContact_->jid);
hidePopup();
}
}
void QtSuggestingJIDInput::positionPopup() {
QDesktopWidget* desktop = QApplication::desktop();
int screen = desktop->screenNumber(this);
QPoint point = mapToGlobal(QPoint(0, height()));
QRect geometry = desktop->availableGeometry(screen);
int x = point.x();
int y = point.y();
int width = this->width();
int height = 80;
int screenWidth = geometry.x() + geometry.width();
if (x + width > screenWidth) {
x = screenWidth - width;
}
height = treeViewPopup_->sizeHintForRow(0) * contactListModel_->rowCount();
height = height > 200 ? 200 : height;
int marginLeft;
int marginTop;
int marginRight;
int marginBottom;
treeViewPopup_->getContentsMargins(&marginLeft, &marginTop, &marginRight, &marginBottom);
height += marginTop + marginBottom;
width += marginLeft + marginRight;
treeViewPopup_->setGeometry(x, y, width, height);
treeViewPopup_->move(x, y);
treeViewPopup_->setMaximumWidth(width);
}