# HG changeset patch # User Raimund Renkert # Date 1396967287 -7200 # Node ID 3261b2a9cab7ddcc5359376633d130d179c29f2e # Parent ad28f6b60e6bd8b8c9e709f970ba78df60d70cf4 Added a first version of the management application gui. diff -r ad28f6b60e6b -r 3261b2a9cab7 ui/CMakeLists.txt --- a/ui/CMakeLists.txt Mon Apr 07 14:50:08 2014 +0000 +++ b/ui/CMakeLists.txt Tue Apr 08 16:28:07 2014 +0200 @@ -27,12 +27,22 @@ ${DOWNLOADER_SOURCES} ) +set(MANAGEMENT_SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/management.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/managementwindow.cpp + ${CERTIFICATELIST_SOURCES} +) + # Seperated to make it easier to include the sources in tests set(M13UI_RESOURCES ${CMAKE_CURRENT_SOURCE_DIR}/icons.qrc ${CMAKE_CURRENT_SOURCE_DIR}/certs.qrc ) +set(MANAGEMENT_RESOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/icons.qrc +) + if(UNIX) # See: https://bugreports.qt-project.org/browse/QTBUG-35918 # XCB_EXTRA_LIBS should be gotten automatically. @@ -86,7 +96,18 @@ ${EXTRA_STATIC_LIBS} ${PROFILING_LIBS}) +set(MANAGEMENT_SOURCES_WITH_RESOURCES ${MANAGEMENT_SOURCES}) +qt5_add_resources(MANAGEMENT_SOURCES_WITH_RESOURCES ${MANAGEMENT_RESOURCES}) +add_executable(management ${MANAGEMENT_SOURCES_WITH_RESOURCES}) + +target_link_libraries(management Qt5::Widgets + m13_common + ${POLARSSL_LIBRARIES} + ${EXTRA_STATIC_LIBS} + ${PROFILING_LIBS}) + # Tests add_subdirectory(tests) install(TARGETS m13ui DESTINATION bin) +install(TARGETS management DESTINATION bin) diff -r ad28f6b60e6b -r 3261b2a9cab7 ui/management.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui/management.cpp Tue Apr 08 16:28:07 2014 +0200 @@ -0,0 +1,41 @@ +#include "managementwindow.h" + +#include +#include +#include +#include + +#ifndef VERSION +#define VERSION "0.0.1" +#endif + +#ifndef APPNAME +#define APPNAME "management" +#endif + +#ifndef ORGANIZATION +#define ORGANIZATION "m13org" +#endif + +#ifdef Q_OS_WIN + Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin) +#else + Q_IMPORT_PLUGIN(QXcbIntegrationPlugin) +#endif + +int main(int argc, char **argv) +{ + QApplication app (argc, argv); + + QStringList arguments = QApplication::arguments(); + + QApplication::setOrganizationName(QString::fromLatin1(ORGANIZATION)); + QApplication::setApplicationName(QString::fromLatin1(APPNAME)); + QApplication::setApplicationVersion(QString::fromLatin1(VERSION)); + QSettings::setDefaultFormat(QSettings::IniFormat); + + ManagementWindow mgntWin; + mgntWin.show(); + + return app.exec(); +} diff -r ad28f6b60e6b -r 3261b2a9cab7 ui/managementwindow.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui/managementwindow.cpp Tue Apr 08 16:28:07 2014 +0200 @@ -0,0 +1,120 @@ +#include "managementwindow.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +ManagementWindow::ManagementWindow() { + createActions(); + createMenuBar(); + createContent(); +} + +void ManagementWindow::createActions() +{ +} + +void ManagementWindow::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 ManagementWindow::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("

" + tr("Management Application") + "

"); + 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 ManagementWindow::showSettings() +{ + qDebug() << "show settingsdialog"; +} + +void ManagementWindow::showHelp() +{ + qDebug() << "show helpdialog"; +} + +void ManagementWindow::showAbout() +{ + qDebug() << "show aboutdialog"; +} + +void ManagementWindow::createInstaller() +{ + qDebug() << "create Installer"; +} + diff -r ad28f6b60e6b -r 3261b2a9cab7 ui/managementwindow.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui/managementwindow.h Tue Apr 08 16:28:07 2014 +0200 @@ -0,0 +1,47 @@ +#ifndef MANAGEMENTWINDOW_H +#define MANAGEMENTWINDOW_H + +/** + * @file managementwindow.h + * @brief Management UI controller + */ + +#include +#include +#include +#include +#include + +class QMenu; +class QAction; + +class ManagementWindow : public QMainWindow +{ + Q_OBJECT + +public: + ManagementWindow(); + +private slots: + void createInstaller(); + void showSettings(); + void showHelp(); + void showAbout(); + +private: + void createActions(); + void createMenuBar(); + void createContent(); + + QSettings settings; + + QMenuBar *menuBar; + + QListWidget *certificateList; + QPushButton *saveButton; + QPushButton *loadButton; + QPushButton *addButton; + QPushButton *removeButton; +}; + +#endif // MANAGEMENTWINDOW_H