From 57f11f40d60d508a09cbc9ee474e2347cc9485fb Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Wed, 2 Apr 2014 13:42:53 +0200 Subject: [PATCH] Welcome: Store examples search text in settings in QtCreator.ini under "WelcomePage/ExamplesSearchString". The installer pre-set that setting, and in that way pre- select a set of examples. Change-Id: I8ac5a38ad0bd3f33875ef1997ccbf0352410dcc3 Reviewed-by: Thomas Hartmann --- share/qtcreator/welcomescreen/examples.qml | 7 ++++++- src/plugins/qtsupport/exampleslistmodel.cpp | 11 +++++++++++ src/plugins/qtsupport/exampleslistmodel.h | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/share/qtcreator/welcomescreen/examples.qml b/share/qtcreator/welcomescreen/examples.qml index 53d77a0d3bf..5dc5d53bde6 100644 --- a/share/qtcreator/welcomescreen/examples.qml +++ b/share/qtcreator/welcomescreen/examples.qml @@ -56,8 +56,13 @@ Rectangle { anchors.right: parent.right anchors.leftMargin: 18 + text: examplesModel.readSearchStringsFromSettings() + placeholderText: qsTr("Search in Examples...") - onTextChanged: examplesModel.parseSearchString(text) + onTextChanged: { + examplesModel.parseSearchString(text); + examplesModel.writeSearchStringToSettings(text); + } } ComboBox { diff --git a/src/plugins/qtsupport/exampleslistmodel.cpp b/src/plugins/qtsupport/exampleslistmodel.cpp index 22f4bf66d1f..ebab7763180 100644 --- a/src/plugins/qtsupport/exampleslistmodel.cpp +++ b/src/plugins/qtsupport/exampleslistmodel.cpp @@ -54,6 +54,7 @@ static bool debugExamples() } static const char kSelectedExampleSetKey[] = "WelcomePage/SelectedExampleSet"; +static const char kExamplesSearchStringKey[] = "WelcomePage/ExamplesSearchString"; void ExampleSetModel::writeCurrentIdToSettings(int currentIndex) const { @@ -841,6 +842,16 @@ void ExamplesListModelFilter::filterForExampleSet(int index) m_sourceModel->selectExampleSet(index); } +void ExamplesListModelFilter::writeSearchStringToSettings(const QString &string) +{ + Core::ICore::settings()->setValue(QLatin1String(kExamplesSearchStringKey), string); +} + +QString ExamplesListModelFilter::readSearchStringsFromSettings() +{ + return Core::ICore::settings()->value(QLatin1String(kExamplesSearchStringKey)).toString(); +} + void ExamplesListModelFilter::setShowTutorialsOnly(bool showTutorialsOnly) { m_showTutorialsOnly = showTutorialsOnly; diff --git a/src/plugins/qtsupport/exampleslistmodel.h b/src/plugins/qtsupport/exampleslistmodel.h index 6a2607de741..ae30ec9290f 100644 --- a/src/plugins/qtsupport/exampleslistmodel.h +++ b/src/plugins/qtsupport/exampleslistmodel.h @@ -185,6 +185,8 @@ public: QAbstractItemModel* exampleSetModel(); Q_INVOKABLE void filterForExampleSet(int index); + Q_INVOKABLE void writeSearchStringToSettings(const QString &string); + Q_INVOKABLE QString readSearchStringsFromSettings(); public slots: void setFilterTags(const QStringList &arg)