• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • applications API Reference
  • KDE Home
  • Contact Us
 

Konsole

  • kde-4.14
  • applications
  • konsole
  • src
ColorScheme.h
Go to the documentation of this file.
1 /*
2  This source file is part of Konsole, a terminal emulator.
3 
4  Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  02110-1301 USA.
20 */
21 
22 #ifndef COLORSCHEME_H
23 #define COLORSCHEME_H
24 
25 // Qt
26 #include <QtCore/QMetaType>
27 
28 // KDE
29 #include <KSharedPtr>
30 
31 // Konsole
32 #include "CharacterColor.h"
33 
34 class KConfig;
35 class QPixmap;
36 class QPainter;
37 
38 namespace Konsole
39 {
44 class ColorSchemeWallpaper : public QSharedData
45 {
46 public:
47  typedef KSharedPtr<ColorSchemeWallpaper> Ptr;
48 
49  explicit ColorSchemeWallpaper(const QString& path);
50  ~ColorSchemeWallpaper();
51 
52  void load();
53 
55  bool draw(QPainter& painter, const QRect& rect, qreal opacity=1.0);
56 
57  bool isNull() const;
58 
59  QString path() const;
60 
61 private:
62  QString _path;
63  QPixmap* _picture;
64 };
65 
72 class ColorScheme
73 {
74 public:
79  ColorScheme();
80  ColorScheme(const ColorScheme& other);
81  ~ColorScheme();
82 
84  void setDescription(const QString& description);
86  QString description() const;
87 
89  void setName(const QString& name);
91  QString name() const;
92 
94  void read(const KConfig& config);
96  void write(KConfig& config) const;
97 
99  void setColorTableEntry(int index , const ColorEntry& entry);
100 
110  void getColorTable(ColorEntry* table, uint randomSeed = 0) const;
111 
117  ColorEntry colorEntry(int index , uint randomSeed = 0) const;
118 
125  QColor foregroundColor() const;
131  QColor backgroundColor() const;
132 
138  bool hasDarkBackground() const;
139 
149  void setOpacity(qreal opacity);
154  qreal opacity() const;
155 
156  void setWallpaper(const QString& path);
157 
158  ColorSchemeWallpaper::Ptr wallpaper() const;
159 
166  void setRandomizedBackgroundColor(bool randomize);
167 
169  bool randomizedBackgroundColor() const;
170 
171  static const ColorEntry defaultTable[]; // table of default color entries
172 
173  static QString colorNameForIndex(int index);
174  static QString translatedColorNameForIndex(int index);
175 
176 private:
177  // specifies how much a particular color can be randomized by
178  class RandomizationRange
179  {
180  public:
181  RandomizationRange() : hue(0) , saturation(0) , value(0) {}
182 
183  bool isNull() const {
184  return (hue == 0 && saturation == 0 && value == 0);
185  }
186 
187  quint16 hue;
188  quint8 saturation;
189  quint8 value;
190  };
191 
192  // returns the active color table. if none has been set specifically,
193  // this is the default color table.
194  const ColorEntry* colorTable() const;
195 
196  // reads a single color entry from a KConfig source
197  // and sets the palette entry at 'index' to the entry read.
198  void readColorEntry(const KConfig& config , int index);
199  // writes a single color entry to a KConfig source
200  void writeColorEntry(KConfig& config , int index) const;
201 
202  // sets the amount of randomization allowed for a particular color
203  // in the palette. creates the randomization table if
204  // it does not already exist
205  void setRandomizationRange(int index , quint16 hue , quint8 saturation , quint8 value);
206 
207  QString _description;
208  QString _name;
209 
210  // pointer to custom color table, or 0 if the default color table is
211  // being used
212  ColorEntry* _table;
213 
214  // pointer to randomization table, or 0 if no colors in the color
215  // scheme support randomization
216  RandomizationRange* _randomTable;
217 
218  qreal _opacity;
219 
220  ColorSchemeWallpaper::Ptr _wallpaper;
221 
222  static const quint16 MAX_HUE = 340;
223 
224  static const char* const colorNames[TABLE_COLORS];
225  static const char* const translatedColorNames[TABLE_COLORS];
226 };
227 }
228 
229 Q_DECLARE_METATYPE(const Konsole::ColorScheme*)
230 
231 #endif //COLORSCHEME_H
Konsole::ColorScheme::translatedColorNameForIndex
static QString translatedColorNameForIndex(int index)
Definition: ColorScheme.cpp:120
TABLE_COLORS
#define TABLE_COLORS
Definition: CharacterColor.h:117
Konsole::ColorSchemeWallpaper::isNull
bool isNull() const
Definition: ColorScheme.cpp:399
Konsole::ColorScheme::ColorScheme
ColorScheme()
Constructs a new color scheme which is initialized to the default color set for Konsole.
Definition: ColorScheme.cpp:127
Konsole::ColorScheme::hasDarkBackground
bool hasDarkBackground() const
Returns true if this color scheme has a dark background.
Definition: ColorScheme.cpp:274
Konsole::ColorSchemeWallpaper::~ColorSchemeWallpaper
~ColorSchemeWallpaper()
Definition: ColorScheme.cpp:381
Konsole::ColorSchemeWallpaper
This class holds the wallpaper pixmap associated with a color scheme.
Definition: ColorScheme.h:44
CharacterColor.h
Konsole::ColorScheme::getColorTable
void getColorTable(ColorEntry *table, uint randomSeed=0) const
Copies the color entries which form the palette for this color scheme into table. ...
Definition: ColorScheme.cpp:222
Konsole::ColorScheme::setRandomizedBackgroundColor
void setRandomizedBackgroundColor(bool randomize)
Enables randomization of the background color.
Definition: ColorScheme.cpp:231
Konsole::ColorScheme::write
void write(KConfig &config) const
Writes the color scheme to the specified configuration source.
Definition: ColorScheme.cpp:322
Konsole::ColorScheme::setOpacity
void setOpacity(qreal opacity)
Sets the opacity level of the display background.
Definition: ColorScheme.cpp:280
Konsole::ColorScheme::colorEntry
ColorEntry colorEntry(int index, uint randomSeed=0) const
Retrieves a single color entry from the table.
Definition: ColorScheme.cpp:193
Konsole::ColorSchemeWallpaper::draw
bool draw(QPainter &painter, const QRect &rect, qreal opacity=1.0)
Returns true if wallpaper available and drawn.
Definition: ColorScheme.cpp:404
Konsole::ColorScheme::~ColorScheme
~ColorScheme()
Definition: ColorScheme.cpp:156
Konsole::ColorSchemeWallpaper::path
QString path() const
Definition: ColorScheme.cpp:422
QRect
Konsole::ColorScheme::opacity
qreal opacity() const
Returns the opacity level for this color scheme, see setOpacity() TODO: More documentation.
Definition: ColorScheme.cpp:284
QSharedData
Konsole::ColorScheme::randomizedBackgroundColor
bool randomizedBackgroundColor() const
Returns true if the background color is randomized.
Definition: ColorScheme.cpp:227
Konsole::ColorSchemeWallpaper::load
void load()
Definition: ColorScheme.cpp:386
Konsole::ColorEntry
An entry in a terminal display's color palette.
Definition: CharacterColor.h:40
Konsole::ColorSchemeWallpaper::Ptr
KSharedPtr< ColorSchemeWallpaper > Ptr
Definition: ColorScheme.h:47
Konsole::ColorSchemeWallpaper::ColorSchemeWallpaper
ColorSchemeWallpaper(const QString &path)
Definition: ColorScheme.cpp:375
Konsole::ColorScheme::setColorTableEntry
void setColorTableEntry(int index, const ColorEntry &entry)
Sets a single entry within the color palette.
Definition: ColorScheme.cpp:180
QPainter
QString
QColor
Konsole::ColorScheme::description
QString description() const
Returns the descriptive name of the color scheme.
Definition: ColorScheme.cpp:166
QPixmap
Konsole::ColorScheme::setDescription
void setDescription(const QString &description)
Sets the descriptive name of the color scheme.
Definition: ColorScheme.cpp:162
Konsole::ColorScheme::setName
void setName(const QString &name)
Sets the name of the color scheme.
Definition: ColorScheme.cpp:171
Konsole::ColorScheme::setWallpaper
void setWallpaper(const QString &path)
Definition: ColorScheme.cpp:365
Konsole::ColorScheme::defaultTable
static const ColorEntry defaultTable[]
Definition: ColorScheme.h:171
Konsole::ColorScheme::colorNameForIndex
static QString colorNameForIndex(int index)
Definition: ColorScheme.cpp:113
Konsole::ColorScheme::name
QString name() const
Returns the name of the color scheme.
Definition: ColorScheme.cpp:175
Konsole::ColorScheme::backgroundColor
QColor backgroundColor() const
Convenience method.
Definition: ColorScheme.cpp:270
Konsole::ColorScheme::foregroundColor
QColor foregroundColor() const
Convenience method.
Definition: ColorScheme.cpp:266
Konsole::ColorScheme
Represents a color scheme for a terminal display.
Definition: ColorScheme.h:72
Konsole::ColorScheme::wallpaper
ColorSchemeWallpaper::Ptr wallpaper() const
Definition: ColorScheme.cpp:370
Konsole::ColorScheme::read
void read(const KConfig &config)
Reads the color scheme from the specified configuration source.
Definition: ColorScheme.cpp:289
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:27 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Konsole

Skip menu "Konsole"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Konsole

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal