feat: Add CEchoTestDialog & its style

This commit is contained in:
chenhuijun
2024-07-31 15:48:36 +08:00
parent 3a9d175533
commit abcdb45764
3 changed files with 188 additions and 0 deletions

View File

@@ -0,0 +1,135 @@
#include "CEchoTestDialog.h"
#include "action/ActionCreator.h"
#include "dicom/CEchoAction.h"
#include "components/LoadingWidget.h"
#include <QVBoxLayout>
#include <QGridLayout>
#include <QLabel>
#include <QVariant>
#include <QPushButton>
#include <QShowEvent>
#include <QGuiApplication>
#include <QScreen>
namespace
{
const int ENDLINE_SPACE = 3;
}
CEchoTestDialog::CEchoTestDialog(QWidget* aParent, Qt::WindowFlags aFlags)
:GUIFormBaseDialog(aParent, aFlags)
,mMessageLayout(new QGridLayout)
,mLoadingWidget(nullptr)
,mAction(new CEchoAction(this))
,mIndex(0)
,mCurrentMessageLabel(nullptr)
,mStarted(false)
{
// setFocusPolicy(Qt::ClickFocus);
setButtonMode(DialogButtonMode::OkOnly);
// setSizePolicy(QSizePolicy::Fixed,QSizePolicy::MinimumExpanding);
setMinimumHeight(200);
setFixedWidth(800);
QRect screenRect = QGuiApplication::primaryScreen()->geometry();
QPoint screenCenter = screenRect.center();
QPoint dialogPos = screenCenter - QPoint(width() / 2, height()/ 2);
move(dialogPos);
auto layout = new QVBoxLayout(mFormWidget);
//Title
QLabel* title = new QLabel(this);
title->setAlignment(Qt::AlignCenter);
title->setText(tr("Test DICOM Connection"));
title->setObjectName("title");
layout->addWidget(title);
layout->addLayout(mMessageLayout);
layout->addSpacerItem(new QSpacerItem(2,2,QSizePolicy::Minimum,QSizePolicy::MinimumExpanding));
connect(mAction, &CEchoAction::actionStepStart,this,&CEchoTestDialog::addActionMessage);
connect(mAction, &CEchoAction::actionStepCompleted,this,&CEchoTestDialog::updateCurrentActionResult);
connect(mAction, &CEchoAction::actionCompleted,this,&CEchoTestDialog::handleActionFinish);
mBtnOk->setEnabled(false);
QLabel* endline = new QLabel(this);
endline->setFixedHeight(ENDLINE_SPACE);
endline->setObjectName("endline");
layout->addWidget(endline);
}
CEchoTestDialog::~CEchoTestDialog()
{
}
void CEchoTestDialog::setCEchoSettings(const QList<CEchoSetting>& aCEchoSettings)
{
if (mAction){
for (const CEchoSetting& item : aCEchoSettings)
{
mAction->addCEchoActionItem(item);
}
}
setFixedHeight(200+ 30 *aCEchoSettings.length());
}
bool CEchoTestDialog::updateReferenceData()
{
return true;
}
void CEchoTestDialog::addActionMessage(const QString& aMessage)
{
mCurrentMessageLabel = new QLabel(aMessage);
if (mCurrentMessageLabel!=nullptr){
mCurrentMessageLabel->setObjectName("CEchoMessage");
mLoadingWidget = new LoadingWidget(this);
mLoadingWidget->setFixedSize(24,24);
mLoadingWidget->setMaxDiameter(5);
mLoadingWidget->setMinDiameter(1);
mLoadingWidget->setCount(8);
mMessageLayout->addWidget(mLoadingWidget,mIndex,1, Qt::AlignRight);
mMessageLayout->addWidget(mCurrentMessageLabel,mIndex,0);
}
}
void CEchoTestDialog::updateCurrentActionResult(const ActionResult& aResult)
{
if (mLoadingWidget){
delete mLoadingWidget;
}
QLabel * icon = new QLabel(this);
QPixmap pix(aResult.Code == ActionCode::Sucessed?":/icons/selected.png":":/icons/close_circle.png");
icon->setPixmap(pix.scaledToHeight(24, Qt::TransformationMode::SmoothTransformation));
mMessageLayout->addWidget(icon,mIndex,1, Qt::AlignRight);
if (mCurrentMessageLabel!=nullptr){
if(aResult.Code != ActionCode::Sucessed)mCurrentMessageLabel->setStyleSheet("color:red");
mCurrentMessageLabel->setText(aResult.Data.toString());
}
mIndex++;
}
void CEchoTestDialog::handleActionFinish(const ActionResult& aResult)
{
if (mCurrentMessageLabel!=nullptr){
QLabel * icon = new QLabel(this);
QPixmap pix(aResult.Code == ActionCode::Sucessed?":/icons/selected.png":":/icons/close_circle.png");
icon->setPixmap(pix.scaledToHeight(24, Qt::TransformationMode::SmoothTransformation));
mMessageLayout->addWidget(icon,mIndex,1, Qt::AlignRight);
if(aResult.Code != ActionCode::Sucessed)mCurrentMessageLabel->setStyleSheet("color:red");
mCurrentMessageLabel->setText(aResult.Data.toString());
}
mIndex++;
mLoadingWidget->setVisible(false);
mBtnOk->setEnabled(true);
}
void CEchoTestDialog::showEvent(QShowEvent *aEvent)
{
QDialog::showEvent(aEvent);
if (mStarted) return;
mAction->execute();
mStarted = true;
}

View File

@@ -0,0 +1,39 @@
#ifndef BF46771C_39DB_408E_8297_B979E36AC297
#define BF46771C_39DB_408E_8297_B979E36AC297
#include "GUIFormBaseDialog.h"
#include "dicom/CEchoSetting.h"
#include "dicom/CEchoAction.h"
class QGridLayout;
class LoadingWidget;
class QLabel;
class CEchoTestDialog :public GUIFormBaseDialog
{
Q_OBJECT
public:
explicit CEchoTestDialog(QWidget* aParent = nullptr, Qt::WindowFlags aFlags = Qt::WindowFlags());
~CEchoTestDialog() override;
void setCEchoSettings(const QList<CEchoSetting>& aCEchoSettings);
protected:
bool updateReferenceData() override;
void showEvent(QShowEvent *aEvent) override;
private:
void addActionMessage(const QString& aMessage);
void updateCurrentActionResult(const ActionResult& aResult);
void handleActionFinish(const ActionResult& aResult);
private:
QGridLayout* mMessageLayout;
LoadingWidget* mLoadingWidget;
CEchoAction* mAction;
int mIndex;
QLabel* mCurrentMessageLabel;
bool mStarted;
};
#endif /* BF46771C_39DB_408E_8297_B979E36AC297 */

View File

@@ -846,6 +846,10 @@ QToolButton#mppsSettingsButton{
text-align: center;
}
QPushButton#cechoButton{
background: #365880;
}
/*------AccountTableForm-----------------------------------------------------*/
QWidget#commandWidgetnoBBorder {
min-height: 123px;
@@ -905,6 +909,12 @@ QPushButton#btnOK {
font-weight: bold;
}
QPushButton#btnOK:disabled {
background: #365880;
font-weight: bold;
color: #606060;
}
/* GUIFormBaseDialog -> AccountFormDialog */
QToolButton#changePwdBtn{
qproperty-icon:url(":/icons/edit.png");
@@ -1225,6 +1235,10 @@ QWidget#ScanProcessWidget QLabel#ScanProcessInformation{
font-size: 50px;
}
QWidget#formWidget QLabel#CEchoMessage{
font-size: 24px;
}