NDEVR
API Documentation
Keypad.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Widgets
28File: Keypad
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/Dictionary.h>
35#include <NDEVR/ApplicationOptions.h>
36#include <NDEVR/String.h>
37#include <QWidget>
38class QTextEdit;
39class QLineEdit;
40class QTimer;
41namespace Ui
42{
43 class KeypadUI;
44}
45namespace NDEVR
46{
47 class QCustomLineEdit;
48 class Button;
49 struct PopupInfo;
50 class KeypadSettings;
56 class NDEVR_WIDGETS_API Keypad : public QWidget
57 {
58 Q_OBJECT
59 public:
62 Keypad(QWidget* parent = nullptr);
67 void setLineEdit(QLineEdit* line_edit);
70 void setTextEdit(QTextEdit* line_edit);
73 [[nodiscard]] QWidget* currentWidget() const;
76 [[nodiscard]] QWidget* lastWidget() const;
79 [[nodiscard]] QCustomLineEdit* editor() const;
82 [[nodiscard]] static bool IsKeypadInitialized();
85 [[nodiscard]] static Keypad* DefaultKeypad();
89 static bool IsCurrentKeypadFocus(const QWidget* widget);
92 void setUpperCase(bool uppercase);
98 QSize sizeHint() const override;
101 QSize minimumSizeHint() const override;
104 bool isFullKeyboard() const { return m_is_full_keyboard; }
110 void focusInEvent(QFocusEvent* focus) override;
113 void mousePressEvent(QMouseEvent* event) override;
116 void setCurrentInputHints(Qt::InputMethodHints hints);
121 public slots:
128 protected slots:
131 signals:
136 protected:
139 void addChar(char value);
144 void setupButton(Button* b, char insert_char, bool add_to_lookup = true);
149 void backspace();
157 void complete();
159 void clear();
166 QLineEdit* m_line_edit;
167 QTextEdit* m_text_edit;
168 QWidget* m_last_widget;
175 Ui::KeypadUI* ui;
178 Qt::InputMethodHints m_input_hints;
179 };
180}
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
A core widget that allows the user to click one of many button types.
Definition Button.h:68
A hash-based key-value store, useful for quick associative lookups.
Definition Dictionary.h:64
Generic Settings for keypad including scales and when to show the keypad.
static bool IsKeypadInitialized()
Checks whether the global default keypad has been initialized.
QLineEdit * m_line_edit
The currently attached QLineEdit target.
Definition Keypad.h:166
bool isFullKeyboard() const
Checks whether the keypad is currently showing a full QWERTY keyboard.
Definition Keypad.h:104
void setCurrentInputHints(Qt::InputMethodHints hints)
Sets the input method hints that determine which keys are available.
void setupButton(Button *b, char insert_char, bool add_to_lookup=true)
Configures a button to insert a specific character when pressed.
void mousePressEvent(QMouseEvent *event) override
Handles mouse press events on the keypad.
void updateWindowTitle()
Updates the window title to reflect the current input context.
static Keypad * DefaultKeypad()
Returns the global default Keypad instance.
void focusPreviousWidget()
Moves focus to the previous widget in the tab order.
void onFocusObjectDeleted()
Slot called when the current focus object is destroyed.
Dictionary< String, Button * > m_symbols_b
Second page of symbol buttons.
Definition Keypad.h:165
bool m_is_folder
Whether the input context is a folder path.
Definition Keypad.h:173
void updateUppercase()
Updates the case state of keyboard letter buttons.
void updateCurrentText()
Updates the displayed text to match the current target widget content.
void focusInEvent(QFocusEvent *focus) override
Handles focus-in events for the keypad widget.
Buffer< Button * > m_buttons
All buttons on the keypad.
Definition Keypad.h:162
void updateFocusGroups()
Updates the focus chain groups for tab navigation.
void requestHideSignal()
Emitted to request that the keypad popup be hidden.
void setTextEdit(QTextEdit *line_edit)
Attaches the keypad to a QTextEdit for input.
void showSettings(PopupInfo info)
Shows the keypad settings dialog as a popup.
void setupButton(Button *b)
Configures a button with its default behavior.
bool m_is_file
Whether the input context is a file path.
Definition Keypad.h:172
String m_original_text
The original text before keypad editing began.
Definition Keypad.h:169
QSize minimumSizeHint() const override
Returns the minimum size hint for the keypad.
void setLineEdit(QLineEdit *line_edit)
Attaches the keypad to a QLineEdit for input.
bool m_is_full_keyboard
Whether the full QWERTY keyboard layout is active.
Definition Keypad.h:174
void setUpperCase(bool uppercase)
Sets whether the keypad displays uppercase characters.
void clear()
Clears the current input text.
void addChar(char value)
Appends a character to the current input.
void complete()
Accepts the current input and closes the keypad.
Qt::InputMethodHints m_input_hints
The current input method hints controlling available keys.
Definition Keypad.h:178
void requestPopupSignal()
Emitted to request that the keypad popup be shown.
void unsetCurrent()
Detaches the keypad from its current target widget.
void backspace()
Removes the last character from the current input.
KeypadSettings * m_keypad_settings
The keypad settings dialog.
Definition Keypad.h:176
QTextEdit * m_text_edit
The currently attached QTextEdit target.
Definition Keypad.h:167
void focusNextWidget()
Moves focus to the next widget in the tab order.
Ui::KeypadUI * ui
The auto-generated UI form.
Definition Keypad.h:175
QCustomLineEdit * editor() const
Returns the internal QCustomLineEdit used by the keypad for editing.
Keypad(QWidget *parent=nullptr)
Constructs a Keypad widget.
void requestPopupSlot()
Slot that triggers the keypad popup to appear.
Dictionary< String, Button * > m_symbols_a
First page of symbol buttons.
Definition Keypad.h:164
void slideInKeyboard(uint04 value)
Slides in a specific keyboard layout page.
~Keypad()
Destructor.
QSize sizeHint() const override
Returns the preferred size hint for the keypad.
QTimer * m_visibility_check_timer
Timer that periodically checks whether the keypad should be visible.
Definition Keypad.h:177
QWidget * m_last_widget
The last widget that had keypad focus.
Definition Keypad.h:168
QWidget * lastWidget() const
Returns the last widget that had keypad focus.
void requestHideSlot()
Slot that triggers the keypad popup to hide.
QWidget * currentWidget() const
Returns the widget currently receiving keypad input.
Dictionary< char, Button * > m_button_ids
Mapping from characters to their corresponding buttons.
Definition Keypad.h:163
static bool IsCurrentKeypadFocus(const QWidget *widget)
Checks whether the given widget currently has keypad focus.
QString m_original_window_title
The original window title before keypad was shown.
Definition Keypad.h:170
String m_current_text
The current text being edited in the keypad.
Definition Keypad.h:171
A line edit allows users to enter and edit a single line of plain text with useful editing functions,...
The core String class for the NDEVR API.
Definition String.h:95
The primary namespace for the NDEVR SDK.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Class which is used to pass arguments and requests for creating a popup dialog or widget.
Definition PopupInfo.h:16