Commit edcefd69 authored by kh1's avatar kh1
Browse files

Implement tabless help mode, behaves now like edit mode.

parent a8801d15
This diff is collapsed.
...@@ -30,29 +30,19 @@ ...@@ -30,29 +30,19 @@
#ifndef CENTRALWIDGET_H #ifndef CENTRALWIDGET_H
#define CENTRALWIDGET_H #define CENTRALWIDGET_H
#include <QtCore/QUrl> #include <find/ifindsupport.h>
#include <QtCore/QPoint>
#include <QtCore/QObject>
#include <QtGui/QWidget> #include <QtGui/QWidget>
#include <QtGui/QTextDocument>
QT_BEGIN_NAMESPACE QT_FORWARD_DECLARE_CLASS(QEvent)
QT_FORWARD_DECLARE_CLASS(QAction)
QT_FORWARD_DECLARE_CLASS(QStackedWidget)
QT_FORWARD_DECLARE_CLASS(QFocusEvent)
class QEvent; namespace Help {
class QLabel; namespace Internal {
class QAction;
class QCheckBox;
class QLineEdit;
class QToolButton;
class QTabWidget;
class QFocusEvent;
QT_END_NAMESPACE
class HelpViewer; class HelpViewer;
namespace Help {
namespace Internal {
class PrintHelper; class PrintHelper;
class CentralWidget : public QWidget class CentralWidget : public QWidget
...@@ -63,82 +53,71 @@ public: ...@@ -63,82 +53,71 @@ public:
CentralWidget(QWidget *parent = 0); CentralWidget(QWidget *parent = 0);
~CentralWidget(); ~CentralWidget();
static CentralWidget *instance();
bool hasSelection() const; bool hasSelection() const;
QUrl currentSource() const;
QString currentTitle() const;
bool isForwardAvailable() const; bool isForwardAvailable() const;
bool isBackwardAvailable() const; bool isBackwardAvailable() const;
QList<QAction*> globalActions() const;
void setGlobalActions(const QList<QAction*> &actions); HelpViewer *viewerAt(int index) const;
HelpViewer *currentHelpViewer() const; HelpViewer *currentHelpViewer() const;
void activateTab(bool onlyHelpViewer = false);
bool find(const QString &txt, QTextDocument::FindFlags findFlags, bool incremental);
void setLastShownPages();
HelpViewer *helpViewerAtIndex(int index) const;
int indexOf(HelpViewer *viewer) const;
static CentralWidget *instance(); void addPage(HelpViewer *page, bool fromSearch = false);
void removePage(int index);
int currentIndex() const;
void setCurrentPage(HelpViewer *page);
bool find(const QString &txt, Find::IFindSupport::FindFlags findFlags,
bool incremental);
public slots: public slots:
void copy();
void home();
void zoomIn(); void zoomIn();
void zoomOut(); void zoomOut();
void nextPage();
void resetZoom(); void resetZoom();
void forward();
void nextPage();
void backward();
void previousPage(); void previousPage();
void print(); void print();
void pageSetup(); void pageSetup();
void printPreview(); void printPreview();
void setSource(const QUrl &url); void setSource(const QUrl &url);
void setSourceInNewTab(const QUrl &url, int zoom = 0); void setSourceFromSearch(const QUrl &url);
HelpViewer *newEmptyTab(); void showTopicChooser(const QMap<QString, QUrl> &links, const QString &key);
void home();
void forward();
void backward();
void showTopicChooser(const QMap<QString, QUrl> &links,
const QString &keyword);
void copy();
void activateTab(int index);
protected: protected:
void focusInEvent(QFocusEvent *event); void focusInEvent(QFocusEvent *event);
signals: signals:
void currentViewerChanged(int index); void currentViewerChanged();
void copyAvailable(bool yes);
void sourceChanged(const QUrl &url); void sourceChanged(const QUrl &url);
void highlighted(const QString &link);
void forwardAvailable(bool available); void forwardAvailable(bool available);
void backwardAvailable(bool available); void backwardAvailable(bool available);
void addNewBookmark(const QString &title, const QString &url);
void viewerAboutToBeRemoved(int index);
void viewerRemoved(int index);
private slots: private slots:
void newTab(); void highlightSearchTerms();
void closeTab();
void closeTab(int index);
void setTabTitle(const QUrl& url);
void currentPageChanged(int index);
void showTabBarContextMenu(const QPoint &point);
void printPreview(QPrinter *printer); void printPreview(QPrinter *printer);
void handleSourceChanged(const QUrl &url);
private: private:
void connectSignals();
bool eventFilter(QObject *object, QEvent *e);
void initPrinter(); void initPrinter();
QString quoteTabTitle(const QString &title) const; void connectSignals(HelpViewer *page);
bool eventFilter(QObject *object, QEvent *e);
private: private:
int lastTabPage;
QList<QAction*> globalActionList;
QWidget *findBar;
QTabWidget* tabWidget;
QPrinter *printer; QPrinter *printer;
QStackedWidget *m_stackedWidget;
}; };
} // namespace Internal } // namespace Internal
} // namespace Help } // namespace Help
#endif // CENTRALWIDGET_H #endif // CENTRALWIDGET_H
...@@ -41,25 +41,23 @@ ...@@ -41,25 +41,23 @@
#include <QtCore/QCoreApplication> #include <QtCore/QCoreApplication>
#include <QtCore/QTextStream> #include <QtCore/QTextStream>
#if defined(QT_NO_WEBKIT)
#include <QtGui/QApplication> #include <QtGui/QApplication>
#else
#include <QtWebKit/QWebSettings>
#endif
#include <QtGui/QFileDialog> #include <QtGui/QFileDialog>
#include <QtHelp/QHelpEngineCore> #include <QtHelp/QHelpEngineCore>
#if !defined(QT_NO_WEBKIT)
#include <QtWebKit/QWebSettings>
#endif
using namespace Help::Internal; using namespace Help::Internal;
GeneralSettingsPage::GeneralSettingsPage() GeneralSettingsPage::GeneralSettingsPage()
{ {
m_font = qApp->font();
#if !defined(QT_NO_WEBKIT) #if !defined(QT_NO_WEBKIT)
QWebSettings* webSettings = QWebSettings::globalSettings(); QWebSettings* webSettings = QWebSettings::globalSettings();
m_font.setFamily(webSettings->fontFamily(QWebSettings::StandardFont));
m_font.setPointSize(webSettings->fontSize(QWebSettings::DefaultFontSize)); m_font.setPointSize(webSettings->fontSize(QWebSettings::DefaultFontSize));
#else
m_font = qApp->font();
#endif #endif
} }
...@@ -168,13 +166,8 @@ void GeneralSettingsPage::apply() ...@@ -168,13 +166,8 @@ void GeneralSettingsPage::apply()
QHelpEngineCore *engine = &HelpManager::helpEngineCore(); QHelpEngineCore *engine = &HelpManager::helpEngineCore();
engine->setCustomValue(QLatin1String("font"), newFont); engine->setCustomValue(QLatin1String("font"), newFont);
#if !defined(QT_NO_WEBKIT) if (newFont != m_font)
QWebSettings* webSettings = QWebSettings::globalSettings(); emit fontChanged();
webSettings->setFontFamily(QWebSettings::StandardFont, m_font.family());
webSettings->setFontSize(QWebSettings::DefaultFontSize, m_font.pointSize());
#else
emit fontChanged();
#endif
QString homePage = m_ui.homePageLineEdit->text(); QString homePage = m_ui.homePageLineEdit->text();
if (homePage.isEmpty()) if (homePage.isEmpty())
......
...@@ -6,33 +6,46 @@ include(../../qtcreatorplugin.pri) ...@@ -6,33 +6,46 @@ include(../../qtcreatorplugin.pri)
include(help_dependencies.pri) include(help_dependencies.pri)
CONFIG += help CONFIG += help
DEFINES += QT_CLUCENE_SUPPORT \ DEFINES += QT_CLUCENE_SUPPORT HELP_LIBRARY
HELP_LIBRARY
HEADERS += helpplugin.h \ HEADERS += \
centralwidget.h \
docsettingspage.h \ docsettingspage.h \
filtersettingspage.h \ filtersettingspage.h \
generalsettingspage.h \
help_global.h \
helpconstants.h \ helpconstants.h \
helpmode.h \
centralwidget.h \
searchwidget.h \
helpfindsupport.h \ helpfindsupport.h \
help_global.h \
helpindexfilter.h \ helpindexfilter.h \
generalsettingspage.h \ helpmanager.h \
xbelsupport.h \ helpmode.h \
helpmanager.h helpplugin.h \
helpviewer.h \
helpviewer_p.h \
openpagesmanager.h \
openpagesmodel.h \
openpageswidget.h \
searchwidget.h \
xbelsupport.h
SOURCES += helpplugin.cpp \ SOURCES += \
centralwidget.cpp \
docsettingspage.cpp \ docsettingspage.cpp \
filtersettingspage.cpp \ filtersettingspage.cpp \
helpmode.cpp \ generalsettingspage.cpp \
centralwidget.cpp \
searchwidget.cpp \
helpfindsupport.cpp \ helpfindsupport.cpp \
helpindexfilter.cpp \ helpindexfilter.cpp \
generalsettingspage.cpp \ helpmanager.cpp \
xbelsupport.cpp \ helpmode.cpp \
helpmanager.cpp helpplugin.cpp \
helpviewer.cpp \
helpviewer_qtb.cpp \
helpviewer_qwv.cpp \
openpagesmanager.cpp \
openpagesmodel.cpp \
openpageswidget.cpp \
searchwidget.cpp \
xbelsupport.cpp
FORMS += docsettingspage.ui \ FORMS += docsettingspage.ui \
filtersettingspage.ui \ filtersettingspage.ui \
......
...@@ -51,7 +51,7 @@ bool HelpFindSupport::isEnabled() const ...@@ -51,7 +51,7 @@ bool HelpFindSupport::isEnabled() const
Find::IFindSupport::FindFlags HelpFindSupport::supportedFindFlags() const Find::IFindSupport::FindFlags HelpFindSupport::supportedFindFlags() const
{ {
return Find::IFindSupport::FindBackward | Find::IFindSupport::FindCaseSensitively return Find::IFindSupport::FindBackward | Find::IFindSupport::FindCaseSensitively
| Find::IFindSupport::FindWholeWords; | Find::IFindSupport::FindWholeWords;
} }
QString HelpFindSupport::currentFindString() const QString HelpFindSupport::currentFindString() const
...@@ -60,11 +60,7 @@ QString HelpFindSupport::currentFindString() const ...@@ -60,11 +60,7 @@ QString HelpFindSupport::currentFindString() const
HelpViewer *viewer = m_centralWidget->currentHelpViewer(); HelpViewer *viewer = m_centralWidget->currentHelpViewer();
if (!viewer) if (!viewer)
return QString(); return QString();
#if !defined(QT_NO_WEBKIT)
return viewer->selectedText(); return viewer->selectedText();
#else
return viewer->textCursor().selectedText();
#endif
} }
QString HelpFindSupport::completedFindString() const QString HelpFindSupport::completedFindString() const
...@@ -72,95 +68,58 @@ QString HelpFindSupport::completedFindString() const ...@@ -72,95 +68,58 @@ QString HelpFindSupport::completedFindString() const
return QString(); return QString();
} }
Find::IFindSupport::Result HelpFindSupport::findIncremental(const QString &txt, Find::IFindSupport::FindFlags findFlags) Find::IFindSupport::Result HelpFindSupport::findIncremental(const QString &txt,
Find::IFindSupport::FindFlags findFlags)
{ {
QTC_ASSERT(m_centralWidget, return NotFound); QTC_ASSERT(m_centralWidget, return NotFound);
findFlags &= ~Find::IFindSupport::FindBackward; findFlags &= ~Find::IFindSupport::FindBackward;
return m_centralWidget->find(txt, Find::IFindSupport::textDocumentFlagsForFindFlags(findFlags), true) return m_centralWidget->find(txt, findFlags, true) ? Found : NotFound;
? Found : NotFound;
} }
Find::IFindSupport::Result HelpFindSupport::findStep(const QString &txt, Find::IFindSupport::FindFlags findFlags) Find::IFindSupport::Result HelpFindSupport::findStep(const QString &txt,
Find::IFindSupport::FindFlags findFlags)
{ {
QTC_ASSERT(m_centralWidget, return NotFound); QTC_ASSERT(m_centralWidget, return NotFound);
return m_centralWidget->find(txt, Find::IFindSupport::textDocumentFlagsForFindFlags(findFlags), false) return m_centralWidget->find(txt, findFlags, false) ? Found : NotFound;
? Found : NotFound;
} }
// -- HelpViewerFindSupport
HelpViewerFindSupport::HelpViewerFindSupport(HelpViewer *viewer) HelpViewerFindSupport::HelpViewerFindSupport(HelpViewer *viewer)
: m_viewer(viewer) : m_viewer(viewer)
{ {
} }
Find::IFindSupport::FindFlags HelpViewerFindSupport::supportedFindFlags() const Find::IFindSupport::FindFlags HelpViewerFindSupport::supportedFindFlags() const
{ {
return Find::IFindSupport::FindBackward | Find::IFindSupport::FindCaseSensitively return Find::IFindSupport::FindBackward | Find::IFindSupport::FindCaseSensitively
| Find::IFindSupport::FindWholeWords; | Find::IFindSupport::FindWholeWords;
} }
QString HelpViewerFindSupport::currentFindString() const QString HelpViewerFindSupport::currentFindString() const
{ {
QTC_ASSERT(m_viewer, return QString()); QTC_ASSERT(m_viewer, return QString());
#if !defined(QT_NO_WEBKIT)
return m_viewer->selectedText(); return m_viewer->selectedText();
#else
return QString();
#endif
} }
Find::IFindSupport::Result HelpViewerFindSupport::findIncremental(const QString &txt, Find::IFindSupport::FindFlags findFlags) Find::IFindSupport::Result HelpViewerFindSupport::findIncremental(const QString &txt,
Find::IFindSupport::FindFlags findFlags)
{ {
QTC_ASSERT(m_viewer, return NotFound); QTC_ASSERT(m_viewer, return NotFound);
findFlags &= ~Find::IFindSupport::FindBackward; findFlags &= ~Find::IFindSupport::FindBackward;
return find(txt, findFlags, true) ? Found : NotFound; return find(txt, findFlags, true) ? Found : NotFound;
} }
Find::IFindSupport::Result HelpViewerFindSupport::findStep(const QString &txt, Find::IFindSupport::FindFlags findFlags) Find::IFindSupport::Result HelpViewerFindSupport::findStep(const QString &txt,
Find::IFindSupport::FindFlags findFlags)
{ {
QTC_ASSERT(m_viewer, return NotFound); QTC_ASSERT(m_viewer, return NotFound);
return find(txt, findFlags, false) ? Found : NotFound; return find(txt, findFlags, false) ? Found : NotFound;
} }
bool HelpViewerFindSupport::find(const QString &txt, Find::IFindSupport::FindFlags findFlags, bool incremental) bool HelpViewerFindSupport::find(const QString &txt,
Find::IFindSupport::FindFlags findFlags, bool incremental)
{ {
QTC_ASSERT(m_viewer, return false); QTC_ASSERT(m_viewer, return false);
#if !defined(QT_NO_WEBKIT) return m_viewer->findText(txt, findFlags, incremental, false);
Q_UNUSED(incremental)
QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument;
if (findFlags & Find::IFindSupport::FindBackward)
options |= QWebPage::FindBackward;
if (findFlags & Find::IFindSupport::FindCaseSensitively)
options |= QWebPage::FindCaseSensitively;
bool found = m_viewer->findText(txt, options);
options = QWebPage::HighlightAllOccurrences;
m_viewer->findText(QLatin1String(""), options); // clear first
m_viewer->findText(txt, options); // force highlighting of all other matches
return found;
#else
QTextCursor cursor = m_viewer->textCursor();
QTextDocument *doc = m_viewer->document();
QTextBrowser *browser = qobject_cast<QTextBrowser*>(m_viewer);
if (!browser || !doc || cursor.isNull())
return false;
if (incremental)
cursor.setPosition(cursor.selectionStart());
QTextCursor found = doc->find(txt, cursor, Find::IFindSupport::textDocumentFlagsForFindFlags(findFlags));
if (found.isNull()) {
if ((findFlags&Find::IFindSupport::FindBackward) == 0)
cursor.movePosition(QTextCursor::Start);
else
cursor.movePosition(QTextCursor::End);
found = doc->find(txt, cursor, Find::IFindSupport::textDocumentFlagsForFindFlags(findFlags));
if (found.isNull()) {
return false;
}
}
if (!found.isNull()) {
m_viewer->setTextCursor(found);
}
return true;
#endif
} }
...@@ -34,12 +34,11 @@ ...@@ -34,12 +34,11 @@
#include <find/ifindsupport.h> #include <find/ifindsupport.h>
class HelpViewer;
namespace Help { namespace Help {
namespace Internal { namespace Internal {
class HelpViewer;
class HelpFindSupport : public Find::IFindSupport class HelpFindSupport : public Find::IFindSupport
{ {
Q_OBJECT Q_OBJECT
......
This diff is collapsed.
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
** contact the sales department at http://qt.nokia.com/contact. ** contact the sales department at http://qt.nokia.com/contact.
** **
**************************************************************************/ **************************************************************************/
#ifndef HELPPLUGIN_H #ifndef HELPPLUGIN_H
#define HELPPLUGIN_H #define HELPPLUGIN_H
...@@ -33,14 +34,11 @@ ...@@ -33,14 +34,11 @@
#include <QtCore/QMap> #include <QtCore/QMap>
#include <QtCore/QStringList> #include <QtCore/QStringList>
QT_BEGIN_NAMESPACE QT_FORWARD_DECLARE_CLASS(QAction)
class QAction; QT_FORWARD_DECLARE_CLASS(QComboBox)
class QComboBox; QT_FORWARD_DECLARE_CLASS(QToolBar)
class QToolBar; QT_FORWARD_DECLARE_CLASS(QToolButton)
class QUrl; QT_FORWARD_DECLARE_CLASS(QUrl)
QT_END_NAMESPACE
class HelpViewer;
namespace Core { namespace Core {
class ICore; class ICore;
...@@ -57,8 +55,10 @@ namespace Internal { ...@@ -57,8 +55,10 @@ namespace Internal {
class CentralWidget; class CentralWidget;
class DocSettingsPage; class DocSettingsPage;
class FilterSettingsPage; class FilterSettingsPage;
class HelpMode;
class GeneralSettingsPage; class GeneralSettingsPage;
class HelpMode;
class HelpViewer;
class OpenPagesManager;
class SearchWidget; class SearchWidget;
class HelpPlugin : public ExtensionSystem::IPlugin class HelpPlugin : public ExtensionSystem::IPlugin
...@@ -78,14 +78,16 @@ public slots: ...@@ -78,14 +78,16 @@ public slots:
private slots: private slots:
void modeChanged(Core::IMode *mode); void modeChanged(Core::IMode *mode);
void activateContext(); void activateContext();
void activateIndex(); void activateIndex();
void activateContents(); void activateContents();
void activateSearch(); void activateSearch();
void activateOpenPages();
void addBookmark();
void updateFilterComboBox(); void updateFilterComboBox();
void filterDocumentation(const QString &customFilter); void filterDocumentation(const QString &customFilter);
void addBookmark();
void addNewBookmark(const QString &title, const QString &url);