summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2009-11-26 09:47:08 (GMT)
committerKevin Smith <git@kismith.co.uk>2009-11-26 09:47:08 (GMT)
commit7b1df614ebfdbdb7d12c1d5618a74b8cdc308133 (patch)
tree22e661f79ce1ce01321a2534d75c8cda162814b1
parent5498152b4c9537742019dd45db72c88d7e3dc70c (diff)
downloadswift-7b1df614ebfdbdb7d12c1d5618a74b8cdc308133.zip
swift-7b1df614ebfdbdb7d12c1d5618a74b8cdc308133.tar.bz2
Make sure window title's update on tab close.
This is a speculative fix for a problem that I couldn't reproduce but was hitting Steve reproducably. This should ensure that whenever a tab is closed, it'll cause the title to be updated.
-rw-r--r--Swift/QtUI/QtChatTabs.cpp5
-rw-r--r--Swift/QtUI/QtChatTabs.h1
2 files changed, 6 insertions, 0 deletions
diff --git a/Swift/QtUI/QtChatTabs.cpp b/Swift/QtUI/QtChatTabs.cpp
index e30478c..f9a42a4 100644
--- a/Swift/QtUI/QtChatTabs.cpp
+++ b/Swift/QtUI/QtChatTabs.cpp
@@ -35,79 +35,84 @@ void QtChatTabs::closeEvent(QCloseEvent* event) {
event->accept();
}
void QtChatTabs::addTab(QtTabbable* tab) {
tabs_->addTab(tab, tab->windowTitle());
connect(tab, SIGNAL(titleUpdated()), this, SLOT(handleTabTitleUpdated()));
connect(tab, SIGNAL(windowClosing()), this, SLOT(handleTabClosing()));
connect(tab, SIGNAL(windowOpening()), this, SLOT(handleWidgetShown()));
connect(tab, SIGNAL(wantsToActivate()), this, SLOT(handleWantsToActivate()));
}
void QtChatTabs::handleWidgetShown() {
QtTabbable* widget = qobject_cast<QtTabbable*>(sender());
if (!widget) {
return;
}
if (tabs_->indexOf(widget) >= 0) {
return;
}
addTab(widget);
show();
}
void QtChatTabs::handleWantsToActivate() {
QtTabbable* widget = qobject_cast<QtTabbable*>(sender());
Q_ASSERT(widget);
Q_ASSERT(tabs_->indexOf(widget) >= 0);
//Un-minimize and bring to front.
setWindowState(windowState() & ~Qt::WindowMinimized);
setWindowState(windowState() | Qt::WindowActive);
tabs_->setCurrentWidget(widget);
widget->setFocus();
activateWindow();
}
void QtChatTabs::handleTabClosing() {
QWidget* widget = qobject_cast<QWidget*>(sender());
if (!widget) {
return;
}
int index = tabs_->indexOf(widget);
if (index < 0) {
return;
}
tabs_->removeTab(index);
if (tabs_->count() == 0) {
hide();
}
+ handleTabTitleUpdated(tabs_->currentWidget());
}
void QtChatTabs::handleTabCloseRequested(int index) {
QWidget* widget = tabs_->widget(index);
widget->close();
}
void QtChatTabs::handleTabTitleUpdated() {
QWidget* widget = qobject_cast<QWidget*>(sender());
+ handleTabTitleUpdated(widget);
+}
+
+void QtChatTabs::handleTabTitleUpdated(QWidget* widget) {
if (!widget) {
return;
}
int index = tabs_->indexOf(widget);
if (index < 0) {
return;
}
tabs_->setTabText(index, widget->windowTitle());
if (widget == tabs_->currentWidget()) {
setWindowTitle(widget->windowTitle());
}
}
void QtChatTabs::resizeEvent(QResizeEvent*) {
emit geometryChanged();
}
void QtChatTabs::moveEvent(QMoveEvent*) {
emit geometryChanged();
}
}
diff --git a/Swift/QtUI/QtChatTabs.h b/Swift/QtUI/QtChatTabs.h
index feb8ebc..c51b88d 100644
--- a/Swift/QtUI/QtChatTabs.h
+++ b/Swift/QtUI/QtChatTabs.h
@@ -1,34 +1,35 @@
#pragma once
#include "QtTabbable.h"
#include <QWidget>
#include <QRect>
class QTabWidget;
namespace Swift {
class QtChatTabs : public QWidget {
Q_OBJECT
public:
QtChatTabs();
void addTab(QtTabbable* tab);
void minimise();
signals:
void geometryChanged();
protected slots:
void closeEvent(QCloseEvent* event);
void resizeEvent(QResizeEvent* event);
void moveEvent(QMoveEvent* event);
private slots:
void handleTabClosing();
void handleTabTitleUpdated();
+ void handleTabTitleUpdated(QWidget* widget);
void handleTabCloseRequested(int index);
void handleWidgetShown();
void handleWantsToActivate();
private:
QTabWidget* tabs_;
};
}