Settings/preferences menu

The need for a settings dialog in Avogadro has been discussed several times recently. It would be good to collect together a list of what should be put into it from the various threads mentioning the idea.

Please comment with any ideas!

Things that come to mind:

  • User-interface language
  • Python path, environment settings
  • Rendering options
  • Atom indexing from 0 or 1
  • Element colours
  • Scroll wheel/gesture inversion

Other possible options, but maybe preferable to keep elsewhere:

  • Background colour

Edit: additions:

  • Preferred unit of energy (Hartree, eV, kJ/mol, kcal/mol)
  • Preferred unit of length (Angstrom, pm, nm)
  • Light/dark mode switch

Downloading / installing / activating scripts seems like it would be useful too

Do you mean what is currently under Extensions > Download plugins...?

I added an issue to the tracker:

Seems like I can’t edit the original post any more.

Additional settings ideas:

  • Preferred units for IR frequencies (wavenumber in cm-1, wavelength in µm)
  • Preferred units for UV-vis absorptions (wavelength in nm, energy in eV)

The light/dark mode switch would be a manual switch to override the automatic switching that Avogadro now successfully does by itself. Maybe it isn’t necessary. Though it is useful failsafe behaviour.

The unit preferences would need to permeate to various other parts of the interface. I’ll start making notes of those places on the GitHub issue as I spot them, else I’ll forget them again.

I guess there will need to be some sort of object that contains the user’s configuration that other parts of the code can import and read. Does that already exist @ghutchis and if so where is it? E.g. for the Python settings that are already implemented.

It would be good if the user’s config could also be passed to extensions as a dictionary, as part of the stuff sent via stdin. Minus any sensitive information that could be abused by plugins, I guess.

I think these need to be added to the spectra dialog itself. (For example NMR visualization needs a popup to pick \ce{^1H} or \ce{^{13}C} etc.

This is handled by Qt. Anytime you create a QSettings object, it grabs the correct settings automatically. These are key / value pairs, although you can add contexts (e.g. spectra/units/ir or similar).

I guess the next step is whether this is a dialog with sections / tabs (like Avo 1.2) or a menu with options.

I’d generally prefer the dialog, since most programs have Settings / Preferences dialogs, although it may be easier to move some existing menu commands (e.g., UI language) into a submenu.

So … if there’s a new menu item for the dialog (and maybe a submenu) where do they live?

I agree that there should be way to switch it there too, but I think for a good UX any setting should also be findable in the settings dialog, as people will look for things there.

I’d also be pro-dialog.

I don’t know how the code for the existing menu commands that deal with user preferences looks, whether they all make use of some class that expects it to be located in a menu or whether they are just standard QDialogs.

If the latter, how about this: as a transitional thing the current dialogs are kept as is, it’s just that they are opened from buttons in the new settings dialog instead of from menu options?

Then the settings can be gradually migrated properly into the dialog later, it makes the initial implementation easier, but they are still accessed from the same central place from the get go (which to my mind is the priority, gathering the scattered options together).

In many cases, the current dialogs are done through code, rather than a .ui file. But they wouldn’t take much work to migrate. Under the hood, everything just looks for QSettings with an appropriate key.

That said, it’s still possible to do a little at a time.

The previous settings dialog was here: avogadro/avogadro/src/settingsdialog.cpp at e1146f240b6d9fe5e2ffe267f334610dfe4467e1 · cryos/avogadro · GitHub

It’s basically just a QStackedWidget for each of the individual settings dialogs, and a QListView for the set of icons on the left. Could be fairly easy to put the icons into a toolbar at top as well.

My suggestion would be to try creating a simple settings dialog and start by moving the configurepython pieces there: avogadrolibs/avogadro/qtplugins/configurepython at master · OpenChemistry/avogadrolibs · GitHub

Then maybe the plugin downloading?

1 Like

Using .ui files rather than coding would be your preference going forward? (I would have defaulted to the opposite because I have never used Qt Creator/Designer/whatever but am happy to adapt.)

For really simple things, it’s easy enough to do in code (e.g., throw up a dialog asking for a path).

For more complex things, it’s much easier to create a .ui file because Qt will auto-generate a lot of code for the UI (e.g., layout, labels, etc.)

Take a look at a few of the .ui files – it’s really easy and I’m happy to give pointers.

1 Like