Merge "Merge remote-tracking branch 'origin/5.11' into dev" into refs/staging/dev

bb10
Liang Qi 2018-05-02 19:00:15 +00:00 committed by The Qt Project
commit f240efaa35
57 changed files with 494 additions and 278 deletions

View File

@ -893,7 +893,7 @@ void Renderer::buildFrame()
VkCommandBuffer cb = m_window->currentCommandBuffer();
const QSize sz = m_window->swapChainImageSize();
VkClearColorValue clearColor = { 0.67f, 0.84f, 0.9f, 1.0f };
VkClearColorValue clearColor = {{ 0.67f, 0.84f, 0.9f, 1.0f }};
VkClearDepthStencilValue clearDS = { 1, 0 };
VkClearValue clearValues[3];
memset(clearValues, 0, sizeof(clearValues));

View File

@ -768,7 +768,7 @@ void VulkanRenderer::startNextFrame()
// Add the necessary barriers and do the host-linear -> device-optimal copy, if not yet done.
ensureTexture();
VkClearColorValue clearColor = { 0, 0, 0, 1 };
VkClearColorValue clearColor = {{ 0, 0, 0, 1 }};
VkClearDepthStencilValue clearDS = { 1, 0 };
VkClearValue clearValues[2];
memset(clearValues, 0, sizeof(clearValues));

View File

@ -94,7 +94,7 @@ void VulkanRenderer::startNextFrame()
if (m_green > 1.0f)
m_green = 0.0f;
VkClearColorValue clearColor = { 0.0f, m_green, 0.0f, 1.0f };
VkClearColorValue clearColor = {{ 0.0f, m_green, 0.0f, 1.0f }};
VkClearDepthStencilValue clearDS = { 1.0f, 0 };
VkClearValue clearValues[2];
memset(clearValues, 0, sizeof(clearValues));

View File

@ -452,7 +452,7 @@ void TriangleRenderer::startNextFrame()
VkCommandBuffer cb = m_window->currentCommandBuffer();
const QSize sz = m_window->swapChainImageSize();
VkClearColorValue clearColor = { 0, 0, 0, 1 };
VkClearColorValue clearColor = {{ 0, 0, 0, 1 }};
VkClearDepthStencilValue clearDS = { 1, 0 };
VkClearValue clearValues[3];
memset(clearValues, 0, sizeof(clearValues));

View File

@ -28,9 +28,13 @@ CMAKE_OUT_DIR = $$MODULE_BASE_OUTDIR/lib/cmake
CMAKE_MODULE_NAME = $$cmakeModuleName($${MODULE})
!generated_privates {
isEmpty(SYNCQT.INJECTED_PRIVATE_HEADER_FILES):isEmpty(SYNCQT.PRIVATE_HEADER_FILES): \
CMAKE_NO_PRIVATE_INCLUDES = true
}
split_incpath {
CMAKE_ADD_SOURCE_INCLUDE_DIRS = true
CMAKE_NO_PRIVATE_INCLUDES = true # Don't add private includes in the build dir which don't exist
CMAKE_SOURCE_INCLUDES = \
$$cmakeTargetPaths($$QT_MODULE_INCLUDE_BASE $$QT_MODULE_INCLUDE_BASE/Qt$${CMAKE_MODULE_NAME})
CMAKE_SOURCE_PRIVATE_INCLUDES = \
@ -53,10 +57,6 @@ contains(CMAKE_INCLUDE_DIR, "^\\.\\./.*") {
CMAKE_INCLUDE_DIR_IS_ABSOLUTE = True
}
isEmpty(QT.$${MODULE}_private.includes)| \
!exists($$first(QT.$${MODULE}_private.includes)): \
CMAKE_NO_PRIVATE_INCLUDES = true
CMAKE_LIB_DIR = $$cmakeRelativePath($$[QT_INSTALL_LIBS], $$[QT_INSTALL_PREFIX])
contains(CMAKE_LIB_DIR,"^\\.\\./.*") {
CMAKE_LIB_DIR = $$[QT_INSTALL_LIBS]/

View File

@ -1603,7 +1603,17 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
}
}
t << "\t\t\t\t" << writeSettings("SYMROOT", Option::output_dir) << ";\n";
// The symroot is marked by xcodebuild as excluded from Time Machine
// backups, as it's a temporary build dir, so we don't want it to be
// the same as the possibe in-source dir, as that would leave out
// sources from being backed up.
t << "\t\t\t\t" << writeSettings("SYMROOT",
Option::output_dir + Option::dir_sep + ".xcode") << ";\n";
// The configuration build dir however is not treated as excluded,
// so we can safely point it to the root output dir.
t << "\t\t\t\t" << writeSettings("CONFIGURATION_BUILD_DIR",
Option::output_dir + Option::dir_sep + "$(CONFIGURATION)") << ";\n";
if (!project->isEmpty("DESTDIR")) {
ProString dir = project->first("DESTDIR");

View File

@ -1502,30 +1502,40 @@ bool QItemSelectionModel::isRowSelected(int row, const QModelIndex &parent) cons
&& d->currentSelection.at(i).intersected(d->ranges.at(j)).isValid())
return false;
}
auto isSelectable = [&](int row, int column) {
Qt::ItemFlags flags = d->model->index(row, column, parent).flags();
return (flags & Qt::ItemIsSelectable);
};
const int colCount = d->model->columnCount(parent);
int unselectable = 0;
// add ranges and currentSelection and check through them all
QList<QItemSelectionRange>::const_iterator it;
QList<QItemSelectionRange> joined = d->ranges;
if (d->currentSelection.count())
joined += d->currentSelection;
int colCount = d->model->columnCount(parent);
for (int column = 0; column < colCount; ++column) {
if (!isSelectable(row, column)) {
++unselectable;
continue;
}
for (it = joined.constBegin(); it != joined.constEnd(); ++it) {
if ((*it).contains(row, column, parent)) {
bool selectable = false;
for (int i = column; !selectable && i <= (*it).right(); ++i) {
Qt::ItemFlags flags = d->model->index(row, i, parent).flags();
selectable = flags & Qt::ItemIsSelectable;
}
if (selectable){
column = qMax(column, (*it).right());
break;
for (int i = column; i <= (*it).right(); ++i) {
if (!isSelectable(row, i))
++unselectable;
}
column = qMax(column, (*it).right());
break;
}
}
if (it == joined.constEnd())
return false;
}
return colCount > 0; // no columns means no selected items
return unselectable < colCount;
}
/*!
@ -1568,26 +1578,39 @@ bool QItemSelectionModel::isColumnSelected(int column, const QModelIndex &parent
}
}
}
auto isSelectable = [&](int row, int column) {
Qt::ItemFlags flags = d->model->index(row, column, parent).flags();
return (flags & Qt::ItemIsSelectable);
};
const int rowCount = d->model->rowCount(parent);
int unselectable = 0;
// add ranges and currentSelection and check through them all
QList<QItemSelectionRange>::const_iterator it;
QList<QItemSelectionRange> joined = d->ranges;
if (d->currentSelection.count())
joined += d->currentSelection;
int rowCount = d->model->rowCount(parent);
for (int row = 0; row < rowCount; ++row) {
for (it = joined.constBegin(); it != joined.constEnd(); ++it) {
if ((*it).contains(row, column, parent)) {
Qt::ItemFlags flags = d->model->index(row, column, parent).flags();
if ((flags & Qt::ItemIsSelectable) && (flags & Qt::ItemIsEnabled)) {
row = qMax(row, (*it).bottom());
break;
}
}
}
if (it == joined.constEnd())
return false;
if (!isSelectable(row, column)) {
++unselectable;
continue;
}
for (it = joined.constBegin(); it != joined.constEnd(); ++it) {
if ((*it).contains(row, column, parent)) {
for (int i = row; i <= (*it).bottom(); ++i) {
if (!isSelectable(i, column)) {
++unselectable;
}
}
row = qMax(row, (*it).bottom());
break;
}
}
if (it == joined.constEnd())
return false;
}
return rowCount > 0; // no rows means no selected items
return unselectable < rowCount;
}
/*!

View File

@ -311,9 +311,9 @@ static inline bool isTextFile(const QByteArray &data)
if (data.startsWith(bigEndianBOM) || data.startsWith(littleEndianBOM))
return true;
// Check the first 32 bytes (see shared-mime spec)
// Check the first 128 bytes (see shared-mime spec)
const char *p = data.constData();
const char *e = p + qMin(32, data.size());
const char *e = p + qMin(128, data.size());
for ( ; p < e; ++p) {
if ((unsigned char)(*p) < 32 && *p != 9 && *p !=10 && *p != 13)
return false;

View File

@ -181,6 +181,13 @@ int qDBusParametersForMethod(const QList<QByteArray> &parameterTypes, QVector<in
}
int id = QMetaType::type(type);
#ifdef QT_BOOTSTRAPPED
// in bootstrap mode QDBusMessage isn't included, thus we need to resolve it manually here
if (type == "QDBusMessage") {
id = QDBusMetaTypeId::message();
}
#endif
if (id == QMetaType::UnknownType) {
errorMsg = QLatin1String("Unregistered input type in parameter list: ") + QLatin1String(type);
return -1;

View File

@ -178,7 +178,9 @@ static void ensureInitialized()
it sends. It contains the proxy and cache configuration, as well as the
signals related to such issues, and reply signals that can be used to
monitor the progress of a network operation. One QNetworkAccessManager
should be enough for the whole Qt application.
instance should be enough for the whole Qt application. Since
QNetworkAccessManager is based on QObject, it can only be used from the
thread it belongs to.
Once a QNetworkAccessManager object has been created, the application can
use it to send requests over the network. A group of standard functions

View File

@ -241,6 +241,17 @@ QList<QNetworkCookie> QNetworkCookieJar::cookiesForUrl(const QUrl &url) const
if ((*it).isSecure() && !isEncrypted)
continue;
QString domain = it->domain();
if (domain.startsWith(QLatin1Char('.'))) /// Qt6?: remove when compliant with RFC6265
domain = domain.mid(1);
#if QT_CONFIG(topleveldomain)
if (qIsEffectiveTLD(domain) && url.host() != domain)
continue;
#else
if (!domain.contains(QLatin1Char('.')) && url.host() != domain)
continue;
#endif // topleveldomain
// insert this cookie into result, sorted by path
QList<QNetworkCookie>::Iterator insertIt = result.begin();
while (insertIt != result.end()) {
@ -340,6 +351,11 @@ bool QNetworkCookieJar::validateCookie(const QNetworkCookie &cookie, const QUrl
if (domain.startsWith(QLatin1Char('.')))
domain = domain.mid(1);
// We shouldn't reject if:
// "[...] the domain-attribute is identical to the canonicalized request-host"
// https://tools.ietf.org/html/rfc6265#section-5.3 step 5
if (host == domain)
return true;
#if QT_CONFIG(topleveldomain)
// the check for effective TLDs makes the "embedded dot" rule from RFC 2109 section 4.3.2
// redundant; the "leading dot" rule has been relaxed anyway, see QNetworkCookie::normalize()

View File

@ -314,6 +314,7 @@ NSCursor *QCocoaCursor::createCursorFromPixmap(const QPixmap pixmap, const QPoin
if (pixmap.devicePixelRatio() > 1.0) {
QSize layoutSize = pixmap.size() / pixmap.devicePixelRatio();
QPixmap scaledPixmap = pixmap.scaled(layoutSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
scaledPixmap.setDevicePixelRatio(1.0);
nsimage = static_cast<NSImage *>(qt_mac_create_nsimage(scaledPixmap));
CGImageRef cgImage = qt_mac_toCGImage(pixmap.toImage());
NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] initWithCGImage:cgImage];

View File

@ -110,7 +110,9 @@
#include <qstyleoption.h>
#include <qtextedit.h>
#include <qtextstream.h>
#if QT_CONFIG(toolbar)
#include <qtoolbar.h>
#endif
#if QT_CONFIG(toolbutton)
#include <qtoolbutton.h>
#endif

View File

@ -75,7 +75,9 @@
#if QT_CONFIG(spinbox)
#include <qspinbox.h>
#endif
#if QT_CONFIG(toolbar)
#include <qtoolbar.h>
#endif
#if QT_CONFIG(combobox)
#include <qcombobox.h>
#endif

View File

@ -79,7 +79,9 @@
#if QT_CONFIG(pushbutton)
#include <qpushbutton.h>
#endif
#if QT_CONFIG(toolbar)
#include <qtoolbar.h>
#endif
#include <qlabel.h>
#include <qvarlengtharray.h>
#include <qdebug.h>
@ -3315,12 +3317,12 @@ int QWindowsXPStyle::pixelMetric(PixelMetric pm, const QStyleOption *option, con
res = 160;
break;
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
case PM_ToolBarHandleExtent:
res = int(QStyleHelper::dpiScaled(8.));
break;
#endif // QT_NO_TOOLBAR
#endif // QT_CONFIG(toolbar)
case PM_DockWidgetSeparatorExtent:
case PM_DockWidgetTitleMargin:
res = int(QStyleHelper::dpiScaled(4.));

View File

@ -45,11 +45,6 @@
QT_BEGIN_NAMESPACE
// hack
class QPrintDialogPrivate : public QAbstractPrintDialogPrivate
{
};
/*!
\class QAbstractPrintDialog
\brief The QAbstractPrintDialog class provides a base implementation for
@ -145,7 +140,7 @@ QAbstractPrintDialog::~QAbstractPrintDialog()
*/
void QPrintDialog::setOption(PrintDialogOption option, bool on)
{
Q_D(QPrintDialog);
auto *d = static_cast<QAbstractPrintDialogPrivate *>(d_ptr.data());
if (!(d->options & option) != !on)
setOptions(d->options ^ option);
}
@ -158,7 +153,7 @@ void QPrintDialog::setOption(PrintDialogOption option, bool on)
*/
bool QPrintDialog::testOption(PrintDialogOption option) const
{
Q_D(const QPrintDialog);
auto *d = static_cast<const QAbstractPrintDialogPrivate *>(d_ptr.data());
return (d->options & option) != 0;
}
@ -177,7 +172,7 @@ bool QPrintDialog::testOption(PrintDialogOption option) const
*/
void QPrintDialog::setOptions(PrintDialogOptions options)
{
Q_D(QPrintDialog);
auto *d = static_cast<QAbstractPrintDialogPrivate *>(d_ptr.data());
PrintDialogOptions changed = (options ^ d->options);
if (!changed)
@ -188,7 +183,7 @@ void QPrintDialog::setOptions(PrintDialogOptions options)
QPrintDialog::PrintDialogOptions QPrintDialog::options() const
{
Q_D(const QPrintDialog);
auto *d = static_cast<const QAbstractPrintDialogPrivate *>(d_ptr.data());
return d->options;
}
@ -464,7 +459,7 @@ void QAbstractPrintDialog::setOptionTabs(const QList<QWidget*> &tabs)
*/
void QPrintDialog::done(int result)
{
Q_D(QPrintDialog);
auto *d = static_cast<QAbstractPrintDialogPrivate *>(d_ptr.data());
QDialog::done(result);
if (result == Accepted)
emit accepted(printer());
@ -487,7 +482,7 @@ void QPrintDialog::done(int result)
*/
void QPrintDialog::open(QObject *receiver, const char *member)
{
Q_D(QPrintDialog);
auto *d = static_cast<QAbstractPrintDialogPrivate *>(d_ptr.data());
connect(this, SIGNAL(accepted(QPrinter*)), receiver, member);
d->receiverToDisconnectOnClose = receiver;
d->memberToDisconnectOnClose = member;

View File

@ -69,16 +69,15 @@ class QAbstractPrintDialogPrivate : public QDialogPrivate
public:
QAbstractPrintDialogPrivate()
: printer(nullptr), pd(nullptr), ownsPrinter(false)
: printer(nullptr), pd(nullptr)
, options(QAbstractPrintDialog::PrintToFile | QAbstractPrintDialog::PrintPageRange |
QAbstractPrintDialog::PrintCollateCopies | QAbstractPrintDialog::PrintShowPageSize),
minPage(0), maxPage(INT_MAX)
minPage(0), maxPage(INT_MAX), ownsPrinter(false)
{
}
QPrinter *printer;
QPrinterPrivate *pd;
bool ownsPrinter;
QPointer<QObject> receiverToDisconnectOnClose;
QByteArray memberToDisconnectOnClose;
@ -88,6 +87,8 @@ public:
void setPrinter(QPrinter *newPrinter);
int minPage;
int maxPage;
bool ownsPrinter;
};
QT_END_NAMESPACE

View File

@ -1559,8 +1559,6 @@ QFormLayout::TakeRowResult QFormLayout::takeRow(int row)
QFormLayoutItem *label = d->m_matrix(row, 0);
QFormLayoutItem *field = d->m_matrix(row, 1);
Q_ASSERT(field);
d->m_things.removeOne(label);
d->m_things.removeOne(field);
d->m_matrix.removeRow(row);

View File

@ -44,7 +44,9 @@
#if QT_CONFIG(menubar)
#include "qmenubar.h"
#endif
#if QT_CONFIG(toolbar)
#include "qtoolbar.h"
#endif
#if QT_CONFIG(sizegrip)
#include "qsizegrip.h"
#endif

View File

@ -44,7 +44,9 @@
#if QT_CONFIG(menubar)
#include "qmenubar.h"
#endif
#if QT_CONFIG(toolbar)
#include "qtoolbar.h"
#endif
#include "qevent.h"
#include "qstyle.h"
#include "qvariant.h"

View File

@ -237,6 +237,7 @@ bool QWidgetWindow::event(QEvent *event)
switch (event->type()) {
case QEvent::Close:
handleCloseEvent(static_cast<QCloseEvent *>(event));
QWindow::event(event);
return true;
case QEvent::Enter:

View File

@ -251,10 +251,10 @@ static QEvent *cloneEvent(QEvent *e)
return new QWhatsThisClickedEvent(*static_cast<QWhatsThisClickedEvent*>(e));
#endif // QT_CONFIG(whatsthis)
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
case QEvent::ToolBarChange:
return new QToolBarChangeEvent(*static_cast<QToolBarChangeEvent*>(e));
#endif //QT_NO_TOOLBAR
#endif // QT_CONFIG(toolbar)
case QEvent::ApplicationActivate:
return new QEvent(*e);

View File

@ -81,7 +81,9 @@
#if QT_CONFIG(tabwidget)
#include <qtabwidget.h>
#endif
#if QT_CONFIG(toolbar)
#include <qtoolbar.h>
#endif
#if QT_CONFIG(toolbutton)
#include <qtoolbutton.h>
#endif
@ -276,7 +278,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
}
}
break;
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
case PE_PanelMenuBar:
if (widget && qobject_cast<QToolBar *>(widget->parentWidget()))
break;
@ -295,7 +297,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
break;
case PE_PanelToolBar:
break;
#endif // QT_NO_TOOLBAR
#endif // QT_CONFIG(toolbar)
#if QT_CONFIG(progressbar)
case PE_IndicatorProgressChunk:
{
@ -477,7 +479,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
}
break;
#endif // QT_CONFIG(dockwidget)
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
case PE_IndicatorToolBarHandle:
p->save();
p->translate(opt->rect.x(), opt->rect.y());
@ -515,7 +517,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
qDrawShadeLine(p, p1, p2, opt->palette, 1, 1, 0);
break;
}
#endif // QT_NO_TOOLBAR
#endif // QT_CONFIG(toolbar)
#if QT_CONFIG(spinbox)
case PE_IndicatorSpinPlus:
case PE_IndicatorSpinMinus: {
@ -2153,7 +2155,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
}
break;
#endif // QT_CONFIG(combobox)
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
case CE_ToolBar:
if (const QStyleOptionToolBar *toolBar = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) {
// Compatibility with styles that use PE_PanelToolBar
@ -2169,7 +2171,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
&toolBar->palette.brush(QPalette::Button));
}
break;
#endif // QT_NO_TOOLBAR
#endif // QT_CONFIG(toolbar)
case CE_ColumnViewGrip: {
// draw background gradients
QLinearGradient g(0, 0, opt->rect.width(), 0);
@ -3072,7 +3074,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt,
}
break;
#endif // QT_CONFIG(itemviews)
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
case SE_ToolBarHandle:
if (const QStyleOptionToolBar *tbopt = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) {
if (tbopt->features & QStyleOptionToolBar::Movable) {
@ -3090,7 +3092,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt,
}
}
break;
#endif //QT_NO_TOOLBAR
#endif // QT_CONFIG(toolbar)
default:
break;
}
@ -4570,7 +4572,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid
ret = 0;
break;
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
case PM_ToolBarFrameWidth:
ret = 1;
break;
@ -4594,7 +4596,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid
case PM_ToolBarExtensionExtent:
ret = int(QStyleHelper::dpiScaled(12.));
break;
#endif // QT_NO_TOOLBAR
#endif // QT_CONFIG(toolbar)
#if QT_CONFIG(tabbar)
case PM_TabBarTabOverlap:

View File

@ -1040,7 +1040,7 @@ QStyleOptionButton::QStyleOptionButton(int version)
*/
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
/*!
\class QStyleOptionToolBar
\brief The QStyleOptionToolBar class is used to describe the

View File

@ -296,7 +296,7 @@ typedef Q_DECL_DEPRECATED QStyleOptionTab QStyleOptionTabV3;
#endif // QT_CONFIG(tabbar)
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
class Q_WIDGETS_EXPORT QStyleOptionToolBar : public QStyleOption
{
@ -321,7 +321,7 @@ protected:
Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionToolBar::ToolBarFeatures)
#endif // QT_NO_TOOLBAR
#endif // QT_CONFIG(toolbar)
class Q_WIDGETS_EXPORT QStyleOptionProgressBar : public QStyleOption
{

View File

@ -111,7 +111,9 @@
#include "qdrawutil.h"
#include <limits.h>
#if QT_CONFIG(toolbar)
#include <QtWidgets/qtoolbar.h>
#endif
QT_BEGIN_NAMESPACE
@ -1979,7 +1981,7 @@ QRenderRule QStyleSheetStyle::renderRule(const QObject *obj, const QStyleOption
if (frm->features & QStyleOptionFrame::Flat)
extraClass |= PseudoClass_Flat;
}
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
else if (const QStyleOptionToolBar *tb = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) {
if (tb->toolBarArea == Qt::LeftToolBarArea)
extraClass |= PseudoClass_Left;
@ -1999,7 +2001,7 @@ QRenderRule QStyleSheetStyle::renderRule(const QObject *obj, const QStyleOption
else if (tb->positionWithinLine == QStyleOptionToolBar::OnlyOne)
extraClass |= PseudoClass_OnlyOne;
}
#endif // QT_NO_TOOLBAR
#endif // QT_CONFIG(toolbar)
#if QT_CONFIG(toolbox)
else if (const QStyleOptionToolBox *tb = qstyleoption_cast<const QStyleOptionToolBox *>(opt)) {
if (tb->position == QStyleOptionToolBox::OnlyOneTab)
@ -3594,13 +3596,13 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
if (rule.hasBorder()) {
rule.drawBorder(p, rule.borderRect(opt->rect));
} else {
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
if (const QStyleOptionToolBar *tb = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) {
QStyleOptionToolBar newTb(*tb);
newTb.rect = rule.borderRect(opt->rect);
baseStyle()->drawControl(ce, &newTb, p, w);
}
#endif // QT_NO_TOOLBAR
#endif // QT_CONFIG(toolbar)
}
return;
@ -5946,12 +5948,12 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c
return positionRect(w, subRule, subRule2, pe, opt->rect, opt->direction);
}
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
case SE_ToolBarHandle:
if (hasStyleRule(w, PseudoElement_ToolBarHandle))
return ParentStyle::subElementRect(se, opt, w);
break;
#endif //QT_NO_TOOLBAR
#endif // QT_CONFIG(toolbar)
// On mac we make pixel adjustments to layouts which are not
// desireable when you have custom style sheets on them

View File

@ -661,7 +661,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt,
bool doRestore = false;
switch (pe) {
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
case PE_IndicatorToolBarSeparator:
{
QRect rect = opt->rect;
@ -721,7 +721,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt,
p->restore();
break;
#endif // QT_NO_TOOLBAR
#endif // QT_CONFIG(toolbar)
case PE_FrameButtonTool:
case PE_PanelButtonTool: {
QPen oldPen = p->pen();
@ -1572,7 +1572,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
p->fillRect(opt->rect, fill);
}
break; }
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
case CE_ToolBar:
if (const QStyleOptionToolBar *toolbar = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) {
// Reserve the beveled appearance only for mainwindow toolbars
@ -1673,7 +1673,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
break;
#endif // QT_NO_TOOLBAR
#endif // QT_CONFIG(toolbar)
case CE_ProgressBarContents:
if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {

View File

@ -53,6 +53,7 @@
#include "qmainwindow.h"
#include "qwidgetanimator_p.h"
#include "qmainwindowlayout_p.h"
#include "qmenu_p.h"
#include "qdockwidget_p.h"
#include <private/qlayoutengine_p.h>

View File

@ -45,7 +45,9 @@
#if QT_CONFIG(dockwidget)
#include "qdockwidget.h"
#endif
#if QT_CONFIG(toolbar)
#include "qtoolbar.h"
#endif
#include <qapplication.h>
#include <qmenu.h>
@ -61,7 +63,9 @@
#include <qpainter.h>
#include <private/qwidget_p.h>
#if QT_CONFIG(toolbar)
#include "qtoolbar_p.h"
#endif
#include "qwidgetanimator_p.h"
#ifdef Q_OS_OSX
#include <qpa/qplatformnativeinterface.h>
@ -706,7 +710,7 @@ Qt::DockWidgetArea QMainWindow::corner(Qt::Corner corner) const
{ return d_func()->layout->corner(corner); }
#endif
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
static bool checkToolBarArea(Qt::ToolBarArea area, const char *where)
{
@ -874,7 +878,7 @@ bool QMainWindow::toolBarBreak(QToolBar *toolbar) const
return d_func()->layout->toolBarBreak(toolbar);
}
#endif // QT_NO_TOOLBAR
#endif // QT_CONFIG(toolbar)
#if QT_CONFIG(dockwidget)
@ -1312,7 +1316,7 @@ bool QMainWindow::event(QEvent *event)
return true;
switch (event->type()) {
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
case QEvent::ToolBarChange: {
d->layout->toggleToolBarsVisible();
return true;
@ -1344,7 +1348,7 @@ bool QMainWindow::event(QEvent *event)
return QWidget::event(event);
}
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
/*!
\property QMainWindow::unifiedTitleAndToolBarOnMac
@ -1389,7 +1393,7 @@ bool QMainWindow::unifiedTitleAndToolBarOnMac() const
return false;
}
#endif // QT_NO_TOOLBAR
#endif // QT_CONFIG(toolbar)
/*!
\internal
@ -1435,7 +1439,7 @@ void QMainWindow::contextMenuEvent(QContextMenuEvent *event)
break;
}
#endif // QT_CONFIG(dockwidget)
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
if (QToolBar *tb = qobject_cast<QToolBar *>(child)) {
if (tb->parentWidget() != this)
return;
@ -1506,7 +1510,7 @@ QMenu *QMainWindow::createPopupMenu()
menu->addSeparator();
}
#endif // QT_CONFIG(dockwidget)
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
QList<QToolBar *> toolbars = findChildren<QToolBar *>();
if (toolbars.size()) {
if (!menu)

View File

@ -74,7 +74,7 @@ class Q_WIDGETS_EXPORT QMainWindow : public QWidget
Q_PROPERTY(bool dockNestingEnabled READ isDockNestingEnabled WRITE setDockNestingEnabled)
#endif // QT_CONFIG(dockwidget)
Q_PROPERTY(DockOptions dockOptions READ dockOptions WRITE setDockOptions)
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
Q_PROPERTY(bool unifiedTitleAndToolBarOnMac READ unifiedTitleAndToolBarOnMac WRITE setUnifiedTitleAndToolBarOnMac)
#endif
@ -145,7 +145,7 @@ public:
Qt::DockWidgetArea corner(Qt::Corner corner) const;
#endif
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
void addToolBarBreak(Qt::ToolBarArea area = Qt::TopToolBarArea);
void insertToolBarBreak(QToolBar *before);
@ -190,7 +190,7 @@ public Q_SLOTS:
void setAnimated(bool enabled);
void setDockNestingEnabled(bool enabled);
#endif
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
void setUnifiedTitleAndToolBarOnMac(bool set);
#endif

View File

@ -45,10 +45,12 @@
#include "qdockwidget.h"
#include "qdockwidget_p.h"
#endif
#if QT_CONFIG(toolbar)
#include "qtoolbar_p.h"
#include "qmainwindow.h"
#include "qtoolbar.h"
#include "qtoolbarlayout_p.h"
#endif
#include "qmainwindow.h"
#include "qwidgetanimator_p.h"
#if QT_CONFIG(rubberband)
#include "qrubberband.h"
@ -75,6 +77,7 @@
# include <qtextstream.h>
#endif
#include <private/qmenu_p.h>
#include <private/qapplication_p.h>
#include <private/qlayoutengine_p.h>
#include <private/qwidgetresizehandler_p.h>
@ -606,7 +609,7 @@ void QDockWidgetGroupWindow::apply()
QMainWindowLayoutState::QMainWindowLayoutState(QMainWindow *win)
:
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
toolBarAreaLayout(win),
#endif
#if QT_CONFIG(dockwidget)
@ -631,9 +634,9 @@ QSize QMainWindowLayoutState::sizeHint() const
result = centralWidgetItem->sizeHint();
#endif
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
result = toolBarAreaLayout.sizeHint(result);
#endif // QT_NO_TOOLBAR
#endif // QT_CONFIG(toolbar)
return result;
}
@ -649,16 +652,16 @@ QSize QMainWindowLayoutState::minimumSize() const
result = centralWidgetItem->minimumSize();
#endif
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
result = toolBarAreaLayout.minimumSize(result);
#endif // QT_NO_TOOLBAR
#endif // QT_CONFIG(toolbar)
return result;
}
void QMainWindowLayoutState::apply(bool animated)
{
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
toolBarAreaLayout.apply(animated);
#endif
@ -677,12 +680,12 @@ void QMainWindowLayoutState::apply(bool animated)
void QMainWindowLayoutState::fitLayout()
{
QRect r;
#ifdef QT_NO_TOOLBAR
#if !QT_CONFIG(toolbar)
r = rect;
#else
toolBarAreaLayout.rect = rect;
r = toolBarAreaLayout.fitLayout();
#endif // QT_NO_TOOLBAR
#endif // QT_CONFIG(toolbar)
#if QT_CONFIG(dockwidget)
dockAreaLayout.rect = r;
@ -694,7 +697,7 @@ void QMainWindowLayoutState::fitLayout()
void QMainWindowLayoutState::deleteAllLayoutItems()
{
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
toolBarAreaLayout.deleteAllLayoutItems();
#endif
@ -716,7 +719,7 @@ void QMainWindowLayoutState::deleteCentralWidgetItem()
QLayoutItem *QMainWindowLayoutState::itemAt(int index, int *x) const
{
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
if (QLayoutItem *ret = toolBarAreaLayout.itemAt(x, index))
return ret;
#endif
@ -734,7 +737,7 @@ QLayoutItem *QMainWindowLayoutState::itemAt(int index, int *x) const
QLayoutItem *QMainWindowLayoutState::takeAt(int index, int *x)
{
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
if (QLayoutItem *ret = toolBarAreaLayout.takeAt(x, index))
return ret;
#endif
@ -757,7 +760,7 @@ QList<int> QMainWindowLayoutState::indexOf(QWidget *widget) const
{
QList<int> result;
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
// is it a toolbar?
if (QToolBar *toolBar = qobject_cast<QToolBar*>(widget)) {
result = toolBarAreaLayout.indexOf(toolBar);
@ -792,7 +795,7 @@ bool QMainWindowLayoutState::contains(QWidget *widget) const
return true;
#endif
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
if (!toolBarAreaLayout.indexOf(widget).isEmpty())
return true;
#endif
@ -835,7 +838,7 @@ QList<int> QMainWindowLayoutState::gapIndex(QWidget *widget,
{
QList<int> result;
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
// is it a toolbar?
if (qobject_cast<QToolBar*>(widget) != 0) {
result = toolBarAreaLayout.gapIndex(pos);
@ -873,7 +876,7 @@ bool QMainWindowLayoutState::insertGap(const QList<int> &path, QLayoutItem *item
int i = path.first();
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
if (i == 0) {
Q_ASSERT(qobject_cast<QToolBar*>(item->widget()) != 0);
return toolBarAreaLayout.insertGap(path.mid(1), item);
@ -894,7 +897,7 @@ void QMainWindowLayoutState::remove(const QList<int> &path)
{
int i = path.first();
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
if (i == 0)
toolBarAreaLayout.remove(path.mid(1));
#endif
@ -907,7 +910,7 @@ void QMainWindowLayoutState::remove(const QList<int> &path)
void QMainWindowLayoutState::remove(QLayoutItem *item)
{
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
toolBarAreaLayout.remove(item);
#endif
@ -923,7 +926,7 @@ void QMainWindowLayoutState::remove(QLayoutItem *item)
void QMainWindowLayoutState::clear()
{
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
toolBarAreaLayout.clear();
#endif
@ -945,7 +948,7 @@ QLayoutItem *QMainWindowLayoutState::item(const QList<int> &path)
{
int i = path.first();
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
if (i == 0) {
const QToolBarAreaLayoutItem *tbItem = toolBarAreaLayout.item(path.mid(1));
Q_ASSERT(tbItem);
@ -965,7 +968,7 @@ QRect QMainWindowLayoutState::itemRect(const QList<int> &path) const
{
int i = path.first();
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
if (i == 0)
return toolBarAreaLayout.itemRect(path.mid(1));
#endif
@ -982,7 +985,7 @@ QRect QMainWindowLayoutState::gapRect(const QList<int> &path) const
{
int i = path.first();
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
if (i == 0)
return toolBarAreaLayout.itemRect(path.mid(1));
#endif
@ -999,7 +1002,7 @@ QLayoutItem *QMainWindowLayoutState::plug(const QList<int> &path)
{
int i = path.first();
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
if (i == 0)
return toolBarAreaLayout.plug(path.mid(1));
#endif
@ -1016,7 +1019,7 @@ QLayoutItem *QMainWindowLayoutState::unplug(const QList<int> &path, QMainWindowL
{
int i = path.first();
#ifdef QT_NO_TOOLBAR
#if !QT_CONFIG(toolbar)
Q_UNUSED(other);
#else
if (i == 0)
@ -1047,7 +1050,7 @@ void QMainWindowLayoutState::saveState(QDataStream &stream) const
}
#endif
#endif
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
toolBarAreaLayout.saveState(stream);
#endif
}
@ -1094,7 +1097,7 @@ bool QMainWindowLayoutState::checkFormat(QDataStream &stream)
stream >> marker;
switch(marker)
{
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
case QToolBarAreaLayout::ToolBarStateMarker:
case QToolBarAreaLayout::ToolBarStateMarkerEx:
{
@ -1104,7 +1107,7 @@ bool QMainWindowLayoutState::checkFormat(QDataStream &stream)
}
}
break;
#endif // QT_NO_TOOLBAR
#endif // QT_CONFIG(toolbar)
#if QT_CONFIG(dockwidget)
case QDockAreaLayout::DockWidgetStateMarker:
@ -1213,7 +1216,7 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream,
#endif // QT_CONFIG(tabwidget)
#endif // QT_CONFIG(dockwidget)
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
case QToolBarAreaLayout::ToolBarStateMarker:
case QToolBarAreaLayout::ToolBarStateMarkerEx:
{
@ -1234,7 +1237,7 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream,
}
}
break;
#endif //QT_NO_TOOLBAR
#endif // QT_CONFIG(toolbar)
default:
return false;
}// switch
@ -1248,7 +1251,7 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream,
** QMainWindowLayoutState - toolbars
*/
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
static inline void validateToolBarArea(Qt::ToolBarArea &area)
{
@ -1423,7 +1426,7 @@ void QMainWindowLayout::toggleToolBarsVisible()
}
}
#endif // QT_NO_TOOLBAR
#endif // QT_CONFIG(toolbar)
/******************************************************************************
** QMainWindowLayoutState - dock areas
@ -1907,7 +1910,7 @@ QLayoutItem *QMainWindowLayout::takeAt(int index)
layoutState.remove(ret);
}
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
if (!currentGapPos.isEmpty() && currentGapPos.constFirst() == 0) {
currentGapPos = layoutState.toolBarAreaLayout.currentGapIndex();
if (!currentGapPos.isEmpty()) {
@ -2019,7 +2022,7 @@ void QMainWindowLayout::setCurrentHoveredFloat(QDockWidgetGroupWindow *w)
static void fixToolBarOrientation(QLayoutItem *item, int dockPos)
{
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
QToolBar *toolBar = qobject_cast<QToolBar*>(item->widget());
if (toolBar == 0)
return;
@ -2148,7 +2151,7 @@ void QMainWindowLayout::animationFinished(QWidget *widget)
{
//this function is called from within the Widget Animator whenever an animation is finished
//on a certain widget
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
if (QToolBar *tb = qobject_cast<QToolBar*>(widget)) {
QToolBarLayout *tbl = qobject_cast<QToolBarLayout*>(tb->layout());
if (tbl->animating) {
@ -2219,7 +2222,7 @@ void QMainWindowLayout::animationFinished(QWidget *widget)
dw->d_func()->plug(currentGapRect);
}
#endif
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
if (QToolBar *tb = qobject_cast<QToolBar*>(widget))
tb->d_func()->plug(currentGapRect);
#endif
@ -2466,7 +2469,7 @@ QLayoutItem *QMainWindowLayout::unplug(QWidget *widget, bool group)
}
}
#endif // QT_CONFIG(dockwidget)
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
if (QToolBar *tb = qobject_cast<QToolBar*>(widget)) {
tb->d_func()->unplug(r);
}
@ -2614,7 +2617,7 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos)
if (qobject_cast<QDockWidgetGroupWindow *>(widget))
allowed = true;
#endif
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
if (QToolBar *tb = qobject_cast<QToolBar*>(widget))
allowed = tb->isAreaAllowed(toToolBarArea(path.at(1)));
#endif

View File

@ -69,7 +69,9 @@
#if QT_CONFIG(dockwidget)
#include "qdockarealayout_p.h"
#endif
#if QT_CONFIG(toolbar)
#include "qtoolbararealayout_p.h"
#endif
QT_REQUIRE_CONFIG(mainwindow);
@ -385,7 +387,7 @@ public:
QMainWindowLayoutState(QMainWindow *win);
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
QToolBarAreaLayout toolBarAreaLayout;
#endif
@ -462,7 +464,7 @@ public:
// toolbars
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
void addToolBarBreak(Qt::ToolBarArea area);
void insertToolBarBreak(QToolBar *before);
void removeToolBarBreak(QToolBar *before);

View File

@ -68,6 +68,33 @@ QT_REQUIRE_CONFIG(menu);
QT_BEGIN_NAMESPACE
static inline int pick(Qt::Orientation o, const QPoint &pos)
{ return o == Qt::Horizontal ? pos.x() : pos.y(); }
static inline int pick(Qt::Orientation o, const QSize &size)
{ return o == Qt::Horizontal ? size.width() : size.height(); }
static inline int &rpick(Qt::Orientation o, QPoint &pos)
{ return o == Qt::Horizontal ? pos.rx() : pos.ry(); }
static inline int &rpick(Qt::Orientation o, QSize &size)
{ return o == Qt::Horizontal ? size.rwidth() : size.rheight(); }
static inline QSizePolicy::Policy pick(Qt::Orientation o, const QSizePolicy &policy)
{ return o == Qt::Horizontal ? policy.horizontalPolicy() : policy.verticalPolicy(); }
static inline int perp(Qt::Orientation o, const QPoint &pos)
{ return o == Qt::Vertical ? pos.x() : pos.y(); }
static inline int perp(Qt::Orientation o, const QSize &size)
{ return o == Qt::Vertical ? size.width() : size.height(); }
static inline int &rperp(Qt::Orientation o, QPoint &pos)
{ return o == Qt::Vertical ? pos.rx() : pos.ry(); }
static inline int &rperp(Qt::Orientation o, QSize &size)
{ return o == Qt::Vertical ? size.rwidth() : size.rheight(); }
class QTornOffMenu;
class QEventLoop;

View File

@ -52,7 +52,9 @@
#if QT_CONFIG(mainwindow)
#include <qmainwindow.h>
#endif
#if QT_CONFIG(toolbar)
#include <qtoolbar.h>
#endif
#if QT_CONFIG(toolbutton)
#include <qtoolbutton.h>
#endif

View File

@ -53,7 +53,9 @@
#include "qpushbutton.h"
#include "qstyle.h"
#include "qstyleoption.h"
#if QT_CONFIG(toolbar)
#include "qtoolbar.h"
#endif
#include "qdebug.h"
#include "qlayoutitem.h"
#if QT_CONFIG(dialogbuttonbox)
@ -596,7 +598,7 @@ QPoint QPushButtonPrivate::adjustedMenuPosition()
Q_Q(QPushButton);
bool horizontal = true;
#if !defined(QT_NO_TOOLBAR)
#if QT_CONFIG(toolbar)
QToolBar *tb = qobject_cast<QToolBar*>(parent);
if (tb && tb->orientation() == Qt::Vertical)
horizontal = false;

View File

@ -39,8 +39,6 @@
#include "qtoolbar.h"
#ifndef QT_NO_TOOLBAR
#include <qapplication.h>
#if QT_CONFIG(combobox)
#include <qcombobox.h>
@ -1288,5 +1286,3 @@ void QToolBar::initStyleOption(QStyleOptionToolBar *option) const
QT_END_NAMESPACE
#include "moc_qtoolbar.cpp"
#endif // QT_NO_TOOLBAR

View File

@ -44,11 +44,10 @@
#include <QtWidgets/qaction.h>
#include <QtWidgets/qwidget.h>
QT_REQUIRE_CONFIG(toolbar);
QT_BEGIN_NAMESPACE
#ifndef QT_NO_TOOLBAR
class QToolBarPrivate;
class QAction;
@ -211,8 +210,6 @@ private:
inline QAction *QToolBar::actionAt(int ax, int ay) const
{ return actionAt(QPoint(ax, ay)); }
#endif // QT_NO_TOOLBAR
QT_END_NAMESPACE
#endif // QDYNAMICTOOLBAR_H

View File

@ -57,9 +57,9 @@
#include "private/qwidget_p.h"
#include <QtCore/qbasictimer.h>
QT_BEGIN_NAMESPACE
QT_REQUIRE_CONFIG(toolbar);
#ifndef QT_NO_TOOLBAR
QT_BEGIN_NAMESPACE
class QToolBarLayout;
class QTimer;
@ -127,8 +127,6 @@ public:
QBasicTimer waitForPopupTimer;
};
#endif // QT_NO_TOOLBAR
QT_END_NAMESPACE
#endif // QDYNAMICTOOLBAR_P_H

View File

@ -53,8 +53,6 @@
** QToolBarAreaLayoutItem
*/
#ifndef QT_NO_TOOLBAR
QT_BEGIN_NAMESPACE
// qmainwindow.cpp
@ -1391,5 +1389,3 @@ bool QToolBarAreaLayout::isEmpty() const
}
QT_END_NAMESPACE
#endif // QT_NO_TOOLBAR

View File

@ -52,41 +52,15 @@
//
#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qmenu_p.h"
#include <QList>
#include <QSize>
#include <QRect>
QT_REQUIRE_CONFIG(toolbar);
QT_BEGIN_NAMESPACE
static inline int pick(Qt::Orientation o, const QPoint &pos)
{ return o == Qt::Horizontal ? pos.x() : pos.y(); }
static inline int pick(Qt::Orientation o, const QSize &size)
{ return o == Qt::Horizontal ? size.width() : size.height(); }
static inline int &rpick(Qt::Orientation o, QPoint &pos)
{ return o == Qt::Horizontal ? pos.rx() : pos.ry(); }
static inline int &rpick(Qt::Orientation o, QSize &size)
{ return o == Qt::Horizontal ? size.rwidth() : size.rheight(); }
static inline QSizePolicy::Policy pick(Qt::Orientation o, const QSizePolicy &policy)
{ return o == Qt::Horizontal ? policy.horizontalPolicy() : policy.verticalPolicy(); }
static inline int perp(Qt::Orientation o, const QPoint &pos)
{ return o == Qt::Vertical ? pos.x() : pos.y(); }
static inline int perp(Qt::Orientation o, const QSize &size)
{ return o == Qt::Vertical ? size.width() : size.height(); }
static inline int &rperp(Qt::Orientation o, QPoint &pos)
{ return o == Qt::Vertical ? pos.rx() : pos.ry(); }
static inline int &rperp(Qt::Orientation o, QSize &size)
{ return o == Qt::Vertical ? size.rwidth() : size.rheight(); }
#ifndef QT_NO_TOOLBAR
class QToolBar;
class QLayoutItem;
class QMainWindow;
@ -244,7 +218,6 @@ public:
bool isEmpty() const;
};
QT_END_NAMESPACE
#endif // QT_NO_TOOLBAR
#endif // QTOOLBARAREALAYOUT_P_H

View File

@ -59,8 +59,6 @@
#include "qtoolbarlayout_p.h"
#include "qtoolbarseparator_p.h"
#ifndef QT_NO_TOOLBAR
QT_BEGIN_NAMESPACE
// qmainwindow.cpp
@ -753,5 +751,3 @@ QToolBarItem *QToolBarLayout::createItem(QAction *action)
QT_END_NAMESPACE
#include "moc_qtoolbarlayout_p.cpp"
#endif // QT_NO_TOOLBAR

View File

@ -56,9 +56,9 @@
#include <private/qlayoutengine_p.h>
#include <QVector>
QT_BEGIN_NAMESPACE
QT_REQUIRE_CONFIG(toolbar);
#ifndef QT_NO_TOOLBAR
QT_BEGIN_NAMESPACE
class QAction;
class QToolBarExtension;
@ -127,8 +127,6 @@ private:
QMenu *popupMenu;
};
#endif // QT_NO_TOOLBAR
QT_END_NAMESPACE
#endif // QTOOLBARLAYOUT_P_H

View File

@ -39,8 +39,6 @@
#include "qtoolbarseparator_p.h"
#ifndef QT_NO_TOOLBAR
#include <qstyle.h>
#include <qstyleoption.h>
#include <qtoolbar.h>
@ -87,5 +85,3 @@ void QToolBarSeparator::paintEvent(QPaintEvent *)
QT_END_NAMESPACE
#include "moc_qtoolbarseparator_p.cpp"
#endif // QT_NO_TOOLBAR

View File

@ -54,9 +54,9 @@
#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "QtWidgets/qwidget.h"
QT_BEGIN_NAMESPACE
QT_REQUIRE_CONFIG(toolbar);
#ifndef QT_NO_TOOLBAR
QT_BEGIN_NAMESPACE
class QStyleOption;
class QToolBar;
@ -80,8 +80,6 @@ public Q_SLOTS:
void setOrientation(Qt::Orientation orientation);
};
#endif // QT_NO_TOOLBAR
QT_END_NAMESPACE
#endif // QDYNAMICTOOLBARSEPARATOR_P_H

View File

@ -53,7 +53,9 @@
#if QT_CONFIG(mainwindow)
#include <qmainwindow.h>
#endif
#if QT_CONFIG(toolbar)
#include <qtoolbar.h>
#endif
#include <qvariant.h>
#include <qstylepainter.h>
#include <private/qabstractbutton_p.h>
@ -201,7 +203,7 @@ void QToolButtonPrivate::init()
{
Q_Q(QToolButton);
defaultAction = 0;
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
if (qobject_cast<QToolBar*>(parent))
autoRaise = true;
else
@ -245,13 +247,13 @@ void QToolButton::initStyleOption(QStyleOptionToolButton *option) const
bool forceNoText = false;
option->iconSize = iconSize(); //default value
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
if (parentWidget()) {
if (QToolBar *toolBar = qobject_cast<QToolBar *>(parentWidget())) {
option->iconSize = toolBar->iconSize();
}
}
#endif // QT_NO_TOOLBAR
#endif // QT_CONFIG(toolbar)
if (!forceNoText)
option->text = d->text;
@ -571,7 +573,7 @@ void QToolButton::timerEvent(QTimerEvent *e)
*/
void QToolButton::changeEvent(QEvent *e)
{
#ifndef QT_NO_TOOLBAR
#if QT_CONFIG(toolbar)
Q_D(QToolButton);
if (e->type() == QEvent::ParentChange) {
if (qobject_cast<QToolBar*>(parentWidget()))
@ -743,7 +745,7 @@ void QToolButtonPrivate::popupTimerDone()
repeat = q->autoRepeat();
q->setAutoRepeat(false);
bool horizontal = true;
#if !defined(QT_NO_TOOLBAR)
#if QT_CONFIG(toolbar)
QToolBar *tb = qobject_cast<QToolBar*>(parent);
if (tb && tb->orientation() == Qt::Vertical)
horizontal = false;

View File

@ -1977,8 +1977,12 @@ void QWidgetTextControlPrivate::inputMethodEvent(QInputMethodEvent *e)
cursor.removeSelectedText();
}
QTextBlock block;
// insert commit string
if (!e->commitString().isEmpty() || e->replacementLength()) {
if (e->commitString().endsWith(QChar::LineFeed))
block = cursor.block(); // Remember the block where the preedit text is
QTextCursor c = cursor;
c.setPosition(c.position() + e->replacementStart());
c.setPosition(c.position() + e->replacementLength(), QTextCursor::KeepAnchor);
@ -1997,7 +2001,8 @@ void QWidgetTextControlPrivate::inputMethodEvent(QInputMethodEvent *e)
}
}
QTextBlock block = cursor.block();
if (!block.isValid())
block = cursor.block();
QTextLayout *layout = block.layout();
if (isGettingInput)
layout->setPreeditArea(cursor.position() - block.position(), e->preeditString());

View File

@ -3,25 +3,16 @@
HEADERS += \
widgets/qframe.h \
widgets/qframe_p.h \
widgets/qtoolbar.h \
widgets/qtoolbar_p.h \
widgets/qtoolbarlayout_p.h \
widgets/qtoolbarseparator_p.h \
widgets/qabstractscrollarea.h \
widgets/qabstractscrollarea_p.h \
widgets/qfocusframe.h \
widgets/qwidgetanimator_p.h \
widgets/qtoolbararealayout_p.h
widgets/qwidgetanimator_p.h
SOURCES += \
widgets/qframe.cpp \
widgets/qtoolbar.cpp \
widgets/qtoolbarlayout.cpp \
widgets/qtoolbarseparator.cpp \
widgets/qabstractscrollarea.cpp \
widgets/qfocusframe.cpp \
widgets/qwidgetanimator.cpp \
widgets/qtoolbararealayout.cpp
widgets/qwidgetanimator.cpp
qtConfig(abstractbutton) {
HEADERS += \
@ -326,6 +317,21 @@ qtConfig(tabwidget) {
SOURCES += widgets/qtabwidget.cpp
}
qtConfig(toolbar) {
HEADERS += \
widgets/qtoolbar.h \
widgets/qtoolbar_p.h \
widgets/qtoolbararealayout_p.h \
widgets/qtoolbarlayout_p.h \
widgets/qtoolbarseparator_p.h
SOURCES += \
widgets/qtoolbar.cpp \
widgets/qtoolbarlayout.cpp \
widgets/qtoolbararealayout.cpp \
widgets/qtoolbarseparator.cpp
}
qtConfig(toolbox) {
HEADERS += widgets/qtoolbox.h
SOURCES += widgets/qtoolbox.cpp

View File

@ -95,6 +95,9 @@ private slots:
void QTBUG58851_data();
void QTBUG58851();
void QTBUG18001_data();
void QTBUG18001();
private:
QAbstractItemModel *model;
QItemSelectionModel *selection;
@ -2922,5 +2925,98 @@ void tst_QItemSelectionModel::QTBUG58851()
}
}
void tst_QItemSelectionModel::QTBUG18001_data()
{
using IntPair = std::pair<int, int>;
using IntPairList = QList<IntPair>;
using IntList = QList<int>;
using BoolList = QList<bool>;
QTest::addColumn<IntPairList>("indexesToSelect");
QTest::addColumn<IntList>("selectionCommands");
QTest::addColumn<BoolList>("expectedSelectedRows");
QTest::addColumn<BoolList>("expectedSelectedColums");
int colSelect = QItemSelectionModel::Select | QItemSelectionModel::Columns;
int rowSelect = QItemSelectionModel::Select | QItemSelectionModel::Rows;
QTest::newRow("Select column 1")
<< IntPairList { {0, 1} }
<< IntList{ colSelect }
<< BoolList{ false, false, false, false, false }
<< BoolList{ false, true, false, false, false };
QTest::newRow("Select row 1")
<< IntPairList { {1, 0} }
<< IntList{ rowSelect }
<< BoolList{ false, true, false, false, false }
<< BoolList{ false, false, false, false, false };
QTest::newRow("Select column 1+2, row 1+2")
<< IntPairList { {0, 1}, {0, 2}, {1, 0}, {2, 0} }
<< IntList{ colSelect, colSelect, rowSelect, rowSelect }
<< BoolList{ false, true, true, false, false }
<< BoolList{ false, true, true, false, false };
QTest::newRow("Select row 1+2, col 1+2")
<< IntPairList { {1, 0}, {2, 0}, {0, 1}, {0, 2} }
<< IntList{ rowSelect, rowSelect, colSelect, colSelect }
<< BoolList{ false, true, true, false, false }
<< BoolList{ false, true, true, false, false };
}
void tst_QItemSelectionModel::QTBUG18001()
{
using IntPair = std::pair<int, int>;
using IntPairList = QList<IntPair>;
using IntList = QList<int>;
using BoolList = QList<bool>;
QFETCH(IntPairList, indexesToSelect);
QFETCH(IntList, selectionCommands);
QFETCH(BoolList, expectedSelectedRows);
QFETCH(BoolList, expectedSelectedColums);
QStandardItemModel model(5, 5);
for (int row = 0; row < model.rowCount(); ++row) {
for (int column = 0; column < model.columnCount(); ++column) {
QStandardItem *item = new QStandardItem(QString("%0x%1").arg(row).arg(column));
model.setItem(row, column, item);
const bool oddRow = row % 2;
const bool oddCol = column % 2;
if (oddRow == oddCol)
item->setSelectable(false);
}
}
QItemSelectionModel selectionModel(&model);
for (int i = 0; i < indexesToSelect.count(); ++i) {
QModelIndex idx = model.index( indexesToSelect.at(i).first, indexesToSelect.at(i).second );
selectionModel.select(idx, QItemSelectionModel::SelectionFlag(selectionCommands.at(i)));
}
for (int i = 0; i < expectedSelectedRows.count(); ++i) {
const bool expected = expectedSelectedRows.at(i);
const bool actual = selectionModel.isRowSelected(i, QModelIndex());
QByteArray description = QByteArray("Row ") + QByteArray::number(i)
+ " Expected " + QByteArray::number(expected)
+ " Actual " + QByteArray::number(actual);
QVERIFY2(expected == actual, description.data());
}
for (int i = 0; i < expectedSelectedColums.count(); ++i) {
const bool expected = expectedSelectedColums.at(i);
const bool actual = selectionModel.isColumnSelected(i, QModelIndex());
QByteArray description = QByteArray("Col ") + QByteArray::number(i)
+ " Expected " + QByteArray::number(expected)
+ " Actual " + QByteArray::number(actual);
QVERIFY2(expected == actual, description.data());
}
}
QTEST_MAIN(tst_QItemSelectionModel)
#include "tst_qitemselectionmodel.moc"

View File

@ -324,10 +324,8 @@ public:
public slots:
void cleanup();
private slots:
#ifndef Q_CC_HPACC
void fromStdString();
void toStdString();
#endif
void check_QTextIOStream();
void check_QTextStream();
void check_QDataStream();
@ -4098,8 +4096,6 @@ void tst_QString::setRawData()
QVERIFY(cstr.data_ptr() != csd);
}
#ifndef Q_CC_HPACC
// This test crashes on HP-UX with aCC (not supported)
void tst_QString::fromStdString()
{
std::string stroustrup = "foo";
@ -4110,10 +4106,7 @@ void tst_QString::fromStdString()
QString qtnull = QString::fromStdString( stdnull );
QCOMPARE( qtnull.size(), int(stdnull.size()) );
}
#endif
#ifndef Q_CC_HPACC
// This test crashes on HP-UX with aCC (not supported)
void tst_QString::toStdString()
{
QString nord = "foo";
@ -4130,7 +4123,6 @@ void tst_QString::toStdString()
std::string stdnull = qtnull.toStdString();
QCOMPARE( int(stdnull.size()), qtnull.size() );
}
#endif
void tst_QString::utf8()
{

View File

@ -164,7 +164,9 @@ void tst_QNetworkCookieJar::setCookiesFromUrl_data()
result.clear();
preset.clear();
cookie.setDomain(".foo.ck");
QTest::newRow("effective-tld2-denied") << preset << cookie << "http://foo.ck" << result << false;
result += cookie;
QTest::newRow("effective-tld2-accepted2") << preset << cookie << "http://foo.ck" << result << true;
result.clear();
QTest::newRow("effective-tld2-denied2") << preset << cookie << "http://www.foo.ck" << result << false;
QTest::newRow("effective-tld2-denied3") << preset << cookie << "http://www.anything.foo.ck" << result << false;
cookie.setDomain(".www.ck");
@ -208,6 +210,22 @@ void tst_QNetworkCookieJar::setCookiesFromUrl_data()
preset.clear();
cookie.setDomain(".com.");
QTest::newRow("rfc2109-4.3.2-ex3-2") << preset << cookie << "http://x.foo.com" << result << false;
// When using a TLD as a hostname the hostname should still get cookies (QTBUG-52040)
// ... and nothing else should get the cookies.
result.clear();
preset.clear();
cookie.setPath("/");
cookie.setDomain(".support");
result += cookie;
QTest::newRow("TLD-as-domain-accepted") << preset << cookie << "http://support" << result << true;
result.clear();
QTest::newRow("TLD-as-domain-rejected") << preset << cookie << "http://a.support" << result << false;
// Now test with no domain in the cookie, use the domain from the url (matching TLD)
cookie.setDomain("support");
result += cookie;
cookie.setDomain("");
QTest::newRow("TLD-as-domain-accepted2") << preset << cookie << "http://support" << result << true;
}
void tst_QNetworkCookieJar::setCookiesFromUrl()
@ -351,6 +369,19 @@ void tst_QNetworkCookieJar::cookiesForUrl_data()
result.clear();
result += rootCookie;
QTest::newRow("root-path-match") << allCookies << "http://qt-project.org" << result;
// Domain in cookie happens to match a TLD
allCookies.clear();
QNetworkCookie tldCookie;
tldCookie.setDomain(".support");
tldCookie.setName("a");
tldCookie.setValue("b");
allCookies += tldCookie;
result.clear();
result += tldCookie;
QTest::newRow("tld-cookie-match") << allCookies << "http://support/" << result;
result.clear();
QTest::newRow("tld-cookie-no-match") << allCookies << "http://a.support/" << result;
}
void tst_QNetworkCookieJar::cookiesForUrl()

View File

@ -43,24 +43,6 @@
#include <qdebug.h>
static bool waitForWindowExposed(QWindow *window)
{
if (!window)
return false;
#ifdef Q_OS_OSX
QTest::qWait(100);
return window->isExposed();
#endif
return QTest::qWaitForWindowExposed(window);
}
static bool waitForWindowExposed(QWidget *widget)
{
if (!widget)
return false;
return waitForWindowExposed(widget->windowHandle());
}
static QPointF mapToGlobal(const QPointF &pt, QGraphicsItem *item, QGraphicsView *view)
{
return view->viewport()->mapToGlobal(view->mapFromScene(item->mapToScene(pt)));
@ -376,7 +358,7 @@ void tst_Gestures::customGesture()
GestureWidget widget;
widget.grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren);
widget.show();
QVERIFY(waitForWindowExposed(&widget));
QVERIFY(QTest::qWaitForWindowExposed(&widget));
CustomEvent event;
event.hotSpot = widget.mapToGlobal(QPoint(5,5));
@ -845,7 +827,7 @@ void tst_Gestures::graphicsItemGesture()
item->setPos(100, 100);
view.show();
QVERIFY(waitForWindowExposed(&view));
QVERIFY(QTest::qWaitForWindowExposed(&view));
view.ensureVisible(scene.sceneRect());
item->grabGesture(CustomGesture::GestureType);
@ -907,7 +889,7 @@ void tst_Gestures::graphicsView()
item->setPos(100, 100);
view.show();
QVERIFY(waitForWindowExposed(&view));
QVERIFY(QTest::qWaitForWindowExposed(&view));
view.ensureVisible(scene.sceneRect());
item->grabGesture(CustomGesture::GestureType);
@ -983,7 +965,7 @@ void tst_Gestures::graphicsItemTreeGesture()
item1_child2->setParentItem(item1);
view.show();
QVERIFY(waitForWindowExposed(&view));
QVERIFY(QTest::qWaitForWindowExposed(&view));
view.ensureVisible(scene.sceneRect());
item1->grabGesture(CustomGesture::GestureType);
@ -1040,7 +1022,7 @@ void tst_Gestures::explicitGraphicsObjectTarget()
item2_child1->setPos(10, 10);
view.show();
QVERIFY(waitForWindowExposed(&view));
QVERIFY(QTest::qWaitForWindowExposed(&view));
view.ensureVisible(scene.sceneRect());
item1->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren);
@ -1099,7 +1081,7 @@ void tst_Gestures::gestureOverChildGraphicsItem()
item2_child1->setPos(0, 0);
view.show();
QVERIFY(waitForWindowExposed(&view));
QVERIFY(QTest::qWaitForWindowExposed(&view));
view.ensureVisible(scene.sceneRect());
item1->grabGesture(CustomGesture::GestureType);
@ -1397,7 +1379,7 @@ void tst_Gestures::testMapToScene()
item0->setPos(14, 16);
view.show(); // need to show to give it a global coordinate
QVERIFY(waitForWindowExposed(&view));
QVERIFY(QTest::qWaitForWindowExposed(&view));
view.ensureVisible(scene.sceneRect());
QPoint origin = view.mapToGlobal(QPoint());
@ -1523,7 +1505,7 @@ void tst_Gestures::autoCancelGestures()
parent.grabGesture(CustomGesture::GestureType);
child->grabGesture(secondGesture);
parent.show();
QVERIFY(waitForWindowExposed(&parent));
QVERIFY(QTest::qWaitForWindowExposed(&parent));
/*
An event is sent to both the child and the parent, when the child gets it a gesture is triggered
@ -1582,7 +1564,7 @@ void tst_Gestures::autoCancelGestures2()
child->grabGesture(secondGesture);
view.show();
QVERIFY(waitForWindowExposed(&view));
QVERIFY(QTest::qWaitForWindowExposed(&view));
view.ensureVisible(scene.sceneRect());
CustomEvent event;
@ -1628,7 +1610,7 @@ void tst_Gestures::graphicsViewParentPropagation()
item1_c1_c1->setPos(0, 0);
view.show();
QVERIFY(waitForWindowExposed(&view));
QVERIFY(QTest::qWaitForWindowExposed(&view));
view.ensureVisible(scene.sceneRect());
item0->grabGesture(CustomGesture::GestureType, Qt::ReceivePartialGestures | Qt::IgnoredGesturesPropagateToParent);
@ -1698,7 +1680,7 @@ void tst_Gestures::panelPropagation()
item1_child1_child1->setZValue(10);
view.show();
QVERIFY(waitForWindowExposed(&view));
QVERIFY(QTest::qWaitForWindowExposed(&view));
view.ensureVisible(scene.sceneRect());
static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
@ -1809,7 +1791,7 @@ void tst_Gestures::panelStacksBehindParent()
panel->setZValue(5);
view.show();
QVERIFY(waitForWindowExposed(&view));
QVERIFY(QTest::qWaitForWindowExposed(&view));
view.ensureVisible(scene.sceneRect());
static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
@ -1893,7 +1875,7 @@ void tst_Gestures::deleteGestureTargetItem()
items.insert(item2->objectName(), item2);
view.show();
QVERIFY(waitForWindowExposed(&view));
QVERIFY(QTest::qWaitForWindowExposed(&view));
view.ensureVisible(scene.sceneRect());
if (propagateUpdateGesture)
@ -1938,7 +1920,7 @@ void tst_Gestures::viewportCoordinates()
scene.addItem(item1);
view.show();
QVERIFY(waitForWindowExposed(&view));
QVERIFY(QTest::qWaitForWindowExposed(&view));
view.ensureVisible(scene.sceneRect());
CustomEvent event;
@ -1975,7 +1957,7 @@ void tst_Gestures::partialGesturePropagation()
scene.addItem(item4);
view.show();
QVERIFY(waitForWindowExposed(&view));
QVERIFY(QTest::qWaitForWindowExposed(&view));
view.ensureVisible(scene.sceneRect());
item1->ignoredUpdatedGestures << CustomGesture::GestureType;
@ -2063,7 +2045,7 @@ void tst_Gestures::testQGestureRecognizerCleanup()
//QGestureRecognizer::registerRecognizer(new PanRecognizer(PanRecognizer::Custom));
w->show();
QVERIFY(waitForWindowExposed(w));
QVERIFY(QTest::qWaitForWindowExposed(w));
delete w;
}
@ -2184,7 +2166,7 @@ void tst_Gestures::testReuseCanceledGestures()
gv->viewport()->grabGesture(tapGestureTypeId);
mw.show();
QVERIFY(waitForWindowExposed(&mw));
QVERIFY(QTest::qWaitForWindowExposed(&mw));
QPoint targetPos(gv->mapFromScene(target->mapToScene(target->rect().center())));
targetPos = gv->viewport()->mapFromParent(targetPos);
@ -2250,7 +2232,7 @@ void tst_Gestures::conflictingGesturesInGraphicsView()
scene.addItem(item2);
view.show();
QVERIFY(waitForWindowExposed(&view));
QVERIFY(QTest::qWaitForWindowExposed(&view));
view.ensureVisible(scene.sceneRect());
static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
@ -2315,7 +2297,7 @@ void tst_Gestures::bug_13501_gesture_not_accepted()
NoConsumeWidgetBug13501 w;
w.grabGesture(Qt::TapGesture);
w.show();
QVERIFY(waitForWindowExposed(&w));
QVERIFY(QTest::qWaitForWindowExposed(&w));
//QTest::mousePress(&ignoreEvent, Qt::LeftButton);
QTouchDevice *device = QTest::createTouchDevice();
QTest::touchEvent(&w, device).press(0, QPoint(10, 10), &w);

View File

@ -304,6 +304,7 @@ void tst_QFocusEvent::checkReason_focusWidget()
frame1.setLayout(&leftLayout);
frame2.setLayout(&rightLayout);
window1.show();
QVERIFY(QTest::qWaitForWindowActive(&window1));
edit1.setFocus();
QTRY_VERIFY(edit1.hasFocus());

View File

@ -401,6 +401,8 @@ private slots:
void tabletTracking();
void closeEvent();
private:
bool ensureScreenSize(int width, int height);
@ -10808,5 +10810,31 @@ void tst_QWidget::tabletTracking()
QTRY_COMPARE(widget.moveEventCount, 3);
}
class CloseCountingWidget : public QWidget
{
public:
int closeCount = 0;
void closeEvent(QCloseEvent *ev) override;
};
void CloseCountingWidget::closeEvent(QCloseEvent *ev)
{
++closeCount;
ev->accept();
}
void tst_QWidget::closeEvent()
{
CloseCountingWidget widget;
widget.show();
QVERIFY(QTest::qWaitForWindowExposed(&widget));
// Yes we call the close() function twice. This mimics the behavior of QTBUG-43344 where
// QApplication first closes all windows and then QCocoaApplication flushes window system
// events, triggering more close events.
widget.windowHandle()->close();
widget.windowHandle()->close();
QCOMPARE(widget.closeCount, 1);
}
QTEST_MAIN(tst_QWidget)
#include "tst_qwidget.moc"

View File

@ -319,6 +319,7 @@ private:
void psKeyClick(QWidget *target, Qt::Key key, Qt::KeyboardModifiers pressState = 0);
void psKeyClick(QTestEventList &keys, Qt::Key key, Qt::KeyboardModifiers pressState = 0);
bool unselectingWithLeftOrRightChangesCursorPosition();
void addKeySequenceStandardKey(QTestEventList &keys, QKeySequence::StandardKey);
QLineEdit *ensureTestWidget();
bool validInput;
@ -724,7 +725,7 @@ void tst_QLineEdit::keypress_inputMask_data()
{
QTestEventList keys;
// inserting 'A1.2B'
keys.addKeyClick(Qt::Key_Home);
addKeySequenceStandardKey(keys, QKeySequence::MoveToStartOfLine);
keys.addKeyClick(Qt::Key_A);
keys.addKeyClick(Qt::Key_1);
keys.addKeyClick(Qt::Key_Period);
@ -735,7 +736,7 @@ void tst_QLineEdit::keypress_inputMask_data()
{
QTestEventList keys;
// inserting 'A1.2B'
keys.addKeyClick(Qt::Key_Home);
addKeySequenceStandardKey(keys, QKeySequence::MoveToStartOfLine);
keys.addKeyClick(Qt::Key_0);
keys.addKeyClick(Qt::Key_Exclam);
keys.addKeyClick('P');
@ -745,22 +746,24 @@ void tst_QLineEdit::keypress_inputMask_data()
{
QTestEventList keys;
// pressing delete
keys.addKeyClick(Qt::Key_Home);
addKeySequenceStandardKey(keys, QKeySequence::MoveToStartOfLine);
keys.addKeyClick(Qt::Key_Delete);
QTest::newRow("delete") << QString("000.000;_") << keys << QString(".") << QString("___.___");
}
{
QTestEventList keys;
// selecting all and delete
keys.addKeyClick(Qt::Key_Home);
keys.addKeyClick(Qt::Key_End, Qt::ShiftModifier);
keys.addKeyClick(Qt::Key_1);
keys.addKeyClick(Qt::Key_2);
addKeySequenceStandardKey(keys, QKeySequence::MoveToStartOfLine);
addKeySequenceStandardKey(keys, QKeySequence::SelectEndOfLine);
keys.addKeyClick(Qt::Key_Delete);
QTest::newRow("deleting all") << QString("000.000;_") << keys << QString(".") << QString("___.___");
}
{
QTestEventList keys;
// inserting '12.12' then two backspaces
keys.addKeyClick(Qt::Key_Home);
addKeySequenceStandardKey(keys, QKeySequence::MoveToStartOfLine);
keys.addKeyClick(Qt::Key_1);
keys.addKeyClick(Qt::Key_2);
keys.addKeyClick(Qt::Key_Period);
@ -773,7 +776,7 @@ void tst_QLineEdit::keypress_inputMask_data()
{
QTestEventList keys;
// inserting '12ab'
keys.addKeyClick(Qt::Key_Home);
addKeySequenceStandardKey(keys, QKeySequence::MoveToStartOfLine);
keys.addKeyClick(Qt::Key_1);
keys.addKeyClick(Qt::Key_2);
keys.addKeyClick(Qt::Key_A);
@ -1971,6 +1974,13 @@ void tst_QLineEdit::psKeyClick(QTestEventList &keys, Qt::Key key, Qt::KeyboardMo
keys.addKeyClick(key, pressState);
}
void tst_QLineEdit::addKeySequenceStandardKey(QTestEventList &keys, QKeySequence::StandardKey key)
{
QKeySequence keyseq = QKeySequence(key);
for (int i = 0; i < keyseq.count(); ++i)
keys.addKeyClick( Qt::Key( keyseq[i] & ~Qt::KeyboardModifierMask), Qt::KeyboardModifier(keyseq[i] & Qt::KeyboardModifierMask) );
}
void tst_QLineEdit::cursorPosition()
{
QLineEdit *testWidget = ensureTestWidget();

View File

@ -549,7 +549,9 @@ void tst_QTabWidget::paintEventCount()
QCOMPARE(tw->currentIndex(), 0);
tw->show();
QVERIFY(QTest::qWaitForWindowActive(tw));
QVERIFY(QTest::qWaitForWindowExposed(tw));
// Wait for extra paint events that happen at least on macOS
QTest::qWait(1000);
// Mac, Windows and Windows CE get multiple repaints on the first show, so use those as a starting point.
static const int MaxInitialPaintCount =

View File

@ -47,8 +47,8 @@
#include <QDebug>
#include <QTextStream>
bool optIgnoreTouch = false;
QVector<Qt::GestureType> optGestures;
static bool optIgnoreTouch = false;
static QVector<Qt::GestureType> optGestures;
static inline void drawEllipse(const QPointF &center, qreal hDiameter, qreal vDiameter, const QColor &color, QPainter &painter)
{
@ -275,10 +275,10 @@ class TouchTestWidget : public QWidget {
Q_OBJECT
Q_PROPERTY(bool drawPoints READ drawPoints WRITE setDrawPoints)
public:
explicit TouchTestWidget(QWidget *parent = 0) : QWidget(parent), m_drawPoints(true)
explicit TouchTestWidget(QWidget *parent = nullptr) : QWidget(parent), m_drawPoints(true)
{
setAttribute(Qt::WA_AcceptTouchEvents);
foreach (Qt::GestureType t, optGestures)
for (Qt::GestureType t : optGestures)
grabGesture(t);
}
@ -337,10 +337,11 @@ bool TouchTestWidget::event(QEvent *event)
case QEvent::TouchBegin:
case QEvent::TouchUpdate:
if (m_drawPoints) {
foreach (const QTouchEvent::TouchPoint &p, static_cast<const QTouchEvent *>(event)->touchPoints())
for (const QTouchEvent::TouchPoint &p : static_cast<const QTouchEvent *>(event)->touchPoints())
m_points.append(Point(p.pos(), TouchPoint, Qt::MouseEventNotSynthesized, p.ellipseDiameters()));
update();
}
Q_FALLTHROUGH();
case QEvent::TouchEnd:
if (optIgnoreTouch)
event->ignore();
@ -358,7 +359,8 @@ bool TouchTestWidget::event(QEvent *event)
void TouchTestWidget::handleGestureEvent(QGestureEvent *gestureEvent)
{
foreach (QGesture *gesture, gestureEvent->gestures()) {
const auto gestures = gestureEvent->gestures();
for (QGesture *gesture : gestures) {
if (optGestures.contains(gesture->gestureType())) {
switch (gesture->state()) {
case Qt::NoGesture:
@ -389,7 +391,7 @@ void TouchTestWidget::paintEvent(QPaintEvent *)
const QRectF geom = QRectF(QPointF(0, 0), QSizeF(size()));
painter.fillRect(geom, Qt::white);
painter.drawRect(QRectF(geom.topLeft(), geom.bottomRight() - QPointF(1, 1)));
foreach (const Point &point, m_points) {
for (const Point &point : qAsConst(m_points)) {
if (geom.contains(point.pos)) {
if (point.type == MouseRelease)
drawEllipse(point.pos, point.horizontalDiameter, point.verticalDiameter, point.color(), painter);
@ -397,7 +399,7 @@ void TouchTestWidget::paintEvent(QPaintEvent *)
fillEllipse(point.pos, point.horizontalDiameter, point.verticalDiameter, point.color(), painter);
}
}
foreach (const GesturePtr &gp, m_gestures)
for (const GesturePtr &gp : qAsConst(m_gestures))
gp->draw(geom, painter);
}
@ -429,24 +431,24 @@ MainWindow::MainWindow()
QMenu *fileMenu = menuBar()->addMenu("File");
QAction *dumpDeviceAction = fileMenu->addAction(QStringLiteral("Dump devices"));
dumpDeviceAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D));
connect(dumpDeviceAction, SIGNAL(triggered()), this, SLOT(dumpTouchDevices()));
connect(dumpDeviceAction, &QAction::triggered, this, &MainWindow::dumpTouchDevices);
toolBar->addAction(dumpDeviceAction);
QAction *clearLogAction = fileMenu->addAction(QStringLiteral("Clear Log"));
clearLogAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_L));
connect(clearLogAction, SIGNAL(triggered()), m_logTextEdit, SLOT(clear()));
connect(clearLogAction, &QAction::triggered, m_logTextEdit, &QPlainTextEdit::clear);
toolBar->addAction(clearLogAction);
QAction *toggleDrawPointAction = fileMenu->addAction(QStringLiteral("Draw Points"));
toggleDrawPointAction->setCheckable(true);
toggleDrawPointAction->setChecked(m_touchWidget->drawPoints());
connect(toggleDrawPointAction, SIGNAL(toggled(bool)), m_touchWidget, SLOT(setDrawPoints(bool)));
connect(toggleDrawPointAction, &QAction::toggled, m_touchWidget, &TouchTestWidget::setDrawPoints);
toolBar->addAction(toggleDrawPointAction);
QAction *clearPointAction = fileMenu->addAction(QStringLiteral("Clear Points"));
clearPointAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_P));
connect(clearPointAction, SIGNAL(triggered()), m_touchWidget, SLOT(clearPoints()));
connect(clearPointAction, &QAction::triggered, m_touchWidget, &TouchTestWidget::clearPoints);
toolBar->addAction(clearPointAction);
QAction *quitAction = fileMenu->addAction(QStringLiteral("Quit"));
quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
connect(quitAction, &QAction::triggered, qApp, &QCoreApplication::quit);
toolBar->addAction(quitAction);
QSplitter *mainSplitter = new QSplitter(Qt::Vertical, this);
@ -541,7 +543,7 @@ int main(int argc, char *argv[])
: static_cast<QObject *>(w.touchWidget());
EventFilter *filter = new EventFilter(eventTypes, filterTarget);
filterTarget->installEventFilter(filter);
QObject::connect(filter, SIGNAL(eventReceived(QString)), &w, SLOT(appendToLog(QString)));
QObject::connect(filter, &EventFilter::eventReceived, &w, &MainWindow::appendToLog);
return a.exec();
}

View File

@ -29,6 +29,8 @@
#ifndef EMULATIONDETECTOR_H
#define EMULATIONDETECTOR_H
#include <QtCore/qglobal.h>
#if defined(Q_OS_LINUX) && defined(Q_PROCESSOR_ARM)
#define SHOULD_CHECK_ARM_ON_X86