use gui-interface for ATBUpdateTool

This commit is contained in:
Gerhard Hoffmann 2023-07-31 16:55:36 +02:00
parent 1ddd0074b3
commit ab8acfc7d1
3 changed files with 160 additions and 0 deletions

63
mainwindow.cpp Normal file
View File

@ -0,0 +1,63 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "worker.h"
#include <QDateTime>
MainWindow::MainWindow(Worker *worker, QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
, m_worker(worker) {
ui->setupUi(this);
connect(ui->start, SIGNAL(clicked()), m_worker, SLOT(update()));
connect(ui->exit, SIGNAL(clicked()), qApp, SLOT(quit()));
int w = 52;
QStringList lst;
QString start = QDateTime::currentDateTime().toString(Qt::ISODate);
lst << QString("Start: ") + start.leftJustified(w-10);
lst << QString("").leftJustified(w-3, '=');
lst << QString("Machine number : %1 ").arg(996).leftJustified(w-3);
lst << QString("Customer number : %1 ").arg(281).leftJustified(w-3);
lst << QString("Zone number : %1 (%2)").arg(1).arg("yellow").leftJustified(w-3);
lst << QString("").leftJustified(w-3, '=');
lst << QString("Backend connected ").leftJustified(w-10) + " [ ok]";
lst << QString("Update trigger set ").leftJustified(w-10) + " [ ok]";
// lst << QString("Found ISMAS machine number : %1 ").arg(996).leftJustified(w-10) + " [done]";
// lst << QString("Found ISMAS customer number: %1 ").arg(281).leftJustified(w-10) + " [done]";
lst << QString("Prepare customer environment ").leftJustified(w-10) + " [done]";
lst << QString("Found %1 files to update ").arg(5).leftJustified(w-10) + " [done]";
lst << QString("(") + QString("%1").arg(1).rightJustified(2, ' ') + QString(")")
+ (QString(" Update ") + "DC2C_print01.json ").leftJustified(w-14) + " [done]";
lst << QString("(") + QString("%1").arg(2).rightJustified(2, ' ') + QString(")")
+ (QString(" Update ") + "DC2C_print01.json ").leftJustified(w-14) + " [done]";
lst << QString("(") + QString("%1").arg(3).rightJustified(2, ' ') + QString(")")
+ QString(" Update opkg pakets ").leftJustified(w-14) + " [done]";
lst << QString("(") + QString("%1").arg(4).rightJustified(2, ' ') + QString(")")
+ QString(" Update device controller %1 ").arg("04.38").leftJustified(w-14) + " [done]";
lst << QString("Sync customer environment with filesystem ").leftJustified(w-10) + " [done]";
lst << QString("(") + QString("%1").arg(5).rightJustified(2, ' ') + QString(")")
+ (QString(" Update ") + "tariff01.json ").leftJustified(w-14) + " [done]";
lst << QString("Send ISMAS notification ").leftJustified(w-10) + " [done]";
lst << QString("Save log file %1.log").arg(start).leftJustified(w-10) + " [done]";
lst << QString("").leftJustified(w-3, '=');
lst << QString("").leftJustified(w-13) + " [SUCCESS]";
ui->updateStatus->setText(lst.join('\n'));
ui->updateStatus->setEnabled(true);
}
MainWindow::~MainWindow() {
delete ui;
}
void MainWindow::onStartClicked() {
}
void MainWindow::onExitClicked() {
}

26
mainwindow.h Normal file
View File

@ -0,0 +1,26 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class Worker;
class MainWindow : public QMainWindow {
Q_OBJECT
public:
MainWindow(Worker *worker, QWidget *parent = nullptr);
~MainWindow();
private slots:
void onStartClicked();
void onExitClicked();
private:
Ui::MainWindow *ui;
Worker *m_worker;
};
#endif // MAINWINDOW_H

71
mainwindow.ui Normal file
View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>370</width>
<height>358</height>
</rect>
</property>
<property name="font">
<font>
<family>Source Code Pro</family>
</font>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>351</width>
<height>341</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QPushButton" name="start">
<property name="font">
<font>
<family>Terminus</family>
</font>
</property>
<property name="text">
<string>Start</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="exit">
<property name="text">
<string>Exit</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QTextEdit" name="updateStatus">
<property name="enabled">
<bool>false</bool>
</property>
<property name="font">
<font>
<family>Noto Sans</family>
<pointsize>8</pointsize>
<bold>false</bold>
</font>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</widget>
<resources/>
<connections/>
</ui>