Commit e7a526cc authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Hide OpenPGP keys section if card does not provide OpenPGP keys

GnuPG-bug-id: 4876
parent 5ea28758
...@@ -46,6 +46,7 @@ P15CardWidget::P15CardWidget(QWidget *parent) ...@@ -46,6 +46,7 @@ P15CardWidget::P15CardWidget(QWidget *parent)
, mSerialNumber{new QLabel{this}} , mSerialNumber{new QLabel{this}}
, mVersionLabel{new QLabel{this}} , mVersionLabel{new QLabel{this}}
, mStatusLabel{new QLabel{this}} , mStatusLabel{new QLabel{this}}
, mOpenPGPKeysSection{new QWidget{this}}
, mOpenPGPKeysWidget{new OpenPGPKeyCardWidget{this}} , mOpenPGPKeysWidget{new OpenPGPKeyCardWidget{this}}
{ {
// Set up the scroll area // Set up the scroll area
...@@ -82,11 +83,17 @@ P15CardWidget::P15CardWidget(QWidget *parent) ...@@ -82,11 +83,17 @@ P15CardWidget::P15CardWidget(QWidget *parent)
areaVLay->addWidget(new KSeparator(Qt::Horizontal)); areaVLay->addWidget(new KSeparator(Qt::Horizontal));
areaVLay->addWidget(new QLabel(QStringLiteral("<b>%1</b>").arg(i18n("OpenPGP keys:")))); {
mOpenPGPKeysWidget->setAllowedActions(OpenPGPKeyCardWidget::NoAction); auto l = new QVBoxLayout{mOpenPGPKeysSection};
areaVLay->addWidget(mOpenPGPKeysWidget); l->setContentsMargins(0, 0, 0, 0);
l->addWidget(new QLabel(QStringLiteral("<b>%1</b>").arg(i18n("OpenPGP keys:"))));
mOpenPGPKeysWidget->setAllowedActions(OpenPGPKeyCardWidget::NoAction);
l->addWidget(mOpenPGPKeysWidget);
l->addWidget(new KSeparator(Qt::Horizontal));
}
mOpenPGPKeysSection->setVisible(false);
areaVLay->addWidget(mOpenPGPKeysSection);
areaVLay->addWidget(new KSeparator(Qt::Horizontal));
areaVLay->addStretch(1); areaVLay->addStretch(1);
} }
...@@ -154,5 +161,10 @@ void P15CardWidget::setCard(const P15Card *card) ...@@ -154,5 +161,10 @@ void P15CardWidget::setCard(const P15Card *card)
} }
} }
mOpenPGPKeysWidget->update(card); const bool cardHasOpenPGPKeys = !card->keyFingerprint(OpenPGPCard::pgpSigKeyRef()).empty()
|| !card->keyFingerprint(OpenPGPCard::pgpEncKeyRef()).empty();
mOpenPGPKeysSection->setVisible(cardHasOpenPGPKeys);
if (cardHasOpenPGPKeys) {
mOpenPGPKeysWidget->update(card);
}
} }
...@@ -40,6 +40,7 @@ private: ...@@ -40,6 +40,7 @@ private:
QLabel *mSerialNumber = nullptr; QLabel *mSerialNumber = nullptr;
QLabel *mVersionLabel = nullptr; QLabel *mVersionLabel = nullptr;
QLabel *mStatusLabel = nullptr; QLabel *mStatusLabel = nullptr;
QWidget *mOpenPGPKeysSection = nullptr;
OpenPGPKeyCardWidget *mOpenPGPKeysWidget = nullptr; OpenPGPKeyCardWidget *mOpenPGPKeysWidget = nullptr;
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment