summaryrefslogtreecommitdiffstats
path: root/debian/pinentry-tqt/pinentry-tqt-1.2.1/qt/pinentryconfirm.h
blob: f175f53a0fb634e543ed6e35c73391b7ce4a84a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/* pinentryconfirm.h - A QMessageBox with a timeout
 *
 * Copyright (C) 2011 Ben Kibbey <bjk@luxsci.net>
 * Copyright (C) 2022 g10 Code GmbH
 *
 * Software engineering by Ingo Klöcker <dev@ingo-kloecker.de>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <https://www.gnu.org/licenses/>.
 * SPDX-License-Identifier: GPL-2.0+
 */

#ifndef PINENTRYCONFIRM_H
#define PINENTRYCONFIRM_H

#include <QAccessible>
#include <QMessageBox>
#include <QTimer>

class PinentryConfirm : public QMessageBox
#ifndef QT_NO_ACCESSIBILITY
    , public QAccessible::ActivationObserver
#endif
{
    Q_OBJECT
public:
    PinentryConfirm(Icon icon, const QString &title, const QString &text,
                    StandardButtons buttons = NoButton, QWidget *parent = nullptr,
                    Qt::WindowFlags flags = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
    ~PinentryConfirm() override;

    void setTimeout(std::chrono::seconds timeout);
    std::chrono::seconds timeout() const;

    bool timedOut() const;

protected:
    void showEvent(QShowEvent *event) override;
    bool focusNextPrevChild(bool next) override;

private Q_SLOTS:
    void slotTimeout();

private:
#ifndef QT_NO_ACCESSIBILITY
    void accessibilityActiveChanged(bool active) override;
#endif

private:
    QTimer _timer;
    bool _timed_out = false;
};

#endif