Mercurial > trustbridge
changeset 193:17eb8ad43984
merged.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Wed, 26 Mar 2014 12:22:24 +0100 |
parents | 103daf2d39c0 (diff) 2551ad24d3c2 (current diff) |
children | 56ae02b4a0fc 4790a26c2e8b |
files | |
diffstat | 5 files changed, 139 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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} )
--- /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 <QDebug> +#include <QVBoxLayout> +#include <QTextEdit> +#include <QPushButton> + +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); +}
--- /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 <QDialog> +#include <QMainWindow> +/** + * @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
--- 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 <QApplication> #include <QFile> #include <QTimer> +#include <QHBoxLayout> +#include <QVBoxLayout> +#include <QGroupBox> +#include <QPushButton> +#include <QSplitter> // 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>("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); +}
--- 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 <QMainWindow> #include <QSettings> #include <QMenuBar> +#include <QListWidget> +#include <QTextEdit> #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