summaryrefslogtreecommitdiffstats
path: root/tools/assistant
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-11-10 13:36:53 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-11-10 13:36:53 (GMT)
commit7b15c669c336a1d76e3ac001fadde38a294e3e80 (patch)
tree2b8e9631019d1bc9af37d9a93bb93ce0eb16381a /tools/assistant
parent47bc34f413d9a0c6efac6ca3eead95eed7da2e40 (diff)
parent86048e1a09fce11f557d0e8b117229a754ee9098 (diff)
downloadQt-7b15c669c336a1d76e3ac001fadde38a294e3e80.zip
Qt-7b15c669c336a1d76e3ac001fadde38a294e3e80.tar.gz
Qt-7b15c669c336a1d76e3ac001fadde38a294e3e80.tar.bz2
Merge branch 'tools-team/4.6' (early part) into 4.6
Conflicts: src/corelib/tools/qscopedpointer.h
Diffstat (limited to 'tools/assistant')
-rw-r--r--tools/assistant/tools/assistant/bookmarkmanager.cpp1
-rw-r--r--tools/assistant/tools/assistant/centralwidget.cpp120
-rw-r--r--tools/assistant/tools/assistant/centralwidget.h9
-rw-r--r--tools/assistant/tools/assistant/helpviewer.cpp5
-rw-r--r--tools/assistant/tools/assistant/mainwindow.cpp21
-rw-r--r--tools/assistant/tools/assistant/mainwindow.h1
-rw-r--r--tools/assistant/tools/assistant/remotecontrol.cpp2
7 files changed, 84 insertions, 75 deletions
diff --git a/tools/assistant/tools/assistant/bookmarkmanager.cpp b/tools/assistant/tools/assistant/bookmarkmanager.cpp
index 9cccd82..511a56e 100644
--- a/tools/assistant/tools/assistant/bookmarkmanager.cpp
+++ b/tools/assistant/tools/assistant/bookmarkmanager.cpp
@@ -621,6 +621,7 @@ Qt::ItemFlags BookmarkModel::flags(const QModelIndex &index) const
BookmarkManager::BookmarkManager(QHelpEngineCore *_helpEngine)
: treeModel(new BookmarkModel(0, 1, this))
, listModel(new BookmarkModel(0, 1, this))
+ , renameItem(0)
, helpEngine(_helpEngine)
{
folderIcon = QApplication::style()->standardIcon(QStyle::SP_DirClosedIcon);
diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp
index 62b4736..67d803d 100644
--- a/tools/assistant/tools/assistant/centralwidget.cpp
+++ b/tools/assistant/tools/assistant/centralwidget.cpp
@@ -666,34 +666,16 @@ void CentralWidget::setSourceInNewTab(const QUrl &url, qreal zoom)
tabWidget->setCurrentIndex(tabWidget->addTab(viewer,
quoteTabTitle(viewer->documentTitle())));
- QFont font = qApp->font();
- bool userFont = helpEngine->customValue(QLatin1String("useBrowserFont")).toBool();
- if (userFont) {
- font = qVariantValue<QFont>(helpEngine->customValue(
- QLatin1String("browserFont")));
- }
-
-#if !defined(QT_NO_WEBKIT)
- QWebSettings *settings = QWebSettings::globalSettings();
- if (!userFont) {
- int fontSize = settings->fontSize(QWebSettings::DefaultFontSize);
- QString fontFamily = settings->fontFamily(QWebSettings::StandardFont);
- font = QFont(fontFamily, fontSize);
- }
+ QFont font;
+ getBrowserFontFor(viewer, &font);
- QWebView *view = qobject_cast<QWebView*> (viewer);
- if (view) {
- settings = view->settings();
- settings->setFontFamily(QWebSettings::StandardFont, font.family());
- settings->setFontSize(QWebSettings::DefaultFontSize, font.pointSize());
- } else if (viewer) {
- viewer->setFont(font);
- }
- viewer->setTextSizeMultiplier(zoom == 0.0 ? 1.0 : zoom);
-#else
+#if defined(QT_NO_WEBKIT)
font.setPointSize((int)(font.pointSize() + zoom));
- viewer->setFont(font);
+ setBrowserFontFor(viewer, font);
viewer->setZoom((int)zoom);
+#else
+ setBrowserFontFor(viewer, font);
+ viewer->setTextSizeMultiplier(zoom == 0.0 ? 1.0 : zoom);
#endif
connectSignals();
@@ -1011,41 +993,17 @@ bool CentralWidget::findInTextBrowser(QTextBrowser* browser, const QString &ttf,
void CentralWidget::updateBrowserFont()
{
- QFont font = qApp->font();
- bool userFont = helpEngine->customValue(QLatin1String("useBrowserFont")).toBool();
- if (userFont) {
- font = qVariantValue<QFont>(helpEngine->customValue(
- QLatin1String("browserFont")));
- }
-
-#if !defined(QT_NO_WEBKIT)
- QWebSettings *settings = QWebSettings::globalSettings();
- if (!userFont) {
- int fontSize = settings->fontSize(QWebSettings::DefaultFontSize);
- QString fontFamily = settings->fontFamily(QWebSettings::StandardFont);
- font = QFont(fontFamily, fontSize);
+ QFont font;
+ bool searchAttached = searchWidgetAttached();
+ if (searchAttached) {
+ getBrowserFontFor(m_searchWidget, &font);
+ setBrowserFontFor(m_searchWidget, font);
}
-#endif
- QWidget *widget = 0;
- for (int i = 0; i < tabWidget->count(); ++i) {
- widget = tabWidget->widget(i);
-#if !defined(QT_NO_WEBKIT)
- QWebView *view = qobject_cast<QWebView*> (widget);
- if (view) {
- settings = view->settings();
- settings->setFontFamily(QWebSettings::StandardFont, font.family());
- settings->setFontSize(QWebSettings::DefaultFontSize, font.pointSize());
- } else if (widget) {
- if (!userFont)
- font = qApp->font();
- widget->setFont(font);
- }
-#else
- if (widget && widget->font() != font)
- widget->setFont(font);
-#endif
- }
+ int i = searchAttached ? 1 : 0;
+ getBrowserFontFor(tabWidget->widget(i), &font);
+ for (i; i < tabWidget->count(); ++i)
+ setBrowserFontFor(tabWidget->widget(i), font);
}
void CentralWidget::createSearchWidget(QHelpSearchEngine *searchEngine)
@@ -1058,6 +1016,10 @@ void CentralWidget::createSearchWidget(QHelpSearchEngine *searchEngine)
SLOT(setSourceFromSearch(QUrl)));
connect(m_searchWidget, SIGNAL(requestShowLinkInNewTab(QUrl)), this,
SLOT(setSourceFromSearchInNewTab(QUrl)));
+
+ QFont font;
+ getBrowserFontFor(m_searchWidget, &font);
+ setBrowserFontFor(m_searchWidget, font);
}
void CentralWidget::activateSearchWidget(bool updateLastTabPage)
@@ -1079,7 +1041,7 @@ void CentralWidget::activateSearchWidget(bool updateLastTabPage)
void CentralWidget::removeSearchWidget()
{
- if (m_searchWidget && m_searchWidget->isAttached()) {
+ if (searchWidgetAttached()) {
tabWidget->removeTab(0);
m_searchWidget->setAttached(false);
}
@@ -1088,7 +1050,7 @@ void CentralWidget::removeSearchWidget()
int CentralWidget::availableHelpViewer() const
{
int count = tabWidget->count();
- if (m_searchWidget && m_searchWidget->isAttached())
+ if (searchWidgetAttached())
count--;
return count;
}
@@ -1096,7 +1058,7 @@ int CentralWidget::availableHelpViewer() const
bool CentralWidget::enableTabCloseAction() const
{
int minTabCount = 1;
- if (m_searchWidget && m_searchWidget->isAttached())
+ if (searchWidgetAttached())
minTabCount = 2;
return (tabWidget->count() > minTabCount);
@@ -1199,4 +1161,40 @@ QMap<int, QString> CentralWidget::currentSourceFileList() const
return sourceList;
}
+void CentralWidget::getBrowserFontFor(QWidget *viewer, QFont *font)
+{
+ const QLatin1String key("useBrowserFont");
+ if (!helpEngine->customValue(key, false).toBool()) {
+ *font = qApp->font(); // case for QTextBrowser and SearchWidget
+#if !defined(QT_NO_WEBKIT)
+ QWebView *view = qobject_cast<QWebView*> (viewer);
+ if (view) {
+ QWebSettings *settings = QWebSettings::globalSettings();
+ *font = QFont(settings->fontFamily(QWebSettings::StandardFont),
+ settings->fontSize(QWebSettings::DefaultFontSize));
+ }
+#endif
+ } else {
+ *font = qVariantValue<QFont>(helpEngine->customValue(
+ QLatin1String("browserFont")));
+ }
+}
+
+void CentralWidget::setBrowserFontFor(QWidget *widget, const QFont &font)
+{
+#if !defined(QT_NO_WEBKIT)
+ QWebView *view = qobject_cast<QWebView*> (widget);
+ if (view) {
+ QWebSettings *settings = view->settings();
+ settings->setFontFamily(QWebSettings::StandardFont, font.family());
+ settings->setFontSize(QWebSettings::DefaultFontSize, font.pointSize());
+ } else if (widget && widget->font() != font) {
+ widget->setFont(font);
+ }
+#else
+ if (widget && widget->font() != font)
+ widget->setFont(font);
+#endif
+}
+
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/centralwidget.h b/tools/assistant/tools/assistant/centralwidget.h
index 7ae8ee5..8c186f0 100644
--- a/tools/assistant/tools/assistant/centralwidget.h
+++ b/tools/assistant/tools/assistant/centralwidget.h
@@ -48,6 +48,8 @@
#include <QtGui/QWidget>
+#include "searchwidget.h"
+
QT_BEGIN_NAMESPACE
class QEvent;
@@ -65,7 +67,6 @@ class CentralWidget;
class PrintHelper;
class MainWindow;
-class SearchWidget;
class QHelpSearchEngine;
class FindWidget : public QWidget
@@ -123,6 +124,9 @@ public:
HelpViewer *currentHelpViewer() const;
void activateTab(bool onlyHelpViewer = false);
+ bool searchWidgetAttached() const {
+ return m_searchWidget && m_searchWidget->isAttached();
+ }
void createSearchWidget(QHelpSearchEngine *searchEngine);
void activateSearchWidget(bool updateLastTabPage = false);
void removeSearchWidget();
@@ -190,6 +194,9 @@ private:
void highlightSearchTerms();
void setLastShownPages();
+ void getBrowserFontFor(QWidget* viewer, QFont *font);
+ void setBrowserFontFor(QWidget *widget, const QFont &font);
+
private:
int lastTabPage;
QString collectionFile;
diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp
index c888a5f..3547652 100644
--- a/tools/assistant/tools/assistant/helpviewer.cpp
+++ b/tools/assistant/tools/assistant/helpviewer.cpp
@@ -133,10 +133,9 @@ HelpNetworkAccessManager::HelpNetworkAccessManager(QHelpEngine *engine,
{
}
-QNetworkReply *HelpNetworkAccessManager::createRequest(Operation op,
- const QNetworkRequest &request, QIODevice *outgoingData)
+QNetworkReply *HelpNetworkAccessManager::createRequest(Operation /*op*/,
+ const QNetworkRequest &request, QIODevice* /*outgoingData*/)
{
- const QString& scheme = request.url().scheme();
const QUrl& url = request.url();
QString mimeType = url.toString();
if (mimeType.endsWith(QLatin1String(".svg"))
diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp
index de3f695..c56e7e4 100644
--- a/tools/assistant/tools/assistant/mainwindow.cpp
+++ b/tools/assistant/tools/assistant/mainwindow.cpp
@@ -227,16 +227,8 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent)
if (!m_cmdLine->currentFilter().isEmpty()) {
const QString &curFilter = m_cmdLine->currentFilter();
- m_helpEngine->setCurrentFilter(curFilter);
- if (m_filterCombo) {
- int idx = m_filterCombo->findText(curFilter);
- if (idx >= 0) {
- bool blocked = m_filterCombo->signalsBlocked();
- m_filterCombo->blockSignals(true);
- m_filterCombo->setCurrentIndex(idx);
- m_filterCombo->blockSignals(blocked);
- }
- }
+ if (m_helpEngine->customFilters().contains(curFilter))
+ m_helpEngine->setCurrentFilter(curFilter);
}
if (usesDefaultCollection())
@@ -664,6 +656,8 @@ void MainWindow::setupFilterToolbar()
SLOT(setupFilterCombo()));
connect(m_filterCombo, SIGNAL(activated(QString)), this,
SLOT(filterDocumentation(QString)));
+ connect(m_helpEngine, SIGNAL(currentFilterChanged(QString)), this,
+ SLOT(currentFilterChanged(QString)));
setupFilterCombo();
}
@@ -1041,4 +1035,11 @@ QString MainWindow::defaultHelpCollectionFileName()
arg(QLatin1String(QT_VERSION_STR));
}
+void MainWindow::currentFilterChanged(const QString &filter)
+{
+ const int index = m_filterCombo->findText(filter);
+ Q_ASSERT(index != -1);
+ m_filterCombo->setCurrentIndex(index);
+}
+
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/mainwindow.h b/tools/assistant/tools/assistant/mainwindow.h
index 6b858e9..7559fe4 100644
--- a/tools/assistant/tools/assistant/mainwindow.h
+++ b/tools/assistant/tools/assistant/mainwindow.h
@@ -95,6 +95,7 @@ public slots:
void showSearchWidget();
void syncContents();
void activateCurrentCentralWidgetTab();
+ void currentFilterChanged(const QString &filter);
private slots:
void insertLastPages();
diff --git a/tools/assistant/tools/assistant/remotecontrol.cpp b/tools/assistant/tools/assistant/remotecontrol.cpp
index be1c197..474a681 100644
--- a/tools/assistant/tools/assistant/remotecontrol.cpp
+++ b/tools/assistant/tools/assistant/remotecontrol.cpp
@@ -237,6 +237,8 @@ void RemoteControl::handleCommandString(const QString &cmdString)
else
m_mainWindow->expandTOC(depth);
} else if (cmd == QLatin1String("setcurrentfilter")) {
+ if (!m_helpEngine->customFilters().contains(arg))
+ return;
if (m_caching) {
clearCache();
m_currentFilter = arg;