Commit a18b0673 authored by Alessandro Portale's avatar Alessandro Portale Committed by hjk

Cleanup of Theming

A theme is supposed to provide colors, flags and images. This change
removes functions from Theme which do not just return simple data.
Also ManhattanStyle and Theme get separated a bit.

Change-Id: I2fab26ee38b858fefb55920eb219f84abcfaac18
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 4612cccb
...@@ -113,18 +113,15 @@ DetailsWidgetHeaderGradient\1\color=0 ...@@ -113,18 +113,15 @@ DetailsWidgetHeaderGradient\1\color=0
DetailsWidgetHeaderGradient\1\pos=1 DetailsWidgetHeaderGradient\1\pos=1
DetailsWidgetHeaderGradient\size=1 DetailsWidgetHeaderGradient\size=1
[IconOverlay] [ImageFiles]
CSourceMimetype=:/cppeditor/images/dark_qt_c.png IconOverlayCSource=:/cppeditor/images/dark_qt_c.png
CppHeaderMimetype=:/cppeditor/images/dark_qt_h.png IconOverlayCppHeader=:/cppeditor/images/dark_qt_h.png
CppSourceMimetype=:/cppeditor/images/dark_qt_cpp.png IconOverlayCppSource=:/cppeditor/images/dark_qt_cpp.png
PrfMimetype=:/qtsupport/images/dark_qt_project.png IconOverlayPrf=:/qtsupport/images/dark_qt_project.png
PriMimetype=:/qtsupport/images/dark_qt_project.png IconOverlayPri=:/qtsupport/images/dark_qt_project.png
ProMimetype=:/qtsupport/images/dark_qt_project.png IconOverlayPro=:/qtsupport/images/dark_qt_project.png
StandardPixmapFileIcon=:/core/images/dark_fileicon.png
#TODO: needs to be ported to new ini format! StandardPixmapDirIcon=:/core/images/dark_foldericon.png
[StandardIcons]
SP_FileIcon=:/core/images/dark_fileicon.png
SP_DirIcon=:/core/images/dark_foldericon.png
[Style] [Style]
WidgetStyle=StyleFlat WidgetStyle=StyleFlat
...@@ -63,13 +63,6 @@ Theme::~Theme() ...@@ -63,13 +63,6 @@ Theme::~Theme()
delete d; delete d;
} }
void Theme::drawIndicatorBranch(QPainter *painter, const QRect &rect, QStyle::State state) const
{
Q_UNUSED(painter);
Q_UNUSED(rect);
Q_UNUSED(state);
}
Theme::WidgetStyle Theme::widgetStyle() const Theme::WidgetStyle Theme::widgetStyle() const
{ {
return d->widgetStyle; return d->widgetStyle;
...@@ -85,48 +78,15 @@ QColor Theme::color(Theme::ColorRole role) const ...@@ -85,48 +78,15 @@ QColor Theme::color(Theme::ColorRole role) const
return d->colors[role].first; return d->colors[role].first;
} }
QGradientStops Theme::gradient(Theme::GradientRole role) const QString Theme::imageFile(Theme::ImageFile imageFile, const QString &fallBack) const
{
return d->gradientStops[role];
}
QString Theme::iconOverlay(Theme::MimeType mimetype) const
{
return d->iconOverlays[mimetype];
}
QString Theme::dpiSpecificImageFile(const QString &fileName) const
{ {
return dpiSpecificImageFile(fileName, QLatin1String("")); const QString &file = d->imageFiles.at(imageFile);
return file.isEmpty() ? fallBack : file;
} }
QString Theme::dpiSpecificImageFile(const QString &fileName, const QString &themePrefix) const QGradientStops Theme::gradient(Theme::GradientRole role) const
{ {
// See QIcon::addFile() return d->gradientStops[role];
const QFileInfo fi(fileName);
bool at2x = (qApp->devicePixelRatio() > 1.0);
const QString at2xFileName = fi.path() + QStringLiteral("/")
+ fi.completeBaseName() + QStringLiteral("@2x.") + fi.suffix();
const QString themedAt2xFileName = fi.path() + QStringLiteral("/") + themePrefix
+ fi.completeBaseName() + QStringLiteral("@2x.") + fi.suffix();
const QString themedFileName = fi.path() + QStringLiteral("/") + themePrefix
+ fi.completeBaseName() + QStringLiteral(".") + fi.suffix();
if (at2x) {
if (QFile::exists(themedAt2xFileName))
return themedAt2xFileName;
else if (QFile::exists(themedFileName))
return themedFileName;
else if (QFile::exists(at2xFileName))
return at2xFileName;
return fileName;
} else {
if (QFile::exists(themedFileName))
return themedFileName;
return fileName;
}
} }
QPair<QColor, QString> Theme::readNamedColor(const QString &color) const QPair<QColor, QString> Theme::readNamedColor(const QString &color) const
...@@ -143,11 +103,6 @@ QPair<QColor, QString> Theme::readNamedColor(const QString &color) const ...@@ -143,11 +103,6 @@ QPair<QColor, QString> Theme::readNamedColor(const QString &color) const
return qMakePair(QColor::fromRgba(rgba), QString()); return qMakePair(QColor::fromRgba(rgba), QString());
} }
QString Theme::imageFile(const QString &fileName) const
{
return fileName;
}
QString Theme::fileName() const QString Theme::fileName() const
{ {
return d->fileName; return d->fileName;
...@@ -202,6 +157,17 @@ void Theme::writeSettings(const QString &filename) const ...@@ -202,6 +157,17 @@ void Theme::writeSettings(const QString &filename) const
} }
settings.endGroup(); 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")); settings.beginGroup(QLatin1String("Gradients"));
const QMetaEnum e = m.enumerator(m.indexOfEnumerator("GradientRole")); const QMetaEnum e = m.enumerator(m.indexOfEnumerator("GradientRole"));
...@@ -220,15 +186,6 @@ void Theme::writeSettings(const QString &filename) const ...@@ -220,15 +186,6 @@ void Theme::writeSettings(const QString &filename) const
} }
settings.endGroup(); settings.endGroup();
} }
{
settings.beginGroup(QLatin1String("IconOverlay"));
const QMetaEnum e = m.enumerator(m.indexOfEnumerator("MimeType"));
for (int i = 0, total = e.keyCount(); i < total; ++i) {
const QString key = QLatin1String(e.key(i));
settings.setValue(key, iconOverlay(static_cast<Theme::MimeType>(i)));
}
settings.endGroup();
}
{ {
settings.beginGroup(QLatin1String("Flags")); settings.beginGroup(QLatin1String("Flags"));
const QMetaEnum e = m.enumerator(m.indexOfEnumerator("Flag")); const QMetaEnum e = m.enumerator(m.indexOfEnumerator("Flag"));
...@@ -280,6 +237,15 @@ void Theme::readSettings(QSettings &settings) ...@@ -280,6 +237,15 @@ void Theme::readSettings(QSettings &settings)
} }
settings.endGroup(); settings.endGroup();
} }
{
settings.beginGroup(QLatin1String("ImageFiles"));
QMetaEnum e = m.enumerator(m.indexOfEnumerator("ImageFile"));
for (int i = 0, total = e.keyCount(); i < total; ++i) {
const QString key = QLatin1String(e.key(i));
d->imageFiles[i] = settings.value(key).toString();
}
settings.endGroup();
}
{ {
settings.beginGroup(QLatin1String("Gradients")); settings.beginGroup(QLatin1String("Gradients"));
QMetaEnum e = m.enumerator(m.indexOfEnumerator("GradientRole")); QMetaEnum e = m.enumerator(m.indexOfEnumerator("GradientRole"));
...@@ -300,16 +266,6 @@ void Theme::readSettings(QSettings &settings) ...@@ -300,16 +266,6 @@ void Theme::readSettings(QSettings &settings)
} }
settings.endGroup(); settings.endGroup();
} }
{
settings.beginGroup(QLatin1String("IconOverlay"));
QMetaEnum e = m.enumerator(m.indexOfEnumerator("MimeType"));
for (int i = 0, total = e.keyCount(); i < total; ++i) {
const QString key = QLatin1String(e.key(i));
QTC_ASSERT(settings.contains(key), return);;
d->iconOverlays[i] = settings.value(key).toString();
}
settings.endGroup();
}
{ {
settings.beginGroup(QLatin1String("Flags")); settings.beginGroup(QLatin1String("Flags"));
QMetaEnum e = m.enumerator(m.indexOfEnumerator("Flag")); QMetaEnum e = m.enumerator(m.indexOfEnumerator("Flag"));
...@@ -322,14 +278,6 @@ void Theme::readSettings(QSettings &settings) ...@@ -322,14 +278,6 @@ void Theme::readSettings(QSettings &settings)
} }
} }
QIcon Theme::standardIcon(QStyle::StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget) const
{
Q_UNUSED(standardPixmap);
Q_UNUSED(opt);
Q_UNUSED(widget);
return QIcon();
}
QPalette Theme::palette(const QPalette &base) const QPalette Theme::palette(const QPalette &base) const
{ {
if (!flag(DerivePaletteFromTheme)) if (!flag(DerivePaletteFromTheme))
......
...@@ -47,6 +47,7 @@ class QTCREATOR_UTILS_EXPORT Theme : public QObject ...@@ -47,6 +47,7 @@ class QTCREATOR_UTILS_EXPORT Theme : public QObject
Q_OBJECT Q_OBJECT
Q_ENUMS(ColorRole) Q_ENUMS(ColorRole)
Q_ENUMS(ImageFile)
Q_ENUMS(GradientRole) Q_ENUMS(GradientRole)
Q_ENUMS(MimeType) Q_ENUMS(MimeType)
Q_ENUMS(Flag) Q_ENUMS(Flag)
...@@ -159,13 +160,22 @@ public: ...@@ -159,13 +160,22 @@ public:
Welcome_Button_GradientPressed Welcome_Button_GradientPressed
}; };
enum MimeType { enum ImageFile {
CppSourceMimetype, ProjectExplorerHeader,
CSourceMimetype, ProjectExplorerSource,
CppHeaderMimetype, ProjectExplorerForm,
ProMimetype, ProjectExplorerResource,
PriMimetype, ProjectExplorerQML,
PrfMimetype ProjectExplorerOtherFiles,
ProjectFileIcon,
IconOverlayCSource,
IconOverlayCppHeader,
IconOverlayCppSource,
IconOverlayPri,
IconOverlayPrf,
IconOverlayPro,
StandardPixmapFileIcon,
StandardPixmapDirIcon
}; };
enum Flag { enum Flag {
...@@ -185,13 +195,9 @@ public: ...@@ -185,13 +195,9 @@ public:
WidgetStyle widgetStyle() const; WidgetStyle widgetStyle() const;
bool flag(Flag f) const; bool flag(Flag f) const;
QColor color(ColorRole role) const; QColor color(ColorRole role) const;
QString imageFile(ImageFile imageFile, const QString &fallBack) const;
QGradientStops gradient(GradientRole role) const; QGradientStops gradient(GradientRole role) const;
QString iconOverlay(MimeType mimetype) const;
QPalette palette(const QPalette &base) const; QPalette palette(const QPalette &base) const;
QString dpiSpecificImageFile(const QString &fileName) const;
void drawIndicatorBranch(QPainter *painter, const QRect &rect, QStyle::State state) const;
QIcon standardIcon(QStyle::StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget) const;
QString imageFile(const QString &fileName) const;
QString fileName() const; QString fileName() const;
void setName(const QString &name); void setName(const QString &name);
...@@ -203,9 +209,6 @@ public: ...@@ -203,9 +209,6 @@ public:
signals: signals:
void changed(); void changed();
protected:
QString dpiSpecificImageFile(const QString &fileName, const QString &themePrefix) const;
private: private:
QPair<QColor, QString> readNamedColor(const QString &color) const; QPair<QColor, QString> readNamedColor(const QString &color) const;
}; };
......
...@@ -39,8 +39,8 @@ ThemePrivate::ThemePrivate() ...@@ -39,8 +39,8 @@ ThemePrivate::ThemePrivate()
{ {
const QMetaObject &m = Theme::staticMetaObject; const QMetaObject &m = Theme::staticMetaObject;
colors.resize (m.enumerator(m.indexOfEnumerator("ColorRole")).keyCount()); colors.resize (m.enumerator(m.indexOfEnumerator("ColorRole")).keyCount());
imageFiles.resize (m.enumerator(m.indexOfEnumerator("ImageFile")).keyCount());
gradientStops.resize (m.enumerator(m.indexOfEnumerator("GradientRole")).keyCount()); gradientStops.resize (m.enumerator(m.indexOfEnumerator("GradientRole")).keyCount());
iconOverlays.resize (m.enumerator(m.indexOfEnumerator("MimeType")).keyCount());
flags.resize (m.enumerator(m.indexOfEnumerator("Flag")).keyCount()); flags.resize (m.enumerator(m.indexOfEnumerator("Flag")).keyCount());
} }
......
...@@ -47,7 +47,7 @@ public: ...@@ -47,7 +47,7 @@ public:
QString fileName; QString fileName;
QString name; QString name;
QVector<QPair<QColor, QString> > colors; QVector<QPair<QColor, QString> > colors;
QVector<QString> iconOverlays; QVector<QString> imageFiles;
QVector<QGradientStops> gradientStops; QVector<QGradientStops> gradientStops;
QVector<bool> flags; QVector<bool> flags;
Theme::WidgetStyle widgetStyle; Theme::WidgetStyle widgetStyle;
......
...@@ -314,12 +314,17 @@ void ManhattanStyle::polish(QPalette &pal) ...@@ -314,12 +314,17 @@ void ManhattanStyle::polish(QPalette &pal)
QProxyStyle::polish(pal); QProxyStyle::polish(pal);
} }
QIcon ManhattanStyle::standardIcon(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget) const QIcon ManhattanStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const
{ {
QIcon ico = creatorTheme()->standardIcon(standardPixmap, opt, widget); QIcon icon;
if (!ico.isNull()) switch (standardIcon) {
return ico; case QStyle::SP_TitleBarCloseButton:
return QProxyStyle::standardIcon(standardPixmap, opt, widget); case QStyle::SP_ToolBarHorizontalExtensionButton:
return QIcon(standardPixmap(standardIcon, option, widget));
default:
icon = baseStyle()->standardIcon(standardIcon, option, widget);
}
return icon;
} }
QPixmap ManhattanStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, QPixmap ManhattanStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
...@@ -376,13 +381,8 @@ int ManhattanStyle::styleHint(StyleHint hint, const QStyleOption *option, const ...@@ -376,13 +381,8 @@ int ManhattanStyle::styleHint(StyleHint hint, const QStyleOption *option, const
void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option,
QPainter *painter, const QWidget *widget) const QPainter *painter, const QWidget *widget) const
{ {
if (!panelWidget(widget)) { if (!panelWidget(widget))
if (creatorTheme()->flag(Theme::DrawIndicatorBranch) && element == PE_IndicatorBranch) {
creatorTheme()->drawIndicatorBranch(painter, option->rect, option->state);
return;
}
return QProxyStyle::drawPrimitive(element, option, painter, widget); return QProxyStyle::drawPrimitive(element, option, painter, widget);
}
bool animating = (option->state & State_Animating); bool animating = (option->state & State_Animating);
int state = option->state; int state = option->state;
......
...@@ -56,7 +56,6 @@ public: ...@@ -56,7 +56,6 @@ public:
SubControl hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option, const QPoint &pos, const QWidget *widget = 0) const; SubControl hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option, const QPoint &pos, const QWidget *widget = 0) const;
QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget = 0) const; QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget = 0) const;
QIcon standardIcon(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget = 0) const;
int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const; int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const;
QRect itemRect(QPainter *p, const QRect &r, int flags, bool enabled, const QPixmap *pixmap, const QString &text, int len = -1) const; QRect itemRect(QPainter *p, const QRect &r, int flags, bool enabled, const QPixmap *pixmap, const QString &text, int len = -1) const;
QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const; QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const;
...@@ -72,6 +71,9 @@ public: ...@@ -72,6 +71,9 @@ public:
void unpolish(QWidget *widget); void unpolish(QWidget *widget);
void unpolish(QApplication *app); void unpolish(QApplication *app);
protected slots:
QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const;
private: private:
void drawButtonSeparator(QPainter *painter, const QRect &rect, bool reverse) const; void drawButtonSeparator(QPainter *painter, const QRect &rect, bool reverse) const;
......
...@@ -65,7 +65,7 @@ int ThemeSettingsTableModel::sectionRowCount(int section) const ...@@ -65,7 +65,7 @@ int ThemeSettingsTableModel::sectionRowCount(int section) const
case SectionWidgetStyle: return 1; case SectionWidgetStyle: return 1;
case SectionColors: return m_colors->numColorRoles(); case SectionColors: return m_colors->numColorRoles();
case SectionFlags: return m_flags.size(); case SectionFlags: return m_flags.size();
case SectionIconOverlays: return m_iconOverlays.size(); case SectionImageFiles: return m_imageFiles.size();
default: return 0; default: return 0;
} }
} }
...@@ -110,11 +110,11 @@ QVariant ThemeSettingsTableModel::sectionBodyData(int section, int row, int colu ...@@ -110,11 +110,11 @@ QVariant ThemeSettingsTableModel::sectionBodyData(int section, int row, int colu
return QVariant::fromValue(makeDecoration(Qt::transparent)); return QVariant::fromValue(makeDecoration(Qt::transparent));
return QVariant(); return QVariant();
} }
case SectionIconOverlays: { case SectionImageFiles: {
if (column == 0 && role == Qt::DisplayRole) if (column == 0 && role == Qt::DisplayRole)
return m_iconOverlays[row].first; return m_imageFiles[row].first;
else if (column == 1 && role == Qt::DisplayRole) else if (column == 1 && role == Qt::DisplayRole)
return m_iconOverlays[row].second; return m_imageFiles[row].second;
else if (column == 0 && role == Qt::DecorationRole) else if (column == 0 && role == Qt::DecorationRole)
return QVariant::fromValue(makeDecoration(Qt::transparent)); return QVariant::fromValue(makeDecoration(Qt::transparent));
return QVariant(); return QVariant();
...@@ -131,7 +131,7 @@ QVariant ThemeSettingsTableModel::sectionHeaderData(int section, int role) const ...@@ -131,7 +131,7 @@ QVariant ThemeSettingsTableModel::sectionHeaderData(int section, int role) const
case SectionWidgetStyle: return tr("Widget Style"); case SectionWidgetStyle: return tr("Widget Style");
case SectionColors: return tr("Colors"); case SectionColors: return tr("Colors");
case SectionFlags: return tr("Flags"); case SectionFlags: return tr("Flags");
case SectionIconOverlays: return tr("Icon Overlays"); case SectionImageFiles: return tr("Image Files");
default: return QString(); default: return QString();
} }
} }
...@@ -159,7 +159,7 @@ Qt::ItemFlags ThemeSettingsTableModel::sectionBodyFlags(int section, int row, in ...@@ -159,7 +159,7 @@ Qt::ItemFlags ThemeSettingsTableModel::sectionBodyFlags(int section, int row, in
case SectionFlags: case SectionFlags:
return (column == 0) ? Qt::ItemIsEnabled return (column == 0) ? Qt::ItemIsEnabled
: Qt::ItemIsEnabled | Qt::ItemIsUserCheckable; : Qt::ItemIsEnabled | Qt::ItemIsUserCheckable;
case SectionIconOverlays: case SectionImageFiles:
return Qt::ItemIsEnabled; return Qt::ItemIsEnabled;
default: return Qt::ItemIsEnabled; default: return Qt::ItemIsEnabled;
} }
...@@ -225,12 +225,12 @@ void ThemeSettingsTableModel::initFrom(Theme *theme) ...@@ -225,12 +225,12 @@ void ThemeSettingsTableModel::initFrom(Theme *theme)
m_flags.append(qMakePair(key, theme->flag(static_cast<Theme::Flag>(i)))); m_flags.append(qMakePair(key, theme->flag(static_cast<Theme::Flag>(i))));
} }
} }
// IconOverlays // ImageFiles
{ {
QMetaEnum e = metaObject.enumerator(metaObject.indexOfEnumerator("MimeType")); QMetaEnum e = metaObject.enumerator(metaObject.indexOfEnumerator("ImageFile"));
for (int i = 0, total = e.keyCount(); i < total; ++i) { for (int i = 0, total = e.keyCount(); i < total; ++i) {
const QString key = QLatin1String(e.key(i)); const QString key = QLatin1String(e.key(i));
m_iconOverlays.append(qMakePair(key, theme->iconOverlay(static_cast<Theme::MimeType>(i)))); m_imageFiles.append(qMakePair(key, theme->imageFile(static_cast<Theme::ImageFile>(i), QString())));
} }
} }
...@@ -256,12 +256,11 @@ void ThemeSettingsTableModel::toTheme(Theme *t) const ...@@ -256,12 +256,11 @@ void ThemeSettingsTableModel::toTheme(Theme *t) const
for (int i = 0; i < theme->flags.size(); ++i) for (int i = 0; i < theme->flags.size(); ++i)
theme->flags[i] = m_flags[i].second; theme->flags[i] = m_flags[i].second;
} }
// IconOveralys // ImageFiles
{ {
const int nOverlays = theme->iconOverlays.size(); const int nImageFiles = theme->imageFiles.size();
QTC_ASSERT(nOverlays == m_iconOverlays.size(), return); for (int i = 0; i < nImageFiles; ++i)
for (int i = 0; i < nOverlays; ++i) theme->imageFiles[i] = m_imageFiles.at(i).second;
theme->iconOverlays[i] = m_iconOverlays[i].second;
} }
theme->widgetStyle = m_widgetStyle; theme->widgetStyle = m_widgetStyle;
......
...@@ -52,7 +52,7 @@ public: ...@@ -52,7 +52,7 @@ public:
SectionWidgetStyle, SectionWidgetStyle,
SectionColors, SectionColors,
SectionFlags, SectionFlags,
SectionIconOverlays, SectionImageFiles,
SectionInvalid // end SectionInvalid // end
}; };
...@@ -82,7 +82,7 @@ public: ...@@ -82,7 +82,7 @@ public:
public: public:
ThemeColors::Ptr m_colors; ThemeColors::Ptr m_colors;
QList<QPair<QString, bool> > m_flags; QList<QPair<QString, bool> > m_flags;
QList<QPair<QString, QString> > m_iconOverlays; QList<QPair<QString, QString> > m_imageFiles;
Utils::Theme::WidgetStyle m_widgetStyle; Utils::Theme::WidgetStyle m_widgetStyle;
bool m_hasChanges; bool m_hasChanges;
}; };
......
...@@ -105,9 +105,15 @@ public: ...@@ -105,9 +105,15 @@ public:
addHoverHandler(new CppHoverHandler); addHoverHandler(new CppHoverHandler);
if (!Utils::HostOsInfo::isMacHost() && !Utils::HostOsInfo::isWindowsHost()) { if (!Utils::HostOsInfo::isMacHost() && !Utils::HostOsInfo::isWindowsHost()) {
FileIconProvider::registerIconOverlayForMimeType(creatorTheme()->iconOverlay(Theme::CppSourceMimetype).toLatin1().data(), Constants::CPP_SOURCE_MIMETYPE); FileIconProvider::registerIconOverlayForMimeType(
FileIconProvider::registerIconOverlayForMimeType(creatorTheme()->iconOverlay(Theme::CSourceMimetype).toLatin1().data(), Constants::C_SOURCE_MIMETYPE); QIcon(creatorTheme()->imageFile(Theme::IconOverlayCppSource, QLatin1String(":/cppeditor/images/qt_cpp.png"))),
FileIconProvider::registerIconOverlayForMimeType(creatorTheme()->iconOverlay(Theme::CppHeaderMimetype).toLatin1().data(), Constants::CPP_HEADER_MIMETYPE); Constants::CPP_SOURCE_MIMETYPE);
FileIconProvider::registerIconOverlayForMimeType(
QIcon(creatorTheme()->imageFile(Theme::IconOverlayCSource, QLatin1String(":/cppeditor/images/qt_c.png"))),
Constants::C_SOURCE_MIMETYPE);
FileIconProvider::registerIconOverlayForMimeType(
QIcon(creatorTheme()->imageFile(Theme::IconOverlayCppHeader, QLatin1String(":/cppeditor/images/qt_h.png"))),
Constants::CPP_HEADER_MIMETYPE);
} }
} }
}; };
......
...@@ -224,9 +224,13 @@ ProFileEditorFactory::ProFileEditorFactory() ...@@ -224,9 +224,13 @@ ProFileEditorFactory::ProFileEditorFactory()
addHoverHandler(new ProFileHoverHandler(keywords)); addHoverHandler(new ProFileHoverHandler(keywords));
setSyntaxHighlighterCreator([keywords]() { return new ProFileHighlighter(keywords); }); setSyntaxHighlighterCreator([keywords]() { return new ProFileHighlighter(keywords); });
Core::FileIconProvider::registerIconOverlayForSuffix(creatorTheme()->iconOverlay(Theme::ProMimetype).toLatin1().data(), "pro"); const QString defaultOverlay = QLatin1String(QtSupport::Constants::ICON_QT_PROJECT);
Core::FileIconProvider::registerIconOverlayForSuffix(creatorTheme()->iconOverlay(Theme::PriMimetype).toLatin1().data(), "pri"); Core::FileIconProvider::registerIconOverlayForSuffix(
Core::FileIconProvider::registerIconOverlayForSuffix(creatorTheme()->iconOverlay(Theme::PrfMimetype).toLatin1().data(), "prf"); creatorTheme()->imageFile(Theme::IconOverlayPro, defaultOverlay).toLatin1().data(), "pro");
Core::FileIconProvider::registerIconOverlayForSuffix(
creatorTheme()->imageFile(Theme::IconOverlayPri, defaultOverlay).toLatin1().data(), "pri");
Core::FileIconProvider::registerIconOverlayForSuffix(
creatorTheme()->imageFile(Theme::IconOverlayPrf, defaultOverlay).toLatin1().data(), "prf");
} }
} // namespace Internal } // namespace Internal
......
...@@ -84,27 +84,28 @@ struct FileTypeDataStorage { ...@@ -84,27 +84,28 @@ struct FileTypeDataStorage {
ProjectExplorer::FileType type; ProjectExplorer::FileType type;
const char *typeName; const char *typeName;
const char *icon; const char *icon;
Theme::ImageFile themeImage;
}; };