forked from samnazarko/osmc-browser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQKeyPushButton.h
More file actions
executable file
·101 lines (88 loc) · 5.03 KB
/
QKeyPushButton.h
File metadata and controls
executable file
·101 lines (88 loc) · 5.03 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/***************************************************************************
* Copyright (C) 2008 by Giovanni Romano *
* Giovanni.Romano.76@gmail.com *
* *
* This program may be distributed under the terms of the Q Public *
* License as defined by Trolltech AS of Norway and appearing in the *
* file LICENSE.QPL included in the packaging of this file. *
* *
* 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. *
***************************************************************************/
#include <QPushButton>
#ifndef _QKEYPUSHBUTTON_H
//sounds:
#define CLICK_SOUND "/sounds/click.wav" // in future version of QT QSound will support loader from resource file
//
// colori e stile da utilizzare per la tastiera ed i tasti:
#define _QKEYPUSHBUTTON_H
#define DEFAULT_BACKGROUND_BUTTON "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #8C8F8C, stop: 1 #000000);"
#define CHANGED_BACKGROUND_BUTTON "background:lightgray;color:darkred;"
//#define DEFAULT_BACKGROUND_BUTTON "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #f6f7fa, stop: 1 #dadbde);"
//#define CHANGED_BACKGROUND_BUTTON "background:lightblue;"
#define DEFAULT_STYLE_BUTTON "color:white;border: 1px solid #000000;border-radius:6px;"
//#define DEFAULT_STYLE_BUTTON "border: 1px solid #8f8f91;border-radius:5px;"
#define STYLE_FOCUS_TEXT "border: 1px solid red"
//#define DEFAULT_STYLE_BUTTON "color:white;border: 2px solid black;border-radius:5px;font-weight: bold;font-size:17px;"
//#define DEFAULT_BACKGROUND_BUTTON "background:gray;"
//#define CHANGED_BACKGROUND_BUTTON "background:red;"
#define EMBEDDED_KEYBOARD "font-size:9px"
#define WIDTH_ZOOM_KEY 20
#define HEIGHT_ZOOM_KEY WIDTH_ZOOM_KEY
//
// tasti speciali utilizzati all'interno delle classi:
#define KEY_TAB tr("TAB")
#define KEY_ALT tr("ALT")
#define KEY_CAPS tr("CAPS")
#define KEY_CTRL_LEFT tr("CTRL")
#define KEY_CUT_LEFT tr("cut")
#define KEY_COPY tr("copy")
#define KEY_PASTE tr("paste")
#define KEY_BACKSPACE tr("BACKSPACE")
#define KEY_BACKSPACE_EMBEDDED "<---"
#define KEY_HIDECHAR tr("echo")
#define KEY_HIDECHAR_EMBEDDED tr("echo")
#define KEY_CANC tr("CANC")
#define KEY_RETURN tr("RETURN")
#define KEY_SPACE " "
#define KEY_WIDTH_EMBEDDED 26
#define KEY_HEIGHT_EMBEDDED 22
//
// macro parametrizzate per la riduzione del codice:
#define IS_KEY(keyTextPressed, keyValCompare) (keyTextPressed).contains((keyValCompare), Qt::CaseInsensitive)
#define IS_TAB(text) IS_KEY(text, KEY_TAB)
#define IS_ALT(text) IS_KEY(text, KEY_ALT)
#define IS_CAPS(text) IS_KEY(text, KEY_CAPS)
#define IS_CTRL_LEFT(text) IS_KEY(text, KEY_CTRL_LEFT)
#define IS_CUT_LEFT(text) IS_KEY(text, KEY_CUT_LEFT)
#define IS_BACK(text) IS_KEY(text, KEY_BACKSPACE)
#define IS_BACK_EMB(text) IS_KEY(text, KEY_BACKSPACE_EMBEDDED)
#define IS_CANC(text) IS_KEY(text, KEY_CANC)
#define IS_RETURN(text) IS_KEY(text, KEY_RETURN)
#define IS_SPACE(text) IS_KEY(text, KEY_SPACE)
#define IS_PASSWORD(text) IS_KEY(text, KEY_HIDECHAR)
#define IS_PASSWORD_EMB(text) IS_KEY(text, KEY_HIDECHAR_EMBEDDED)
#define IS_COPY(text) IS_KEY(text, KEY_COPY)
#define IS_PASTE(text) IS_KEY(text, KEY_PASTE)
#define NO_SPECIAL_KEY(text) ((text).length() == 1)
//
//
// definizione classe rappresentante un tasto:
class QKeyPushButton : public QPushButton {
Q_OBJECT
public:
QKeyPushButton(QWidget *parent = 0);
private slots:
void getKeyPress(bool statusCaps);
signals:
void pressedKey(bool statusCaps);
private:
QWidget *m_parent;
QString style_embedded;
int m_oldYKey;
protected:
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
};
#endif // _QKEYPUSHBUTTON_H