35 #include "boost/bind.hpp"
36 #include "boost/function.hpp"
37 #include <QHelpEngine>
39 #include <QHelpContentWidget>
40 #include <QHelpIndexWidget>
51 #include <QDesktopServices>
58 mVerticalLayout(NULL),
64 void HelpWidget::setup()
70 mVerticalLayout =
new QVBoxLayout(
this);
71 mVerticalLayout->setMargin(0);
72 mVerticalLayout->setSpacing(0);
73 this->setLayout(mVerticalLayout);
74 mTabWidget =
new QTabWidget(
this);
75 mTabWidget->setElideMode(Qt::ElideRight);
77 QSplitter *splitter =
new QSplitter(Qt::Horizontal);
85 QHBoxLayout* buttonLayout =
new QHBoxLayout;
87 mVerticalLayout->addLayout(buttonLayout);
89 splitter->insertWidget(0, mTabWidget);
90 splitter->insertWidget(1, browser);
91 splitter->setStretchFactor(1, 1);
92 mVerticalLayout->addWidget(splitter);
94 this->addContentWidget(mTabWidget, buttonLayout);
95 this->addSearchWidget(mTabWidget, buttonLayout);
96 this->addIndexWidget(mTabWidget, buttonLayout);
98 this->addToggleTabWidgetButton(buttonLayout);
99 this->addWebNavigationButtons(buttonLayout);
100 this->addWebButton(buttonLayout);
101 buttonLayout->addStretch();
105 bool navVis =
settings()->
value(
"org.custusx.help/navigationVisible").toBool();
106 mTabWidget->setVisible(navVis);
115 return QSize(250,30);
119 void HelpWidget::addContentWidget(QTabWidget* tabWidget, QBoxLayout* buttonLayout)
121 QHelpContentWidget* contentWidget = mEngine->engine()->contentWidget();
122 tabWidget->addTab(contentWidget,
"contents");
124 boost::function<void()> f = boost::bind(&QHelpContentWidget::expandToDepth, contentWidget, 2);
125 connect(mEngine->engine()->contentModel(), &QHelpContentModel::contentsCreated, f);
126 contentWidget->expandToDepth(2);
128 connect(mEngine->engine()->contentWidget(), &QHelpContentWidget::linkActivated,
132 void HelpWidget::addWebNavigationButtons(QBoxLayout* buttonLayout)
135 QIcon(
":/icons/open_icon_library/arrow-left-3.png"),
136 "Back",
"Back to previous page",
141 QIcon(
":/icons/open_icon_library/arrow-right-3.png"),
142 "Forward",
"Forward to next page",
146 connect(mBrowser, SIGNAL(backwardAvailable(
bool)), back, SLOT(setEnabled(
bool)));
147 connect(mBrowser, SIGNAL(forwardAvailable(
bool)), forward, SLOT(setEnabled(
bool)));
150 void HelpWidget::addWebButton(QBoxLayout* buttonLayout)
152 this->createAction2(
this,
153 QIcon(
":/icons/open_icon_library/applications-internet.png"),
154 "Web",
"Open Web Documentation",
155 &HelpWidget::onGotoDocumentation,
159 void HelpWidget::onGotoDocumentation()
162 QDesktopServices::openUrl(QUrl(url, QUrl::TolerantMode));
165 void HelpWidget::backSlot()
167 mBrowser->backward();
170 void HelpWidget::forwardSlot()
175 void HelpWidget::addToggleTabWidgetButton(QBoxLayout* buttonLayout)
178 QIcon(
":/icons/open_icon_library/view-list-tree.png"),
179 "Toggle show navigation controls",
"",
180 SLOT(toggleShowNavigationControls()),
182 action->setCheckable(
true);
184 button->setDefaultAction(action);
185 buttonLayout->addWidget(button);
186 mShowNavigationControlsAction = action;
189 void HelpWidget::addIndexWidget(QTabWidget* tabWidget, QBoxLayout* buttonLayout)
191 mIndexWidget =
new HelpIndexWidget(mEngine,
this);
192 tabWidget->addTab(mIndexWidget,
"index");
198 void HelpWidget::addSearchWidget(QTabWidget* tabWidget, QBoxLayout* buttonLayout)
200 mSearchWidget =
new HelpSearchWidget(mEngine,
this);
201 tabWidget->addTab(mSearchWidget,
"search");
206 void HelpWidget::showEvent(QShowEvent* event)
208 QWidget::showEvent(event);
212 void HelpWidget::hideEvent(QHideEvent* event)
214 QWidget::hideEvent(event);
217 void HelpWidget::prePaintEvent()
222 void HelpWidget::toggleShowNavigationControls()
224 if (mTabWidget->isVisible())
230 QList<int> sizes = mSplitter->sizes();
233 sizes[0] = sizes[1]*1/3;
234 sizes[1] = sizes[1]*2/3;
235 mSplitter->setSizes(sizes);
239 settings()->
setValue(
"org.custusx.help/navigationVisible", mTabWidget->isVisible());
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