7#include "colorscheme.h"
12#include "auxiliary/ksnotification.h"
13#include "skyobjects/starobject.h"
15#include "skymaplite.h"
17#include "skyqpainter.h"
29 appendItem(
"SkyColor",
i18n(
"Sky"),
"#000000");
30 appendItem(
"DSOColor",
i18n(
"Messier Object"),
"#008f00");
31 appendItem(
"HSTColor",
i18nc(
"Object with extra attached URLs",
"Object w/ Links"),
"#930000");
32 appendItem(
"SNameColor",
i18n(
"Star Name"),
"#577d7d");
33 appendItem(
"DSNameColor",
i18n(
"Deep Sky Object Name"),
"#75759c");
34 appendItem(
"PNameColor",
i18n(
"Planet Name"),
"#ac9800");
35 appendItem(
"CNameColor",
i18nc(
"Constellation Name",
"Constell. Name"),
"#718488");
36 appendItem(
"CLineColor",
i18nc(
"Constellation Line",
"Constell. Line"),
"#3d3d3d");
37 appendItem(
"CBoundColor",
i18nc(
"Constellation Boundary",
"Constell. Boundary"),
"#222f2f");
38 appendItem(
"CBoundHighColor",
i18nc(
"Highlighted Constellation Boundary",
"Constell. Boundary Highlight"),
40 appendItem(
"MWColor",
i18nc(
"refers to the band of stars in the sky due to the Galactic plane",
"Milky Way"),
42 appendItem(
"EqColor",
i18n(
"Equator"),
"#909090");
43 appendItem(
"EclColor",
i18n(
"Ecliptic"),
"#613d12");
44 appendItem(
"HorzColor",
i18n(
"Horizon"),
"#091f14");
45 appendItem(
"LocalMeridianColor",
i18n(
"Local Meridian"),
"#0059b3");
46 appendItem(
"CompassColor",
i18n(
"Compass Labels"),
"#909055");
47 appendItem(
"EquatorialGridColor",
i18n(
"Equatorial Coordinate Grid"),
"#445566");
48 appendItem(
"HorizontalGridColor",
i18n(
"Horizontal Coordinate Grid"),
"#091f14");
49 appendItem(
"BoxTextColor",
i18n(
"Info Box Text"),
"#d2dbef");
50 appendItem(
"BoxGrabColor",
i18n(
"Info Box Selected"),
"#900000");
51 appendItem(
"BoxBGColor",
i18n(
"Info Box Background"),
"#000000");
52 appendItem(
"TargetColor",
i18n(
"Target Indicator"),
"#DD0000");
53 appendItem(
"UserLabelColor",
i18n(
"User Labels"),
"#AAAAAA");
54 appendItem(
"PlanetTrailColor",
i18n(
"Planet Trails"),
"#993311");
55 appendItem(
"AngularRuler",
i18n(
"Angular Distance Ruler"),
"#445566");
56 appendItem(
"ObsListColor",
i18n(
"Observing List Label"),
"#FF0000");
57 appendItem(
"StarHopRouteColor",
i18n(
"Star-Hop Route"),
"#00FFFF");
58 appendItem(
"VisibleSatColor",
i18n(
"Visible Satellites"),
"#00FF00");
59 appendItem(
"SatColor",
i18n(
"Satellites"),
"#FF0000");
60 appendItem(
"SatLabelColor",
i18n(
"Satellites Labels"),
"#640000");
61 appendItem(
"SupernovaColor",
i18n(
"Supernovae"),
"#FFA500");
62 appendItem(
"AsteroidColor",
i18n(
"Asteroids"),
"#F1C232");
63 appendItem(
"ArtificialHorizonColor",
i18n(
"Artificial Horizon"),
"#C82828");
64 appendItem(
"RAGuideError",
i18n(
"RA Guide Error"),
"#00FF00");
65 appendItem(
"DEGuideError",
i18n(
"DEC Guide Error"),
"#00A5FF");
66 appendItem(
"SolverFOVColor",
i18n(
"Solver FOV"),
"#FFFFFF");
67 appendItem(
"SensorFOVColor",
i18n(
"Sensor FOV"),
"#FFAA00");
68 appendItem(
"HIPSGridColor",
i18n(
"HiPS Grid"),
"#FFFFFF");
69 appendItem(
"FITSObjectLabelColor",
i18n(
"FITS Image Object Label"),
"#00FF00");
76 StarColorIntensity = 4;
91 qWarning() <<
"No color named" << name <<
"found in color scheme.";
110 return KeyName.
at(i);
131 int inew = 0, iold = 0;
135 if (name ==
i18nc(
"use default color scheme",
"Default Colors"))
136 filename =
"classic.colors";
137 if (name ==
i18nc(
"use 'star chart' color scheme",
"Star Chart"))
138 filename =
"chart.colors";
139 if (name ==
i18nc(
"use 'night vision' color scheme",
"Night Vision"))
140 filename =
"night.colors";
144 ok = KSUtils::openDataFile(file, filename);
153 ok = KSUtils::openDataFile(file, filename);
158 qDebug() << Q_FUNC_INFO <<
QString(
"Unable to load color scheme named %1. Also tried %2.").
arg(name, filename);
171 if (modes.
count() > 0)
173 int newmode = modes[0].toInt(&ok);
179 if (modes.
count() > 1)
181 int newintens = modes[1].toInt(&ok);
188 if (modes.
count() > 2)
190 int newintens = modes[2].toInt(&ok);
198 while (!stream.
atEnd())
202 if (line.
count(
':') ==
226 qWarning() <<
"Could not use the key \"" << tkey <<
"\" from the color scheme file \"" << filename
227 <<
"\". I also tried \"" << k <<
"\".";
240 foreach (
const QString &key, KeyName)
258 for (
int i = 0; i < filename.
length(); ++i)
259 if (filename.
at(i) ==
' ')
262 filename = filename.
append(
".colors");
269 KSNotification::sorry(
i18n(
"Local color scheme file could not be opened.\nScheme cannot be recorded."));
275 stream << StarColorMode <<
":" << StarColorIntensity <<
":" << DarkPalette <<
'\n';
277 foreach (
const QString &key, KeyName)
278 stream <<
Palette[key] <<
" :" << key <<
'\n';
287 KSNotification::sorry(
i18n(
"Local color scheme index file could not be opened.\nScheme cannot be recorded."));
292 QString schemeLine = name +
':' + filename;
297 while (stream.
atEnd() ==
false)
300 if (line == schemeLine)
309 stream << schemeLine <<
'\n';
316 KSNotification::sorry(
"Invalid filename requested.\nScheme cannot be recorded.");
329 for (
int i = 0; i < KeyName.
size(); ++i)
335 FileName = cg.
readEntry(
"ColorSchemeFile",
"moonless-night.colors");
341 for (
int i = 0; i < KeyName.
size(); ++i)
355 StarColorMode = mode;
356 Options::setStarColorMode(mode);
365 DarkPalette = enable ? 1 : 0;
366 Options::setDarkAppColors(enable);
375 StarColorIntensity = intens;
376 Options::setStarColorIntensity(intens);
384 StarColorMode = mode;
385 StarColorIntensity = intens;
386 Options::setStarColorMode(mode);
387 Options::setStarColorIntensity(intens);
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
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
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
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
KConfigGroup group(const QString &group)
void writeEntry(const char *key, const char *value, WriteConfigFlags pFlags=Normal)
QString readEntry(const char *key, const char *aDefault=nullptr) const
static KSharedConfig::Ptr openConfig(const QString &fileName=QString(), OpenFlags mode=FullConfig, QStandardPaths::StandardLocation type=QStandardPaths::GenericConfigLocation)
static void initStarImages()
Recalculates the star pixmaps.
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
QString name(NameFormat format) const const
bool open(FILE *fh, OpenMode mode, FileHandleFlags handleFlags)
void setFileName(const QString &name)
virtual void close() override
void append(QList< T > &&value)
const_reference at(qsizetype i) const const
qsizetype count() const const
qsizetype size() const const
qsizetype count() const const
QString & append(QChar ch)
QString arg(Args &&... args) const const
const QChar at(qsizetype position) const const
bool endsWith(QChar c, Qt::CaseSensitivity cs) const const
qsizetype indexOf(QChar ch, qsizetype from, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
QString left(qsizetype n) const const
qsizetype length() const const
QString mid(qsizetype position, qsizetype n) const const
QString & replace(QChar before, QChar after, Qt::CaseSensitivity cs)
QStringList split(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
QString toLower() const const
QString trimmed() const const
bool contains(QLatin1StringView str, Qt::CaseSensitivity cs) const const
qsizetype indexOf(const QRegularExpression &re, qsizetype from) const const
QString readLine(qint64 maxlen)