Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Allow error indicator colors to be controlled for code editor color s…
…cheme
  • Loading branch information
nyalldawson committed Oct 13, 2020
1 parent b02d7b3 commit 0a3f40a
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 69 deletions.
1 change: 1 addition & 0 deletions images/images.qrc
Expand Up @@ -891,6 +891,7 @@
<file>themes/default/mActionLabelAnchorStart.svg</file>
<file>themes/default/transformation.svg</file>
<file>themes/default/mIconCodeEditor.svg</file>
<file>themes/default/console/iconSyntaxErrorConsoleParams.svg</file>
</qresource>
<qresource prefix="/images/tips">
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Expand Up @@ -54,6 +54,7 @@ Defines a color scheme for use in QgsCodeEditor widgets.
Edge,
Fold,
Error,
ErrorBackground,
FoldIconForeground,
FoldIconHalo,
IndentationGuide,
Expand Down
1 change: 1 addition & 0 deletions src/app/options/qgscodeeditoroptions.cpp
Expand Up @@ -66,6 +66,7 @@ QgsCodeEditorOptionsWidget::QgsCodeEditorOptionsWidget( QWidget *parent )
{QgsCodeEditorColorScheme::ColorRole::Edge, mColorEdge },
{QgsCodeEditorColorScheme::ColorRole::Fold, mColorFold },
{QgsCodeEditorColorScheme::ColorRole::Error, mColorError },
{QgsCodeEditorColorScheme::ColorRole::ErrorBackground, mColorErrorBackground },
{QgsCodeEditorColorScheme::ColorRole::FoldIconForeground, mColorFoldIcon },
{QgsCodeEditorColorScheme::ColorRole::FoldIconHalo, mColorFoldIconHalo },
{QgsCodeEditorColorScheme::ColorRole::IndentationGuide, mColorIndentation },
Expand Down
9 changes: 6 additions & 3 deletions src/gui/codeeditors/qgscodeeditor.cpp
Expand Up @@ -62,6 +62,7 @@ QMap< QgsCodeEditorColorScheme::ColorRole, QString > QgsCodeEditor::sColorRoleTo
{QgsCodeEditorColorScheme::ColorRole::Edge, QStringLiteral( "edgeColor" ) },
{QgsCodeEditorColorScheme::ColorRole::Fold, QStringLiteral( "foldColor" ) },
{QgsCodeEditorColorScheme::ColorRole::Error, QStringLiteral( "stderrFontColor" ) },
{QgsCodeEditorColorScheme::ColorRole::ErrorBackground, QStringLiteral( "stderrBackgroundColor" ) },
{QgsCodeEditorColorScheme::ColorRole::FoldIconForeground, QStringLiteral( "foldIconForeground" ) },
{QgsCodeEditorColorScheme::ColorRole::FoldIconHalo, QStringLiteral( "foldIconHalo" ) },
{QgsCodeEditorColorScheme::ColorRole::IndentationGuide, QStringLiteral( "indentationGuide" ) },
Expand Down Expand Up @@ -89,8 +90,6 @@ QgsCodeEditor::QgsCodeEditor( QWidget *parent, const QString &title, bool foldin
SendScintilla( SCI_SETMULTIPASTE, 1 );
SendScintilla( SCI_SETVIRTUALSPACEOPTIONS, SCVS_RECTANGULARSELECTION );

markerDefine( QgsApplication::getThemePixmap( "console/iconSyntaxErrorConsole.svg" ),
MARKER_NUMBER );
SendScintilla( SCI_SETMARGINTYPEN, 3, SC_MARGIN_SYMBOL );
SendScintilla( SCI_SETMARGINMASKN, 3, 1 << MARKER_NUMBER );
setMarginWidth( 3, 0 );
Expand Down Expand Up @@ -248,6 +247,9 @@ void QgsCodeEditor::setSciWidget()
// autocomplete
setAutoCompletionThreshold( 2 );
setAutoCompletionSource( QsciScintilla::AcsAPIs );

markerDefine( QgsApplication::getThemePixmap( "console/iconSyntaxErrorConsoleParams.svg", lexerColor( QgsCodeEditorColorScheme::ColorRole::Error ),
lexerColor( QgsCodeEditorColorScheme::ColorRole::ErrorBackground ), 16 ), MARKER_NUMBER );
}

