summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2011-04-28 17:59:26 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-04-28 21:10:51 (GMT)
commite31f0e1f42b11eabfd02d5d5759aeef0c0ef72b6 (patch)
tree330e72ec7f27acca42334512c45d1a8e8681bacd
parent9a1e579654314d90154bd2782d1735323bf9596b (diff)
downloadswift-e31f0e1f42b11eabfd02d5d5759aeef0c0ef72b6.zip
swift-e31f0e1f42b11eabfd02d5d5759aeef0c0ef72b6.tar.bz2
Hiding widgets which aren't visible anyway to prevent them from redrawing.
License: This patch is BSD-licensed, see http://www.opensource.org/licenses/bsd-license.php
-rw-r--r--Swift/QtUI/QtChatTabs.cpp26
-rw-r--r--Swift/QtUI/QtChatTabs.h1
2 files changed, 27 insertions, 0 deletions
diff --git a/Swift/QtUI/QtChatTabs.cpp b/Swift/QtUI/QtChatTabs.cpp
index 249080b..9063001 100644
--- a/Swift/QtUI/QtChatTabs.cpp
+++ b/Swift/QtUI/QtChatTabs.cpp
@@ -39,6 +39,8 @@ QtChatTabs::QtChatTabs() : QWidget() {
#else
#warning Qt 4.5 or later is needed. Trying anyway, some things will be disabled.
#endif
+ connect(tabs_, SIGNAL(currentChanged(int)), this, SLOT(handleTabChange(int)), Qt::UniqueConnection);
+
QVBoxLayout *layout = new QVBoxLayout;
layout->setSpacing(0);
layout->setContentsMargins(0, 3, 0, 0);
@@ -64,6 +66,13 @@ void QtChatTabs::addTab(QtTabbable* tab) {
QSizePolicy policy = sizePolicy();
/* Chat windows like to grow - don't let them */
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+
+ /* Hide previous opened QtChatWindow, so it doesn't receive further QPaint events. */
+ QWidget* old = tabs_->currentWidget();
+ if (old) {
+ old->hide();
+ }
+
tabs_->addTab(tab, tab->windowTitle());
connect(tab, SIGNAL(titleUpdated()), this, SLOT(handleTabTitleUpdated()), Qt::UniqueConnection);
connect(tab, SIGNAL(countUpdated()), this, SLOT(handleTabTitleUpdated()), Qt::UniqueConnection);
@@ -252,6 +261,11 @@ void QtChatTabs::handleTabTitleUpdated(QWidget* widget) {
std::string current(Q2PSTRING(qobject_cast<QtTabbable*>(tabs_->currentWidget())->windowTitle()));
ChatMessageSummarizer summary;
setWindowTitle(summary.getSummary(current, unreads).c_str());
+
+ /* hide() QtChatWindow again, so it won't receive Paint events. */
+ if (widget != tabs_->currentWidget()) {
+ widget->hide();
+ }
}
void QtChatTabs::flash() {
@@ -260,6 +274,18 @@ void QtChatTabs::flash() {
#endif
}
+void QtChatTabs::handleTabChange(int index) {
+ if (index == -1) {
+ return;
+ }
+ /* hide() old tab, show() new tab */
+ QWidget* old_tab = tabs_->currentWidget();
+ old_tab->hide();
+
+ QWidget* new_tab = tabs_->widget(index);
+ new_tab->show();
+}
+
void QtChatTabs::resizeEvent(QResizeEvent*) {
emit geometryChanged();
}
diff --git a/Swift/QtUI/QtChatTabs.h b/Swift/QtUI/QtChatTabs.h
index 233c574..19a486c 100644
--- a/Swift/QtUI/QtChatTabs.h
+++ b/Swift/QtUI/QtChatTabs.h
@@ -39,6 +39,7 @@ namespace Swift {
void handleRequestedPreviousTab();
void handleRequestedNextTab();
void handleRequestedActiveTab();
+ void handleTabChange(int index);
void flash();
private: