1 /*
2  * A tan input dialog for optical photoTan used in online banking
3  * Copyright 2019  Jürgen Diez
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of
8  * the License or (at your option) version 3 or any later version
9  * accepted by the membership of KDE e.V. (or its successor approved
10  * by the membership of KDE e.V.), which shall act as a proxy
11  * defined in Section 14 of version 3 of the license.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU 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 <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #ifndef PHOTOTANDIALOG_H
24 #define PHOTOTANDIALOG_H
25 
26 #include <memory>
27 
28 #include <QDialog>
29 #include <QGraphicsPixmapItem>
30 
31 namespace Ui
32 {
33 class photoTanDialog;
34 }
35 
36 class photoTanDialog : public QDialog
37 {
38   Q_OBJECT
39   Q_PROPERTY(QString infoText READ infoText() WRITE setInfoText)
40   Q_PROPERTY(QPixmap picture READ picture() WRITE setPicture)
41 
42 public:
43   explicit photoTanDialog(QWidget* parent = 0);
44   ~photoTanDialog();
45 
46   enum Result { Accepted = 0, Rejected, InternalError };
47 
48   QString infoText();
49   QString tan();
50   QPixmap picture();
51 
52 public Q_SLOTS:
53   void accept() final override;
54   void reject() final override;
55 
56   void setInfoText(const QString&);
57   void setPicture(const QPixmap&);
58 
59   void setTanLimits(const int& minLength, const int& maxLength);
60 
61 private Q_SLOTS:
62   void tanInputChanged(const QString&);
63 
64 private:
65   std::unique_ptr<Ui::photoTanDialog> ui;
66   QGraphicsPixmapItem *pictureItem;
67   QString m_tan;
68   bool m_accepted;
69 };
70 
71 #endif // PHOTOTANDIALOG_H
72