summaryrefslogtreecommitdiffstats
path: root/src/b2qt-flashing-wizard/platform_page.cpp
diff options
context:
space:
mode:
authorRainer Keller <rainer.keller@theqtcompany.com>2014-12-10 15:04:40 +0100
committerRainer Keller <rainer.keller@theqtcompany.com>2014-12-15 10:19:09 +0200
commit364753fb3e8bb95faa4cdbef07de8c0f6868d913 (patch)
tree073e6dd66cea96d3ff05060102d7d92d5874d486 /src/b2qt-flashing-wizard/platform_page.cpp
parent93e20f9fc2acb05814366344d774ebdadaead06b (diff)
b2qt-flashing-wizard: Use config files for deploment
Change-Id: If79eec5eb395c60e6f7531bbd9a3d422221c0f19 Reviewed-by: Rainer Keller <rainer.keller@theqtcompany.com>
Diffstat (limited to 'src/b2qt-flashing-wizard/platform_page.cpp')
-rw-r--r--src/b2qt-flashing-wizard/platform_page.cpp150
1 files changed, 68 insertions, 82 deletions
diff --git a/src/b2qt-flashing-wizard/platform_page.cpp b/src/b2qt-flashing-wizard/platform_page.cpp
index 31ee880..609a5aa 100644
--- a/src/b2qt-flashing-wizard/platform_page.cpp
+++ b/src/b2qt-flashing-wizard/platform_page.cpp
@@ -24,14 +24,12 @@
#include <QDir>
#include <QLabel>
#include <QSpacerItem>
+#include <QSettings>
#include "mainwindow.h" // Page_ enum
-extern QString G_platform;
-extern QString G_version;
-extern QString G_os;
-extern QString G_device;
-extern QString G_board;
+static QList<PlatformInfo> platforms;
extern QString G_SDKDIR;
+extern PlatformInfo G_platforminfo;
QLabel *createErrorLabel(QWidget *parent)
{
@@ -68,20 +66,7 @@ PlatformPage::~PlatformPage()
bool PlatformPage::isComplete() const
{
- QStringList data = buttonData();
- if (data.isEmpty())
- return false;
-
- if (data[0] == "nexus7") {
- mError->setText(tr("The selected platform is not supported."));
- return false;
- }
- if (data[0] == "iMX6" && data[1] == "eAndroid") {
- mError->setText(tr("The selected platform is not supported."));
- return false;
- }
-
- return !data.isEmpty();
+ return true;
}
void PlatformPage::itemSelected()
@@ -90,13 +75,53 @@ void PlatformPage::itemSelected()
emit completeChanged();
}
+static void loadDeployConfig(const QString &filename, const QString &version)
+{
+ qDebug() << "Trying to load config" << filename;
+ if (!QFile::exists(filename))
+ return;
+
+ QFileInfo fi(filename);
+
+ QSettings settings(filename, QSettings::IniFormat);
+
+ foreach (const QString &group, settings.childGroups()) {
+ PlatformInfo pi;
+
+ settings.beginGroup(group);
+ pi.name = group;
+ pi.platform = settings.value("platform").toString();
+ pi.os = settings.value("os").toString();
+ pi.androidversion = settings.value("androidversion").toString();
+ pi.board = settings.value("board").toString();
+ pi.deployCommand = settings.value("deploycommand").toString();
+ pi.deployCommand = QDir::cleanPath(fi.canonicalPath() + "/" + pi.deployCommand);
+ pi.deployArguments = settings.value("deployarguments").toStringList();
+ pi.asroot = settings.value("asroot").toBool();
+ pi.version = version;
+ settings.endGroup();
+
+ if (pi.platform.isEmpty() || pi.os.isEmpty() || pi.deployCommand.isEmpty()) {
+ qWarning() << "Invalid data";
+ continue;
+ }
+
+ if (pi.os == "eAndroid" && pi.androidversion.isEmpty()) {
+ qWarning() << "Invalid data";
+ continue;
+ }
+
+ qDebug() << "Adding platform" << group;
+ platforms.append(pi);
+ }
+}
+
void PlatformPage::initializePage()
{
mError->clear();
qDeleteAll(mButtons);
mButtons.clear();
- mButtonData.clear();
QDir dir(G_SDKDIR);
foreach (const QString i, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) {
@@ -111,91 +136,52 @@ void PlatformPage::initializePage()
QString os = token.takeLast();
QString name = token.join("-");
- if (os == "eAndroid" && name.startsWith("generic-")) {
- QString version = token[1];
- QDir dir3(dir2.absoluteFilePath(j) + "/images");
- foreach (const QString k, dir3.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) {
- if (k == "common")
- continue;
-
- if (!QFile::exists(dir3.absoluteFilePath(k) + "/deploy.sh"))
- continue;
-
- QRadioButton *button = new QRadioButton;
- button->setText(k + "-" + version + "-" + os + " (" + i + ")");
- mLayout->insertWidget(0, button);
- connect(button, &QRadioButton::toggled, this, &PlatformPage::itemSelected);
- mButtons.append(button);
- mButtonData.insert(button, QStringList() << name << os << i << k);
- }
-
- } else if (os == "eAndroid" || os == "eLinux") {
- // Will be fixed with http://qt-gerrit.it.local/#change,7842
- if (name == "imx6qsabresd") {
- {
- QRadioButton *button = new QRadioButton;
- button->setText(j + " (" + i + ")");
- mLayout->insertWidget(0, button);
- connect(button, &QRadioButton::toggled, this, &PlatformPage::itemSelected);
- mButtons.append(button);
- mButtonData.insert(button, QStringList() << name << os << i << name);
- }
- {
- QRadioButton *button = new QRadioButton;
- button->setText("imx6dsabresd-eLinux (" + i + ")");
- mLayout->insertWidget(0, button);
- connect(button, &QRadioButton::toggled, this, &PlatformPage::itemSelected);
- mButtons.append(button);
- mButtonData.insert(button, QStringList() << "imx6dsabresd" << os << i << name);
- }
- } else {
- QRadioButton *button = new QRadioButton;
- button->setText(j + " (" + i + ")");
- mLayout->insertWidget(0, button);
- connect(button, &QRadioButton::toggled, this, &PlatformPage::itemSelected);
- mButtons.append(button);
- mButtonData.insert(button, QStringList() << name << os << i << name);
- }
- }
+ loadDeployConfig(dir2.absoluteFilePath(j) + "/images/deploy.conf", i);
}
}
- if (mButtons.isEmpty()) {
+ if (platforms.isEmpty()) {
mError->setText(tr("No suitable platform found in '%1'.\nMake sure you have"
"installed at least one hardware platform.").arg(G_SDKDIR));
}
+
+ for (int i = 0; i < platforms.count(); ++i) {
+ const PlatformInfo &pi = platforms[i];
+ QRadioButton *button = new QRadioButton;
+ if (pi.os == "eAndroid")
+ button->setText(pi.name + " | " + pi.os + " " + pi.androidversion + " (" + pi.version + ")");
+ else
+ button->setText(pi.name + " | " + pi.os + " (" + pi.version + ")");
+ mLayout->insertWidget(0, button);
+ connect(button, &QRadioButton::toggled, this, &PlatformPage::itemSelected);
+ button->setProperty("b2qt-platform-name", i);
+ mButtons.append(button);
+ }
}
-QStringList PlatformPage::buttonData() const
+PlatformInfo PlatformPage::buttonData() const
{
- QStringList data;
-
foreach (QRadioButton *button, mButtons) {
if (button->isChecked()) {
- data = mButtonData[button];
- break;
+ int id = button->property("b2qt-platform-name").toInt();
+ return platforms[id];
}
}
- return data;
+ return PlatformInfo();
}
bool PlatformPage::validatePage()
{
- QStringList data = buttonData();
-
- G_platform = data[0];
- G_os = data[1];
- G_version = data[2];
- G_board = data[3];
-
- qDebug() << "Selected:" << G_platform << G_os << G_version << G_board;
+ G_platforminfo = buttonData();
+ qDebug() << "Selected:" << G_platforminfo.name;
return true;
}
int PlatformPage::nextId() const
{
- if (G_board.startsWith("nexus7"))
+ if (G_platforminfo.board.startsWith("nexus7"))
return MainWindow::Page_Device;
else
return MainWindow::Page_Disk;
}
+