From f20841cad342623e05c9021c645d498aeadf9605 Mon Sep 17 00:00:00 2001
From: Erik Verbruggen <erik.verbruggen@nokia.com>
Date: Tue, 9 Feb 2010 16:01:47 +0100
Subject: [PATCH] Fixes for the QML designer settings page.

---
 src/plugins/qmldesigner/designersettings.cpp  | 10 ++++++++++
 src/plugins/qmldesigner/designersettings.h    |  3 +++
 src/plugins/qmldesigner/qmldesignerplugin.cpp |  2 ++
 src/plugins/qmldesigner/settingspage.cpp      |  6 +++++-
 src/plugins/qmldesigner/settingspage.ui       |  7 +++++++
 5 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/src/plugins/qmldesigner/designersettings.cpp b/src/plugins/qmldesigner/designersettings.cpp
index a059c3f449f..d1e52f9ce34 100644
--- a/src/plugins/qmldesigner/designersettings.cpp
+++ b/src/plugins/qmldesigner/designersettings.cpp
@@ -37,7 +37,13 @@ static const char *qmlGroup = "Qml";
 static const char *qmlDesignerGroup = "Designer";
 static const char *snapToGridKey = "SnapToGrid";
 static const char *showBoundingRectanglesKey = "ShowBoundingRectangles";
+static const char *onlyShowItemsWithContentsKey = "OnlyShowItemsWithContents";
 
+DesignerSettings::DesignerSettings()
+    : snapToGrid(false)
+    , showBoundingRectangles(false)
+    , onlyShowItemsWithContents(false)
+{}
 void DesignerSettings::fromSettings(QSettings *settings)
 {
     settings->beginGroup(QLatin1String(qmlGroup));
@@ -45,6 +51,8 @@ void DesignerSettings::fromSettings(QSettings *settings)
     snapToGrid = settings->value(QLatin1String(snapToGridKey), false).toBool();
     showBoundingRectangles = settings->value(
             QLatin1String(showBoundingRectanglesKey), false).toBool();
+    onlyShowItemsWithContents = settings->value(
+            QLatin1String(onlyShowItemsWithContentsKey), false).toBool();
     settings->endGroup();
     settings->endGroup();
 }
@@ -56,6 +64,8 @@ void DesignerSettings::toSettings(QSettings *settings) const
     settings->setValue(QLatin1String(snapToGridKey), snapToGrid);
     settings->setValue(QLatin1String(showBoundingRectanglesKey),
                        showBoundingRectangles);
+    settings->setValue(QLatin1String(onlyShowItemsWithContentsKey),
+                       onlyShowItemsWithContents);
     settings->endGroup();
     settings->endGroup();
 }
diff --git a/src/plugins/qmldesigner/designersettings.h b/src/plugins/qmldesigner/designersettings.h
index db0829db034..02a0296e118 100644
--- a/src/plugins/qmldesigner/designersettings.h
+++ b/src/plugins/qmldesigner/designersettings.h
@@ -40,6 +40,8 @@ QT_END_NAMESPACE
 namespace QmlDesigner {
 
 struct DesignerSettings {
+    DesignerSettings();
+
     void fromSettings(QSettings *);
     void toSettings(QSettings *) const;
 
@@ -47,6 +49,7 @@ struct DesignerSettings {
 
     bool snapToGrid;
     bool showBoundingRectangles;
+    bool onlyShowItemsWithContents;
 };
 
 inline bool operator==(const DesignerSettings &s1, const DesignerSettings &s2)
diff --git a/src/plugins/qmldesigner/qmldesignerplugin.cpp b/src/plugins/qmldesigner/qmldesignerplugin.cpp
index 4a40842e85e..c70c72d77fb 100644
--- a/src/plugins/qmldesigner/qmldesignerplugin.cpp
+++ b/src/plugins/qmldesigner/qmldesignerplugin.cpp
@@ -32,6 +32,7 @@
 #include "designmode.h"
 #include "qmldesignerconstants.h"
 #include "pluginmanager.h"
+#include "settingspage.h"
 
 #include <coreplugin/icore.h>
 #include <coreplugin/dialogs/iwizard.h>
@@ -99,6 +100,7 @@ bool BauhausPlugin::initialize(const QStringList & /*arguments*/, QString *error
     m_designerCore->pluginManager()->setPluginPaths(QStringList() << pluginPath);
 
     addAutoReleasedObject(new DesignMode);
+    addAutoReleasedObject(new SettingsPage);
 
     error_message->clear();
 
diff --git a/src/plugins/qmldesigner/settingspage.cpp b/src/plugins/qmldesigner/settingspage.cpp
index f1b943cf1f1..fc0c798fa35 100644
--- a/src/plugins/qmldesigner/settingspage.cpp
+++ b/src/plugins/qmldesigner/settingspage.cpp
@@ -49,6 +49,8 @@ DesignerSettings SettingsPageWidget::settings() const
     DesignerSettings ds;
     ds.snapToGrid = m_ui.snapToGridCheckbox->isChecked();
     ds.showBoundingRectangles = m_ui.showBoundingRectanglesCheckbox->isChecked();
+    ds.onlyShowItemsWithContents =
+            m_ui.onlyShowItemsWithContentsCheckBox->isChecked();
     return ds;
 }
 
@@ -56,6 +58,7 @@ void SettingsPageWidget::setSettings(const DesignerSettings &s)
 {
     m_ui.snapToGridCheckbox->setChecked(s.snapToGrid);
     m_ui.showBoundingRectanglesCheckbox->setChecked(s.showBoundingRectangles);
+    m_ui.onlyShowItemsWithContentsCheckBox->setChecked(s.onlyShowItemsWithContents);
 }
 
 QString SettingsPageWidget::searchKeywords() const
@@ -63,7 +66,8 @@ QString SettingsPageWidget::searchKeywords() const
     QString rc;
     QTextStream(&rc)
             << m_ui.snapToGridCheckbox->text()
-            << m_ui.showBoundingRectanglesCheckbox->text()
+            << ' ' << m_ui.showBoundingRectanglesCheckbox->text()
+            << ' ' << m_ui.onlyShowItemsWithContentsCheckBox->text()
             << ' ' << m_ui.groupBox->title();
     rc.remove(QLatin1Char('&'));
     return rc;
diff --git a/src/plugins/qmldesigner/settingspage.ui b/src/plugins/qmldesigner/settingspage.ui
index dfdf3b3805b..09244658e4d 100644
--- a/src/plugins/qmldesigner/settingspage.ui
+++ b/src/plugins/qmldesigner/settingspage.ui
@@ -34,6 +34,13 @@
         </property>
        </widget>
       </item>
+      <item>
+       <widget class="QCheckBox" name="onlyShowItemsWithContentsCheckBox">
+        <property name="text">
+         <string>Only Show Items with Contents</string>
+        </property>
+       </widget>
+      </item>
      </layout>
     </widget>
    </item>
-- 
GitLab