Editor: Tooltips for color scheme items

in Fonts & collors settingspage

Change-Id: Ia067e86a31a12301458a5d49e1096e7b2aa0f118
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
David Schulz
2012-08-27 10:55:13 +02:00
committed by hjk
parent 966c82d212
commit 813cd709fb
4 changed files with 134 additions and 58 deletions

View File

@@ -115,6 +115,9 @@ public:
font.setItalic(m_scheme->formatFor(description.id()).italic()); font.setItalic(m_scheme->formatFor(description.id()).italic());
return font; return font;
} }
case Qt::ToolTipRole: {
return description.tooltipText();
}
} }
return QVariant(); return QVariant();
} }

View File

@@ -228,17 +228,19 @@ FontSettingsPagePrivate::~FontSettingsPagePrivate()
// ------- FormatDescription // ------- FormatDescription
FormatDescription::FormatDescription(TextStyle id, const QString &displayName, const QColor &color) : FormatDescription::FormatDescription(TextStyle id, const QString &displayName, const QString &tooltipText, const QColor &foreground) :
m_id(id),
m_displayName(displayName)
{
m_format.setForeground(color);
}
FormatDescription::FormatDescription(TextStyle id, const QString &displayName, const Format &format) :
m_id(id), m_id(id),
m_displayName(displayName), m_displayName(displayName),
m_format(format) m_tooltipText(tooltipText)
{
m_format.setForeground(foreground);
}
FormatDescription::FormatDescription(TextStyle id, const QString &displayName, const QString &tooltipText, const Format &format) :
m_id(id),
m_displayName(displayName),
m_format(format),
m_tooltipText(tooltipText)
{ {
} }

View File

@@ -56,9 +56,9 @@ class FontSettingsPagePrivate;
class TEXTEDITOR_EXPORT FormatDescription class TEXTEDITOR_EXPORT FormatDescription
{ {
public: public:
FormatDescription(TextStyle id, const QString &displayName, FormatDescription(TextStyle id, const QString &displayName, const QString &tooltipText,
const QColor &foreground = Qt::black); const QColor &foreground = Qt::black);
FormatDescription(TextStyle id, const QString &displayName, FormatDescription(TextStyle id, const QString &displayName, const QString &tooltipText,
const Format &format); const Format &format);
TextStyle id() const { return m_id; } TextStyle id() const { return m_id; }
@@ -72,10 +72,14 @@ public:
const Format &format() const { return m_format; } const Format &format() const { return m_format; }
Format &format() { return m_format; } Format &format() { return m_format; }
QString tooltipText() const
{ return m_tooltipText; }
private: private:
TextStyle m_id; // Name of the category TextStyle m_id; // Name of the category
QString m_displayName; // Displayed name of the category QString m_displayName; // Displayed name of the category
Format m_format; // Default format Format m_format; // Default format
QString m_tooltipText; // Description text for category
}; };
typedef QList<FormatDescription> FormatDescriptions; typedef QList<FormatDescription> FormatDescriptions;

View File

