uisettings — Settings dialogue¶
Module provides GUI to edit settings. This GUI may be used by other core modules and by plugins.
Conception¶
Settings dialogue subsystem consists of 3 major entities:
UISettings.ui GUI form. Contains of controls.
*Option classes.
Every object of the class links together control on GUI and option in the config file. It loads its option from config to GUI, and saves from GUI to config.
config may be either
enki.core.config.Config
or python dictionaryenki.core.uisettings.UISettingsManager
. Invokes the dialogue. Emits signals when Plugins shall add own settings to the dialogue and when Plugins shall apply settings
GUI dialog invocation workflow¶
- Enki starts. Each plugin connects themselves to UISettingsManager.aboutToExecute
- An user clicks Settings->Settings
- UISettings.ui are created
enki.core.uisettings.UISettingsManager
emits aboutToExecute- Each plugins adds own options to the dialogue
- Each option loads its value from the
enki.core.config.Config
- The user edits settigns
- The user clicks OK
- Each option writes it’s new value to the config
enki.core.uisettings.UISettingsManager
emits dialogAccepted- Each plugin applies own settings
Adding new settings¶
If you need to add own settings to UISettings dialog, you should:
- Connect to UISettingsManager.aboutToExecute and UISettingsManager.dialogAccepted
- Add controls to the dialog. You may edit UISettings.ui or add your controls dynamically during dialog creation (connect to UISettingsManager.aboutToExecute for adding dynamically)
- Create *Option class instance for every configurable option on UISettingsManager.aboutToExecute
Classes¶
- Main classes:
enki.core.uisettings.UISettings
- settings dialogue. Created when shall be executedenki.core.uisettings.UISettingsManager
- manager. Exists always
- Option types:
enki.core.uisettings.CheckableOption
- bool option, CheckBoxenki.core.uisettings.TextOption
- string option, line editenki.core.uisettings.ListOnePerLineOption
- list of strings option, text editenki.core.uisettings.NumericOption
- numeric option, any numeric controlenki.core.uisettings.ColorOption
- color option, buttonenki.core.uisettings.FontOption
- font option, buttonenki.core.uisettings.ChoiseOption
- string from the set option, combo box
-
class
enki.core.uisettings.
Option
(dialog, config, optionName, control)¶ Base class for all Options. Every class knows control on UISettings form, configuration option name, and can load/save the option
Do not create dirrectly, use *Option classes
-
load
()¶ Load the value from config to GUI. To be implemented by child classes
-
save
()¶ Save the value from GUI to config. To be implemented by child classes
-
-
class
enki.core.uisettings.
CheckableOption
(dialog, config, optionName, control)¶ Bases:
enki.core.uisettings.Option
Bool option.
Control may be QCheckBox, QGroupBox or other control, which has .isChecked() and .setChecked()
-
load
()¶ Load the value from config to GUI
-
save
()¶ Save the value from GUI to config
-
-
class
enki.core.uisettings.
TextOption
(dialog, config, optionName, control)¶ Bases:
enki.core.uisettings.Option
Text option
Control may be QLineEdit
-
load
()¶ Load the value from config to GUI
-
save
()¶ Save the value from GUI to config
-
-
class
enki.core.uisettings.
ListOnePerLineOption
(dialog, config, optionName, control)¶ Bases:
enki.core.uisettings.Option
List of strings. One item per line.
Control may be QPlainTextEdit
-
load
()¶ Load the value from config to GUI
-
save
()¶ Save the value from GUI to config
-
-
class
enki.core.uisettings.
NumericOption
(dialog, config, optionName, control)¶ Bases:
enki.core.uisettings.Option
Numeric option.
Control may be QSlider or other control, which has .value() and .setValue() methods
-
load
()¶ Load the value from config to GUI
-
save
()¶ Save the value from GUI to config
-
-
class
enki.core.uisettings.
ColorOption
(dialog, config, optionName, control)¶ Bases:
enki.core.uisettings.Option
Color option
Control must be enki.widgets.ColorButton
-
load
()¶ Load the value from config to GUI
-
save
()¶ Save the value from GUI to config
-
-
class
enki.core.uisettings.
FontOption
(dialog, config, familyOption, sizeOption, editControl, buttonControl)¶ Bases:
enki.core.uisettings.Option
Font option.
Option has 2 controls:
- QLineEdit is an example of font
- Button is used for open font dialogue.
This option opens Font dialogue automatically, when button has been clicked
-
load
()¶ Load the value from config to GUI
-
save
()¶ Save the value from GUI to config
-
class
enki.core.uisettings.
ChoiseOption
(dialog, config, optionName, controlToValue)¶ Bases:
enki.core.uisettings.Option
This option allows to choose value from few possible.
It is presented as set of QRadioButton’s
controlToValue dictionary contains mapping checked radio button name: option value
-
load
()¶ Load the value from config to GUI
-
save
()¶ Save the value from GUI to config
-
-
class
enki.core.uisettings.
UISettings
(parent)¶ Bases:
QDialog
Settings dialog widget
-
appendPage
(path, widget, icon=None)¶ Append page to the tree. Called by a plugin for creating own page. Example:
widget = MitSchemeSettings(dialog) dialog.appendPage(u"Modes/MIT Scheme", widget, QIcon(':/enkiicons/languages/scheme.png'))
-
on_twMenu_itemSelectionChanged
()¶
-
-
class
enki.core.uisettings.
UISettingsManager
¶ Bases:
QObject
Add to the main menu Settings->Settings action and execute settings dialogue
-
aboutToExecute
¶ aboutToExecute(
enki.core.uisettings.UISettings
)Signal emitted, when dialog is about to be executed. Plugins shall add own settings to the dialogue
-
dialogAccepted
¶ accepted()
Signal emitted, when dialog has been accepted. Plugins shall save and apply settings
-
del_
()¶
-