1 /* vi: set sw=4 ts=4: 2 * 3 * Copyright (C) 2015 Christian Hohnstaedt. 4 * 5 * All rights reserved. 6 */ 7 8 #ifndef __XCADIALOG_H 9 #define __XCADIALOG_H 10 11 #include <QList> 12 #include <QDialog> 13 #include "ui_XcaDialog.h" 14 #include "lib/db.h" 15 #include "MainWindow.h" 16 #include "Help.h" 17 18 // index = enum pki_type 19 static const char * const PixmapMap[] = { 20 "" ":keyImg", ":csrImg", ":certImg", ":revImg", ":tempImg", "", ":scardImg", 21 }; 22 23 class XcaDialog : public QDialog, public Ui::XcaDialog 24 { 25 QWidget *widg; 26 public: 27 XcaDialog(QWidget *parent, enum pki_type type, QWidget *w, QString t, 28 QString desc, QString help_ctx = QString()) 29 : QDialog(parent ?: mainwin) 30 { 31 setupUi(this); 32 setWindowTitle(XCA_TITLE); 33 image->setPixmap(QPixmap(PixmapMap[type])); 34 content->addWidget(w); 35 mainwin->helpdlg->register_ctxhelp_button(this, help_ctx); 36 37 widg = w; 38 title->setText(t); 39 if (desc.isEmpty()) { 40 verticalLayout->removeWidget(description); 41 delete description; 42 } else { 43 description->setText(desc); 44 } 45 } noSpacer()46 void noSpacer() 47 { 48 verticalLayout->removeItem(topSpacer); 49 verticalLayout->removeItem(bottomSpacer); 50 delete topSpacer; 51 delete bottomSpacer; 52 if (widg) 53 widg->setSizePolicy(QSizePolicy::Expanding, 54 QSizePolicy::Expanding); 55 } aboutDialog(const QPixmap & left)56 void aboutDialog(const QPixmap &left) 57 { 58 title->setPixmap(left.scaledToHeight(title->height())); 59 noSpacer(); 60 resize(560, 400); 61 buttonBox->setStandardButtons(QDialogButtonBox::Ok); 62 buttonBox->centerButtons(); 63 } 64 }; 65 66 #endif 67