Commit 9573ead4 authored by Alessandro Portale's avatar Alessandro Portale
Browse files

Removing the ThemeEditor



The Theme editor is a feature which was present but disabled since the
introduction of Themes. It is still unfinished and unlikely to be
finished.

An alternative, cheaper approch could be installing a file watcher
on a theme file, and reloading it on any change. But for that we
would still need proper theme switching during runtime.

Change-Id: Ifd44e8c25c924a8f021618d20ce126648a3558a3
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
Reviewed-by: default avatarLeena Miettinen <riitta-leena.miettinen@theqtcompany.com>
parent 42554938
......@@ -178,91 +178,6 @@ static QColor readColor(const QString &color)
return QColor::fromRgba(rgba);
}
static QString writeColor(const QColor &color)
{
return QString::number(color.rgba(), 16);
}
// reading, writing of .creatortheme ini file ////////////////////////////////
void Theme::writeSettings(const QString &filename) const
{
QSettings settings(filename, QSettings::IniFormat);
const QMetaObject &m = *metaObject();
{
settings.setValue(QLatin1String("ThemeName"), d->displayName);
settings.setValue(QLatin1String("PreferredStyles"), d->preferredStyles);
}
{
settings.beginGroup(QLatin1String("Palette"));
for (int i = 0, total = d->colors.size(); i < total; ++i) {
const QPair<QColor, QString> var = d->colors[i];
if (var.second.isEmpty())
continue;
settings.setValue(var.second, writeColor(var.first));
}
settings.endGroup();
}
{
settings.beginGroup(QLatin1String("Colors"));
const QMetaEnum e = m.enumerator(m.indexOfEnumerator("Color"));
for (int i = 0, total = e.keyCount(); i < total; ++i) {
const QString key = QLatin1String(e.key(i));
const QPair<QColor, QString> var = d->colors[i];
if (!var.second.isEmpty())
settings.setValue(key, var.second); // named color
else
settings.setValue(key, writeColor(var.first));
}
settings.endGroup();
}
{
settings.beginGroup(QLatin1String("ImageFiles"));
const QMetaEnum e = m.enumerator(m.indexOfEnumerator("ImageFile"));
for (int i = 0, total = e.keyCount(); i < total; ++i) {
const QString key = QLatin1String(e.key(i));
const QString &var = d->imageFiles.at(i);
if (!var.isEmpty())
settings.setValue(key, var);
}
settings.endGroup();
}
{
settings.beginGroup(QLatin1String("Gradients"));
const QMetaEnum e = m.enumerator(m.indexOfEnumerator("Gradient"));
for (int i = 0, total = e.keyCount(); i < total; ++i) {
const QString key = QLatin1String(e.key(i));
QGradientStops stops = gradient(static_cast<Theme::Gradient>(i));
settings.beginWriteArray(key);
int k = 0;
foreach (const QGradientStop stop, stops) {
settings.setArrayIndex(k);
settings.setValue(QLatin1String("pos"), stop.first);
settings.setValue(QLatin1String("color"), writeColor(stop.second));
++k;
}
settings.endArray();
}
settings.endGroup();
}
{
settings.beginGroup(QLatin1String("Flags"));
const QMetaEnum e = m.enumerator(m.indexOfEnumerator("Flag"));
for (int i = 0, total = e.keyCount(); i < total; ++i) {
const QString key = QLatin1String(e.key(i));
settings.setValue(key, flag(static_cast<Theme::Flag>(i)));
}
settings.endGroup();
}
{
settings.beginGroup(QLatin1String("Style"));
const QMetaEnum e = m.enumerator(m.indexOfEnumerator("WidgetStyle"));
settings.setValue(QLatin1String("WidgetStyle"), QLatin1String(e.valueToKey(widgetStyle ())));
settings.endGroup();
}
}
void Theme::readSettings(QSettings &settings)
{
d->fileName = settings.fileName();
......
......@@ -287,7 +287,6 @@ public:
QVariantHash values() const;
void writeSettings(const QString &filename) const;
void readSettings(QSettings &settings);
static QPalette initialPalette();
......
......@@ -105,14 +105,6 @@ SOURCES += corejsextensions.cpp \
patchtool.cpp \
windowsupport.cpp \
opendocumentstreeview.cpp \
themeeditor/themecolors.cpp \
themeeditor/themecolorstableview.cpp \
themeeditor/colorvariable.cpp \
themeeditor/themeeditorwidget.cpp \
themeeditor/colorrole.cpp \
themeeditor/themesettingstablemodel.cpp \
themeeditor/sectionedtablemodel.cpp \
themeeditor/themesettingsitemdelegate.cpp \
messagebox.cpp \
iwelcomepage.cpp \
externaltoolmanager.cpp \
......@@ -222,14 +214,6 @@ HEADERS += corejsextensions.h \
patchtool.h \
windowsupport.h \
opendocumentstreeview.h \
themeeditor/themecolors.h \
themeeditor/themecolorstableview.h \
themeeditor/colorvariable.h \
themeeditor/themeeditorwidget.h \
themeeditor/colorrole.h \
themeeditor/themesettingstablemodel.h \
themeeditor/sectionedtablemodel.h \
themeeditor/themesettingsitemdelegate.h \
messagebox.h \
iwelcomepage.h \
systemsettings.h \
......@@ -246,7 +230,6 @@ FORMS += dialogs/newdialog.ui \
mimetypemagicdialog.ui \
removefiledialog.ui \
dialogs/addtovcsdialog.ui \
themeeditor/themeeditorwidget.ui \
systemsettings.ui
RESOURCES += core.qrc \
......
......@@ -300,30 +300,6 @@ QtcPlugin {
]
}
Group {
name: "ThemeEditor"
prefix: "themeeditor/"
files: [
"colorrole.cpp",
"colorrole.h",
"colorvariable.cpp",
"colorvariable.h",
"sectionedtablemodel.cpp",
"sectionedtablemodel.h",
"themecolors.cpp",
"themecolors.h",
"themecolorstableview.cpp",
"themecolorstableview.h",
"themeeditorwidget.cpp",
"themeeditorwidget.h",
"themeeditorwidget.ui",
"themesettingsitemdelegate.cpp",
"themesettingsitemdelegate.h",
"themesettingstablemodel.cpp",
"themesettingstablemodel.h",
]
}
Export {
Depends { name: "Aggregation" }
Depends { name: "Utils" }
......
/****************************************************************************
**
** Copyright (C) 2015 Thorben Kroeger <thorbenkroeger@gmail.com>.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "colorrole.h"
#include "colorvariable.h"
namespace Core {
namespace Internal {
namespace ThemeEditor {
ColorRole::ColorRole(const QString &roleName, QSharedPointer<ColorVariable> colorVariable)
: m_roleName(roleName),
m_roleVariable(colorVariable)
{
m_roleVariable->addReference(this);
}
QSharedPointer<ColorVariable> ColorRole::colorVariable() const
{
return m_roleVariable;
}
void ColorRole::assignColorVariable(ColorVariable::Ptr namedColor)
{
namedColor->addReference(this);
m_roleVariable = namedColor;
}
} // namespace ThemeEditor
} // namespace Internal
} // namespace Core
/****************************************************************************
**
** Copyright (C) 2015 Thorben Kroeger <thorbenkroeger@gmail.com>.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef COLORROLE_H
#define COLORROLE_H
#include <QString>
#include <QColor>
#include <QSharedPointer>
namespace Core {
namespace Internal {
namespace ThemeEditor {
class ColorVariable;
class ThemeColors;
class ColorRole
{
public:
friend class ThemeColors;
typedef QSharedPointer<ColorRole> Ptr;
QString roleName() const { return m_roleName; }
QSharedPointer<ColorVariable> colorVariable() const;
void assignColorVariable(QSharedPointer<ColorVariable> colorVariable);
private:
explicit ColorRole(const QString &roleName, QSharedPointer<ColorVariable> colorVariable);
QString m_roleName;
QString m_roleDescription;
QSharedPointer<ColorVariable> m_roleVariable;
};
} // namespace ThemeEditor
} // namespace Internal
} // namespace Core
#endif // COLORROLE_H
/****************************************************************************
**
** Copyright (C) 2015 Thorben Kroeger <thorbenkroeger@gmail.com>.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "colorvariable.h"
#include "colorrole.h"
#include <utils/qtcassert.h>
namespace Core {
namespace Internal {
namespace ThemeEditor {
ColorVariable::ColorVariable(const QColor &color, const QString &name)
: m_variableValue(color)
, m_variableName(name)
{
}
ColorVariable::~ColorVariable()
{
}
void ColorVariable::setColor(const QColor &newColor)
{
m_variableValue = newColor;
}
void ColorVariable::addReference(ColorRole *t)
{
m_references.insert(t);
}
void ColorVariable::removeReference(ColorRole *t)
{
QTC_ASSERT(m_references.contains(t), return);
m_references.remove(t);
}
QSet<ColorRole *> ColorVariable::references() const
{
return m_references;
}
} // namespace ThemeEditor
} // namespace Internal
} // namespace Core
/****************************************************************************
**
** Copyright (C) 2015 Thorben Kroeger <thorbenkroeger@gmail.com>.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef COLORVARIABLE_H
#define COLORVARIABLE_H
#include <QSharedPointer>
#include <QColor>
#include <QString>
#include <QSet>
namespace Core {
namespace Internal {
namespace ThemeEditor {
class ColorRole;
class ThemeColors;
class ColorVariable
{
public:
friend class ThemeColors;
typedef QSharedPointer<ColorVariable> Ptr;
~ColorVariable();
// name of this variable
QString variableName() const { return m_variableName; }
// value of this variable
QColor color() const { return m_variableValue; }
void setColor(const QColor &color);
// which theme colors are referencing this variable?
void addReference(ColorRole *t);
void removeReference(ColorRole *t);
QSet<ColorRole *> references() const;
private:
explicit ColorVariable(const QColor &color, const QString &variableName = QString());
QColor m_variableValue;
QString m_variableName;
QSet<ColorRole *> m_references;
};
} // namespace ThemeEditor
} // namespace Internal
} // namespace Core
#endif // COLORVARIABLE_H
/****************************************************************************
**
** Copyright (C) 2015 Thorben Kroeger <thorbenkroeger@gmail.com>.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "sectionedtablemodel.h"
#include <QSize>
namespace Core {
namespace Internal {
namespace ThemeEditor {
SectionedTableModel::SectionedTableModel(QObject *parent) :
QAbstractTableModel(parent)
{
}
int SectionedTableModel::sectionHeader(int row) const
{
int currRow = 0;
int i = 0;
do {
if (row == currRow)
return i;
currRow += sectionRowCount(i) + 1; //account for next header
++i;
} while (i < sectionCount());
return -1;
}
int SectionedTableModel::inSectionBody(int row) const
{
int currRow = 0;
int i = 0;
do {
++currRow;
if (row >= currRow && row < currRow + sectionRowCount(i))
return i;
currRow += sectionRowCount(i);
++i;
} while (i < sectionCount());
return -1;
}
int SectionedTableModel::modelToSectionRow(int row) const
{
int currRow = 0;
for (int i = 0; i < sectionCount(); ++i) {
++currRow;
if (row >= currRow && row < currRow + sectionRowCount(i))
return row-currRow;
currRow += sectionRowCount(i);
}
return row;
}
QSize SectionedTableModel::span(const QModelIndex &index) const
{
if (sectionHeader(index.row()) >= 0 && index.column() == 0)
return QSize(1, columnCount(index));
return QSize(1, 1);
}
int SectionedTableModel::rowCount(const QModelIndex &index) const
{
if (index.isValid())
return 0;
int r = 0;
for (int i = 0; i < sectionCount(); ++i)
r += sectionRowCount(i) + 1;
return r;
}
QVariant SectionedTableModel::data(const QModelIndex &index, int role) const
{
int header = sectionHeader(index.row());
if (header >= 0)
return (index.column() == 0) ? sectionHeaderData(header, role)
: QVariant(QString());
return sectionBodyData(inSectionBody(index.row()),
modelToSectionRow(index.row()),
index.column(),
role);
}
Qt::ItemFlags SectionedTableModel::flags(const QModelIndex &index) const
{
if (int h = sectionHeader(index.row()) >= 0)
return sectionHeaderFlags(h);
return sectionBodyFlags(inSectionBody(index.row()),
modelToSectionRow(index.row()),
index.column());
}
} // namespace ThemeEditor
} // namespace Internal
} // namespace Core
/****************************************************************************
**
** Copyright (C) 2015 Thorben Kroeger <thorbenkroeger@gmail.com>.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free