b
This commit is contained in:
@@ -55,6 +55,9 @@ ToolsUI::ToolsUI(QWidget *parent) :
|
||||
|
||||
remotecontrol = new RemoteControl();
|
||||
|
||||
|
||||
|
||||
|
||||
install(index0, 0,QIcon(":/img/warning.png"),tr("Inspector"));
|
||||
install(index1, 1,QIcon(":/img/warning.png"),tr("Log"));
|
||||
install(index2, 2,QIcon(":/img/warning.png"),tr("Replay"));
|
||||
|
||||
@@ -19,9 +19,6 @@ QString STR2HTML(QByteArray &str)
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
||||
{
|
||||
QString msgstr;
|
||||
@@ -90,9 +87,6 @@ Tools_Index3::Tools_Index3(QWidget *parent) :
|
||||
|
||||
ui->comboBox_EndType->setFixedSize(w,h);
|
||||
ui->lineEdit->setFixedHeight(h);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Tools_Index3::~Tools_Index3()
|
||||
|
||||
@@ -22,54 +22,14 @@ tools_Index4::tools_Index4(QWidget *parent) :
|
||||
|
||||
setWindowTitle(tr("Servos Inspector"));
|
||||
|
||||
//setWindowFlags(Qt::Dialog);
|
||||
|
||||
|
||||
loadCommandJson("./Init/Init.json");
|
||||
|
||||
/*
|
||||
addGroup(0);
|
||||
addGroup(1);
|
||||
addGroup(2);
|
||||
addGroup(3);
|
||||
addGroup(4);
|
||||
|
||||
|
||||
/*
|
||||
|
||||
QObjectList groups = ui->frame->children();
|
||||
|
||||
|
||||
foreach (QObject *child, groups) {
|
||||
|
||||
QGroupBox *box = qobject_cast<QGroupBox *>(child);
|
||||
|
||||
if(box)
|
||||
{
|
||||
QObjectList objlist = box->children();
|
||||
|
||||
foreach (QObject *obj, objlist) {
|
||||
QProgressBar *progressbar = qobject_cast<QProgressBar *>(obj);
|
||||
|
||||
if(progressbar)
|
||||
{
|
||||
QStringList namelist = progressbar->objectName().split(QLatin1Char('_'));
|
||||
|
||||
QString group_str = namelist.at(1);
|
||||
QString index_str = namelist.at(2);
|
||||
|
||||
bool ret = false;
|
||||
int group = group_str.toInt(&ret);
|
||||
int index = index_str.toInt();
|
||||
|
||||
if(ret == true)
|
||||
{
|
||||
barlist.insert(group * 16 + index,progressbar);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
tools_Index4::~tools_Index4()
|
||||
@@ -89,18 +49,6 @@ void tools_Index4::mouseReleaseEvent(QMouseEvent *event)
|
||||
else if (event->button() == Qt::RightButton)
|
||||
{
|
||||
|
||||
if(event->modifiers() == Qt::ControlModifier)
|
||||
{
|
||||
QFileDialog *dlg = new QFileDialog();
|
||||
|
||||
QString fileName = dlg->getOpenFileName(this, tr("Selete Init File..."),
|
||||
"./Init/",
|
||||
tr("Init file (*.json)"));
|
||||
if(!fileName.isEmpty())
|
||||
{
|
||||
loadCommandJson(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,62 +57,13 @@ void tools_Index4::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
|
||||
}
|
||||
|
||||
void tools_Index4::loadCommandJson(const QString& jsonFilename)
|
||||
{
|
||||
if (jsonFilename.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "Loading " << jsonFilename;
|
||||
|
||||
QFile jsonFile(jsonFilename);
|
||||
if (!jsonFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
qWarning() << "Unable to open file" << jsonFilename << jsonFile.errorString();
|
||||
return;
|
||||
}
|
||||
|
||||
QByteArray bytes = jsonFile.readAll();
|
||||
|
||||
jsonFile.close();
|
||||
QJsonParseError jsonParseError;
|
||||
QJsonDocument doc = QJsonDocument::fromJson(bytes, &jsonParseError);
|
||||
if (jsonParseError.error != QJsonParseError::NoError) {
|
||||
qWarning() << jsonFilename << "Unable to open json document" << jsonParseError.errorString();
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonObject json = doc.object();
|
||||
qDebug() << "command version :" << json.value("version").toInt();
|
||||
QJsonValue jsonValue = json.value("ServoSetting");
|
||||
|
||||
if (!jsonValue.isObject()) {
|
||||
qWarning() << jsonFilename << "_CommandButtonJsonKey not object";
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonObject infojson = jsonValue.toObject();
|
||||
|
||||
|
||||
QJsonValue MaxValue = infojson.value("Max");
|
||||
if (!MaxValue.isArray()) {
|
||||
qWarning() << jsonFilename << "_CommandButtonJsonKey not Array";
|
||||
return;
|
||||
}
|
||||
Max = MaxValue.toArray();
|
||||
|
||||
QJsonValue MinValue = infojson.value("Min");
|
||||
if (!MinValue.isArray()) {
|
||||
qWarning() << jsonFilename << "_CommandButtonJsonKey not Array";
|
||||
return;
|
||||
}
|
||||
Min = MinValue.toArray();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void tools_Index4::setChannel(int port,QMap<int,uint16_t> pwm)
|
||||
{
|
||||
if(!barlist.contains(port * 16 + 1))
|
||||
{
|
||||
addGroup(port);
|
||||
}
|
||||
|
||||
for (int var = 1; var <= 16; ++var) {
|
||||
QProgressBar *progress = barlist.value(port * 16 + var);
|
||||
|
||||
|
||||
@@ -47,9 +47,6 @@ public:
|
||||
public slots:
|
||||
void setChannel(int port,QMap<int,uint16_t> value);
|
||||
|
||||
void loadCommandJson(const QString& jsonFilename);
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user