QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
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 {
26 {QgsCodeEditorColorScheme::ColorRole::Class, QColor( "#4271ae" ) },
27 {QgsCodeEditorColorScheme::ColorRole::Method, QColor( "#4271ae" ) },
29 {QgsCodeEditorColorScheme::ColorRole::Number, QColor( "#c82829" ) },
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 addColorScheme( defaultScheme );
62
63 QgsCodeEditorColorScheme solarizedLight( QStringLiteral( "solarized" ), QObject::tr( "Solarized (Light)" ) );
64 solarizedLight.setColors(
65 {
68 {QgsCodeEditorColorScheme::ColorRole::Class, QColor( "#268BD2" ) },
69 {QgsCodeEditorColorScheme::ColorRole::Method, QColor( "#268BD2" ) },
71 {QgsCodeEditorColorScheme::ColorRole::Number, QColor( "#2AA198" ) },
76 {QgsCodeEditorColorScheme::ColorRole::Cursor, QColor( "#DC322F" ) },
82 {QgsCodeEditorColorScheme::ColorRole::Tag, QColor( "#2AA198" ) },
94 {QgsCodeEditorColorScheme::ColorRole::Edge, QColor( "#EEE8D5" ) },
95 {QgsCodeEditorColorScheme::ColorRole::Fold, QColor( "#EEE8D5" ) },
96 {QgsCodeEditorColorScheme::ColorRole::Error, QColor( "#DC322F" ) },
102 } );
103 addColorScheme( solarizedLight );
104
105 QgsCodeEditorColorScheme solarizedDark( QStringLiteral( "solarized_dark" ), QObject::tr( "Solarized (Dark)" ) );
106 solarizedDark.setColors(
107 {
108 {QgsCodeEditorColorScheme::ColorRole::Default, QColor( "#839496" ) },
109 {QgsCodeEditorColorScheme::ColorRole::Keyword, QColor( "#859900" ) },
110 {QgsCodeEditorColorScheme::ColorRole::Class, QColor( "#268BD2" ) },
111 {QgsCodeEditorColorScheme::ColorRole::Method, QColor( "#268BD2" ) },
113 {QgsCodeEditorColorScheme::ColorRole::Number, QColor( "#2AA198" ) },
114 {QgsCodeEditorColorScheme::ColorRole::Comment, QColor( "#2AA198" ) },
118 {QgsCodeEditorColorScheme::ColorRole::Cursor, QColor( "#DC322F" ) },
120 {QgsCodeEditorColorScheme::ColorRole::Operator, QColor( "#839496" ) },
124 {QgsCodeEditorColorScheme::ColorRole::Tag, QColor( "#268BD2" ) },
136 {QgsCodeEditorColorScheme::ColorRole::Edge, QColor( "#586E75" ) },
137 {QgsCodeEditorColorScheme::ColorRole::Fold, QColor( "#073642" ) },
138 {QgsCodeEditorColorScheme::ColorRole::Error, QColor( "#DC322F" ) },
144 } );
145 addColorScheme( solarizedDark );
146}
147
149{
150 if ( mColorSchemes.contains( scheme.id() ) )
151 return false;
152
153 mColorSchemes.insert( scheme.id(), scheme );
154 return true;
155}
156
158{
159 if ( !mColorSchemes.contains( id ) )
160 return false;
161
162 mColorSchemes.remove( id );
163 return true;
164}
165
167{
168 return mColorSchemes.keys();
169}
170
172{
173 if ( !mColorSchemes.contains( id ) )
174 return mColorSchemes.value( QStringLiteral( "default" ) );
175
176 return mColorSchemes.value( id );
177}
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.