14 #include "boost/bind.hpp" 15 #include "boost/function.hpp" 16 #include <QHelpEngine> 18 #include <QHelpContentWidget> 19 #include <QHelpIndexWidget> 30 #include <QDesktopServices> 37 mVerticalLayout(NULL),
43 void HelpWidget::setup()
49 mVerticalLayout =
new QVBoxLayout(
this);
50 mVerticalLayout->setMargin(0);
51 mVerticalLayout->setSpacing(0);
52 this->setLayout(mVerticalLayout);
53 mTabWidget =
new QTabWidget(
this);
54 mTabWidget->setElideMode(Qt::ElideRight);
56 QSplitter *splitter =
new QSplitter(Qt::Horizontal);
65 QHBoxLayout* buttonLayout =
new QHBoxLayout;
67 mVerticalLayout->addLayout(buttonLayout);
69 splitter->insertWidget(0, mTabWidget);
70 splitter->insertWidget(1, browser);
71 splitter->setStretchFactor(1, 1);
72 mVerticalLayout->addWidget(splitter);
74 this->addContentWidget(mTabWidget, buttonLayout);
75 this->addSearchWidget(mTabWidget, buttonLayout);
76 this->addIndexWidget(mTabWidget, buttonLayout);
78 this->addToggleTabWidgetButton(buttonLayout);
79 this->addWebNavigationButtons(buttonLayout);
80 this->addWebButton(buttonLayout);
81 buttonLayout->addStretch();
85 bool navVis =
settings()->
value(
"org.custusx.help/navigationVisible").toBool();
86 mTabWidget->setVisible(navVis);
100 void HelpWidget::addContentWidget(QTabWidget* tabWidget, QBoxLayout* buttonLayout)
102 QHelpContentWidget* contentWidget = mEngine->engine()->contentWidget();
103 tabWidget->addTab(contentWidget,
"contents");
105 boost::function<void()> f = boost::bind(&QHelpContentWidget::expandToDepth, contentWidget, 2);
106 connect(mEngine->engine()->contentModel(), &QHelpContentModel::contentsCreated, f);
107 contentWidget->expandToDepth(2);
109 connect(mEngine->engine()->contentWidget(), &QHelpContentWidget::linkActivated,
113 void HelpWidget::addWebNavigationButtons(QBoxLayout* buttonLayout)
116 QIcon(
":/icons/open_icon_library/arrow-left-3.png"),
117 "Back",
"Back to previous page",
122 QIcon(
":/icons/open_icon_library/arrow-right-3.png"),
123 "Forward",
"Forward to next page",
127 connect(mBrowser, SIGNAL(backwardAvailable(
bool)), back, SLOT(setEnabled(
bool)));
128 connect(mBrowser, SIGNAL(forwardAvailable(
bool)), forward, SLOT(setEnabled(
bool)));
131 void HelpWidget::addWebButton(QBoxLayout* buttonLayout)
133 this->createAction2(
this,
134 QIcon(
":/icons/open_icon_library/applications-internet.png"),
135 "Web",
"Open Web Documentation",
136 &HelpWidget::onGotoDocumentation,
140 void HelpWidget::onGotoDocumentation()
143 QDesktopServices::openUrl(QUrl(url, QUrl::TolerantMode));
146 void HelpWidget::backSlot()
148 mBrowser->backward();
151 void HelpWidget::forwardSlot()
156 void HelpWidget::addToggleTabWidgetButton(QBoxLayout* buttonLayout)
159 QIcon(
":/icons/open_icon_library/view-list-tree.png"),
160 "Toggle show navigation controls",
"",
161 SLOT(toggleShowNavigationControls()),
163 action->setCheckable(
true);
165 button->setDefaultAction(action);
166 buttonLayout->addWidget(button);
167 mShowNavigationControlsAction = action;
170 void HelpWidget::addIndexWidget(QTabWidget* tabWidget, QBoxLayout* buttonLayout)
173 tabWidget->addTab(mIndexWidget,
"index");
179 void HelpWidget::addSearchWidget(QTabWidget* tabWidget, QBoxLayout* buttonLayout)
182 tabWidget->addTab(mSearchWidget,
"search");
187 void HelpWidget::showEvent(QShowEvent* event)
189 QWidget::showEvent(event);
193 void HelpWidget::hideEvent(QHideEvent* event)
195 QWidget::hideEvent(event);
198 void HelpWidget::prePaintEvent()
203 void HelpWidget::toggleShowNavigationControls()
205 if (mTabWidget->isVisible())
211 QList<int> sizes = mSplitter->sizes();
214 sizes[0] = sizes[1]*1/3;
215 sizes[1] = sizes[1]*2/3;
216 mSplitter->setSizes(sizes);
220 settings()->
setValue(
"org.custusx.help/navigationVisible", mTabWidget->isVisible());
void listenToEngineKeywordActivated()
static QString getWebsiteUserDocumentationURL()
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
void setValue(const QString &key, const QVariant &value)
void showHelpForKeyword(const QString &id)
Settings * settings()
Shortcut for accessing the settings instance.
virtual void setSource(const QUrl &name)
boost::shared_ptr< HelpEngine > HelpEnginePtr
Namespace for all CustusX production code.