summaryrefslogtreecommitdiffstats
path: root/tools/assistant
diff options
context:
space:
mode:
authorGeir Vattekar <geir.vattekar@trolltech.com>2009-05-06 11:32:48 (GMT)
committerGeir Vattekar <geir.vattekar@trolltech.com>2009-05-06 11:32:48 (GMT)
commit19bf6774c6894264342640baf979fa8039547d37 (patch)
treeed8dc234e1163ea9424618d96f533541255eee01 /tools/assistant
parent3dcbd944d90f6e2db9ab74078ccc4f6caf38a2bd (diff)
parent4258eb4c448f2e68fe5cd428f90e1af0c9268a00 (diff)
downloadQt-19bf6774c6894264342640baf979fa8039547d37.zip
Qt-19bf6774c6894264342640baf979fa8039547d37.tar.gz
Qt-19bf6774c6894264342640baf979fa8039547d37.tar.bz2
Merge branch '4.5' of git@scm.dev.nokia.troll.no:qt/qt into 4.5
Diffstat (limited to 'tools/assistant')
-rw-r--r--tools/assistant/tools/assistant/centralwidget.cpp46
-rw-r--r--tools/assistant/tools/assistant/centralwidget.h2
-rw-r--r--tools/assistant/tools/assistant/mainwindow.cpp8
-rw-r--r--tools/assistant/tools/assistant/mainwindow.h1
4 files changed, 42 insertions, 15 deletions
diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp
index 4390a10..ec54d0c 100644
--- a/tools/assistant/tools/assistant/centralwidget.cpp
+++ b/tools/assistant/tools/assistant/centralwidget.cpp
@@ -262,8 +262,9 @@ CentralWidget::~CentralWidget()
QString zoomCount;
QString currentPages;
QLatin1Char separator('|');
- int i = m_searchWidget->isAttached() ? 1 : 0;
+ bool searchAttached = m_searchWidget->isAttached();
+ int i = searchAttached ? 1 : 0;
for (; i < tabWidget->count(); ++i) {
HelpViewer *viewer = qobject_cast<HelpViewer*>(tabWidget->widget(i));
if (viewer && viewer->source().isValid()) {
@@ -274,6 +275,7 @@ CentralWidget::~CentralWidget()
engine.setCustomValue(QLatin1String("LastTabPage"), lastTabPage);
engine.setCustomValue(QLatin1String("LastShownPages"), currentPages);
+ engine.setCustomValue(QLatin1String("SearchWasAttached"), searchAttached);
#if !defined(QT_NO_WEBKIT)
engine.setCustomValue(QLatin1String("LastPagesZoomWebView"), zoomCount);
#else
@@ -418,7 +420,18 @@ void CentralWidget::setLastShownPages()
setSourceInNewTab((*it), (*zIt).toFloat());
const QLatin1String lastTab("LastTabPage");
- tabWidget->setCurrentIndex(helpEngine->customValue(lastTab, 1).toInt());
+ int tab = helpEngine->customValue(lastTab, 1).toInt();
+
+ const QLatin1String searchKey("SearchWasAttached");
+ const bool searchIsAttached = m_searchWidget->isAttached();
+ const bool searchWasAttached = helpEngine->customValue(searchKey).toBool();
+
+ if (searchWasAttached && !searchIsAttached)
+ tabWidget->setCurrentIndex(--tab);
+ else if (!searchWasAttached && searchIsAttached)
+ tabWidget->setCurrentIndex(++tab);
+ else
+ tabWidget->setCurrentIndex(tab);
}
bool CentralWidget::hasSelection() const
@@ -978,22 +991,29 @@ void CentralWidget::updateBrowserFont()
void CentralWidget::createSearchWidget(QHelpSearchEngine *searchEngine)
{
- if (!m_searchWidget) {
- 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)));
- }
- tabWidget->insertTab(0, m_searchWidget, tr("Search"));
- m_searchWidget->setAttached(true);
+ 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)));
}
-void CentralWidget::activateSearchWidget()
+void CentralWidget::activateSearchWidget(bool updateLastTabPage)
{
- if (!m_searchWidget->isAttached())
+ if (!m_searchWidget)
createSearchWidget(helpEngine->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();
}
diff --git a/tools/assistant/tools/assistant/centralwidget.h b/tools/assistant/tools/assistant/centralwidget.h
index 2c28091..e3ce200 100644
--- a/tools/assistant/tools/assistant/centralwidget.h
+++ b/tools/assistant/tools/assistant/centralwidget.h
@@ -118,7 +118,7 @@ public:
void activateTab(bool onlyHelpViewer = false);
void createSearchWidget(QHelpSearchEngine *searchEngine);
- void activateSearchWidget();
+ void activateSearchWidget(bool updateLastTabPage = false);
void removeSearchWidget();
int availableHelpViewer() const;
diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp
index 426a828..52cbf45 100644
--- a/tools/assistant/tools/assistant/mainwindow.cpp
+++ b/tools/assistant/tools/assistant/mainwindow.cpp
@@ -126,6 +126,7 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent)
connect(searchEngine, SIGNAL(indexingFinished()), this, SLOT(indexingFinished()));
m_centralWidget->createSearchWidget(searchEngine);
+ m_centralWidget->activateSearchWidget();
QString defWindowTitle = tr("Qt Assistant");
setWindowTitle(defWindowTitle);
@@ -461,7 +462,7 @@ void MainWindow::setupActions()
QKeySequence(tr("ALT+I")));
m_viewMenu->addAction(tr("Bookmarks"), this, SLOT(showBookmarks()),
QKeySequence(tr("ALT+O")));
- m_viewMenu->addAction(tr("Search"), this, SLOT(showSearch()),
+ m_viewMenu->addAction(tr("Search"), this, SLOT(showSearchWidget()),
QKeySequence(tr("ALT+S")));
menu = menuBar()->addMenu(tr("&Go"));
@@ -880,6 +881,11 @@ void MainWindow::showSearch()
m_centralWidget->activateSearchWidget();
}
+void MainWindow::showSearchWidget()
+{
+ m_centralWidget->activateSearchWidget(true);
+}
+
void MainWindow::hideSearch()
{
m_centralWidget->removeSearchWidget();
diff --git a/tools/assistant/tools/assistant/mainwindow.h b/tools/assistant/tools/assistant/mainwindow.h
index 7d08a74..d7f5c69 100644
--- a/tools/assistant/tools/assistant/mainwindow.h
+++ b/tools/assistant/tools/assistant/mainwindow.h
@@ -92,6 +92,7 @@ public slots:
void showIndex();
void showBookmarks();
void showSearch();
+ void showSearchWidget();
void syncContents();
void activateCurrentCentralWidgetTab();