-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtwaitform.cpp
More file actions
65 lines (53 loc) · 1.5 KB
/
Copy pathtwaitform.cpp
File metadata and controls
65 lines (53 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "twaitform.h"
#include <QCloseEvent>
#include <QDesktopServices>
#include <QString>
#include <QUrl>
#include <stdio.h>
#include <string>
#include "Base/tphrases.h"
#include "ui_twaitform.h"
using namespace std;
TWaitForm::TWaitForm(QWidget* parent) : QDialog(parent), ui(new Ui::TWaitForm) {
ui->setupUi(this);
Timer = new QTimer(this);
connect(Timer, SIGNAL(timeout()), this, SLOT(Update()));
Timer->start(100);
connect(ui->label_2, SIGNAL(linkActivated(const QString&)), this, SLOT(LinkActivated(const QString&)));
if (MyTranslator.CheckDictionary("TWaitForm") == false) {
MyTranslator.AddEng("Wait for %d secs");
MyTranslator.AddRus("Ждите %d секунд");
MyTranslator.AddDictionary("TWaitForm");
};
}
TWaitForm::~TWaitForm() {
delete Timer;
delete ui;
}
void TWaitForm::Update() {
WaitTime -= Timer->interval() / 1000.0;
UpdateLabel();
if (WaitTime <= 0) {
this->close();
}
}
void TWaitForm::SetWaitTime(double Time) {
WaitTime = Time;
UpdateLabel();
}
void TWaitForm::UpdateLabel() {
char Buf[128];
sprintf(Buf, MyTranslator.tr("Wait for %lf secs").c_str(), WaitTime);
ui->label->setText(QString::fromUtf8(Buf));
}
void TWaitForm::closeEvent(QCloseEvent* event) {
if (WaitTime <= 0)
QDialog::changeEvent(event);
else
event->ignore();
}
void TWaitForm::reject() {}
void TWaitForm::LinkActivated(const QString& Link) {
QDesktopServices S;
S.openUrl(QUrl(Link));
}