# HG changeset patch # User Raimund Renkert # Date 1395832944 -3600 # Node ID 17eb8ad43984def9166784649013f5b818531bcf # Parent 103daf2d39c0654d186b8adce19b77fc615ea4a7# Parent 2551ad24d3c21686eac0a28de239cd37c2cfb59f merged. diff -r 2551ad24d3c2 -r 17eb8ad43984 ui/CMakeLists.txt --- a/ui/CMakeLists.txt Wed Mar 26 12:07:06 2014 +0100 +++ b/ui/CMakeLists.txt Wed Mar 26 12:22:24 2014 +0100 @@ -16,6 +16,7 @@ ${CMAKE_CURRENT_SOURCE_DIR}/mainwindow.cpp ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ${CMAKE_CURRENT_SOURCE_DIR}/listupdatedialog.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/helpdialog.cpp ${CERTIFICATELIST_SOURCES} ${DOWNLOADER_SOURCES} ) diff -r 2551ad24d3c2 -r 17eb8ad43984 ui/helpdialog.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui/helpdialog.cpp Wed Mar 26 12:22:24 2014 +0100 @@ -0,0 +1,28 @@ +#include "helpdialog.h" +#include +#include +#include +#include + +HelpDialog::HelpDialog(QMainWindow *parent) : + QDialog(parent) +{ + setupGUI(); +} + +void HelpDialog::setupGUI() +{ + QVBoxLayout *mainLayout = new QVBoxLayout(this); + QTextEdit *helpText = new QTextEdit; + helpText->setReadOnly(true); + helpText->setPlainText(tr("This dialog contains some text to help the user.")); + + QHBoxLayout *buttonLayout = new QHBoxLayout; + QPushButton *closeButton = new QPushButton(tr("Close")); + connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); + buttonLayout->insertStretch(0, 10); + buttonLayout->addWidget(closeButton); + + mainLayout->addWidget(helpText); + mainLayout->addLayout(buttonLayout); +} diff -r 2551ad24d3c2 -r 17eb8ad43984 ui/helpdialog.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui/helpdialog.h Wed Mar 26 12:22:24 2014 +0100 @@ -0,0 +1,21 @@ +#ifndef HELPDIALOG_H +#define HELPDIALOG_H + +#include +#include +/** + * @file helpdialog.h + * @brief The dialog for help text. + */ + +class HelpDialog : public QDialog +{ +public: + /** @brief Create a help dialog */ + HelpDialog(QMainWindow *parent); + +private: + void setupGUI(); + +}; +#endif // HELPDIALOG_H diff -r 2551ad24d3c2 -r 17eb8ad43984 ui/mainwindow.cpp --- a/ui/mainwindow.cpp Wed Mar 26 12:07:06 2014 +0100 +++ b/ui/mainwindow.cpp Wed Mar 26 12:22:24 2014 +0100 @@ -9,6 +9,11 @@ #include #include #include +#include +#include +#include +#include +#include // The amount of time in minutes stay silent if we have // something to say @@ -21,11 +26,13 @@ #include "certificatelist.h" #include "downloader.h" #include "listupdatedialog.h" +#include "helpdialog.h" MainWindow::MainWindow() { createActions(); createTrayIcon(); createMenuBar(); + createContent(); qRegisterMetaType("SSLConnection::ErrorCode"); connect(mTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), @@ -118,6 +125,7 @@ mCurMessage = tr("An updated certificate list is available. Click here to install."); setState(NewListAvailable); showMessage(); + loadCertificateList(); } } @@ -213,16 +221,88 @@ setMenuBar(mMenuBar); } -void MainWindow::showSettings() { +void MainWindow::createContent() +{ + // Create a central widget containing the main layout. + QWidget *base = new QWidget; + + QVBoxLayout *mainLayout = new QVBoxLayout; + QHBoxLayout *certLayout = new QHBoxLayout; + QHBoxLayout *bottomLayout = new QHBoxLayout; + + QGroupBox *certBox = new QGroupBox(tr("Managed Certificates")); + certificateList = new QListWidget; + connect(certificateList, SIGNAL(itemClicked(QListWidgetItem*)), + this, SLOT(showDetails(QListWidgetItem*))); + certificateDetails = new QTextEdit; + certificateDetails->setReadOnly(true); + QSplitter *splitter = new QSplitter(certBox); + splitter->addWidget(certificateList); + splitter->addWidget(certificateDetails); + certLayout->addWidget(splitter); + certBox->setLayout(certLayout); + + QPushButton *update = new QPushButton("Search for Updates"); + connect(update, SIGNAL(clicked()), this, SLOT(checkUpdates())); + bottomLayout->insertStretch(0, 10); + bottomLayout->addWidget(update); + 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 MainWindow::loadCertificateList() +{ + qDebug() << "display certificates"; + certificateList->clear(); + foreach (const Certificate &cert, mListToInstall.getInstallCertificates()) { + if (!cert.isValid()) { + qWarning() << "Invalid certificate in list"; + continue; + } + QListWidgetItem* item = new QListWidgetItem(cert.shortDescription()); + item->setData(Qt::UserRole, cert.details()); + QIcon *certIcon = new QIcon(":/img/tray_22.png"); + item->setIcon(*certIcon); + certificateList->addItem(item); + } + foreach (const Certificate& cert, mListToInstall.getRemoveCertificates()) { + if (!cert.isValid()) { + qWarning() << "Invalid certificate in list"; + continue; + } + QListWidgetItem* item = new QListWidgetItem(cert.shortDescription()); + item->setData(Qt::UserRole, cert.details()); + QIcon *certIcon = new QIcon(":/img/tray_22.png"); + item->setIcon(*certIcon); + certificateList->addItem(item); + } +} + +void MainWindow::showSettings() +{ qDebug() << "show settingsdialog"; } void MainWindow::showHelp() { qDebug() << "show helpdialog"; + HelpDialog *help = new HelpDialog(this); + help->show(); } void MainWindow::showAbout() { qDebug() << "show aboutdialog"; } + +void MainWindow::showDetails(QListWidgetItem *item) +{ + qDebug() << "show details"; + QString details = item->data(Qt::UserRole).toString(); + certificateDetails->setPlainText(details); +} diff -r 2551ad24d3c2 -r 17eb8ad43984 ui/mainwindow.h --- a/ui/mainwindow.h Wed Mar 26 12:07:06 2014 +0100 +++ b/ui/mainwindow.h Wed Mar 26 12:22:24 2014 +0100 @@ -10,6 +10,8 @@ #include #include #include +#include +#include #include "downloader.h" #include "certificatelist.h" @@ -49,6 +51,7 @@ void showSettings(); void showHelp(); void showAbout(); + void showDetails(QListWidgetItem*); private: /** @brief check the integrity of available files. @@ -63,6 +66,8 @@ void createTrayIcon(); void createActions(); void createMenuBar(); + void createContent(); + void loadCertificateList(); QString mCurMessage; QString mInstalledSWVersion; @@ -79,6 +84,9 @@ QMenuBar *mMenuBar; CertificateList mListToInstall; + + QListWidget *certificateList; + QTextEdit *certificateDetails; }; #endif // MAINWINDOW_H