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);
86 QHBoxLayout* buttonLayout =
new QHBoxLayout;
88 mVerticalLayout->addLayout(buttonLayout);
90 splitter->insertWidget(0, mTabWidget);
91 splitter->insertWidget(1, browser);
92 splitter->setStretchFactor(1, 1);
93 mVerticalLayout->addWidget(splitter);
95 this->addContentWidget(mTabWidget, buttonLayout);
96 this->addSearchWidget(mTabWidget, buttonLayout);
97 this->addIndexWidget(mTabWidget, buttonLayout);
99 this->addToggleTabWidgetButton(buttonLayout);
100 this->addWebNavigationButtons(buttonLayout);
101 this->addWebButton(buttonLayout);
102 buttonLayout->addStretch();
106 bool navVis =
settings()->
value(
"org.custusx.help/navigationVisible").toBool();
107 mTabWidget->setVisible(navVis);
117 return QSize(500,30);
121 void HelpWidget::addContentWidget(QTabWidget* tabWidget, QBoxLayout* buttonLayout)
123 QHelpContentWidget* contentWidget = mEngine->engine()->contentWidget();
124 tabWidget->addTab(contentWidget,
"contents");
126 boost::function<void()> f = boost::bind(&QHelpContentWidget::expandToDepth, contentWidget, 2);
127 connect(mEngine->engine()->contentModel(), &QHelpContentModel::contentsCreated, f);
128 contentWidget->expandToDepth(2);
130 connect(mEngine->engine()->contentWidget(), &QHelpContentWidget::linkActivated,
134 void HelpWidget::addWebNavigationButtons(QBoxLayout* buttonLayout)
137 QIcon(
":/icons/open_icon_library/arrow-left-3.png"),
138 "Back",
"Back to previous page",
143 QIcon(
":/icons/open_icon_library/arrow-right-3.png"),
144 "Forward",
"Forward to next page",
148 connect(mBrowser, SIGNAL(backwardAvailable(
bool)), back, SLOT(setEnabled(
bool)));
149 connect(mBrowser, SIGNAL(forwardAvailable(
bool)), forward, SLOT(setEnabled(
bool)));
152 void HelpWidget::addWebButton(QBoxLayout* buttonLayout)
154 this->createAction2(
this,
155 QIcon(
":/icons/open_icon_library/applications-internet.png"),
156 "Web",
"Open Web Documentation",
157 &HelpWidget::onGotoDocumentation,
161 void HelpWidget::onGotoDocumentation()
164 QDesktopServices::openUrl(QUrl(url, QUrl::TolerantMode));
167 void HelpWidget::backSlot()
169 mBrowser->backward();
172 void HelpWidget::forwardSlot()
177 void HelpWidget::addToggleTabWidgetButton(QBoxLayout* buttonLayout)
180 QIcon(
":/icons/open_icon_library/view-list-tree.png"),
181 "Toggle show navigation controls",
"",
182 SLOT(toggleShowNavigationControls()),
184 action->setCheckable(
true);
186 button->setDefaultAction(action);
187 buttonLayout->addWidget(button);
188 mShowNavigationControlsAction = action;
191 void HelpWidget::addIndexWidget(QTabWidget* tabWidget, QBoxLayout* buttonLayout)
194 tabWidget->addTab(mIndexWidget,
"index");
200 void HelpWidget::addSearchWidget(QTabWidget* tabWidget, QBoxLayout* buttonLayout)
203 tabWidget->addTab(mSearchWidget,
"search");
208 void HelpWidget::showEvent(QShowEvent* event)
210 QWidget::showEvent(event);
214 void HelpWidget::hideEvent(QHideEvent* event)
216 QWidget::hideEvent(event);
219 void HelpWidget::prePaintEvent()
224 void HelpWidget::toggleShowNavigationControls()
226 if (mTabWidget->isVisible())
232 QList<int> sizes = mSplitter->sizes();
235 sizes[0] = sizes[1]*1/3;
236 sizes[1] = sizes[1]*2/3;
237 mSplitter->setSizes(sizes);
241 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.