1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
/******************************************************************************
This source file is part of the Avogadro project.
This source code is released under the New BSD License, (the "License").
******************************************************************************/
#ifndef AVOGADRO_QTPLUGINS_COMMAND_H
#define AVOGADRO_QTPLUGINS_COMMAND_H
#include <avogadro/qtgui/extensionplugin.h>
#include <QtCore/QMap>
#include <QtCore/QStringList>
class QAction;
class QDialog;
namespace Avogadro {
namespace Io {
class FileFormat;
}
namespace QtGui {
class InterfaceScript;
class InterfaceWidget;
}
namespace QtPlugins {
/**
* @brief The Command class implements the extension interface for
* external (script) Commands
* @author Geoffrey R. Hutchison
*/
class Command : public QtGui::ExtensionPlugin
{
Q_OBJECT
public:
explicit Command(QObject* parent = 0);
~Command() override;
QString name() const override { return tr("Command scripts"); }
QString description() const override
{
return tr("Run external script commands");
}
QList<QAction*> actions() const override;
QStringList menuPath(QAction*) const override;
void setMolecule(QtGui::Molecule* mol) override;
public slots:
/**
* Scan for new scripts in the command directories.
*/
void refreshScripts();
void run();
bool readMolecule(QtGui::Molecule& mol) override;
private slots:
void menuActivated();
void configurePython();
private:
void updateScripts();
void updateActions();
void addAction(const QString& label, const QString& scriptFilePath);
QList<QAction*> m_actions;
QtGui::Molecule* m_molecule;
// keyed on script file path
QMap<QString, QtGui::InterfaceWidget*> m_dialogs;
QDialog* m_currentDialog;
QtGui::InterfaceWidget* m_currentInterface;
// maps program name --> script file path
QMap<QString, QString> m_commandScripts;
const Io::FileFormat* m_outputFormat;
QString m_outputFileName;
};
}
}
#endif // AVOGADRO_QTPLUGINS_COMMAND_H
|