-
Notifications
You must be signed in to change notification settings - Fork 3
/
fileinfo.cpp
75 lines (63 loc) · 1.94 KB
/
fileinfo.cpp
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
#include "fileinfo.h"
/* Informations displayed
*
* NAME : filename, size limited to xx char see mywindows.cpp
*
* WIDTH : int or 0 if not a image
*
* HEIGHT : int or 0 if not a image
*
* TYPE : extension of the file or "Not a standard file"
*
* SIZE : size in B, KB, GB..
*
**/
fileInfo::fileInfo(QWidget *parent) : QWidget(parent) {
layout = new QVBoxLayout;
commonName = QString("Name: ");
commonSize = QString("Size: ");
commonSizeEnd = QString("");
fontSize = QString("font: 14pt;");
width = QString("Width: Unknown");
height = QString("Height: Unknown");
fileType = QString("Type: Unknown");
name = new QLabel(commonName + "No file chosen");
size = new QLabel(commonSize + "0");
labelWidth = new QLabel(width);
labelHeight = new QLabel(height);
type = new QLabel(fileType);
name->setStyleSheet(fontSize);
size->setStyleSheet(fontSize);
labelWidth->setStyleSheet(fontSize);
labelHeight->setStyleSheet(fontSize);
type->setStyleSheet(fontSize);
layout->addWidget(name);
layout->addWidget(labelWidth);
layout->addWidget(labelHeight);
layout->addWidget(type);
layout->addWidget(size);
this->setLayout(layout);
}
void fileInfo::setType(QString ext) { type->setText("Type: " + ext); }
void fileInfo::setName(QString nameIn) { name->setText(commonName + nameIn); }
void fileInfo::setResolution(int width, int height) {
labelWidth->setText("Width: " + QString::number(width));
labelHeight->setText("Height: " + QString::number(height));
}
void fileInfo::setSize(int sizeIn) {
commonSizeEnd = QString(" B");
if (sizeIn > 1000) {
sizeIn = sizeIn / 1000;
commonSizeEnd = QString(" kB");
if (sizeIn > 1000) {
sizeIn = sizeIn / 1000;
commonSizeEnd = QString(" mB");
if (sizeIn > 1000) {
sizeIn = sizeIn / 1000;
commonSizeEnd = QString(" gB");
}
}
}
size->setText(commonSize + QString::number(sizeIn) + commonSizeEnd);
}
fileInfo::~fileInfo() {}