123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- #include "compareitemdialog.h"
- #include "ui_compareitemwidget.h"
- #include "UIStyleManager.h"
- CompareItemDialog::CompareItemDialog(QWidget *parent)
- : DialogBase(parent)
- , ui(new Ui::CompareItemWidget)
- {
- QWidget *widgetContent = new QWidget(this);
- ui->setupUi(widgetContent);
- /* 设置内容 */
- setContentWidget(widgetContent);
- /* 设置标题 */
- setTitle("对比项信息", QSize(120, 18));
- /* 连接信号和槽 */
- connect(ui->pBtn_add, &QPushButton::clicked, this, &CompareItemDialog::do_pBtn_add_clicked);
- /* 连接静音、过载、反相三个按钮的开关 */
- connect(ui->checkBoxMute, &QCheckBox::clicked, this, &CompareItemDialog::do_checkBox_MOP_clicked);
- connect(ui->checkBoxOverload, &QCheckBox::clicked, this, &CompareItemDialog::do_checkBox_MOP_clicked);
- connect(ui->checkBoxPhase, &QCheckBox::clicked, this, &CompareItemDialog::do_checkBox_MOP_clicked);
- /* 设置默认开启 */
- ui->checkBoxMute->setChecked(true);
- ui->checkBoxOverload->setChecked(true);
- ui->checkBoxPhase->setChecked(true);
- /* 设置样式 */
- setQSS();
- }
- CompareItemDialog::~CompareItemDialog()
- {
- delete ui;
- }
- /* 获取生成的对比项信息 */
- CompareItemInfo_t& CompareItemDialog::getCompareItemInfo()
- {
- return m_compareItemInfo;
- }
- /* 新增通道 */
- void CompareItemDialog::do_pBtn_add_clicked()
- {
- QVBoxLayout* pLayout = qobject_cast<QVBoxLayout*>(ui->scrollAreaWidgetContents->layout());
- if(pLayout)
- {
- SingleCompareRoadWidget *pWgt = new SingleCompareRoadWidget(this);
- connect(pWgt, &SingleCompareRoadWidget::deleted, this, &CompareItemDialog::do_CompareRoadWgtDeleted);
- pWgt->setIndex(m_listOtherRoadWgt.size() + 3);
- pWgt->setDelBtnVisible(true);
- pWgt->setStyleSheet(m_qssRecordRoad);
- pLayout->insertWidget(m_listOtherRoadWgt.size(), pWgt);
- m_listOtherRoadWgt.append(pWgt);
- }
- }
- /* 删除通道 */
- void CompareItemDialog::do_CompareRoadWgtDeleted(int nIndex)
- {
- int nRealIndex = nIndex - 3;
- if(nRealIndex < m_listOtherRoadWgt.size())
- {
- SingleCompareRoadWidget *pWgt = m_listOtherRoadWgt.at(nRealIndex);
- m_listOtherRoadWgt.removeOne(pWgt);
- delete pWgt;
- pWgt = nullptr;
- }
- for(int i = nRealIndex; i < m_listOtherRoadWgt.size(); i++)
- {
- m_listOtherRoadWgt.at(i)->setIndex(i + 3);
- }
- }
- /* 静音、过载、反相检测条件开关 */
- void CompareItemDialog::do_checkBox_MOP_clicked(bool checked)
- {
- /* 获取信号发送者 */
- QCheckBox *checkBox = qobject_cast<QCheckBox*>(sender());
- checkBox->setText(checked ? "开启" : "关闭");
- if(checkBox == ui->checkBoxMute)
- {
- setMOPEditable(EDBType::DBType_Mute, checked);
- }
- else if(checkBox == ui->checkBoxOverload)
- {
- setMOPEditable(EDBType::DBType_Overload, checked);
- }
- else if(checkBox == ui->checkBoxPhase)
- {
- setMOPEditable(EDBType::DBType_Phase, checked);
- }
- }
- /* 设置样式表 */
- void CompareItemDialog::setQSS()
- {
- QString qssPath = UIStyle.getQSSPath() + "/compareitemwidget.qss";
- QFile file(qssPath);
- if(file.open(QFile::ReadOnly))
- {
- QString qss = file.readAll();
- file.close();
- /* 这里设置的是内容容器样式表,this是最外层的 */
- getContentWidget()->setStyleSheet(qss);
- ui->scrollArea->setStyleSheet(qss);
- ui->scrollAreaWidgetContents->setStyleSheet(qss);
- } else
- {
- SPDLOG_LOGGER_ERROR(m_logger, "打开QSS文件失败: {}", qssPath.toStdString());
- SPDLOG_LOGGER_ERROR(m_logger, "错误信息: {}", file.errorString().toStdString());
- }
- /* 清除父类的qss */
- // this->setStyleSheet("");
- // SPDLOG_LOGGER_INFO(m_logger, "qss: {}", getContentWidget()->styleSheet().toStdString());
- // ui->scrollArea->viewport()->setStyleSheet("background-color: #FFFFFF;"); // 设置滚动区域背景透明
- file.setFileName(UIStyle.getQSSPath() + "/singlecompareroadwidget.qss");
- if(file.open(QFile::ReadOnly))
- {
- m_qssRecordRoad = file.readAll();
- file.close();
- } else
- {
- SPDLOG_LOGGER_ERROR(m_logger, "打开QSS文件失败: {}", file.fileName().toStdString());
- SPDLOG_LOGGER_ERROR(m_logger, "错误信息: {}", file.errorString().toStdString());
- }
- ui->widget_mainRoad->setStyleSheet(m_qssRecordRoad);
- ui->widget_secondRoad->setStyleSheet(m_qssRecordRoad);
- }
- /* 设置静音过载反相可编辑 */
- void CompareItemDialog::setMOPEditable(EDBType type, bool editable)
- {
- if(type == EDBType::DBType_Mute)
- {
- if(editable)
- {
- ui->lineEditMuteLen->setEnabled(true);
- ui->lineEditMuteSensibility->setEnabled(true);
- ui->lineEditMuteThreshold->setEnabled(true);
- }else {
- ui->lineEditMuteLen->setEnabled(false);
- ui->lineEditMuteSensibility->setEnabled(false);
- ui->lineEditMuteThreshold->setEnabled(false);
- }
- }
- else if(type == EDBType::DBType_Overload)
- {
- if(editable)
- {
- ui->lineEditOverloadLen->setEnabled(true);
- ui->lineEditOverloadSensibility->setEnabled(true);
- ui->lineEditOverloadThreshold->setEnabled(true);
- }else {
- ui->lineEditOverloadLen->setEnabled(false);
- ui->lineEditOverloadSensibility->setEnabled(false);
- ui->lineEditOverloadThreshold->setEnabled(false);
- }
- }
- else if(type == EDBType::DBType_Phase)
- {
- if(editable)
- {
- ui->lineEditPhaseLen->setEnabled(true);
- ui->lineEditPhaseSensibility->setEnabled(true);
- ui->lineEditPhaseThreshold->setEnabled(true);
- }else {
- ui->lineEditPhaseLen->setEnabled(false);
- ui->lineEditPhaseSensibility->setEnabled(false);
- ui->lineEditPhaseThreshold->setEnabled(false);
- }
- }
- }
- /* 重载按下关闭按钮之前的操作 */
- bool CompareItemDialog::isOKClicked()
- {
- /* 获取对比项的信息 */
-
- /* 获取主通道信息 */
- /* 获取第二通道信息 */
- /* 获取其他通道信息 */
- /* 获取音频检测信息 */
- return true;
- }
|