446 |
andreas |
1 |
/*
|
|
|
2 |
* Copyright (C) 2021, 2022 by Andreas Theofilu <andreas@theosys.at>
|
|
|
3 |
*
|
|
|
4 |
* This program is free software; you can redistribute it and/or modify
|
|
|
5 |
* it under the terms of the GNU General Public License as published by
|
|
|
6 |
* the Free Software Foundation; either version 3 of the License, or
|
|
|
7 |
* (at your option) any later version.
|
|
|
8 |
*
|
|
|
9 |
* This program is distributed in the hope that it will be useful,
|
|
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
* GNU General Public License for more details.
|
|
|
13 |
*
|
|
|
14 |
* You should have received a copy of the GNU General Public License
|
|
|
15 |
* along with this program; if not, write to the Free Software Foundation,
|
|
|
16 |
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
17 |
*/
|
|
|
18 |
#ifndef TQKEYPAD_H
|
|
|
19 |
#define TQKEYPAD_H
|
|
|
20 |
|
|
|
21 |
#include <QDialog>
|
|
|
22 |
|
|
|
23 |
#include "tsystemsound.h"
|
|
|
24 |
|
|
|
25 |
namespace Ui
|
|
|
26 |
{
|
|
|
27 |
class TQKeypad;
|
|
|
28 |
|
|
|
29 |
typedef enum KEYSP_t
|
|
|
30 |
{
|
|
|
31 |
KEYP_0,
|
|
|
32 |
KEYP_1,
|
|
|
33 |
KEYP_2,
|
|
|
34 |
KEYP_3,
|
|
|
35 |
KEYP_4,
|
|
|
36 |
KEYP_5,
|
|
|
37 |
KEYP_6,
|
|
|
38 |
KEYP_7,
|
|
|
39 |
KEYP_8,
|
|
|
40 |
KEYP_9,
|
|
|
41 |
KEYP_Minus,
|
|
|
42 |
KEYP_Plus,
|
|
|
43 |
KEYP_Clear,
|
|
|
44 |
KEYP_Dot,
|
|
|
45 |
KEYP_Komma,
|
|
|
46 |
KEYP_DoubleDot
|
|
|
47 |
}KEYSP_t;
|
|
|
48 |
}
|
|
|
49 |
|
|
|
50 |
class TQKeypad : public QDialog, TSystemSound
|
|
|
51 |
{
|
|
|
52 |
Q_OBJECT
|
|
|
53 |
|
|
|
54 |
public:
|
|
|
55 |
explicit TQKeypad(const std::string& init, const std::string& prompt, QWidget *parent = nullptr, bool priv=false);
|
|
|
56 |
~TQKeypad();
|
|
|
57 |
|
|
|
58 |
void doResize();
|
|
|
59 |
void setPrivate(bool mode) { mPrivate = mode; }
|
|
|
60 |
void setScaleFactor(double sf) { mScaleFactor = sf; }
|
|
|
61 |
void setMaxLength(int len) { mMaxLen = len; }
|
|
|
62 |
std::string& getText() { return mText; }
|
|
|
63 |
void setString(const std::string& str);
|
|
|
64 |
|
|
|
65 |
private slots:
|
|
|
66 |
void key0() { setKey(Ui::KEYP_0); }
|
|
|
67 |
void key1() { setKey(Ui::KEYP_1); }
|
|
|
68 |
void key2() { setKey(Ui::KEYP_2); }
|
|
|
69 |
void key3() { setKey(Ui::KEYP_3); }
|
|
|
70 |
void key4() { setKey(Ui::KEYP_4); }
|
|
|
71 |
void key5() { setKey(Ui::KEYP_5); }
|
|
|
72 |
void key6() { setKey(Ui::KEYP_6); }
|
|
|
73 |
void key7() { setKey(Ui::KEYP_7); }
|
|
|
74 |
void key8() { setKey(Ui::KEYP_8); }
|
|
|
75 |
void key9() { setKey(Ui::KEYP_9); }
|
|
|
76 |
void keyMinus() { setKey(Ui::KEYP_Minus); }
|
|
|
77 |
void keyPlus() { setKey(Ui::KEYP_Plus); }
|
|
|
78 |
void keyDot() { setKey(Ui::KEYP_Dot); }
|
|
|
79 |
void keyKomma() { setKey(Ui::KEYP_Komma); }
|
|
|
80 |
void keyDoubleDot() { setKey(Ui::KEYP_DoubleDot); }
|
|
|
81 |
void keyClear() { setKey(Ui::KEYP_Clear); }
|
|
|
82 |
|
|
|
83 |
private:
|
|
|
84 |
void setKey(Ui::KEYSP_t key);
|
|
|
85 |
int scale(int value);
|
|
|
86 |
|
|
|
87 |
Ui::TQKeypad *ui{nullptr};
|
|
|
88 |
|
|
|
89 |
bool mPrivate{false}; // TRUE = private mode. Only * is showed.
|
|
|
90 |
double mScaleFactor{0.0}; // The scale factor if we are on a mobile device
|
|
|
91 |
std::string mText; // The typed text.
|
|
|
92 |
std::string mSound; // Path and name to a sound file played on every key press.
|
|
|
93 |
int mMaxLen{0}; // If >0 then this is the maximum number of chars
|
|
|
94 |
};
|
|
|
95 |
|
|
|
96 |
#endif // TQKEYPAD_H
|