mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-21 13:48:08 +00:00
feat(Colors): provide a way to get colors (without alpha)
This commit is contained in:
parent
a8bc6ad507
commit
64b45e2dbd
2 changed files with 24 additions and 4 deletions
|
|
@ -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;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue