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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
/*
* Copyright (C) 2004
* LGPL v2 zecke@handhelds.org
*/
#ifndef ODP_KEY_CONFIG_WIDGET_H
#define ODP_KEY_CONFIG_WIDGET_H
#include <opie2/okeyconfigmanager.h>
#include <qhbox.h>
#include <qdialog.h>
class QKeyEvent;
class QLabel;
class QPushButton;
class QListViewItem;
class QRadioButton;
class QTimer;
namespace Opie {
namespace Ui {
namespace Internal {
class OKeyConfigWidgetPrivate;
typedef QValueList<OKeyConfigWidgetPrivate> OKeyConfigWidgetPrivateList;
class OKeyListViewItem;
}
class OListViewItem;
class OListView;
/**
* With this Widget you can let the Keyboard Shortcuts
* be configured by the user.
* There are two ways you can use this widget. Either in a tab were
* all changes are immediately getting into effect or in a queue
* were you ask for saving. Save won't write the data but only set
* it to the OKeyConfigManager.
*
* Normally subclassing this widget does not make much sense as the widget content
* as such is immutable. If I'm wrong I'm willing to learn and you could mail me which
* functions do make sense with virtual on it (zecke@handhelds.org).
*
* @since 1.2
*/
class OKeyConfigWidget : public QWidget {
Q_OBJECT
public:
/**
* Immediate Apply the change directly to the underlying OKeyConfigManager
* Queue Save all items and then apply when you save()
*/
enum ChangeMode { Imediate, Queue };
OKeyConfigWidget( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
virtual ~OKeyConfigWidget();
void setChangeMode( enum ChangeMode );
ChangeMode changeMode()const;
void insert( const QString& name, Opie::Core::OKeyConfigManager* );
void load();
void save();
protected slots:
void slotListViewItem( QListViewItem* );
void slotNoKey();
void slotDefaultKey();
void slotCustomKey();
void slotConfigure();
private:
static bool sanityCheck( Opie::Ui::Internal::OKeyListViewItem* man,
const Opie::Core::OKeyPair& newItem );
void updateItem( Opie::Ui::Internal::OKeyListViewItem* man,
const Opie::Core::OKeyPair& newItem);
void initUi();
Opie::Ui::OListView *m_view;
Opie::Ui::Internal::OKeyConfigWidgetPrivateList m_list;
QLabel *m_lbl;
QPushButton *m_btn;
QRadioButton *m_def, *m_cus, *m_none;
QWidget* m_box;
ChangeMode m_mode;
class Private;
Private *d;
};
/**
* This is a small dialog that allows you to
* capture a key sequence.
* If you want it to close after a key was captured you
* can use this code snippet.
*
* \code
* OKeyChooserConfigDialog diag(0,0,true);
* connect(&diag,SIGNAL(keyCaptured()),
* this,SLOT(accept()));
* if( QPEApplication::execDialog(&diag) == QDialog::Accept ){
* take_the_key_and_do_something
* }
*
* \endcode
*
*/
class OKeyChooserConfigDialog : public QDialog {
Q_OBJECT
public:
OKeyChooserConfigDialog( QWidget* parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0 );
~OKeyChooserConfigDialog();
Opie::Core::OKeyPair keyPair()const;
protected:
void keyPressEvent( QKeyEvent* );
void keyReleaseEvent( QKeyEvent* );
signals:
void keyCaptured();
private slots:
void slotTimeUp();
private:
QTimer *m_timer;
QLabel *m_lbl;
bool m_virtKey : 1;
Opie::Core::OKeyPair m_keyPair;
int m_key, m_mod;
class Private;
Private *d;
};
}
}
#endif
|