diff --git a/share/qtcreator/styles/default.xml b/share/qtcreator/styles/default.xml index 3e441fbce149b62390656478df4ed3d2b2345b41..27ac73c11aa28fabefc7e64f1222e0316fa48865 100644 --- a/share/qtcreator/styles/default.xml +++ b/share/qtcreator/styles/default.xml @@ -1,27 +1,4 @@ <?xml version="1.0" encoding="UTF-8"?> -<style-scheme version="1.0"> - <style name="AddedLine" foreground="#00aa00"/> - <style name="Comment" foreground="#008000"/> - <style name="CurrentLine" background="#fef2da"/> - <style name="CurrentLineNumber" foreground="#808080" bold="true"/> - <style name="DiffFile" foreground="#000080"/> - <style name="DiffLocation" foreground="#0000ff"/> - <style name="DisabledCode" foreground="#a0a0a4"/> - <style name="Doxygen.Comment" foreground="#000080"/> - <style name="Doxygen.Tag" foreground="#0000ff"/> - <style name="Keyword" foreground="#808000"/> - <style name="Label" foreground="#800000"/> - <style name="LineNumber" foreground="#c7c4c1" background="#efebe7"/> - <style name="Link" foreground="#0000ff"/> - <style name="Number" foreground="#000080"/> - <style name="Operator" foreground="#000000"/> - <style name="Parentheses" foreground="#ff0000" background="#b4eeb4"/> - <style name="Preprocessor" foreground="#000080"/> - <style name="RemovedLine" foreground="#ff0000"/> - <style name="SearchResult" background="#ffef0b"/> - <style name="SearchScope" background="#fdedce"/> - <style name="Selection" background="#fad184"/> - <style name="String" foreground="#008000"/> - <style name="Text" foreground="#000000" background="#ffffff"/> - <style name="Type" foreground="#800080"/> +<style-scheme version="1.0" name="Default"> + <!-- Empty scheme, relying entirely on built-in defaults. --> </style-scheme> diff --git a/share/qtcreator/styles/grayscale.xml b/share/qtcreator/styles/grayscale.xml new file mode 100644 index 0000000000000000000000000000000000000000..d575410876ff1b95fe1e472170f003506c2bdbe1 --- /dev/null +++ b/share/qtcreator/styles/grayscale.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<style-scheme version="1.0" name="Grayscale"> + <style name="AddedLine" foreground="#636363"/> + <style name="Comment" foreground="#808080"/> + <style name="CurrentLine" foreground="#000000" background="#f2f2f2"/> + <style name="DiffFile"/> + <style name="DiffLocation"/> + <style name="DisabledCode" foreground="#a0a0a4"/> + <style name="Doxygen.Comment" foreground="#808080"/> + <style name="Doxygen.Tag" foreground="#808080" italic="true"/> + <style name="Keyword" bold="true"/> + <style name="Label"/> + <style name="LineNumber" foreground="#c7c4c1" background="#efebe7"/> + <style name="Link" foreground="#0000ff"/> + <style name="Number" foreground="#3f3f3f"/> + <style name="Operator"/> + <style name="Parentheses" background="#e3e3e3" bold="true"/> + <style name="Preprocessor" foreground="#5b5b5b"/> + <style name="RemovedLine" foreground="#a0a0a4"/> + <style name="String" foreground="#636363"/> + <style name="Text" foreground="#000000" background="#ffffff"/> + <style name="Type"/> + <!-- + Relying on default colors for: + + CurrentLineNumber + LineNumber + SearchResult + SearchScope + Selection + + --> +</style-scheme> diff --git a/src/plugins/texteditor/fontsettings.cpp b/src/plugins/texteditor/fontsettings.cpp index 23a8f52dede9058014cb4033261940e522e11e1a..03f61b61c024e88bdc6cf2acad2cabbb24300bad 100644 --- a/src/plugins/texteditor/fontsettings.cpp +++ b/src/plugins/texteditor/fontsettings.cpp @@ -92,18 +92,7 @@ void FontSettings::toSettings(const QString &category, if (m_schemeFileName != defaultSchemeFileName() || s->contains(QLatin1String(schemeFileNameKey))) s->setValue(QLatin1String(schemeFileNameKey), m_schemeFileName); -#if 0 - const Format defaultFormat; - foreach (const FormatDescription &desc, descriptions) { - const QString name = desc.name(); - if (m_scheme.contains(name)) { - const Format &f = m_scheme.formatFor(name); - if (f != defaultFormat || s->contains(name)) - s->setValue(name, f.toString()); - } - } -#endif s->endGroup(); } @@ -122,25 +111,9 @@ bool FontSettings::fromSettings(const QString &category, m_family = s->value(group + QLatin1String(fontFamilyKey), defaultFixedFontFamily()).toString(); m_fontSize = s->value(group + QLatin1String(fontSizeKey), m_fontSize).toInt(); m_antialias = s->value(group + QLatin1String(antialiasKey), DEFAULT_ANTIALIAS).toBool(); - m_schemeFileName = s->value(group + QLatin1String(schemeFileNameKey), defaultSchemeFileName()).toString(); + loadColorScheme(s->value(group + QLatin1String(schemeFileNameKey), defaultSchemeFileName()).toString(), + descriptions); - m_scheme.load(m_schemeFileName); -#if 0 - foreach (const FormatDescription &desc, descriptions) { - const QString name = desc.name(); - const QString fmt = s->value(group + name, QString()).toString(); - Format format; - if (fmt.isEmpty()) { - format.setForeground(desc.foreground()); - format.setBackground(desc.background()); - format.setBold(desc.format().bold()); - format.setItalic(desc.format().italic()); - } else { - format.fromString(fmt); - } - m_scheme.setFormatFor(name, format); - } -#endif return true; } @@ -247,9 +220,24 @@ QString FontSettings::colorSchemeFileName() const return m_schemeFileName; } -void FontSettings::setColorSchemeFileName(const QString &fileName) +void FontSettings::loadColorScheme(const QString &fileName, + const FormatDescriptions &descriptions) { m_schemeFileName = fileName; + m_scheme.load(m_schemeFileName); + + // Apply default formats to undefined categories + foreach (const FormatDescription &desc, descriptions) { + const QString name = desc.name(); + if (!m_scheme.contains(name)) { + Format format; + format.setForeground(desc.foreground()); + format.setBackground(desc.background()); + format.setBold(desc.format().bold()); + format.setItalic(desc.format().italic()); + m_scheme.setFormatFor(name, format); + } + } } /** diff --git a/src/plugins/texteditor/fontsettings.h b/src/plugins/texteditor/fontsettings.h index 918f075d394c7d3a1fea4277a76e08ce537cbf12..b67e48b3111f97f8b006f92eaab179f26ef34d52 100644 --- a/src/plugins/texteditor/fontsettings.h +++ b/src/plugins/texteditor/fontsettings.h @@ -84,7 +84,7 @@ public: Format &formatFor(const QString &category); QString colorSchemeFileName() const; - void setColorSchemeFileName(const QString &fileName); + void loadColorScheme(const QString &fileName, const FormatDescriptions &descriptions); ColorScheme colorScheme() const; void setColorScheme(const ColorScheme &scheme); diff --git a/src/plugins/texteditor/fontsettingspage.cpp b/src/plugins/texteditor/fontsettingspage.cpp index b411101f5c22ac5b713449401c462f3edbe94bf1..be16da4ca53728b17d0048bf65a2b9ef122fefec 100644 --- a/src/plugins/texteditor/fontsettingspage.cpp +++ b/src/plugins/texteditor/fontsettingspage.cpp @@ -235,6 +235,8 @@ QWidget *FontSettingsPage::createPage(QWidget *parent) d_ptr->ui.antialias->setChecked(d_ptr->m_value.antialias()); connect(d_ptr->ui.familyComboBox, SIGNAL(activated(int)), this, SLOT(updatePointSizes())); + connect(d_ptr->ui.schemeListWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), + this, SLOT(colorSchemeSelected(QListWidgetItem*))); connect(d_ptr->ui.exportButton, SIGNAL(clicked()), this, SLOT(exportColorScheme())); connect(d_ptr->ui.editButton, SIGNAL(clicked()), this, SLOT(editColorScheme())); @@ -268,6 +270,11 @@ void FontSettingsPage::updatePointSizes() d_ptr->ui.sizeComboBox->setCurrentIndex(idx); } +void FontSettingsPage::colorSchemeSelected(QListWidgetItem *item) +{ + // TODO: Enable the appropriate actions +} + void FontSettingsPage::importColorScheme() { QString fn = QFileDialog::getOpenFileName(d_ptr->ui.importButton->window(), @@ -318,12 +325,22 @@ void FontSettingsPage::refreshColorSchemeList() styleDir.setNameFilters(QStringList() << QLatin1String("*.xml")); styleDir.setFilter(QDir::Files); + int selected = 0; + int count = 0; + foreach (const QString &file, styleDir.entryList()) { // TODO: Read the name of the style QListWidgetItem *item = new QListWidgetItem(file); - item->setData(Qt::UserRole, styleDir.absoluteFilePath(file)); + const QString absFileName = styleDir.absoluteFilePath(file); + item->setData(Qt::UserRole, absFileName ); d_ptr->ui.schemeListWidget->addItem(item); + if (d_ptr->m_value.colorSchemeFileName() == absFileName) + selected = count; + ++count; } + + const QModelIndex s = d_ptr->ui.schemeListWidget->model()->index(selected, 0); + d_ptr->ui.schemeListWidget->setCurrentIndex(s); } void FontSettingsPage::delayedChange() @@ -336,6 +353,12 @@ void FontSettingsPage::apply() d_ptr->m_value.setFamily(d_ptr->ui.familyComboBox->currentText()); d_ptr->m_value.setAntialias(d_ptr->ui.antialias->isChecked()); + if (QListWidgetItem *item = d_ptr->ui.schemeListWidget->currentItem()) { + QString file = item->data(Qt::UserRole).toString(); + if (file != d_ptr->m_value.colorSchemeFileName()) + d_ptr->m_value.loadColorScheme(file, d_ptr->m_descriptions); + } + bool ok = true; const int size = d_ptr->ui.sizeComboBox->currentText().toInt(&ok); if (ok) diff --git a/src/plugins/texteditor/fontsettingspage.h b/src/plugins/texteditor/fontsettingspage.h index bdda4e7fbfc7c06e4d173feb4f5e0ecb207326ee..748fb48d58cb7f223a2076c4e57bdd814447ae5c 100644 --- a/src/plugins/texteditor/fontsettingspage.h +++ b/src/plugins/texteditor/fontsettingspage.h @@ -42,6 +42,7 @@ #include <QtCore/QVector> QT_BEGIN_NAMESPACE +class QListWidgetItem; class QWidget; QT_END_NAMESPACE @@ -110,6 +111,7 @@ signals: private slots: void delayedChange(); void updatePointSizes(); + void colorSchemeSelected(QListWidgetItem *item); void importColorScheme(); void exportColorScheme(); void editColorScheme();