RibbonUI: Add color() and alpha() for Qt 5.

This commit is contained in:
Mentalflow 2025-05-24 00:42:29 +08:00
parent d4bb700891
commit fb809e6a5c
Signed by: Mentalflow
GPG Key ID: 5AE68D4401A2EE71
2 changed files with 17 additions and 0 deletions

View File

@ -26,6 +26,8 @@ public:
bool autoLoadLanguage(){return _autoLoadLanguage;};
void setAutoLoadLanguage(bool value);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
Q_INVOKABLE QColor color(QString colorName);
Q_INVOKABLE QColor alpha(QString colorName, float alpha = 1);
public:
#else
private:

View File

@ -85,3 +85,18 @@ void RibbonUI::setAutoLoadLanguage(bool value){
_autoLoadLanguage = value;
initTranslator();
}
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
Q_INVOKABLE QColor RibbonUI::color(QString colorName){
return QColor(colorName);
}
Q_INVOKABLE QColor RibbonUI::alpha(QString colorName, float alpha){
QColor c(colorName);
if(alpha > 1)
c.setAlpha(alpha);
else
c.setAlphaF(alpha);
return c;
}
#endif