QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
qgscodeeditorcolorschemeregistry.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgscodeeditorcolorschemeregistry.cpp
3 --------------------------------------
4 Date : October 2020
5 Copyright : (C) 2020 by Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
16
17#include <QObject>
18
20{
21 QgsCodeEditorColorScheme defaultScheme( QStringLiteral( "default" ), QObject::tr( "Default" ) );
22 defaultScheme.setColors(
23 {
24 { QgsCodeEditorColorScheme::ColorRole::Default, QColor( "#4d4d4c" ) },
25 { QgsCodeEditorColorScheme::ColorRole::Keyword, QColor( "#8959a8" ) },
26 { QgsCodeEditorColorScheme::ColorRole::Class, QColor( "#4271ae" ) },
27 { QgsCodeEditorColorScheme::ColorRole::Method, QColor( "#4271ae" ) },
29 { QgsCodeEditorColorScheme::ColorRole::Number, QColor( "#c82829" ) },
30 { QgsCodeEditorColorScheme::ColorRole::Comment, QColor( "#8e908c" ) },
34 { QgsCodeEditorColorScheme::ColorRole::Operator, QColor( "#8959a8" ) },
38 { QgsCodeEditorColorScheme::ColorRole::Tag, QColor( "#4271ae" ) },
40 { QgsCodeEditorColorScheme::ColorRole::Cursor, QColor( "#636363" ) },
52 { QgsCodeEditorColorScheme::ColorRole::Edge, QColor( "#efefef" ) },
53 { QgsCodeEditorColorScheme::ColorRole::Fold, QColor( "#efefef" ) },
54 { QgsCodeEditorColorScheme::ColorRole::Error, QColor( "#e31a1c" ) },
60 }
61 );
62 addColorScheme( defaultScheme );
63
64 QgsCodeEditorColorScheme solarizedLight( QStringLiteral( "solarized" ), QObject::tr( "Solarized (Light)" ) );
65 solarizedLight.setColors(
66 {
67 { QgsCodeEditorColorScheme::ColorRole::Default, QColor( "#586E75" ) },
68 { QgsCodeEditorColorScheme::ColorRole::Keyword, QColor( "#859900" ) },
69 { QgsCodeEditorColorScheme::ColorRole::Class, QColor( "#268BD2" ) },
70 { QgsCodeEditorColorScheme::ColorRole::Method, QColor( "#268BD2" ) },
72 { QgsCodeEditorColorScheme::ColorRole::Number, QColor( "#2AA198" ) },
73 { QgsCodeEditorColorScheme::ColorRole::Comment, QColor( "#93A1A1" ) },
77 { QgsCodeEditorColorScheme::ColorRole::Cursor, QColor( "#DC322F" ) },
79 { QgsCodeEditorColorScheme::ColorRole::Operator, QColor( "#586E75" ) },
83 { QgsCodeEditorColorScheme::ColorRole::Tag, QColor( "#2AA198" ) },
95 { QgsCodeEditorColorScheme::ColorRole::Edge, QColor( "#EEE8D5" ) },
96 { QgsCodeEditorColorScheme::ColorRole::Fold, QColor( "#EEE8D5" ) },
97 { QgsCodeEditorColorScheme::ColorRole::Error, QColor( "#DC322F" ) },
103 }
104 );
105 addColorScheme( solarizedLight );
106
107 QgsCodeEditorColorScheme solarizedDark( QStringLiteral( "solarized_dark" ), QObject::tr( "Solarized (Dark)" ) );
108 solarizedDark.setColors(
109 {
110 { QgsCodeEditorColorScheme::ColorRole::Default, QColor( "#839496" ) },
111 { QgsCodeEditorColorScheme::ColorRole::Keyword, QColor( "#859900" ) },
112 { QgsCodeEditorColorScheme::ColorRole::Class, QColor( "#268BD2" ) },
113 { QgsCodeEditorColorScheme::ColorRole::Method, QColor( "#268BD2" ) },
115 { QgsCodeEditorColorScheme::ColorRole::Number, QColor( "#2AA198" ) },
116 { QgsCodeEditorColorScheme::ColorRole::Comment, QColor( "#2AA198" ) },
120 { QgsCodeEditorColorScheme::ColorRole::Cursor, QColor( "#DC322F" ) },
121 { QgsCodeEditorColorScheme::ColorRole::CaretLine, QColor( "#073642" ) },
122 { QgsCodeEditorColorScheme::ColorRole::Operator, QColor( "#839496" ) },
126 { QgsCodeEditorColorScheme::ColorRole::Tag, QColor( "#268BD2" ) },
138 { QgsCodeEditorColorScheme::ColorRole::Edge, QColor( "#586E75" ) },
139 { QgsCodeEditorColorScheme::ColorRole::Fold, QColor( "#073642" ) },
140 { QgsCodeEditorColorScheme::ColorRole::Error, QColor( "#DC322F" ) },
146 }
147 );
148 addColorScheme( solarizedDark );
149}
150
152{
153 if ( mColorSchemes.contains( scheme.id() ) )
154 return false;
155
156 mColorSchemes.insert( scheme.id(), scheme );
157 return true;
158}
159
161{
162 if ( !mColorSchemes.contains( id ) )
163 return false;
164
165 mColorSchemes.remove( id );
166 return true;
167}
168
170{
171 return mColorSchemes.keys();
172}
173
175{
176 if ( !mColorSchemes.contains( id ) )
177 return mColorSchemes.value( QStringLiteral( "default" ) );
178
179 return mColorSchemes.value( id );
180}
bool addColorScheme(const QgsCodeEditorColorScheme &scheme)
Adds a color scheme to the registry.
bool removeColorScheme(const QString &id)
Removes the color scheme with matching id from the registry.
QgsCodeEditorColorScheme scheme(const QString &id) const
Returns the color scheme with matching id.
QStringList schemes() const
Returns a list of the QgsCodeEditorColorScheme::id() values for all registered color schemes.
QgsCodeEditorColorSchemeRegistry()
Constructor for a color scheme registry.
Defines a color scheme for use in QgsCodeEditor widgets.
@ TripleSingleQuote
Triple single quote color.
@ CommentBlock
Comment block color.
@ QuotedOperator
Quoted operator color.
@ DoubleQuote
Double quote color.
@ QuotedIdentifier
Quoted identifier color.
@ SelectionForeground
Selection foreground color.
@ CommentLine
Line comment color.
@ FoldIconForeground
Fold icon foreground color.
@ MarginForeground
Margin foreground color.
@ ErrorBackground
Error background color.
@ MatchedBraceBackground
Matched brace background color.
@ SearchMatchBackground
Background color for search matches.
@ IndentationGuide
Indentation guide line.
@ SingleQuote
Single quote color.
@ MarginBackground
Margin background color.
@ SelectionBackground
Selection background color.
@ MatchedBraceForeground
Matched brace foreground color.
@ TripleDoubleQuote
Triple double quote color.
@ FoldIconHalo
Fold icon halo color.
QString id() const
Returns the ID of the color scheme, which is a unique, non-translated identifier for the scheme.
void setColors(const QMap< ColorRole, QColor > &colors)
Sets all colors for the scheme.