76 lines
1.8 KiB
C++
76 lines
1.8 KiB
C++
#include "guimessagedialog.h"
|
|
#include "ui_guimessagedialog.h"
|
|
#include "event/EventCenter.h"
|
|
GUIMessageDialog::GUIMessageDialog(QWidget *parent) :
|
|
QDialog(parent),
|
|
ui(new Ui::GUIMessageDialog)
|
|
{
|
|
ui->setupUi(this);
|
|
this->setWindowFlags (Qt :: FramelessWindowHint | Qt :: Dialog);
|
|
this->showFullScreen ();
|
|
ui->lbl_msg->setVisible(false);
|
|
ui->lbl_progressicon->setVisible(false);
|
|
ui->btn_main->setVisible(false);
|
|
this->setWindowOpacity(0.6);
|
|
for (int i=1; i<=6;i++)
|
|
{
|
|
QString str(" ");
|
|
for(int j=0;j<i;j++)
|
|
{
|
|
str[j]='.';
|
|
}
|
|
frame.append(str);
|
|
}
|
|
for (int i=1; i<=6;i++)
|
|
{
|
|
QString str("......");
|
|
for(int j=0;j<i;j++)
|
|
{
|
|
str[j]=' ';
|
|
}
|
|
frame.append(str);
|
|
}
|
|
connect(EventCenter::Default(),&EventCenter::InvokeOperationEnd,[=](){
|
|
if (timerID != -1){
|
|
killTimer(timerID);
|
|
timerID = -1;
|
|
}
|
|
accept();
|
|
});
|
|
}
|
|
|
|
GUIMessageDialog::~GUIMessageDialog()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
void GUIMessageDialog::timerEvent(QTimerEvent *event) {
|
|
if (frameIndex>11) frameIndex = frameIndex % 12;
|
|
ui->lbl_progressicon->setText(frame[frameIndex++]);
|
|
this->update();
|
|
printf("trigger timer event\r\n");
|
|
}
|
|
|
|
void GUIMessageDialog::stopLoading() {
|
|
if (timerID!=-1)killTimer(timerID);
|
|
ui->lbl_progressicon->setVisible(false);
|
|
|
|
}
|
|
|
|
void GUIMessageDialog::startLoading() {
|
|
ui->lbl_progressicon->setVisible(true);
|
|
timerID = startTimer(100);
|
|
}
|
|
|
|
void GUIMessageDialog::showMessage(QString msg) {
|
|
ui->lbl_msg->setText(msg);
|
|
}
|
|
|
|
void GUIMessageDialog::showExitButton() {
|
|
ui->btn_main->setVisible(true);
|
|
disconnect(ui->btn_main);
|
|
connect(ui->btn_main,&QToolButton::clicked,[=](){
|
|
accept();
|
|
});
|
|
}
|