Add revert button to padwidget

The revert button reverts the last crypto action.
parent 348f6ed9
...@@ -73,6 +73,7 @@ public: ...@@ -73,6 +73,7 @@ public:
mEdit(new QTextEdit), mEdit(new QTextEdit),
mCryptBtn(new QPushButton(QIcon::fromTheme("document-edit-sign-encrypt"), i18n("Sign / Encrypt Notepad"))), mCryptBtn(new QPushButton(QIcon::fromTheme("document-edit-sign-encrypt"), i18n("Sign / Encrypt Notepad"))),
mDecryptBtn(new QPushButton(QIcon::fromTheme("document-edit-decrypt-verify"), i18n("Decrypt / Verify Notepad"))), mDecryptBtn(new QPushButton(QIcon::fromTheme("document-edit-decrypt-verify"), i18n("Decrypt / Verify Notepad"))),
mRevertBtn(new QPushButton(QIcon::fromTheme("edit-undo"), i18n("Revert"))),
mAdditionalInfoLabel(new QLabel), mAdditionalInfoLabel(new QLabel),
mSigEncWidget(new SignEncryptWidget), mSigEncWidget(new SignEncryptWidget),
mProgressBar(new QProgressBar), mProgressBar(new QProgressBar),
...@@ -85,8 +86,10 @@ public: ...@@ -85,8 +86,10 @@ public:
vLay->addLayout(btnLay); vLay->addLayout(btnLay);
btnLay->addWidget(mCryptBtn); btnLay->addWidget(mCryptBtn);
btnLay->addWidget(mDecryptBtn); btnLay->addWidget(mDecryptBtn);
btnLay->addWidget(mRevertBtn);
mRevertBtn->setVisible(false);
mAdditionalInfoLabel->setWordWrap(true);
btnLay->addWidget(mAdditionalInfoLabel); btnLay->addWidget(mAdditionalInfoLabel);
btnLay->addStretch(-1); btnLay->addStretch(-1);
...@@ -145,6 +148,16 @@ public: ...@@ -145,6 +148,16 @@ public:
connect(mDecryptBtn, &QPushButton::clicked, q, [this] () { connect(mDecryptBtn, &QPushButton::clicked, q, [this] () {
doDecryptVerify(); doDecryptVerify();
}); });
connect(mRevertBtn, &QPushButton::clicked, q, [this] () {
revert();
});
}
void revert()
{
mEdit->setPlainText(QString::fromUtf8(mInputData));
mRevertBtn->setVisible(false);
} }
void cryptDone(const std::shared_ptr<const Kleo::Crypto::Task::Result> &result) void cryptDone(const std::shared_ptr<const Kleo::Crypto::Task::Result> &result)
...@@ -172,6 +185,7 @@ public: ...@@ -172,6 +185,7 @@ public:
} }
mEdit->setPlainText(QString::fromUtf8(mOutputData)); mEdit->setPlainText(QString::fromUtf8(mOutputData));
mOutputData.clear(); mOutputData.clear();
mRevertBtn->setVisible(true);
} }
void doDecryptVerify() void doDecryptVerify()
...@@ -301,6 +315,7 @@ private: ...@@ -301,6 +315,7 @@ private:
QTextEdit *mEdit; QTextEdit *mEdit;
QPushButton *mCryptBtn; QPushButton *mCryptBtn;
QPushButton *mDecryptBtn; QPushButton *mDecryptBtn;
QPushButton *mRevertBtn;
QLabel *mAdditionalInfoLabel; QLabel *mAdditionalInfoLabel;
QByteArray mInputData; QByteArray mInputData;
QByteArray mOutputData; QByteArray mOutputData;
......
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