@@ -112,84 +112,151 @@ TextEditorSettings::TextEditorSettings(QObject *parent)
// Note: default background colors are coming from FormatDescription::background() // Note: default background colors are coming from FormatDescription::background()
// Add font preference page // Add font preference page
FormatDescriptions formatDescriptions; FormatDescriptions formatDescr;
formatDescriptions.append(FormatDescription(C_TEXT, tr("Text"))); formatDescr.append(FormatDescription(C_TEXT, tr("Text"), tr("Generic text.\nApplied for "
"text, if no other "
"rules matching.")));
// Special categories // Special categories
const QPalette p = QApplication::palette(); const QPalette p = QApplication::palette();
formatDescriptions.append(FormatDescription(C_LINK, tr("Link"), Qt::blue)); formatDescr.append(FormatDescription(C_LINK, tr("Link"),
formatDescriptions.append(FormatDescription(C_SELECTION, tr("Selection"), p.color(QPalette::HighlightedText))); tr("Links that follow symbol under cursor."), Qt::blue));
formatDescriptions.append(FormatDescription(C_LINE_NUMBER, tr("Line Number"))); formatDescr.append(FormatDescription(C_SELECTION, tr("Selection"), tr("Selected text."),
formatDescriptions.append(FormatDescription(C_SEARCH_RESULT, tr("Search Result"))); p.color(QPalette::HighlightedText)));
formatDescriptions.append(FormatDescription(C_SEARCH_SCOPE, tr("Search Scope"))); formatDescr.append(FormatDescription(C_LINE_NUMBER, tr("Line Number"),
formatDescriptions.append(FormatDescription(C_PARENTHESES, tr("Parentheses"))); tr("Line numbers located on the "
formatDescriptions.append(FormatDescription(C_CURRENT_LINE, tr("Current Line"))); "left side of the editor.")));
formatDescr.append(FormatDescription(C_SEARCH_RESULT, tr("Search Result"),
tr("Highlighted search results inside the editor.")));
formatDescr.append(FormatDescription(C_SEARCH_SCOPE, tr("Search Scope"),
tr("Section where the pattern is searched in.")));
formatDescr.append(FormatDescription(C_PARENTHESES, tr("Parentheses"),
tr("Displayed when matching parantheses, square brackets "
"or curly brackets are found.")));
formatDescr.append(FormatDescription(C_CURRENT_LINE, tr("Current Line"),
tr("Line where the cursor is placed in.")));
FormatDescription currentLineNumber = FormatDescription(C_CURRENT_LINE_NUMBER, tr("Current Line Number"), Qt::darkGray); FormatDescription currentLineNumber =
FormatDescription(C_CURRENT_LINE_NUMBER, tr("Current Line Number"),
tr("Line number located on the left side of the "
"editor where the cursor is placed in."), Qt::darkGray);
currentLineNumber.format().setBold(true); currentLineNumber.format().setBold(true);
formatDescriptions.append(currentLineNumber); formatDescr.append(currentLineNumber);
formatDescriptions.append(FormatDescription(C_OCCURRENCES, tr("Occurrences")));
formatDescriptions.append(FormatDescription(C_OCCURRENCES_UNUSED, tr("Unused Occurrence"))); formatDescr.append(FormatDescription(C_OCCURRENCES, tr("Occurrences"),
formatDescriptions.append(FormatDescription(C_OCCURRENCES_RENAME, tr("Renaming Occurrence"))); tr("Occurences of the symbol under the cursor.\n"
"(Only the backgroud will be applied.)")));
formatDescr.append(FormatDescription(C_OCCURRENCES_UNUSED, tr("Unused Occurrence"),
tr("Occurences of unused variables.")));
formatDescr.append(FormatDescription(C_OCCURRENCES_RENAME, tr("Renaming Occurrence"),
tr("Occurences of a symbol that will be renamed.")));
// Standard categories // Standard categories
formatDescriptions.append(FormatDescription(C_NUMBER, tr("Number"), Qt::darkBlue)); formatDescr.append(FormatDescription(C_NUMBER, tr("Number"), tr("Number literal."),
formatDescriptions.append(FormatDescription(C_STRING, tr("String"), Qt::darkGreen)); Qt::darkBlue));
formatDescriptions.append(FormatDescription(C_TYPE, tr("Type"), Qt::darkMagenta)); formatDescr.append(FormatDescription(C_STRING, tr("String"),
formatDescriptions.append(FormatDescription(C_LOCAL, tr("Local"))); tr("Character and string literals."), Qt::darkGreen));
formatDescriptions.append(FormatDescription(C_FIELD, tr("Field"), Qt::darkRed)); formatDescr.append(FormatDescription(C_TYPE, tr("Type"), tr("Name of a type."),
formatDescriptions.append(FormatDescription(C_ENUMERATION, tr("Enumeration"), Qt::darkMagenta)); Qt::darkMagenta));
formatDescr.append(FormatDescription(C_LOCAL, tr("Local"), tr("Local variables.")));
formatDescr.append(FormatDescription(C_FIELD, tr("Field"),
tr("Class' data members."), Qt::darkRed));
formatDescr.append(FormatDescription(C_ENUMERATION, tr("Enumeration"),
tr("Applied for Enumeration Items."), Qt::darkMagenta));
Format functionFormat; Format functionFormat;
formatDescriptions.append(FormatDescription(C_FUNCTION, tr("Function"), functionFormat)); formatDescr.append(FormatDescription(C_FUNCTION, tr("Function"), tr("Name of a function."),
functionFormat));
functionFormat.setItalic(true); functionFormat.setItalic(true);
formatDescriptions.append(FormatDescription(C_VIRTUAL_METHOD, tr("Virtual Method"), functionFormat)); formatDescr.append(FormatDescription(C_VIRTUAL_METHOD, tr("Virtual Method"),
tr("Name of method declared as virtual."),
functionFormat));
formatDescriptions.append(FormatDescription(C_BINDING, tr("QML Binding"), Qt::darkRed)); formatDescr.append(FormatDescription(C_BINDING, tr("QML Binding"),
tr("QML item property, that allows a "
"binding to another property."),
Qt::darkRed));
Format qmlLocalNameFormat; Format qmlLocalNameFormat;
qmlLocalNameFormat.setItalic(true); qmlLocalNameFormat.setItalic(true);
formatDescriptions.append(FormatDescription(C_QML_LOCAL_ID, tr("QML Local Id"), qmlLocalNameFormat)); formatDescr.append(FormatDescription(C_QML_LOCAL_ID, tr("QML Local Id"),
formatDescriptions.append(FormatDescription(C_QML_ROOT_OBJECT_PROPERTY, tr("QML Root Object Property"), qmlLocalNameFormat)); tr("QML item id within a QML file."), qmlLocalNameFormat));
formatDescriptions.append(FormatDescription(C_QML_SCOPE_OBJECT_PROPERTY, tr("QML Scope Object Property"), qmlLocalNameFormat)); formatDescr.append(FormatDescription(C_QML_ROOT_OBJECT_PROPERTY,
formatDescriptions.append(FormatDescription(C_QML_STATE_NAME, tr("QML State Name"), qmlLocalNameFormat)); tr("QML root Object Property"),
tr("QML property of a parent item."), qmlLocalNameFormat));
formatDescr.append(FormatDescription(C_QML_SCOPE_OBJECT_PROPERTY,
tr("QML scope Object Property"),
tr("Property of the same QML item."), qmlLocalNameFormat));
formatDescr.append(FormatDescription(C_QML_STATE_NAME, tr("QML State Name"),
tr("Name of a QML state."), qmlLocalNameFormat));
formatDescriptions.append(FormatDescription(C_QML_TYPE_ID, tr("QML Type Name"), Qt::darkMagenta)); formatDescr.append(FormatDescription(C_QML_TYPE_ID, tr("QML Type Name"),
tr("Name of a QML type."), Qt::darkMagenta));
Format qmlExternalNameFormat = qmlLocalNameFormat; Format qmlExternalNameFormat = qmlLocalNameFormat;
qmlExternalNameFormat.setForeground(Qt::darkBlue); qmlExternalNameFormat.setForeground(Qt::darkBlue);
formatDescriptions.append(FormatDescription(C_QML_EXTERNAL_ID, tr("QML External Id"), qmlExternalNameFormat)); formatDescr.append(FormatDescription(C_QML_EXTERNAL_ID, tr("QML External Id"),
formatDescriptions.append(FormatDescription(C_QML_EXTERNAL_OBJECT_PROPERTY, tr("QML External Object Property"), qmlExternalNameFormat)); tr("QML id defined in another QML file."),
qmlExternalNameFormat));
formatDescr.append(FormatDescription(C_QML_EXTERNAL_OBJECT_PROPERTY,
tr("QML External Object Property"),
tr("QML property defined in another QML file."),
qmlExternalNameFormat));
Format jsLocalFormat; Format jsLocalFormat;
jsLocalFormat.setForeground(QColor(41, 133, 199)); // very light blue jsLocalFormat.setForeground(QColor(41, 133, 199)); // very light blue
jsLocalFormat.setItalic(true); jsLocalFormat.setItalic(true);
formatDescriptions.append(FormatDescription(C_JS_SCOPE_VAR, tr("JavaScript Scope Var"), jsLocalFormat)); formatDescr.append(FormatDescription(C_JS_SCOPE_VAR, tr("JavaScript Scope Var"),
tr("Variables defined inside the JavaScript file."),
jsLocalFormat));
Format jsGlobalFormat; Format jsGlobalFormat;
jsGlobalFormat.setForeground(QColor(0, 85, 175)); // light blue jsGlobalFormat.setForeground(QColor(0, 85, 175)); // light blue
jsGlobalFormat.setItalic(true); jsGlobalFormat.setItalic(true);
formatDescriptions.append(FormatDescription(C_JS_IMPORT_VAR, tr("JavaScript Import"), jsGlobalFormat)); formatDescr.append(FormatDescription(C_JS_IMPORT_VAR, tr("JavaScript Import"),
formatDescriptions.append(FormatDescription(C_JS_GLOBAL_VAR, tr("JavaScript Global Variable"), jsGlobalFormat)); tr("Name of a JavaScript import inside a QML file."),
jsGlobalFormat));
formatDescr.append(FormatDescription(C_JS_GLOBAL_VAR, tr("JavaScript Global Variable"),
tr("Variables defined outside the script."),
jsGlobalFormat));
formatDescriptions.append(FormatDescription(C_KEYWORD, tr("Keyword"), Qt::darkYellow)); formatDescr.append(FormatDescription(C_KEYWORD, tr("Keyword"),
formatDescriptions.append(FormatDescription(C_OPERATOR, tr("Operator"))); tr("Reserved keywords of the programming language."),
formatDescriptions.append(FormatDescription(C_PREPROCESSOR, tr("Preprocessor"), Qt::darkBlue)); Qt::darkYellow));
formatDescriptions.append(FormatDescription(C_LABEL, tr("Label"), Qt::darkRed)); formatDescr.append(FormatDescription(C_OPERATOR, tr("Operator"),
formatDescriptions.append(FormatDescription(C_COMMENT, tr("Comment"), Qt::darkGreen)); tr("Operators. (for example operator++ operator-=)")));
formatDescriptions.append(FormatDescription(C_DOXYGEN_COMMENT, tr("Doxygen Comment"), Qt::darkBlue)); formatDescr.append(FormatDescription(C_PREPROCESSOR, tr("Preprocessor"),
formatDescriptions.append(FormatDescription(C_DOXYGEN_TAG, tr("Doxygen Tag"), Qt::blue)); tr("Preprocessor directives."), Qt::darkBlue));
formatDescriptions.append(FormatDescription(C_VISUAL_WHITESPACE, tr("Visual Whitespace"), Qt::lightGray)); formatDescr.append(FormatDescription(C_LABEL, tr("Label"), tr("Labels for goto steatments."),
formatDescriptions.append(FormatDescription(C_DISABLED_CODE, tr("Disabled Code"))); Qt::darkRed));
formatDescr.append(FormatDescription(C_COMMENT, tr("Comment"),
tr("All style of comments except Doxygen comments."),
Qt::darkGreen));
formatDescr.append(FormatDescription(C_DOXYGEN_COMMENT, tr("Doxygen Comment"),
tr("Doxygen comments."), Qt::darkBlue));
formatDescr.append(FormatDescription(C_DOXYGEN_TAG, tr("Doxygen Tag"), tr("Doxygen tags"),
Qt::blue));
formatDescr.append(FormatDescription(C_VISUAL_WHITESPACE, tr("Visual Whitespace"),
tr("Whitespace\nWill not be applied for whitespace "
"in comments and strings."), Qt::lightGray));
formatDescr.append(FormatDescription(C_DISABLED_CODE, tr("Disabled Code"),
tr("Code disabled by preprocessor directives.")));
// Diff categories // Diff categories
formatDescriptions.append(FormatDescription(C_ADDED_LINE, tr("Added Line"), QColor(0, 170, 0))); formatDescr.append(FormatDescription(C_ADDED_LINE, tr("Added Line"),
formatDescriptions.append(FormatDescription(C_REMOVED_LINE, tr("Removed Line"), Qt::red)); tr("Applied for added lines in differences "
formatDescriptions.append(FormatDescription(C_DIFF_FILE, tr("Diff File"), Qt::darkBlue)); "(in diff editor)."), QColor(0, 170, 0)));
formatDescriptions.append(FormatDescription(C_DIFF_LOCATION, tr("Diff Location"), Qt::blue)); formatDescr.append(FormatDescription(C_REMOVED_LINE, tr("Removed Line"),
tr("Applied for removed lines "
"in differences (in diff editor)."), Qt::red));
formatDescr.append(FormatDescription(C_DIFF_FILE, tr("Diff File"),
tr("Compared files (in diff editor)."), Qt::darkBlue));
formatDescr.append(FormatDescription(C_DIFF_LOCATION, tr("Diff Location"),
tr("Location in the files where the difference is "
"(in diff editor)."), Qt::blue));
m_d->m_fontSettingsPage = new FontSettingsPage(formatDescriptions, m_d->m_fontSettingsPage = new FontSettingsPage(formatDescr,
QLatin1String(Constants::TEXT_EDITOR_FONT_SETTINGS), QLatin1String(Constants::TEXT_EDITOR_FONT_SETTINGS),
this); this);
ExtensionSystem::PluginManager::addObject(m_d->m_fontSettingsPage); ExtensionSystem::PluginManager::addObject(m_d->m_fontSettingsPage);