Commit 64b45e2d authored by Ronan Abhamon's avatar Ronan Abhamon

feat(Colors): provide a way to get colors (without alpha)

parent a8bc6ad5
......@@ -37,17 +37,33 @@ Colors::Colors (QObject *parent) : QObject(parent) {
QObject::connect(CoreManager::getInstance(), &CoreManager::coreCreated, this, &Colors::overrideColors);
}
// -----------------------------------------------------------------------------
void Colors::overrideColors () {
shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig();
const QMetaObject *info = metaObject();
for (int i = info->propertyOffset(); i < info->propertyCount(); ++i) {
const QMetaProperty &metaProperty = info->property(i);
string colorName = metaProperty.name();
string colorValue = config->getString(COLORS_SECTION, colorName, "");
const QMetaProperty metaProperty = info->property(i);
const string colorName = metaProperty.name();
const string colorValue = config->getString(COLORS_SECTION, colorName, "");
if (!colorValue.empty())
setProperty(colorName.c_str(), QColor(::Utils::coreStringToAppString(colorValue)));
}
}
QStringList Colors::getColorNames () const {
static QStringList colorNames;
if (!colorNames.isEmpty())
return colorNames;
const QMetaObject *info = metaObject();
for (int i = info->propertyOffset(); i < info->propertyCount(); ++i) {
const QMetaProperty metaProperty = info->property(i);
if (metaProperty.isWritable())
colorNames << QString::fromLatin1(metaProperty.name());
}
return colorNames;
}
......@@ -50,6 +50,8 @@
class Colors : public QObject {
Q_OBJECT;
Q_PROPERTY(QStringList colorNames READ getColorNames CONSTANT);
ADD_COLOR(a, "transparent");
ADD_COLOR(b, "#5E5E5F");
ADD_COLOR(c, "#CBCBCB");
......@@ -124,6 +126,8 @@ signals:
private:
void overrideColors ();
QStringList getColorNames () const;
};
// -----------------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment