-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2016 from ferranpujolcamins/Enable-Setting-hotcue…
…-color-via-controlobject Enable setting hotcue color via controlobject
- Loading branch information
Showing
27 changed files
with
611 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include "controllers/colorjsproxy.h" | ||
|
||
ColorJSProxy::ColorJSProxy(QScriptEngine* pScriptEngine) | ||
: m_pScriptEngine(pScriptEngine), | ||
m_predefinedColorsList(makePredefinedColorsList(pScriptEngine)){}; | ||
|
||
ColorJSProxy::~ColorJSProxy() {}; | ||
|
||
QScriptValue ColorJSProxy::predefinedColorFromId(int iId) { | ||
PredefinedColorPointer color(Color::predefinedColorSet.predefinedColorFromId(iId)); | ||
return jsColorFrom(color); | ||
}; | ||
|
||
Q_INVOKABLE QScriptValue ColorJSProxy::predefinedColorsList() { | ||
return m_predefinedColorsList; | ||
} | ||
|
||
QScriptValue ColorJSProxy::jsColorFrom(PredefinedColorPointer predefinedColor) { | ||
QScriptValue jsColor = m_pScriptEngine->newObject(); | ||
jsColor.setProperty("red", predefinedColor->m_defaultRgba.red()); | ||
jsColor.setProperty("green", predefinedColor->m_defaultRgba.green()); | ||
jsColor.setProperty("blue", predefinedColor->m_defaultRgba.blue()); | ||
jsColor.setProperty("alpha", predefinedColor->m_defaultRgba.alpha()); | ||
jsColor.setProperty("id", predefinedColor->m_iId); | ||
return jsColor; | ||
} | ||
|
||
QScriptValue ColorJSProxy::makePredefinedColorsList(QScriptEngine* pScriptEngine) { | ||
int numColors = Color::predefinedColorSet.allColors.length(); | ||
QScriptValue colorList = pScriptEngine->newArray(numColors); | ||
for (int i = 0; i < numColors; ++i) { | ||
PredefinedColorPointer color = Color::predefinedColorSet.allColors.at(i); | ||
colorList.setProperty(i, jsColorFrom(color)); | ||
} | ||
return colorList; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#ifndef COLORJSPROXY_H | ||
#define COLORJSPROXY_H | ||
|
||
#include <QObject> | ||
#include <QScriptEngine> | ||
#include <QScriptValue> | ||
|
||
#include "util/color/color.h" | ||
|
||
class ColorJSProxy: public QObject { | ||
Q_OBJECT | ||
public: | ||
ColorJSProxy(QScriptEngine* pScriptEngine); | ||
|
||
virtual ~ColorJSProxy(); | ||
|
||
Q_INVOKABLE QScriptValue predefinedColorFromId(int iId); | ||
Q_INVOKABLE QScriptValue predefinedColorsList(); | ||
|
||
private: | ||
QScriptValue jsColorFrom(PredefinedColorPointer predefinedColor); | ||
QScriptValue makePredefinedColorsList(QScriptEngine* pScriptEngine); | ||
QScriptEngine* m_pScriptEngine; | ||
QScriptValue m_predefinedColorsList; | ||
}; | ||
|
||
#endif /* COLORJSPROXY_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.