summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-05-24 16:06:22 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-05-24 16:06:22 (GMT)
commit933d3ab7b34500c8edb927505d831fe439ca4253 (patch)
tree06a5d3f6bdb60b7f6835e1f73f635dc6ccb01dac /Swift
parent10534d5b942e7ef1e2f8e6900fb5b17411111b06 (diff)
downloadswift-933d3ab7b34500c8edb927505d831fe439ca4253.zip
swift-933d3ab7b34500c8edb927505d831fe439ca4253.tar.bz2
Dismiss the status editing when the edit loses focus.
Resolves: #358 Resolves: #362
Diffstat (limited to 'Swift')
-rw-r--r--Swift/QtUI/QtStatusWidget.cpp15
-rw-r--r--Swift/QtUI/QtStatusWidget.h1
2 files changed, 15 insertions, 1 deletions
diff --git a/Swift/QtUI/QtStatusWidget.cpp b/Swift/QtUI/QtStatusWidget.cpp
index 28df59c..6aeec4a 100644
--- a/Swift/QtUI/QtStatusWidget.cpp
+++ b/Swift/QtUI/QtStatusWidget.cpp
@@ -74,9 +74,13 @@ QtStatusWidget::QtStatusWidget(QWidget *parent) : QWidget(parent), editCursor_(Q
menu_ = new QListWidget();
menu_->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint );
- menu_->setAlternatingRowColors(true);
+ menu_->setAlternatingRowColors(true);
+ menu_->setFocusProxy(statusEdit_);
connect(menu_, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(handleItemClicked(QListWidgetItem*)));
+
+ connect(qApp, SIGNAL(focusChanged(QWidget*, QWidget*)), this, SLOT(handleApplicationFocusChanged(QWidget*, QWidget*)));
+
viewMode();
}
@@ -84,6 +88,15 @@ QtStatusWidget::~QtStatusWidget() {
delete menu_;
}
+void QtStatusWidget::handleApplicationFocusChanged(QWidget* /*old*/, QWidget* now) {
+ if (stack_->currentIndex() == 0) {
+ return;
+ }
+ if (now != menu_ && now != statusEdit_) {
+ handleEditCancelled();
+ }
+}
+
void QtStatusWidget::mousePressEvent(QMouseEvent*) {
handleClicked();
}
diff --git a/Swift/QtUI/QtStatusWidget.h b/Swift/QtUI/QtStatusWidget.h
index 84994d8..4e6aa20 100644
--- a/Swift/QtUI/QtStatusWidget.h
+++ b/Swift/QtUI/QtStatusWidget.h
@@ -37,6 +37,7 @@ namespace Swift {
void handleClicked();
void handleEditComplete();
void handleEditCancelled();
+ void handleApplicationFocusChanged(QWidget* old, QWidget* now);
protected slots:
virtual void mousePressEvent(QMouseEvent* event);
void handleItemClicked(QListWidgetItem* item);