GpgFrontend Project
A Free, Powerful, Easy-to-Use, Compact, Cross-Platform, and Installation-Free OpenPGP(pgp) Crypto Tool.
pinentryconfirm.h
1 /* pinentryconfirm.h - A QMessageBox with a timeout
2  *
3  * Copyright (C) 2011 Ben Kibbey <bjk@luxsci.net>
4  * Copyright (C) 2022 g10 Code GmbH
5  *
6  * Software engineering by Ingo Klöcker <dev@ingo-kloecker.de>
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License as
10  * published by the Free Software Foundation; either version 2 of the
11  * License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, see <https://www.gnu.org/licenses/>.
20  * SPDX-License-Identifier: GPL-2.0+
21  */
22 
23 #ifndef PINENTRYCONFIRM_H
24 #define PINENTRYCONFIRM_H
25 
26 #include <QAccessible>
27 #include <QMessageBox>
28 #include <QTimer>
29 
30 class PinentryConfirm : public QMessageBox
31 #ifndef QT_NO_ACCESSIBILITY
32  , public QAccessible::ActivationObserver
33 #endif
34 {
35  Q_OBJECT
36 public:
37  PinentryConfirm(Icon icon, const QString &title, const QString &text,
38  StandardButtons buttons = NoButton, QWidget *parent = nullptr,
39  Qt::WindowFlags flags = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
40  ~PinentryConfirm() override;
41 
42  void setTimeout(std::chrono::seconds timeout);
43  std::chrono::seconds timeout() const;
44 
45  bool timedOut() const;
46 
47 protected:
48  void showEvent(QShowEvent *event) override;
49 
50 private Q_SLOTS:
51  void slotTimeout();
52 
53 private:
54 #ifndef QT_NO_ACCESSIBILITY
55  void accessibilityActiveChanged(bool active) override;
56 #endif
57 
58 private:
59  QTimer _timer;
60  bool _timed_out = false;
61 };
62 
63 #endif
Definition: pinentryconfirm.h:34