void QgsCodeEditor::setTitle( const QString &title )
Expand Down Expand Up @@ -360,6 +362,7 @@ QColor QgsCodeEditor::defaultColor( QgsCodeEditorColorScheme::ColorRole role, co
{QgsCodeEditorColorScheme::ColorRole::Edge, QStringLiteral( "edgeColor" ) },
{QgsCodeEditorColorScheme::ColorRole::Fold, QStringLiteral( "foldColor" ) },
{QgsCodeEditorColorScheme::ColorRole::Error, QStringLiteral( "stderrFontColor" ) },
{QgsCodeEditorColorScheme::ColorRole::ErrorBackground, QStringLiteral( "stderrBackground" ) },
{QgsCodeEditorColorScheme::ColorRole::FoldIconForeground, QStringLiteral( "foldIconForeground" ) },
{QgsCodeEditorColorScheme::ColorRole::FoldIconHalo, QStringLiteral( "foldIconHalo" ) },
{QgsCodeEditorColorScheme::ColorRole::IndentationGuide, QStringLiteral( "indentationGuide" ) },
Expand Down Expand Up @@ -460,7 +463,7 @@ void QgsCodeEditor::addWarning( const int lineNumber, const QString &warning )
font.setItalic( true );
const QsciStyle styleAnn = QsciStyle( -1, QStringLiteral( "Annotation" ),
lexerColor( QgsCodeEditorColorScheme::ColorRole::Error ),
QColor( 255, 200, 0 ), // TODO - expose as configurable color!
lexerColor( QgsCodeEditorColorScheme::ColorRole::ErrorBackground ),
font,
true );
annotate( lineNumber, warning, styleAnn );
Expand Down
1 change: 1 addition & 0 deletions src/gui/codeeditors/qgscodeeditorcolorscheme.h
Expand Up @@ -67,6 +67,7 @@ class GUI_EXPORT QgsCodeEditorColorScheme
Edge, //!< Edge color
Fold, //!< Fold color
Error, //!< Error color
ErrorBackground, //!< Error background color
FoldIconForeground, //!< Fold icon foreground color
FoldIconHalo, //!< Fold icon halo color
IndentationGuide, //!< Indentation guide line
Expand Down
3 changes: 3 additions & 0 deletions src/gui/codeeditors/qgscodeeditorcolorschemeregistry.cpp
Expand Up @@ -52,6 +52,7 @@ QgsCodeEditorColorSchemeRegistry::QgsCodeEditorColorSchemeRegistry()
{QgsCodeEditorColorScheme::ColorRole::Edge, QColor( "#efefef" ) },
{QgsCodeEditorColorScheme::ColorRole::Fold, QColor( "#efefef" ) },
{QgsCodeEditorColorScheme::ColorRole::Error, QColor( "#e31a1c" ) },
{QgsCodeEditorColorScheme::ColorRole::ErrorBackground, QColor( "#ffffff" ) },
{QgsCodeEditorColorScheme::ColorRole::FoldIconForeground, QColor( "#ffffff" ) },
{QgsCodeEditorColorScheme::ColorRole::FoldIconHalo, QColor( "#000000" ) },
{QgsCodeEditorColorScheme::ColorRole::IndentationGuide, QColor( "#d5d5d5" ) },
Expand Down Expand Up @@ -92,6 +93,7 @@ QgsCodeEditorColorSchemeRegistry::QgsCodeEditorColorSchemeRegistry()
{QgsCodeEditorColorScheme::ColorRole::Edge, QColor( "#EEE8D5" ) },
{QgsCodeEditorColorScheme::ColorRole::Fold, QColor( "#EEE8D5" ) },
{QgsCodeEditorColorScheme::ColorRole::Error, QColor( "#DC322F" ) },
{QgsCodeEditorColorScheme::ColorRole::ErrorBackground, QColor( "#ffffff" ) },
{QgsCodeEditorColorScheme::ColorRole::FoldIconForeground, QColor( "#ffffff" ) },
{QgsCodeEditorColorScheme::ColorRole::FoldIconHalo, QColor( "#93a1a1" ) },
{QgsCodeEditorColorScheme::ColorRole::IndentationGuide, QColor( "#c2beb3" ) },
Expand Down Expand Up @@ -132,6 +134,7 @@ QgsCodeEditorColorSchemeRegistry::QgsCodeEditorColorSchemeRegistry()
{QgsCodeEditorColorScheme::ColorRole::Edge, QColor( "#586E75" ) },
{QgsCodeEditorColorScheme::ColorRole::Fold, QColor( "#073642" ) },
{QgsCodeEditorColorScheme::ColorRole::Error, QColor( "#DC322F" ) },
{QgsCodeEditorColorScheme::ColorRole::ErrorBackground, QColor( "#ffffff" ) },
{QgsCodeEditorColorScheme::ColorRole::FoldIconForeground, QColor( "#586e75" ) },
{QgsCodeEditorColorScheme::ColorRole::FoldIconHalo, QColor( "#839496" ) },
{QgsCodeEditorColorScheme::ColorRole::IndentationGuide, QColor( "#586E75" ) },
Expand Down
147 changes: 81 additions & 66 deletions src/ui/qgscodeditorsettings.ui
Expand Up @@ -297,13 +297,6 @@
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_8">
<item row="9" column="5">
<widget class="QgsColorButton" name="mColorFold">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="9" column="3">
<widget class="QgsColorButton" name="mColorMarginForeground">
<property name="text">
Expand Down Expand Up @@ -479,13 +472,6 @@
</property>
</widget>
</item>
<item row="10" column="5">
<widget class="QgsColorButton" name="mColorCaretLine">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="5">
<widget class="QgsColorButton" name="mColorNumber">
<property name="text">
Expand Down Expand Up @@ -535,13 +521,6 @@
</property>
</widget>
</item>
<item row="7" column="4">
<widget class="QLabel" name="label_38">
<property name="text">
<string>Indentation guide</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="5">
<widget class="QComboBox" name="mColorSchemeComboBox"/>
</item>
Expand All @@ -552,13 +531,6 @@
</property>
</widget>
</item>
<item row="7" column="5">
<widget class="QgsColorButton" name="mColorIndentation">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QLabel" name="label_26">
<property name="text">
Expand All @@ -580,13 +552,6 @@
</property>
</widget>
</item>
<item row="6" column="4">
<widget class="QLabel" name="label_21">
<property name="text">
<string>Comment line</string>
</property>
</widget>
</item>
<item row="5" column="3">
<widget class="QgsColorButton" name="mColorUnknownTag">
<property name="text">
Expand Down Expand Up @@ -615,13 +580,6 @@
</property>
</widget>
</item>
<item row="6" column="5">
<widget class="QgsColorButton" name="mColorCommentLine">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
Expand Down Expand Up @@ -664,13 +622,6 @@
</property>
</widget>
</item>
<item row="9" column="4">
<widget class="QLabel" name="label_39">
<property name="text">
<string>Fold guide</string>
</property>
</widget>
</item>
<item row="12" column="2">
<widget class="QLabel" name="label_52">
<property name="text">
Expand Down Expand Up @@ -734,13 +685,6 @@
</property>
</widget>
</item>
<item row="10" column="4">
<widget class="QLabel" name="label_22">
<property name="text">
<string>Caretline</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QgsColorButton" name="mColorMarginBackground">
<property name="text">
Expand All @@ -762,22 +706,92 @@
</property>
</widget>
</item>
<item row="8" column="4">
<item row="3" column="0">
<widget class="QLabel" name="label_23">
<property name="text">
<string>Operator</string>
</property>
</widget>
</item>
<item row="11" column="4">
<widget class="QLabel" name="label_22">
<property name="text">
<string>Caretline</string>
</property>
</widget>
</item>
<item row="11" column="5">
<widget class="QgsColorButton" name="mColorCaretLine">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="10" column="4">
<widget class="QLabel" name="label_39">
<property name="text">
<string>Fold guide</string>
</property>
</widget>
</item>
<item row="10" column="5">
<widget class="QgsColorButton" name="mColorFold">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="9" column="4">
<widget class="QLabel" name="label_40">
<property name="text">
<string>Edge guide</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_23">
<item row="9" column="5">
<widget class="QgsColorButton" name="mColorEdge">
<property name="text">
<string>Operator</string>
<string/>
</property>
</widget>
</item>
<item row="8" column="4">
<widget class="QLabel" name="label_38">
<property name="text">
<string>Indentation guide</string>
</property>
</widget>
</item>
<item row="8" column="5">
<widget class="QgsColorButton" name="mColorEdge">
<widget class="QgsColorButton" name="mColorIndentation">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="7" column="4">
<widget class="QLabel" name="label_21">
<property name="text">
<string>Comment line</string>
</property>
</widget>
</item>
<item row="7" column="5">
<widget class="QgsColorButton" name="mColorCommentLine">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="6" column="4">
<widget class="QLabel" name="label_34">
<property name="text">
<string>Error background</string>
</property>
</widget>
</item>
<item row="6" column="5">
<widget class="QgsColorButton" name="mColorErrorBackground">
<property name="text">
<string/>
</property>
Expand Down Expand Up @@ -865,21 +879,22 @@
<tabstop>mColorError</tabstop>
<tabstop>mColorComment</tabstop>
<tabstop>mColorCommentBlock</tabstop>
<tabstop>mColorCommentLine</tabstop>
<tabstop>mColorErrorBackground</tabstop>
<tabstop>mColorSingleQuote</tabstop>
<tabstop>mColorDoubleQuote</tabstop>
<tabstop>mColorIndentation</tabstop>
<tabstop>mColorCommentLine</tabstop>
<tabstop>mColorTripleSingleQuote</tabstop>
<tabstop>mColorTripleDoubleQuote</tabstop>
<tabstop>mColorEdge</tabstop>
<tabstop>mColorIndentation</tabstop>
<tabstop>mColorMarginBackground</tabstop>
<tabstop>mColorMarginForeground</tabstop>
<tabstop>mColorFold</tabstop>
<tabstop>mColorEdge</tabstop>
<tabstop>mColorSelectionBackground</tabstop>
<tabstop>mColorSelectionForeground</tabstop>
<tabstop>mColorCaretLine</tabstop>
<tabstop>mColorFold</tabstop>
<tabstop>mColorBraceBackground</tabstop>
<tabstop>mColorBraceForeground</tabstop>
<tabstop>mColorCaretLine</tabstop>
<tabstop>mColorFoldIcon</tabstop>
<tabstop>mColorFoldIconHalo</tabstop>
<tabstop>mListLanguage</tabstop>
Expand Down

0 comments on commit 0a3f40a

Please sign in to comment.