-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinformationwindow.cpp
More file actions
101 lines (85 loc) · 3.41 KB
/
Copy pathinformationwindow.cpp
File metadata and controls
101 lines (85 loc) · 3.41 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include "informationwindow.h"
#include "ui_informationwindow.h"
void InformationWindow::createInformationWidgets()
{
this->informationFont.setFamily("Alien Encounters");
this->informationFont.setPixelSize(16);
this->labelInformation = new QLabel("System information: ", this);
this->labelInformation->setGeometry(15, 5, this->WIDTH - 30, 30);
this->labelInformation->setFont(this->informationFont);
this->labelInformation->show();
QFile informationFile("./store/info/information.txt");
informationFile.open(QFile::ReadOnly);
this->informationFont.setFamily("Autumn");
this->informationFont.setPixelSize(14);
QFile styleFile(":/styleScrollBar.css");
styleFile.open(QFile::ReadOnly);
this->verticalScrollBar = new QScrollBar(nullptr);
this->verticalScrollBar->setStyleSheet(styleFile.readAll());
this->textEditInformation = new QTextEdit(this);
this->textEditInformation->setReadOnly(true);
this->textEditInformation->setGeometry(15, 35, this->WIDTH - 30, this->HEIGHT - 95);
this->textEditInformation->setText(informationFile.readAll());
this->textEditInformation->setFont(this->informationFont);
this->textEditInformation->setVerticalScrollBar(this->verticalScrollBar);
this->textEditInformation->show();
this->informationFont.setFamily("Good Times");
this->informationFont.setPixelSize(11);
this->buttonOK = new QPushButton("OK", this);
this->buttonOK->setGeometry(this->WIDTH - 115, this->HEIGHT - 45, 100, 30);
this->buttonOK->setFont(this->informationFont);
this->buttonOK->show();
connect(this->buttonOK,SIGNAL(clicked()),this,SLOT(handleInformationOK()));
}
void InformationWindow::handleInformationOK()
{
this->close();
}
void InformationWindow::readInformation()
{
QFile informationFile("./store/info/information.txt");
informationFile.open(QFile::ReadOnly);
if(informationFile.size() == 0)
{
informationFile.close();
QString program = "msinfo32 /report ./store/info/information.txt";
QProcess *myProcess = new QProcess(this);
QString command = QString("cmd.exe %1 \"%2 \"").arg(" /C ").arg(program);
myProcess->start(command);
if (myProcess->waitForStarted(-1))
{
while(myProcess->waitForReadyRead(-1)){}
}
myProcess->kill();
if(myProcess)
delete myProcess;
}
else
informationFile.close();
}
InformationWindow::InformationWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::InformationWindow)
{
ui->setupUi(this);
this->readInformation();
this->informationIcon = new QIcon("./store/icons/mainIcon.ico");
this->setWindowTitle("Information");
this->setBaseSize(this->WIDTH, this->HEIGHT);
this->setMaximumSize(this->WIDTH, this->HEIGHT);
this->setMinimumSize(this->WIDTH, this->HEIGHT);
this->setWindowIcon(*this->informationIcon);
QFile styleFileMainWindow(":/styleInformationWindow.css");
styleFileMainWindow.open(QFile::ReadOnly);
this->setStyleSheet(styleFileMainWindow.readAll());
this->createInformationWidgets();
}
InformationWindow::~InformationWindow()
{
delete this->buttonOK;
delete this->informationIcon;
delete this->labelInformation;
delete this->verticalScrollBar;
delete this->textEditInformation;
delete ui;
}