summaryrefslogtreecommitdiffstats
path: root/tools/assistant
diff options
context:
space:
mode:
authorck <qt-info@nokia.com>2010-03-10 15:49:03 (GMT)
committerck <qt-info@nokia.com>2010-04-12 09:09:11 (GMT)
commitb0773d144e1cd31f49be5f70c357d6be030a2e8f (patch)
tree7dbafd80a41abb45d39baa28a92fcbbac1bf268b /tools/assistant
parentaeaa61a4b8ad7339bd5d1a32374c05253ce971da (diff)
downloadQt-b0773d144e1cd31f49be5f70c357d6be030a2e8f.zip
Qt-b0773d144e1cd31f49be5f70c357d6be030a2e8f.tar.gz
Qt-b0773d144e1cd31f49be5f70c357d6be030a2e8f.tar.bz2
Assistant: Move search widget into the dock area.
Task-number: QTBUG-2048 Reviewed-by: kh1
Diffstat (limited to 'tools/assistant')
-rw-r--r--tools/assistant/tools/assistant/centralwidget.cpp276
-rw-r--r--tools/assistant/tools/assistant/centralwidget.h16
-rw-r--r--tools/assistant/tools/assistant/helpenginewrapper.cpp12
-rw-r--r--tools/assistant/tools/assistant/helpenginewrapper.h3
-rw-r--r--tools/assistant/tools/assistant/mainwindow.cpp80
-rw-r--r--tools/assistant/tools/assistant/mainwindow.h11
6 files changed, 107 insertions, 291 deletions
diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp
index f56e9e3..e562198 100644
--- a/tools/assistant/tools/assistant/centralwidget.cpp
+++ b/tools/assistant/tools/assistant/centralwidget.cpp
@@ -92,7 +92,6 @@ CentralWidget::CentralWidget(MainWindow *parent)
, findWidget(0)
, printer(0)
, usesDefaultCollection(parent->usesDefaultCollection())
- , m_searchWidget(0)
{
TRACE_OBJ
globalActionList.clear();
@@ -168,10 +167,7 @@ CentralWidget::~CentralWidget()
QStringList zoomFactors;
QStringList currentPages;
- bool searchAttached = m_searchWidget->isAttached();
-
- int i = searchAttached ? 1 : 0;
- for (; i < tabWidget->count(); ++i) {
+ for (int i = 0; i < tabWidget->count(); ++i) {
HelpViewer *viewer = qobject_cast<HelpViewer*>(tabWidget->widget(i));
if (viewer && viewer->source().isValid()) {
currentPages << viewer->source().toString();
@@ -182,7 +178,6 @@ CentralWidget::~CentralWidget()
HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance();
helpEngine.setLastTabPage(tabWidget->currentIndex());
helpEngine.setLastShownPages(currentPages);
- helpEngine.setSearchWasAttached(searchAttached);
helpEngine.setLastZoomFactors(zoomFactors);
}
@@ -197,9 +192,7 @@ void CentralWidget::newTab()
TRACE_OBJ
HelpViewer *viewer = currentHelpViewer();
#if !defined(QT_NO_WEBKIT)
- if (viewer && viewer->hasLoadFinished())
-#else
- if (viewer)
+ if (viewer->hasLoadFinished())
#endif
setSourceInNewTab(viewer->source());
}
@@ -207,23 +200,13 @@ void CentralWidget::newTab()
void CentralWidget::zoomIn()
{
TRACE_OBJ
- HelpViewer *viewer = currentHelpViewer();
- if (viewer)
- viewer->scaleUp();
-
- if (tabWidget->currentWidget() == m_searchWidget)
- m_searchWidget->zoomIn();
+ currentHelpViewer()->scaleUp();
}
void CentralWidget::zoomOut()
{
TRACE_OBJ
- HelpViewer *viewer = currentHelpViewer();
- if (viewer)
- viewer->scaleDown();
-
- if (tabWidget->currentWidget() == m_searchWidget)
- m_searchWidget->zoomOut();
+ currentHelpViewer()->scaleDown();
}
void CentralWidget::nextPage()
@@ -238,11 +221,7 @@ void CentralWidget::nextPage()
void CentralWidget::resetZoom()
{
TRACE_OBJ
- if (HelpViewer *viewer = currentHelpViewer())
- viewer->resetScale();
-
- if (tabWidget->currentWidget() == m_searchWidget)
- m_searchWidget->resetZoom();
+ currentHelpViewer()->resetScale();
}
void CentralWidget::previousPage()
@@ -257,10 +236,10 @@ void CentralWidget::previousPage()
void CentralWidget::closeTab()
{
TRACE_OBJ
- HelpViewer *viewer = currentHelpViewer();
- if (!viewer|| tabWidget->count() == 1)
+ if (tabWidget->count() == 1)
return;
+ HelpViewer *viewer = currentHelpViewer();
tabWidget->removeTab(tabWidget->indexOf(viewer));
QTimer::singleShot(0, viewer, SLOT(deleteLater()));
}
@@ -323,20 +302,13 @@ void CentralWidget::setLastShownPages()
while (zoomFactors.count() < pageCount)
zoomFactors.append(CollectionConfiguration::DefaultZoomFactor);
- const bool searchIsAttached = m_searchWidget->isAttached();
- const bool searchWasAttached = helpEngine.searchWasAttached();
int tabToShow = helpEngine.lastTabPage();
- if (searchWasAttached && !searchIsAttached && tabToShow != 0)
- --tabToShow;
- else if (!searchWasAttached && searchIsAttached)
- ++tabToShow;
-
for (int curTab = 0; curTab < pageCount; ++curTab) {
const QString &curFile = lastShownPageList.at(curTab);
if (helpEngine.findFile(curFile).isValid()
|| curFile == QLatin1String("about:blank")) {
setSourceInNewTab(curFile, zoomFactors.at(curTab).toFloat());
- } else if (curTab + searchIsAttached <= tabToShow)
+ } else if (curTab <= tabToShow)
--tabToShow;
}
@@ -346,36 +318,25 @@ void CentralWidget::setLastShownPages()
bool CentralWidget::hasSelection() const
{
TRACE_OBJ
- const HelpViewer *viewer = currentHelpViewer();
- return viewer ? viewer->hasSelection() : false;
+ return currentHelpViewer()->hasSelection();
}
QUrl CentralWidget::currentSource() const
{
TRACE_OBJ
- const HelpViewer *viewer = currentHelpViewer();
- if (viewer)
- return viewer->source();
-
- return QUrl();
+ return currentHelpViewer()->source();
}
QString CentralWidget::currentTitle() const
{
TRACE_OBJ
- const HelpViewer *viewer = currentHelpViewer();
- if (viewer)
- return viewer->documentTitle();
-
- return QString();
+ return currentHelpViewer()->documentTitle();
}
void CentralWidget::copySelection()
{
TRACE_OBJ
- HelpViewer *viewer = currentHelpViewer();
- if (viewer)
- viewer->copy();
+ currentHelpViewer()->copy();
}
void CentralWidget::showTextSearch()
@@ -398,11 +359,7 @@ void CentralWidget::print()
TRACE_OBJ
#ifndef QT_NO_PRINTER
HelpViewer *viewer = currentHelpViewer();
- if (!viewer)
- return;
-
initPrinter();
-
QPrintDialog dlg(printer, this);
#if defined(QT_NO_WEBKIT)
if (viewer->textCursor().hasSelection())
@@ -433,9 +390,7 @@ void CentralWidget::printPreview(QPrinter *p)
{
TRACE_OBJ
#ifndef QT_NO_PRINTER
- HelpViewer *viewer = currentHelpViewer();
- if (viewer)
- viewer->print(p);
+ currentHelpViewer()->print(p);
#endif
}
@@ -449,54 +404,34 @@ void CentralWidget::pageSetup()
#endif
}
-bool CentralWidget::isHomeAvailable() const
-{
- TRACE_OBJ
- return currentHelpViewer() ? true : false;
-}
-
void CentralWidget::home()
{
TRACE_OBJ
- HelpViewer *viewer = currentHelpViewer();
- if (viewer)
- viewer->home();
+ currentHelpViewer()->home();
}
bool CentralWidget::isForwardAvailable() const
{
TRACE_OBJ
- const HelpViewer *viewer = currentHelpViewer();
- if (viewer)
- return viewer->isForwardAvailable();
-
- return false;
+ return currentHelpViewer()->isForwardAvailable();
}
void CentralWidget::forward()
{
TRACE_OBJ
- HelpViewer *viewer = currentHelpViewer();
- if (viewer)
- viewer->forward();
+ currentHelpViewer()->forward();
}
bool CentralWidget::isBackwardAvailable() const
{
TRACE_OBJ
- const HelpViewer *viewer = currentHelpViewer();
- if (viewer)
- return viewer->isBackwardAvailable();
-
- return false;
+ return currentHelpViewer()->isBackwardAvailable();
}
void CentralWidget::backward()
{
TRACE_OBJ
- HelpViewer *viewer = currentHelpViewer();
- if (viewer)
- viewer->backward();
+ currentHelpViewer()->backward();
}
@@ -515,10 +450,9 @@ void CentralWidget::setGlobalActions(const QList<QAction*> &actions)
void CentralWidget::setSourceInNewTab(const QUrl &url, qreal zoom)
{
TRACE_OBJ
- if (HelpViewer *viewer = currentHelpViewer()) {
- if (viewer->launchWithExternalApp(url))
- return;
- }
+
+ if (AbstractHelpViewer::launchWithExternalApp(url))
+ return;
HelpViewer *viewer = new HelpViewer(this, zoom);
viewer->installEventFilter(this);
@@ -548,20 +482,18 @@ void CentralWidget::connectSignals()
{
TRACE_OBJ
const HelpViewer *viewer = currentHelpViewer();
- if (viewer) {
- connect(viewer, SIGNAL(copyAvailable(bool)), this,
+ connect(viewer, SIGNAL(copyAvailable(bool)), this,
SIGNAL(copyAvailable(bool)));
- connect(viewer, SIGNAL(forwardAvailable(bool)), this,
+ connect(viewer, SIGNAL(forwardAvailable(bool)), this,
SIGNAL(forwardAvailable(bool)));
- connect(viewer, SIGNAL(backwardAvailable(bool)), this,
+ connect(viewer, SIGNAL(backwardAvailable(bool)), this,
SIGNAL(backwardAvailable(bool)));
- connect(viewer, SIGNAL(sourceChanged(QUrl)), this,
+ connect(viewer, SIGNAL(sourceChanged(QUrl)), this,
SIGNAL(sourceChanged(QUrl)));
- connect(viewer, SIGNAL(highlighted(QString)), this,
+ connect(viewer, SIGNAL(highlighted(QString)), this,
SIGNAL(highlighted(QString)));
- connect(viewer, SIGNAL(sourceChanged(QUrl)), this,
+ connect(viewer, SIGNAL(sourceChanged(QUrl)), this,
SLOT(setTabTitle(QUrl)));
- }
}
HelpViewer* CentralWidget::viewerAt(int index) const
@@ -576,18 +508,10 @@ HelpViewer* CentralWidget::currentHelpViewer() const
return qobject_cast<HelpViewer*>(tabWidget->currentWidget());
}
-void CentralWidget::activateTab(bool onlyHelpViewer)
+void CentralWidget::activateTab()
{
TRACE_OBJ
- if (currentHelpViewer()) {
- currentHelpViewer()->setFocus();
- } else {
- int idx = 0;
- if (onlyHelpViewer)
- idx = lastTabPage;
- tabWidget->setCurrentIndex(idx);
- tabWidget->currentWidget()->setFocus();
- }
+ currentHelpViewer()->setFocus();
}
void CentralWidget::setTabTitle(const QUrl &url)
@@ -605,25 +529,18 @@ void CentralWidget::setTabTitle(const QUrl &url)
}
#else
HelpViewer *viewer = currentHelpViewer();
- if (viewer) {
- tabWidget->setTabText(lastTabPage,
- quoteTabTitle(viewer->documentTitle().trimmed()));
- }
+ tabWidget->setTabText(lastTabPage,
+ quoteTabTitle(viewer->documentTitle().trimmed()));
#endif
}
void CentralWidget::currentPageChanged(int index)
{
TRACE_OBJ
- const HelpViewer *viewer = currentHelpViewer();
- if (viewer)
- lastTabPage = index;
+ lastTabPage = index;
- QWidget *widget = tabWidget->cornerWidget(Qt::TopRightCorner);
- widget->setEnabled(viewer && enableTabCloseAction());
-
- widget = tabWidget->cornerWidget(Qt::TopLeftCorner);
- widget->setEnabled(viewer ? true : false);
+ QWidget *closeButton = tabWidget->cornerWidget(Qt::TopRightCorner);
+ closeButton->setEnabled(enableTabCloseAction());
emit currentViewerChanged();
}
@@ -778,34 +695,33 @@ bool CentralWidget::findInWebPage(const QString &ttf, bool forward)
{
TRACE_OBJ
#if !defined(QT_NO_WEBKIT)
- if (HelpViewer *viewer = currentHelpViewer()) {
- bool found = false;
- QWebPage::FindFlags options;
- if (!ttf.isEmpty()) {
- if (!forward)
- options |= QWebPage::FindBackward;
+ HelpViewer *viewer = currentHelpViewer();
+ bool found = false;
+ QWebPage::FindFlags options;
+ if (!ttf.isEmpty()) {
+ if (!forward)
+ options |= QWebPage::FindBackward;
- if (findWidget->caseSensitive())
- options |= QWebPage::FindCaseSensitively;
+ if (findWidget->caseSensitive())
+ options |= QWebPage::FindCaseSensitively;
- found = viewer->findText(ttf, options);
- findWidget->setTextWrappedVisible(false);
+ found = viewer->findText(ttf, options);
+ findWidget->setTextWrappedVisible(false);
- if (!found) {
- options |= QWebPage::FindWrapsAroundDocument;
- found = viewer->findText(ttf, options);
- if (found)
- findWidget->setTextWrappedVisible(true);
- }
+ if (!found) {
+ options |= QWebPage::FindWrapsAroundDocument;
+ found = viewer->findText(ttf, options);
+ if (found)
+ findWidget->setTextWrappedVisible(true);
}
- // force highlighting of all other matches, also when empty (clear)
- options = QWebPage::HighlightAllOccurrences;
- if (findWidget->caseSensitive())
- options |= QWebPage::FindCaseSensitively;
- viewer->findText(QLatin1String(""), options);
- viewer->findText(ttf, options);
- return found;
}
+ // force highlighting of all other matches, also when empty (clear)
+ options = QWebPage::HighlightAllOccurrences;
+ if (findWidget->caseSensitive())
+ options |= QWebPage::FindCaseSensitively;
+ viewer->findText(QLatin1String(""), options);
+ viewer->findText(ttf, options);
+ return found;
// this needs to stay, case for active search results page
return findInTextBrowser(ttf, forward);
@@ -820,8 +736,6 @@ bool CentralWidget::findInTextBrowser(const QString &ttf, bool forward)
{
TRACE_OBJ
QTextBrowser *browser = qobject_cast<QTextBrowser*>(currentHelpViewer());
- if (tabWidget->currentWidget() == m_searchWidget)
- browser = qFindChild<QTextBrowser*>(m_searchWidget);
if (!browser || ttf.isEmpty())
return false;
@@ -868,88 +782,22 @@ bool CentralWidget::findInTextBrowser(const QString &ttf, bool forward)
void CentralWidget::updateBrowserFont()
{
TRACE_OBJ
- const bool searchAttached = searchWidgetAttached();
- if (searchAttached) {
- HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance();
- m_searchWidget->setFont(helpEngine.usesBrowserFont()
- ? helpEngine.browserFont() : qApp->font());
- }
-
const int count = tabWidget->count();
- if (HelpViewer* viewer = viewerAt(count - 1)) {
- const QFont &font = viewer->viewerFont();
- for (int i = searchAttached ? 1 : 0; i < count; ++i)
- viewerAt(i)->setViewerFont(font);
- }
-}
-
-bool CentralWidget::searchWidgetAttached() const
-{
- TRACE_OBJ
- return m_searchWidget && m_searchWidget->isAttached();
-}
-
-void CentralWidget::createSearchWidget(QHelpSearchEngine *searchEngine)
-{
- TRACE_OBJ
- if (m_searchWidget)
- return;
-
- m_searchWidget = new SearchWidget(searchEngine, this);
- connect(m_searchWidget, SIGNAL(requestShowLink(QUrl)), this,
- SLOT(setSourceFromSearch(QUrl)));
- connect(m_searchWidget, SIGNAL(requestShowLinkInNewTab(QUrl)), this,
- SLOT(setSourceFromSearchInNewTab(QUrl)));
-
- HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance();
- m_searchWidget->setFont(!helpEngine.usesBrowserFont() ? qApp->font()
- : helpEngine.browserFont());
-}
-
-void CentralWidget::activateSearchWidget(bool updateLastTabPage)
-{
- TRACE_OBJ
- if (!m_searchWidget)
- createSearchWidget(HelpEngineWrapper::instance().searchEngine());
-
- if (!m_searchWidget->isAttached()) {
- tabWidget->insertTab(0, m_searchWidget, tr("Search"));
- m_searchWidget->setAttached(true);
-
- if (updateLastTabPage)
- lastTabPage++;
- }
-
- tabWidget->setCurrentWidget(m_searchWidget);
- m_searchWidget->setFocus();
-}
-
-void CentralWidget::removeSearchWidget()
-{
- TRACE_OBJ
- if (searchWidgetAttached()) {
- tabWidget->removeTab(0);
- m_searchWidget->setAttached(false);
- }
+ const QFont &font = viewerAt(count - 1)->viewerFont();
+ for (int i = 0; i < count; ++i)
+ viewerAt(i)->setViewerFont(font);
}
int CentralWidget::availableHelpViewer() const
{
TRACE_OBJ
- int count = tabWidget->count();
- if (searchWidgetAttached())
- count--;
- return count;
+ return tabWidget->count();
}
bool CentralWidget::enableTabCloseAction() const
{
TRACE_OBJ
- int minTabCount = 1;
- if (searchWidgetAttached())
- minTabCount = 2;
-
- return (tabWidget->count() > minTabCount);
+ return tabWidget->count() > 1;
}
QString CentralWidget::quoteTabTitle(const QString &title) const
@@ -990,8 +838,6 @@ CentralWidget::highlightSearchTerms()
{
TRACE_OBJ
HelpViewer *viewer = currentHelpViewer();
- if (!viewer)
- return;
QHelpSearchEngine *searchEngine =
HelpEngineWrapper::instance().searchEngine();
diff --git a/tools/assistant/tools/assistant/centralwidget.h b/tools/assistant/tools/assistant/centralwidget.h
index f286ff7..66d4142 100644
--- a/tools/assistant/tools/assistant/centralwidget.h
+++ b/tools/assistant/tools/assistant/centralwidget.h
@@ -51,7 +51,6 @@ class HelpViewer;
class MainWindow;
class QHelpSearchEngine;
class QTabWidget;
-class SearchWidget;
class CentralWidget : public QWidget
{
@@ -65,7 +64,6 @@ public:
bool hasSelection() const;
QUrl currentSource() const;
QString currentTitle() const;
- bool isHomeAvailable() const;
bool isForwardAvailable() const;
bool isBackwardAvailable() const;
QList<QAction*> globalActions() const;
@@ -74,11 +72,6 @@ public:
HelpViewer *viewerAt(int index) const;
HelpViewer *currentHelpViewer() const;
- bool searchWidgetAttached() const;
- void createSearchWidget(QHelpSearchEngine *searchEngine);
- void activateSearchWidget(bool updateLastTabPage = false);
- void removeSearchWidget();
-
int availableHelpViewer() const;
bool enableTabCloseAction() const;
@@ -107,12 +100,15 @@ public slots:
void forward();
void backward();
- void activateTab(bool onlyHelpViewer = false);
+ void activateTab();
void findNext();
void findPrevious();
void find(const QString &text, bool forward);
+ void setSourceFromSearch(const QUrl &url);
+ void setSourceFromSearchInNewTab(const QUrl &url);
+
signals:
void currentViewerChanged();
void copyAvailable(bool yes);
@@ -132,8 +128,6 @@ private slots:
void currentPageChanged(int index);
void showTabBarContextMenu(const QPoint &point);
void printPreview(QPrinter *printer);
- void setSourceFromSearch(const QUrl &url);
- void setSourceFromSearchInNewTab(const QUrl &url);
void highlightSearchTerms();
private:
@@ -153,8 +147,6 @@ private:
FindWidget *findWidget;
QPrinter *printer;
bool usesDefaultCollection;
-
- SearchWidget *m_searchWidget;
};
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/helpenginewrapper.cpp b/tools/assistant/tools/assistant/helpenginewrapper.cpp
index e21e95d..c7f4091 100644
--- a/tools/assistant/tools/assistant/helpenginewrapper.cpp
+++ b/tools/assistant/tools/assistant/helpenginewrapper.cpp
@@ -566,18 +566,6 @@ void HelpEngineWrapper::setLastTabPage(int lastPage)
CollectionConfiguration::setLastTabPage(*d->m_helpEngine, lastPage);
}
-bool HelpEngineWrapper::searchWasAttached() const
-{
- TRACE_OBJ
- return d->m_helpEngine->customValue(SearchWasAttachedKey).toBool();
-}
-
-void HelpEngineWrapper::setSearchWasAttached(bool attached)
-{
- TRACE_OBJ
- d->m_helpEngine->setCustomValue(SearchWasAttachedKey, attached);
-}
-
int HelpEngineWrapper::startOption() const
{
TRACE_OBJ
diff --git a/tools/assistant/tools/assistant/helpenginewrapper.h b/tools/assistant/tools/assistant/helpenginewrapper.h
index c1041b6..f1a381a 100644
--- a/tools/assistant/tools/assistant/helpenginewrapper.h
+++ b/tools/assistant/tools/assistant/helpenginewrapper.h
@@ -170,9 +170,6 @@ public:
int startOption() const;
void setStartOption(int option);
- bool searchWasAttached() const;
- void setSearchWasAttached(bool attached);
-
bool hasFontSettings() const;
bool usesAppFont() const;
void setUseAppFont(bool useAppFont);
diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp
index 8096218..2605050 100644
--- a/tools/assistant/tools/assistant/mainwindow.cpp
+++ b/tools/assistant/tools/assistant/mainwindow.cpp
@@ -131,30 +131,34 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent)
contentDock->setWidget(m_contentWindow);
addDockWidget(Qt::LeftDockWidgetArea, contentDock);
- QDockWidget *bookmarkDock = 0;
- if (BookmarkManager *manager = BookmarkManager::instance()) {
- bookmarkDock = new QDockWidget(tr("Bookmarks"), this);
- bookmarkDock->setObjectName(QLatin1String("BookmarkWindow"));
- bookmarkDock->setWidget(m_bookmarkWidget = manager->bookmarkDockWidget());
- addDockWidget(Qt::LeftDockWidgetArea, bookmarkDock);
-
- connect(manager, SIGNAL(escapePressed()), this,
+ m_searchWindow = new SearchWidget(helpEngineWrapper.searchEngine());
+ m_searchWindow->setFont(!helpEngineWrapper.usesBrowserFont() ? qApp->font()
+ : helpEngineWrapper.browserFont());
+ QDockWidget *searchDock = new QDockWidget(tr("Search"), this);
+ searchDock->setObjectName(QLatin1String("SearchWindow"));
+ searchDock->setWidget(m_searchWindow);
+ addDockWidget(Qt::LeftDockWidgetArea, searchDock);
+
+ BookmarkManager *bookMarkManager = BookmarkManager::instance();
+ QDockWidget *bookmarkDock = new QDockWidget(tr("Bookmarks"), this);
+ bookmarkDock->setObjectName(QLatin1String("BookmarkWindow"));
+ bookmarkDock->setWidget(m_bookmarkWidget
+ = bookMarkManager->bookmarkDockWidget());
+ addDockWidget(Qt::LeftDockWidgetArea, bookmarkDock);
+
+ connect(bookMarkManager, SIGNAL(escapePressed()), this,
SLOT(activateCurrentCentralWidgetTab()));
- connect(manager, SIGNAL(setSource(QUrl)), m_centralWidget,
+ connect(bookMarkManager, SIGNAL(setSource(QUrl)), m_centralWidget,
SLOT(setSource(QUrl)));
- connect(manager, SIGNAL(setSourceInNewTab(QUrl)), m_centralWidget,
+ connect(bookMarkManager, SIGNAL(setSourceInNewTab(QUrl)), m_centralWidget,
SLOT(setSourceInNewTab(QUrl)));
- connect(m_centralWidget, SIGNAL(addBookmark(QString, QString)), manager,
- SLOT(addBookmark(QString, QString)));
- }
+ connect(m_centralWidget, SIGNAL(addBookmark(QString, QString)),
+ bookMarkManager, SLOT(addBookmark(QString, QString)));
QHelpSearchEngine *searchEngine = helpEngineWrapper.searchEngine();
connect(searchEngine, SIGNAL(indexingStarted()), this, SLOT(indexingStarted()));
connect(searchEngine, SIGNAL(indexingFinished()), this, SLOT(indexingFinished()));
- m_centralWidget->createSearchWidget(searchEngine);
- m_centralWidget->activateSearchWidget();
-
QString defWindowTitle = tr("Qt Assistant");
setWindowTitle(defWindowTitle);
@@ -190,10 +194,10 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent)
restoreGeometry(ba);
} else {
tabifyDockWidget(contentDock, indexDock);
- if (bookmarkDock)
- tabifyDockWidget(indexDock, bookmarkDock);
+ tabifyDockWidget(indexDock, bookmarkDock);
+ tabifyDockWidget(bookmarkDock, searchDock);
contentDock->raise();
- resize(QSize(800, 600));
+ resize(QSize(1024, 768));
}
if (!helpEngineWrapper.hasFontSettings()) {
@@ -490,7 +494,7 @@ void MainWindow::setupActions()
QKeySequence(tr("ALT+I")));
m_viewMenu->addAction(tr("Bookmarks"), this, SLOT(showBookmarksDockWidget()),
QKeySequence(tr("ALT+O")));
- m_viewMenu->addAction(tr("Search"), this, SLOT(showSearchWidget()),
+ m_viewMenu->addAction(tr("Search"), this, SLOT(showSearch()),
QKeySequence(tr("ALT+S")));
menu = menuBar()->addMenu(tr("&Go"));
@@ -524,8 +528,7 @@ void MainWindow::setupActions()
tmp->setShortcuts(QList<QKeySequence>() << QKeySequence(tr("Ctrl+Alt+Left"))
<< QKeySequence(Qt::CTRL + Qt::Key_PageUp));
- if (BookmarkManager *manager = BookmarkManager::instance())
- manager->takeBookmarksMenu(menuBar()->addMenu(tr("&Bookmarks")));
+ BookmarkManager::instance()->takeBookmarksMenu(menuBar()->addMenu(tr("&Bookmarks")));
menu = menuBar()->addMenu(tr("&Help"));
m_aboutAction = menu->addAction(tr("About..."), this, SLOT(showAboutDialog()));
@@ -601,6 +604,12 @@ void MainWindow::setupActions()
connect(m_contentWindow, SIGNAL(escapePressed()), this,
SLOT(activateCurrentCentralWidgetTab()));
+ // search window
+ connect(m_searchWindow, SIGNAL(requestShowLink(QUrl)), m_centralWidget,
+ SLOT(setSourceFromSearch(QUrl)));
+ connect(m_searchWindow, SIGNAL(requestShowLinkInNewTab(QUrl)),
+ m_centralWidget, SLOT(setSourceFromSearchInNewTab(QUrl)));
+
#if defined(QT_NO_PRINTER)
m_pageSetupAction->setVisible(false);
m_printPreviewAction->setVisible(false);
@@ -727,15 +736,9 @@ void MainWindow::gotoAddress()
void MainWindow::updateNavigationItems()
{
TRACE_OBJ
- bool hasCurrentViewer = m_centralWidget->isHomeAvailable();
m_copyAction->setEnabled(m_centralWidget->hasSelection());
- m_homeAction->setEnabled(hasCurrentViewer);
- m_syncAction->setEnabled(hasCurrentViewer);
- m_printPreviewAction->setEnabled(hasCurrentViewer);
- m_printAction->setEnabled(hasCurrentViewer);
m_nextAction->setEnabled(m_centralWidget->isForwardAvailable());
m_backAction->setEnabled(m_centralWidget->isBackwardAvailable());
- m_newTabAction->setEnabled(hasCurrentViewer);
}
void MainWindow::updateTabCloseAction()
@@ -891,15 +894,13 @@ void MainWindow::setBookmarksVisible(bool visible)
void MainWindow::showBookmarksDockWidget()
{
TRACE_OBJ
- if (m_bookmarkWidget)
- activateDockWidget(m_bookmarkWidget);
+ activateDockWidget(m_bookmarkWidget);
}
void MainWindow::hideBookmarksDockWidget()
{
TRACE_OBJ
- if (m_bookmarkWidget)
- m_bookmarkWidget->parentWidget()->hide();
+ m_bookmarkWidget->parentWidget()->hide();
}
void MainWindow::setSearchVisible(bool visible)
@@ -914,13 +915,13 @@ void MainWindow::setSearchVisible(bool visible)
void MainWindow::showSearch()
{
TRACE_OBJ
- m_centralWidget->activateSearchWidget();
+ activateDockWidget(m_searchWindow);
}
void MainWindow::hideSearch()
{
TRACE_OBJ
- m_centralWidget->removeSearchWidget();
+ m_searchWindow->parentWidget()->hide();
}
void MainWindow::activateDockWidget(QWidget *w)
@@ -940,10 +941,7 @@ void MainWindow::setIndexString(const QString &str)
void MainWindow::activateCurrentBrowser()
{
TRACE_OBJ
- CentralWidget *cw = CentralWidget::instance();
- if (cw) {
- cw->activateTab(true);
- }
+ CentralWidget::instance()->activateTab();
}
void MainWindow::activateCurrentCentralWidgetTab()
@@ -952,12 +950,6 @@ void MainWindow::activateCurrentCentralWidgetTab()
m_centralWidget->activateTab();
}
-void MainWindow::showSearchWidget()
-{
- TRACE_OBJ
- m_centralWidget->activateSearchWidget(true);
-}
-
void MainWindow::updateApplicationFont()
{
TRACE_OBJ
diff --git a/tools/assistant/tools/assistant/mainwindow.h b/tools/assistant/tools/assistant/mainwindow.h
index 40ca624..6ac148e 100644
--- a/tools/assistant/tools/assistant/mainwindow.h
+++ b/tools/assistant/tools/assistant/mainwindow.h
@@ -53,13 +53,14 @@ class QLineEdit;
class QComboBox;
class QMenu;
-class IndexWindow;
-class QHelpEngineCore;
-class QHelpEngine;
class CentralWidget;
-class ContentWindow;
class CmdLineParser;
+class ContentWindow;
+class IndexWindow;
class QtDocInstaller;
+class QHelpEngineCore;
+class QHelpEngine;
+class SearchWidget;
class MainWindow : public QMainWindow
{
@@ -87,7 +88,6 @@ public slots:
void setIndexVisible(bool visible);
void setBookmarksVisible(bool visible);
void setSearchVisible(bool visible);
- void showSearchWidget();
void syncContents();
void activateCurrentCentralWidgetTab();
void currentFilterChanged(const QString &filter);
@@ -144,6 +144,7 @@ private:
CentralWidget *m_centralWidget;
IndexWindow *m_indexWindow;
ContentWindow *m_contentWindow;
+ SearchWidget *m_searchWindow;
QLineEdit *m_addressLineEdit;
QComboBox *m_filterCombo;