Kstars

colorscheme.h
1/*
2 SPDX-FileCopyrightText: 2002 Jason Harris <kstars@30doradus.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include <QColor>
10#include <QMap>
11#include <QStringList>
12
13/**
14 * @class ColorScheme
15 * This class stores all of the adjustable colors in KStars, in
16 * a QMap object keyed by the names of the colors. It also stores
17 * information on how stars are to be rendered in the map
18 * (with realistic colors, or as solid red/whit/black circles).
19 * In addition to the brief "Key names" used to index the colors in
20 * the QMap, each color has a "long name" description that is a bit
21 * more verbose, and suitable for UI display.
22 *
23 * @author Jason Harris
24 * @version 1.0
25 */
27{
28 public:
29 /**
30 * Constructor. Enter all adjustable colors and their default
31 * values into the QMap. Also assign the corresponding long names.
32 */
34
35 /** @return true if the Palette contains the given key name */
36 bool hasColorNamed(const QString &name) const { return (Palette.contains(name)); }
37
38 /**
39 * @short Retrieve a color by name.
40 * @p name the key name of the color to be retrieved.
41 * @return the requested color, or Qt::white if color name not found.
42 */
43 QColor colorNamed(const QString &name) const;
44
45 /**
46 * @p i the index of the color to retrieve
47 * @return a color by its index in the QMap
48 */
49 QColor colorAt(int i) const;
50
51 /**
52 * @p i the index of the long name to retrieve
53 * @return the name of the color at index i
54 */
55 QString nameAt(int i) const;
56
57 /**
58 * @p i the index of the key name to retrieve
59 * @return the key name of the color at index i
60 */
61 QString keyAt(int i) const;
62
63 /**
64 * @return the long name of the color whose key name is given
65 * @p key the key name identifying the color.
66 */
67 QString nameFromKey(const QString &key) const;
68
69 /**
70 * Change the color with the given key to the given value
71 * @p key the key-name of the color to be changed
72 * @p color the new color value
73 */
74 void setColor(const QString &key, const QString &color);
75
76 /**
77 * Load a color scheme from a *.colors file
78 * @p filename the filename of the color scheme to be loaded.
79 * @return true if the scheme was successfully loaded
80 */
81 bool load(const QString &filename);
82
83 /**
84 * Save the current color scheme to a *.colors file.
85 * @p name the filename to create
86 * @return true if the color scheme is successfully writen to a file
87 */
88 bool save(const QString &name);
89
90 /** @return the Filename associated with the color scheme. */
91 QString fileName() const { return FileName; }
92
93 /** Read color-scheme data from the Config object. */
94 void loadFromConfig();
95
96 /** Save color-scheme data to the Config object. */
97 void saveToConfig();
98
99 /** @return the number of colors in the color scheme. */
100 unsigned int numberOfColors() const { return (int)Palette.size(); }
101
102 /** @return the star color mode used by the color scheme */
103 int starColorMode() const { return StarColorMode; }
104
105 /** @return True if dark palette colors are used by the color scheme */
106 bool useDarkPalette() const { return DarkPalette == 1; }
107
108 /** @return the star color intensity value used by the color scheme */
109 int starColorIntensity() const { return StarColorIntensity; }
110
111 /**
112 * Set the star color mode used by the color scheme
113 * @p mode the star color mode to use
114 */
115 void setStarColorMode(int mode);
116
117 /**
118 * Set the star color intensity value used by the color scheme
119 * @p intens The star color intensity value
120 */
121 void setStarColorIntensity(int intens);
122
123 /**
124 * Set the star color mode and intensity value used by the color scheme
125 * @p mode the star color mode to use
126 * @p intens The star color intensity value
127 */
128 void setStarColorModeIntensity(int mode, int intens);
129
130 /**
131 * @brief setDarkPalette Set whether the color schemes uses dark palette
132 * @param enable True to use dark palette. False to use application default palette
133 */
134 void setDarkPalette(bool enable);
135
136 private:
137 /** Append items to all string lists. */
138 void appendItem(const QString &key, const QString &name, const QString &def);
139
140 int StarColorMode { 0 };
141 int StarColorIntensity { 0 };
142 int DarkPalette { 0 };
143 QString FileName;
144 QStringList KeyName, Name, Default;
146};
This class stores all of the adjustable colors in KStars, in a QMap object keyed by the names of the ...
Definition colorscheme.h:27
bool save(const QString &name)
Save the current color scheme to a *.colors file.
void saveToConfig()
Save color-scheme data to the Config object.
void setStarColorModeIntensity(int mode, int intens)
Set the star color mode and intensity value used by the color scheme mode the star color mode to use ...
QColor colorNamed(const QString &name) const
Retrieve a color by name.
int starColorIntensity() const
int starColorMode() const
QString fileName() const
Definition colorscheme.h:91
void setStarColorIntensity(int intens)
Set the star color intensity value used by the color scheme intens The star color intensity value.
bool hasColorNamed(const QString &name) const
Definition colorscheme.h:36
QString nameFromKey(const QString &key) const
QColor colorAt(int i) const
i the index of the color to retrieve
QString nameAt(int i) const
i the index of the long name to retrieve
void setDarkPalette(bool enable)
setDarkPalette Set whether the color schemes uses dark palette
unsigned int numberOfColors() const
QString keyAt(int i) const
i the index of the key name to retrieve
bool load(const QString &filename)
Load a color scheme from a *.colors file filename the filename of the color scheme to be loaded.
void setColor(const QString &key, const QString &color)
Change the color with the given key to the given value key the key-name of the color to be changed co...
void loadFromConfig()
Read color-scheme data from the Config object.
void setStarColorMode(int mode)
Set the star color mode used by the color scheme mode the star color mode to use.
ColorScheme()
Constructor.
bool useDarkPalette() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:57:47 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.