-
Notifications
You must be signed in to change notification settings - Fork 1
/
dialogfiledelete.cpp
77 lines (59 loc) · 1.85 KB
/
dialogfiledelete.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
#include "dialogfiledelete.h"
DialogFileDelete::DialogFileDelete(QWidget *parent, int mode) : QDialog(parent), _mode(mode)
{
setWindowIcon(QIcon(":/ico.png"));
setFixedSize(QSize(600,100));
mainLay = new QVBoxLayout(this);
le_fileName = new QLineEdit;
combox = new QComboBox;
QHBoxLayout *lay_edit = new QHBoxLayout;
QHBoxLayout *lay_btns = new QHBoxLayout;
mainLay->addLayout(lay_edit);
mainLay->addLayout(lay_btns);
lay_edit->addWidget(new QLabel("Target Path:"));
lay_edit->addWidget(combox);
lay_edit->addWidget(le_fileName);
combox->addItem("${srcdir}");
combox->addItem("${pkgdir}");
combox->setCurrentIndex(1);
QPushButton *btn_cancel = new QPushButton("Cancel");
QPushButton *btn_apply = new QPushButton("Apply");
lay_btns->addStretch();
lay_btns->addWidget(btn_cancel);
lay_btns->addStretch();
lay_btns->addWidget(btn_apply);
lay_btns->addStretch();
le_fileName->setText("/");
//file
if(_mode == 0)
{
setWindowTitle("Delete File");
}
//dir
if(_mode == 1)
{
setWindowTitle("Delete Dir");
}
connect(btn_cancel, &QPushButton::clicked, [=](){
int ret = QMessageBox::question(this, "Confirming", "Are you sure to exit?");
if(ret == QMessageBox::Yes)
{
close();
}
});
connect(btn_apply, &QPushButton::clicked, [=](){
if(le_fileName->text()=="/")
{
QMessageBox::critical(this, "Error", "Please input the target path!");
return;
}
if(_mode == 0)
{
emit signalAddOperation(tr("rm -f %1").arg(combox->currentText()+le_fileName->text()));
}
if(_mode == 1)
{
emit signalAddOperation(tr("rm -rf %1").arg(combox->currentText()+le_fileName->text()));
}
});
}