From d489dc180c1e71de117e6d015c5645441eb9fb7f Mon Sep 17 00:00:00 2001 From: kh Date: Fri, 24 Apr 2009 12:59:39 +0200 Subject: init combobox member and make sure we won't access it uninitialized --- tools/assistant/tools/assistant/mainwindow.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) 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); + } } } -- cgit v0.12 From fc0c0621d8c5ffb89e4f9c72fa706b3f10aea97e Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 24 Apr 2009 13:11:17 +0200 Subject: Updated WebKit from /home/shausman/src/webkit/trunk to origin/qtwebkit-4.5 ( a6ebe3865025e2bb4d767a79435af4daf5a9b4db ) Changes in WebKit since the last update: ++ b/WebKit/qt/ChangeLog Rubber-stamped by Ariya Hidayat. Fix qdoc warning about link to QAction::isEnabled. * Api/qwebpage.cpp: 2009-04-24 Simon Hausmann --- src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp | 2 +- src/3rdparty/webkit/WebKit/qt/ChangeLog | 8 ++++++++ 3 files changed, 10 insertions(+), 2 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 + Rubber-stamped by Ariya Hidayat. + + Fix qdoc warning about link to QAction::isEnabled. + + * Api/qwebpage.cpp: + +2009-04-24 Simon Hausmann + Reviewed by Ariya Hidayat. Added support for generating API docs in the Qt build using "make docs" -- cgit v0.12 From 211bea9838bcc2acd7f54b65468fe1be2d81b1e0 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Fri, 24 Apr 2009 14:18:17 +0200 Subject: Re-send network request properly when the socket is in Closing state. This fixes the "QAbstractSocket::connectToHost() called when already connecting/connected to ". The issue was that we were trying to call connect on a socket that was in a Closing state. We have to wait for the disconnected signal before we try to connect again. Reviewed-by: Prasanth --- src/network/access/qhttpnetworkconnection.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) 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; } -- cgit v0.12 From d6d25c3978360bd8c30b3dcce3bfa4117d37f5d8 Mon Sep 17 00:00:00 2001 From: kh Date: Fri, 24 Apr 2009 16:52:13 +0200 Subject: cleanup, no functional change --- tools/assistant/tools/assistant/centralwidget.cpp | 207 ++++++++++++---------- tools/assistant/tools/assistant/centralwidget.h | 3 + tools/assistant/tools/assistant/helpviewer.h | 2 + 3 files changed, 118 insertions(+), 94 deletions(-) diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index 633747a..aa8887c 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(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(" Search wrapped")); + labelWrapped->setAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignVCenter); + labelWrapped->setText(tr(" 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(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(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()) { - QVectorzoomList = 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 zoomVector = value.split(QLatin1Char('|'), + QString::SkipEmptyParts).toVector(); - QVector::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::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))); } } @@ -700,8 +714,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 +893,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 +990,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.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(); -- cgit v0.12 From deffb8578757550e57ea3058e95a758155632226 Mon Sep 17 00:00:00 2001 From: kh Date: Fri, 24 Apr 2009 16:54:33 +0200 Subject: fixes empty tab titles after restart --- tools/assistant/tools/assistant/centralwidget.cpp | 23 +++++++++-------------- tools/assistant/tools/assistant/helpviewer.cpp | 1 + 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index aa8887c..0a94a3d 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -678,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(tabWidget); - for (tab = 0; tab < tabBar->count(); ++tab) { - viewer = qobject_cast(tabWidget->widget(tab)); - if (viewer && viewer->source() == url) - break; - } + QTabBar *tabBar = qFindChild(tabWidget); + for (int tab = 0; tab < tabBar->count(); ++tab) { + HelpViewer* viewer = qobject_cast(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) 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) -- cgit v0.12 From ed21b9dafea192ddd39f1d2a4abcb54962d6dfb8 Mon Sep 17 00:00:00 2001 From: Bjoern Erik Nilsen Date: Fri, 24 Apr 2009 17:34:28 +0200 Subject: Sometimes wrong clipping in QWidget::render() when passing a device or an untransformed painter When passing a painter to QWidget::render, we use the painter->paintEngine()->systemClip() as the "system viewport", i.e. all painting triggered by render() should be limited to this area. The only way to achieve this is by always ensuring the system clip is clipped to the same area (systemClip &= systemViewport). The problem however, was that we only did this for transformed painters. We must of course always do it when there's a systemViewport set, regardless of whether the painter is transformed or not. Auto test included. Task-number: 248852 Reviewed-by: Trond --- src/gui/kernel/qwidget.cpp | 11 +++-- src/gui/painting/qpaintengine.cpp | 4 +- src/gui/painting/qpaintengine_p.h | 12 +++-- tests/auto/qwidget/tst_qwidget.cpp | 98 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 114 insertions(+), 11 deletions(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 071e1bd..e9fd28b 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -4709,10 +4709,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/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index a052034..767553a 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(); @@ -6897,6 +6899,102 @@ void tst_QWidget::render_systemClip() #endif } +void tst_QWidget::render_systemClip2_data() +{ + QTest::addColumn("autoFillBackground"); + QTest::addColumn("usePaintEvent"); + QTest::addColumn("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?"); -- cgit v0.12 From 8b5a400581b9c037d12a9f49e075b187edcb0b00 Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Fri, 24 Apr 2009 19:54:44 +0200 Subject: fixed minor issue with the piechart demo The rubberband was not set on the viewport, leading to an offset when adding margins. Task-number: 251892 Reviewed-by: Alexis --- examples/itemviews/chart/pieview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/itemviews/chart/pieview.cpp b/examples/itemviews/chart/pieview.cpp index 6b62f25..48f4073 100644 --- a/examples/itemviews/chart/pieview.cpp +++ b/examples/itemviews/chart/pieview.cpp @@ -254,7 +254,7 @@ void PieView::mousePressEvent(QMouseEvent *event) QAbstractItemView::mousePressEvent(event); origin = event->pos(); if (!rubberBand) - rubberBand = new QRubberBand(QRubberBand::Rectangle, this); + rubberBand = new QRubberBand(QRubberBand::Rectangle, viewport()); rubberBand->setGeometry(QRect(origin, QSize())); rubberBand->show(); } -- cgit v0.12