04-17-2016, 09:50 AM | #1 |
Grand Sorcerer
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
Tabbed Driver Configuration
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. |
04-17-2016, 10:21 AM | #2 |
Grand Sorcerer
Posts: 6,233
Karma: 11768331
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
I would glad to use this if it can replace the KoboTouchExtended (if you tell me how). I prefer this organization. Only one question: does it include the template metadata update as KoboUtilities?
|
Advert | |
|
04-17-2016, 07:40 PM | #3 | |||
Grand Sorcerer
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
Quote:
Code:
if opts.extra_customization[self.OPT_MODIFY_CSS]: Code:
if self.modifying_epub(): Quote:
Quote:
As an aside, I've actually been using a plugboard to set the comments when sending books. I just added the comments to the list of "dest_fields" in gui2/preferences/plugboard.py. Then used the template I had defined for the Utilities plugin in plugboard. I have been doing this for a while and haven't had a problem with it. But, I also made sure the template I used was correct and haven't tracked through all the code used to set the comments to see where it might go wrong. |
|||
05-18-2016, 11:42 AM | #4 |
Grand Sorcerer
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
@David,
As I don't use KoboTouchExtended I'll restrict my comments to the first 3 Tabs. Some general first thoughts:
More specific thought:
Final thought:
Last edited by jackie_w; 05-18-2016 at 04:10 PM. Reason: On reflection, I'm not sure that was fair comment |
05-20-2016, 10:28 PM | #5 | ||||||
Grand Sorcerer
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
Quote:
Quote:
Quote:
Thanks for all the comments. |
||||||
Advert | |
|
05-22-2016, 10:21 AM | #6 |
Grand Sorcerer
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
I have just committed to my repository the changes as suggested by jackie_w plus a couple of other changes in how the tabs and widgets are managed.
If anyone wants to look at the changes and comment... |
05-22-2016, 12:50 PM | #7 |
Grand Sorcerer
Posts: 6,233
Karma: 11768331
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
I'm trying it but I always get this message when I try to configure it:
Spoiler:
|
05-22-2016, 01:53 PM | #8 |
Grand Sorcerer
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
@David,
I have my device driver set as your updated standard KOBOTOUCH and I get this error if I try to save a driver config change: Spoiler:
|
05-22-2016, 08:11 PM | #9 |
Grand Sorcerer
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
The extended driver has been updated in the last week or so. You need to make the changes I suggested a few posts up. I'll try and remember to create a version that works with both KoboTouch drivers tonight.
|
05-22-2016, 08:27 PM | #10 |
Grand Sorcerer
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
I think I might have broken something in the migration of the old settings. I didn't recheck this last night and was working with an already migrated settings file. Could you removed the file "device_drivers_KOBOTOUCH.py" in your calibre configuration directory and try again?
|
05-23-2016, 08:18 AM | #11 | |
Grand Sorcerer
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
Quote:
- device_drivers_KOBO.py - device_drivers_KOBOTOUCHCSSEDIT.py (the driver for my subclassed KOBOTOUCH) I'm still getting an error. This is the complete log from calibre startup to failing to save the config: Spoiler:
Is there something else I should have disabled or deleted before starting? ETA: Just in case removing device_drivers_KOBO.py wasn't a very smart thing to do, I put it back, restarted calibre and re-ran the test. Still the same error Code:
TypeError: <calibre.utils.config_base.OptionValues object at 0x...> is not JSON serializable Last edited by jackie_w; 05-23-2016 at 08:57 AM. Reason: ETA2 |
|
05-23-2016, 10:32 AM | #12 | |
Grand Sorcerer
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
Quote:
I'll have to look at that code again to work out what I was intending. In the meantime, you can get past this by creating a file called KoboTouch_devices.json in the calibre configuration directory. The contents needs to be: Code:
{ "KoboTouch": { } } |
|
05-24-2016, 02:52 PM | #13 |
Grand Sorcerer
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
FYI. I noticed that the file KoboTouch_devices.json was already in the config directory, dated May 18, but it was empty. After adding the content you specified above there were no errors when I did a Save Config.
I did observe that if I made a config change and saved, although there were no errors the contents of KoboTouch_devices.json did not change. Is this what you would expect? |
05-24-2016, 07:57 PM | #14 |
Grand Sorcerer
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
Yes, that's what I should have expected.
The problem was that when I started this, I pulled code from the MTP driver and it's configuration dialog. It handles the configuration at the actual device level rather than one set for the driver. I had a look at doing this for the Kobo driver, but, it broke to much. The parent classes all assume the single configuration and overriding that was more work than I wanted at the time. I thought I had removed all this code, but, I had missed this one bit. Everything else would have been working properly. This was just a check being done when saving configuration against the current configuration to prevent unnecessary writes. But, it wasn't checking against the correct saved configuration. Putting the null configuration in means that the checks always come as as a change happened, and the correct configuration is saved in the right place. I fixed this last night, but haven't checked it in yet. I'll do it tonight after some more testing. |
05-25-2016, 09:08 AM | #15 |
Grand Sorcerer
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
I'm happy with those changes and have checked them in. The configuration should work without the KoboTouch_devices.json existing. Tell me how it goes.
|
Tags |
configuration, drivers, kobo |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Kindle 4NT tabbed browsing fix attempt | ghudod | Kindle Developer's Corner | 36 | 01-08-2013 02:24 PM |
tabbed browsing | rbrohman | Kindle Developer's Corner | 6 | 02-19-2011 06:10 PM |
Format tabbed text columns, NOT flowing | Hitch | Sigil | 19 | 06-09-2010 07:58 PM |
Grassroots works! MS IE to do "tabbed browsing" | Alexander Turcic | Lounge | 1 | 06-10-2005 11:12 AM |