Quantcast
Channel: MobileRead Forums - Reading and Management
Viewing all articles
Browse latest Browse all 24022

Tabbed Driver Configuration

$
0
0
I made a comment in a thread earlier in the year about options seeming to the bane of my life. That was about the options for a plugin, but the set of options that I was really thinking of are those in the drivers. Or specifically, the extra customisation options in the KoboTouch driver. Any time I need to change these, it's a pain. Especially if I want to group the changes.

I've been thinking about this for a while, but finally got around to it earlier this year. The biggest thing is I didn't want to break anything or have to re-implement a lot of the options and how they are handled in the different drivers.

What I have come up with is a tabbed interface. The first tab is "File Formats" and has the common options including the file formats save template. After this, are the custom tabs for the driver. There is one last tab, "Extra Customization" if these are needed.

There are several new classes. The main one is "TabbedDeviceConfig". This is to be expected to be subclassed for any specific driver. But, if used by a driver will show the "File Formats" and "Extra Customization" tabs and work the same as the existing ConfigWidget.

There are two other abstract classes. "DeviceConfigTab" is parent class for a device specific tab. The other is "DeviceOptionsGroupBox". This is intended as the parent class for groups of options displayed on the tabs. The subclasses of this should implement the actual options. This will include any interactions between the options such as disabling certain options when another is selected. This is where most of the code for individual drivers will be.

Across these three classes, I have implemented some accessors so that the device specific options can be treated as properties. Making a call against a subclass of TabbedDeviceConfig will search all known tabs for the property or method. The subclass of DeviceConfigTab will search all known widgets, expected to be subclasses of DeviceOptionsGroupBox, for the accessor.

I have done a full implementation of this for the KOBOTOUCH driver. KOBOTOUCHConfig has two tabs, each with two groups of options. The options within the groups are related and, in some cases, interdependent. Selecting "Update metadata" will enable the "Set Series information" option. The first three attached screenshots show the three tabs for the driver. While making the changes to the driver to use the new configuration, I have made most of the options into properties in the driver. That made changing to the new configuration easier. Plus, the old versions was just ugly. I also needed to add a migration routine from the old to the new configuration. This will get run each time the driver is loaded until the user opens and saves the configuration. After that, it will not do anything.

For the KOBO driver, I have not done the full implementation. But, I have changed it to use TabbedDeviceConfig. This driver is stable and I haven't needed to make changes in the options for a long. I haven't decided whether to complete the changes for this driver.

A complication in this is the KoboTouchExtended driver. This is a subclass of KOBOTOUCH but is a separate plugin. I have made some small changes to my local copy of this to use new configuration. The fourth screenshot is of the "Extra Customization" tab for this driver. This demonstrates the mixing of the methods for doing the options.

I have been using this for about three months with no problems. I have also done some testing of other drivers to use TabbedDeviceConfig instead of the current widget. They all worked for reading and saving the options. But, as I don't have an appropriate device, I can't do complete tests. I am reasonably confident it works. This was mainly experimenting to make sure I didn't break anything. Most device drivers do not need the extra function provided by these changes. In fact, it is probably only the KOBOTOUCH driver that does. Most of the others either don't have the extra options, or they are simple enough to be handled by the current configuration widgets.

I'm at the point where I need others to comment. The code is in https://github.com/davidfor/calibre.git. Within that, the new code is in:
- devices/kobo/kobotouch_config.py
- devices/kobo/driver.py
- gui2/device_drivers/tabbed_device_config.py

Any comments or suggestions for improvement are welcome. I am sure there are better ways to do some of this.

Attached Thumbnails
Click image for larger version

Name:	KOBOTOUCHConfig-FileFormats.png
Views:	N/A
Size:	18.8 KB
ID:	147927   Click image for larger version

Name:	KOBOTOUCHConfig-Collections.png
Views:	N/A
Size:	17.8 KB
ID:	147928   Click image for larger version

Name:	KOBOTOUCHConfig-Metadata.png
Views:	N/A
Size:	17.2 KB
ID:	147929   Click image for larger version

Name:	KoboTouchExtended-Extra.png
Views:	N/A
Size:	19.5 KB
ID:	147930  

Viewing all articles
Browse latest Browse all 24022

Trending Articles