summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-05-24 21:21:46 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-05-24 21:21:46 (GMT)
commit253bcd613e1935c5f93df581e3499e7d3f787208 (patch)
tree76b2394b3183aae14dacd249f8e804c709c21448 /Swift/QtUI
parent6dffe5cf7d64fc134f4db81362404949da9c56c1 (diff)
downloadswift-253bcd613e1935c5f93df581e3499e7d3f787208.zip
swift-253bcd613e1935c5f93df581e3499e7d3f787208.tar.bz2
Allow setting status messages again.
This is not a nice solution to an unpleasant problem - Qt is telling us we've lost focus, so we cancel ... while we're in the middle of completing a successful status set. So we need to keep track and make sure we don't clear out the status on cancel if we're also accepting.
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/QtStatusWidget.cpp13
-rw-r--r--Swift/QtUI/QtStatusWidget.h2
2 files changed, 13 insertions, 2 deletions
diff --git a/Swift/QtUI/QtStatusWidget.cpp b/Swift/QtUI/QtStatusWidget.cpp
index e909f5c..ab2e854 100644
--- a/Swift/QtUI/QtStatusWidget.cpp
+++ b/Swift/QtUI/QtStatusWidget.cpp
@@ -90,7 +90,7 @@ QtStatusWidget::~QtStatusWidget() {
}
void QtStatusWidget::handleApplicationFocusChanged(QWidget* /*old*/, QWidget* now) {
- if (stack_->currentIndex() == 0) {
+ if (!editing_ || stack_->currentIndex() == 0) {
return;
}
if (!now || (now != menu_ && now != statusEdit_ && !now->isAncestorOf(statusEdit_) && !now->isAncestorOf(menu_) && !statusEdit_->isAncestorOf(now) && !menu_->isAncestorOf(now))) {
@@ -106,7 +106,11 @@ void QtStatusWidget::mousePressEvent(QMouseEvent*) {
}
void QtStatusWidget::generateList() {
+ if (!editing_) {
+ return;
+ }
QString text = statusEdit_->text();
+ newStatusText_ = text;
menu_->clear();
foreach (StatusShow::Type type, icons_.keys()) {
QListWidgetItem* item = new QListWidgetItem(text, menu_);
@@ -117,6 +121,7 @@ void QtStatusWidget::generateList() {
void QtStatusWidget::handleClicked() {
+ editing_ = true;
QPoint point = mapToGlobal(QPoint(0, height()));
int x = point.x();
int y = point.y();
@@ -143,17 +148,20 @@ void QtStatusWidget::handleClicked() {
}
void QtStatusWidget::viewMode() {
+ editing_ = false;
menu_->hide();
stack_->setCurrentIndex(0);
}
void QtStatusWidget::handleEditComplete() {
- statusText_ = statusEdit_->text();
+ editing_ = false;
+ statusText_ = newStatusText_;
viewMode();
emit onChangeStatusRequest(selectedStatusType_, statusText_);
}
void QtStatusWidget::handleEditCancelled() {
+ editing_ = false;
setStatusText(statusText_);
viewMode();
}
@@ -163,6 +171,7 @@ StatusShow::Type QtStatusWidget::getSelectedStatusShow() {
}
void QtStatusWidget::handleItemClicked(QListWidgetItem* item) {
+ editing_ = false;
selectedStatusType_ = (StatusShow::Type)(item->data(Qt::UserRole).toInt());
handleEditComplete();
}
diff --git a/Swift/QtUI/QtStatusWidget.h b/Swift/QtUI/QtStatusWidget.h
index ef8b397..111bc84 100644
--- a/Swift/QtUI/QtStatusWidget.h
+++ b/Swift/QtUI/QtStatusWidget.h
@@ -48,12 +48,14 @@ namespace Swift {
QLabel* statusTextLabel_;
QtLineEdit* statusEdit_;
QString statusText_;
+ QString newStatusText_;
QMap<StatusShow::Type, QIcon> icons_;
StatusShow::Type selectedStatusType_;
bool isClicking_;
QListWidget* menu_;
QCursor editCursor_;
QCursor viewCursor_;
+ bool editing_;
};
}