plover.gui_qt
– Qt plugins#
This module provides the Qt-based steno engine, which is necessary for developing GUI tool plugins.
- class plover.gui_qt.Engine#
This is largely just a subclass of
StenoEngine
, except for some Qt-specific logic, such as the signals below.Since Qt’s signals will fit better into the Qt processing model than Plover’s default engine hooks, GUI plugins should use the API provided by this engine over the built-in one where possible.
- signal_connect(name: str, callback: Function)#
Registers
callback
as a callback to be called when thename
hook is triggered. The callback is called with the arguments shown in Engine Hooks when the hook is triggered.The individual Qt signals are also available below for convenience, for example if you need to trigger them manually. For example,
engine.signal_lookup.emit()
would trigger thelookup
hook. The arguments for each signal are shown in Engine Hooks.
- signal_stroked: QSignal#
The signal version of the
stroked
hook.
- signal_translated: QSignal#
The signal version of the
translated
hook.
- signal_machine_state_changed: QSignal#
The signal version of the
machine_state_changed
hook.
- signal_output_changed: QSignal#
The signal version of the
output_changed
hook.
- signal_config_changed: QSignal#
The signal version of the
config_changed
hook.
- signal_dictionaries_loaded: QSignal#
The signal version of the
dictionaries_loaded
hook.
- signal_send_string: QSignal#
The signal version of the
send_string
hook.
- signal_send_backspaces: QSignal#
The signal version of the
send_backspaces
hook.
- signal_send_key_combination: QSignal#
The signal version of the
send_key_combination
hook.
- signal_add_translation: QSignal#
The signal version of the
add_translation
hook.
- signal_focus: QSignal#
The signal version of the
focus
hook.
- signal_configure: QSignal#
The signal version of the
configure
hook.
- signal_lookup: QSignal#
The signal version of the
lookup
hook.
- signal_suggestions: QSignal#
The signal version of the
suggestions
hook.
- signal_quit: QSignal#
The signal version of the
quit
hook.
Tools#
Plover provides a helper class for creating GUI tools:
- class plover.gui_qt.tool.Tool(engine)#
A subclass of
QDialog
for creating GUI tools. When writing a GUI tool, you would typically subclass bothTool
and some generated code class (namedUi_YourTool
or something) to take care of the UI setup.- setupUi(widget)#
Sets up the user interface for this tool. You would typically call this in the
__init__
method of your subclass to actually build the UI. Make sure to passself
in if you do.
- TITLE: str#
The title that would show up in the main window’s toolbar and the tools list in the main menu.
- ICON: str#
The path to the icon for this tool, usually of the form
:/icon.svg
. This file should be included as a resource in the GUI plugin.
- ROLE: str#
A unique name to identify this tool when saving and loading state.
- SHORTCUT: str#
A keyboard shortcut to activate this window, for example
Ctrl+F
.
- _save_state(settings: QSettings)#
Saves the current state of this tool to
settings
. Callsettings.setValue(key, value)
to store individual properties in this settings object.
- _restore_state(settings: QSettings)#
Restores the current state of this tool from
settings
. Callsettings.value(key)
to retrieve values for the desired properties.
Machine Options#
- class plover.gui_qt.machine_options.MachineOption#
Represents the user interface for manipulating machine-specific configuration options. Each
MachineOption
class is also a subclass of aQWidget
and is set up with a UI, similar toTool
above.This isn’t itself a real class, though; in order to support a machine options UI for your machine, subclass
QWidget
and your UI class of choice and implement the method and attribute below.- setValue(value)#
Sets the contained value to
value
.
- valueChanged: QSignal#
A signal that gets emitted when the contained value is changed. Callbacks are called with the new value.
- class plover.gui_qt.machine_options.KeyboardOption#
A :class:
MachineOption
class for keyboard-specific options.
- class plover.gui_qt.machine_options.SerialOption#
A :class:
MachineOption
class for serial connection-specific options.
Utilities#
- plover.gui_qt.utils.ToolBar(*action_list: List[QAction]) QToolBar #
Returns a toolbar with a button for each of the specified actions.
Returns a dictionary mapping action names to action objects in
menu
. This traverses the entire menu tree recursively.