7 #include "uiGenericQt/action/ShowHelpContents.hpp" 9 #include <fwCore/base.hpp> 11 #include <fwGui/Cursor.hpp> 12 #include <fwGui/dialog/MessageDialog.hpp> 14 #include <fwServices/macros.hpp> 16 #include <boost/filesystem/operations.hpp> 18 #include <QApplication> 20 #include <QHBoxLayout> 21 #include <QHelpContentWidget> 22 #include <QHelpEngine> 25 #include <QTextBrowser> 37 HelpBrowser(QHelpEngine* helpEngine, QWidget* parent = 0) :
39 helpEngine(helpEngine)
45 QVariant loadResource(
int type,
const QUrl& url)
47 if (url.scheme() ==
"qthelp")
49 return QVariant(helpEngine->fileData(url));
53 return QTextBrowser::loadResource(type, url);
58 QHelpEngine* helpEngine;
66 ShowHelpContents::ShowHelpContents( ) noexcept :
67 m_bServiceIsConfigured(
false),
74 ShowHelpContents::~ShowHelpContents() noexcept
82 _sstream <<
"Action for show help contents" << std::endl;
96 if( m_configuration->findConfigurationElement(
"filename") )
98 std::string filename = m_configuration->findConfigurationElement(
"filename")->getExistingAttributeValue(
"id");
99 m_fsHelpPath = ::boost::filesystem::path( filename );
100 m_bServiceIsConfigured = ::boost::filesystem::exists(m_fsHelpPath);
101 OSLM_WARN_IF(
"Help file " <<filename<<
" doesn't exist", !m_bServiceIsConfigured);
111 SLM_ASSERT(
"The Help service isn't configured properly.", m_bServiceIsConfigured);
113 QDialog* dialog =
new QDialog(qApp->activeWindow());
114 dialog->setWindowTitle(QString(
"Help"));
115 QHelpEngine* helpEngine =
new QHelpEngine(QString::fromStdString(m_fsHelpPath.string()), dialog);
116 if (!helpEngine->setupData())
118 OSLM_ERROR(
"HelpEngine error: " << helpEngine->error().toStdString());
121 messageBox.setMessage(
"Help file is missing or not correct." );
122 messageBox.setIcon(::fwGui::dialog::IMessageDialog::WARNING);
123 messageBox.addButton(::fwGui::dialog::IMessageDialog::OK);
130 QSplitter* helpPanel =
new QSplitter(Qt::Horizontal);
132 helpPanel->insertWidget(0, helpEngine->contentWidget());
133 helpPanel->insertWidget(1, helpBrowser);
134 helpPanel->setStretchFactor(1, 1);
136 QHBoxLayout* hLayout =
new QHBoxLayout();
137 hLayout->addWidget(helpPanel);
138 dialog->setLayout( hLayout );
139 QObject::connect(helpEngine->contentWidget(), SIGNAL(linkActivated(
const QUrl &)), helpBrowser,
140 SLOT(setSource(
const QUrl &)));
void stopping() override
Stops action.
void configuring() override
Configuring method.
void updating() override
Show the frame.
FWGUI_API void actionServiceStarting()
Method called when the action service is starting.
The namespace uiGenericQt contains actions to show help, acknowledgments and about frame...
#define SLM_TRACE_FUNC()
Trace contextual function signature.
Defines the generic message box for IHM. Use the Delegate design pattern.
FWGUI_API void actionServiceStopping()
Method called when the action service is stopping.
#define OSLM_TRACE(message)
Defines the service interface managing the menu items.
This action show the help contents.
#define OSLM_ERROR(message)
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
FWGUI_API void initialize()
Initialize the action.
Base class for each data object.
UIGENERICQT_API void info(std::ostream &_sstream) override
Write information in a stream.
#define OSLM_WARN_IF(message, cond)
void starting() override
Starts action.
virtual FWGUI_API void setTitle(const std::string &title) override
Set the title of the message box.