summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/function_keyboard.h
blob: efeff6d2fab510ecf128cfc08d68d784a2481c7b (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
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
#ifndef OPIE_FUNCTION_KEYBOARD_H
#define OPIE_FUNCTION_KEYBOARD_H

#include <qpe/config.h>
#include <qframe.h>
#include <qpainter.h>
#include <qvbox.h>
#include <qgroupbox.h>
#include <qmap.h>
#include <qspinbox.h>
#include <qcombobox.h>
#include "profiledialogwidget.h"


class FKey {

public:

    FKey(): qcode(0), unicode(0) {};
    FKey(const QString &l, ushort q, ushort u): label(l), qcode(q), unicode(u) {};

    QString getL() { return label; }
    ushort getQ() { return qcode; }
    ushort getU() { return unicode; }


private:

    QString label;
    ushort qcode;
    ushort unicode;
};

class FunctionKeyboard : public QFrame {
    Q_OBJECT

public:
    FunctionKeyboard(QWidget *parent = 0);
    ~FunctionKeyboard();

    void changeRows(int);
    void changeCols(int);

    void paintEvent(QPaintEvent *);
    void paintKey(int, int);
    void mousePressEvent(QMouseEvent*);
    void mouseReleaseEvent(QMouseEvent*);
    void resizeEvent(QResizeEvent*);
    QSize sizeHint() const;

signals:

    void keyPressed(ushort, ushort, bool, bool, bool, ushort, ushort);

private:

    void loadDefaults();


private:

    // thie key for the map is the row/col
    QMap<QString, FKey> keys;

    uint numRows;
    uint numCols;
    uint keyHeight;
    double keyWidth; // decimal point matters!

    int pressedRow, pressedCol;

    QObject *parent;

};

class FunctionKeyboardConfig : public ProfileDialogKeyWidget {
    Q_OBJECT
public:
    FunctionKeyboardConfig(const QString& name, QWidget *wid);
    ~FunctionKeyboardConfig();

    void load(const Profile&);
    void save(Profile&);

private slots:

    void slotKeyPressed(ushort, ushort, bool, bool, bool, ushort, ushort);
    void slotChangeRows(int);
    void slotChangeCols(int);
    void slotChangeIcon(int);

private:

    FunctionKeyboard *kb;
    QSpinBox *m_rowBox, *m_colBox;
    QComboBox *m_labels;

};

#endif