08-11-2021, 12:46 PM | #16 | |
Sigil Developer
Posts: 7,630
Karma: 5433388
Join Date: Nov 2009
Device: many
|
Quote:
Code:
bool MainWindow::Automate(const QStringList &commands) { PluginDB *pdb = PluginDB::instance(); QHash<QString, Plugin *> plugins = pdb->all_plugins(); QStringList plugin_names = plugins.keys(); foreach(QString cmd , commands) { bool success = false; QString plugin_type; int validation_error_count = 0; if (plugin_names.contains(cmd)) { ShowMessageOnStatusBar(cmd + " " + tr("running")); PluginRunner prunner(m_TabManager, this); prunner.exec(cmd); qApp->processEvents(); success = prunner.getResult() == "success"; plugin_type = prunner.getPluginType(); if (plugin_type == "validation") { validation_error_count = prunner.getValidationErrorCount(); } } else { ShowMessageOnStatusBar(tr("Missing or unknown plugin") + ": " + cmd); break; } if (!success) { ShowMessageOnStatusBar(cmd + " " + tr("failed")); break; } if (plugin_type == "validation" && (validation_error_count != 0)) { // Try to pause to see if can ignore or not in a non-modal way ShowMessageOnStatusBar(tr("Validation Plugin Found Errors") + ": " + cmd); QMessageBox msgBox; msgBox.setText(tr("Validation found errors - Abort or Ignore?")) QPushButton * abortButton = msgBox.addButton(QMessageBox::Abort); QPushButton * ignoreButton = msgBox.addButton(QMessageBox::Ignore); msgBox.show(); if (msgBox.clickedButton() != ignoreButton) { break; } } qApp->processEvents(); } } We then add 3 new icons and an automate toolbar to parse the 3 different automate0x.txt scripts and pass the results to the Automate routine above for processing. Maybe? |
|
08-11-2021, 01:15 PM | #17 |
Sigil Developer
Posts: 7,630
Karma: 5433388
Join Date: Nov 2009
Device: many
|
If this approach works we can look up individual commands in a list of MainWindow tools and run those tools as well so that a mixed list of plugins and tools can be run.
We would still need to modify all MainWindow C++ tools we want to allow to return success or failure similar to how we do with plugins and that would take more than a bit of work. And then if that works finally design a dialog using checks to enable selections from a list of plugins and commands and perhaps some drag and drop to create an order that could be used to create the automate0x.txt lists. But let's start simple with 3 lists of plugins edited by the user and see if this approach proves at all useful in the end. |
Advert | |
|
08-11-2021, 01:22 PM | #18 |
Sigil Developer
Posts: 7,630
Karma: 5433388
Join Date: Nov 2009
Device: many
|
As for toolbar icons for the 3 Automate lists, how about a little robot person with a 1, 2, or 3 beside him/her in the svg icon?
Other suggestions welcome! Donations of artwork once decided upon welcome as well. Perhaps we can convince BeckyEbook to help us here again once we figure out an idea! Last edited by KevinH; 08-11-2021 at 01:33 PM. |
08-11-2021, 04:29 PM | #19 |
Bibliophagist
Posts: 35,307
Karma: 145435140
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Forma, Clara HD, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Sounds good to me.
|
08-11-2021, 09:44 PM | #20 |
Hedge Wizard
Posts: 800
Karma: 19999999
Join Date: May 2011
Location: UK/Philippines
Device: Kobo Touch, Nook Simple
|
I would love such a feature.
I have tried to reproduce it in the past using various freeware macro programs, I usually could get them working but they were fragile and needed constant maintenance. |
Advert | |
|
08-12-2021, 05:41 AM | #21 |
Guru
Posts: 689
Karma: 2180740
Join Date: Jan 2017
Location: Poland
Device: Kindle (Key3, PW2, PW3), Nook (ST, GLP), Kobo Touch, Tolino Vision 2
|
Working suggestions.
If any proposal will appeal – I will refine and prepare the final versions. |
08-12-2021, 08:17 AM | #22 |
Sigil Developer
Posts: 7,630
Karma: 5433388
Join Date: Nov 2009
Device: many
|
I like them all! Thank you!
I do think the robot arm icon is the easier to read and understand. It seems to best represent the automation concept. Does there already exist something appropriate for fluent and material icons we can use or would you refine one of these to match those sets? Last edited by KevinH; 08-12-2021 at 08:19 AM. |
08-12-2021, 09:24 AM | #23 |
Guru
Posts: 689
Karma: 2180740
Join Date: Jan 2017
Location: Poland
Device: Kindle (Key3, PW2, PW3), Nook (ST, GLP), Kobo Touch, Tolino Vision 2
|
I will prepare automate icons for all themes in next week.
|
08-12-2021, 09:26 AM | #24 |
Sigil Developer
Posts: 7,630
Karma: 5433388
Join Date: Nov 2009
Device: many
|
|
08-12-2021, 10:17 AM | #25 |
Sigil Developer
Posts: 7,630
Karma: 5433388
Join Date: Nov 2009
Device: many
|
Okay, I took the code pieces I had and BeckyEbook's robotic arm svg, and pushed to master a rough proof of concept for using automate lists of plugin names.
It only works with the main icon theme right now since it is just a proof of concept. Sigil adds a Automate toolbar with 3 automate icons. These can have keyboard shortcuts assigned. To use it, the user needs to create a list of plugin names (no version or .zip) one per line using any text editor and save the file as utf-8. A '#' can be used to comment out a line. And then save it in your Sigil Prefs directory under: automate01.txt automate02.txt automate03.txt I have tried to make the validation with errors block but still be non-modal so that errors can be fixed before choosing ignore or abort. But this may open a kettle of fish as it will be easy to lose the fact that a automation list is still in progress. If you build your own, bug reports welcome. If this appears to be useful, we will eventually expand the known commands to include some primary C++ based Sigil tools and then create a dialog to make it simple to edit and create these lists without having to use a separate text editor. Perhaps even making a plugin to edit these automation lists. Last edited by KevinH; 08-12-2021 at 11:17 AM. |
08-12-2021, 10:20 AM | #26 | |
Well trained by Cats
Posts: 29,779
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
Gears, spanners are commonly used for settings |
|
08-12-2021, 11:31 AM | #27 |
Sigil Developer
Posts: 7,630
Karma: 5433388
Join Date: Nov 2009
Device: many
|
If anyone gives this a try, remember the plugin names used in the list must exactly match the plugin names as set in the Plugin menus. All are case sensitive.
|
08-12-2021, 06:56 PM | #28 |
null operator (he/him)
Posts: 20,550
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
|
08-13-2021, 10:54 AM | #29 |
Sigil Developer
Posts: 7,630
Karma: 5433388
Join Date: Nov 2009
Device: many
|
FYI, I started the process of making selected tools from the MainWindow return values so that they can be used in the automate lists:
Right now these include:
This leads to a couple of questions: 1. How should we deal with intl Sigil user/devs in these automate lists if at all? In other words should we be treating them like shell/bat commands which are all English based like most programming and scripting languages? 2. Should shorthand notations for automate commands instead of actual C++ routine names (as provided above) be used (think unix like short command line tools) 3. How to deal with non-modal dialogs like Search Editor / SpellCheck, Edit TOC, Reports, Edit Metadata, etc? Should we wait until these dialogs are closed by the user before proceeding to the next command in the automate list? 4. How to deal with running a specifically named saved searches with replace? Or do we punt on this and require a plugin to do those types of things in an automated setting. Perhaps the best way to deal with this is to make a mac/Win builds available for testers to report back before going any further. If these features turn out not to be that usable for real power users/devs it will end up being a waste of time for little to no gain. Any Thoughts? Last edited by KevinH; 08-14-2021 at 12:06 PM. |
08-13-2021, 12:11 PM | #30 |
Guru
Posts: 689
Karma: 2180740
Join Date: Jan 2017
Location: Poland
Device: Kindle (Key3, PW2, PW3), Nook (ST, GLP), Kobo Touch, Tolino Vision 2
|
Ad 1. English names will be the best. translations sometimes change, not complete, etc., so it's asking for trouble. The Automate option is intended for advanced users, so creating "automateXX.txt" script with English names should be OK.
Ad 2. If it is well described in the documentation – a good idea. Ad 3. Of course, we wait until these dialogs are closed. Ad 4. Hmmm ... A difficult matter, because in Saved Searches we can do various actions: Find, Replace, Replace/Find, Replace All. Maybe something as: * "F&R-Find:GroupNameFromSavedSearches" (calling a search in the whole group, probably quote marks will be necessary) * "F&R-ReplaceAll:GroupNameFromSavedSearches/Single Sample Replace" (Replace All In Single Search In Saved Searches) ----- I would add an optional AutomateXX operation report (message box? logfile?): Code:
Function Name or Plugin Name 1: passed Function Name or Plugin Name 2: passed Function Name or Plugin Name 3: passed with errors Aborted by user Despite my earlier doubts, it might come in handy for some repetitive operations on each file. That's why I noticed that I missed a summary/report in which I could see that all the plugins "did their job" without errors. Now I have to look at the statusbar, because it is probably only there that we can see what is going on. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Feature requested for Sigil 1.7 | RbnJrg | Sigil | 23 | 08-06-2021 08:44 AM |
Feature Requests for Adding Books | toomuchreading | Library Management | 5 | 03-17-2015 03:15 PM |
Parity feature with Sigil | roger64 | Editor | 8 | 03-17-2014 11:28 AM |
New to "Read in Store" feature: Limited Selection | negris123 | Barnes & Noble NOOK | 4 | 06-09-2011 01:08 PM |
New Inkmesh Feature: Limited Time Free Ebooks | anurag | News | 11 | 02-25-2010 02:43 PM |