编写主界面逻辑
This commit is contained in:
parent
cf3b2c94d0
commit
38b316018e
126
mainwindow.cpp
126
mainwindow.cpp
@ -9,6 +9,7 @@
|
||||
#include "singlerelay.h"
|
||||
#include "tachometer.h"
|
||||
#include "seismic_monitor.h"
|
||||
#include "setpoint.h"
|
||||
#include <QMessageBox>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
@ -77,7 +78,7 @@ void MainWindow::readJsonFile(const QString &filePath)
|
||||
QJsonObject obj = value.toObject();
|
||||
slot_config.slot = obj["slot"].toInt();
|
||||
slot_config.slot_type = obj["slot_type"].toInt();
|
||||
slot_config.chan_type = obj["chan_type"].toString();
|
||||
slot_config.chan_display = obj["chan_display"].toString();
|
||||
slot_config.rack_type = obj["rack_type"].toString();
|
||||
map_slot_config.insert(slot_id,slot_config);
|
||||
slot_id ++;
|
||||
@ -88,8 +89,9 @@ void MainWindow::createMenu()
|
||||
{
|
||||
QList<QAbstractButton*> buttonList = btnGroup_slot->buttons();
|
||||
for (int i = 0; i < buttonList.count(); i++){
|
||||
//buttonList[i]->setText(map_slot_config[i + 3].chan_type);
|
||||
buttonList[i]->setText(map_slot_config[i + 3].chan_display);
|
||||
createMenu(QString("%1").arg(i + 1), (QPushButton*)buttonList[i]);
|
||||
map_slot_config[ i + 3].slot_btn = (QPushButton*)buttonList[i];
|
||||
// else
|
||||
// createMenuSet(QString("%1").arg(i + 1), (QPushButton*)buttonList[i]);
|
||||
}
|
||||
@ -97,7 +99,6 @@ void MainWindow::createMenu()
|
||||
void MainWindow::createMenu(const QString& rootTitle, QPushButton* parent )
|
||||
{
|
||||
// 创建主菜单
|
||||
qDebug() << "createMenu" << parent->objectName() << endl;
|
||||
QMenu *mainMenu = new QMenu(rootTitle, parent);
|
||||
|
||||
// 创建第一层子菜单:/30 振电器模块
|
||||
@ -201,30 +202,124 @@ void MainWindow::onMenuActionTriggered()
|
||||
QString rack_type = action->text().right(action->text().length()-4);
|
||||
int button_id = button->objectName().right(button->objectName().length()-15).toInt();
|
||||
qDebug() << slot_type << rack_type << button_id << map_slot_config[button_id + 1].slot_type << map_slot_config[button_id + 2].slot_type << endl;
|
||||
if(rack_type == "三冗余板卡" && (map_slot_config[button_id + 1].slot_type != 0 \
|
||||
if(rack_type == "三冗余板卡" && (map_slot_config[button_id].slot_type != 0 || map_slot_config[button_id + 1].slot_type != 0 \
|
||||
|| map_slot_config[button_id + 2].slot_type != 0)){
|
||||
QMessageBox::information(this, QStringLiteral("提示"), "不要重叠三冗余板卡配置,请在创建新配置之前移除现有的配置!");
|
||||
return;
|
||||
}else if(rack_type == "三冗余板卡" && map_slot_config[button_id + 1].slot_type == 0 \
|
||||
&& map_slot_config[button_id + 2].slot_type == 0){
|
||||
map_slot_config[button_id].slot_type = slot_type;
|
||||
map_slot_config[button_id].rack_type = "TMR";
|
||||
map_slot_config[button_id].rack_type = "TMR1";
|
||||
map_slot_config[button_id].slot_btn->setText(action->text());
|
||||
map_slot_config[button_id].chan_display = action->text();
|
||||
map_slot_config[button_id + 1].slot_type = slot_type;
|
||||
map_slot_config[button_id + 1].rack_type = "TMR2";
|
||||
map_slot_config[button_id + 1].slot_btn->setText(action->text());
|
||||
map_slot_config[button_id + 1].chan_display = action->text();
|
||||
map_slot_config[button_id + 2].slot_type = slot_type;
|
||||
map_slot_config[button_id + 2].rack_type = "TMR3";
|
||||
map_slot_config[button_id + 2].slot_btn->setText(action->text());
|
||||
map_slot_config[button_id + 2].chan_display = action->text();
|
||||
}
|
||||
if(rack_type == "两板卡" && map_slot_config[button_id + 1].slot_type != 0 ){
|
||||
if(rack_type == "两板卡" && (map_slot_config[button_id].slot_type != 0 || map_slot_config[button_id + 1].slot_type != 0 )){
|
||||
QMessageBox::information(this, QStringLiteral("提示"), "不要重叠两板卡配置,请在创建新配置之前移除现有的配置!");
|
||||
return;
|
||||
}else if(rack_type == "两板卡" && map_slot_config[button_id + 1].slot_type == 0){
|
||||
map_slot_config[button_id].slot_type = slot_type;
|
||||
map_slot_config[button_id].rack_type = "Double";
|
||||
map_slot_config[button_id].rack_type = "Double1";
|
||||
map_slot_config[button_id].slot_btn->setText(action->text());
|
||||
map_slot_config[button_id].chan_display = action->text();
|
||||
map_slot_config[button_id + 1].slot_type = slot_type;
|
||||
map_slot_config[button_id + 1].rack_type = "Double2";
|
||||
map_slot_config[button_id + 1].slot_btn->setText(action->text());
|
||||
map_slot_config[button_id + 1].chan_display = action->text();
|
||||
}
|
||||
if(rack_type == "单板卡" && map_slot_config[button_id].slot_type != 0){
|
||||
QMessageBox::information(this, QStringLiteral("提示"), "不要重叠单板卡配置,请在创建新配置之前移除现有的配置!");
|
||||
return;
|
||||
}else if(rack_type == "单板卡" && map_slot_config[button_id].slot_type == 0) {
|
||||
map_slot_config[button_id].slot_type = slot_type;
|
||||
map_slot_config[button_id].rack_type = "Single";
|
||||
map_slot_config[button_id].chan_display = action->text();
|
||||
button->setText(action->text());
|
||||
QMenu* menu = button->menu();
|
||||
if (!menu) {
|
||||
qWarning() << "菜单为空,无法清除属性!";
|
||||
return;
|
||||
}
|
||||
|
||||
QString reset_slot = action->text();
|
||||
qDebug() << "action->text():" << action->text() << reset_slot;
|
||||
if(reset_slot == "重置模块"){
|
||||
if(map_slot_config[button_id].rack_type == "TMR1"){
|
||||
map_slot_config[button_id].slot_type = 0;
|
||||
map_slot_config[button_id].rack_type = "0";
|
||||
map_slot_config[button_id].slot_btn->setText("");
|
||||
map_slot_config[button_id].chan_display = "";
|
||||
map_slot_config[button_id + 1].slot_type = 0;
|
||||
map_slot_config[button_id + 1].rack_type = "0";
|
||||
map_slot_config[button_id + 1].slot_btn->setText("");
|
||||
map_slot_config[button_id + 1].chan_display = "";
|
||||
map_slot_config[button_id + 2].slot_type = 0;
|
||||
map_slot_config[button_id + 2].rack_type = "0";
|
||||
map_slot_config[button_id + 2].slot_btn->setText("");
|
||||
map_slot_config[button_id + 2].chan_display = "";
|
||||
}else if(map_slot_config[button_id].rack_type == "TMR2"){
|
||||
map_slot_config[button_id - 1].slot_type = 0;
|
||||
map_slot_config[button_id - 1].rack_type = "0";
|
||||
map_slot_config[button_id - 1].slot_btn->setText("");
|
||||
map_slot_config[button_id - 1].chan_display = "";
|
||||
map_slot_config[button_id].slot_type = 0;
|
||||
map_slot_config[button_id].rack_type = "0";
|
||||
map_slot_config[button_id].slot_btn->setText("");
|
||||
map_slot_config[button_id].chan_display = "";
|
||||
map_slot_config[button_id + 1].slot_type = 0;
|
||||
map_slot_config[button_id + 1].rack_type = "0";
|
||||
map_slot_config[button_id + 1].slot_btn->setText("");
|
||||
map_slot_config[button_id + 1].chan_display = "";
|
||||
}else if(map_slot_config[button_id].rack_type == "TMR3"){
|
||||
map_slot_config[button_id - 2].slot_type = 0;
|
||||
map_slot_config[button_id - 2].rack_type = "0";
|
||||
map_slot_config[button_id - 2].slot_btn->setText("");
|
||||
map_slot_config[button_id - 2].chan_display = "";
|
||||
map_slot_config[button_id - 1].slot_type = 0;
|
||||
map_slot_config[button_id - 1].rack_type = "0";
|
||||
map_slot_config[button_id - 1].slot_btn->setText("");
|
||||
map_slot_config[button_id - 1].chan_display = "";
|
||||
map_slot_config[button_id].slot_type = 0;
|
||||
map_slot_config[button_id].rack_type = "0";
|
||||
map_slot_config[button_id].slot_btn->setText("");
|
||||
map_slot_config[button_id].chan_display = "";
|
||||
}
|
||||
|
||||
if(map_slot_config[button_id].rack_type == "Double1"){
|
||||
map_slot_config[button_id].slot_type = 0;
|
||||
map_slot_config[button_id].rack_type = "0";
|
||||
map_slot_config[button_id].slot_btn->setText("");
|
||||
map_slot_config[button_id].chan_display = "";
|
||||
map_slot_config[button_id + 1].slot_type = 0;
|
||||
map_slot_config[button_id + 1].rack_type = "0";
|
||||
map_slot_config[button_id + 1].slot_btn->setText("");
|
||||
map_slot_config[button_id + 1].chan_display = "";
|
||||
|
||||
}else if(map_slot_config[button_id].rack_type == "Double2"){
|
||||
map_slot_config[button_id - 1].slot_type = 0;
|
||||
map_slot_config[button_id - 1].rack_type = "0";
|
||||
map_slot_config[button_id - 1].slot_btn->setText("");
|
||||
map_slot_config[button_id - 1].chan_display = "";
|
||||
map_slot_config[button_id].slot_type = 0;
|
||||
map_slot_config[button_id].rack_type = "0";
|
||||
map_slot_config[button_id].slot_btn->setText("");
|
||||
map_slot_config[button_id].chan_display = "";
|
||||
}
|
||||
if(map_slot_config[button_id].rack_type == "Single"){
|
||||
map_slot_config[button_id].slot_type = 0;
|
||||
map_slot_config[button_id].rack_type = "0";
|
||||
map_slot_config[button_id].slot_btn->setText("");
|
||||
map_slot_config[button_id].chan_display = "";
|
||||
}
|
||||
}
|
||||
// QMenu* menu = button->menu();
|
||||
// if (!menu) {
|
||||
// qWarning() << "菜单为空,无法清除属性!";
|
||||
// return;
|
||||
// }
|
||||
clearMenuProperties(button->menu());
|
||||
createMenu();
|
||||
break; // 找到按钮后,跳出循环
|
||||
@ -261,6 +356,13 @@ void MainWindow::OnButtonGroup(QAbstractButton * slot_btn)
|
||||
tachometer->show();
|
||||
}
|
||||
}
|
||||
if(slot_btn != NULL && ui->pushButton_alarm->isChecked()){
|
||||
QString object_name = slot_btn->objectName();
|
||||
qDebug() << object_name << endl;
|
||||
Setpoint *setpoint = new Setpoint();
|
||||
setpoint->setWindowModality(Qt::ApplicationModal);
|
||||
setpoint->show();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_slot_clicked()
|
||||
@ -314,7 +416,7 @@ void MainWindow::on_pushButton_save_clicked()
|
||||
for(int i = 0; i < map_slot_config.size();i++){
|
||||
itemObj["slot"] = map_slot_config[i+3].slot;
|
||||
itemObj["slot_type"] = map_slot_config[i+3].slot_type;
|
||||
itemObj["chan_type"] = map_slot_config[i+3].chan_type;
|
||||
itemObj["chan_display"] = map_slot_config[i+3].chan_display;
|
||||
itemObj["rack_type"] = map_slot_config[i+3].rack_type;
|
||||
slotArray.append(itemObj);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user