summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorkh <qtc-committer@nokia.com>2009-05-06 11:11:08 (GMT)
committerkh <qtc-committer@nokia.com>2009-05-06 11:11:08 (GMT)
commitacd5ac35f26b075c48bc04a2db8064fe8bd4be90 (patch)
tree661924db294c961df31bd66c639aa4842fab922e /tools
parentb38874c55ec7d046c3ff3ba08599d52e004c0146 (diff)
downloadQt-acd5ac35f26b075c48bc04a2db8064fe8bd4be90.zip
Qt-acd5ac35f26b075c48bc04a2db8064fe8bd4be90.tar.gz
Qt-acd5ac35f26b075c48bc04a2db8064fe8bd4be90.tar.bz2
Fixes broken last tab page handling in case the search was hidden.
Diffstat (limited to 'tools')
-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();