forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -36,14 +36,15 @@
|
||||
#include <utils/stringutils.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QSettings>
|
||||
#include <QTimer>
|
||||
#include <QFileDialog>
|
||||
#include <QFontDatabase>
|
||||
#include <QInputDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QPalette>
|
||||
#include <QPointer>
|
||||
#include <QSettings>
|
||||
#include <QTimer>
|
||||
#include <QDebug>
|
||||
|
||||
namespace TextEditor {
|
||||
namespace Internal {
|
||||
@@ -122,10 +123,10 @@ public:
|
||||
TextEditor::FormatDescriptions m_descriptions;
|
||||
FontSettings m_value;
|
||||
FontSettings m_lastValue;
|
||||
QPointer<QWidget> m_widget;
|
||||
Ui::FontSettingsPage *m_ui;
|
||||
SchemeListModel *m_schemeListModel;
|
||||
bool m_refreshingSchemeList;
|
||||
QString m_searchKeywords;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
@@ -326,49 +327,40 @@ FontSettingsPage::~FontSettingsPage()
|
||||
delete d_ptr;
|
||||
}
|
||||
|
||||
QWidget *FontSettingsPage::createPage(QWidget *parent)
|
||||
QWidget *FontSettingsPage::widget()
|
||||
{
|
||||
QWidget *w = new QWidget(parent);
|
||||
d_ptr->m_ui = new Ui::FontSettingsPage;
|
||||
d_ptr->m_ui->setupUi(w);
|
||||
d_ptr->m_ui->schemeComboBox->setModel(d_ptr->m_schemeListModel);
|
||||
if (!d_ptr->m_widget){
|
||||
d_ptr->m_widget = new QWidget;
|
||||
d_ptr->m_ui = new Ui::FontSettingsPage;
|
||||
d_ptr->m_ui->setupUi(d_ptr->m_widget);
|
||||
d_ptr->m_ui->schemeComboBox->setModel(d_ptr->m_schemeListModel);
|
||||
|
||||
QFontDatabase db;
|
||||
const QStringList families = db.families();
|
||||
d_ptr->m_ui->familyComboBox->addItems(families);
|
||||
const int idx = families.indexOf(d_ptr->m_value.family());
|
||||
d_ptr->m_ui->familyComboBox->setCurrentIndex(idx);
|
||||
QFontDatabase db;
|
||||
const QStringList families = db.families();
|
||||
d_ptr->m_ui->familyComboBox->addItems(families);
|
||||
const int idx = families.indexOf(d_ptr->m_value.family());
|
||||
d_ptr->m_ui->familyComboBox->setCurrentIndex(idx);
|
||||
|
||||
d_ptr->m_ui->antialias->setChecked(d_ptr->m_value.antialias());
|
||||
d_ptr->m_ui->zoomSpinBox->setValue(d_ptr->m_value.fontZoom());
|
||||
d_ptr->m_ui->antialias->setChecked(d_ptr->m_value.antialias());
|
||||
d_ptr->m_ui->zoomSpinBox->setValue(d_ptr->m_value.fontZoom());
|
||||
|
||||
d_ptr->m_ui->schemeEdit->setFormatDescriptions(d_ptr->m_descriptions);
|
||||
d_ptr->m_ui->schemeEdit->setBaseFont(d_ptr->m_value.font());
|
||||
d_ptr->m_ui->schemeEdit->setColorScheme(d_ptr->m_value.colorScheme());
|
||||
d_ptr->m_ui->schemeEdit->setFormatDescriptions(d_ptr->m_descriptions);
|
||||
d_ptr->m_ui->schemeEdit->setBaseFont(d_ptr->m_value.font());
|
||||
d_ptr->m_ui->schemeEdit->setColorScheme(d_ptr->m_value.colorScheme());
|
||||
|
||||
connect(d_ptr->m_ui->familyComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(fontFamilySelected(QString)));
|
||||
connect(d_ptr->m_ui->sizeComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(fontSizeSelected(QString)));
|
||||
connect(d_ptr->m_ui->zoomSpinBox, SIGNAL(valueChanged(int)), this, SLOT(fontZoomChanged()));
|
||||
connect(d_ptr->m_ui->schemeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(colorSchemeSelected(int)));
|
||||
connect(d_ptr->m_ui->copyButton, SIGNAL(clicked()), this, SLOT(copyColorScheme()));
|
||||
connect(d_ptr->m_ui->deleteButton, SIGNAL(clicked()), this, SLOT(confirmDeleteColorScheme()));
|
||||
connect(d_ptr->m_ui->familyComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(fontFamilySelected(QString)));
|
||||
connect(d_ptr->m_ui->sizeComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(fontSizeSelected(QString)));
|
||||
connect(d_ptr->m_ui->zoomSpinBox, SIGNAL(valueChanged(int)), this, SLOT(fontZoomChanged()));
|
||||
connect(d_ptr->m_ui->schemeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(colorSchemeSelected(int)));
|
||||
connect(d_ptr->m_ui->copyButton, SIGNAL(clicked()), this, SLOT(copyColorScheme()));
|
||||
connect(d_ptr->m_ui->deleteButton, SIGNAL(clicked()), this, SLOT(confirmDeleteColorScheme()));
|
||||
|
||||
|
||||
updatePointSizes();
|
||||
refreshColorSchemeList();
|
||||
d_ptr->m_lastValue = d_ptr->m_value;
|
||||
if (d_ptr->m_searchKeywords.isEmpty()) {
|
||||
QLatin1Char sep(' ');
|
||||
d_ptr->m_searchKeywords =
|
||||
d_ptr->m_ui->fontGroupBox->title() + sep
|
||||
+ d_ptr->m_ui->familyLabel->text() + sep
|
||||
+ d_ptr->m_ui->sizeLabel->text() + sep
|
||||
+ d_ptr->m_ui->zoomLabel->text() + sep
|
||||
+ d_ptr->m_ui->antialias->text() + sep
|
||||
+ d_ptr->m_ui->colorSchemeGroupBox->title();
|
||||
d_ptr->m_searchKeywords.remove(QLatin1Char('&'));
|
||||
updatePointSizes();
|
||||
refreshColorSchemeList();
|
||||
d_ptr->m_lastValue = d_ptr->m_value;
|
||||
}
|
||||
return w;
|
||||
return d_ptr->m_widget;
|
||||
}
|
||||
|
||||
void FontSettingsPage::fontFamilySelected(const QString &family)
|
||||
@@ -630,6 +622,7 @@ void FontSettingsPage::saveSettings()
|
||||
|
||||
void FontSettingsPage::finish()
|
||||
{
|
||||
delete d_ptr->m_widget;
|
||||
if (!d_ptr->m_ui) // page was never shown
|
||||
return;
|
||||
// If changes were applied, these are equal. Otherwise restores last value.
|
||||
@@ -642,8 +635,3 @@ const FontSettings &FontSettingsPage::fontSettings() const
|
||||
{
|
||||
return d_ptr->m_value;
|
||||
}
|
||||
|
||||
bool FontSettingsPage::matches(const QString &s) const
|
||||
{
|
||||
return d_ptr->m_searchKeywords.contains(s, Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user