diff --git a/companion/src/modeledit/colorcustomscreens.cpp b/companion/src/modeledit/colorcustomscreens.cpp index d6b2906d2..330d814f5 100644 --- a/companion/src/modeledit/colorcustomscreens.cpp +++ b/companion/src/modeledit/colorcustomscreens.cpp @@ -48,12 +48,10 @@ UserInterfacePanel::UserInterfacePanel(QWidget * parent, ModelData & model, Gene int col = 0; int row = 0; - // set default theme as back up - const std::string defaultTheme = "EdgeTX Default"; - std::string themeName = defaultTheme; - std::string themeAuthor = "EdgeTX Team"; - std::string themeInfo = "Default EdgeTX Color Scheme"; - std::string themeFolder = "/THEMES/EdgeTX"; + std::string themeName = tr("Information unavailable").toStdString(); + std::string themeAuthor = ""; + std::string themeInfo = ""; + std::string themeFolder = ""; QString selTheme = QString(); @@ -73,20 +71,26 @@ UserInterfacePanel::UserInterfacePanel(QWidget * parent, ModelData & model, Gene } if (!selTheme.isEmpty()) { - QFile fst(sdPath % selTheme); + QStringList strl = selTheme.split("/"); + if (strl.size() >= 3) { + themeFolder = "/THEMES/" + strl.at(2).toStdString(); + themeName = strl.at(2).toStdString(); + } - if (fst.exists()) { - QStringList strl = selTheme.split("/"); - if (strl.size() >= 3) - themeFolder = "/THEMES/" + strl.at(2).toStdString(); + QString selThemeDetails(sdPath % selTheme); - YAML::Node node = YAML::LoadFile(QString(sdPath % selTheme).toStdString()); + if (QFile(selThemeDetails).exists()) { + + YAML::Node node = YAML::LoadFile(selThemeDetails.toStdString()); if (node["summary"]) { const auto &summary = node["summary"]; if (summary.IsMap()) { - themeName = summary["name"].as(); - themeAuthor = summary["author"].as(); - themeInfo = summary["info"].as(); + if (summary["name"].IsScalar()) + themeName = summary["name"].as(); + if (summary["author"].IsScalar()) + themeAuthor = summary["author"].as(); + if (summary["info"].IsScalar()) + themeInfo = summary["info"].as(); } } } @@ -106,21 +110,19 @@ UserInterfacePanel::UserInterfacePanel(QWidget * parent, ModelData & model, Gene addGridLabel(grid, tr("Information"), row, col++); addGridLabel(grid, themeInfo.c_str(), row++, col++); - if (themeName != defaultTheme) { - col = 0; - addGridBlankRow(grid, row); - addGridLabel(grid, "", row, col++); + col = 0; + addGridBlankRow(grid, row); + addGridLabel(grid, "", row, col++); - QLabel * img = new QLabel(this); - QString path = sdPath + themeFolder.c_str() + "/logo.png"; - QFile fimg(path); - if (fimg.exists()) { - QImage image(path); - if (!image.isNull()) { - img->setText(""); - img->setFixedSize(QSize(firmware->getCapability(LcdWidth) / 2, firmware->getCapability(LcdHeight) / 2)); - img->setPixmap(QPixmap::fromImage(image.scaled(firmware->getCapability(LcdWidth) / 2, firmware->getCapability(LcdHeight) / 2))); - } + QLabel * img = new QLabel(this); + QString path = sdPath + themeFolder.c_str() + "/logo.png"; + QFile fimg(path); + if (fimg.exists()) { + QImage image(path); + if (!image.isNull()) { + img->setText(""); + img->setFixedSize(QSize(firmware->getCapability(LcdWidth) / 2, firmware->getCapability(LcdHeight) / 2)); + img->setPixmap(QPixmap::fromImage(image.scaled(firmware->getCapability(LcdWidth) / 2, firmware->getCapability(LcdHeight) / 2))); } grid->addWidget(img, row++, col++);