summaryrefslogtreecommitdiff
path: root/src/plugins/help/generalsettingspage.cpp
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@digia.com>2013-12-03 14:17:03 +0100
committerEike Ziller <eike.ziller@digia.com>2013-12-10 13:31:48 +0100
commitdeb43b4c8a261855252aeee09fd6df283576932e (patch)
treea844379f47974fd681b86aa2187735e03639b567 /src/plugins/help/generalsettingspage.cpp
parentea1a92484ac99057b06130a012164bf9788650e9 (diff)
downloadqt-creator-deb43b4c8a261855252aeee09fd6df283576932e.tar.gz
Preferences: Add default implementation for filtering
The default "matches" method now takes the widget and looks for all child labels, checkboxes, push buttons and group boxes. Because of that, the former "createWidget" method can be called multiple times without creating a new widget (-->widget()), and the "finished" method must ensure that the created widget gets deleted, since not all widgets that were created are added to the UI anymore. Change-Id: Ia231c7c78dd8819146668e6447d36d22e7836904 Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Diffstat (limited to 'src/plugins/help/generalsettingspage.cpp')
-rw-r--r--src/plugins/help/generalsettingspage.cpp91
1 files changed, 41 insertions, 50 deletions
diff --git a/src/plugins/help/generalsettingspage.cpp b/src/plugins/help/generalsettingspage.cpp
index 43ac9b1aed..53848cff7c 100644
--- a/src/plugins/help/generalsettingspage.cpp
+++ b/src/plugins/help/generalsettingspage.cpp
@@ -72,59 +72,54 @@ GeneralSettingsPage::GeneralSettingsPage()
setCategoryIcon(QLatin1String(Help::Constants::HELP_CATEGORY_ICON));
}
-QWidget *GeneralSettingsPage::createPage(QWidget *parent)
+QWidget *GeneralSettingsPage::widget()
{
- QWidget *widget = new QWidget(parent);
- m_ui = new Ui::GeneralSettingsPage;
- m_ui->setupUi(widget);
- m_ui->sizeComboBox->setEditable(false);
- m_ui->styleComboBox->setEditable(false);
-
- m_font = qvariant_cast<QFont>(HelpManager::customValue(QLatin1String("font"), m_font));
-
- updateFontSize();
- updateFontStyle();
- updateFontFamily();
-
- m_homePage = HelpManager::customValue(QLatin1String("HomePage"), QString())
- .toString();
- if (m_homePage.isEmpty()) {
- m_homePage = HelpManager::customValue(QLatin1String("DefaultHomePage"),
- Help::Constants::AboutBlank).toString();
- }
- m_ui->homePageLineEdit->setText(m_homePage);
+ if (!m_widget) {
+ m_widget = new QWidget;
+ m_ui = new Ui::GeneralSettingsPage;
+ m_ui->setupUi(m_widget);
+ m_ui->sizeComboBox->setEditable(false);
+ m_ui->styleComboBox->setEditable(false);
+
+ m_font = qvariant_cast<QFont>(HelpManager::customValue(QLatin1String("font"), m_font));
+
+ updateFontSize();
+ updateFontStyle();
+ updateFontFamily();
+
+ m_homePage = HelpManager::customValue(QLatin1String("HomePage"), QString())
+ .toString();
+ if (m_homePage.isEmpty()) {
+ m_homePage = HelpManager::customValue(QLatin1String("DefaultHomePage"),
+ Help::Constants::AboutBlank).toString();
+ }
+ m_ui->homePageLineEdit->setText(m_homePage);
- m_startOption = HelpManager::customValue(QLatin1String("StartOption"),
- Help::Constants::ShowLastPages).toInt();
- m_ui->helpStartComboBox->setCurrentIndex(m_startOption);
+ m_startOption = HelpManager::customValue(QLatin1String("StartOption"),
+ Help::Constants::ShowLastPages).toInt();
+ m_ui->helpStartComboBox->setCurrentIndex(m_startOption);
- m_contextOption = HelpManager::customValue(QLatin1String("ContextHelpOption"),
- Help::Constants::SideBySideIfPossible).toInt();
- m_ui->contextHelpComboBox->setCurrentIndex(m_contextOption);
+ m_contextOption = HelpManager::customValue(QLatin1String("ContextHelpOption"),
+ Help::Constants::SideBySideIfPossible).toInt();
+ m_ui->contextHelpComboBox->setCurrentIndex(m_contextOption);
- connect(m_ui->currentPageButton, SIGNAL(clicked()), this, SLOT(setCurrentPage()));
- connect(m_ui->blankPageButton, SIGNAL(clicked()), this, SLOT(setBlankPage()));
- connect(m_ui->defaultPageButton, SIGNAL(clicked()), this, SLOT(setDefaultPage()));
+ connect(m_ui->currentPageButton, SIGNAL(clicked()), this, SLOT(setCurrentPage()));
+ connect(m_ui->blankPageButton, SIGNAL(clicked()), this, SLOT(setBlankPage()));
+ connect(m_ui->defaultPageButton, SIGNAL(clicked()), this, SLOT(setDefaultPage()));
- HelpViewer *viewer = CentralWidget::instance()->currentHelpViewer();
- if (!viewer)
- m_ui->currentPageButton->setEnabled(false);
+ HelpViewer *viewer = CentralWidget::instance()->currentHelpViewer();
+ if (!viewer)
+ m_ui->currentPageButton->setEnabled(false);
- m_ui->errorLabel->setVisible(false);
- connect(m_ui->importButton, SIGNAL(clicked()), this, SLOT(importBookmarks()));
- connect(m_ui->exportButton, SIGNAL(clicked()), this, SLOT(exportBookmarks()));
+ m_ui->errorLabel->setVisible(false);
+ connect(m_ui->importButton, SIGNAL(clicked()), this, SLOT(importBookmarks()));
+ connect(m_ui->exportButton, SIGNAL(clicked()), this, SLOT(exportBookmarks()));
- if (m_searchKeywords.isEmpty()) {
- QTextStream(&m_searchKeywords) << ' ' << m_ui->contextHelpLabel->text()
- << ' ' << m_ui->startPageLabel->text() << ' ' << m_ui->homePageLabel->text();
- m_searchKeywords.remove(QLatin1Char('&'));
+ m_returnOnClose = HelpManager::customValue(QLatin1String("ReturnOnClose"),
+ false).toBool();
+ m_ui->m_returnOnClose->setChecked(m_returnOnClose);
}
-
- m_returnOnClose = HelpManager::customValue(QLatin1String("ReturnOnClose"),
- false).toBool();
- m_ui->m_returnOnClose->setChecked(m_returnOnClose);
-
- return widget;
+ return m_widget;
}
void GeneralSettingsPage::apply()
@@ -342,13 +337,9 @@ int GeneralSettingsPage::closestPointSizeIndex(int desiredPointSize) const
return closestIndex;
}
-bool GeneralSettingsPage::matches(const QString &s) const
-{
- return m_searchKeywords.contains(s, Qt::CaseInsensitive);
-}
-
void GeneralSettingsPage::finish()
{
+ delete m_widget;
if (!m_ui) // page was never shown
return;
delete m_ui;