view ui/administratorwindow.cpp @ 334:36be67070dcb

Added table model for certificates.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 09 Apr 2014 12:43:40 +0200
parents de94c4ec22b1
children 811eec4e1b99
line wrap: on
line source
#include "administratorwindow.h"

#include <QDebug>
#include <QMessageBox>
#include <QAction>
#include <QMenu>
#include <QApplication>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QGroupBox>
#include <QSplitter>
#include <QLabel>
#include <QImage>
#include <QCheckBox>

AdministratorWindow::AdministratorWindow() {
    createActions();
    createMenuBar();
    createContent();
}

void AdministratorWindow::createActions()
{
}

void AdministratorWindow::createMenuBar()
{
    menuBar = new QMenuBar(this);
    QMenu *menu = new QMenu(tr("Menu"), menuBar);
    menuBar->addMenu(menu);
    QAction *createInstaller = menu->addAction(tr("Create Installer"));
    QAction *settings = menu->addAction(tr("Settings"));
    menu->addSeparator();
    QAction *help = menu->addAction(tr("Help"));
    QAction *about = menu->addAction(tr("About"));
    menu->addSeparator();
    QAction *quit = menu->addAction(tr("Quit"));
    connect(createInstaller, SIGNAL(triggered()), this, SLOT(createInstaller()));
    connect(settings, SIGNAL(triggered()), this, SLOT(showSettings()));
    connect(help, SIGNAL(triggered()), this, SLOT(showHelp()));
    connect(about, SIGNAL(triggered()), this, SLOT(showAbout()));
    connect(quit, SIGNAL(triggered()), qApp, SLOT(quit()));
    setMenuBar(menuBar);
}

void AdministratorWindow::createContent()
{
    // Create a central widget containing the main layout.
    QWidget *base = new QWidget;

    // Layouts and Container
    QVBoxLayout *mainLayout = new QVBoxLayout;
    QVBoxLayout *certLayout = new QVBoxLayout;
    QHBoxLayout *headerLayout = new QHBoxLayout;
    QVBoxLayout *headerTextLayout = new QVBoxLayout;
    QHBoxLayout *bottomLayout = new QHBoxLayout;

    // The certificate list
    QGroupBox *certBox = new QGroupBox(tr("Managed Certificates"));
    certificateList = new QListWidget();
    certLayout->addWidget(certificateList);
    certBox->setLayout(certLayout);

    // The header (icon, about text)
    QImage *logoImage = new QImage(":/img/logo.png");
    QLabel *logo = new QLabel;
    logo->setBackgroundRole(QPalette::Base);
    logo->setPixmap(QPixmap::fromImage(*logoImage));
    QLabel *title = new QLabel("<h2>" + tr("Administrator Application") + "</h2>");
    QLabel *subTitle = new QLabel("This Software creates a signed file containing certificates");
    headerTextLayout->addWidget(title);
    headerTextLayout->addWidget(subTitle);
    headerLayout->addWidget(logo);
    headerLayout->addLayout(headerTextLayout);
    headerLayout->setStretch(0, 0);
    headerLayout->setStretch(1, 10);

    // The buttons.
    bottomLayout->setAlignment(Qt::AlignBottom);
    saveButton = new QPushButton(tr("Save"));
    loadButton = new QPushButton(tr("Load"));
    addButton = new QPushButton(tr("Add"));
    removeButton = new QPushButton(tr("Remove"));
    bottomLayout->addWidget(saveButton);
    bottomLayout->addWidget(loadButton);
    bottomLayout->addWidget(addButton);
    bottomLayout->addWidget(removeButton);
    bottomLayout->insertStretch(4, 10);

    mainLayout->addLayout(headerLayout);
    mainLayout->addWidget(certBox);
    mainLayout->addLayout(bottomLayout);


    // QMainWindow allready has a layout. All child layouts and widgets are
    // managed in the central widget.
    base->setLayout(mainLayout);
    setCentralWidget(base);
}

void AdministratorWindow::showSettings()
{
    qDebug() << "show settingsdialog";
}

void AdministratorWindow::showHelp()
{
    qDebug() << "show helpdialog";
}

void AdministratorWindow::showAbout()
{
    qDebug() << "show aboutdialog";
}

void AdministratorWindow::createInstaller()
{
    qDebug() << "create Installer";
}

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