-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqtrandomcodemaindialog.cpp
More file actions
59 lines (49 loc) · 1.52 KB
/
qtrandomcodemaindialog.cpp
File metadata and controls
59 lines (49 loc) · 1.52 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
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#include "qtrandomcodemaindialog.h"
#include <string>
#include <vector>
#include <QDesktopWidget>
#include <QKeyEvent>
#include "about.h"
#include "qtaboutdialog.h"
#include "ui_qtrandomcodemaindialog.h"
#include "randomcode.h"
#include "randomcodemenudialog.h"
#pragma GCC diagnostic pop
ribi::QtRandomCodeMainDialog::QtRandomCodeMainDialog(QWidget *parent) :
QtHideAndShowDialog(parent),
ui(new Ui::QtRandomCodeMainDialog)
{
ui->setupUi(this);
//Put the dialog in the screen center
const QRect screen = QApplication::desktop()->screenGeometry();
this->setGeometry( screen.adjusted(64,64,-64,-64));
this->move( screen.center() - this->rect().center() );
ui->button_generate->click();
}
ribi::QtRandomCodeMainDialog::~QtRandomCodeMainDialog() noexcept
{
delete ui;
}
void ribi::QtRandomCodeMainDialog::keyPressEvent(QKeyEvent * event)
{
if (event->key() == Qt::Key_Escape) { close(); return; }
}
void ribi::QtRandomCodeMainDialog::on_button_generate_clicked()
{
const std::vector<std::string> v = RandomCode::CreateRandomCode();
ui->textEdit->clear();
for(const std::string& s: v)
{
ui->textEdit->append(s.c_str());
}
}
void ribi::QtRandomCodeMainDialog::on_button_about_clicked()
{
About about = RandomCodeMenuDialog().GetAbout();
//about.AddLibrary("QtConnectThreeWidget version: " + QtConnectThreeWidget::GetVersion());
QtAboutDialog d(about);
this->ShowChild(&d);
}