Changeset View
Changeset View
Standalone View
Standalone View
src/crypto/gui/signencryptfileswizard.cpp
Show All 39 Lines | |||||
40 | 40 | | |||
41 | #include <KLocalizedString> | 41 | #include <KLocalizedString> | ||
42 | #include <KSharedConfig> | 42 | #include <KSharedConfig> | ||
43 | #include <KConfigGroup> | 43 | #include <KConfigGroup> | ||
44 | 44 | | |||
45 | #include <KMessageBox> | 45 | #include <KMessageBox> | ||
46 | 46 | | |||
47 | #include "kleopatra_debug.h" | 47 | #include "kleopatra_debug.h" | ||
48 | #include <utils/gnupg-helper.h> | ||||
48 | 49 | | |||
49 | #include <Libkleo/FileNameRequester> | 50 | #include <Libkleo/FileNameRequester> | ||
50 | #include <QVBoxLayout> | 51 | #include <QVBoxLayout> | ||
51 | #include <QWizardPage> | 52 | #include <QWizardPage> | ||
52 | #include <QGroupBox> | 53 | #include <QGroupBox> | ||
53 | #include <QLabel> | 54 | #include <QLabel> | ||
54 | #include <QIcon> | 55 | #include <QIcon> | ||
55 | #include <QCheckBox> | 56 | #include <QCheckBox> | ||
Show All 17 Lines | |||||
73 | 74 | | |||
74 | class SigEncPage: public QWizardPage | 75 | class SigEncPage: public QWizardPage | ||
75 | { | 76 | { | ||
76 | Q_OBJECT | 77 | Q_OBJECT | ||
77 | 78 | | |||
78 | public: | 79 | public: | ||
79 | explicit SigEncPage(QWidget *parent = nullptr) | 80 | explicit SigEncPage(QWidget *parent = nullptr) | ||
80 | : QWizardPage(parent), | 81 | : QWizardPage(parent), | ||
82 | mParent((SignEncryptFilesWizard *) parent), | ||||
81 | mWidget(new SignEncryptWidget), | 83 | mWidget(new SignEncryptWidget), | ||
82 | mOutLayout(new QVBoxLayout), | 84 | mOutLayout(new QVBoxLayout), | ||
83 | mArchive(false), | 85 | mArchive(false), | ||
84 | mUseOutputDir(false) | 86 | mUseOutputDir(false) | ||
85 | { | 87 | { | ||
86 | setTitle(i18nc("@title", "Sign / Encrypt Files")); | 88 | setTitle(i18nc("@title", "Sign / Encrypt Files")); | ||
87 | auto vLay = new QVBoxLayout(this); | 89 | auto vLay = new QVBoxLayout(this); | ||
88 | vLay->setMargin(0); | 90 | vLay->setMargin(0); | ||
▲ Show 20 Lines • Show All 190 Lines • ▼ Show 20 Line(s) | 262 | public: | |||
279 | bool encryptSymmetric() const | 281 | bool encryptSymmetric() const | ||
280 | { | 282 | { | ||
281 | return mWidget->encryptSymmetric(); | 283 | return mWidget->encryptSymmetric(); | ||
282 | } | 284 | } | ||
283 | 285 | | |||
284 | private Q_SLOTS: | 286 | private Q_SLOTS: | ||
285 | void updateCommitButton(const QString &label) | 287 | void updateCommitButton(const QString &label) | ||
286 | { | 288 | { | ||
289 | auto btn = mParent->button(QWizard::CommitButton); | ||||
287 | if (!label.isEmpty()) { | 290 | if (!label.isEmpty()) { | ||
288 | setButtonText(QWizard::CommitButton, label); | 291 | btn->setText(label); | ||
292 | if (Kleo::gpgComplianceP("de-vs")) { | ||||
293 | bool de_vs = mWidget->isDeVsAndValid(); | ||||
294 | btn->setIcon(QIcon::fromTheme(de_vs | ||||
295 | ? "security-high" | ||||
296 | : "security-medium")); | ||||
297 | btn->setStyleSheet(de_vs | ||||
298 | ? "background-color: lime" | ||||
299 | : "background-color: red"); | ||||
300 | mParent->setLabelText(de_vs | ||||
301 | ? i18nc("VS-conforming is a German standard for restricted documents for which special restrictions about algorithms apply. The string states that all cryptographic operations necessary for the communication are compliant with that.", | ||||
302 | "VS-conforming communication possible.") | ||||
aheinecke: Minor: In other places we use compliant. Same in the string below. No need to upload a new diff… | |||||
303 | : i18nc("VS-conforming is a German standard for restricted documents for which special restrictions about algorithms apply. The string states that all cryptographic operations necessary for the communication are compliant with that.", | ||||
304 | "VS-conforming communication not possible.")); | ||||
305 | } | ||||
289 | } else { | 306 | } else { | ||
290 | setButtonText(QWizard::CommitButton, i18n("Next")); | 307 | btn->setText(i18n("Next")); | ||
308 | btn->setIcon(QIcon()); | ||||
309 | btn->setStyleSheet(""); | ||||
291 | } | 310 | } | ||
292 | Q_EMIT completeChanged(); | 311 | Q_EMIT completeChanged(); | ||
293 | } | 312 | } | ||
294 | 313 | | |||
295 | void updateFileWidgets() | 314 | void updateFileWidgets() | ||
296 | { | 315 | { | ||
297 | if (mRequester.isEmpty()) { | 316 | if (mRequester.isEmpty()) { | ||
298 | return; | 317 | return; | ||
Show All 20 Lines | |||||
319 | mRequester[SignEncryptFilesWizard::CombinedPGP]->setVisible(!mUseOutputDir && sigKey.protocol() == Protocol::OpenPGP && pgp); | 338 | mRequester[SignEncryptFilesWizard::CombinedPGP]->setVisible(!mUseOutputDir && sigKey.protocol() == Protocol::OpenPGP && pgp); | ||
320 | mRequester[SignEncryptFilesWizard::EncryptedPGP]->setVisible(!mUseOutputDir && pgp && sigKey.protocol() != Protocol::OpenPGP); | 339 | mRequester[SignEncryptFilesWizard::EncryptedPGP]->setVisible(!mUseOutputDir && pgp && sigKey.protocol() != Protocol::OpenPGP); | ||
321 | mRequester[SignEncryptFilesWizard::SignaturePGP]->setVisible(!mUseOutputDir && sigKey.protocol() == Protocol::OpenPGP && !pgp); | 340 | mRequester[SignEncryptFilesWizard::SignaturePGP]->setVisible(!mUseOutputDir && sigKey.protocol() == Protocol::OpenPGP && !pgp); | ||
322 | mRequester[SignEncryptFilesWizard::Directory]->setVisible(mUseOutputDir && !mPlaceholderWidget->isVisible()); | 341 | mRequester[SignEncryptFilesWizard::Directory]->setVisible(mUseOutputDir && !mPlaceholderWidget->isVisible()); | ||
323 | mOutLayout->setEnabled(true); | 342 | mOutLayout->setEnabled(true); | ||
324 | } | 343 | } | ||
325 | 344 | | |||
326 | private: | 345 | private: | ||
346 | SignEncryptFilesWizard *mParent; | ||||
327 | SignEncryptWidget *mWidget; | 347 | SignEncryptWidget *mWidget; | ||
328 | QMap <int, QString> mOutNames; | 348 | QMap <int, QString> mOutNames; | ||
329 | QMap <int, QWidget *> mRequester; | 349 | QMap <int, QWidget *> mRequester; | ||
330 | QVBoxLayout *mOutLayout; | 350 | QVBoxLayout *mOutLayout; | ||
331 | QWidget *mPlaceholderWidget; | 351 | QWidget *mPlaceholderWidget; | ||
332 | QCheckBox *mUseOutputDirChk; | 352 | QCheckBox *mUseOutputDirChk; | ||
333 | bool mArchive; | 353 | bool mArchive; | ||
334 | bool mUseOutputDir; | 354 | bool mUseOutputDir; | ||
335 | }; | 355 | }; | ||
336 | 356 | | |||
337 | class ResultPage : public NewResultPage | 357 | class ResultPage : public NewResultPage | ||
338 | { | 358 | { | ||
339 | Q_OBJECT | 359 | Q_OBJECT | ||
360 | | ||||
340 | public: | 361 | public: | ||
341 | explicit ResultPage(QWidget *parent = nullptr) | 362 | explicit ResultPage(QWidget *parent = nullptr) | ||
342 | : NewResultPage(parent) | 363 | : NewResultPage(parent), | ||
364 | mParent((SignEncryptFilesWizard *) parent) | ||||
343 | { | 365 | { | ||
344 | setTitle(i18nc("@title", "Results")); | 366 | setTitle(i18nc("@title", "Results")); | ||
345 | setSubTitle(i18nc("@title", | 367 | setSubTitle(i18nc("@title", | ||
346 | "Status and progress of the crypto operations is shown here.")); | 368 | "Status and progress of the crypto operations is shown here.")); | ||
347 | } | 369 | } | ||
348 | 370 | | |||
371 | void initializePage() override | ||||
372 | { | ||||
373 | mParent->setLabelText(QString()); | ||||
374 | } | ||||
375 | | ||||
376 | private: | ||||
377 | SignEncryptFilesWizard *mParent; | ||||
349 | }; | 378 | }; | ||
350 | 379 | | |||
351 | SignEncryptFilesWizard::SignEncryptFilesWizard(QWidget *parent, Qt::WindowFlags f) | 380 | SignEncryptFilesWizard::SignEncryptFilesWizard(QWidget *parent, Qt::WindowFlags f) | ||
352 | : QWizard(parent, f) | 381 | : QWizard(parent, f) | ||
353 | , mSigningPreset(false) | 382 | , mSigningPreset(false) | ||
354 | , mSigningUserMutable(false) | 383 | , mSigningUserMutable(false) | ||
355 | , mEncryptionUserMutable(false) | 384 | , mEncryptionUserMutable(false) | ||
356 | , mEncryptionPreset(false) | 385 | , mEncryptionPreset(false) | ||
357 | { | 386 | { | ||
387 | bool de_vs = Kleo::gpgComplianceP("de-vs"); | ||||
358 | #ifdef Q_OS_WIN | 388 | #ifdef Q_OS_WIN | ||
359 | // Enforce modern style to avoid vista style uglyness. | 389 | // Enforce modern style to avoid vista style uglyness. | ||
360 | setWizardStyle(QWizard::ModernStyle); | 390 | setWizardStyle(QWizard::ModernStyle); | ||
361 | #endif | 391 | #endif | ||
362 | mSigEncPage = new SigEncPage(this); | 392 | mSigEncPage = new SigEncPage(this); | ||
363 | mResultPage = new ResultPage(this); | 393 | mResultPage = new ResultPage(this); | ||
364 | 394 | | |||
365 | connect(this, &QWizard::currentIdChanged, this, | 395 | connect(this, &QWizard::currentIdChanged, this, | ||
366 | &SignEncryptFilesWizard::slotCurrentIdChanged); | 396 | &SignEncryptFilesWizard::slotCurrentIdChanged); | ||
367 | setPage(SigEncPageId, mSigEncPage); | 397 | setPage(SigEncPageId, mSigEncPage); | ||
368 | setPage(ResultPageId, mResultPage); | 398 | setPage(ResultPageId, mResultPage); | ||
369 | setOptions(QWizard::IndependentPages | | 399 | setOptions(QWizard::IndependentPages | | ||
400 | (de_vs ? QWizard::HaveCustomButton1 : (QWizard::WizardOption) 0) | | ||||
370 | QWizard::NoBackButtonOnLastPage | | 401 | QWizard::NoBackButtonOnLastPage | | ||
371 | QWizard::NoBackButtonOnStartPage); | 402 | QWizard::NoBackButtonOnStartPage); | ||
372 | 403 | | |||
404 | if (de_vs) { | ||||
405 | /* We use a custom button to display a label next to the | ||||
406 | buttons. */ | ||||
407 | mLabel = button(QWizard::CustomButton1); | ||||
408 | /* We style the button so that it looks and acts like a | ||||
409 | label. */ | ||||
410 | mLabel->setStyleSheet("border: none"); | ||||
411 | mLabel->setFocusPolicy(Qt::NoFocus); | ||||
412 | } else | ||||
413 | mLabel = NULL; | ||||
Here and in some other places: KDE Coding style requires braces even around single line statements. aheinecke: Here and in some other places: KDE Coding style requires braces even around single line… | |||||
414 | | ||||
373 | KConfigGroup cfgGroup(KSharedConfig::openConfig(), "SignEncryptFilesWizard"); | 415 | KConfigGroup cfgGroup(KSharedConfig::openConfig(), "SignEncryptFilesWizard"); | ||
374 | const QByteArray geom = cfgGroup.readEntry("geometry", QByteArray()); | 416 | const QByteArray geom = cfgGroup.readEntry("geometry", QByteArray()); | ||
375 | if (!geom.isEmpty()) { | 417 | if (!geom.isEmpty()) { | ||
376 | restoreGeometry(geom); | 418 | restoreGeometry(geom); | ||
377 | return; | 419 | return; | ||
378 | } | 420 | } | ||
379 | } | 421 | } | ||
380 | 422 | | |||
423 | void SignEncryptFilesWizard::setLabelText(const QString &label) const | ||||
424 | { | ||||
425 | if (mLabel) | ||||
426 | mLabel->setText(label); | ||||
427 | } | ||||
428 | | ||||
381 | void SignEncryptFilesWizard::slotCurrentIdChanged(int id) | 429 | void SignEncryptFilesWizard::slotCurrentIdChanged(int id) | ||
382 | { | 430 | { | ||
383 | if (id == ResultPageId) { | 431 | if (id == ResultPageId) { | ||
384 | Q_EMIT operationPrepared(); | 432 | Q_EMIT operationPrepared(); | ||
385 | } | 433 | } | ||
386 | } | 434 | } | ||
387 | 435 | | |||
388 | SignEncryptFilesWizard::~SignEncryptFilesWizard() | 436 | SignEncryptFilesWizard::~SignEncryptFilesWizard() | ||
▲ Show 20 Lines • Show All 80 Lines • Show Last 20 Lines |
Minor: In other places we use compliant. Same in the string below. No need to upload a new diff just fix it before push.