feat:历史事件对话框增加信MessageBox
This commit is contained in:
parent
64007be44a
commit
99d90201e7
|
|
@ -2,6 +2,7 @@
|
|||
#define ALARMEVENTMAINDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "global.h"
|
||||
#include "alarmEventGlobal.h"
|
||||
#include "alarmEventUtils.h"
|
||||
|
||||
|
|
@ -11,7 +12,10 @@ class alarmEventMainDialog;
|
|||
}
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class TransparentMask;
|
||||
class MessageDialog;
|
||||
class AlarmEventDataView;
|
||||
|
||||
class AlarmEventMainDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
@ -27,15 +31,24 @@ signals:
|
|||
|
||||
protected:
|
||||
void showEvent(QShowEvent* event) override;
|
||||
void resizeEvent(QResizeEvent*) override;
|
||||
|
||||
private slots:
|
||||
void onSignal_subDialogClose();
|
||||
void onSyncDataStatus(const PaginationInfo&);
|
||||
void onLoadDataError(const QString&);
|
||||
|
||||
public slots:
|
||||
void onBtnClicked_close();
|
||||
|
||||
private:
|
||||
void showTransparentMask();
|
||||
void hideTransparentMask();
|
||||
void showMessageDialog(MessageDialogType,const QString&,const QString&);
|
||||
|
||||
Ui::alarmEventMainDialog* ui;
|
||||
TransparentMask* m_pTransparentMask;
|
||||
MessageDialog* m_pMessageDialog;
|
||||
AlarmEventDataView* m_tableView;
|
||||
AlarmDataMode m_mode;
|
||||
AlarmEventDataFilter m_eventFilter;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,16 @@
|
|||
#include "alarmEventMainDialog.h"
|
||||
#include "ui_alarmEventMainDialog.h"
|
||||
#include "transparentMask.h"
|
||||
#include "messageDialog.h"
|
||||
//#include "dashboardFrame.h"
|
||||
#include "alarmEventDataView.h"
|
||||
|
||||
AlarmEventMainDialog::AlarmEventMainDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::alarmEventMainDialog)
|
||||
, m_mode(Historical)
|
||||
, m_pTransparentMask(nullptr)
|
||||
, m_pMessageDialog(nullptr)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setWindowFlags(Qt::FramelessWindowHint);
|
||||
|
|
@ -22,6 +27,7 @@ AlarmEventMainDialog::AlarmEventMainDialog(QWidget *parent)
|
|||
m_tableView->model()->setFilter(m_eventFilter);
|
||||
ui->tableLayout->addWidget(m_tableView);
|
||||
connect(m_tableView->model(), &AlarmEventDataModel::syncDataStatus, this, &AlarmEventMainDialog::onSyncDataStatus);
|
||||
connect(m_tableView->model(), &AlarmEventDataModel::loadDataError, this, &AlarmEventMainDialog::onLoadDataError);
|
||||
|
||||
connect(ui->btnClose, &QPushButton::clicked, this, &AlarmEventMainDialog::onBtnClicked_close);
|
||||
}
|
||||
|
|
@ -36,6 +42,46 @@ void AlarmEventMainDialog::showEvent(QShowEvent* event)
|
|||
QDialog::showEvent(event);
|
||||
}
|
||||
|
||||
void AlarmEventMainDialog::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
if(m_pTransparentMask && m_pTransparentMask->isVisible())
|
||||
m_pTransparentMask->setGeometry(0, 0, this->width(), this->height());
|
||||
}
|
||||
|
||||
void AlarmEventMainDialog::showTransparentMask()
|
||||
{
|
||||
if(m_pTransparentMask == nullptr)
|
||||
m_pTransparentMask = new TransparentMask(this);
|
||||
|
||||
m_pTransparentMask->setGeometry(0, 0, this->width(), this->height());
|
||||
m_pTransparentMask->show();
|
||||
}
|
||||
void AlarmEventMainDialog::hideTransparentMask()
|
||||
{
|
||||
if(m_pTransparentMask && m_pTransparentMask->isVisible())
|
||||
m_pTransparentMask->hide();
|
||||
}
|
||||
|
||||
void AlarmEventMainDialog::showMessageDialog(MessageDialogType type,const QString& strTitle,const QString& strContent)
|
||||
{
|
||||
if(m_pMessageDialog == nullptr)
|
||||
{
|
||||
m_pMessageDialog = new MessageDialog(this);
|
||||
m_pMessageDialog->installEventFilter(this);
|
||||
connect(m_pMessageDialog, SIGNAL(sgl_hide()), this, SLOT(onSignal_subDialogClose()));
|
||||
}
|
||||
|
||||
m_pMessageDialog->setMessage(type, strTitle, strContent);
|
||||
int nX = (this->width() - m_pMessageDialog->width()) * 0.5;
|
||||
int nY = (this->height() - m_pMessageDialog->height()) * 0.5;
|
||||
m_pMessageDialog->move(nX, nY);
|
||||
m_pMessageDialog->raise();
|
||||
if(type == type_question)
|
||||
m_pMessageDialog->exec();
|
||||
else
|
||||
m_pMessageDialog->show();
|
||||
}
|
||||
|
||||
void AlarmEventMainDialog::setMode(AlarmDataMode mode)
|
||||
{
|
||||
if(mode == RealTime)
|
||||
|
|
@ -52,6 +98,11 @@ void AlarmEventMainDialog::setMode(AlarmDataMode mode)
|
|||
m_mode = mode;
|
||||
}
|
||||
|
||||
void AlarmEventMainDialog::onSignal_subDialogClose()
|
||||
{
|
||||
hideTransparentMask();
|
||||
}
|
||||
|
||||
void AlarmEventMainDialog::onSyncDataStatus(const PaginationInfo& paginationInfo)
|
||||
{
|
||||
QString recordInfo = QString::fromWCharArray(L"共 %1 条记录").arg(paginationInfo.totalEntries);
|
||||
|
|
@ -59,6 +110,11 @@ void AlarmEventMainDialog::onSyncDataStatus(const PaginationInfo& paginationInfo
|
|||
ui->lineEditPage->setText(QString::number(paginationInfo.currentPage));
|
||||
}
|
||||
|
||||
void AlarmEventMainDialog::onLoadDataError(const QString& error)
|
||||
{
|
||||
showMessageDialog(type_information, QString("错误"), QString("加载数据失败(%1)").arg(error));
|
||||
}
|
||||
|
||||
void AlarmEventMainDialog::onBtnClicked_close()
|
||||
{
|
||||
//reject();
|
||||
|
|
|
|||
|
|
@ -146,6 +146,15 @@ void DashboardFrame::resizeEvent(QResizeEvent* event)
|
|||
m_pDashboardNamingDialog->move(nX, nY);
|
||||
}
|
||||
|
||||
if(m_pAlarmEventMainDialog && m_pAlarmEventMainDialog->isVisible())
|
||||
{
|
||||
int nWidth = this->width() * 0.8;
|
||||
int nHeight = this->height() * 0.8;
|
||||
int nX = this->geometry().x() + (this->width() - nWidth) * 0.5;
|
||||
int nY = this->geometry().y() + (this->height() - nHeight) * 0.5;
|
||||
m_pAlarmEventMainDialog->setGeometry(nX, nY, nWidth, nHeight);
|
||||
}
|
||||
|
||||
double ratioX = (double)event->size().width() / (double)event->oldSize().width();
|
||||
double ratioY = (double)event->size().height() / (double)event->oldSize().height();
|
||||
//qDebug() << ratioX << ", " << ratioY;
|
||||
|
|
|
|||
Loading…
Reference in New Issue