View Single Post
Old 08-11-2021, 12:46 PM   #16
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,884
Karma: 6120478
Join Date: Nov 2009
Device: many
Quote:
Originally Posted by DiapDealer View Post
I agree. I don't know how feasible it would be, but the ability to continue (ignore) or abort in the event of a validation error would be optimal, I think.
So hopefully something along these lines:

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();
    }
}
Not sure if this will even compile and that a non-Modal QMessageBox is even possible. But if so, the user can then decide to fix the validation errors before deciding on ignore or abort.

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?
KevinH is offline   Reply With Quote