comparison ui/administratorwindow.cpp @ 336:26817025351f

merge
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 09 Apr 2014 13:49:59 +0000
parents 811eec4e1b99
children e3d6de930c90
comparison
equal deleted inserted replaced
332:81a205fc651e 336:26817025351f
1 #include "administratorwindow.h"
2
3 #include <QDebug>
4 #include <QMessageBox>
5 #include <QAction>
6 #include <QMenu>
7 #include <QApplication>
8 #include <QHBoxLayout>
9 #include <QVBoxLayout>
10 #include <QGroupBox>
11 #include <QSplitter>
12 #include <QLabel>
13 #include <QImage>
14 #include <QCheckBox>
15 #include <QHeaderView>
16
17 #include "certificatetablemodel.h"
18
19 AdministratorWindow::AdministratorWindow() {
20 createActions();
21 createMenuBar();
22 createContent();
23 }
24
25 void AdministratorWindow::createActions()
26 {
27 }
28
29 void AdministratorWindow::createMenuBar()
30 {
31 menuBar = new QMenuBar(this);
32 QMenu *menu = new QMenu(tr("Menu"), menuBar);
33 menuBar->addMenu(menu);
34 QAction *createInstaller = menu->addAction(tr("Create Installer"));
35 QAction *settings = menu->addAction(tr("Settings"));
36 menu->addSeparator();
37 QAction *help = menu->addAction(tr("Help"));
38 QAction *about = menu->addAction(tr("About"));
39 menu->addSeparator();
40 QAction *quit = menu->addAction(tr("Quit"));
41 connect(createInstaller, SIGNAL(triggered()), this, SLOT(createInstaller()));
42 connect(settings, SIGNAL(triggered()), this, SLOT(showSettings()));
43 connect(help, SIGNAL(triggered()), this, SLOT(showHelp()));
44 connect(about, SIGNAL(triggered()), this, SLOT(showAbout()));
45 connect(quit, SIGNAL(triggered()), qApp, SLOT(quit()));
46 setMenuBar(menuBar);
47 }
48
49 void AdministratorWindow::createContent()
50 {
51 // Create a central widget containing the main layout.
52 QWidget *base = new QWidget;
53
54 // Layouts and Container
55 QVBoxLayout *mainLayout = new QVBoxLayout;
56 QVBoxLayout *certLayout = new QVBoxLayout;
57 QHBoxLayout *headerLayout = new QHBoxLayout;
58 QVBoxLayout *headerTextLayout = new QVBoxLayout;
59 QHBoxLayout *bottomLayout = new QHBoxLayout;
60
61 // The certificate list
62 QGroupBox *certBox = new QGroupBox(tr("Managed Certificates"));
63 certificateView = new QTableView;
64 certificateView->setModel(new CertificateTabelModel());
65 certificateView->setColumnWidth(0, 30);
66 certificateView->setColumnWidth(2, 130);
67 certificateView->setColumnWidth(3, 130);
68 certificateView->setColumnWidth(4, 200);
69
70 certLayout->addWidget(certificateView);
71 certBox->setLayout(certLayout);
72
73 // The header (icon, about text)
74 QImage *logoImage = new QImage(":/img/logo.png");
75 QLabel *logo = new QLabel;
76 logo->setBackgroundRole(QPalette::Base);
77 logo->setPixmap(QPixmap::fromImage(*logoImage));
78 QLabel *title = new QLabel("<h2>" + tr("Administrator Application") + "</h2>");
79 QLabel *subTitle = new QLabel("This Software creates a signed file containing certificates");
80 headerTextLayout->addWidget(title);
81 headerTextLayout->addWidget(subTitle);
82 headerLayout->addWidget(logo);
83 headerLayout->addLayout(headerTextLayout);
84 headerLayout->setStretch(0, 0);
85 headerLayout->setStretch(1, 10);
86
87 // The buttons.
88 bottomLayout->setAlignment(Qt::AlignBottom);
89 saveButton = new QPushButton(tr("Save"));
90 loadButton = new QPushButton(tr("Load"));
91 addButton = new QPushButton(tr("Add"));
92 removeButton = new QPushButton(tr("Remove"));
93 bottomLayout->addWidget(saveButton);
94 bottomLayout->addWidget(loadButton);
95 bottomLayout->addWidget(addButton);
96 bottomLayout->addWidget(removeButton);
97 bottomLayout->insertStretch(4, 10);
98
99 mainLayout->addLayout(headerLayout);
100 mainLayout->addWidget(certBox);
101 mainLayout->addLayout(bottomLayout);
102
103
104 // QMainWindow allready has a layout. All child layouts and widgets are
105 // managed in the central widget.
106 base->setLayout(mainLayout);
107 setCentralWidget(base);
108 certificateView->horizontalHeader()->setSectionResizeMode(1,
109 QHeaderView::Stretch);
110 }
111
112 void AdministratorWindow::showSettings()
113 {
114 qDebug() << "show settingsdialog";
115 }
116
117 void AdministratorWindow::showHelp()
118 {
119 qDebug() << "show helpdialog";
120 }
121
122 void AdministratorWindow::showAbout()
123 {
124 qDebug() << "show aboutdialog";
125 }
126
127 void AdministratorWindow::createInstaller()
128 {
129 qDebug() << "create Installer";
130 }
131

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