textcolortab.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. #include "textcolortab.h"
  2. textColorTab::textColorTab()
  3. {
  4. }
  5. void textColorTab::updateLabels(QString jsonData)
  6. {
  7. //Convert the jsonData var to QJsonObject
  8. QJsonDocument jsonDataDocument = QJsonDocument::fromJson(jsonData.toUtf8());
  9. QJsonObject jsonDataDocumentObject = jsonDataDocument.object();
  10. //Convert the colors in the JSON to QColor
  11. QColor primaryColor, secondaryColor, iconSetColor, iconSetActiveColor, transitionScreen;
  12. primaryColor.setNamedColor("#" + jsonDataDocumentObject.value("primaryText").toString());
  13. secondaryColor.setNamedColor("#" + jsonDataDocumentObject.value("secondaryText").toString());
  14. iconSetColor.setNamedColor("#" + jsonDataDocumentObject.value("iconSet").toString());
  15. iconSetActiveColor.setNamedColor("#" + jsonDataDocumentObject.value("iconSetActive").toString());
  16. transitionScreen.setNamedColor("#" + jsonDataDocumentObject.value("transitionScreen").toString());
  17. //Update labels color
  18. emit setLabelsColor(primaryColor, secondaryColor, iconSetColor, iconSetActiveColor, transitionScreen);
  19. }
  20. QColor textColorTab::getColorFromUser()
  21. {
  22. //Open the Color Selector dialog
  23. return QColorDialog::getColor();
  24. }