-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhistoryviewcard.cpp
165 lines (144 loc) · 5.43 KB
/
historyviewcard.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
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#include "historyviewcard.h"
#include<QVBoxLayout>
#include"ElaCheckBox.h"
#include"ElaIconButton.h"
#include<QPainter>
#include <QEvent>
#include <QMouseEvent>
#include <QDesktopServices>
#include <QUrl>
#include"ElaApplication.h"
HistoryViewCard::HistoryViewCard(QString file,QString cloud,QString p)
{
filename=new ElaText(file);
cloudName=cloud;
cloudname=new ElaText(cloud);
this->path=p;
fullText=file;
cfullText=cloud;
filename->setWordWrap(false);
cloudname->setWordWrap(false);
filename->setTextSize(16);
filename->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
QWidget* filenameWidget = new QWidget();
filenameWidget->setWindowFlags(Qt::FramelessWindowHint);
filenameWidget->setAttribute(Qt::WA_TranslucentBackground);
filenameWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
QVBoxLayout* filenameArea = new QVBoxLayout(filenameWidget);
filenameArea->addWidget(filename, 0, Qt::AlignLeft);
cloudname->setTextSize(16);
cloudname->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
QWidget* cloudnameWidget = new QWidget();
cloudnameWidget->setWindowFlags(Qt::FramelessWindowHint);
cloudnameWidget->setAttribute(Qt::WA_TranslucentBackground);
cloudnameWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
QVBoxLayout* cloudnameArea = new QVBoxLayout(cloudnameWidget);
cloudnameArea->addWidget(cloudname, 0, Qt::AlignLeft);
button=new ElaIconButton(ElaIconType::AngleDown,this);
button->setFixedSize(35,35);
QVBoxLayout*buttonArea=new QVBoxLayout();
buttonArea->addWidget(button,0,Qt::AlignCenter);
ElaText* catalogueText0 = new ElaText("", this);
catalogueText0->setTextSize(16);
catalogueText0->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
catalogueText0->setFixedSize(25,20);
catalogueText0->setAlignment(Qt::AlignCenter); // 设置文本居中对齐
QVBoxLayout* catalogueArea0 = new QVBoxLayout();
catalogueArea0->addWidget(catalogueText0, 0, Qt::AlignCenter);
QHBoxLayout*FileCardArea=new QHBoxLayout(this);
FileCardArea->addLayout(catalogueArea0);
FileCardArea->addWidget(filenameWidget);
FileCardArea->addWidget(cloudnameWidget);
FileCardArea->addLayout(buttonArea);
FileCardArea->setStretchFactor(catalogueArea0,25);
FileCardArea->setStretchFactor(filenameWidget,430);
FileCardArea->setStretchFactor(cloudnameWidget,375);
FileCardArea->setStretchFactor(buttonArea,35);
filenameWidget->setStyleSheet("QToolTip { color: #5C5C5C; background-color: #F9F9F9; border: 1px solid #808080; border-radius: 3px; }");
cloudnameWidget->setStyleSheet("QToolTip { color: #5C5C5C; background-color: #F9F9F9; border: 1px solid #808080; border-radius: 3px; }");
}
SubCard::SubCard(QString ID,quint64 d,QString time)
{
if(ID.length()>=9)
{
ID=ID.right(9);
}
versionID=new ElaText(ID);
datasize=d;
bindtime=new ElaText(time);
QString size;
QString dataStr;
double data=d;
data/=1024;
if(data<1024)
{
dataStr=QString::number(data,'f',1);
size=dataStr+"KB";
}
else
{
data/=1024;
if(data<1024)
{
dataStr=QString::number(data,'f',1);
size=dataStr+"MB";
}
else
{
data/=1024;
dataStr=QString::number(data,'f',1);
size=dataStr+"GB";
}
}
ElaText *dataSize = new ElaText(size, this);
versionID->setWordWrap(true);
dataSize->setWordWrap(false);
bindtime->setWordWrap(false);
versionID->setTextSize(16);
versionID->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
versionID->setFixedSize(180,30);
versionID->setAlignment(Qt::AlignCenter);
QVBoxLayout*versionIDArea=new QVBoxLayout();
versionIDArea->addWidget(versionID,0,Qt::AlignCenter);
dataSize->setTextSize(16);
dataSize->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
dataSize->setFixedSize(100,20);
QVBoxLayout*dataSizeArea=new QVBoxLayout();
dataSizeArea->addWidget(dataSize,0,Qt::AlignCenter);
bindtime->setTextSize(16);
bindtime->setFixedWidth(200);
QVBoxLayout*bindtimeArea=new QVBoxLayout();
bindtimeArea->addWidget(bindtime,0,Qt::AlignCenter);
rollback=new ElaPushButton("下载");
rollback->setFixedWidth(100);
QHBoxLayout *rollbackArea=new QHBoxLayout();
rollbackArea->addWidget(rollback);
QHBoxLayout*subcardLayout=new QHBoxLayout(this);
subcardLayout->addLayout(bindtimeArea);
subcardLayout->addLayout(versionIDArea);
subcardLayout->addLayout(dataSizeArea);
subcardLayout->addLayout(rollbackArea);
subcardLayout->setStretchFactor(bindtimeArea,245);
subcardLayout->setStretchFactor(versionIDArea,245);
subcardLayout->setStretchFactor(dataSizeArea,245);
subcardLayout->setStretchFactor(rollback,100);
}
void SubCard::paintEvent(QPaintEvent* event)
{
QPainter painter(this);
painter.save();
auto themeMode=ElaApplication::getInstance()->getThemeMode();
if (themeMode == ElaApplicationType::Light)
{
painter.setPen(QPen(QColor(0xDF, 0xDF, 0xDF), 1));
painter.setBrush(QColor(0xF5, 0xF5, 0xF5));
}
else
{
painter.setPen(QPen(QColor(0x37, 0x37, 0x37), 1));
painter.setBrush(QColor(0x1C, 0x22, 0x32));
}
QRect foregroundRect(1, 1, width() - 2, height() - 2);
painter.drawRoundedRect(foregroundRect, 6, 6);
painter.restore();
}