From 54a91425f2c7529d84b7b270feaea0146424ac0f Mon Sep 17 00:00:00 2001 From: xarkes Date: Fri, 9 Mar 2018 12:24:26 +0100 Subject: [PATCH] Fix arrow colors #370 --- src/utils/Configuration.cpp | 48 +++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/src/utils/Configuration.cpp b/src/utils/Configuration.cpp index 938056b4..2ee442da 100644 --- a/src/utils/Configuration.cpp +++ b/src/utils/Configuration.cpp @@ -141,6 +141,21 @@ void Configuration::setDarkTheme(bool set) emit colorsUpdated(); } +QString Configuration::getLogoFile() +{ + return logoFile; +} + +/*! + * \brief Configuration::setColor sets the local Cutter configuration color + * \param name Color Name + * \param color The color you want to set + */ +void Configuration::setColor(const QString &name, const QColor &color) +{ + s.setValue("colors." + name, color); +} + const QColor Configuration::getColor(const QString &name) const { if (s.contains("colors." + name)) { @@ -150,32 +165,25 @@ const QColor Configuration::getColor(const QString &name) const } } -QString Configuration::getLogoFile() -{ - return logoFile; -} - -/** - * @brief Configuration::setColor sets the local Cutter configuration color - * @param name Color Name - * @param color The color you want to set - */ -void Configuration::setColor(const QString &name, const QColor &color) -{ - s.setValue("colors." + name, color); -} - void Configuration::setColorTheme(QString theme) { - if (theme == "default") - { + if (theme == "default") { Core()->cmd("ecd"); s.setValue("theme", "default"); - } - else - { + } else { Core()->cmd(QString("eco %1").arg(theme)); s.setValue("theme", theme); } + // Duplicate interesting colors into our Cutter Settings + // Dirty fix for arrow colors, TODO refactor getColor, setColor, etc. + QJsonDocument colors = Core()->cmdj("ecj"); + QJsonObject colorsObject = colors.object(); + QJsonObject::iterator it; + for (it = colorsObject.begin(); it != colorsObject.end(); it++) { + if (!it.key().contains("graph")) + continue; + QJsonArray rgb = it.value().toArray(); + s.setValue("colors." + it.key(), QColor(rgb[0].toInt(), rgb[1].toInt(), rgb[2].toInt())); + } emit colorsUpdated(); }