summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-02-23 12:09:55 (GMT)
committerTobias Markmann <tm@ayena.de>2015-02-23 12:09:55 (GMT)
commite963c5e939f4e1b7cd8f8d653ec2d1cadbec4a8d (patch)
treeec2c5b9faa0e6f9c647f11722c0865f8b4bb1dd8
parent8718d29202d5df23cd979055b8be8a2d28d82301 (diff)
downloadswift-e963c5e939f4e1b7cd8f8d653ec2d1cadbec4a8d.zip
swift-e963c5e939f4e1b7cd8f8d653ec2d1cadbec4a8d.tar.bz2
Fix chat window title showing wrong chat titleswift-3.0beta1
Setup an application wide focus handler which updates the title if a focus change to a QtTabWidget happened. Test-Information: Tested on OS X 10.9.5 with Qt 5.4.0. Change-Id: Ib2e2f4c4a93deddb286350bdef685eb7aee504c9
-rw-r--r--Swift/QtUI/QtChatTabs.cpp5
-rw-r--r--Swift/QtUI/QtChatTabs.h1
-rw-r--r--Swift/QtUI/Trellis/QtDynamicGridLayout.cpp14
-rw-r--r--Swift/QtUI/Trellis/QtDynamicGridLayout.h4
4 files changed, 23 insertions, 1 deletions
diff --git a/Swift/QtUI/QtChatTabs.cpp b/Swift/QtUI/QtChatTabs.cpp
index 60ffbea..e869028 100644
--- a/Swift/QtUI/QtChatTabs.cpp
+++ b/Swift/QtUI/QtChatTabs.cpp
@@ -37,12 +37,13 @@ QtChatTabs::QtChatTabs(bool singleWindow, SettingsProvider* settingsProvider, bo
setWindowIcon(QIcon(":/logo-chat-16.png"));
#else
setAttribute(Qt::WA_ShowWithoutActivating);
#endif
dynamicGrid_ = new QtDynamicGridLayout(this, trellisMode);
connect(dynamicGrid_, SIGNAL(tabCloseRequested(int)), this, SLOT(handleTabCloseRequested(int)));
+ connect(dynamicGrid_, SIGNAL(onCurrentIndexChanged(int)), this, SLOT(handleCurrentTabIndexChanged(int)));
QVBoxLayout *layout = new QVBoxLayout;
layout->setSpacing(0);
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(dynamicGrid_);
setLayout(layout);
@@ -169,12 +170,16 @@ void QtChatTabs::handleWidgetShown() {
return;
}
addTab(widget);
show();
}
+void QtChatTabs::handleCurrentTabIndexChanged(int newIndex) {
+ handleTabTitleUpdated(dynamicGrid_->widget(newIndex));
+}
+
void QtChatTabs::handleWantsToActivate() {
QtTabbable* widget = qobject_cast<QtTabbable*>(sender());
Q_ASSERT(widget);
//Un-minimize and bring to front.
setWindowState(windowState() & ~Qt::WindowMinimized);
setWindowState(windowState() | Qt::WindowActive);
diff --git a/Swift/QtUI/QtChatTabs.h b/Swift/QtUI/QtChatTabs.h
index 04e9eca..bee03ec 100644
--- a/Swift/QtUI/QtChatTabs.h
+++ b/Swift/QtUI/QtChatTabs.h
@@ -39,12 +39,13 @@ namespace Swift {
protected slots:
void closeEvent(QCloseEvent* event);
void resizeEvent(QResizeEvent* event);
void moveEvent(QMoveEvent* event);
private slots:
+ void handleCurrentTabIndexChanged(int newIndex);
void handleTabClosing();
void handleTabTitleUpdated();
void handleTabTitleUpdated(QWidget* widget);
void handleTabCloseRequested(int index);
void handleWidgetShown();
void handleWantsToActivate();
diff --git a/Swift/QtUI/Trellis/QtDynamicGridLayout.cpp b/Swift/QtUI/Trellis/QtDynamicGridLayout.cpp
index e0bfa33..cc3208b 100644
--- a/Swift/QtUI/Trellis/QtDynamicGridLayout.cpp
+++ b/Swift/QtUI/Trellis/QtDynamicGridLayout.cpp
@@ -5,12 +5,14 @@
*/
#include <Swift/QtUI/Trellis/QtDynamicGridLayout.h>
#include <cassert>
+#include <QApplication>
+#include <QEvent>
#include <QLayoutItem>
#include <QGridLayout>
#include <QtDebug>
#include <Swift/QtUI/QtSwiftUtil.h>
#include <Swift/QtUI/QtTabbable.h>
@@ -20,12 +22,13 @@
namespace Swift {
QtDynamicGridLayout::QtDynamicGridLayout(QWidget* parent, bool enableDND) : QWidget(parent), dndEnabled_(enableDND) {
gridLayout_ = new QGridLayout(this);
setContentsMargins(0,0,0,0);
setDimensions(QSize(1,1));
+ connect(qApp, SIGNAL(focusChanged(QWidget*, QWidget*)), this, SLOT(handleApplicationFocusChanged(QWidget*,QWidget*)));
}
QtDynamicGridLayout::~QtDynamicGridLayout() {
}
int QtDynamicGridLayout::addTab(QtTabbable* tab, const QString& title) {
@@ -100,12 +103,23 @@ int QtDynamicGridLayout::indexOf(const QWidget* widget) const {
}
}
}
return -1;
}
+void QtDynamicGridLayout::handleApplicationFocusChanged(QWidget*, QWidget* newFocus) {
+ if (newFocus) {
+ if (isAncestorOf(newFocus)) {
+ QtTabbable *newTab = dynamic_cast<QtTabbable*>(newFocus->parentWidget());
+ if (newTab) {
+ onCurrentIndexChanged(currentIndex());
+ }
+ }
+ }
+}
+
int QtDynamicGridLayout::currentIndex() const {
return indexOf(currentWidget());
}
void QtDynamicGridLayout::setCurrentIndex(int index) {
int tabIndex = -1;
diff --git a/Swift/QtUI/Trellis/QtDynamicGridLayout.h b/Swift/QtUI/Trellis/QtDynamicGridLayout.h
index 3b798bd..616ee5e 100644
--- a/Swift/QtUI/Trellis/QtDynamicGridLayout.h
+++ b/Swift/QtUI/Trellis/QtDynamicGridLayout.h
@@ -1,8 +1,8 @@
/*
- * Copyright (c) 2014 Isode Limited.
+ * Copyright (c) 2014-2015 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
@@ -44,12 +44,13 @@ namespace Swift {
QHash<QString, QPoint> getTabPositions() const;
void setTabPositions(const QHash<QString, QPoint> positions);
signals:
void tabCloseRequested(int index);
+ void onCurrentIndexChanged(int newIndex);
public slots:
void setDimensions(const QSize& dim);
// Tab Management
void moveCurrentTabRight();
@@ -59,12 +60,13 @@ namespace Swift {
void updateTabPositions();
private slots:
void handleTabCloseRequested(int index);
void handleTabCurrentChanged(int index);
+ void handleApplicationFocusChanged(QWidget* oldFocus, QWidget* newFocus);
private:
void moveTab(QtTabWidget* tabWidget, int oldIndex, int newIndex);
QtTabWidget* createDNDTabWidget(QWidget* parent);
private: