From 880cbf602701b0116ca1143d6d07ee8e7eb3f03f Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Mon, 2 Apr 2012 22:17:36 +1000 Subject: Bump some Qt 5 to-do's to Qt 6. Source-incompatible changes are no longer desirable for Qt 5, so these items must wait until at least Qt 6. Task-number: QTBUG-23524 Change-Id: I0b9ae5f6f3a792e0169a4b0d3aefbdcb744acd2f Reviewed-by: Thiago Macieira Reviewed-by: Lars Knoll --- src/widgets/dialogs/qwizard.h | 2 +- src/widgets/styles/qstyle.h | 6 +++--- src/widgets/widgets/qcombobox.h | 2 +- src/widgets/widgets/qdockwidget.h | 2 +- src/widgets/widgets/qstatusbar.h | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/dialogs/qwizard.h b/src/widgets/dialogs/qwizard.h index caa9d5e648..c9d791653b 100644 --- a/src/widgets/dialogs/qwizard.h +++ b/src/widgets/dialogs/qwizard.h @@ -130,7 +130,7 @@ public: void removePage(int id); QWizardPage *page(int id) const; bool hasVisitedPage(int id) const; - QList visitedPages() const; // ### visitedIds()? + QList visitedPages() const; // ### Qt 6: visitedIds()? QList pageIds() const; void setStartId(int id); int startId() const; diff --git a/src/widgets/styles/qstyle.h b/src/widgets/styles/qstyle.h index a8ec8c8c3e..42bd8763d2 100644 --- a/src/widgets/styles/qstyle.h +++ b/src/widgets/styles/qstyle.h @@ -194,7 +194,7 @@ public: PE_IndicatorItemViewItemDrop, PE_PanelItemViewItem, - PE_PanelItemViewRow, // ### Qt 5: remove + PE_PanelItemViewRow, // ### Qt 6: remove PE_PanelStatusBar, @@ -303,7 +303,7 @@ public: SE_ProgressBarContents, SE_ProgressBarLabel, - // ### Qt 5: These values are unused; eliminate them + // ### Qt 6: These values are unused; eliminate them SE_DialogButtonAccept, SE_DialogButtonReject, SE_DialogButtonApply, @@ -343,7 +343,7 @@ public: SE_CheckBoxLayoutItem, SE_ComboBoxLayoutItem, SE_DateTimeEditLayoutItem, - SE_DialogButtonBoxLayoutItem, // ### remove + SE_DialogButtonBoxLayoutItem, // ### Qt 6: remove SE_LabelLayoutItem, SE_ProgressBarLayoutItem, SE_PushButtonLayoutItem, diff --git a/src/widgets/widgets/qcombobox.h b/src/widgets/widgets/qcombobox.h index 1442cd983e..854ced596b 100644 --- a/src/widgets/widgets/qcombobox.h +++ b/src/widgets/widgets/qcombobox.h @@ -131,7 +131,7 @@ public: enum SizeAdjustPolicy { AdjustToContents, AdjustToContentsOnFirstShow, - AdjustToMinimumContentsLength, // ### Qt 5: remove + AdjustToMinimumContentsLength, // ### Qt 6: remove AdjustToMinimumContentsLengthWithIcon }; diff --git a/src/widgets/widgets/qdockwidget.h b/src/widgets/widgets/qdockwidget.h index 21872fa404..bd5a2c2aa4 100644 --- a/src/widgets/widgets/qdockwidget.h +++ b/src/widgets/widgets/qdockwidget.h @@ -82,7 +82,7 @@ public: DockWidgetVerticalTitleBar = 0x08, DockWidgetFeatureMask = 0x0f, - AllDockWidgetFeatures = DockWidgetClosable|DockWidgetMovable|DockWidgetFloatable, // ### remove in 5.0 + AllDockWidgetFeatures = DockWidgetClosable|DockWidgetMovable|DockWidgetFloatable, // ### Qt 6: remove NoDockWidgetFeatures = 0x00, Reserved = 0xff diff --git a/src/widgets/widgets/qstatusbar.h b/src/widgets/widgets/qstatusbar.h index b05bf627ad..4cab706c0b 100644 --- a/src/widgets/widgets/qstatusbar.h +++ b/src/widgets/widgets/qstatusbar.h @@ -87,7 +87,7 @@ protected: void paintEvent(QPaintEvent *); void resizeEvent(QResizeEvent *); - // ### Qt 5: consider making reformat() and hideOrShow() private + // ### Qt 6: consider making reformat() and hideOrShow() private void reformat(); void hideOrShow(); bool event(QEvent *); -- cgit v1.2.3 From 784076fccbc7f5644259bff274db371747fecee2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Mill=C3=A1n=20Soto?= Date: Sun, 22 Jan 2012 19:48:09 +0100 Subject: Made qt_accStripAmp handle "&&" Changed qt_accStripAmp implementation to handle texts which contains pairs of ampersands representing a single ampersand. In order to do that, a new static function called qt_accAmpIndex was created. This function is based on the code of qt_accHotKey, which was changed to use qt_accAmpIndex. Change-Id: Idcc5d07581d7fb3251c30399b189740ca8071104 Reviewed-by: Frederik Gladhorn (cherry picked from commit f864f8f79b88bbc3cc9007d2a92b08ca4b5cb871) --- src/widgets/accessible/qaccessiblewidget.cpp | 41 ++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 12 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/accessible/qaccessiblewidget.cpp b/src/widgets/accessible/qaccessiblewidget.cpp index ae050ac643..796ce42118 100644 --- a/src/widgets/accessible/qaccessiblewidget.cpp +++ b/src/widgets/accessible/qaccessiblewidget.cpp @@ -100,16 +100,14 @@ static QString buddyString(const QWidget *widget) return QString(); } -QString Q_WIDGETS_EXPORT qt_accStripAmp(const QString &text) -{ - return QString(text).remove(QLatin1Char('&')); -} - -QString Q_WIDGETS_EXPORT qt_accHotKey(const QString &text) +/* This function will return the offset of the '&' in the text that would be + preceding the accelerator character. + If this text does not have an accelerator, -1 will be returned. */ +static int qt_accAmpIndex(const QString &text) { #ifndef QT_NO_SHORTCUT if (text.isEmpty()) - return text; + return -1; int fa = 0; QChar ac; @@ -118,23 +116,42 @@ QString Q_WIDGETS_EXPORT qt_accHotKey(const QString &text) if (fa < text.length()) { // ignore "&&" if (text.at(fa) == QLatin1Char('&')) { + ++fa; continue; } else { - ac = text.at(fa); + return fa - 1; break; } } } - if (ac.isNull()) - return QString(); - return QKeySequence(Qt::ALT).toString(QKeySequence::NativeText) + ac.toUpper(); + + return -1; #else Q_UNUSED(text); - return QString(); + return -1; #endif } +QString Q_WIDGETS_EXPORT qt_accStripAmp(const QString &text) +{ + QString newText(text); + int ampIndex = qt_accAmpIndex(newText); + if (ampIndex != -1) + newText.remove(ampIndex, 1); + + return newText.replace(QLatin1String("&&"), QLatin1String("&")); +} + +QString Q_WIDGETS_EXPORT qt_accHotKey(const QString &text) +{ + int ampIndex = qt_accAmpIndex(text); + if (ampIndex != -1) + return (QString)QKeySequence(Qt::ALT) + text.at(ampIndex + 1); + + return QString(); +} + class QAccessibleWidgetPrivate { public: -- cgit v1.2.3 From 699f2424eba929d04b081af2a0cad74e2e58e235 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lund=20Martsum?= Date: Tue, 3 Apr 2012 06:38:48 +0200 Subject: QHeaderView - rename many spans classes and variables In (SHA) b800d8b94a7861ecf8853621f6556fca186fb5b7 the span model was replaced with a plain section model. The code however still has variables and classes called someting with spans which would be confusing for possible new readers of the code. This patch cleans up most of it. It only renames classes,functions and variables (and not any semantics or the public API). Change-Id: I6ceb068c7317223f0d8e37f8032197f518d0174c Reviewed-by: Stephen Kelly --- src/widgets/itemviews/qheaderview.cpp | 159 +++++++++++++++++----------------- src/widgets/itemviews/qheaderview_p.h | 32 +++---- 2 files changed, 97 insertions(+), 94 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index e82cd477c5..444e56d6d0 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -67,15 +67,15 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_DATASTREAM -QDataStream &operator<<(QDataStream &out, const QHeaderViewPrivate::SectionSpan &span) +QDataStream &operator<<(QDataStream &out, const QHeaderViewPrivate::SectionItem §ion) { - span.write(out); + section.write(out); return out; } -QDataStream &operator>>(QDataStream &in, QHeaderViewPrivate::SectionSpan &span) +QDataStream &operator>>(QDataStream &in, QHeaderViewPrivate::SectionItem §ion) { - span.read(in); + section.read(in); return in; } #endif // QT_NO_DATASTREAM @@ -789,18 +789,18 @@ void QHeaderView::moveSection(int from, int to) //Q_ASSERT(oldHeaderLength == length()); // move sizes - // ### check for spans of section sizes here + // ### check for items of section sizes here if (to > from) { for (visual = from; visual <= to; ++visual) { int size = sizes[visual - from]; ResizeMode mode = modes[visual - from]; - d->createSectionSpan(visual, visual, size, mode); + d->createSectionItems(visual, visual, size, mode); } } else { for (visual = to; visual <= from; ++visual) { int size = sizes[visual - to]; ResizeMode mode = modes[visual - to]; - d->createSectionSpan(visual, visual, size, mode); + d->createSectionItems(visual, visual, size, mode); } } //Q_ASSERT(d->headerLength() == length()); @@ -839,8 +839,8 @@ void QHeaderView::swapSections(int first, int second) ResizeMode secondMode = d->headerSectionResizeMode(second); int secondLogical = d->logicalIndex(second); - d->createSectionSpan(second, second, firstSize, firstMode); - d->createSectionSpan(first, first, secondSize, secondMode); + d->createSectionItems(second, second, firstSize, firstMode); + d->createSectionItems(first, first, secondSize, secondMode); d->initializeIndexMapping(); @@ -898,7 +898,7 @@ void QHeaderView::resizeSection(int logical, int size) if (stretchLastSection() && visual == d->lastVisibleVisualIndex()) d->lastSectionSize = size; - d->createSectionSpan(visual, visual, size, d->headerSectionResizeMode(visual)); + d->createSectionItems(visual, visual, size, d->headerSectionResizeMode(visual)); if (!updatesEnabled()) { if (d->hasAutoResizeSections()) @@ -1719,18 +1719,18 @@ void QHeaderView::sectionsInserted(const QModelIndex &parent, int insertAt = logicalFirst; int insertCount = logicalLast - logicalFirst + 1; - QHeaderViewPrivate::SectionSpan span(d->defaultSectionSize, d->globalResizeMode); + QHeaderViewPrivate::SectionItem section(d->defaultSectionSize, d->globalResizeMode); d->sectionStartposRecalc = true; - if (d->sectionSpans.isEmpty() || insertAt >= d->sectionSpans.count()) { + if (d->sectionItems.isEmpty() || insertAt >= d->sectionItems.count()) { int insertLength = d->defaultSectionSize * insertCount; d->length += insertLength; - d->sectionSpans.insert(d->sectionSpans.count(), insertCount, span); // append + d->sectionItems.insert(d->sectionItems.count(), insertCount, section); // append } else { - // separate them out into their own spans + // separate them out into their own sections int insertLength = d->defaultSectionSize * insertCount; d->length += insertLength; - d->sectionSpans.insert(insertAt, insertCount, span); + d->sectionItems.insert(insertAt, insertCount, section); } // update sorting column @@ -1852,7 +1852,7 @@ void QHeaderViewPrivate::_q_sectionsRemoved(const QModelIndex &parent, if (visualIndices.isEmpty() && logicalIndices.isEmpty()) { //Q_ASSERT(headerSectionCount() == sectionCount); - removeSectionsFromSpans(logicalFirst, logicalLast); + removeSectionsFromSectionItems(logicalFirst, logicalLast); } else { if (logicalFirst == logicalLast) { // Remove just one index. int l = logicalFirst; @@ -1869,21 +1869,21 @@ void QHeaderViewPrivate::_q_sectionsRemoved(const QModelIndex &parent, logicalIndices.remove(visual); visualIndices.remove(l); //Q_ASSERT(headerSectionCount() == sectionCount); - removeSectionsFromSpans(visual, visual); + removeSectionsFromSectionItems(visual, visual); } else { sectionStartposRecalc = true; // We will need to recalc positions after removing items - for (int u = 0; u < sectionSpans.count(); ++u) // Store spans info - sectionSpans.at(u).tmpLogIdx = logicalIndices.at(u); - for (int v = sectionSpans.count() - 1; v >= 0; --v) { // Remove the sections - if (logicalFirst <= sectionSpans.at(v).tmpLogIdx && sectionSpans.at(v).tmpLogIdx <= logicalLast) - removeSectionsFromSpans(v, v); // Invalidates the spans variable + for (int u = 0; u < sectionItems.count(); ++u) // Store section info + sectionItems.at(u).tmpLogIdx = logicalIndices.at(u); + for (int v = sectionItems.count() - 1; v >= 0; --v) { // Remove the sections + if (logicalFirst <= sectionItems.at(v).tmpLogIdx && sectionItems.at(v).tmpLogIdx <= logicalLast) + removeSectionsFromSectionItems(v, v); } - visualIndices.resize(sectionSpans.count()); - logicalIndices.resize(sectionSpans.count()); + visualIndices.resize(sectionItems.count()); + logicalIndices.resize(sectionItems.count()); int* visual_data = visualIndices.data(); int* logical_data = logicalIndices.data(); - for (int w = 0; w < sectionSpans.count(); ++w) { // Restore visual and logical indexes - int logindex = sectionSpans.at(w).tmpLogIdx; + for (int w = 0; w < sectionItems.count(); ++w) { // Restore visual and logical indexes + int logindex = sectionItems.at(w).tmpLogIdx; if (logindex > logicalFirst) logindex -= changeCount; visual_data[logindex] = w; @@ -2005,7 +2005,7 @@ void QHeaderView::initializeSections(int start, int end) if (end + 1 < d->sectionCount()) { int newCount = end + 1; - d->removeSectionsFromSpans(newCount, d->sectionCount() - 1); + d->removeSectionsFromSectionItems(newCount, d->sectionCount() - 1); if (!d->hiddenSectionSize.isEmpty()) { if (oldCount - newCount > d->hiddenSectionSize.count()) { for (int i = end + 1; i < d->sectionCount(); ++i) @@ -2055,7 +2055,7 @@ void QHeaderView::initializeSections(int start, int end) d->sectionHidden.resize(newSectionCount); if (newSectionCount > oldCount) - d->createSectionSpan(start, end, (end - start + 1) * d->defaultSectionSize, d->globalResizeMode); + d->createSectionItems(start, end, (end - start + 1) * d->defaultSectionSize, d->globalResizeMode); //Q_ASSERT(d->headerLength() == d->length); if (d->sectionCount() != oldCount) @@ -2224,14 +2224,14 @@ void QHeaderView::paintEvent(QPaintEvent *e) } #if 0 - // ### visualize section spans - for (int a = 0, i = 0; i < d->sectionSpans.count(); ++i) { + // ### visualize sections + for (int a = 0, i = 0; i < d->sectionItems.count(); ++i) { QColor color((i & 4 ? 255 : 0), (i & 2 ? 255 : 0), (i & 1 ? 255 : 0)); if (d->orientation == Qt::Horizontal) - painter.fillRect(a - d->offset, 0, d->sectionSpans.at(i).size, 4, color); + painter.fillRect(a - d->offset, 0, d->sectionItems.at(i).size, 4, color); else - painter.fillRect(0, a - d->offset, 4, d->sectionSpans.at(i).size, color); - a += d->sectionSpans.at(i).size; + painter.fillRect(0, a - d->offset, 4, d->sectionItems.at(i).size, color); + a += d->sectionItems.at(i).size; } #endif @@ -3108,6 +3108,7 @@ void QHeaderViewPrivate::resizeSections(QHeaderView::ResizeMode globalMode, bool pixelReminder = lengthToStrech % numberOfStretchedSections; } + // ### The code below would be nicer if it was cleaned up a bit (since spans has been replaced with items) int spanStartSection = 0; int previousSectionLength = 0; @@ -3149,7 +3150,7 @@ void QHeaderViewPrivate::resizeSections(QHeaderView::ResizeMode globalMode, bool if ((previousSectionResizeMode != newSectionResizeMode || previousSectionLength != newSectionLength) && i > 0) { int spanLength = (i - spanStartSection) * previousSectionLength; - createSectionSpan(spanStartSection, i - 1, spanLength, previousSectionResizeMode); + createSectionItems(spanStartSection, i - 1, spanLength, previousSectionResizeMode); //Q_ASSERT(headerLength() == length); spanStartSection = i; } @@ -3161,7 +3162,7 @@ void QHeaderViewPrivate::resizeSections(QHeaderView::ResizeMode globalMode, bool previousSectionResizeMode = newSectionResizeMode; } - createSectionSpan(spanStartSection, sectionCount() - 1, + createSectionItems(spanStartSection, sectionCount() - 1, (sectionCount() - spanStartSection) * previousSectionLength, previousSectionResizeMode); //Q_ASSERT(headerLength() == length); @@ -3169,14 +3170,14 @@ void QHeaderViewPrivate::resizeSections(QHeaderView::ResizeMode globalMode, bool viewport->update(); } -void QHeaderViewPrivate::createSectionSpan(int start, int end, int size, QHeaderView::ResizeMode mode) +void QHeaderViewPrivate::createSectionItems(int start, int end, int size, QHeaderView::ResizeMode mode) { int sizePerSection = size / (end - start + 1); - if (end >= sectionSpans.count()) { - sectionSpans.resize(end + 1); + if (end >= sectionItems.count()) { + sectionItems.resize(end + 1); sectionStartposRecalc = true; } - SectionSpan *sectiondata = sectionSpans.data(); + SectionItem *sectiondata = sectionItems.data(); for (int i = start; i <= end; ++i) { length += (sizePerSection - sectiondata[i].size); sectionStartposRecalc |= (sectiondata[i].size != sizePerSection); @@ -3185,15 +3186,15 @@ void QHeaderViewPrivate::createSectionSpan(int start, int end, int size, QHeader } } -void QHeaderViewPrivate::removeSectionsFromSpans(int start, int end) +void QHeaderViewPrivate::removeSectionsFromSectionItems(int start, int end) { // remove sections - sectionStartposRecalc |= (end != sectionSpans.count() - 1); + sectionStartposRecalc |= (end != sectionItems.count() - 1); int removedlength = 0; for (int u = start; u <= end; ++u) - removedlength += sectionSpans.at(u).size; + removedlength += sectionItems.at(u).size; length -= removedlength; - sectionSpans.remove(start, end - start + 1); + sectionItems.remove(start, end - start + 1); } void QHeaderViewPrivate::clear() @@ -3205,7 +3206,7 @@ void QHeaderViewPrivate::clear() sectionSelected.clear(); sectionHidden.clear(); hiddenSectionSize.clear(); - sectionSpans.clear(); + sectionItems.clear(); } } @@ -3242,7 +3243,7 @@ void QHeaderViewPrivate::cascadingResize(int visual, int newSize) int originalSectionSize = cascadingSectionSize.value(i); if (currentSectionSize < originalSectionSize) { int newSectionSize = currentSectionSize + delta; - resizeSectionSpan(i, currentSectionSize, newSectionSize); + resizeSectionItem(i, currentSectionSize, newSectionSize); if (newSectionSize >= originalSectionSize && false) cascadingSectionSize.remove(i); // the section is now restored sectionResized = true; @@ -3256,7 +3257,7 @@ void QHeaderViewPrivate::cascadingResize(int visual, int newSize) if (!sectionResized) { newSize = qMax(newSize, minimumSize); if (oldSize != newSize) - resizeSectionSpan(visual, oldSize, newSize); + resizeSectionItem(visual, oldSize, newSize); } // cascade the section size change @@ -3268,7 +3269,7 @@ void QHeaderViewPrivate::cascadingResize(int visual, int newSize) continue; int newSectionSize = qMax(currentSectionSize - delta, minimumSize); //qDebug() << "### cascading to" << i << newSectionSize - currentSectionSize << delta; - resizeSectionSpan(i, currentSectionSize, newSectionSize); + resizeSectionItem(i, currentSectionSize, newSectionSize); saveCascadingSectionSize(i, currentSectionSize); delta = delta - (currentSectionSize - newSectionSize); //qDebug() << "new delta" << delta; @@ -3288,7 +3289,7 @@ void QHeaderViewPrivate::cascadingResize(int visual, int newSize) if (currentSectionSize >= originalSectionSize) continue; int newSectionSize = currentSectionSize - delta; - resizeSectionSpan(i, currentSectionSize, newSectionSize); + resizeSectionItem(i, currentSectionSize, newSectionSize); if (newSectionSize >= originalSectionSize && false) { //qDebug() << "section" << i << "restored to" << originalSectionSize; cascadingSectionSize.remove(i); // the section is now restored @@ -3298,7 +3299,7 @@ void QHeaderViewPrivate::cascadingResize(int visual, int newSize) } // resize the section - resizeSectionSpan(visual, oldSize, qMax(newSize, minimumSize)); + resizeSectionItem(visual, oldSize, qMax(newSize, minimumSize)); // cascade the section size change if (delta < 0 && newSize < minimumSize) { @@ -3308,7 +3309,7 @@ void QHeaderViewPrivate::cascadingResize(int visual, int newSize) int sectionSize = headerSectionSize(i); if (sectionSize <= minimumSize) continue; - resizeSectionSpan(i, sectionSize, qMax(sectionSize + delta, minimumSize)); + resizeSectionItem(i, sectionSize, qMax(sectionSize + delta, minimumSize)); saveCascadingSectionSize(i, sectionSize); break; } @@ -3321,7 +3322,7 @@ void QHeaderViewPrivate::cascadingResize(int visual, int newSize) continue; int currentSectionSize = headerSectionSize(i); int newSectionSize = qMax(currentSectionSize - delta, minimumSize); - resizeSectionSpan(i, currentSectionSize, newSectionSize); + resizeSectionItem(i, currentSectionSize, newSectionSize); break; } } @@ -3337,14 +3338,14 @@ void QHeaderViewPrivate::setDefaultSectionSize(int size) { Q_Q(QHeaderView); defaultSectionSize = size; - for (int i = 0; i < sectionSpans.count(); ++i) { - QHeaderViewPrivate::SectionSpan &span = sectionSpans[i]; + for (int i = 0; i < sectionItems.count(); ++i) { + QHeaderViewPrivate::SectionItem §ion = sectionItems[i]; if (sectionHidden.isEmpty() || !sectionHidden.testBit(i)) { // resize on not hidden. const int newSize = size; - if (newSize != span.size) { - length += newSize - span.size; //the whole length is changed - const int oldSectionSize = span.sectionSize(); - span.size = size; + if (newSize != section.size) { + length += newSize - section.size; //the whole length is changed + const int oldSectionSize = section.sectionSize(); + section.size = size; emit q->sectionResized(logicalIndex(i), oldSectionSize, size); } } @@ -3354,25 +3355,25 @@ void QHeaderViewPrivate::setDefaultSectionSize(int size) void QHeaderViewPrivate::recalcSectionStartPos() const // linear (but fast) { int pixelpos = 0; - for (QVector::const_iterator i = sectionSpans.constBegin(); i != sectionSpans.constEnd(); ++i) { + for (QVector::const_iterator i = sectionItems.constBegin(); i != sectionItems.constEnd(); ++i) { i->calculated_startpos = pixelpos; // write into const mutable pixelpos += i->size; } sectionStartposRecalc = false; } -void QHeaderViewPrivate::resizeSectionSpan(int visualIndex, int oldSize, int newSize) +void QHeaderViewPrivate::resizeSectionItem(int visualIndex, int oldSize, int newSize) { Q_Q(QHeaderView); QHeaderView::ResizeMode mode = headerSectionResizeMode(visualIndex); - createSectionSpan(visualIndex, visualIndex, newSize, mode); + createSectionItems(visualIndex, visualIndex, newSize, mode); emit q->sectionResized(logicalIndex(visualIndex), oldSize, newSize); } int QHeaderViewPrivate::headerSectionSize(int visual) const { if (visual < sectionCount() && visual >= 0) - return sectionSpans.at(visual).sectionSize(); + return sectionItems.at(visual).sectionSize(); return -1; } @@ -3381,7 +3382,7 @@ int QHeaderViewPrivate::headerSectionPosition(int visual) const if (visual < sectionCount() && visual >= 0) { if (sectionStartposRecalc) recalcSectionStartPos(); - return sectionSpans.at(visual).calculated_startpos; + return sectionItems.at(visual).calculated_startpos; } return -1; } @@ -3391,13 +3392,13 @@ int QHeaderViewPrivate::headerVisualIndexAt(int position) const if (sectionStartposRecalc) recalcSectionStartPos(); int startidx = 0; - int endidx = sectionSpans.count() - 1; + int endidx = sectionItems.count() - 1; while (startidx <= endidx) { int middle = (endidx + startidx) / 2; - if (sectionSpans.at(middle).calculated_startpos > position) { + if (sectionItems.at(middle).calculated_startpos > position) { endidx = middle - 1; } else { - if (sectionSpans.at(middle).calculatedEndPos() <= position) + if (sectionItems.at(middle).calculatedEndPos() <= position) startidx = middle + 1; else // we found it. return middle; @@ -3409,7 +3410,7 @@ int QHeaderViewPrivate::headerVisualIndexAt(int position) const void QHeaderViewPrivate::setHeaderSectionResizeMode(int visual, QHeaderView::ResizeMode mode) { int size = headerSectionSize(visual); - createSectionSpan(visual, visual, size, mode); + createSectionItems(visual, visual, size, mode); } QHeaderView::ResizeMode QHeaderViewPrivate::headerSectionResizeMode(int visual) const @@ -3417,14 +3418,14 @@ QHeaderView::ResizeMode QHeaderViewPrivate::headerSectionResizeMode(int visual) int span = sectionSpanIndex(visual); if (span == -1) return globalResizeMode; - return sectionSpans.at(span).resizeMode; + return sectionItems.at(span).resizeMode; } void QHeaderViewPrivate::setGlobalHeaderResizeMode(QHeaderView::ResizeMode mode) { globalResizeMode = mode; - for (int i = 0; i < sectionSpans.count(); ++i) - sectionSpans[i].resizeMode = mode; + for (int i = 0; i < sectionItems.count(); ++i) + sectionItems[i].resizeMode = mode; } int QHeaderViewPrivate::viewSectionSizeHint(int logical) const @@ -3442,7 +3443,7 @@ int QHeaderViewPrivate::adjustedVisualIndex(int visualIndex) const if (!sectionHidden.isEmpty()) { int adjustedVisualIndex = visualIndex; int currentVisualIndex = 0; - for (int i = 0; i < sectionSpans.count(); ++i) { + for (int i = 0; i < sectionItems.count(); ++i) { if (sectionHidden.testBit(i)) ++adjustedVisualIndex; else @@ -3484,7 +3485,7 @@ void QHeaderViewPrivate::write(QDataStream &out) const out << int(defaultAlignment); out << int(globalResizeMode); - out << sectionSpans; + out << sectionItems; } bool QHeaderViewPrivate::read(QDataStream &in) @@ -3524,15 +3525,17 @@ bool QHeaderViewPrivate::read(QDataStream &in) in >> global; globalResizeMode = (QHeaderView::ResizeMode)global; - in >> sectionSpans; - // Spans in Qt5 only contains one element - but for backward compability with Qt4 we do the following - QVector newSectionSpans; - for (int u = 0; u < sectionSpans.count(); ++u) { - int count = sectionSpans.at(u).tmpDataStreamSectionCount; + in >> sectionItems; + // In Qt4 we had a vector of spans where one span could hold information on more sections. + // Now we have an itemvector where one items contains information about one section + // For backward compability with Qt4 we do the following + QVector newSectionItems; + for (int u = 0; u < sectionItems.count(); ++u) { + int count = sectionItems.at(u).tmpDataStreamSectionCount; for (int n = 0; n < count; ++n) - newSectionSpans.append(sectionSpans[u]); + newSectionItems.append(sectionItems[u]); } - sectionSpans = newSectionSpans; + sectionItems = newSectionItems; recalcSectionStartPos(); return true; } diff --git a/src/widgets/itemviews/qheaderview_p.h b/src/widgets/itemviews/qheaderview_p.h index a2b0ef2180..d6e6ab991a 100644 --- a/src/widgets/itemviews/qheaderview_p.h +++ b/src/widgets/itemviews/qheaderview_p.h @@ -141,7 +141,7 @@ public: else sectionSelected.fill(false); } - inline int sectionCount() const {return sectionSpans.count();} + inline int sectionCount() const {return sectionItems.count();} inline bool reverse() const { return orientation == Qt::Horizontal && q_func()->isRightToLeft(); @@ -195,7 +195,7 @@ public: } inline void clearCascadingSections() { - firstCascadingSection = sectionSpans.count(); + firstCascadingSection = sectionItems.count(); lastCascadingSection = 0; cascadingSectionSize.clear(); } @@ -283,9 +283,9 @@ public: QHeaderView::ResizeMode globalResizeMode; QList persistentHiddenSections; mutable bool sectionStartposRecalc; - // header section spans + // header sections - struct SectionSpan { + struct SectionItem { int size; union { // This union is made in order to save space and ensure good vector performance (on remove) mutable int calculated_startpos; // <- this is the primary used member. @@ -293,8 +293,8 @@ public: int tmpDataStreamSectionCount; // recalcSectionStartPos() or set sectionStartposRecalc to true }; // to ensure that calculated_startpos will be calculated afterwards. QHeaderView::ResizeMode resizeMode; - inline SectionSpan() : size(0), resizeMode(QHeaderView::Interactive) {} - inline SectionSpan(int length, QHeaderView::ResizeMode mode) + inline SectionItem() : size(0), resizeMode(QHeaderView::Interactive) {} + inline SectionItem(int length, QHeaderView::ResizeMode mode) : size(length), calculated_startpos(-1), resizeMode(mode) {} inline int sectionSize() const { return size; } inline int calculatedEndPos() const { return calculated_startpos + size; } @@ -306,34 +306,34 @@ public: #endif }; - QVector sectionSpans; + QVector sectionItems; - void createSectionSpan(int start, int end, int size, QHeaderView::ResizeMode mode); - void removeSectionsFromSpans(int start, int end); - void resizeSectionSpan(int visualIndex, int oldSize, int newSize); + void createSectionItems(int start, int end, int size, QHeaderView::ResizeMode mode); + void removeSectionsFromSectionItems(int start, int end); + void resizeSectionItem(int visualIndex, int oldSize, int newSize); void setDefaultSectionSize(int size); void recalcSectionStartPos() const; // not really const inline int headerSectionCount() const { // for debugging - return sectionSpans.count(); + return sectionItems.count(); } inline int headerLength() const { // for debugging int len = 0; - for (int i = 0; i < sectionSpans.count(); ++i) - len += sectionSpans.at(i).size; + for (int i = 0; i < sectionItems.count(); ++i) + len += sectionItems.at(i).size; return len; } inline void removeSpans(const QList &spans) { for (int i = spans.count() - 1; i >= 0; --i) { - length -= sectionSpans.at(spans.at(i)).size; - sectionSpans.remove(spans.at(i)); + length -= sectionItems.at(spans.at(i)).size; + sectionItems.remove(spans.at(i)); } } inline int sectionSpanIndex(int visual) const { - if (visual < sectionSpans.count() && visual >= 0) { + if (visual < sectionItems.count() && visual >= 0) { return visual; } return -1; -- cgit v1.2.3 From e8b098b6367baafda9e494ec4c9ddd1b7bf661ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lund=20Martsum?= Date: Tue, 10 Apr 2012 08:22:12 +0200 Subject: QHeaderView - remove some (nearly) unused span functions This removes a couple of functions. Two of them are unused and the last one has its (now) very simple implementation inlined in the only caller. The last function was called something with spans and we would like to get away from using the word 'span' since we no longer uses spans. Change-Id: Icef95166289d52bd958400cba70daceb6fa75913 Reviewed-by: Stephen Kelly --- src/widgets/itemviews/qheaderview.cpp | 5 ++--- src/widgets/itemviews/qheaderview_p.h | 18 ------------------ 2 files changed, 2 insertions(+), 21 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index 444e56d6d0..e6376cef60 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -3415,10 +3415,9 @@ void QHeaderViewPrivate::setHeaderSectionResizeMode(int visual, QHeaderView::Res QHeaderView::ResizeMode QHeaderViewPrivate::headerSectionResizeMode(int visual) const { - int span = sectionSpanIndex(visual); - if (span == -1) + if (visual < 0 || visual >= sectionItems.count()) return globalResizeMode; - return sectionItems.at(span).resizeMode; + return sectionItems.at(visual).resizeMode; } void QHeaderViewPrivate::setGlobalHeaderResizeMode(QHeaderView::ResizeMode mode) diff --git a/src/widgets/itemviews/qheaderview_p.h b/src/widgets/itemviews/qheaderview_p.h index d6e6ab991a..cca81b0c22 100644 --- a/src/widgets/itemviews/qheaderview_p.h +++ b/src/widgets/itemviews/qheaderview_p.h @@ -314,10 +314,6 @@ public: void setDefaultSectionSize(int size); void recalcSectionStartPos() const; // not really const - inline int headerSectionCount() const { // for debugging - return sectionItems.count(); - } - inline int headerLength() const { // for debugging int len = 0; for (int i = 0; i < sectionItems.count(); ++i) @@ -325,20 +321,6 @@ public: return len; } - inline void removeSpans(const QList &spans) { - for (int i = spans.count() - 1; i >= 0; --i) { - length -= sectionItems.at(spans.at(i)).size; - sectionItems.remove(spans.at(i)); - } - } - - inline int sectionSpanIndex(int visual) const { - if (visual < sectionItems.count() && visual >= 0) { - return visual; - } - return -1; - } - int headerSectionSize(int visual) const; int headerSectionPosition(int visual) const; int headerVisualIndexAt(int position) const; -- cgit v1.2.3 From 62cda62c0c70a75de3f87cbd802a1be24d27ef18 Mon Sep 17 00:00:00 2001 From: Qt4iOS Date: Sat, 24 Mar 2012 14:00:56 +0000 Subject: Modified project files to be iOS compatible. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removed some MacOS source code files from iOS build. Use unix standard paths for now (iOS-specific implementation will come later). Change-Id: I8b2731b431b3a379a1ec4ec07d227e886209e3e9 Reviewed-by: Morten Johan Sørvig --- src/widgets/styles/styles.pri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/styles/styles.pri b/src/widgets/styles/styles.pri index ef6827f74f..8f6996cfa3 100644 --- a/src/widgets/styles/styles.pri +++ b/src/widgets/styles/styles.pri @@ -37,7 +37,7 @@ contains( styles, all ) { styles = mac windows windowsxp windowsvista } -!macx-*:styles -= mac +!macx-*|!contains(QT_CONFIG, coreservices):styles -= mac x11{ QMAKE_CXXFLAGS += $$QT_CFLAGS_QGTKSTYLE -- cgit v1.2.3 From ad1bd1563f3f65d0f7b65687af2ade42f7f9f3d9 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Wed, 28 Mar 2012 15:26:17 +0200 Subject: Implement window modality in QtGui MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QWindow already has windowModality() and setWindowModality() as part of its API from commit 516f4e283ba4626d7239630397ef867ab0366071. Platform plugins can use this already to setup modality hints on windows that they create, but it's not enough to implement modality fully. QGuiApplication gets a modalWindow() static method, which is similar to QApplication::activeModalWidget() in that it returns the last modal window to be shown. The modal window "stack" moves from QApplicationPrivate to QGuiApplicationPrivate. The enterModal*() and leaveModal*() functions in QApplicationPrivate are removed and replaced by QGuiApplicationPrivate::showModalWindow() and hideModalWindow(), which are called by QWindow::setVisible() just before calling QPlatformWindow::setVisible(). The virtual QGuiApplicationPrivate::isWindowBlocked() will tell us if a window is blocked by a modal window (and tell which modal window for any interested callers). The default implementation works on the QWindow level. QApplicationPrivate reimplements isWindowBlocked() and adds popup and WA_GroupLeader support. QGuiApplication uses the state set from isWindowBlocked() to block user-input events: mouse press, mouse move, mouse release, wheel, key presses, key releases, enter/leave events, close events, and touch begin, update, and end events. Note also that the modality helper functions in QtWidgets and QApplicationPrivate are left in place and working as they always have. The behavior of QWidget in the presence of modal windows/dialogs should not change. Change-Id: I2c89e6026d40160387787a6e009ae1fdc12dfd69 Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll Reviewed-by: Samuel Rødal Reviewed-by: Morten Johan Sørvig --- src/widgets/kernel/qapplication.cpp | 171 ++++++++++++++------------------ src/widgets/kernel/qapplication_p.h | 9 +- src/widgets/kernel/qapplication_qpa.cpp | 23 +---- src/widgets/kernel/qwidget.cpp | 23 +---- 4 files changed, 82 insertions(+), 144 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index a8b1fa6d1c..c560dba1b7 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -440,8 +440,6 @@ FontHash *qt_app_fonts_hash() QWidgetList *QApplicationPrivate::popupWidgets = 0; // has keyboard input focus QDesktopWidget *qt_desktopWidget = 0; // root window widgets -QWidgetList * qt_modal_stack = 0; // stack of modal widgets -bool app_do_modal = false; /*! \internal @@ -755,7 +753,8 @@ QWidget *QApplication::activePopupWidget() QWidget *QApplication::activeModalWidget() { - return qt_modal_stack && !qt_modal_stack->isEmpty() ? qt_modal_stack->first() : 0; + QWidgetWindow *widgetWindow = qobject_cast(modalWindow()); + return widgetWindow ? widgetWindow->widget() : 0; } /*! @@ -2315,31 +2314,52 @@ Q_WIDGETS_EXPORT bool qt_tryModalHelper(QWidget *widget, QWidget **rettop) bool QApplicationPrivate::isBlockedByModal(QWidget *widget) { widget = widget->window(); - if (!modalState()) + return self->isWindowBlocked(widget->windowHandle()); +} + +bool QApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blockingWindow) const +{ + QWindow *unused = 0; + if (!blockingWindow) + blockingWindow = &unused; + + if (modalWindowList.isEmpty()) { + *blockingWindow = 0; return false; - if (QApplication::activePopupWidget() == widget) + } + QWidget *popupWidget = QApplication::activePopupWidget(); + QWindow *popupWindow = popupWidget ? popupWidget->windowHandle() : 0; + if (popupWindow == window) { + *blockingWindow = 0; return false; + } - for (int i = 0; i < qt_modal_stack->size(); ++i) { - QWidget *modalWidget = qt_modal_stack->at(i); + for (int i = 0; i < modalWindowList.count(); ++i) { + QWindow *modalWindow = modalWindowList.at(i); { - // check if the active modal widget is our widget or a parent of our widget - QWidget *w = widget; + // check if the modal window is our window or a (transient) parent of our window + QWindow *w = window; while (w) { - if (w == modalWidget) + if (w == modalWindow) { + *blockingWindow = 0; return false; - w = w->parentWidget(); + } + QWindow *p = w->parent(); + if (!p) + p = w->transientParent(); + w = p; } } - Qt::WindowModality windowModality = modalWidget->windowModality(); + Qt::WindowModality windowModality = modalWindow->windowModality(); + QWidgetWindow *modalWidgetWindow = qobject_cast(modalWindow); if (windowModality == Qt::NonModal) { // determine the modality type if it hasn't been set on the - // modalWidget, this normally happens when waiting for a - // native dialog. use WindowModal if we are the child of a - // group leader; otherwise use ApplicationModal. - QWidget *m = modalWidget; + // modalWindow's widget, this normally happens when waiting for a + // native dialog. use WindowModal if we are the child of a group + // leader; otherwise use ApplicationModal. + QWidget *m = modalWidgetWindow ? modalWidgetWindow->widget() : 0; while (m && !m->testAttribute(Qt::WA_GroupLeader)) { m = m->parentWidget(); if (m) @@ -2352,97 +2372,58 @@ bool QApplicationPrivate::isBlockedByModal(QWidget *widget) switch (windowModality) { case Qt::ApplicationModal: - { - QWidget *groupLeaderForWidget = widget; - while (groupLeaderForWidget && !groupLeaderForWidget->testAttribute(Qt::WA_GroupLeader)) - groupLeaderForWidget = groupLeaderForWidget->parentWidget(); - - if (groupLeaderForWidget) { - // if \a widget has WA_GroupLeader, it can only be blocked by ApplicationModal children - QWidget *m = modalWidget; - while (m && m != groupLeaderForWidget && !m->testAttribute(Qt::WA_GroupLeader)) - m = m->parentWidget(); - if (m == groupLeaderForWidget) - return true; - } else if (modalWidget != widget) { + { + QWidgetWindow *widgetWindow = qobject_cast(window); + QWidget *groupLeaderForWidget = widgetWindow ? widgetWindow->widget() : 0; + while (groupLeaderForWidget && !groupLeaderForWidget->testAttribute(Qt::WA_GroupLeader)) + groupLeaderForWidget = groupLeaderForWidget->parentWidget(); + + if (groupLeaderForWidget) { + // if \a widget has WA_GroupLeader, it can only be blocked by ApplicationModal children + QWidget *m = modalWidgetWindow ? modalWidgetWindow->widget() : 0; + while (m && m != groupLeaderForWidget && !m->testAttribute(Qt::WA_GroupLeader)) + m = m->parentWidget(); + if (m == groupLeaderForWidget) { + *blockingWindow = m->windowHandle(); return true; } - break; + } else if (modalWindow != window) { + *blockingWindow = modalWindow; + return true; } + break; + } case Qt::WindowModal: - { - QWidget *w = widget; + { + QWindow *w = window; + do { + QWindow *m = modalWindow; do { - QWidget *m = modalWidget; - do { - if (m == w) - return true; - m = m->parentWidget(); - if (m) - m = m->window(); - } while (m); - w = w->parentWidget(); - if (w) - w = w->window(); - } while (w); - break; - } + if (m == w) { + *blockingWindow = m; + return true; + } + QWindow *p = m->parent(); + if (!p) + p = m->transientParent(); + m = p; + } while (m); + QWindow *p = w->parent(); + if (!p) + p = w->transientParent(); + w = p; + } while (w); + break; + } default: - Q_ASSERT_X(false, "QApplication", "internal error, a modal widget cannot be modeless"); + Q_ASSERT_X(false, "QApplication", "internal error, a modal window cannot be modeless"); break; } } + *blockingWindow = 0; return false; } -/*!\internal - */ -void QApplicationPrivate::enterModal(QWidget *widget) -{ - QSet blocked; - QList windows = QApplication::topLevelWidgets(); - for (int i = 0; i < windows.count(); ++i) { - QWidget *window = windows.at(i); - if (window->windowType() != Qt::Tool && isBlockedByModal(window)) - blocked.insert(window); - } - - enterModal_sys(widget); - - windows = QApplication::topLevelWidgets(); - QEvent e(QEvent::WindowBlocked); - for (int i = 0; i < windows.count(); ++i) { - QWidget *window = windows.at(i); - if (!blocked.contains(window) && window->windowType() != Qt::Tool && isBlockedByModal(window)) - QApplication::sendEvent(window, &e); - } -} - -/*!\internal - */ -void QApplicationPrivate::leaveModal(QWidget *widget) -{ - QSet blocked; - QList windows = QApplication::topLevelWidgets(); - for (int i = 0; i < windows.count(); ++i) { - QWidget *window = windows.at(i); - if (window->windowType() != Qt::Tool && isBlockedByModal(window)) - blocked.insert(window); - } - - leaveModal_sys(widget); - - windows = QApplication::topLevelWidgets(); - QEvent e(QEvent::WindowUnblocked); - for (int i = 0; i < windows.count(); ++i) { - QWidget *window = windows.at(i); - if(blocked.contains(window) && window->windowType() != Qt::Tool && !isBlockedByModal(window)) - QApplication::sendEvent(window, &e); - } -} - - - /*!\internal Called from qapplication_\e{platform}.cpp, returns true diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h index 74af3bca6d..8f67a29d84 100644 --- a/src/widgets/kernel/qapplication_p.h +++ b/src/widgets/kernel/qapplication_p.h @@ -198,10 +198,7 @@ public: static void dispatchEnterLeave(QWidget *enter, QWidget *leave); //modality - static void enterModal(QWidget*); - static void leaveModal(QWidget*); - static void enterModal_sys(QWidget*); - static void leaveModal_sys(QWidget*); + Q_DECL_OVERRIDE bool isWindowBlocked(QWindow *window, QWindow **blockingWindow = 0) const; static bool isBlockedByModal(QWidget *widget); static bool modalState(); static bool tryModalHelper(QWidget *widget, QWidget **rettop = 0); @@ -279,10 +276,6 @@ public: static bool widgetCount; // Coupled with -widgetcount switch static bool load_testability; // Coupled with -testability switch -#ifdef Q_WS_MAC - static bool native_modal_dialog_active; -#endif - static void setSystemPalette(const QPalette &pal); static void setPalette_helper(const QPalette &palette, const char* className, bool clearWidgetPaletteHash); static void initializeWidgetPaletteHash(); diff --git a/src/widgets/kernel/qapplication_qpa.cpp b/src/widgets/kernel/qapplication_qpa.cpp index bcea2676bc..92b831101f 100644 --- a/src/widgets/kernel/qapplication_qpa.cpp +++ b/src/widgets/kernel/qapplication_qpa.cpp @@ -75,8 +75,6 @@ QT_BEGIN_NAMESPACE static QString appName; static QString appFont; static bool popupGrabOk; -extern bool app_do_modal; -extern QWidgetList *qt_modal_stack; extern QWidget *qt_button_down; extern QWidget *qt_popup_down; extern bool qt_replay_popup_mouse_event; @@ -126,28 +124,9 @@ bool qt_try_modal(QWidget *widget, QEvent::Type type) return !block_event; } -void QApplicationPrivate::enterModal_sys(QWidget *widget) -{ - if (!qt_modal_stack) - qt_modal_stack = new QWidgetList; - qt_modal_stack->insert(0, widget); - app_do_modal = true; -} - -void QApplicationPrivate::leaveModal_sys(QWidget *widget) -{ - if (qt_modal_stack && qt_modal_stack->removeAll(widget)) { - if (qt_modal_stack->isEmpty()) { - delete qt_modal_stack; - qt_modal_stack = 0; - } - } - app_do_modal = qt_modal_stack != 0; -} - bool QApplicationPrivate::modalState() { - return app_do_modal; + return !self->modalWindowList.isEmpty(); } QWidget *qt_tlw_for_window(QWindow *wnd) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index cccde764ad..70839e705f 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -7080,12 +7080,6 @@ void QWidgetPrivate::show_helper() QShowEvent showEvent; QApplication::sendEvent(q, &showEvent); - if (!isEmbedded && q->isModal() && q->isWindow()) - // QApplicationPrivate::enterModal *before* show, otherwise the initial - // stacking might be wrong - QApplicationPrivate::enterModal(q); - - show_sys(); if (!isEmbedded && q->windowType() == Qt::Popup) @@ -7141,12 +7135,6 @@ void QWidgetPrivate::hide_helper() if (!isEmbedded && (q->windowType() == Qt::Popup)) qApp->d_func()->closePopup(q); - // Move test modal here. Otherwise, a modal dialog could get - // destroyed and we lose all access to its parent because we haven't - // left modality. (Eg. modal Progress Dialog) - if (!isEmbedded && q->isModal() && q->isWindow()) - QApplicationPrivate::leaveModal(q); - #if defined(Q_WS_WIN) if (q->isWindow() && !(q->windowType() == Qt::Popup) && q->parentWidget() && !q->parentWidget()->isHidden() && q->isActiveWindow()) @@ -10047,9 +10035,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) break; case Qt::WA_ShowModal: if (!on) { - if (isVisible()) - QApplicationPrivate::leaveModal(this); - // reset modality type to Modeless when clearing WA_ShowModal + // reset modality type to NonModal when clearing WA_ShowModal data->window_modality = Qt::NonModal; } else if (data->window_modality == Qt::NonModal) { // determine the modality type if it hasn't been set prior @@ -10067,10 +10053,9 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) data->window_modality = (w && w->testAttribute(Qt::WA_GroupLeader)) ? Qt::WindowModal : Qt::ApplicationModal; - // Some window managers does not allow us to enter modal after the - // window is showing. Therefore, to be consistent, we cannot call - // QApplicationPrivate::enterModal(this) here. The window must be - // hidden before changing modality. + // Some window managers do not allow us to enter modality after the + // window is visible.The window must be hidden before changing the + // windowModality property and then reshown. } if (testAttribute(Qt::WA_WState_Created)) { // don't call setModal_sys() before create_sys() -- cgit v1.2.3 From 9839474e19dbef4b5b79abeaecebbf6e7bd6aed2 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Fri, 30 Mar 2012 09:53:12 +0200 Subject: QWidget: allow modal top-levels to have WA_DontShowOnScreen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If a modal top-level widget has WA_DontShowOnScreen set, we need to call QGuiApplicationPrivate::showModalWindow() and hideModalWindow() ourselves, since we will not be calling QWindow::setVisible() (which would normally do the call for us). Change-Id: I1b22dd177c5956a2290f3ee031c95ab50d88f153 Reviewed-by: Friedemann Kleint Reviewed-by: Morten Johan Sørvig --- src/widgets/kernel/qwidget_qpa.cpp | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp index 3d23b04ddf..4fe7ad6dc7 100644 --- a/src/widgets/kernel/qwidget_qpa.cpp +++ b/src/widgets/kernel/qwidget_qpa.cpp @@ -441,8 +441,15 @@ void QWidgetPrivate::show_sys() { Q_Q(QWidget); q->setAttribute(Qt::WA_Mapped); + + QWindow *window = q->windowHandle(); + if (q->testAttribute(Qt::WA_DontShowOnScreen)) { invalidateBuffer(q->rect()); + if (q->isWindow() && q->windowModality() != Qt::NonModal && window) { + // add our window to the modal window list + QGuiApplicationPrivate::showModalWindow(window); + } return; } @@ -451,7 +458,6 @@ void QWidgetPrivate::show_sys() if (!q->isWindow() && !q->testAttribute(Qt::WA_NativeWindow)) return; - QWindow *window = q->windowHandle(); if (window) { QRect geomRect = q->geometry(); if (q->isWindow()) { @@ -473,9 +479,7 @@ void QWidgetPrivate::show_sys() } invalidateBuffer(q->rect()); - - if (window) - window->setVisible(true); + window->setVisible(true); } } @@ -484,6 +488,17 @@ void QWidgetPrivate::hide_sys() { Q_Q(QWidget); q->setAttribute(Qt::WA_Mapped, false); + + QWindow *window = q->windowHandle(); + + if (q->testAttribute(Qt::WA_DontShowOnScreen) + && q->isWindow() + && q->windowModality() != Qt::NonModal + && window) { + // remove our window from the modal window list + QGuiApplicationPrivate::hideModalWindow(window); + } + deactivateWidgetCleanup(); if (!q->isWindow()) { QWidget *p = q->parentWidget(); @@ -492,9 +507,9 @@ void QWidgetPrivate::hide_sys() } return; } - if (QWindow *window = q->windowHandle()) { - window->setVisible(false); - } + + if (window) + window->setVisible(false); } void QWidgetPrivate::setMaxWindowState_helper() -- cgit v1.2.3 From ce84af7c9b57f7f8cef5d57c5486b1409e13bcdd Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 11 Apr 2012 12:07:59 +0200 Subject: Propagate window state changes to QWidget. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apply the state in QWidgetWindow and send an event to the widget unless the code is triggered by QWidget::setWindowState(). Change-Id: Ibf2f4e730384e41636841b9216eecfdff35b7bcb Reviewed-by: Samuel Rødal --- src/widgets/kernel/qwidgetwindow_qpa.cpp | 34 +++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qwidgetwindow_qpa.cpp b/src/widgets/kernel/qwidgetwindow_qpa.cpp index 6dbd3c1f77..3cccc52311 100644 --- a/src/widgets/kernel/qwidgetwindow_qpa.cpp +++ b/src/widgets/kernel/qwidgetwindow_qpa.cpp @@ -454,10 +454,38 @@ void QWidgetWindow::handleWindowStateChangedEvent(QWindowStateChangeEvent *event { // QWindow does currently not know 'active'. Qt::WindowStates eventState = event->oldState(); - if (m_widget->windowState() & Qt::WindowActive) + Qt::WindowStates widgetState = m_widget->windowState(); + if (widgetState & Qt::WindowActive) eventState |= Qt::WindowActive; - QWindowStateChangeEvent widgetEvent(eventState); - QGuiApplication::sendSpontaneousEvent(m_widget, &widgetEvent); + + // Determine the new widget state, remember maximized/full screen + // during minimized. + switch (windowState()) { + case Qt::WindowNoState: + widgetState &= ~(Qt::WindowMinimized | Qt::WindowMaximized | Qt::WindowFullScreen); + break; + case Qt::WindowMinimized: + widgetState |= Qt::WindowMinimized; + break; + case Qt::WindowMaximized: + widgetState &= ~Qt::WindowFullScreen; + widgetState |= Qt::WindowMaximized; + break; + case Qt::WindowFullScreen: + widgetState &= ~Qt::WindowMaximized; + widgetState |= Qt::WindowFullScreen; + break; + case Qt::WindowActive: // Not handled by QWindow + break; + } + + // Sent event if the state changed (that is, it is not triggered by + // QWidget::setWindowState(), which also sends an event to the widget). + if (widgetState != m_widget->data->window_state) { + m_widget->data->window_state = widgetState; + QWindowStateChangeEvent widgetEvent(eventState); + QGuiApplication::sendSpontaneousEvent(m_widget, &widgetEvent); + } } bool QWidgetWindow::nativeEvent(const QByteArray &eventType, void *message, long *result) -- cgit v1.2.3 From d6ad749e8fdce0ebf595cc05a9367be5bf52240d Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Thu, 12 Apr 2012 00:21:42 +1000 Subject: Remove Qt 5 to-do comments from qgraphicslayoutitem.h. Neither of these comments will be actioned for Qt 5: the first because would be source-incompatible with Qt 4, the second becuase it would be a significant behavioural change. Task-number: QTBUG-25090 Change-Id: I5f8f7cce3007c3188b2f0184138fa8e55a165654 Reviewed-by: Lars Knoll --- src/widgets/graphicsview/qgraphicslayoutitem.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/graphicsview/qgraphicslayoutitem.h b/src/widgets/graphicsview/qgraphicslayoutitem.h index ef391f01a0..38f09743c0 100644 --- a/src/widgets/graphicsview/qgraphicslayoutitem.h +++ b/src/widgets/graphicsview/qgraphicslayoutitem.h @@ -96,13 +96,12 @@ public: QSizeF effectiveSizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const; - virtual void updateGeometry(); //### rename to sizeHintChanged() + virtual void updateGeometry(); QGraphicsLayoutItem *parentLayoutItem() const; void setParentLayoutItem(QGraphicsLayoutItem *parent); bool isLayout() const; - // ###Qt5: Make automatic reparenting work regardless of item/object/widget type. QGraphicsItem *graphicsItem() const; bool ownedByLayout() const; -- cgit v1.2.3 From ee5bd5349bb8d781524307627b205676726d09a7 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Thu, 12 Apr 2012 02:04:07 +1000 Subject: Remove Qt 5 to-do comment that will not be addressed. The suggested behavioural change had the potential to break existing code, so the change won't be made for Qt 5. Task-number: QTBUG-25119 Change-Id: Ie03271d12b21a800c998e073eeb9ca1cd03ffe19 Reviewed-by: Lars Knoll --- src/widgets/kernel/qwidget.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 70839e705f..f02a67d9ea 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -6730,7 +6730,6 @@ void QWidget::setContentsMargins(int left, int top, int right, int bottom) else updateGeometry(); - // ### Qt 5: compat, remove if (isVisible()) { update(); QResizeEvent e(data->crect.size(), data->crect.size()); -- cgit v1.2.3 From a9cda515177db1615f8d47becf2aa781f26955ae Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Sun, 8 Apr 2012 11:58:30 +0200 Subject: Fixes a regression; missing cursor blink when input mask is set. I can't say for sure why q*linecontrol passes an empty rect to the updateNeeded() signal when an input mask is set; presumably the empty rect at some point has meant "full update", but there are a few problems with this. Surely a full update is wrong, even if the semantics have been lost in translation somewhere (likely the qlinecontrol refactoring). This fix ensures that empty rects from updateNeeded() are interpreted as a request to update the whole widget. A further improvement would be to ensure the line control doesn't request a full update when an input mask is set. The cursor is usually wider when a mask is set but because of QLineEdit::paintEvent()'s implementation, there is currently a mismatch between the cursor width as seen by q*linecontrol and what is actually drawn, which causes rendering artifacts if updateNeeded() sends the cursorRect(). Since QLineEdit and Q*LineControl aren't actively developed, it's best to keep this fix minimal, although the performance cost of updating the whole line edit when an input mask is set is unfortunate. Task-number: QTBUG-7174 Change-Id: Ie51e015d760915e07b0220b770f04fc958d93a12 Reviewed-by: Andy Shaw Reviewed-by: Girish Ramakrishnan --- src/widgets/widgets/qlineedit_p.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp index 6cee96e717..d1c374a6ca 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -62,9 +62,10 @@ const int QLineEditPrivate::horizontalMargin(2); QRect QLineEditPrivate::adjustedControlRect(const QRect &rect) const { + QRect widgetRect = !rect.isEmpty() ? rect : q_func()->rect(); QRect cr = adjustedContentsRect(); int cix = cr.x() - hscroll + horizontalMargin; - return rect.translated(QPoint(cix, vscroll)); + return widgetRect.translated(QPoint(cix, vscroll)); } int QLineEditPrivate::xToPos(int x, QTextLine::CursorPosition betweenOrOn) const -- cgit v1.2.3 From 0ac019111137b13788468ddb3c020302f1a25038 Mon Sep 17 00:00:00 2001 From: Alberto Mardegan Date: Sun, 18 Dec 2011 19:19:29 +0200 Subject: Fix QScroller diagonal scrolling Compute the time needed for the scrolling operation before computing the movement on the X and Y components. This ensures (except when overshooting or snapping to snap points) that the scrolling on the X and Y components takes the same time. That is, scrolling occurs always along a straight line. Task-number: QTBUG-23227 Change-Id: Ic3b78b8611dbcbf19711c3dd96485a0d53accaed Reviewed-by: Robin Burchell --- src/widgets/util/qscroller.cpp | 63 ++++++++++++++++++++++++++---------------- src/widgets/util/qscroller_p.h | 5 +++- 2 files changed, 43 insertions(+), 25 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/util/qscroller.cpp b/src/widgets/util/qscroller.cpp index 4482134c7b..e39ed9c0a5 100644 --- a/src/widgets/util/qscroller.cpp +++ b/src/widgets/util/qscroller.cpp @@ -58,6 +58,7 @@ #include #include #include +#include #include #include #include @@ -1160,11 +1161,10 @@ void QScrollerPrivate::recalcScrollingSegments(bool forceRecalc) releaseVelocity = q->velocity(); - if (forceRecalc || !scrollingSegmentsValid(Qt::Horizontal)) - createScrollingSegments(releaseVelocity.x(), contentPosition.x() + overshootPosition.x(), ppm.x(), Qt::Horizontal); - - if (forceRecalc || !scrollingSegmentsValid(Qt::Vertical)) - createScrollingSegments(releaseVelocity.y(), contentPosition.y() + overshootPosition.y(), ppm.y(), Qt::Vertical); + if (forceRecalc || + !scrollingSegmentsValid(Qt::Horizontal) || + !scrollingSegmentsValid(Qt::Vertical)) + createScrollingSegments(releaseVelocity, contentPosition + overshootPosition, ppm); } /*! \internal @@ -1256,7 +1256,9 @@ void QScrollerPrivate::createScrollToSegments(qreal v, qreal deltaTime, qreal en /*! \internal */ -void QScrollerPrivate::createScrollingSegments(qreal v, qreal startPos, qreal ppm, Qt::Orientation orientation) +void QScrollerPrivate::createScrollingSegments(qreal v, qreal startPos, + qreal deltaTime, qreal deltaPos, + Qt::Orientation orientation) { const QScrollerPropertiesPrivate *sp = properties.d.data(); @@ -1287,22 +1289,6 @@ void QScrollerPrivate::createScrollingSegments(qreal v, qreal startPos, qreal pp qScrollerDebug() << "v = " << v << ", decelerationFactor = " << sp->decelerationFactor << ", curveType = " << sp->scrollingCurve.type(); - // This is only correct for QEasingCurve::OutQuad (linear velocity, - // constant deceleration), but the results look and feel ok for OutExpo - // and OutSine as well - - // v(t) = deltaTime * a * 0.5 * differentialForProgress(t / deltaTime) - // v(0) = vrelease - // v(deltaTime) = 0 - // deltaTime = (2 * vrelease) / (a * differntial(0)) - - // pos(t) = integrate(v(t)dt) - // pos(t) = vrelease * t - 0.5 * a * t * t - // pos(t) = deltaTime * a * 0.5 * progress(t / deltaTime) * deltaTime - // deltaPos = pos(deltaTime) - - qreal deltaTime = (qreal(2) * qAbs(v)) / (sp->decelerationFactor * differentialForProgress(sp->scrollingCurve, 0)); - qreal deltaPos = qSign(v) * deltaTime * deltaTime * qreal(0.5) * sp->decelerationFactor * ppm; qreal endPos = startPos + deltaPos; qScrollerDebug() << " Real Delta:" << deltaPos; @@ -1414,6 +1400,36 @@ void QScrollerPrivate::createScrollingSegments(qreal v, qreal startPos, qreal pp } +void QScrollerPrivate::createScrollingSegments(const QPointF &v, + const QPointF &startPos, + const QPointF &ppm) +{ + const QScrollerPropertiesPrivate *sp = properties.d.data(); + + // This is only correct for QEasingCurve::OutQuad (linear velocity, + // constant deceleration), but the results look and feel ok for OutExpo + // and OutSine as well + + // v(t) = deltaTime * a * 0.5 * differentialForProgress(t / deltaTime) + // v(0) = vrelease + // v(deltaTime) = 0 + // deltaTime = (2 * vrelease) / (a * differntial(0)) + + // pos(t) = integrate(v(t)dt) + // pos(t) = vrelease * t - 0.5 * a * t * t + // pos(t) = deltaTime * a * 0.5 * progress(t / deltaTime) * deltaTime + // deltaPos = pos(deltaTime) + + QVector2D vel(v); + qreal deltaTime = (qreal(2) * vel.length()) / (sp->decelerationFactor * differentialForProgress(sp->scrollingCurve, 0)); + QPointF deltaPos = (vel.normalized() * QVector2D(ppm)).toPointF() * deltaTime * deltaTime * qreal(0.5) * sp->decelerationFactor; + + createScrollingSegments(v.x(), startPos.x(), deltaTime, deltaPos.x(), + Qt::Horizontal); + createScrollingSegments(v.y(), startPos.y(), deltaTime, deltaPos.y(), + Qt::Vertical); +} + /*! \internal Prepares scrolling by sending a QScrollPrepareEvent to the receiver widget. Returns true if the scrolling was accepted and a target was returned. @@ -1650,8 +1666,7 @@ bool QScrollerPrivate::releaseWhileDragging(const QPointF &position, qint64 time } QPointF ppm = q->pixelPerMeter(); - createScrollingSegments(releaseVelocity.x(), contentPosition.x() + overshootPosition.x(), ppm.x(), Qt::Horizontal); - createScrollingSegments(releaseVelocity.y(), contentPosition.y() + overshootPosition.y(), ppm.y(), Qt::Vertical); + createScrollingSegments(releaseVelocity, contentPosition + overshootPosition, ppm); qScrollerDebug() << "QScroller::releaseWhileDragging() -- velocity:" << releaseVelocity << "-- minimum velocity:" << sp->minimumVelocity << "overshoot" << overshootPosition; diff --git a/src/widgets/util/qscroller_p.h b/src/widgets/util/qscroller_p.h index 6463f03573..26bd64461f 100644 --- a/src/widgets/util/qscroller_p.h +++ b/src/widgets/util/qscroller_p.h @@ -131,7 +131,10 @@ public: qreal scrollingSegmentsEndPos(Qt::Orientation orientation) const; bool scrollingSegmentsValid(Qt::Orientation orientation); void createScrollToSegments(qreal v, qreal deltaTime, qreal endPos, Qt::Orientation orientation, ScrollType type); - void createScrollingSegments(qreal v, qreal startPos, qreal ppm, Qt::Orientation orientation); + void createScrollingSegments(qreal v, qreal startPos, + qreal deltaTime, qreal deltaPos, + Qt::Orientation orientation); + void createScrollingSegments(const QPointF &v, const QPointF &startPos, const QPointF &ppm); void setContentPositionHelperDragging(const QPointF &deltaPos); void setContentPositionHelperScrolling(); -- cgit v1.2.3 From 011b88a7b37680288944bde2c4769fd203ee8218 Mon Sep 17 00:00:00 2001 From: Alberto Mardegan Date: Sun, 18 Dec 2011 19:12:42 +0200 Subject: Compute overshoot condition before snap points Snap points are not needed if the overshoot condition is met; therefore, move the overshoot handling before the computation of snap points. Change-Id: I37556b10c1b1124eaed53b0f2a330085acf70776 Reviewed-by: Robin Burchell --- src/widgets/util/qscroller.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/util/qscroller.cpp b/src/widgets/util/qscroller.cpp index e39ed9c0a5..2c8b617761 100644 --- a/src/widgets/util/qscroller.cpp +++ b/src/widgets/util/qscroller.cpp @@ -1293,6 +1293,16 @@ void QScrollerPrivate::createScrollingSegments(qreal v, qreal startPos, qScrollerDebug() << " Real Delta:" << deltaPos; + // -- check if are in overshoot and end in overshoot + if ((startPos < minPos && endPos < minPos) || + (startPos > maxPos && endPos > maxPos)) { + qreal stopPos = endPos < minPos ? minPos : maxPos; + qreal oDeltaTime = sp->overshootScrollTime; + + pushSegment(ScrollTypeOvershoot, oDeltaTime * qreal(0.7), qreal(1.0), startPos, stopPos - startPos, stopPos, sp->scrollingCurve.type(), orientation); + return; + } + // -- determine snap points qreal nextSnap = nextSnapPos(endPos, 0, orientation); qreal lowerSnapPos = nextSnapPos(startPos, -1, orientation); @@ -1306,16 +1316,6 @@ void QScrollerPrivate::createScrollingSegments(qreal v, qreal startPos, if (nextSnap < lowerSnapPos || qIsNaN(lowerSnapPos)) lowerSnapPos = nextSnap; - // -- check if are in overshoot and end in overshoot - if ((startPos < minPos && endPos < minPos) || - (startPos > maxPos && endPos > maxPos)) { - qreal stopPos = endPos < minPos ? minPos : maxPos; - qreal oDeltaTime = sp->overshootScrollTime; - - pushSegment(ScrollTypeOvershoot, oDeltaTime * qreal(0.7), qreal(1.0), startPos, stopPos - startPos, stopPos, sp->scrollingCurve.type(), orientation); - return; - } - if (qAbs(v) < sp->minimumVelocity) { qScrollerDebug() << "### below minimum Vel" << orientation; -- cgit v1.2.3 From b53ea6973102e3ec2a7c84da3496b61d01070b99 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Wed, 11 Apr 2012 22:06:05 -0700 Subject: qss: fix parsing of icon style hints Use cssIconValueToIcon (see 5a0eb4e768435b9ce32b074e620fca33be4df2fb) to retrieve the QIcon value from the css parser. Task-number: QTBUG-25120 Change-Id: Ie7c6691514a4b35d416ca09ccf7966689de831c1 Reviewed-by: Friedemann Kleint --- src/widgets/styles/qstylesheetstyle.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 0e928b13c2..89e8f59315 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -991,9 +991,8 @@ QRenderRule::QRenderRule(const QVector &declarations, const QWidget hintValue = (int) decl.colorValue().rgba(); } else if (hintName.endsWith(QLatin1String("size"))) { hintValue = decl.sizeValue(); - // ### Qt5 -// } else if (hintName.endsWith(QLatin1String("icon"))) { -// hintValue = decl.iconValue(); + } else if (hintName.endsWith(QLatin1String("icon"))) { + hintValue = cssIconValueToIcon(decl.iconValue()); } else if (hintName == QLatin1String("button-layout") && decl.d->values.count() != 0 && decl.d->values.at(0).type == Value::String) { hintValue = subControlLayout(decl.d->values.at(0).variant.toString()); -- cgit v1.2.3 From 0734979976ecd12d9849bb31f67c527dca453dfc Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Thu, 12 Apr 2012 00:44:29 +1000 Subject: Remove Qt 5 to-do comment that will not be addressed. Task-number: QTBUG-25093 Change-Id: Ib78cffe06f721371ff5c16e24db3abae6dcd4984 Reviewed-by: Lars Knoll --- src/widgets/graphicsview/qgraphicswidget.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/graphicsview/qgraphicswidget.h b/src/widgets/graphicsview/qgraphicswidget.h index e0bb591231..01e3efcc58 100644 --- a/src/widgets/graphicsview/qgraphicswidget.h +++ b/src/widgets/graphicsview/qgraphicswidget.h @@ -171,7 +171,6 @@ public: void dumpFocusChain(); #endif - // ### Qt 5: Disambiguate #ifdef Q_NO_USING_KEYWORD const QObjectList &children() const { return QObject::children(); } #else -- cgit v1.2.3 From 0b2a10dce5bab23f4152a671b090ff7b57020578 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Thu, 12 Apr 2012 02:15:57 +1000 Subject: Remove a Qt 5 to-do comment that will not be addressed. Task-number: QTBUG-25102 Change-Id: I3fe1878adcf17cb95209df271d062e126e32a8fd Reviewed-by: Lars Knoll --- src/widgets/widgets/qtabbar.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp index 8263bf8546..f4d289241a 100644 --- a/src/widgets/widgets/qtabbar.cpp +++ b/src/widgets/widgets/qtabbar.cpp @@ -1299,7 +1299,6 @@ static QString computeElidedText(Qt::TextElideMode mode, const QString &text) QSize QTabBarPrivate::minimumTabSizeHint(int index) { Q_Q(QTabBar); - // ### Qt 5: make this a protected virtual function in QTabBar Tab &tab = tabList[index]; QString oldText = tab.text; tab.text = computeElidedText(elideMode, oldText); -- cgit v1.2.3 From dd2429551ed6fee49f092001c58b953e72d139c3 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Wed, 11 Apr 2012 19:42:54 -0700 Subject: Remove QWidget::setWindowHandle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's unused. The window (QWidgetWindow) is created and managed implicitly by QWidget. Change-Id: I28ee3f120a99c877f318e1abd7d73c9f3e542d03 Reviewed-by: Samuel Rødal --- src/widgets/kernel/qwidget.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h index 78b693c78d..64042ccc36 100644 --- a/src/widgets/kernel/qwidget.h +++ b/src/widgets/kernel/qwidget.h @@ -607,7 +607,6 @@ public: QBackingStore *backingStore() const; - void setWindowHandle(QWindow *window); QWindow *windowHandle() const; friend class QDesktopScreenWidget; -- cgit v1.2.3 From 93c960876af2aebc265ffe3ddc12a24325fc512e Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Wed, 11 Apr 2012 19:31:39 -0700 Subject: Remove redundant platformNativeInterface() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit platformNativeInterface() is already defined in QGuiApplication. Change-Id: Ice720fb6f7e4b01c4627219d66a5a3c8980a79a5 Reviewed-by: Samuel Rødal --- src/widgets/kernel/qapplication.h | 2 -- src/widgets/kernel/qapplication_qpa.cpp | 6 ------ 2 files changed, 8 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qapplication.h b/src/widgets/kernel/qapplication.h index 3e11db0863..31d228ddd5 100644 --- a/src/widgets/kernel/qapplication.h +++ b/src/widgets/kernel/qapplication.h @@ -175,8 +175,6 @@ public: static bool isEffectEnabled(Qt::UIEffect); static void setEffectEnabled(Qt::UIEffect, bool enable = true); - static QPlatformNativeInterface *platformNativeInterface(); - #ifndef QT_NO_SESSIONMANAGER // session management bool isSessionRestored() const; diff --git a/src/widgets/kernel/qapplication_qpa.cpp b/src/widgets/kernel/qapplication_qpa.cpp index 92b831101f..fa84e86f29 100644 --- a/src/widgets/kernel/qapplication_qpa.cpp +++ b/src/widgets/kernel/qapplication_qpa.cpp @@ -437,12 +437,6 @@ void QApplication::alert(QWidget *, int) { } -QPlatformNativeInterface *QApplication::platformNativeInterface() -{ - QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration(); - return pi->nativeInterface(); -} - void qt_init(QApplicationPrivate *priv, int type) { Q_UNUSED(priv); -- cgit v1.2.3 From e583ce4103e925ec7ef832d2c9e88979bc04d56c Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Wed, 11 Apr 2012 22:38:15 -0700 Subject: remove references to qws from backingstore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The backingstore code is already hard to read as-is. Let's simplify things by removing qws code. Change-Id: Ibefd3ea17d29970d1f7348461959fdc5b01c1f42 Reviewed-by: Samuel Rødal --- src/widgets/kernel/qwidgetbackingstore.cpp | 46 +----------------------------- src/widgets/kernel/qwidgetbackingstore_p.h | 11 ------- 2 files changed, 1 insertion(+), 56 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp index b331356e66..ef4483195e 100644 --- a/src/widgets/kernel/qwidgetbackingstore.cpp +++ b/src/widgets/kernel/qwidgetbackingstore.cpp @@ -57,11 +57,6 @@ #include #include -#ifdef Q_WS_QWS -#include -#include -#endif - QT_BEGIN_NAMESPACE extern QRegion qt_dirtyRegion(QWidget *); @@ -153,13 +148,6 @@ static void showYellowThing_win(QWidget *widget, const QRegion ®ion, int msec void QWidgetBackingStore::showYellowThing(QWidget *widget, const QRegion &toBePainted, int msec, bool unclipped) { -#ifdef Q_WS_QWS - Q_UNUSED(widget); - Q_UNUSED(unclipped); - static QWSYellowSurface surface(true); - surface.setDelay(msec); - surface.flush(widget, toBePainted, QPoint()); -#else QRegion paintRegion = toBePainted; QRect widgetRect = widget->rect(); @@ -224,7 +212,6 @@ void QWidgetBackingStore::showYellowThing(QWidget *widget, const QRegion &toBePa ::usleep(1000 * msec); #endif #endif // Q_WS_WIN -#endif // Q_WS_QWS } bool QWidgetBackingStore::flushPaint(QWidget *widget, const QRegion &rgn) @@ -633,7 +620,7 @@ void QWidgetBackingStore::markDirtyOnScreen(const QRegion ®ion, QWidget *widg if (!widget || widget->d_func()->paintOnScreen() || region.isEmpty()) return; -#if defined(Q_WS_QWS) || defined(Q_WS_MAC) +#if defined(Q_WS_MAC) if (!widget->testAttribute(Qt::WA_WState_InPaintEvent)) dirtyOnScreen += region.translated(topLevelOffset); return; @@ -751,11 +738,6 @@ void QWidgetPrivate::moveRect(const QRect &rect, int dx, int dy) QPoint toplevelOffset = pw->mapTo(tlw, QPoint()); QWidgetPrivate *pd = pw->d_func(); QRect clipR(pd->clipRect()); -#ifdef Q_WS_QWS - QWidgetBackingStore *wbs = x->backingStore.data(); - QWSWindowSurface *surface = static_cast(wbs->windowSurface); - clipR = clipR.intersected(surface->clipRegion().translated(-toplevelOffset).boundingRect()); -#endif const QRect newRect(rect.translated(dx, dy)); QRect destRect = rect.intersected(clipR); if (destRect.isValid()) @@ -839,26 +821,6 @@ void QWidgetPrivate::scrollRect(const QRect &rect, int dx, int dy) bool accelerateScroll = accelEnv && isOpaque && !(overlapped = isOverlapped(scrollRect.translated(data.crect.topLeft()))); -#if defined(Q_WS_QWS) - QWSWindowSurface *surface; - surface = static_cast(wbs->windowSurface); - - if (accelerateScroll && !surface->isBuffered()) { - const QRegion surfaceClip = surface->clipRegion(); - const QRegion outsideClip = QRegion(rect) - surfaceClip; - if (!outsideClip.isEmpty()) { - const QVector clipped = (surfaceClip & rect).rects(); - if (clipped.size() < 8) { - for (int i = 0; i < clipped.size(); ++i) - this->scrollRect(clipped.at(i), dx, dy); - return; - } else { - accelerateScroll = false; - } - } - } -#endif // Q_WS_QWS - if (!accelerateScroll) { if (overlapped) { QRegion region(scrollRect); @@ -869,12 +831,6 @@ void QWidgetPrivate::scrollRect(const QRect &rect, int dx, int dy) } } else { const QPoint toplevelOffset = q->mapTo(tlw, QPoint()); -#ifdef Q_WS_QWS - QWSWindowSurface *surface = static_cast(wbs->windowSurface); - const QRegion clip = surface->clipRegion().translated(-toplevelOffset) & scrollRect; - const QRect clipBoundingRect = clip.boundingRect(); - scrollRect &= clipBoundingRect; -#endif const QRect destRect = scrollRect.translated(dx, dy) & scrollRect; const QRect sourceRect = destRect.translated(-dx, -dy); diff --git a/src/widgets/kernel/qwidgetbackingstore_p.h b/src/widgets/kernel/qwidgetbackingstore_p.h index 7befdbeb78..56c2547d3e 100644 --- a/src/widgets/kernel/qwidgetbackingstore_p.h +++ b/src/widgets/kernel/qwidgetbackingstore_p.h @@ -87,9 +87,6 @@ public: { return !(dirtyWidgets.isEmpty() && dirty.isEmpty() && !hasDirtyFromPreviousSync && !fullUpdatePending -#if defined(Q_WS_QWS) && !defined(QT_NO_QWS_MANAGER) - && !hasDirtyWindowDecoration() -#endif ); } @@ -130,10 +127,6 @@ private: void removeDirtyWidget(QWidget *w); -#if defined(Q_WS_QWS) && !defined(QT_NO_QWS_MANAGER) - bool hasDirtyWindowDecoration() const; - void paintWindowDecoration(); -#endif void updateLists(QWidget *widget); inline void addDirtyWidget(QWidget *widget, const QRegion &rgn) @@ -199,11 +192,7 @@ private: inline QRect topLevelRect() const { -#ifdef Q_WS_QWS - return tlw->frameGeometry(); -#else return tlw->data->crect; -#endif } inline void appendDirtyOnScreenWidget(QWidget *widget) -- cgit v1.2.3 From 40a1e8eccf42dad9ff70ad54658abcfc9bf896ae Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Wed, 11 Apr 2012 22:42:41 -0700 Subject: Remove hasDirtyFromPreviousSync from backingstore. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's always false (used to be some qws specific variable). Change-Id: I3dc185dba4c778797f180410ce8d293336ecfd9c Reviewed-by: Samuel Rødal --- src/widgets/kernel/qwidgetbackingstore.cpp | 6 +----- src/widgets/kernel/qwidgetbackingstore_p.h | 5 +---- 2 files changed, 2 insertions(+), 9 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp index ef4483195e..f9361cc357 100644 --- a/src/widgets/kernel/qwidgetbackingstore.cpp +++ b/src/widgets/kernel/qwidgetbackingstore.cpp @@ -696,8 +696,7 @@ void QWidgetBackingStore::updateLists(QWidget *cur) } QWidgetBackingStore::QWidgetBackingStore(QWidget *topLevel) - : tlw(topLevel), dirtyOnScreenWidgets(0), hasDirtyFromPreviousSync(false) - , fullUpdatePending(0) + : tlw(topLevel), dirtyOnScreenWidgets(0), fullUpdatePending(0) { store = tlw->backingStore(); Q_ASSERT(store); @@ -982,9 +981,6 @@ void QWidgetBackingStore::sync() if (updatesDisabled) return; - if (hasDirtyFromPreviousSync) - dirty += dirtyFromPreviousSync; - // Contains everything that needs repaint. QRegion toClean(dirty); diff --git a/src/widgets/kernel/qwidgetbackingstore_p.h b/src/widgets/kernel/qwidgetbackingstore_p.h index 56c2547d3e..7c350932ea 100644 --- a/src/widgets/kernel/qwidgetbackingstore_p.h +++ b/src/widgets/kernel/qwidgetbackingstore_p.h @@ -85,9 +85,7 @@ public: inline bool isDirty() const { - return !(dirtyWidgets.isEmpty() && dirty.isEmpty() && !hasDirtyFromPreviousSync - && !fullUpdatePending - ); + return !(dirtyWidgets.isEmpty() && dirty.isEmpty() && !fullUpdatePending); } // ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore). @@ -105,7 +103,6 @@ private: QVector *dirtyOnScreenWidgets; QList staticWidgets; QBackingStore *store; - uint hasDirtyFromPreviousSync : 1; uint fullUpdatePending : 1; QPoint tlwOffset; -- cgit v1.2.3 From e9ab2dabf9827b36cb83e1e83a955866190da08d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 12 Apr 2012 16:50:52 +0200 Subject: Fix MinGW warning about qDebug() formats. Change-Id: I927d17240a7cc7b88814601b0711aa46ca166ff9 Reviewed-by: Friedemann Kleint --- src/widgets/styles/qwindowsxpstyle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index 336d93e8c1..67895980b2 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -323,7 +323,7 @@ void QWindowsXPStylePrivate::cleanupHandleMap() HTHEME QWindowsXPStylePrivate::createTheme(int theme, HWND hwnd) { if (theme < 0 || theme >= NThemes || !hwnd) { - qWarning("%s: Invalid parameters #%d, %p", theme, hwnd); + qWarning("%s: Invalid parameters #%d, %p", Q_FUNC_INFO, theme, hwnd); return 0; } if (!m_themes[theme]) { -- cgit v1.2.3 From b317fe2a606e5b79f24b1e4a1b808f5ff66d3621 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Wed, 11 Apr 2012 23:46:41 +1000 Subject: Merge the two overloads of QButtonGroup::addButton(). This change is source-compatible, but binary-incompatible. Task-number: QTBUG-25101 Change-Id: If67aec2ca8dd54ad9315f6497c2dafbbbc0b775f Reviewed-by: Lars Knoll --- src/widgets/widgets/qabstractbutton.cpp | 6 ------ src/widgets/widgets/qbuttongroup.cpp | 21 ++++++--------------- src/widgets/widgets/qbuttongroup.h | 3 +-- 3 files changed, 7 insertions(+), 23 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qabstractbutton.cpp b/src/widgets/widgets/qabstractbutton.cpp index 5f75bd3913..4e85eae3ff 100644 --- a/src/widgets/widgets/qabstractbutton.cpp +++ b/src/widgets/widgets/qabstractbutton.cpp @@ -219,12 +219,6 @@ void QButtonGroup::setExclusive(bool exclusive) } -// TODO: Qt 5: Merge with addButton(QAbstractButton *button, int id) -void QButtonGroup::addButton(QAbstractButton *button) -{ - addButton(button, -1); -} - void QButtonGroup::addButton(QAbstractButton *button, int id) { Q_D(QButtonGroup); diff --git a/src/widgets/widgets/qbuttongroup.cpp b/src/widgets/widgets/qbuttongroup.cpp index 381e32d96b..a5e96370cf 100644 --- a/src/widgets/widgets/qbuttongroup.cpp +++ b/src/widgets/widgets/qbuttongroup.cpp @@ -175,22 +175,13 @@ */ /*! - \fn void QButtonGroup::addButton(QAbstractButton *button); + \fn void QButtonGroup::addButton(QAbstractButton *button, int id = -1); - Adds the given \a button to the end of the group's internal list - of buttons. An id will be assigned to the button by this - QButtonGroup. Automatically assigned ids are guaranteed to be - negative, starting with -2. If you are also assigning your own - ids, use positive values to avoid conflicts. - - \sa removeButton() buttons() -*/ - -/*! - \fn void QButtonGroup::addButton(QAbstractButton *button, int id); - - Adds the given \a button to the button group, with the given \a - id. It is recommended to assign only positive ids. + Adds the given \a button to the button group. If \a id is -1, + an id will be assigned to the button by this QButtonGroup. + Automatically assigned ids are guaranteed to be negative, + starting with -2. If you are assigning your own ids, use + positive values to avoid conflicts. \sa removeButton() buttons() */ diff --git a/src/widgets/widgets/qbuttongroup.h b/src/widgets/widgets/qbuttongroup.h index e24ac8bbc3..46275d9f04 100644 --- a/src/widgets/widgets/qbuttongroup.h +++ b/src/widgets/widgets/qbuttongroup.h @@ -67,8 +67,7 @@ public: void setExclusive(bool); bool exclusive() const; - void addButton(QAbstractButton *); - void addButton(QAbstractButton *, int id); + void addButton(QAbstractButton *, int id = -1); void removeButton(QAbstractButton *); QList buttons() const; -- cgit v1.2.3 From 9fd2edb6da5f1f6d644cd7c3f35aebe3e88beee2 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Thu, 12 Apr 2012 18:21:39 +0300 Subject: replace hardcoded values with a surrogate handling methods Change-Id: Ib41e08d835f2e8ca2e32b4025c6f5a99840f2e27 Reviewed-by: Oswald Buddenhagen Reviewed-by: Lars Knoll --- src/widgets/widgets/qwidgetlinecontrol.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index c9300d3cdd..017cbee219 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -103,11 +103,11 @@ void QWidgetLineControl::updateDisplayText(bool forceUpdate) int cursor = m_cursor - 1; QChar uc = m_text.at(cursor); str[cursor] = uc; - if (cursor > 0 && uc.unicode() >= 0xdc00 && uc.unicode() < 0xe000) { + if (cursor > 0 && uc.isLowSurrogate()) { // second half of a surrogate, check if we have the first half as well, // if yes restore both at once uc = m_text.at(cursor - 1); - if (uc.unicode() >= 0xd800 && uc.unicode() < 0xdc00) + if (uc.isHighSurrogate()) str[cursor - 1] = uc; } } @@ -220,11 +220,11 @@ void QWidgetLineControl::backspace() if (m_maskData) m_cursor = prevMaskBlank(m_cursor); QChar uc = m_text.at(m_cursor); - if (m_cursor > 0 && uc.unicode() >= 0xdc00 && uc.unicode() < 0xe000) { + if (m_cursor > 0 && uc.isLowSurrogate()) { // second half of a surrogate, check if we have the first half as well, // if yes delete both at once uc = m_text.at(m_cursor - 1); - if (uc.unicode() >= 0xd800 && uc.unicode() < 0xdc00) { + if (uc.isHighSurrogate()) { internalDelete(true); --m_cursor; } -- cgit v1.2.3 From eb52d31ddf59d43c2f8cd1e85613b60213fd6696 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Fri, 20 Jan 2012 19:07:54 +0100 Subject: Update accessibility selections in QTextControl. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Forwardport from Qt 4. Change-Id: Iae0c2792b64b8ec2736a9ff621cf7c313a394093 Reviewed-by: Jan-Arve Sæther (cherry picked from commit d5649547d641b9c5af3c3f814caf8e1ab5bf9f47) --- src/widgets/widgets/qwidgettextcontrol.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index d602d6daa5..91864b6608 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -79,6 +79,7 @@ #include #include #include +#include #ifndef QT_NO_SHORTCUT #include "private/qapplication_p.h" @@ -577,8 +578,15 @@ void QWidgetTextControlPrivate::repaintOldAndNewSelection(const QTextCursor &old void QWidgetTextControlPrivate::selectionChanged(bool forceEmitSelectionChanged /*=false*/) { Q_Q(QWidgetTextControl); - if (forceEmitSelectionChanged) + if (forceEmitSelectionChanged) { emit q->selectionChanged(); +#ifndef QT_NO_ACCESSIBILITY + if (q->parent()) { + QAccessibleTextSelectionEvent ev(q->parent(), cursor.anchor(), cursor.position()); + QAccessible::updateAccessibility(&ev); + } +#endif + } if (cursor.position() == lastSelectionPosition && cursor.anchor() == lastSelectionAnchor) @@ -593,9 +601,15 @@ void QWidgetTextControlPrivate::selectionChanged(bool forceEmitSelectionChanged && (selectionStateChange || (cursor.hasSelection() && (cursor.position() != lastSelectionPosition - || cursor.anchor() != lastSelectionAnchor)))) + || cursor.anchor() != lastSelectionAnchor)))) { emit q->selectionChanged(); - +#ifndef QT_NO_ACCESSIBILITY + if (q->parent()) { + QAccessibleTextSelectionEvent ev(q->parent(), cursor.anchor(), cursor.position()); + QAccessible::updateAccessibility(&ev); + } +#endif + } emit q->microFocusChanged(); lastSelectionPosition = cursor.position(); lastSelectionAnchor = cursor.anchor(); -- cgit v1.2.3 From 5cb2fbe088ee5b15c2a35ba175e3c39a2fac5c03 Mon Sep 17 00:00:00 2001 From: ABBAPOH Date: Sat, 25 Feb 2012 23:52:09 +0400 Subject: Now QSplitter can have 0-pixel handle Change-Id: Iad920ffcd5d7f4c01504d41d1740f130b7aa53dd Reviewed-by: Thiago Macieira Reviewed-by: Girish Ramakrishnan --- src/widgets/widgets/qsplitter.cpp | 8 ++++---- src/widgets/widgets/qsplitter_p.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp index 285099a4cb..44c450ca47 100644 --- a/src/widgets/widgets/qsplitter.cpp +++ b/src/widgets/widgets/qsplitter.cpp @@ -232,14 +232,14 @@ void QSplitterHandle::resizeEvent(QResizeEvent *event) { Q_D(const QSplitterHandle); - // When splitters are only 1 pixel large we increase the + // When splitters are only 1 or 0 pixel large we increase the // actual grab area to five pixels // Note that QSplitter uses contentsRect for layouting // and ensures that handles are drawn on top of widgets // We simply use the contents margins for draggin and only // paint the mask area - bool useTinyMode = (d->s->handleWidth() == 1); + bool useTinyMode = (d->s->handleWidth() <= 1); setAttribute(Qt::WA_MouseNoMask, useTinyMode); if (useTinyMode) { if (orientation() == Qt::Horizontal) @@ -1528,14 +1528,14 @@ void QSplitter::setSizes(const QList &list) By default, this property contains a value that depends on the user's platform and style preferences. - If you set handleWidth to 1, the actual grab area will grow to overlap a + If you set handleWidth to 1 or 0, the actual grab area will grow to overlap a few pixels of it's respective widgets. */ int QSplitter::handleWidth() const { Q_D(const QSplitter); - if (d->handleWidth > 0) { + if (d->handleWidth >= 0) { return d->handleWidth; } else { return style()->pixelMetric(QStyle::PM_SplitterWidth, 0, this); diff --git a/src/widgets/widgets/qsplitter_p.h b/src/widgets/widgets/qsplitter_p.h index c9db6ef9af..d9a0cdecb7 100644 --- a/src/widgets/widgets/qsplitter_p.h +++ b/src/widgets/widgets/qsplitter_p.h @@ -83,7 +83,7 @@ class QSplitterPrivate : public QFramePrivate Q_DECLARE_PUBLIC(QSplitter) public: QSplitterPrivate() : rubberBand(0), opaque(true), firstShow(true), - childrenCollapsible(true), compatMode(false), handleWidth(0), blockChildAdd(false) {} + childrenCollapsible(true), compatMode(false), handleWidth(-1), blockChildAdd(false) {} QPointer rubberBand; mutable QList list; -- cgit v1.2.3 From 83fc52e3b4005d946c731577f8f49becae948c39 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Mon, 2 Apr 2012 11:59:04 +0200 Subject: widgets: Fix painting to a fully transparent top level widget MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QWS used to have a line to change the composite mode from SourceOver to Source for the top level widget. This wasn't used with QPA and I removed the internal DontSetCompositionMode in qtbase. It turns out that the QWS way is the most efficient one to initialize the background of the widget. The alternative is to have the QPlatformBackingStore::beginPaint always clear the entire to be painted area and then paint the background of the widget. The difference of painting each pixel once or twice is noticable on embedded platforms and in the range of one to two fps. Reproduce the issue with: echo "QWidget {background: transparent}" > style.css ./examples/widgets/wiggly/wiggly -stylesheet style.css Task-number: QTBUG-24526 Change-Id: Ica4c980bb3bf6eb87ddb5b510ac7493292d01543 Reviewed-by: Samuel Rødal Reviewed-by: Girish Ramakrishnan --- src/widgets/kernel/qwidget.cpp | 12 +++++++++++- src/widgets/kernel/qwidget_p.h | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index f02a67d9ea..662c9b7403 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -2137,7 +2137,15 @@ void QWidgetPrivate::paintBackground(QPainter *painter, const QRegion &rgn, int if ((flags & DrawAsRoot) && !(q->autoFillBackground() && autoFillBrush.isOpaque())) { const QBrush bg = q->palette().brush(QPalette::Window); - fillRegion(painter, rgn, bg); + if (!(flags & DontSetCompositionMode)) { + //copy alpha straight in + QPainter::CompositionMode oldMode = painter->compositionMode(); + painter->setCompositionMode(QPainter::CompositionMode_Source); + fillRegion(painter, rgn, bg); + painter->setCompositionMode(oldMode); + } else { + fillRegion(painter, rgn, bg); + } } if (q->autoFillBackground()) @@ -5229,6 +5237,8 @@ void QWidgetPrivate::render(QPaintDevice *target, const QPoint &targetOffset, else flags |= DontSubtractOpaqueChildren; + flags |= DontSetCompositionMode; + if (target->devType() == QInternal::Printer) { QPainter p(target); render_helper(&p, targetOffset, paintRegion, renderFlags); diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index 8107b6ca74..d3fcdce6a8 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -284,7 +284,8 @@ public: DrawInvisible = 0x08, DontSubtractOpaqueChildren = 0x10, DontDrawOpaqueChildren = 0x20, - DontDrawNativeChildren = 0x40 + DontDrawNativeChildren = 0x40, + DontSetCompositionMode = 0x80 }; enum CloseMode { -- cgit v1.2.3 From 41673c45dde2eb95ee21dd918235218399f2be2c Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Sun, 15 Apr 2012 04:02:31 -0700 Subject: qmenu.h includes private headers qpa includes are considered private and should not be included in public header files. Change-Id: I26c744ec1d8ddef7b0c11c3d26b593be05f5aa54 Reviewed-by: Thiago Macieira --- src/widgets/widgets/qmenu.h | 2 +- src/widgets/widgets/qmenu_p.h | 2 ++ src/widgets/widgets/qmenubar.h | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qmenu.h b/src/widgets/widgets/qmenu.h index 1fa7195170..9f17d2e63c 100644 --- a/src/widgets/widgets/qmenu.h +++ b/src/widgets/widgets/qmenu.h @@ -46,7 +46,6 @@ #include #include #include -#include #ifdef Q_OS_WINCE #include // for HMENU @@ -61,6 +60,7 @@ QT_BEGIN_NAMESPACE class QMenuPrivate; class QStyleOptionMenuItem; +class QPlatformMenu; class Q_WIDGETS_EXPORT QMenu : public QWidget { diff --git a/src/widgets/widgets/qmenu_p.h b/src/widgets/widgets/qmenu_p.h index ee6e62653f..d637a9be8f 100644 --- a/src/widgets/widgets/qmenu_p.h +++ b/src/widgets/widgets/qmenu_p.h @@ -61,6 +61,8 @@ #include "QtCore/qbasictimer.h" #include "private/qwidget_p.h" +#include + QT_BEGIN_NAMESPACE #ifndef QT_NO_MENU diff --git a/src/widgets/widgets/qmenubar.h b/src/widgets/widgets/qmenubar.h index 9818526543..c1272c45ce 100644 --- a/src/widgets/widgets/qmenubar.h +++ b/src/widgets/widgets/qmenubar.h @@ -54,6 +54,7 @@ QT_BEGIN_NAMESPACE class QMenuBarPrivate; class QStyleOptionMenuItem; class QWindowsStyle; +class QPlatformMenuBar; class Q_WIDGETS_EXPORT QMenuBar : public QWidget { -- cgit v1.2.3