summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/function_keyboard.h
blob: a60ff4bc3517dd58b0b28e75fc9e3ae3620cb457 (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
101
102
103
104
105
106
107
108
109
110
111
112
#ifndef OPIE_FUNCTION_KEYBOARD_H
#define OPIE_FUNCTION_KEYBOARD_H

#include <qpe/config.h>
#include <qpe/resource.h>
#include <qpe/qpeapplication.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"


struct FKey {

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

        if (!f.isEmpty()) {

            pix = new QPixmap ( Resource::loadPixmap("console/keys/" + f ) );
        }
    };

    QString label;
    QPixmap *pix;
    QString pixFile;
    ushort qcode;
    ushort unicode;
};

class FunctionKeyboard : public QFrame {
    Q_OBJECT

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

    friend class FunctionKeyboardConfig;

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

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

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

signals:

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


private:

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

    uint numRows;
    int test;
    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, const char* name = 0l );
    ~FunctionKeyboardConfig();

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

private slots:

    void slotKeyPressed(FKey, ushort, ushort, bool);
    void slotChangeRows(int);
    void slotChangeCols(int);
    void slotChangeIcon(int);
    void slotChangeLabelText(const QString &);
    void slotChangeQCode(const QString &);
    void slotChangeUnicode(const QString &);

private:

    QString selectedHandle;
    ushort selectedRow, selectedCol;

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

};

#endif