libyui-qt
2.43.5
Main Page
Classes
Files
File List
All
Classes
Functions
Variables
YQInputField.h
1
/*
2
Copyright (C) 2000-2012 Novell, Inc
3
This library is free software; you can redistribute it and/or modify
4
it under the terms of the GNU Lesser General Public License as
5
published by the Free Software Foundation; either version 2.1 of the
6
License, or (at your option) version 3.0 of the License. This library
7
is distributed in the hope that it will be useful, but WITHOUT ANY
8
WARRANTY; without even the implied warranty of MERCHANTABILITY or
9
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10
License for more details. You should have received a copy of the GNU
11
Lesser General Public License along with this library; if not, write
12
to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13
Floor, Boston, MA 02110-1301 USA
14
*/
15
16
17
/*-/
18
19
File: YQInputField.h
20
21
Author: Stefan Hundhammer <sh@suse.de>
22
23
/-*/
24
25
26
#ifndef YQInputField_h
27
#define YQInputField_h
28
29
#include <QFrame>
30
#include <qlineedit.h>
31
32
#include <yui/YInputField.h>
33
34
class
QString;
35
class
QY2CharValidator
;
36
class
YQWidgetCaption
;
37
class
YQRawLineEdit
;
38
39
using
std::string;
40
41
42
class
YQInputField
:
public
QFrame,
public
YInputField
43
{
44
Q_OBJECT
45
46
public
:
47
/**
48
* Constructor.
49
**/
50
YQInputField
( YWidget * parent,
51
const
std::string & label,
52
bool
passwordMode =
false
);
53
54
/**
55
* Get the current value (the text entered by the user or set from the
56
* outside) of this input field.
57
*
58
* Reimplemented from YInputField.
59
**/
60
virtual
std::string
value
();
61
62
/**
63
* Set the current value (the text entered by the user or set from the
64
* outside) of this input field.
65
*
66
* Reimplemented from YInputField.
67
**/
68
virtual
void
setValue
(
const
std::string & text );
69
70
/**
71
* Set the label (the caption above the input field).
72
*
73
* Reimplemented from YInputField.
74
**/
75
virtual
void
setLabel
(
const
std::string & label );
76
77
/**
78
* Set the valid input characters. No input validation is performed (i.e.,
79
* the user can enter anything) if this is empty.
80
*
81
* Reimplemented from YInputField.
82
**/
83
virtual
void
setValidChars
(
const
std::string & validChars );
84
85
/**
86
* Specify the amount of characters which can be inserted.
87
*
88
* Reimplemented from YInputField.
89
**/
90
virtual
void
setInputMaxLength
(
int
numberOfChars );
91
92
/**
93
* Returns 'true' if a given text is valid according to ValidChars.
94
**/
95
bool
isValidText
(
const
QString & text )
const
;
96
97
/**
98
* Set enabled/disabled state.
99
*
100
* Reimplemented from YWidget.
101
**/
102
virtual
void
setEnabled
(
bool
enabled );
103
104
/**
105
* Preferred width of the widget.
106
*
107
* Reimplemented from YWidget.
108
**/
109
virtual
int
preferredWidth
();
110
111
/**
112
* Preferred height of the widget.
113
*
114
* Reimplemented from YWidget.
115
**/
116
virtual
int
preferredHeight
();
117
118
/**
119
* Set the new size of the widget.
120
*
121
* Reimplemented from YWidget.
122
**/
123
virtual
void
setSize
(
int
newWidth,
int
newHeight );
124
125
/**
126
* Accept the keyboard focus.
127
*
128
* Reimplemented from YWidget.
129
**/
130
virtual
bool
setKeyboardFocus
();
131
132
133
protected
slots:
134
/**
135
* Triggered when the text in the InputField changes.
136
* This _may_ be of interest to the module.
137
**/
138
void
changed
(
const
QString & );
139
140
/**
141
* Display a warning that CapsLock is active:
142
* Replace the label with "CapsLock!"
143
**/
144
void
displayCapsLockWarning
();
145
146
/**
147
* Clear the CapsLock warning: Restore old label
148
**/
149
void
clearCapsLockWarning
();
150
151
152
protected
:
153
154
YQWidgetCaption
* _caption;
155
YQRawLineEdit
* _qt_lineEdit;
156
QY2CharValidator
* _validator;
157
bool
_shrinkable;
158
bool
_displayingCapsLockWarning;
159
};
160
161
162
/**
163
* Helper class that can obtain the CapsLock status, too.
164
* For some reason, Qt does not propagate that information from X11.
165
**/
166
class
YQRawLineEdit
:
public
QLineEdit
167
{
168
Q_OBJECT
169
170
public
:
171
172
/**
173
* Constructor
174
**/
175
YQRawLineEdit
( QWidget * parent )
176
: QLineEdit( parent )
177
, _capsLockActive( false )
178
{}
179
180
/**
181
* Destructor
182
**/
183
virtual
~YQRawLineEdit
() {};
184
185
/**
186
* Check if CapsLock is active
187
* (rather: was active at the time of the last key or focus event)
188
**/
189
bool
isCapsLockActive
()
const
{
return
_capsLockActive; }
190
191
192
signals:
193
void
capsLockActivated();
194
void
capsLockDeactivated();
195
196
protected
:
197
198
/**
199
* X11 raw event handler. Propagates all events to the Qt event handlers,
200
* but updates _capsLockActive for key events.
201
*
202
* Reimplemented from QWidget.
203
**/
204
bool
x11Event
( XEvent * event ) ;
205
206
private
:
207
208
bool
_capsLockActive;
209
};
210
211
#endif // YQInputField_h
src
YQInputField.h
Generated by
1.8.3.1