Add WorkList Module.
This commit is contained in:
73
src/dialogs/AsyncActionDialog.cpp
Normal file
73
src/dialogs/AsyncActionDialog.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
#include "AsyncActionDialog.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
|
||||
#include "action/AsyncAction.h"
|
||||
#include "components/LoadingWidget.h"
|
||||
|
||||
AsyncActionDialog::AsyncActionDialog(AsyncAction* aAsyncAction,const QString& aTitle, QWidget* aParent, Qt::WindowFlags aFlags)
|
||||
: GUIFormBaseDialog(aParent,aFlags)
|
||||
, mContentWidget(new QWidget(mFormWidget))
|
||||
, mLoadingWidget(new QWidget(mFormWidget))
|
||||
, mAction(aAsyncAction)
|
||||
, mLayout(new QVBoxLayout(mFormWidget))
|
||||
{
|
||||
setFocusPolicy(Qt::ClickFocus);
|
||||
mLoadingWidget->hide();
|
||||
|
||||
initializeTitle(aTitle);
|
||||
initializeProgressBar();
|
||||
connect(mAction,&AsyncAction::actionCompleted,this,&AsyncActionDialog::handleFinishedAction);
|
||||
|
||||
mLayout->setSpacing(10);
|
||||
mLayout->addWidget(mContentWidget);
|
||||
mLayout->addWidget(mLoadingWidget);
|
||||
}
|
||||
|
||||
AsyncActionDialog::~AsyncActionDialog()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AsyncActionDialog::initializeTitle(const QString& aTitle)
|
||||
{
|
||||
QLabel* title = new QLabel(this);
|
||||
title->setAlignment(Qt::AlignCenter);
|
||||
title->setText(tr(aTitle.toLatin1()));
|
||||
title->setObjectName("title");
|
||||
title->setFixedHeight(40);
|
||||
mLayout->addWidget(title);
|
||||
}
|
||||
|
||||
void AsyncActionDialog::initializeProgressBar()
|
||||
{
|
||||
QVBoxLayout* loadingLayout = new QVBoxLayout(mLoadingWidget);
|
||||
|
||||
LoadingWidget* loadingWidget = new LoadingWidget(mLoadingWidget);
|
||||
loadingLayout->addWidget(loadingWidget);
|
||||
|
||||
}
|
||||
|
||||
AsyncAction* AsyncActionDialog::getAction()
|
||||
{
|
||||
return mAction;
|
||||
}
|
||||
|
||||
bool AsyncActionDialog::updateReferenceData()
|
||||
{
|
||||
mAction->execute();
|
||||
mContentWidget->hide();
|
||||
mBtnWidget->hide();
|
||||
mLoadingWidget->show();
|
||||
return false;
|
||||
}
|
||||
|
||||
void AsyncActionDialog::handleFinishedAction(const ActionResult& aResult)
|
||||
{
|
||||
mLoadingWidget->hide();
|
||||
if (aResult.Code == Sucessed)
|
||||
{
|
||||
accept();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user