diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2009-04-25 09:06:28 (GMT) |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2009-04-25 09:06:28 (GMT) |
commit | 9c160157d9617866ae792480a46877dcd82b9e91 (patch) | |
tree | 0f4610709807ad87536ebb19ba6df23c6eed43b9 | |
parent | dae9a234412d09c1af67a34262637bdc6e8c0845 (diff) | |
parent | 8b5a400581b9c037d12a9f49e075b187edcb0b00 (diff) | |
download | Qt-9c160157d9617866ae792480a46877dcd82b9e91.zip Qt-9c160157d9617866ae792480a46877dcd82b9e91.tar.gz Qt-9c160157d9617866ae792480a46877dcd82b9e91.tar.bz2 |
Merge branch '4.5' of git@scm.dev.troll.no:qt/qt
-rw-r--r-- | src/3rdparty/webkit/VERSION | 2 | ||||
-rw-r--r-- | src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp | 2 | ||||
-rw-r--r-- | src/3rdparty/webkit/WebKit/qt/ChangeLog | 8 | ||||
-rw-r--r-- | src/gui/kernel/qwidget.cpp | 11 | ||||
-rw-r--r-- | src/gui/painting/qpaintengine.cpp | 4 | ||||
-rw-r--r-- | src/gui/painting/qpaintengine_p.h | 12 | ||||
-rw-r--r-- | src/network/access/qhttpnetworkconnection.cpp | 8 | ||||
-rw-r--r-- | tests/auto/qwidget/tst_qwidget.cpp | 98 | ||||
-rw-r--r-- | tools/assistant/tools/assistant/centralwidget.cpp | 230 | ||||
-rw-r--r-- | tools/assistant/tools/assistant/centralwidget.h | 3 | ||||
-rw-r--r-- | tools/assistant/tools/assistant/helpviewer.cpp | 1 | ||||
-rw-r--r-- | tools/assistant/tools/assistant/helpviewer.h | 2 | ||||
-rw-r--r-- | tools/assistant/tools/assistant/mainwindow.cpp | 15 |
13 files changed, 269 insertions, 127 deletions
diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index 250eb90..26ce489 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -8,4 +8,4 @@ The commit imported was from the and has the sha1 checksum - 242472777d440a540b4bc944c84eb522388e384e + a6ebe3865025e2bb4d767a79435af4daf5a9b4db diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp index 4828543..01b68eb 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp @@ -1095,7 +1095,7 @@ QVariant QWebPage::inputMethodQuery(Qt::InputMethodQuery property) const This enum describes the types of action which can be performed on the web page. Actions only have an effect when they are applicable. The availability of - actions can be be determined by checking \l{QAction::}{enabled()} on the + actions can be be determined by checking \l{QAction::}{isEnabled()} on the action returned by \l{QWebPage::}{action()}. One method of enabling the text editing, cursor movement, and text selection actions diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog index 640f652..c3bd633 100644 --- a/src/3rdparty/webkit/WebKit/qt/ChangeLog +++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog @@ -1,5 +1,13 @@ 2009-04-24 Simon Hausmann <simon.hausmann@nokia.com> + Rubber-stamped by Ariya Hidayat. + + Fix qdoc warning about link to QAction::isEnabled. + + * Api/qwebpage.cpp: + +2009-04-24 Simon Hausmann <simon.hausmann@nokia.com> + Reviewed by Ariya Hidayat. Added support for generating API docs in the Qt build using "make docs" diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index b38c4bd..1635912 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -4714,10 +4714,13 @@ void QWidget::render(QPaintDevice *target, const QPoint &targetOffset, if (redirected) { target = redirected; offset -= redirectionOffset; - if (!inRenderWithPainter) { // Clip handled by shared painter (in qpainter.cpp). - const QRegion redirectedSystemClip = redirected->paintEngine()->systemClip(); - if (!redirectedSystemClip.isEmpty()) - paintRegion &= redirectedSystemClip.translated(-offset); + } + + if (!inRenderWithPainter) { // Clip handled by shared painter (in qpainter.cpp). + if (QPaintEngine *targetEngine = target->paintEngine()) { + const QRegion targetSystemClip = targetEngine->systemClip(); + if (!targetSystemClip.isEmpty()) + paintRegion &= targetSystemClip.translated(-offset); } } diff --git a/src/gui/painting/qpaintengine.cpp b/src/gui/painting/qpaintengine.cpp index ad09060..7de1ec4 100644 --- a/src/gui/painting/qpaintengine.cpp +++ b/src/gui/painting/qpaintengine.cpp @@ -949,8 +949,8 @@ void QPaintEngine::setSystemClip(const QRegion ®ion) Q_D(QPaintEngine); d->systemClip = region; // Be backward compatible and only call d->systemStateChanged() - // if we currently have a system transform set. - if (d->hasSystemTransform) { + // if we currently have a system transform/viewport set. + if (d->hasSystemTransform || d->hasSystemViewport) { d->transformSystemClip(); d->systemStateChanged(); } diff --git a/src/gui/painting/qpaintengine_p.h b/src/gui/painting/qpaintengine_p.h index eeba7ec..0b5e175 100644 --- a/src/gui/painting/qpaintengine_p.h +++ b/src/gui/painting/qpaintengine_p.h @@ -83,10 +83,12 @@ public: if (systemClip.isEmpty()) return; - if (systemTransform.type() <= QTransform::TxTranslate) - systemClip.translate(qRound(systemTransform.dx()), qRound(systemTransform.dy())); - else - systemClip = systemTransform.map(systemClip); + if (hasSystemTransform) { + if (systemTransform.type() <= QTransform::TxTranslate) + systemClip.translate(qRound(systemTransform.dx()), qRound(systemTransform.dy())); + else + systemClip = systemTransform.map(systemClip); + } // Make sure we're inside the viewport. if (hasSystemViewport) { @@ -101,7 +103,7 @@ public: inline void setSystemTransform(const QTransform &xform) { systemTransform = xform; - if ((hasSystemTransform = !xform.isIdentity())) + if ((hasSystemTransform = !xform.isIdentity()) || hasSystemViewport) transformSystemClip(); systemStateChanged(); } diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 980c0e0..5940fba 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -265,6 +265,11 @@ bool QHttpNetworkConnectionPrivate::ensureConnection(QAbstractSocket *socket) if (socket->state() != QAbstractSocket::ConnectedState) { // connect to the host if not already connected. int index = indexOf(socket); + // resend this request after we receive the disconnected signal + if (socket->state() == QAbstractSocket::ClosingState) { + channels[index].resendCurrent = true; + return false; + } channels[index].state = ConnectingState; channels[index].pendingEncrypt = encrypt; @@ -982,6 +987,9 @@ void QHttpNetworkConnectionPrivate::_q_disconnected() channels[i].state = ReadingState; if (channels[i].reply) receiveReply(socket, channels[i].reply); + } else if (channels[i].state == IdleState && channels[i].resendCurrent) { + // re-sending request because the socket was in ClosingState + QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection); } channels[i].state = IdleState; } diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 9547c8f..b32bc4d 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -283,6 +283,8 @@ private slots: void render_task217815(); void render_windowOpacity(); void render_systemClip(); + void render_systemClip2_data(); + void render_systemClip2(); void setContentsMargins(); @@ -6938,6 +6940,102 @@ void tst_QWidget::render_systemClip() #endif } +void tst_QWidget::render_systemClip2_data() +{ + QTest::addColumn<bool>("autoFillBackground"); + QTest::addColumn<bool>("usePaintEvent"); + QTest::addColumn<QColor>("expectedColor"); + + QTest::newRow("Only auto-fill background") << true << false << QColor(Qt::blue); + QTest::newRow("Only draw in paintEvent") << false << true << QColor(Qt::green); + QTest::newRow("Auto-fill background and draw in paintEvent") << true << true << QColor(Qt::green); +} + +void tst_QWidget::render_systemClip2() +{ + QFETCH(bool, autoFillBackground); + QFETCH(bool, usePaintEvent); + QFETCH(QColor, expectedColor); + + Q_ASSERT_X(expectedColor != QColor(Qt::red), Q_FUNC_INFO, + "Qt::red is the reference color for the image, pick another color"); + + class MyWidget : public QWidget + { + public: + bool usePaintEvent; + void paintEvent(QPaintEvent *) + { + if (usePaintEvent) + QPainter(this).fillRect(rect(), Qt::green); + } + }; + + MyWidget widget; + widget.usePaintEvent = usePaintEvent; + widget.setPalette(Qt::blue); + // NB! widget.setAutoFillBackground(autoFillBackground) won't do the + // trick here since the widget is a top-level. The background is filled + // regardless, unless Qt::WA_OpaquePaintEvent or Qt::WA_NoSystemBackground + // is set. We therefore use the opaque attribute to turn off auto-fill. + if (!autoFillBackground) + widget.setAttribute(Qt::WA_OpaquePaintEvent); + widget.resize(100, 100); + + QImage image(widget.size(), QImage::Format_RGB32); + image.fill(QColor(Qt::red).rgb()); + + QPaintEngine *paintEngine = image.paintEngine(); + QVERIFY(paintEngine); + + QRegion systemClip(QRegion(50, 0, 50, 10)); + systemClip += QRegion(90, 10, 10, 40); + paintEngine->setSystemClip(systemClip); + + // Render entire widget directly onto device. + widget.render(&image); + +#ifndef RENDER_DEBUG + image.save("systemclip_with_device.png"); +#endif + // All pixels within the system clip should now be + // the expectedColor, and the rest should be red. + for (int i = 0; i < image.height(); ++i) { + for (int j = 0; j < image.width(); ++j) { + if (systemClip.contains(QPoint(j, i))) + QCOMPARE(image.pixel(j, i), expectedColor.rgb()); + else + QCOMPARE(image.pixel(j, i), QColor(Qt::red).rgb()); + } + } + + // Refill image with red. + image.fill(QColor(Qt::red).rgb()); + + // Do the same with an untransformed painter. + QPainter painter(&image); + //Make sure we're using the same paint engine and has the right clip set. + paintEngine->setSystemClip(systemClip); + QCOMPARE(painter.paintEngine(), paintEngine); + QCOMPARE(paintEngine->systemClip(), systemClip); + + widget.render(&painter); + +#ifndef RENDER_DEBUG + image.save("systemclip_with_untransformed_painter.png"); +#endif + // All pixels within the system clip should now be + // the expectedColor, and the rest should be red. + for (int i = 0; i < image.height(); ++i) { + for (int j = 0; j < image.width(); ++j) { + if (systemClip.contains(QPoint(j, i))) + QCOMPARE(image.pixel(j, i), expectedColor.rgb()); + else + QCOMPARE(image.pixel(j, i), QColor(Qt::red).rgb()); + } + } +} + void tst_QWidget::setContentsMargins() { QLabel label("why does it always rain on me?"); diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index 633747a..0a94a3d 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -72,7 +72,8 @@ QT_BEGIN_NAMESPACE namespace { - HelpViewer* helpViewerFromTabPosition(const QTabWidget *widget, const QPoint &point) + HelpViewer* helpViewerFromTabPosition(const QTabWidget *widget, + const QPoint &point) { QTabBar *tabBar = qFindChild<QTabBar*>(widget); for (int i = 0; i < tabBar->count(); ++i) { @@ -87,38 +88,32 @@ namespace { FindWidget::FindWidget(QWidget *parent) : QWidget(parent) { - QString system = QLatin1String("win"); QHBoxLayout *hboxLayout = new QHBoxLayout(this); -#ifdef Q_OS_MAC - system = QLatin1String("mac"); -#else - hboxLayout->setSpacing(6); + QString resourcePath = QLatin1String(":/trolltech/assistant/images/"); + +#ifndef Q_OS_MAC hboxLayout->setMargin(0); + hboxLayout->setSpacing(6); + resourcePath.append(QLatin1String("win")); +#else + resourcePath.append(QLatin1String("mac")); #endif - toolClose = new QToolButton(this); - toolClose->setIcon(QIcon(QString::fromUtf8(":/trolltech/assistant/images/%1/closetab.png").arg(system))); - toolClose->setAutoRaise(true); + toolClose = setupToolButton(QLatin1String(""), + resourcePath + QLatin1String("/closetab.png")); hboxLayout->addWidget(toolClose); editFind = new QLineEdit(this); - editFind->setMinimumSize(QSize(150, 0)); - connect(editFind, SIGNAL(textChanged(const QString&)), - this, SLOT(updateButtons())); hboxLayout->addWidget(editFind); + editFind->setMinimumSize(QSize(150, 0)); + connect(editFind, SIGNAL(textChanged(QString)), this, SLOT(updateButtons())); - toolPrevious = new QToolButton(this); - toolPrevious->setAutoRaise(true); - toolPrevious->setText(tr("Previous")); - toolPrevious->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - toolPrevious->setIcon(QIcon(QString::fromUtf8(":/trolltech/assistant/images/%1/previous.png").arg(system))); + toolPrevious = setupToolButton(tr("Previous"), + resourcePath + QLatin1String("/previous.png")); hboxLayout->addWidget(toolPrevious); - toolNext = new QToolButton(this); - toolNext->setAutoRaise(true); - toolNext->setText(tr("Next")); - toolNext->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - toolNext->setIcon(QIcon(QString::fromUtf8(":/trolltech/assistant/images/%1/next.png").arg(system))); + toolNext = setupToolButton(tr("Next"), + resourcePath + QLatin1String("/next.png")); hboxLayout->addWidget(toolNext); checkCase = new QCheckBox(tr("Case Sensitive"), this); @@ -131,15 +126,17 @@ FindWidget::FindWidget(QWidget *parent) #endif labelWrapped = new QLabel(this); + labelWrapped->setScaledContents(true); + labelWrapped->setTextFormat(Qt::RichText); labelWrapped->setMinimumSize(QSize(0, 20)); labelWrapped->setMaximumSize(QSize(105, 20)); - labelWrapped->setTextFormat(Qt::RichText); - labelWrapped->setScaledContents(true); - labelWrapped->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter); - labelWrapped->setText(tr("<img src=\":/trolltech/assistant/images/wrap.png\"> Search wrapped")); + labelWrapped->setAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignVCenter); + labelWrapped->setText(tr("<img src=\":/trolltech/assistant/images/wrap.png\"" + "> Search wrapped")); hboxLayout->addWidget(labelWrapped); - QSpacerItem *spacerItem = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + QSpacerItem *spacerItem = new QSpacerItem(20, 20, QSizePolicy::Expanding, + QSizePolicy::Minimum); hboxLayout->addItem(spacerItem); setMinimumWidth(minimumSizeHint().width()); labelWrapped->hide(); @@ -162,38 +159,54 @@ void FindWidget::updateButtons() } } +QToolButton* FindWidget::setupToolButton(const QString &text, const QString &icon) +{ + QToolButton* toolButton = new QToolButton(this); + + toolButton->setText(text); + toolButton->setAutoRaise(true); + toolButton->setIcon(QIcon(icon)); + toolButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + + return toolButton; +} + + +// -- + CentralWidget::CentralWidget(QHelpEngine *engine, MainWindow *parent) : QWidget(parent) + , lastTabPage(0) + , collectionFile(engine->collectionFile()) , findBar(0) , tabWidget(0) + , findWidget(0) , helpEngine(engine) , printer(0) + , usesDefaultCollection(parent->usesDefaultCollection()) , m_searchWidget(0) { - staticCentralWidget = this; - - lastTabPage = 0; globalActionList.clear(); - collectionFile = helpEngine->collectionFile(); - usesDefaultCollection = parent->usesDefaultCollection(); - - QString system = QLatin1String("win"); + staticCentralWidget = this; QVBoxLayout *vboxLayout = new QVBoxLayout(this); + QString resourcePath = QLatin1String(":/trolltech/assistant/images/"); -#ifdef Q_OS_MAC - system = QLatin1String("mac"); -#else +#ifndef Q_OS_MAC vboxLayout->setMargin(0); + resourcePath.append(QLatin1String("win")); +#else + resourcePath.append(QLatin1String("mac")); #endif tabWidget = new QTabWidget(this); - connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentPageChanged(int))); + connect(tabWidget, SIGNAL(currentChanged(int)), this, + SLOT(currentPageChanged(int))); QToolButton *newTabButton = new QToolButton(this); newTabButton->setAutoRaise(true); newTabButton->setToolTip(tr("Add new page")); - newTabButton->setIcon(QIcon(QString::fromUtf8(":/trolltech/assistant/images/%1/addtab.png").arg(system))); + newTabButton->setIcon(QIcon(resourcePath + QLatin1String("/addtab.png"))); tabWidget->setCornerWidget(newTabButton, Qt::TopLeftCorner); connect(newTabButton, SIGNAL(clicked()), this, SLOT(newTab())); @@ -202,7 +215,7 @@ CentralWidget::CentralWidget(QHelpEngine *engine, MainWindow *parent) closeTabButton->setEnabled(false); closeTabButton->setAutoRaise(true); closeTabButton->setToolTip(tr("Close current page")); - closeTabButton->setIcon(QIcon(QString::fromUtf8(":/trolltech/assistant/images/%1/closetab.png").arg(system))); + closeTabButton->setIcon(QIcon(resourcePath + QLatin1String("/closetab.png"))); tabWidget->setCornerWidget(closeTabButton, Qt::TopRightCorner); connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeTab())); @@ -216,19 +229,20 @@ CentralWidget::CentralWidget(QHelpEngine *engine, MainWindow *parent) vboxLayout->addWidget(findBar); findBar->hide(); findWidget->editFind->installEventFilter(this); - connect(findWidget->toolClose, SIGNAL(clicked()), findBar, SLOT(hide())); + connect(findWidget->toolClose, SIGNAL(clicked()), findBar, SLOT(hide())); connect(findWidget->toolNext, SIGNAL(clicked()), this, SLOT(findNext())); connect(findWidget->editFind, SIGNAL(returnPressed()), this, SLOT(findNext())); - connect(findWidget->editFind, SIGNAL(textChanged(const QString&)), this, SLOT(findCurrentText(const QString&))); + connect(findWidget->editFind, SIGNAL(textChanged(QString)), this, + SLOT(findCurrentText(QString))); connect(findWidget->toolPrevious, SIGNAL(clicked()), this, SLOT(findPrevious())); QTabBar *tabBar = qFindChild<QTabBar*>(tabWidget); if (tabBar) { tabBar->installEventFilter(this); tabBar->setContextMenuPolicy(Qt::CustomContextMenu); - connect(tabBar, SIGNAL(customContextMenuRequested(const QPoint&)), - this, SLOT(showTabBarContextMenu(const QPoint&))); + connect(tabBar, SIGNAL(customContextMenuRequested(QPoint)), this, + SLOT(showTabBarContextMenu(QPoint))); } QPalette p = qApp->palette(); @@ -247,17 +261,12 @@ CentralWidget::~CentralWidget() QString zoomCount; QString currentPages; - QLatin1Char sep('|'); + QLatin1Char separator('|'); for (int i = 1; i < tabWidget->count(); ++i) { HelpViewer *viewer = qobject_cast<HelpViewer*>(tabWidget->widget(i)); if (viewer && viewer->source().isValid()) { - currentPages.append(viewer->source().toString()).append(sep); -#if !defined(QT_NO_WEBKIT) - zoomCount.append(QString::number(viewer->textSizeMultiplier())). - append(sep); -#else - zoomCount.append(QString::number(viewer->zoom())).append(sep); -#endif + currentPages += viewer->source().toString() + separator; + zoomCount += QString::number(viewer->zoom()) + separator; } } engine.setCustomValue(QLatin1String("LastTabPage"), lastTabPage); @@ -363,8 +372,9 @@ void CentralWidget::setSource(const QUrl &url) lastTabPage = tabWidget->addTab(viewer, QString()); tabWidget->setCurrentIndex(lastTabPage); connectSignals(); - } else + } else { viewer = lastViewer; + } viewer->setSource(url); currentPageChanged(lastTabPage); @@ -375,37 +385,35 @@ void CentralWidget::setSource(const QUrl &url) void CentralWidget::setLastShownPages() { + const QLatin1String key("LastShownPages"); + QString value = helpEngine->customValue(key, QString()).toString(); + const QStringList lastShownPageList = value.split(QLatin1Char('|'), + QString::SkipEmptyParts); + + const int pageCount = lastShownPageList.count(); + if (pageCount == 0 && usesDefaultCollection) + return setSource(QUrl(QLatin1String("help"))); + #if !defined(QT_NO_WEBKIT) - QLatin1String zoom("LastPagesZoomWebView"); + const QLatin1String zoom("LastPagesZoomWebView"); #else - QLatin1String zoom("LastPagesZoomTextBrowser"); + const QLatin1String zoom("LastPagesZoomTextBrowser"); #endif - const QStringList lastShownPageList = - helpEngine->customValue(QLatin1String("LastShownPages")).toString(). - split(QLatin1Char('|'), QString::SkipEmptyParts); - - if (!lastShownPageList.isEmpty()) { - QVector<QString>zoomList = helpEngine->customValue(zoom).toString(). - split(QLatin1Char('|'), QString::SkipEmptyParts).toVector(); - if (zoomList.isEmpty()) - zoomList.fill(QLatin1String("0.0"), lastShownPageList.size()); - else if(zoomList.count() < lastShownPageList.count()) { - zoomList.insert(zoomList.count(), - lastShownPageList.count() - zoomList.count(), QLatin1String("0.0")); - } + value = helpEngine->customValue(zoom, QString()).toString(); + QVector<QString> zoomVector = value.split(QLatin1Char('|'), + QString::SkipEmptyParts).toVector(); - QVector<QString>::const_iterator zIt = zoomList.constBegin(); - QStringList::const_iterator it = lastShownPageList.constBegin(); - for (; it != lastShownPageList.constEnd(); ++it, ++zIt) - setSourceInNewTab((*it), (*zIt).toFloat()); + const int zoomCount = zoomVector.count(); + zoomVector.insert(zoomCount, pageCount - zoomCount, QLatin1String("0.0")); - tabWidget->setCurrentIndex(helpEngine->customValue( - QLatin1String("LastTabPage"), 1).toInt()); - } else { - if (usesDefaultCollection) - setSource(QUrl(QLatin1String("help"))); - } + QVector<QString>::const_iterator zIt = zoomVector.constBegin(); + QStringList::const_iterator it = lastShownPageList.constBegin(); + for (; it != lastShownPageList.constEnd(); ++it, ++zIt) + setSourceInNewTab((*it), (*zIt).toFloat()); + + const QLatin1String lastTab("LastTabPage"); + tabWidget->setCurrentIndex(helpEngine->customValue(lastTab, 1).toInt()); } bool CentralWidget::hasSelection() const @@ -483,7 +491,8 @@ void CentralWidget::printPreview() #ifndef QT_NO_PRINTER initPrinter(); QPrintPreviewDialog preview(printer, this); - connect(&preview, SIGNAL(paintRequested(QPrinter *)), SLOT(printPreview(QPrinter *))); + connect(&preview, SIGNAL(paintRequested(QPrinter*)), + SLOT(printPreview(QPrinter*))); preview.exec(); #endif } @@ -634,13 +643,18 @@ void CentralWidget::connectSignals() { const HelpViewer* viewer = currentHelpViewer(); if (viewer) { - connect(viewer, SIGNAL(copyAvailable(bool)), this, SIGNAL(copyAvailable(bool))); - connect(viewer, SIGNAL(forwardAvailable(bool)), this, SIGNAL(forwardAvailable(bool))); - connect(viewer, SIGNAL(backwardAvailable(bool)), this, SIGNAL(backwardAvailable(bool))); - connect(viewer, SIGNAL(sourceChanged(const QUrl&)), this, SIGNAL(sourceChanged(const QUrl&))); - connect(viewer, SIGNAL(highlighted(const QString&)), this, SIGNAL(highlighted(const QString&))); - - connect(viewer, SIGNAL(sourceChanged(const QUrl&)), this, SLOT(setTabTitle(const QUrl&))); + connect(viewer, SIGNAL(copyAvailable(bool)), this, + SIGNAL(copyAvailable(bool))); + connect(viewer, SIGNAL(forwardAvailable(bool)), this, + SIGNAL(forwardAvailable(bool))); + connect(viewer, SIGNAL(backwardAvailable(bool)), this, + SIGNAL(backwardAvailable(bool))); + connect(viewer, SIGNAL(sourceChanged(QUrl)), this, + SIGNAL(sourceChanged(QUrl))); + connect(viewer, SIGNAL(highlighted(QString)), this, + SIGNAL(highlighted(QString))); + connect(viewer, SIGNAL(sourceChanged(QUrl)), this, + SLOT(setTabTitle(QUrl))); } } @@ -664,26 +678,21 @@ void CentralWidget::activateTab(bool onlyHelpViewer) void CentralWidget::setTabTitle(const QUrl& url) { - int tab = lastTabPage; - HelpViewer* viewer = currentHelpViewer(); - + Q_UNUSED(url) #if !defined(QT_NO_WEBKIT) - if (!viewer || viewer->source() != url) { - QTabBar *tabBar = qFindChild<QTabBar*>(tabWidget); - for (tab = 0; tab < tabBar->count(); ++tab) { - viewer = qobject_cast<HelpViewer*>(tabWidget->widget(tab)); - if (viewer && viewer->source() == url) - break; - } + QTabBar *tabBar = qFindChild<QTabBar*>(tabWidget); + for (int tab = 0; tab < tabBar->count(); ++tab) { + HelpViewer* viewer = qobject_cast<HelpViewer*>(tabWidget->widget(tab)); + if (viewer) + tabWidget->setTabText(tab, viewer->documentTitle().trimmed()); } #else - Q_UNUSED(url) -#endif - + HelpViewer* viewer = currentHelpViewer(); if (viewer) { - tabWidget->setTabText(tab, + tabWidget->setTabText(lastTabPage, quoteTabTitle(viewer->documentTitle().trimmed())); } +#endif } void CentralWidget::currentPageChanged(int index) @@ -700,8 +709,11 @@ void CentralWidget::currentPageChanged(int index) enabled = tabWidget->count() > 1; } - tabWidget->cornerWidget(Qt::TopRightCorner)->setEnabled(enabled); - tabWidget->cornerWidget(Qt::TopLeftCorner)->setEnabled(m_searchWidget ? enabled : true); + QWidget *widget = tabWidget->cornerWidget(Qt::TopLeftCorner); + widget->setEnabled(m_searchWidget ? enabled : true); + + widget = tabWidget->cornerWidget(Qt::TopRightCorner); + widget->setEnabled(enabled); emit currentViewerChanged(); } @@ -876,8 +888,10 @@ void CentralWidget::find(QString ttf, bool forward, bool backward) QTextDocument::FindFlags options; - if (cursor.hasSelection()) - cursor.setPosition(forward ? cursor.position() : cursor.anchor(), QTextCursor::MoveAnchor); + if (cursor.hasSelection()) { + cursor.setPosition(forward ? cursor.position() : cursor.anchor(), + QTextCursor::MoveAnchor); + } QTextCursor newCursor = cursor; @@ -971,10 +985,10 @@ void CentralWidget::createSearchWidget(QHelpSearchEngine *searchEngine) { if (!m_searchWidget) { m_searchWidget = new SearchWidget(searchEngine, this); - connect(m_searchWidget, SIGNAL(requestShowLink(const QUrl&)), this, - SLOT(setSourceFromSearch(const QUrl&))); - connect(m_searchWidget, SIGNAL(requestShowLinkInNewTab(const QUrl&)), this, - SLOT(setSourceFromSearchInNewTab(const QUrl&))); + 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")); } diff --git a/tools/assistant/tools/assistant/centralwidget.h b/tools/assistant/tools/assistant/centralwidget.h index 75bd8be..a34ba65 100644 --- a/tools/assistant/tools/assistant/centralwidget.h +++ b/tools/assistant/tools/assistant/centralwidget.h @@ -83,6 +83,9 @@ private slots: void updateButtons(); private: + QToolButton* setupToolButton(const QString &text, const QString &icon); + +private: QLineEdit *editFind; QCheckBox *checkCase; QLabel *labelWrapped; diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp index 5ce6e14..5726136 100644 --- a/tools/assistant/tools/assistant/helpviewer.cpp +++ b/tools/assistant/tools/assistant/helpviewer.cpp @@ -393,6 +393,7 @@ void HelpViewer::mousePressEvent(QMouseEvent *event) void HelpViewer::setLoadFinished(bool ok) { loadFinished = ok; + emit sourceChanged(url()); } #else // !defined(QT_NO_WEBKIT) diff --git a/tools/assistant/tools/assistant/helpviewer.h b/tools/assistant/tools/assistant/helpviewer.h index c66b69c..37545c7 100644 --- a/tools/assistant/tools/assistant/helpviewer.h +++ b/tools/assistant/tools/assistant/helpviewer.h @@ -94,6 +94,8 @@ public: { return pageAction(QWebPage::Back)->isEnabled(); } inline bool hasLoadFinished() const { return loadFinished; } + inline qreal zoom() const + { return textSizeMultiplier(); } public Q_SLOTS: void home(); diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp index 2e39186..6e22413 100644 --- a/tools/assistant/tools/assistant/mainwindow.cpp +++ b/tools/assistant/tools/assistant/mainwindow.cpp @@ -86,6 +86,7 @@ QT_BEGIN_NAMESPACE MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) : QMainWindow(parent) + , m_filterCombo(0) , m_toolBarMenu(0) , m_cmdLine(cmdLine) , m_progressWidget(0) @@ -217,12 +218,14 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) if (!m_cmdLine->currentFilter().isEmpty()) { const QString &curFilter = m_cmdLine->currentFilter(); m_helpEngine->setCurrentFilter(curFilter); - 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_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); + } } } |