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 dictionary

  • enki.core.uisettings.UISettingsManager. Invokes the dialogue. Emits signals when Plugins shall add own settings to the dialogue and when Plugins shall apply settings

Edit the diagramm

GUI dialog invocation workflow

  1. Enki starts. Each plugin connects themselves to UISettingsManager.aboutToExecute
  2. An user clicks Settings->Settings
  3. UISettings.ui are created
  4. enki.core.uisettings.UISettingsManager emits aboutToExecute
  5. Each plugins adds own options to the dialogue
  6. Each option loads its value from the enki.core.config.Config
  7. The user edits settigns
  8. The user clicks OK
  9. Each option writes it’s new value to the config
  10. enki.core.uisettings.UISettingsManager emits dialogAccepted
  11. Each plugin applies own settings

Adding new settings

If you need to add own settings to UISettings dialog, you should:

  1. Connect to UISettingsManager.aboutToExecute and UISettingsManager.dialogAccepted
  2. 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)
  3. Create *Option class instance for every configurable option on UISettingsManager.aboutToExecute

Classes

Main classes:
Option types:
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'))
appendOption(option)

Append *Option instance to the list of options

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_()