Repository navigation
Expand file tree
/
Copy pathDownloadSetup.cpp
More file actions
74 lines (63 loc) · 2.41 KB
/
Copy pathDownloadSetup.cpp
File metadata and controls
74 lines (63 loc) · 2.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
#include "DownloadSetup.h"
#include <QtGui/QFileDialog>
DownloadSetup::DownloadSetup(QWidget *parent) : QWidget(parent) {
setButton = new QPushButton(tr("Select Directory"));
nextButton = new QPushButton(tr("Next"));
headingLabel = new QLabel(tr("<b>Select your downloads directory</b>"));
mainLabel = new QLabel(tr("Choose a directory to keep the downloaded files."));
downloadDir = QDir::home();
downloadDir.cd("Downloads");
downloadPath = downloadDir.absolutePath();
pathLabel = new QLabel(tr("Default: ") + downloadPath); //okay
imageLabel = new QLabel;
imageLabel->setPixmap(QPixmap(":/images/SetupAssistant/downloads.png"));
setButtonLayout = new QHBoxLayout;
setButtonLayout->addStretch();
setButtonLayout->addWidget(setButton);
setButtonLayout->addStretch();
headingLabelLayout = new QHBoxLayout;
headingLabelLayout->addStretch();
headingLabelLayout->addWidget(headingLabel);
headingLabelLayout->addStretch();
mainLabelLayout = new QHBoxLayout;
mainLabelLayout->addStretch();
mainLabelLayout->addWidget(mainLabel);
mainLabelLayout->addStretch();
pathLabelLayout = new QHBoxLayout;
pathLabelLayout->addStretch();
pathLabelLayout->addWidget(pathLabel);
pathLabelLayout->addStretch();
imageLabelLayout = new QHBoxLayout;
imageLabelLayout->addStretch();
imageLabelLayout->addWidget(imageLabel);
imageLabelLayout->addStretch();
buttonsLayout = new QHBoxLayout;
buttonsLayout->addStretch();
buttonsLayout->addWidget(nextButton);
mainLayout = new QVBoxLayout;
mainLayout->addLayout(headingLabelLayout);
mainLayout->addLayout(mainLabelLayout);
mainLayout->addLayout(pathLabelLayout);
mainLayout->addSpacing(10);
mainLayout->addLayout(imageLabelLayout);
mainLayout->addSpacing(10);
mainLayout->addLayout(setButtonLayout);
mainLayout->addStretch();
mainLayout->addLayout(buttonsLayout);
setLayout(mainLayout);
setFixedSize(810,610);
connect(nextButton,SIGNAL(clicked()),this,SIGNAL(setupFinished()));
connect(setButton,SIGNAL(clicked()),this,SLOT(chooseDownloadDirectory()));
}
void DownloadSetup::chooseDownloadDirectory() {
downloadPath = QFileDialog::getExistingDirectory(this,tr("Choose a folder"),QDir::homePath());
if(downloadPath.isEmpty()) {
downloadPath = downloadDir.absolutePath();
pathLabel = new QLabel(tr("Default: ") + downloadPath);
} else {
pathLabel->setText(tr("Your downloads will be saved to: ") + downloadPath);
}
}
QString DownloadSetup::getDownloadPath() {
return downloadPath;
}