25#include <Poco/Environment.h>
37std::once_flag DLLS_LOADED;
41bool helpSystemNotAvailableMsgDisplayed =
false;
68 const QString &optionalMsg,
const QStringList &enabled,
69 const QStringList &disabled) {
71 if (AlgorithmDialogFactory::Instance().exists(alg->name() +
"Dialog")) {
72 g_log.
debug() <<
"Creating a specialised dialog for " << alg->name() <<
'\n';
73 dlg = AlgorithmDialogFactory::Instance().createUnwrapped(alg->name() +
"Dialog");
76 g_log.
debug() <<
"No specialised dialog exists for the " << alg->name()
77 <<
" algorithm: a generic one has been created\n";
81 dlg->setParent(parent);
82 dlg->setAttribute(Qt::WA_DeleteOnClose,
true);
85 Qt::WindowFlags flags = Qt::WindowFlags();
91 flags |= Qt::CustomizeWindowHint;
92 flags |= Qt::WindowMinimizeButtonHint;
93 flags |= Qt::WindowCloseButtonHint;
96 flags |= Qt::WindowCloseButtonHint;
98 dlg->setWindowFlags(flags);
129 QWidget *parent,
bool forScript,
131 const QString &optionalMsg,
const QStringList &enabled,
132 const QStringList &disabled) {
134 auto alg = Mantid::API::AlgorithmManager::Instance().create(algorithmName.toStdString(), version);
137 return createDialog(alg, parent, forScript, presetValues, optionalMsg, enabled, disabled);
148 std::string iname = interface_name.toStdString();
150 user_win = UserSubWindowFactory::Instance().createUnwrapped(iname);
155 g_log.
debug() <<
"Created a specialised interface for " << iname <<
'\n';
160 user_win->setParent(parent, user_win->windowFlags());
162 user_win->setParent(parent);
171 g_log.
error() <<
"Error creating interface " << iname <<
"\n";
187 for (
auto &window : existingWindows)
188 window->otherUserSubWindowCreated(newWindow);
192 existingWindows.append(newWindow);
197 existingSubWindows.erase(std::remove_if(existingSubWindows.begin(), existingSubWindows.end(),
198 [](QPointer<UserSubWindow> &window) { return window.isNull(); }),
199 existingSubWindows.end());
200 return existingSubWindows;
228 if (!helpSystemNotAvailableMsgDisplayed) {
229 g_log.
information(
"Help system not available (no viewer registered via factory).");
230 helpSystemNotAvailableMsgDisplayed =
true;
236 g_log.
error(
"Error creating help window via factory registration.");
245 window->showPage(url);
251 window->showAlgorithm(
name, version);
257 window->showConcept(
name);
263 window->showFitFunction(
name);
269 QString pagePath = QString(
"interfaces/%1/%2.html").arg(area).arg(
name);
270 if (!section.isEmpty()) {
271 pagePath += QString(
"#%1").arg(section);
273 window->showPage(pagePath);
280 g_log.
debug(
"InterfaceManager::closeHelpWindow() called. Note: Direct management of a single help window instance is "
287 window->showPage(QString());
This class should be the basis for all customised algorithm dialogs.
void addEnabledAndDisableLists(const QStringList &enabled, const QStringList &disabled)
Set comma-separated-list of enabled parameter names.
void setAlgorithm(const Mantid::API::IAlgorithm_sptr &)
The following methods were made public for testing in GenericDialogDemo.cpp.
bool isForScript() const
Get the usage boolean value.
void setOptionalMessage(const QString &message)
Set an optional message to be displayed at the top of the dialog.
void executeOnAccept(bool on)
If true then execute the algorithm on acceptance.
void initializeLayout()
Create the layout of the widget. Can only be called once.
void setPresetValues(const QHash< QString, QString > &presetValues)
Set a list of suggested values.
This class gives a basic dialog that is not tailored to a particular algorithm.
AlgorithmDialog * createDialog(const std::shared_ptr< Mantid::API::IAlgorithm > &alg, QWidget *parent=nullptr, bool forScript=false, const QHash< QString, QString > &presetValues=(QHash< QString, QString >()), const QString &optional_msg=QString(), const QStringList &enabled=QStringList(), const QStringList &disabled=QStringList())
Create a new instance of the correct type of AlgorithmDialog.
void showFitFunctionHelp(const QString &name=QString())
AlgorithmDialog * createDialogFromName(const QString &algorithmName, const int version=-1, QWidget *parent=nullptr, bool forScript=false, const QHash< QString, QString > &presetValues=(QHash< QString, QString >()), const QString &optionalMsg=QString(), const QStringList &enabled=QStringList(), const QStringList &disabled=QStringList())
Create an algorithm dialog for a given name and version.
UserSubWindow * createSubWindow(const QString &interface_name, QWidget *parent=nullptr, bool isWindow=true)
Create a new instance of the correct type of UserSubWindow.
static QList< QPointer< UserSubWindow > > & existingInterfaces()
Returns a list of existing UserSubWindows.
InterfaceManager()
Constructor.
void showCustomInterfaceHelp(const QString &name, const QString &area=QString(), const QString §ion=QString())
void showConceptHelp(const QString &name)
static Mantid::Kernel::AbstractInstantiator< MantidHelpInterface > * m_helpViewer
Handle to the help window factory.
QStringList getUserSubWindowKeys() const
The keys associated with UserSubWindow classes.
void showWebPage(const QString &url)
void showAlgorithmHelp(const QString &name, const int version=-1)
MantidHelpInterface * createHelpWindow() const
Function that instantiates the help window.
static void registerHelpWindowFactory(Mantid::Kernel::AbstractInstantiator< MantidHelpInterface > *factory)
Registration function for the help window factory.
void showHelpPage(const QString &url=QString())
virtual ~InterfaceManager()
Destructor.
void notifyExistingInterfaces(UserSubWindow *newWindow)
Notifies the existing interfaces that a new interface has been created, and then notifies the new int...
static bool openUrl(const QUrl &url)
Opens a url in the appropriate web browser.
This is the base class all customised user interfaces that do not wish to be tied to a specific Manti...
void setInterfaceName(const QString &iface_name)
Set the interface name, made public so possible from Python.
virtual void otherUserSubWindowCreated(QPointer< UserSubWindow > window)
To be overridden in order to connect a signal between two interfaces.
void initializeLayout()
Create the layout of the widget. Can only be called once.
The base class for instantiators.
Exception for when an item is not found in a collection.
The Logger class is in charge of the publishing messages from the framework through various channels.
void debug(const std::string &msg)
Logs at debug level.
void error(const std::string &msg)
Logs at error level.
void information(const std::string &msg)
Logs at information level.
EXPORT_OPT_MANTIDQT_COMMON int loadPluginsFromCfgPath(const std::string &key)
Load plugins from a path given by the key in the config service.
Kernel::Logger g_log("DetermineSpinStateOrder")