diff options
author | hjk <qtc-committer@nokia.com> | 2011-02-07 15:17:30 +0100 |
---|---|---|
committer | hjk <qtc-committer@nokia.com> | 2011-02-07 15:17:30 +0100 |
commit | 3212e1152ceee303344b8ecd4d54372ba6ee0f98 (patch) | |
tree | f11089f05ce8d7e75eb52be621e4ac543e2e3a74 /src/libs/utils/fancymainwindow.cpp | |
parent | 7eb5a00f549549d8dd35c75ea4a69d246e0d78df (diff) | |
download | qt-creator-3212e1152ceee303344b8ecd4d54372ba6ee0f98.tar.gz |
fancymainwaindow: replace m_dockWidgetActiveState by dynamic property
Diffstat (limited to 'src/libs/utils/fancymainwindow.cpp')
-rw-r--r-- | src/libs/utils/fancymainwindow.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/libs/utils/fancymainwindow.cpp b/src/libs/utils/fancymainwindow.cpp index fa3c0b0475..d299999dc0 100644 --- a/src/libs/utils/fancymainwindow.cpp +++ b/src/libs/utils/fancymainwindow.cpp @@ -45,13 +45,13 @@ static const char lockedKeyC[] = "Locked"; static const char stateKeyC[] = "State"; static const int settingsVersion = 2; +static const char dockWidgetActiveState[] = "DockWidgetActiveState"; namespace Utils { struct FancyMainWindowPrivate { explicit FancyMainWindowPrivate(FancyMainWindow *q); - QMap<QDockWidget *, bool> m_dockWidgetActiveState; bool m_locked; bool m_handleDockVisibilityChanges; //todo @@ -107,7 +107,7 @@ QDockWidget *FancyMainWindow::addDockForWidget(QWidget *widget) this, SLOT(onDockVisibilityChange(bool))); connect(dockWidget, SIGNAL(topLevelChanged(bool)), this, SLOT(onTopLevelChanged())); - d->m_dockWidgetActiveState[dockWidget] = true; + dockWidget->setProperty(dockWidgetActiveState, true); updateDockWidget(dockWidget); return dockWidget; } @@ -139,10 +139,8 @@ void FancyMainWindow::onDockActionTriggered() void FancyMainWindow::onDockVisibilityChange(bool visible) { - if (!d->m_handleDockVisibilityChanges) - return; - QDockWidget *dockWidget = qobject_cast<QDockWidget *>(sender()); - d->m_dockWidgetActiveState[dockWidget] = visible; + if (d->m_handleDockVisibilityChanges) + sender()->setProperty(dockWidgetActiveState, visible); } void FancyMainWindow::onTopLevelChanged() @@ -154,8 +152,8 @@ void FancyMainWindow::setTrackingEnabled(bool enabled) { if (enabled) { d->m_handleDockVisibilityChanges = true; - foreach(QDockWidget *dockWidget, dockWidgets()) - d->m_dockWidgetActiveState[dockWidget] = dockWidget->isVisible(); + foreach (QDockWidget *dockWidget, dockWidgets()) + dockWidget->setProperty(dockWidgetActiveState, dockWidget->isVisible()); } else { d->m_handleDockVisibilityChanges = false; } @@ -191,9 +189,10 @@ void FancyMainWindow::contextMenuEvent(QContextMenuEvent *event) void FancyMainWindow::handleVisibilityChanged(bool visible) { d->m_handleDockVisibilityChanges = false; - foreach(QDockWidget *dockWidget, dockWidgets()) { + foreach (QDockWidget *dockWidget, dockWidgets()) { if (dockWidget->isFloating()) { - dockWidget->setVisible(visible && d->m_dockWidgetActiveState.value(dockWidget)); + dockWidget->setVisible(visible + && dockWidget->property(dockWidgetActiveState).toBool()); } } if (visible) @@ -224,9 +223,9 @@ QHash<QString, QVariant> FancyMainWindow::saveSettings() const QHash<QString, QVariant> settings; settings.insert(QLatin1String(stateKeyC), saveState(settingsVersion)); settings.insert(QLatin1String(lockedKeyC), d->m_locked); - foreach(QDockWidget *dockWidget, dockWidgets()) { + foreach (QDockWidget *dockWidget, dockWidgets()) { settings.insert(dockWidget->objectName(), - d->m_dockWidgetActiveState.value(dockWidget)); + dockWidget->property(dockWidgetActiveState)); } return settings; } @@ -238,8 +237,9 @@ void FancyMainWindow::restoreSettings(const QHash<QString, QVariant> &settings) restoreState(ba, settingsVersion); d->m_locked = settings.value(QLatin1String("Locked"), true).toBool(); d->m_toggleLockedAction->setChecked(d->m_locked); - foreach(QDockWidget *widget, dockWidgets()) { - d->m_dockWidgetActiveState[widget] = settings.value(widget->objectName(), false).toBool(); + foreach (QDockWidget *widget, dockWidgets()) { + widget->setProperty(dockWidgetActiveState, + settings.value(widget->objectName(), false)); } } |