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

Move definition of methods out of definition of Private class

parent 0ea195ed
......@@ -67,77 +67,82 @@ public:
class SmartCardWidget::Private
{
public:
Private(SmartCardWidget *qq) : q(qq)
{
QPushButton *backBtn = new QPushButton(QIcon::fromTheme(QStringLiteral("arrow-left")), i18n("Back"));
QHBoxLayout *backH = new QHBoxLayout;
backH->addWidget(backBtn);
backH->addWidget(new QLabel(QStringLiteral("<h2>") + i18n("Smartcard Management") +
QStringLiteral("</h2>")));
backH->addStretch(-1);
Private(SmartCardWidget *qq);
QVBoxLayout *vLay = new QVBoxLayout(q);
void setCard(std::shared_ptr<Card> card);
private:
SmartCardWidget *const q;
NetKeyWidget *mNetKeyWidget;
PGPCardWidget *mPGPCardWidget;
PIVCardWidget *mPIVCardWidget;
PlaceHolderWidget *mPlaceHolderWidget;
QStackedWidget *mStack;
};
SmartCardWidget::Private::Private(SmartCardWidget *qq)
: q(qq)
{
QPushButton *backBtn = new QPushButton(QIcon::fromTheme(QStringLiteral("arrow-left")), i18n("Back"));
QHBoxLayout *backH = new QHBoxLayout;
backH->addWidget(backBtn);
backH->addWidget(new QLabel(QStringLiteral("<h2>") + i18n("Smartcard Management") +
QStringLiteral("</h2>")));
backH->addStretch(-1);
connect(backBtn, &QPushButton::clicked, q, [this] () {Q_EMIT q->backRequested();});
QVBoxLayout *vLay = new QVBoxLayout(q);
vLay->addLayout(backH);
mStack = new QStackedWidget;
vLay->addWidget(mStack);
connect(backBtn, &QPushButton::clicked, q, [this] () {Q_EMIT q->backRequested();});
mPGPCardWidget = new PGPCardWidget(q);
mStack->addWidget(mPGPCardWidget);
vLay->addLayout(backH);
mNetKeyWidget = new NetKeyWidget(q);
mStack->addWidget(mNetKeyWidget);
mStack = new QStackedWidget;
vLay->addWidget(mStack);
mPIVCardWidget = new PIVCardWidget(q);
mStack->addWidget(mPIVCardWidget);
mPGPCardWidget = new PGPCardWidget(q);
mStack->addWidget(mPGPCardWidget);
mPlaceHolderWidget = new PlaceHolderWidget(q);
mStack->addWidget(mPlaceHolderWidget);
mNetKeyWidget = new NetKeyWidget(q);
mStack->addWidget(mNetKeyWidget);
mStack->setCurrentWidget(mPlaceHolderWidget);
mPIVCardWidget = new PIVCardWidget(q);
mStack->addWidget(mPIVCardWidget);
connect(ReaderStatus::instance(), &ReaderStatus::cardChanged,
q, [this] (unsigned int slot) {
if (slot == 0) {
const auto cards = ReaderStatus::instance()->getCards();
if (!cards.size()) {
setCard(std::shared_ptr<Card>(new Card()));
} else {
// No support for multiple reader / cards currently
setCard(cards[0]);
}
mPlaceHolderWidget = new PlaceHolderWidget(q);
mStack->addWidget(mPlaceHolderWidget);
mStack->setCurrentWidget(mPlaceHolderWidget);
connect(ReaderStatus::instance(), &ReaderStatus::cardChanged,
q, [this] (unsigned int slot) {
if (slot == 0) {
const auto cards = ReaderStatus::instance()->getCards();
if (!cards.size()) {
setCard(std::shared_ptr<Card>(new Card()));
} else {
// No support for multiple reader / cards currently
setCard(cards[0]);
}
});
}
}
});
}
void setCard(std::shared_ptr<Card> card)
{
if (card->appName() == SmartCard::OpenPGPCard::AppName) {
mPGPCardWidget->setCard(static_cast<OpenPGPCard *> (card.get()));
mStack->setCurrentWidget(mPGPCardWidget);
} else if (card->appName() == SmartCard::NetKeyCard::AppName) {
mNetKeyWidget->setCard(static_cast<NetKeyCard *> (card.get()));
mStack->setCurrentWidget(mNetKeyWidget);
} else if (card->appName() == SmartCard::PIVCard::AppName) {
mPIVCardWidget->setCard(static_cast<PIVCard *> (card.get()));
mStack->setCurrentWidget(mPIVCardWidget);
} else {
mStack->setCurrentWidget(mPlaceHolderWidget);
}
void SmartCardWidget::Private::setCard(std::shared_ptr<Card> card)
{
if (card->appName() == SmartCard::OpenPGPCard::AppName) {
mPGPCardWidget->setCard(static_cast<OpenPGPCard *> (card.get()));
mStack->setCurrentWidget(mPGPCardWidget);
} else if (card->appName() == SmartCard::NetKeyCard::AppName) {
mNetKeyWidget->setCard(static_cast<NetKeyCard *> (card.get()));
mStack->setCurrentWidget(mNetKeyWidget);
} else if (card->appName() == SmartCard::PIVCard::AppName) {
mPIVCardWidget->setCard(static_cast<PIVCard *> (card.get()));
mStack->setCurrentWidget(mPIVCardWidget);
} else {
mStack->setCurrentWidget(mPlaceHolderWidget);
}
private:
SmartCardWidget *const q;
NetKeyWidget *mNetKeyWidget;
PGPCardWidget *mPGPCardWidget;
PIVCardWidget *mPIVCardWidget;
PlaceHolderWidget *mPlaceHolderWidget;
QStackedWidget *mStack;
};
}
SmartCardWidget::SmartCardWidget(QWidget *parent):
QWidget(parent),
......
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