Commit 0788ec7f authored by Alessandro Portale's avatar Alessandro Portale

GlslEditor: Remove duplicated icons

This change makes GlslCompletionAssist reuse the equivalent icons
from CPlusPlus, and adds specific ones for "Attribute", "Uniform"
and "Varying".

Change-Id: Ic8860274a9f421d28cfec86ed0d1badb7e1cf92e
Reviewed-by: default avatarAlessandro Portale <alessandro.portale@theqtcompany.com>
parent 01f4e4a8
......@@ -78,6 +78,9 @@ IconsCodeModelFunctionColor=ffd34373
IconsCodeModelVariableColor=ff2bbbcc
IconsCodeModelEnumColor=ffc0b550
IconsCodeModelMacroColor=ff477ba0
IconsCodeModelAttributeColor=ff316511
IconsCodeModelUniformColor=ff994899
IconsCodeModelVaryingColor=ffa08833
IconsCodeModelOverlayBackgroundColor=88000000
IconsCodeModelOverlayForegroundColor=ffdcdcdc
InfoBarBackground=ff505000
......
......@@ -72,6 +72,9 @@ IconsCodeModelFunctionColor=fff36393
IconsCodeModelVariableColor=ff2bbbcc
IconsCodeModelEnumColor=ffc0b550
IconsCodeModelMacroColor=ff476ba0
IconsCodeModelAttributeColor=ff316511
IconsCodeModelUniformColor=ff994899
IconsCodeModelVaryingColor=ffa08833
IconsCodeModelOverlayBackgroundColor=70ffffff
IconsCodeModelOverlayForegroundColor=ff232425
InfoBarBackground=ffffffe1
......
......@@ -82,6 +82,9 @@ IconsCodeModelFunctionColor=ffd34373
IconsCodeModelVariableColor=ff2bbbcc
IconsCodeModelEnumColor=ffc0b550
IconsCodeModelMacroColor=ff476ba0
IconsCodeModelAttributeColor=ff316511
IconsCodeModelUniformColor=ff994899
IconsCodeModelVaryingColor=ffa08833
IconsCodeModelOverlayBackgroundColor=70ffffff
IconsCodeModelOverlayForegroundColor=ff232425
InfoBarBackground=ffffffe1
......
......@@ -160,6 +160,9 @@ public:
IconsCodeModelVariableColor,
IconsCodeModelEnumColor,
IconsCodeModelMacroColor,
IconsCodeModelAttributeColor,
IconsCodeModelUniformColor,
IconsCodeModelVaryingColor,
IconsCodeModelOverlayBackgroundColor,
IconsCodeModelOverlayForegroundColor,
......
......@@ -41,7 +41,9 @@
#include <texteditor/codeassist/genericproposal.h>
#include <texteditor/codeassist/functionhintproposal.h>
#include <cplusplus/ExpressionUnderCursor.h>
#include <cplusplus/Icons.h>
#include <utils/icon.h>
#include <utils/faketooltip.h>
#include <QIcon>
......@@ -138,6 +140,57 @@ static bool checkStartOfIdentifier(const QString &word)
return false;
}
enum IconTypes {
IconTypeAttribute,
IconTypeUniform,
IconTypeKeyword,
IconTypeVarying,
IconTypeConst,
IconTypeVariable,
IconTypeType,
IconTypeFunction,
IconTypeOther
};
static QIcon glslIcon(IconTypes iconType)
{
using namespace CPlusPlus;
using namespace Utils;
const QString member = QLatin1String(":/codemodel/images/member.png");
switch (iconType) {
case IconTypeType:
return Icons::iconForType(Icons::ClassIconType);
case IconTypeConst:
return Icons::iconForType(Icons::EnumeratorIconType);
case IconTypeKeyword:
return Icons::iconForType(Icons::KeywordIconType);
case IconTypeFunction:
return Icons::iconForType(Icons::FuncPublicIconType);
case IconTypeVariable:
return Icons::iconForType(Icons::VarPublicIconType);
case IconTypeAttribute: {
static const QIcon icon =
Icon({{member, Theme::IconsCodeModelAttributeColor}}, Icon::Tint).icon();
return icon;
}
case IconTypeUniform: {
static const QIcon icon =
Icon({{member, Theme::IconsCodeModelUniformColor}}, Icon::Tint).icon();
return icon;
}
case IconTypeVarying: {
static const QIcon icon =
Icon({{member, Theme::IconsCodeModelVaryingColor}}, Icon::Tint).icon();
return icon;
}
case IconTypeOther:
default:
return Icons::iconForType(Icons::NamespaceIconType);
}
}
// ----------------------------
// GlslCompletionAssistProvider
// ----------------------------
......@@ -223,15 +276,6 @@ int GlslFunctionHintProposalModel::activeArgument(const QString &prefix) const
// -----------------------------
GlslCompletionAssistProcessor::GlslCompletionAssistProcessor()
: m_startPosition(0)
, m_keywordIcon(QLatin1String(":/glsleditor/images/keyword.png"))
, m_varIcon(QLatin1String(":/glsleditor/images/var.png"))
, m_functionIcon(QLatin1String(":/glsleditor/images/func.png"))
, m_typeIcon(QLatin1String(":/glsleditor/images/type.png"))
, m_constIcon(QLatin1String(":/glsleditor/images/const.png"))
, m_attributeIcon(QLatin1String(":/glsleditor/images/attribute.png"))
, m_uniformIcon(QLatin1String(":/glsleditor/images/uniform.png"))
, m_varyingIcon(QLatin1String(":/glsleditor/images/varying.png"))
, m_otherIcon(QLatin1String(":/glsleditor/images/other.png"))
{}
GlslCompletionAssistProcessor::~GlslCompletionAssistProcessor()
......@@ -385,9 +429,9 @@ IAssistProposal *GlslCompletionAssistProcessor::perform(const AssistInterface *i
0
};
for (int index = 0; attributeNames[index]; ++index)
m_completions << createCompletionItem(QString::fromLatin1(attributeNames[index]), m_attributeIcon);
m_completions << createCompletionItem(QString::fromLatin1(attributeNames[index]), glslIcon(IconTypeAttribute));
for (int index = 0; uniformNames[index]; ++index)
m_completions << createCompletionItem(QString::fromLatin1(uniformNames[index]), m_uniformIcon);
m_completions << createCompletionItem(QString::fromLatin1(uniformNames[index]), glslIcon(IconTypeUniform));
}
}
......@@ -395,7 +439,7 @@ IAssistProposal *GlslCompletionAssistProcessor::perform(const AssistInterface *i
QStringList keywords = GLSL::Lexer::keywords(languageVariant(m_interface->mimeType()));
// m_keywordCompletions.clear();
for (int index = 0; index < keywords.size(); ++index)
m_completions << createCompletionItem(keywords.at(index), m_keywordIcon);
m_completions << createCompletionItem(keywords.at(index), glslIcon(IconTypeKeyword));
// m_keywordVariant = languageVariant(m_interface->mimeType());
// }
......@@ -408,23 +452,23 @@ IAssistProposal *GlslCompletionAssistProcessor::perform(const AssistInterface *i
if (var) {
int storageType = var->qualifiers() & GLSL::QualifiedTypeAST::StorageMask;
if (storageType == GLSL::QualifiedTypeAST::Attribute)
icon = m_attributeIcon;
icon = glslIcon(IconTypeAttribute);
else if (storageType == GLSL::QualifiedTypeAST::Uniform)
icon = m_uniformIcon;
icon = glslIcon(IconTypeUniform);
else if (storageType == GLSL::QualifiedTypeAST::Varying)
icon = m_varyingIcon;
icon = glslIcon(IconTypeVarying);
else if (storageType == GLSL::QualifiedTypeAST::Const)
icon = m_constIcon;
icon = glslIcon(IconTypeConst);
else
icon = m_varIcon;
icon = glslIcon(IconTypeVariable);
} else if (s->asArgument()) {
icon = m_varIcon;
icon = glslIcon(IconTypeVariable);
} else if (s->asFunction() || s->asOverloadSet()) {
icon = m_functionIcon;
icon = glslIcon(IconTypeFunction);
} else if (s->asStruct()) {
icon = m_typeIcon;
icon = glslIcon(IconTypeType);
} else {
icon = m_otherIcon;
icon = glslIcon(IconTypeOther);
}
if (specialMembers.contains(s->name()))
m_completions << createCompletionItem(s->name(), icon, SpecialMemberOrder);
......
......@@ -34,7 +34,6 @@
#include <texteditor/codeassist/ifunctionhintproposalmodel.h>
#include <QIcon>
#include <QScopedPointer>
#include <QSharedPointer>
......@@ -107,16 +106,6 @@ private:
int m_startPosition;
QScopedPointer<const GlslCompletionAssistInterface> m_interface;
QIcon m_keywordIcon;
QIcon m_varIcon;
QIcon m_functionIcon;
QIcon m_typeIcon;
QIcon m_constIcon;
QIcon m_attributeIcon;
QIcon m_uniformIcon;
QIcon m_varyingIcon;
QIcon m_otherIcon;
};
class GlslCompletionAssistInterface : public TextEditor::AssistInterface
......
......@@ -2,14 +2,5 @@
<qresource prefix="/glsleditor">
<file>GLSLEditor.mimetypes.xml</file>
<file>images/glslfile.png</file>
<file>images/keyword.png</file>
<file>images/var.png</file>
<file>images/func.png</file>
<file>images/type.png</file>
<file>images/const.png</file>
<file>images/attribute.png</file>
<file>images/uniform.png</file>
<file>images/varying.png</file>
<file>images/other.png</file>
</qresource>
</RCC>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment