summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/assistant/tools/assistant/globalactions.cpp83
-rw-r--r--tools/assistant/tools/assistant/globalactions.h14
-rw-r--r--tools/assistant/tools/assistant/helpenginewrapper.cpp2
-rw-r--r--tools/assistant/tools/assistant/searchwidget.cpp13
-rw-r--r--tools/assistant/tools/assistant/searchwidget.h4
5 files changed, 98 insertions, 18 deletions
diff --git a/tools/assistant/tools/assistant/globalactions.cpp b/tools/assistant/tools/assistant/globalactions.cpp
index a9cc392..0eeab21 100644
--- a/tools/assistant/tools/assistant/globalactions.cpp
+++ b/tools/assistant/tools/assistant/globalactions.cpp
@@ -42,9 +42,15 @@
#include "globalactions.h"
#include "centralwidget.h"
+#include "helpviewer.h"
#include "tracer.h"
#include <QtGui/QAction>
+#include <QtGui/QMenu>
+
+#if !defined(QT_NO_WEBKIT)
+#include <QtWebKit/QWebHistory>
+#endif
GlobalActions *GlobalActions::instance(QObject *parent)
{
@@ -82,6 +88,8 @@ GlobalActions::GlobalActions(QObject *parent) : QObject(parent)
connect(m_nextAction, SIGNAL(triggered()), centralWidget, SLOT(forward()));
m_actionList << m_nextAction;
+ setupNavigationMenus(m_backAction, m_nextAction, centralWidget);
+
m_homeAction = new QAction(tr("&Home"), parent);
m_homeAction->setShortcut(tr("ALT+Home"));
m_homeAction->setIcon(QIcon(resourcePath + QLatin1String("/home.png")));
@@ -160,4 +168,79 @@ void GlobalActions::setCopyAvailable(bool available)
m_copyAction->setEnabled(available);
}
+#if !defined(QT_NO_WEBKIT)
+
+void GlobalActions::slotAboutToShowBackMenu()
+{
+ TRACE_OBJ
+ m_backMenu->clear();
+ if (QWebHistory *history = CentralWidget::instance()->currentHelpViewer()->history()) {
+ const int currentItemIndex = history->currentItemIndex();
+ QList<QWebHistoryItem> items = history->backItems(history->count());
+ for (int i = items.count() - 1; i >= 0; --i) {
+ QAction *action = new QAction(this);
+ action->setText(items.at(i).title());
+ action->setData(-1 * (currentItemIndex - i));
+ m_backMenu->addAction(action);
+ }
+ }
+}
+
+void GlobalActions::slotAboutToShowNextMenu()
+{
+ TRACE_OBJ
+ m_nextMenu->clear();
+ if (QWebHistory *history = CentralWidget::instance()->currentHelpViewer()->history()) {
+ const int count = history->count();
+ QList<QWebHistoryItem> items = history->forwardItems(count);
+ for (int i = 0; i < items.count(); ++i) {
+ QAction *action = new QAction(this);
+ action->setData(count - i);
+ action->setText(items.at(i).title());
+ m_nextMenu->addAction(action);
+ }
+ }
+}
+
+void GlobalActions::slotOpenActionUrl(QAction *action)
+{
+ TRACE_OBJ
+ if (HelpViewer* viewer = CentralWidget::instance()->currentHelpViewer()) {
+ const int offset = action->data().toInt();
+ QWebHistory *history = viewer->history();
+ if (offset > 0) {
+ history->goToItem(history->forwardItems(history->count()
+ - offset + 1).back()); // forward
+ } else if (offset < 0) {
+ history->goToItem(history->backItems(-1 * offset).first()); // back
+ }
+ }
+}
+
+#endif
+
+void GlobalActions::setupNavigationMenus(QAction *back, QAction *next,
+ QWidget *parent)
+{
+#if !defined(QT_NO_WEBKIT)
+ m_backMenu = new QMenu(parent);
+ connect(m_backMenu, SIGNAL(aboutToShow()), this,
+ SLOT(slotAboutToShowBackMenu()));
+ connect(m_backMenu, SIGNAL(triggered(QAction*)), this,
+ SLOT(slotOpenActionUrl(QAction*)));
+ back->setMenu(m_backMenu);
+
+ m_nextMenu = new QMenu(parent);
+ connect(m_nextMenu, SIGNAL(aboutToShow()), this,
+ SLOT(slotAboutToShowNextMenu()));
+ connect(m_nextMenu, SIGNAL(triggered(QAction*)), this,
+ SLOT(slotOpenActionUrl(QAction*)));
+ next->setMenu(m_nextMenu);
+#else
+ Q_UNUSED(back)
+ Q_UNUSED(next)
+ Q_UNUSED(parent)
+#endif
+}
+
GlobalActions *GlobalActions::m_instance = 0;
diff --git a/tools/assistant/tools/assistant/globalactions.h b/tools/assistant/tools/assistant/globalactions.h
index e53e08f..ca8d7eb 100644
--- a/tools/assistant/tools/assistant/globalactions.h
+++ b/tools/assistant/tools/assistant/globalactions.h
@@ -48,6 +48,7 @@
QT_BEGIN_NAMESPACE
class QAction;
+class QMenu;
class GlobalActions : public QObject
{
@@ -69,6 +70,16 @@ public:
Q_SLOT void updateActions();
Q_SLOT void setCopyAvailable(bool available);
+#if !defined(QT_NO_WEBKIT)
+private slots:
+ void slotAboutToShowBackMenu();
+ void slotAboutToShowNextMenu();
+ void slotOpenActionUrl(QAction *action);
+#endif
+
+private:
+ void setupNavigationMenus(QAction *back, QAction *next, QWidget *parent);
+
private:
GlobalActions(QObject *parent);
@@ -84,6 +95,9 @@ private:
QAction *m_findAction;
QList<QAction *> m_actionList;
+
+ QMenu *m_backMenu;
+ QMenu *m_nextMenu;
};
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/helpenginewrapper.cpp b/tools/assistant/tools/assistant/helpenginewrapper.cpp
index fb67551..dc35b2d 100644
--- a/tools/assistant/tools/assistant/helpenginewrapper.cpp
+++ b/tools/assistant/tools/assistant/helpenginewrapper.cpp
@@ -148,7 +148,7 @@ HelpEngineWrapper::HelpEngineWrapper(const QString &collectionFile)
* because we will start to index them, only to be interupted
* by the next request. Also, there is a nasty SQLITE bug that will
* cause the application to hang for minutes in that case.
- * This call is reverted by initalDocSetupDone(), which must be
+ * This call is reverted by initialDocSetupDone(), which must be
* called after the new docs have been installed.
*/
disconnect(d->m_helpEngine, SIGNAL(setupFinished()),
diff --git a/tools/assistant/tools/assistant/searchwidget.cpp b/tools/assistant/tools/assistant/searchwidget.cpp
index 9eb2106..bb5bdeb 100644
--- a/tools/assistant/tools/assistant/searchwidget.cpp
+++ b/tools/assistant/tools/assistant/searchwidget.cpp
@@ -63,7 +63,6 @@ QT_BEGIN_NAMESPACE
SearchWidget::SearchWidget(QHelpSearchEngine *engine, QWidget *parent)
: QWidget(parent)
, zoomCount(0)
- , attached(false)
, searchEngine(engine)
{
TRACE_OBJ
@@ -130,18 +129,6 @@ void SearchWidget::resetZoom()
}
}
-bool SearchWidget::isAttached() const
-{
- TRACE_OBJ
- return attached;
-}
-
-void SearchWidget::setAttached(bool state)
-{
- TRACE_OBJ
- attached = state;
-}
-
void SearchWidget::search() const
{
TRACE_OBJ
diff --git a/tools/assistant/tools/assistant/searchwidget.h b/tools/assistant/tools/assistant/searchwidget.h
index 750497b..04d3e28 100644
--- a/tools/assistant/tools/assistant/searchwidget.h
+++ b/tools/assistant/tools/assistant/searchwidget.h
@@ -65,9 +65,6 @@ public:
void zoomOut();
void resetZoom();
- bool isAttached() const;
- void setAttached(bool state);
-
signals:
void requestShowLink(const QUrl &url);
void requestShowLinkInNewTab(const QUrl &url);
@@ -84,7 +81,6 @@ private:
private:
int zoomCount;
- bool attached;
QHelpSearchEngine *searchEngine;
QHelpSearchResultWidget *resultWidget;
};