Skip to content

Commit

Permalink
style: fix property replacing on MacOS
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Popa <[email protected]>
  • Loading branch information
andrei47w committed Jan 27, 2025
1 parent a7cb6c8 commit 1aaeefb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gui/include/gui/style.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class SCOPY_GUI_EXPORT Style : public QObject
void genrateStyle();
QString getAllProperties();
static bool isProperty(QString style);
static const char *replaceProperty(const char *prop);
static QString replaceProperty(const char *prop);
static QString scaleNumberInString(QString string, float factor);
static QString adjustForScaling(QString key, QString value);

Expand Down
9 changes: 4 additions & 5 deletions gui/src/style.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void Style::init(QString theme)

void Style::setStyle(QWidget *widget, const char *style, QVariant value, bool force)
{
style = replaceProperty(style);
style = strdup(replaceProperty(style).toStdString().c_str());
if(!m_styleMap->contains(style)) {
qCritical("Style: Failed to set style: %s to widget: %s", widget->objectName().toStdString().c_str(),
style);
Expand Down Expand Up @@ -261,17 +261,16 @@ int Style::getDimension(const char *key)
return number;
}

const char *Style::replaceProperty(const char *prop)
QString Style::replaceProperty(const char *prop)
{
for(const QString &key : m_theme_json->object().keys()) {
if(prop == key) {
QJsonValue value = m_theme_json->object().value(key);
prop = value.toString().toLocal8Bit().data();
return prop;
return value.toString();
}
}

return prop;
return QString(prop);
}

QString Style::replaceAttributes(QString style, int calls_limit)
Expand Down

0 comments on commit 1aaeefb

Please sign in to comment.