comparison ui/createinstallerdialog.cpp @ 361:b67dd46cd4a9

Added dialog to create a new, signed installer binary.
author Raimund Renkert <rrenkert@intevation.de>
date Sat, 12 Apr 2014 17:19:38 +0200
parents
children 17e1c8f37d72
comparison
equal deleted inserted replaced
360:c0eac5c8c245 361:b67dd46cd4a9
1 #include "createinstallerdialog.h"
2 #include <QDebug>
3 #include <QDir>
4 #include <QPushButton>
5 #include <QGroupBox>
6 #include <QHBoxLayout>
7 #include <QVBoxLayout>
8 #include <QLabel>
9 #include <QFileDialog>
10
11 CreateInstallerDialog::CreateInstallerDialog(QMainWindow *parent) :
12 QDialog(parent)
13 {
14 setWindowTitle(tr("adminstrator - Create signed installer binary"));
15 setupGUI();
16 }
17
18 void CreateInstallerDialog::setupGUI()
19 {
20 /* Top level layout / widgets */
21 QVBoxLayout *topLayout = new QVBoxLayout;
22 QHBoxLayout *headerLayout = new QHBoxLayout;
23 QVBoxLayout *centerLayout = new QVBoxLayout;
24 QHBoxLayout *bottomLayout = new QHBoxLayout;
25 QHBoxLayout *archiveLayout = new QHBoxLayout;
26 QHBoxLayout *certLayout = new QHBoxLayout;
27 QHBoxLayout *saveLayout = new QHBoxLayout;
28
29 QString descString = tr("Create a new signed installer binary.\n");
30 descString.append("Select the archive, certificate and destination directory.");
31 QLabel *description = new QLabel(descString);
32 headerLayout->addWidget(description);
33
34 QLabel *archiveLabel = new QLabel("Select source archive:");
35 archiveLabel->setFixedWidth(140);
36 mArchiveFile = new QLineEdit();
37 QPushButton *archiveSelect = new QPushButton("...");
38 connect(archiveSelect, SIGNAL(clicked()), this, SLOT(openArchiveSelect()));
39 archiveSelect->setFixedWidth(30);
40 archiveLayout->addWidget(archiveLabel);
41 archiveLayout->addWidget(mArchiveFile);
42 archiveLayout->addWidget(archiveSelect);
43
44 QLabel *certLabel = new QLabel("Select certificate:");
45 certLabel->setFixedWidth(140);
46 mCertFile = new QLineEdit();
47 QPushButton *certSelect = new QPushButton("...");
48 connect(certSelect, SIGNAL(clicked()), this, SLOT(openCertificateSelect()));
49 certSelect->setFixedWidth(30);
50 certLayout->addWidget(certLabel);
51 certLayout->addWidget(mCertFile);
52 certLayout->addWidget(certSelect);
53
54 QLabel *saveLabel = new QLabel("Select target location:");
55 saveLabel->setFixedWidth(140);
56 mSaveFile = new QLineEdit();
57 QPushButton *saveSelect = new QPushButton("...");
58 connect(saveSelect, SIGNAL(clicked()), this, SLOT(openSaveLocation()));
59 saveSelect->setFixedWidth(30);
60 saveLayout->addWidget(saveLabel);
61 saveLayout->addWidget(mSaveFile);
62 saveLayout->addWidget(saveSelect);
63
64 centerLayout->addLayout(archiveLayout);
65 centerLayout->addLayout(certLayout);
66 centerLayout->addLayout(saveLayout);
67
68 QPushButton *create = new QPushButton(tr("Create Installer"));
69 connect(create, SIGNAL(clicked()), this, SLOT(createInstaller()));
70 bottomLayout->insertStretch(0, 10);
71 bottomLayout->addWidget(create);
72
73 topLayout->addLayout(headerLayout);
74 topLayout->addLayout(centerLayout);
75 topLayout->insertStretch(2, 10);
76 topLayout->addLayout(bottomLayout);
77
78 setLayout(topLayout);
79
80 return;
81 }
82
83 void CreateInstallerDialog::openCertificateSelect()
84 {
85 QString certFile = QFileDialog::getOpenFileName(
86 this, tr("Select certificate"), QDir::homePath(), "*.pem *.der *.crt");
87 mCertFile->setText(certFile);
88 }
89
90 void CreateInstallerDialog::openArchiveSelect()
91 {
92 QString archiveFile = QFileDialog::getOpenFileName(
93 this, tr("Select source archive"), QDir::homePath(), "*.zip *.tar.gz");
94 mArchiveFile->setText(archiveFile);
95 }
96
97 void CreateInstallerDialog::openSaveLocation()
98 {
99 QString saveFile = QFileDialog::getExistingDirectory(
100 this, tr("Select target location"), QDir::homePath());
101 mSaveFile->setText(saveFile);
102 }
103
104 void CreateInstallerDialog::createInstaller()
105 {
106 qDebug() << "and now create the installer using:";
107 qDebug() << "source archive: " << mArchiveFile->text();
108 qDebug() << "certificate: " << mCertFile->text();
109 qDebug() << "target" << mSaveFile->text();
110 // TODO
111 }

http://wald.intevation.org/projects/trustbridge/