diff options
Diffstat (limited to 'src/widgets/kernel')
48 files changed, 494 insertions, 314 deletions
diff --git a/src/widgets/kernel/kernel.pri b/src/widgets/kernel/kernel.pri index 0060ad2d31..b40a33b2af 100644 --- a/src/widgets/kernel/kernel.pri +++ b/src/widgets/kernel/kernel.pri @@ -5,8 +5,10 @@ PRECOMPILED_HEADER = kernel/qt_widgets_pch.h KERNEL_P= kernel HEADERS += \ - kernel/qaction.h \ - kernel/qaction_p.h \ + kernel/qtwidgetsglobal.h \ + kernel/qtwidgetsglobal_p.h \ + kernel/qaction.h \ + kernel/qaction_p.h \ kernel/qactiongroup.h \ kernel/qapplication.h \ kernel/qapplication_p.h \ diff --git a/src/widgets/kernel/qaction.cpp b/src/widgets/kernel/qaction.cpp index 718ecffcc9..88b29e9147 100644 --- a/src/widgets/kernel/qaction.cpp +++ b/src/widgets/kernel/qaction.cpp @@ -279,12 +279,8 @@ void QActionPrivate::setShortcutEnabled(bool enable, QShortcutMap &map) group the action will be automatically inserted into the group. */ QAction::QAction(QObject* parent) - : QObject(*(new QActionPrivate), parent) + : QAction(*new QActionPrivate, parent) { - Q_D(QAction); - d->group = qobject_cast<QActionGroup *>(parent); - if (d->group) - d->group->addAction(this); } @@ -302,13 +298,10 @@ QAction::QAction(QObject* parent) */ QAction::QAction(const QString &text, QObject* parent) - : QObject(*(new QActionPrivate), parent) + : QAction(parent) { Q_D(QAction); d->text = text; - d->group = qobject_cast<QActionGroup *>(parent); - if (d->group) - d->group->addAction(this); } /*! @@ -324,14 +317,10 @@ QAction::QAction(const QString &text, QObject* parent) setToolTip(). */ QAction::QAction(const QIcon &icon, const QString &text, QObject* parent) - : QObject(*(new QActionPrivate), parent) + : QAction(text, parent) { Q_D(QAction); d->icon = icon; - d->text = text; - d->group = qobject_cast<QActionGroup *>(parent); - if (d->group) - d->group->addAction(this); } /*! diff --git a/src/widgets/kernel/qaction.h b/src/widgets/kernel/qaction.h index bd491c89ca..97948a2457 100644 --- a/src/widgets/kernel/qaction.h +++ b/src/widgets/kernel/qaction.h @@ -40,6 +40,7 @@ #ifndef QACTION_H #define QACTION_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtGui/qkeysequence.h> #include <QtCore/qstring.h> #include <QtWidgets/qwidget.h> diff --git a/src/widgets/kernel/qaction_p.h b/src/widgets/kernel/qaction_p.h index 84c6774141..8ee71a5ff0 100644 --- a/src/widgets/kernel/qaction_p.h +++ b/src/widgets/kernel/qaction_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "QtWidgets/qaction.h" #include "QtWidgets/qmenu.h" #include "private/qgraphicswidget_p.h" diff --git a/src/widgets/kernel/qactiongroup.h b/src/widgets/kernel/qactiongroup.h index b9d82aeb8c..61c90b911d 100644 --- a/src/widgets/kernel/qactiongroup.h +++ b/src/widgets/kernel/qactiongroup.h @@ -40,6 +40,7 @@ #ifndef QACTIONGROUP_H #define QACTIONGROUP_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qaction.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 86b3282124..df467505d9 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -101,23 +101,13 @@ #include "qdatetime.h" -#ifdef Q_OS_WINCE -extern bool qt_wince_is_smartphone(); //qguifunctions_wince.cpp -extern bool qt_wince_is_mobile(); //qguifunctions_wince.cpp -extern bool qt_wince_is_pocket_pc(); //qguifunctions_wince.cpp -#endif - #include <qpa/qplatformwindow.h> //#define ALIEN_DEBUG static void initResources() { -#if defined(Q_OS_WINCE) - Q_INIT_RESOURCE(qstyle_wince); -#else Q_INIT_RESOURCE(qstyle); -#endif Q_INIT_RESOURCE(qmessagebox); } @@ -171,12 +161,7 @@ static QByteArray nativeStyleClassName() return name; } -#ifdef Q_OS_WINCE -int QApplicationPrivate::autoMaximizeThreshold = -1; -bool QApplicationPrivate::autoSipEnabled = false; -#else bool QApplicationPrivate::autoSipEnabled = true; -#endif QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, int flags) : QApplicationPrivateBase(argc, argv, flags) @@ -352,8 +337,10 @@ void QApplicationPrivate::createEventDispatcher() \sa QCoreApplication, QAbstractEventDispatcher, QEventLoop, QSettings */ +// ### fixme: Qt 6: Remove ColorSpec and accessors. /*! \enum QApplication::ColorSpec + \obsolete \value NormalColor the default color allocation policy \value CustomColor the same as NormalColor for X11; allocates colors @@ -410,8 +397,6 @@ QString QApplicationPrivate::styleSheet; // default application styles #endif QPointer<QWidget> QApplicationPrivate::leaveAfterRelease = 0; -int QApplicationPrivate::app_cspec = QApplication::NormalColor; - QPalette *QApplicationPrivate::sys_pal = 0; // default system palette QPalette *QApplicationPrivate::set_pal = 0; // default palette set by programmer @@ -657,17 +642,6 @@ void QApplicationPrivate::initialize() if (qEnvironmentVariableIntValue("QT_USE_NATIVE_WINDOWS") > 0) QCoreApplication::setAttribute(Qt::AA_NativeWindows); -#ifdef Q_OS_WINCE -#ifdef QT_AUTO_MAXIMIZE_THRESHOLD - autoMaximizeThreshold = QT_AUTO_MAXIMIZE_THRESHOLD; -#else - if (qt_wince_is_mobile()) - autoMaximizeThreshold = 50; - else - autoMaximizeThreshold = -1; -#endif //QT_AUTO_MAXIMIZE_THRESHOLD -#endif //Q_OS_WINCE - #ifndef QT_NO_WHEELEVENT QApplicationPrivate::wheel_scroll_lines = 3; #endif @@ -894,6 +868,7 @@ QApplication::~QApplication() #endif } +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) // #fixme: Remove. static HDC displayDC = 0; // display device context @@ -906,6 +881,7 @@ Q_WIDGETS_EXPORT HDC qt_win_display_dc() // get display D return displayDC; } #endif +#endif void qt_cleanup() { @@ -913,12 +889,14 @@ void qt_cleanup() QColormap::cleanup(); QApplicationPrivate::active_window = 0; //### this should not be necessary +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) if (displayDC) { ReleaseDC(0, displayDC); displayDC = 0; } #endif +#endif } /*! @@ -1023,30 +1001,6 @@ bool QApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventLis */ /*! - \property QApplication::autoMaximizeThreshold - \since 4.4 - \brief defines a threshold for auto maximizing widgets - - \b{The auto maximize threshold is only available as part of Qt for - Windows CE.} - - This property defines a threshold for the size of a window as a percentage - of the screen size. If the minimum size hint of a window exceeds the - threshold, calling show() will cause the window to be maximized - automatically. - - Setting the threshold to 100 or greater means that the widget will always - be maximized. Alternatively, setting the threshold to 50 means that the - widget will be maximized only if the vertical minimum size hint is at least - 50% of the vertical screen size. - - Setting the threshold to -1 disables the feature. - - On Windows CE the default is -1 (i.e., it is disabled). - On Windows Mobile the default is 40. -*/ - -/*! \property QApplication::autoSipEnabled \since 4.5 \brief toggles automatic SIP (software input panel) visibility @@ -1061,19 +1015,6 @@ bool QApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventLis The default is platform dependent. */ - -#ifdef Q_OS_WINCE -void QApplication::setAutoMaximizeThreshold(const int threshold) -{ - QApplicationPrivate::autoMaximizeThreshold = threshold; -} - -int QApplication::autoMaximizeThreshold() const -{ - return QApplicationPrivate::autoMaximizeThreshold; -} -#endif - void QApplication::setAutoSipEnabled(const bool enabled) { QApplicationPrivate::autoSipEnabled = enabled; @@ -1314,17 +1255,21 @@ QStyle* QApplication::setStyle(const QString& style) /*! Returns the color specification. + \obsolete \sa QApplication::setColorSpec() */ int QApplication::colorSpec() { - return QApplicationPrivate::app_cspec; + return QApplication::NormalColor; } /*! Sets the color specification for the application to \a spec. + \obsolete + + This call has no effect. The color specification controls how the application allocates colors when run on a display with a limited amount of colors, e.g. 8 bit / 256 color @@ -1380,10 +1325,7 @@ int QApplication::colorSpec() void QApplication::setColorSpec(int spec) { - if (Q_UNLIKELY(qApp)) - qWarning("QApplication::setColorSpec: This function must be " - "called before the QApplication object is created"); - QApplicationPrivate::app_cspec = spec; + Q_UNUSED(spec) } /*! @@ -3637,7 +3579,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) // We may get here if the widget is subscribed to a gesture, // but has not accepted TouchBegin. Propagate touch events // only if TouchBegin has been accepted. - if (widget && widget->testAttribute(Qt::WA_WState_AcceptedTouchBeginEvent)) + if (widget->testAttribute(Qt::WA_WState_AcceptedTouchBeginEvent)) res = d->notify_helper(widget, e); break; } @@ -3777,7 +3719,7 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e) if (receiver->isWidgetType()) { QWidget *widget = static_cast<QWidget *>(receiver); -#if !defined(Q_OS_WINCE) || (defined(GWES_ICONCURS) && !defined(QT_NO_CURSOR)) +#if !defined(QT_NO_CURSOR) // toggle HasMouse widget state on enter and leave if ((e->type() == QEvent::Enter || e->type() == QEvent::DragEnter) && (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == widget->window())) diff --git a/src/widgets/kernel/qapplication.h b/src/widgets/kernel/qapplication.h index b27fba620e..be5ec2ad05 100644 --- a/src/widgets/kernel/qapplication.h +++ b/src/widgets/kernel/qapplication.h @@ -40,6 +40,7 @@ #ifndef QAPPLICATION_H #define QAPPLICATION_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtCore/qcoreapplication.h> #include <QtGui/qwindowdefs.h> #include <QtCore/qpoint.h> @@ -84,9 +85,6 @@ class Q_WIDGETS_EXPORT QApplication : public QGuiApplication #ifndef QT_NO_STYLE_STYLESHEET Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet) #endif -#ifdef Q_OS_WINCE - Q_PROPERTY(int autoMaximizeThreshold READ autoMaximizeThreshold WRITE setAutoMaximizeThreshold) -#endif Q_PROPERTY(bool autoSipEnabled READ autoSipEnabled WRITE setAutoSipEnabled) public: @@ -101,8 +99,10 @@ public: static void setStyle(QStyle*); static QStyle *setStyle(const QString&); enum ColorSpec { NormalColor=0, CustomColor=1, ManyColor=2 }; - static int colorSpec(); - static void setColorSpec(int); +#if QT_DEPRECATED_SINCE(5, 8) + QT_DEPRECATED static int colorSpec(); + QT_DEPRECATED static void setColorSpec(int); +#endif // QT_DEPRECATED_SINCE(5, 8) #if QT_DEPRECATED_SINCE(5, 0) QT_DEPRECATED static inline void setGraphicsSystem(const QString &) {} #endif @@ -195,10 +195,6 @@ public Q_SLOTS: #ifndef QT_NO_STYLE_STYLESHEET void setStyleSheet(const QString& sheet); #endif -#ifdef Q_OS_WINCE - void setAutoMaximizeThreshold(const int threshold); - int autoMaximizeThreshold() const; -#endif void setAutoSipEnabled(const bool enabled); bool autoSipEnabled() const; static void closeAllWindows(); diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h index 3358cce744..dd0edc7c80 100644 --- a/src/widgets/kernel/qapplication_p.h +++ b/src/widgets/kernel/qapplication_p.h @@ -52,6 +52,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "QtWidgets/qapplication.h" #include "QtGui/qevent.h" #include "QtGui/qfont.h" @@ -90,11 +91,8 @@ extern Q_GUI_EXPORT bool qt_is_gui_used; extern QClipboard *qt_clipboard; #endif -#if defined (Q_OS_WIN32) || defined (Q_OS_CYGWIN) || defined(Q_OS_WINCE) +#if defined (Q_OS_WIN32) || defined (Q_OS_CYGWIN) extern QSysInfo::WinVersion qt_winver; -# ifdef Q_OS_WINCE - extern DWORD qt_cever; -# endif #elif defined (Q_OS_MAC) extern QSysInfo::MacVersion qt_macver; #endif @@ -126,9 +124,6 @@ public: #endif static void reset_instance_pointer(); #endif -#ifdef Q_OS_WINCE - static int autoMaximizeThreshold; -#endif static bool autoSipEnabled; static QString desktopStyleKey(); @@ -189,7 +184,6 @@ public: static QWidgetList *popupWidgets; static QStyle *app_style; static bool overrides_native_style; - static int app_cspec; static QPalette *sys_pal; static QPalette *set_pal; diff --git a/src/widgets/kernel/qboxlayout.h b/src/widgets/kernel/qboxlayout.h index 6c548fbbca..9c7d0e593f 100644 --- a/src/widgets/kernel/qboxlayout.h +++ b/src/widgets/kernel/qboxlayout.h @@ -40,6 +40,7 @@ #ifndef QBOXLAYOUT_H #define QBOXLAYOUT_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qlayout.h> #ifdef QT_INCLUDE_COMPAT #include <QtWidgets/qwidget.h> diff --git a/src/widgets/kernel/qdesktopwidget.h b/src/widgets/kernel/qdesktopwidget.h index 9fb6b293f7..64e1c568eb 100644 --- a/src/widgets/kernel/qdesktopwidget.h +++ b/src/widgets/kernel/qdesktopwidget.h @@ -40,6 +40,7 @@ #ifndef QDESKTOPWIDGET_H #define QDESKTOPWIDGET_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qwidget.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/kernel/qdesktopwidget_p.h b/src/widgets/kernel/qdesktopwidget_p.h index a590024b7c..4846a868aa 100644 --- a/src/widgets/kernel/qdesktopwidget_p.h +++ b/src/widgets/kernel/qdesktopwidget_p.h @@ -51,6 +51,7 @@ #ifndef QDESKTOPWIDGET_P_H #define QDESKTOPWIDGET_P_H +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "QDesktopWidget" #include "private/qwidget_p.h" diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp index d02cb7d6a9..0bc1c029fe 100644 --- a/src/widgets/kernel/qformlayout.cpp +++ b/src/widgets/kernel/qformlayout.cpp @@ -66,6 +66,7 @@ public: int rowCount() const { return m_storage.size() / NumColumns; } void insertRow(int r, const T &value); + void removeRow(int r); // Hmmpf.. Some things are faster that way. const Storage &storage() const { return m_storage; } @@ -85,6 +86,12 @@ void FixedColumnMatrix<T, NumColumns>::insertRow(int r, const T &value) } template <class T, int NumColumns> +void FixedColumnMatrix<T, NumColumns>::removeRow(int r) +{ + m_storage.remove(r * NumColumns, NumColumns); +} + +template <class T, int NumColumns> void FixedColumnMatrix<T, NumColumns>::storageIndexToPosition(int idx, int *rowPtr, int *colPtr) { *rowPtr = idx / NumColumns; @@ -157,6 +164,7 @@ public: int insertRow(int row); void insertRows(int row, int count); + void removeRow(int row); void setItem(int row, QFormLayout::ItemRole role, QLayoutItem *item); void setLayout(int row, QFormLayout::ItemRole role, QLayout *layout); void setWidget(int row, QFormLayout::ItemRole role, QWidget *widget); @@ -919,6 +927,12 @@ void QFormLayoutPrivate::insertRows(int row, int count) } } +void QFormLayoutPrivate::removeRow(int row) +{ + if (uint(row) < uint(m_matrix.rowCount())) + m_matrix.removeRow(row); +} + void QFormLayoutPrivate::setItem(int row, QFormLayout::ItemRole role, QLayoutItem *item) { const bool fullRow = role == QFormLayout::SpanningRole; @@ -1150,6 +1164,28 @@ QLayoutItem* QFormLayoutPrivate::replaceAt(int index, QLayoutItem *newitem) */ /*! + \since 5.8 + + \struct QFormLayout::TakeRowResult + + \brief Contains the result of a QFormLayout::takeRow() call. + + \sa QFormLayout::takeRow() +*/ + +/*! + \variable QFormLayout::TakeRowResult::labelItem + + Contains the layout item corresponding to the label of the row. +*/ + +/*! + \variable QFormLayout::TakeRowResult::fieldItem + + Contains the layout item corresponding to the field of the row. +*/ + +/*! Constructs a new form layout with the given \a parent widget. \sa QWidget::setLayout() @@ -1352,6 +1388,287 @@ void QFormLayout::insertRow(int row, QLayout *layout) invalidate(); } +static QLayoutItem *ownershipCleanedItem(QFormLayoutItem *item, QFormLayout *layout) +{ + if (!item) + return nullptr; + + // grab ownership back from the QFormLayoutItem + QLayoutItem *i = item->item; + item->item = nullptr; + delete item; + + if (QLayout *l = i->layout()) { + // sanity check in case the user passed something weird to QObject::setParent() + if (l->parent() == layout) + l->setParent(nullptr); + } + + return i; +} + +static void clearQLayoutItem(QLayoutItem *item) +{ + if (Q_LIKELY(item)) { + if (QLayout *layout = item->layout()) { + while (QLayoutItem *child = layout->takeAt(0)) { + clearQLayoutItem(child); + delete child; + } + delete layout; + } + delete item->widget(); + delete item->spacerItem(); + } +} + +/*! + \since 5.8 + + Deletes row \a row from this form layout. + + \a row must be non-negative and less than rowCount(). + + After this call, rowCount() is decremented by one. All widgets and + nested layouts that occupied this row are deleted. That includes both + the field widget(s) and the label, if any. All following rows are shifted + up one row and the freed vertical space is redistributed amongst the remaining rows. + + You can use this function to undo a previous addRow() or insertRow(): + \code + QFormLayout *flay = ...; + QPointer<QLineEdit> le = new QLineEdit; + flay->insertRow(2, "User:", le); + // later: + flay->removeRow(2); // le == nullptr at this point + \endcode + + If you want to remove the row from the layout without deleting the widgets, use takeRow() instead. + + \sa takeRow() +*/ +void QFormLayout::removeRow(int row) +{ + TakeRowResult result = takeRow(row); + clearQLayoutItem(result.labelItem); + clearQLayoutItem(result.fieldItem); +} + +/*! + \since 5.8 + + \overload + + Deletes the row corresponding to \a widget from this form layout. + + After this call, rowCount() is decremented by one. All widgets and + nested layouts that occupied this row are deleted. That includes both + the field widget(s) and the label, if any. All following rows are shifted + up one row and the freed vertical space is redistributed amongst the remaining rows. + + You can use this function to undo a previous addRow() or insertRow(): + \code + QFormLayout *flay = ...; + QPointer<QLineEdit> le = new QLineEdit; + flay->insertRow(2, "User:", le); + // later: + flay->removeRow(le); // le == nullptr at this point + \endcode + + If you want to remove the row from the layout without deleting the widgets, use takeRow() instead. + + \sa takeRow() +*/ +void QFormLayout::removeRow(QWidget *widget) +{ + TakeRowResult result = takeRow(widget); + clearQLayoutItem(result.labelItem); + clearQLayoutItem(result.fieldItem); +} + +/*! + \since 5.8 + + \overload + + Deletes the row corresponding to \a layout from this form layout. + + After this call, rowCount() is decremented by one. All widgets and + nested layouts that occupied this row are deleted. That includes both + the field widget(s) and the label, if any. All following rows are shifted + up one row and the freed vertical space is redistributed amongst the remaining rows. + + You can use this function to undo a previous addRow() or insertRow(): + \code + QFormLayout *flay = ...; + QPointer<QVBoxLayout> vbl = new QVBoxLayout; + flay->insertRow(2, "User:", vbl); + // later: + flay->removeRow(layout); // vbl == nullptr at this point + \endcode + + If you want to remove the row from the form layout without deleting the inserted layout, + use takeRow() instead. + + \sa takeRow() +*/ +void QFormLayout::removeRow(QLayout *layout) +{ + TakeRowResult result = takeRow(layout); + clearQLayoutItem(result.labelItem); + clearQLayoutItem(result.fieldItem); +} + +/*! + \since 5.8 + + Removes the specified \a row from this form layout. + + \a row must be non-negative and less than rowCount(). + + \note This function doesn't delete anything. + + After this call, rowCount() is decremented by one. All following rows are shifted + up one row and the freed vertical space is redistributed amongst the remaining rows. + + You can use this function to undo a previous addRow() or insertRow(): + \code + QFormLayout *flay = ...; + QPointer<QLineEdit> le = new QLineEdit; + flay->insertRow(2, "User:", le); + // later: + QFormLayout::TakeRowResult result = flay->takeRow(2); + \endcode + + If you want to remove the row from the layout and delete the widgets, use removeRow() instead. + + \return A structure containing both the widget and + corresponding label layout items + + \sa removeRow() +*/ +QFormLayout::TakeRowResult QFormLayout::takeRow(int row) +{ + Q_D(QFormLayout); + + const int storageIndex = storageIndexFromLayoutItem(d->m_matrix, d->m_things.value(row)); + if (Q_UNLIKELY(storageIndex == -1)) { + qWarning("QFormLayout::takeRow: Invalid row %d", row); + return TakeRowResult(); + } + + int storageRow, dummy; + QFormLayoutPrivate::ItemMatrix::storageIndexToPosition(storageIndex, &storageRow, &dummy); + Q_ASSERT(d->m_matrix(storageRow, dummy)); + + QFormLayoutItem *label = d->m_matrix(storageRow, 0); + QFormLayoutItem *field = d->m_matrix(storageRow, 1); + + Q_ASSERT(field); + + d->m_things.removeOne(label); + d->m_things.removeOne(field); + d->m_matrix.removeRow(storageRow); + + invalidate(); + + TakeRowResult result; + result.labelItem = ownershipCleanedItem(label, this); + result.fieldItem = ownershipCleanedItem(field, this); + return result; +} + +/*! + \since 5.8 + + \overload + + Removes the specified \a widget from this form layout. + + \note This function doesn't delete anything. + + After this call, rowCount() is decremented by one. All following rows are shifted + up one row and the freed vertical space is redistributed amongst the remaining rows. + + \code + QFormLayout *flay = ...; + QPointer<QLineEdit> le = new QLineEdit; + flay->insertRow(2, "User:", le); + // later: + QFormLayout::TakeRowResult result = flay->takeRow(widget); + \endcode + + If you want to remove the row from the layout and delete the widgets, use removeRow() instead. + + \return A structure containing both the widget and + corresponding label layout items + + \sa removeRow() +*/ +QFormLayout::TakeRowResult QFormLayout::takeRow(QWidget *widget) +{ + Q_D(QFormLayout); + if (Q_UNLIKELY(!d->checkWidget(widget))) + return TakeRowResult(); + + int row; + ItemRole role; + getWidgetPosition(widget, &row, &role); + + if (Q_UNLIKELY(row < 0)) { + qWarning("QFormLayout::takeRow: Invalid widget"); + return TakeRowResult(); + } + + return takeRow(row); +} + +/*! + \since 5.8 + + \overload + + Removes the specified \a layout from this form layout. + + \note This function doesn't delete anything. + + After this call, rowCount() is decremented by one. All following rows are shifted + up one row and the freed vertical space is redistributed amongst the remaining rows. + + \code + QFormLayout *flay = ...; + QPointer<QVBoxLayout> vbl = new QVBoxLayout; + flay->insertRow(2, "User:", vbl); + // later: + QFormLayout::TakeRowResult result = flay->takeRow(widget); + \endcode + + If you want to remove the row from the form layout and delete the inserted layout, + use removeRow() instead. + + \return A structure containing both the widget and + corresponding label layout items + + \sa removeRow() +*/ +QFormLayout::TakeRowResult QFormLayout::takeRow(QLayout *layout) +{ + Q_D(QFormLayout); + if (Q_UNLIKELY(!d->checkLayout(layout))) + return TakeRowResult(); + + int row; + ItemRole role; + getLayoutPosition(layout, &row, &role); + + if (Q_UNLIKELY(row < 0)) { + qWarning("QFormLayout::takeRow: Invalid layout"); + return TakeRowResult(); + } + + return takeRow(row); +} + /*! \reimp */ @@ -1408,18 +1725,7 @@ QLayoutItem *QFormLayout::takeAt(int index) invalidate(); - // grab ownership back from the QFormLayoutItem - QLayoutItem *i = item->item; - item->item = 0; - delete item; - - if (QLayout *l = i->layout()) { - // sanity check in case the user passed something weird to QObject::setParent() - if (l->parent() == this) - l->setParent(0); - } - - return i; + return ownershipCleanedItem(item, this); } /*! diff --git a/src/widgets/kernel/qformlayout.h b/src/widgets/kernel/qformlayout.h index 8e4f7b7309..b4185374fd 100644 --- a/src/widgets/kernel/qformlayout.h +++ b/src/widgets/kernel/qformlayout.h @@ -40,6 +40,7 @@ #ifndef QFORMLAYOUT_H #define QFORMLAYOUT_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/QLayout> QT_BEGIN_NAMESPACE @@ -80,6 +81,11 @@ public: }; Q_ENUM(ItemRole) + struct TakeRowResult { + QLayoutItem *labelItem; + QLayoutItem *fieldItem; + }; + explicit QFormLayout(QWidget *parent = Q_NULLPTR); ~QFormLayout(); @@ -114,6 +120,14 @@ public: void insertRow(int row, QWidget *widget); void insertRow(int row, QLayout *layout); + void removeRow(int row); + void removeRow(QWidget *widget); + void removeRow(QLayout *layout); + + TakeRowResult takeRow(int row); + TakeRowResult takeRow(QWidget *widget); + TakeRowResult takeRow(QLayout *layout); + void setItem(int row, ItemRole role, QLayoutItem *item); void setWidget(int row, ItemRole role, QWidget *widget); void setLayout(int row, ItemRole role, QLayout *layout); @@ -153,6 +167,8 @@ private: void resetFormAlignment(); }; +Q_DECLARE_TYPEINFO(QFormLayout::TakeRowResult, Q_PRIMITIVE_TYPE); + QT_END_NAMESPACE #endif diff --git a/src/widgets/kernel/qgesture.h b/src/widgets/kernel/qgesture.h index 57b59abf60..034d1d88c1 100644 --- a/src/widgets/kernel/qgesture.h +++ b/src/widgets/kernel/qgesture.h @@ -40,6 +40,7 @@ #ifndef QGESTURE_H #define QGESTURE_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtCore/qobject.h> #include <QtCore/qlist.h> #include <QtCore/qdatetime.h> diff --git a/src/widgets/kernel/qgesture_p.h b/src/widgets/kernel/qgesture_p.h index b438b81e31..636103c1e1 100644 --- a/src/widgets/kernel/qgesture_p.h +++ b/src/widgets/kernel/qgesture_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "qrect.h" #include "qpoint.h" #include "qgesture.h" diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp index df72c6c4d2..c901285d1a 100644 --- a/src/widgets/kernel/qgesturemanager.cpp +++ b/src/widgets/kernel/qgesturemanager.cpp @@ -75,7 +75,7 @@ static inline int panTouchPoints() const int result = qEnvironmentVariableIntValue(panTouchPointVariable, &ok); if (ok && result >= 1) return result; - qWarning() << "Ignoring invalid value of " << panTouchPointVariable; + qWarning("Ignoring invalid value of %s", panTouchPointVariable); } // Pan should use 1 finger on a touch screen and 2 fingers on touch pads etc. // where 1 finger movements are used for mouse event synthetization. For now, diff --git a/src/widgets/kernel/qgesturemanager_p.h b/src/widgets/kernel/qgesturemanager_p.h index 9cd1f79418..ec51466a63 100644 --- a/src/widgets/kernel/qgesturemanager_p.h +++ b/src/widgets/kernel/qgesturemanager_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "qobject.h" #include "qbasictimer.h" #include "private/qwidget_p.h" diff --git a/src/widgets/kernel/qgesturerecognizer.h b/src/widgets/kernel/qgesturerecognizer.h index f44f763217..04e85c46cc 100644 --- a/src/widgets/kernel/qgesturerecognizer.h +++ b/src/widgets/kernel/qgesturerecognizer.h @@ -40,7 +40,7 @@ #ifndef QGESTURERECOGNIZER_H #define QGESTURERECOGNIZER_H -#include <QtCore/qglobal.h> +#include <QtWidgets/qtwidgetsglobal.h> #include <QtCore/qnamespace.h> #ifndef QT_NO_GESTURES diff --git a/src/widgets/kernel/qgridlayout.cpp b/src/widgets/kernel/qgridlayout.cpp index b58e7fdc9e..29df38f19c 100644 --- a/src/widgets/kernel/qgridlayout.cpp +++ b/src/widgets/kernel/qgridlayout.cpp @@ -746,9 +746,13 @@ void QGridLayoutPrivate::setupSpacings(QVector<QLayoutStruct> &chain, if (orientation == Qt::Vertical) { QGridBox *sibling = vReversed ? previousBox : box; if (sibling) { - QWidget *wid = sibling->item()->widget(); - if (wid) - spacing = qMax(spacing, sibling->item()->geometry().top() - wid->geometry().top() ); + if (sibling->item()->isEmpty()) { + spacing = 0; + } else { + QWidget *wid = sibling->item()->widget(); + if (wid) + spacing = qMax(spacing, sibling->item()->geometry().top() - wid->geometry().top()); + } } } } diff --git a/src/widgets/kernel/qgridlayout.h b/src/widgets/kernel/qgridlayout.h index fc6e70748f..51dd65d181 100644 --- a/src/widgets/kernel/qgridlayout.h +++ b/src/widgets/kernel/qgridlayout.h @@ -40,6 +40,7 @@ #ifndef QGRIDLAYOUT_H #define QGRIDLAYOUT_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qlayout.h> #ifdef QT_INCLUDE_COMPAT #include <QtWidgets/qwidget.h> diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp index 240f525722..0a21ece1dd 100644 --- a/src/widgets/kernel/qlayout.cpp +++ b/src/widgets/kernel/qlayout.cpp @@ -810,7 +810,7 @@ static bool layoutDebug() { static int checked_env = -1; if(checked_env == -1) - checked_env = !!qgetenv("QT_LAYOUT_DEBUG").toInt(); + checked_env = !!qEnvironmentVariableIntValue("QT_LAYOUT_DEBUG"); return checked_env; } @@ -945,12 +945,7 @@ void QLayout::addChildWidget(QWidget *w) void QLayout::setMenuBar(QWidget *widget) { Q_D(QLayout); - -#ifdef Q_OS_WINCE_WM - if (widget && widget->size().height() > 0) -#else if (widget) -#endif addChildWidget(widget); d->menubar = widget; } diff --git a/src/widgets/kernel/qlayout.h b/src/widgets/kernel/qlayout.h index d76e12ca8c..2de12b4f99 100644 --- a/src/widgets/kernel/qlayout.h +++ b/src/widgets/kernel/qlayout.h @@ -40,6 +40,7 @@ #ifndef QLAYOUT_H #define QLAYOUT_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtCore/qobject.h> #include <QtWidgets/qlayoutitem.h> #include <QtWidgets/qsizepolicy.h> diff --git a/src/widgets/kernel/qlayout_p.h b/src/widgets/kernel/qlayout_p.h index 0d70c74fe5..8a1b12a6be 100644 --- a/src/widgets/kernel/qlayout_p.h +++ b/src/widgets/kernel/qlayout_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "private/qobject_p.h" #include "qstyle.h" #include "qsizepolicy.h" diff --git a/src/widgets/kernel/qlayoutengine_p.h b/src/widgets/kernel/qlayoutengine_p.h index 0f7d3fdb90..812fa7cf3b 100644 --- a/src/widgets/kernel/qlayoutengine_p.h +++ b/src/widgets/kernel/qlayoutengine_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "QtWidgets/qlayoutitem.h" #include "QtWidgets/qstyle.h" diff --git a/src/widgets/kernel/qlayoutitem.h b/src/widgets/kernel/qlayoutitem.h index b54a59084b..6f701b9f82 100644 --- a/src/widgets/kernel/qlayoutitem.h +++ b/src/widgets/kernel/qlayoutitem.h @@ -40,6 +40,7 @@ #ifndef QLAYOUTITEM_H #define QLAYOUTITEM_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qsizepolicy.h> #include <QtCore/qrect.h> diff --git a/src/widgets/kernel/qmacgesturerecognizer_p.h b/src/widgets/kernel/qmacgesturerecognizer_p.h index 844d4a6460..be3f3266ac 100644 --- a/src/widgets/kernel/qmacgesturerecognizer_p.h +++ b/src/widgets/kernel/qmacgesturerecognizer_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "qtimer.h" #include "qpoint.h" #include "qgesturerecognizer.h" diff --git a/src/widgets/kernel/qopenglwidget.h b/src/widgets/kernel/qopenglwidget.h index acbbb24c40..b60d79bedb 100644 --- a/src/widgets/kernel/qopenglwidget.h +++ b/src/widgets/kernel/qopenglwidget.h @@ -40,7 +40,7 @@ #ifndef QOPENGLWIDGET_H #define QOPENGLWIDGET_H -#include <QtCore/qglobal.h> +#include <QtWidgets/qtwidgetsglobal.h> #ifndef QT_NO_OPENGL diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp index bf162249d0..7bd9e74924 100644 --- a/src/widgets/kernel/qshortcut.cpp +++ b/src/widgets/kernel/qshortcut.cpp @@ -456,12 +456,11 @@ QShortcut::QShortcut(QWidget *parent) QShortcut::QShortcut(const QKeySequence &key, QWidget *parent, const char *member, const char *ambiguousMember, Qt::ShortcutContext context) - : QObject(*new QShortcutPrivate, parent) + : QShortcut(parent) { QAPP_CHECK("QShortcut"); Q_D(QShortcut); - Q_ASSERT(parent != 0); d->sc_context = context; d->sc_sequence = key; d->redoGrab(qApp->d_func()->shortcutMap); diff --git a/src/widgets/kernel/qshortcut.h b/src/widgets/kernel/qshortcut.h index c3ccbe3c08..22c667c9c1 100644 --- a/src/widgets/kernel/qshortcut.h +++ b/src/widgets/kernel/qshortcut.h @@ -40,6 +40,7 @@ #ifndef QSHORTCUT_H #define QSHORTCUT_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qwidget.h> #include <QtGui/qkeysequence.h> diff --git a/src/widgets/kernel/qsizepolicy.h b/src/widgets/kernel/qsizepolicy.h index 7a1e22fdc2..63b578fbf3 100644 --- a/src/widgets/kernel/qsizepolicy.h +++ b/src/widgets/kernel/qsizepolicy.h @@ -40,6 +40,7 @@ #ifndef QSIZEPOLICY_H #define QSIZEPOLICY_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtCore/qobject.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/kernel/qstackedlayout.h b/src/widgets/kernel/qstackedlayout.h index fb83fddc43..6f5eded1f0 100644 --- a/src/widgets/kernel/qstackedlayout.h +++ b/src/widgets/kernel/qstackedlayout.h @@ -40,6 +40,7 @@ #ifndef QSTACKEDLAYOUT_H #define QSTACKEDLAYOUT_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qlayout.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/kernel/qstandardgestures_p.h b/src/widgets/kernel/qstandardgestures_p.h index abda1a3f6e..9b2cffaa9a 100644 --- a/src/widgets/kernel/qstandardgestures_p.h +++ b/src/widgets/kernel/qstandardgestures_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "qgesturerecognizer.h" #include "private/qgesture_p.h" diff --git a/src/widgets/kernel/qt_widgets_pch.h b/src/widgets/kernel/qt_widgets_pch.h index f58a8895eb..f30202d89e 100644 --- a/src/widgets/kernel/qt_widgets_pch.h +++ b/src/widgets/kernel/qt_widgets_pch.h @@ -47,7 +47,7 @@ // from corelib/global/qt_pch.h #if defined __cplusplus -#include <qglobal.h> +#include <qtwidgetsglobal.h> #ifdef Q_DEAD_CODE_FROM_QT4_WIN diff --git a/src/widgets/kernel/qtooltip.h b/src/widgets/kernel/qtooltip.h index aad6e941c8..5e68eef0a7 100644 --- a/src/widgets/kernel/qtooltip.h +++ b/src/widgets/kernel/qtooltip.h @@ -40,6 +40,7 @@ #ifndef QTOOLTIP_H #define QTOOLTIP_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qwidget.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/kernel/qwidgetsfunctions_wince.h b/src/widgets/kernel/qtwidgetsglobal.h index f2c620a966..f6d003e629 100644 --- a/src/widgets/kernel/qwidgetsfunctions_wince.h +++ b/src/widgets/kernel/qtwidgetsglobal.h @@ -36,25 +36,24 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#ifndef QWIDGETSFUNCTIONS_WCE_H -#define QWIDGETSFUNCTIONS_WCE_H -#include <QtCore/qglobal.h> +#ifndef QTWIDGETSGLOBAL_H +#define QTWIDGETSGLOBAL_H -#ifdef Q_OS_WINCE -#include <QtCore/qfunctions_wince.h> +#include <QtGui/qtguiglobal.h> -#ifdef QT_BUILD_GUI_LIB QT_BEGIN_NAMESPACE -QT_END_NAMESPACE -#endif - -//WinCe 7 has shell support -#ifndef ShellExecute -HINSTANCE qt_wince_ShellExecute(HWND hwnd, LPCWSTR operation, LPCWSTR file, LPCWSTR params, LPCWSTR dir, int showCmd); -#define ShellExecute(a,b,c,d,e,f) qt_wince_ShellExecute(a,b,c,d,e,f) +#ifndef QT_STATIC +# if defined(QT_BUILD_WIDGETS_LIB) +# define Q_WIDGETS_EXPORT Q_DECL_EXPORT +# else +# define Q_WIDGETS_EXPORT Q_DECL_IMPORT +# endif +#else +# define Q_WIDGETS_EXPORT #endif -#endif // Q_OS_WINCE -#endif // QWIDGETSFUNCTIONS_WCE_H +QT_END_NAMESPACE + +#endif // QTGUIGLOBAL_H diff --git a/src/widgets/kernel/qtwidgetsglobal_p.h b/src/widgets/kernel/qtwidgetsglobal_p.h new file mode 100644 index 0000000000..7dd545415c --- /dev/null +++ b/src/widgets/kernel/qtwidgetsglobal_p.h @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWidgets module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QTWIDGETSGLOBAL_P_H +#define QTWIDGETSGLOBAL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtWidgets/qtwidgetsglobal.h> +#include <QtGui/private/qtguiglobal_p.h> + +#endif // QTWIDGETSGLOBAL_P_H diff --git a/src/widgets/kernel/qwhatsthis.h b/src/widgets/kernel/qwhatsthis.h index 0889653e2c..746fd3ff22 100644 --- a/src/widgets/kernel/qwhatsthis.h +++ b/src/widgets/kernel/qwhatsthis.h @@ -40,6 +40,7 @@ #ifndef QWHATSTHIS_H #define QWHATSTHIS_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtCore/qobject.h> #include <QtGui/qcursor.h> diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 4d402ca1bd..25874e9bcc 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1109,11 +1109,7 @@ void QWidgetPrivate::adjustFlags(Qt::WindowFlags &flags, QWidget *w) if (customize) ; // don't modify window flags if the user explicitly set them. else if (type == Qt::Dialog || type == Qt::Sheet) -#ifndef Q_OS_WINCE flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowContextHelpButtonHint | Qt::WindowCloseButtonHint; -#else - flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint; -#endif else if (type == Qt::Tool) flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint; else @@ -2406,9 +2402,8 @@ static inline void fillRegion(QPainter *painter, const QRegion &rgn, const QBrus painter->fillRect(0, 0, painter->device()->width(), painter->device()->height(), brush); painter->restore(); } else { - const QVector<QRect> &rects = rgn.rects(); - for (int i = 0; i < rects.size(); ++i) - painter->fillRect(rects.at(i), brush); + for (const QRect &rect : rgn) + painter->fillRect(rect, brush); } } @@ -4554,7 +4549,7 @@ const QPalette &QWidget::palette() const if (!isEnabled()) { data->pal.setCurrentColorGroup(QPalette::Disabled); } else if ((!isVisible() || isActiveWindow()) -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) && !QApplicationPrivate::isBlockedByModal(const_cast<QWidget *>(this)) #endif ) { @@ -8557,13 +8552,9 @@ QSize QWidgetPrivate::adjustedSize() const #else // all others QRect screen = QApplication::desktop()->screenGeometry(q->pos()); #endif -#if defined (Q_OS_WINCE) - s.setWidth(qMin(s.width(), screen.width())); - s.setHeight(qMin(s.height(), screen.height())); -#else s.setWidth(qMin(s.width(), screen.width()*2/3)); s.setHeight(qMin(s.height(), screen.height()*2/3)); -#endif + if (QTLWExtra *extra = maybeTopData()) extra->sizeAdjusted = true; } @@ -9535,7 +9526,7 @@ void QWidget::focusOutEvent(QFocusEvent *) if (focusPolicy() != Qt::NoFocus || !isWindow()) update(); -#ifndef Q_OS_IOS +#if !defined(QT_PLATFORM_UIKIT) // FIXME: revisit autoSIP logic, QTBUG-42906 if (qApp->autoSipEnabled() && testAttribute(Qt::WA_InputMethodEnabled)) QGuiApplication::inputMethod()->hide(); @@ -10751,10 +10742,8 @@ void QWidget::scroll(int dx, int dy) // Graphics View maintains its own dirty region as a list of rects; // until we can connect item updates directly to the view, we must // separately add a translated dirty region. - if (!d->dirty.isEmpty()) { - foreach (const QRect &rect, (d->dirty.translated(dx, dy)).rects()) - proxy->update(rect); - } + for (const QRect &rect : d->dirty) + proxy->update(rect.translated(dx, dy)); proxy->scroll(dx, dy, proxy->subWidgetRect(this)); return; } @@ -10794,7 +10783,7 @@ void QWidget::scroll(int dx, int dy, const QRect &r) // until we can connect item updates directly to the view, we must // separately add a translated dirty region. if (!d->dirty.isEmpty()) { - foreach (const QRect &rect, (d->dirty.translated(dx, dy) & r).rects()) + for (const QRect &rect : d->dirty.translated(dx, dy) & r) proxy->update(rect); } proxy->scroll(dx, dy, r.translated(proxy->subWidgetRect(this).topLeft().toPoint())); diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h index 43ca76ac7c..2a71710143 100644 --- a/src/widgets/kernel/qwidget.h +++ b/src/widgets/kernel/qwidget.h @@ -40,6 +40,7 @@ #ifndef QWIDGET_H #define QWIDGET_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtGui/qwindowdefs.h> #include <QtCore/qobject.h> #include <QtCore/qmargins.h> diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index 71691a4afa..f2884e7b17 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "QtWidgets/qwidget.h" #include "private/qobject_p.h" #include "QtCore/qrect.h" diff --git a/src/widgets/kernel/qwidgetaction.h b/src/widgets/kernel/qwidgetaction.h index 4adb9b61ea..3da691a430 100644 --- a/src/widgets/kernel/qwidgetaction.h +++ b/src/widgets/kernel/qwidgetaction.h @@ -40,6 +40,7 @@ #ifndef QWIDGETACTION_H #define QWIDGETACTION_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qaction.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/kernel/qwidgetaction_p.h b/src/widgets/kernel/qwidgetaction_p.h index 20da855185..1fbcf236a1 100644 --- a/src/widgets/kernel/qwidgetaction_p.h +++ b/src/widgets/kernel/qwidgetaction_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "private/qaction_p.h" QT_BEGIN_NAMESPACE diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp index 4d37c7f682..81fbe49a43 100644 --- a/src/widgets/kernel/qwidgetbackingstore.cpp +++ b/src/widgets/kernel/qwidgetbackingstore.cpp @@ -67,7 +67,9 @@ QT_BEGIN_NAMESPACE extern QRegion qt_dirtyRegion(QWidget *); +#ifndef QT_NO_OPENGL Q_GLOBAL_STATIC(QPlatformTextureList, qt_dummy_platformTextureList) +#endif /** * Flushes the contents of the \a backingStore into the screen area of \a widget. @@ -174,7 +176,7 @@ static void showYellowThing_win(QWidget *widget, const QRegion ®ion, int msec } i = (i + 1) & 3; - foreach (const QRect &rect, region.rects()) { + for (const QRect &rect : region) { RECT winRect; SetRect(&winRect, rect.left(), rect.top(), rect.right(), rect.bottom()); FillRect(hdc, &winRect, brush); @@ -301,7 +303,7 @@ bool QWidgetBackingStore::bltRect(const QRect &rect, int dx, int dy, QWidget *wi { const QPoint pos(tlwOffset + widget->mapTo(tlw, rect.topLeft())); const QRect tlwRect(QRect(pos, rect.size())); - if (fullUpdatePending || dirty.intersects(tlwRect)) + if (dirty.intersects(tlwRect)) return false; // We don't want to scroll junk. return store->scroll(tlwRect, dx, dy); } @@ -370,7 +372,7 @@ QRegion QWidgetBackingStore::dirtyRegion(QWidget *widget) const const bool widgetDirty = widget && widget != tlw; const QRect tlwRect(topLevelRect()); const QRect surfaceGeometry(tlwRect.topLeft(), store->size()); - if (fullUpdatePending || (surfaceGeometry != tlwRect && surfaceGeometry.size() != tlwRect.size())) { + if (surfaceGeometry != tlwRect && surfaceGeometry.size() != tlwRect.size()) { if (widgetDirty) { const QRect dirtyTlwRect = QRect(QPoint(), tlwRect.size()); const QPoint offset(widget->mapTo(tlw, QPoint())); @@ -548,13 +550,6 @@ void QWidgetBackingStore::markDirty(const QRegion &rgn, QWidget *widget, return; } - //### FIXME fullUpdatePending seems to be always false???? - if (fullUpdatePending) { - if (updateTime == UpdateNow) - sendUpdateRequest(tlw, updateTime); - return; - } - const QPoint offset = widget->mapTo(tlw, QPoint()); if (QWidgetPrivate::get(widget)->renderToTexture) { @@ -647,12 +642,6 @@ void QWidgetBackingStore::markDirty(const QRect &rect, QWidget *widget, return; } - if (fullUpdatePending) { - if (updateTime == UpdateNow) - sendUpdateRequest(tlw, updateTime); - return; - } - if (QWidgetPrivate::get(widget)->renderToTexture) { if (!widget->d_func()->inDirtyList) addDirtyRenderToTextureWidget(widget); @@ -789,7 +778,6 @@ void QWidgetBackingStore::updateLists(QWidget *cur) QWidgetBackingStore::QWidgetBackingStore(QWidget *topLevel) : tlw(topLevel), dirtyOnScreenWidgets(0), - fullUpdatePending(0), updateRequestSent(0), textureListWatcher(0), perfFrames(0) @@ -1168,7 +1156,6 @@ void QWidgetBackingStore::sync() for (int i = 0; i < dirtyWidgets.size(); ++i) resetWidget(dirtyWidgets.at(i)); dirtyWidgets.clear(); - fullUpdatePending = false; } return; } @@ -1185,7 +1172,7 @@ void QWidgetBackingStore::doSync() const bool inTopLevelResize = tlw->d_func()->maybeTopData()->inTopLevelResize; const QRect tlwRect(topLevelRect()); const QRect surfaceGeometry(tlwRect.topLeft(), store->size()); - if ((fullUpdatePending || inTopLevelResize || surfaceGeometry.size() != tlwRect.size()) && !updatesDisabled) { + if ((inTopLevelResize || surfaceGeometry.size() != tlwRect.size()) && !updatesDisabled) { if (hasStaticContents() && !store->size().isEmpty() ) { // Repaint existing dirty area and newly visible area. const QRect clipRect(0, 0, surfaceGeometry.width(), surfaceGeometry.height()); @@ -1281,7 +1268,6 @@ void QWidgetBackingStore::doSync() tlwExtra->widgetTextures.clear(); findAllTextureWidgetsRecursively(tlw, tlw); qt_window_private(tlw->windowHandle())->compositing = false; // will get updated in qt_flush() - fullUpdatePending = false; #endif if (toClean.isEmpty()) { @@ -1347,9 +1333,8 @@ void QWidgetBackingStore::doSync() updateStaticContentsSize(); dirty = QRegion(); updateRequestSent = false; - const QVector<QRect> rects(toClean.rects()); - for (int i = 0; i < rects.size(); ++i) - tlw->d_func()->extra->proxyWidget->update(rects.at(i)); + for (const QRect &rect : toClean) + tlw->d_func()->extra->proxyWidget->update(rect); return; } #endif diff --git a/src/widgets/kernel/qwidgetbackingstore_p.h b/src/widgets/kernel/qwidgetbackingstore_p.h index fa2b934ff8..16b36423a6 100644 --- a/src/widgets/kernel/qwidgetbackingstore_p.h +++ b/src/widgets/kernel/qwidgetbackingstore_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include <QDebug> #include <QtWidgets/qwidget.h> #include <private/qwidget_p.h> @@ -116,7 +117,7 @@ public: inline bool isDirty() const { - return !(dirtyWidgets.isEmpty() && dirty.isEmpty() && !fullUpdatePending && dirtyRenderToTextureWidgets.isEmpty()); + return !(dirtyWidgets.isEmpty() && dirty.isEmpty() && dirtyRenderToTextureWidgets.isEmpty()); } // ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore). @@ -135,7 +136,6 @@ private: QVector<QWidget *> *dirtyOnScreenWidgets; QList<QWidget *> staticWidgets; QBackingStore *store; - uint fullUpdatePending : 1; uint updateRequestSent : 1; QPoint tlwOffset; diff --git a/src/widgets/kernel/qwidgetsfunctions_wince.cpp b/src/widgets/kernel/qwidgetsfunctions_wince.cpp deleted file mode 100644 index 2bf8c6563b..0000000000 --- a/src/widgets/kernel/qwidgetsfunctions_wince.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "qwidgetsfunctions_wince.h" -#include <shellapi.h> - -QT_USE_NAMESPACE - -#ifndef ShellExecute -HINSTANCE qt_wince_ShellExecute(HWND hwnd, LPCWSTR, LPCWSTR file, LPCWSTR params, LPCWSTR dir, int showCmd) -{ - SHELLEXECUTEINFO info; - info.hwnd = hwnd; - info.lpVerb = L"Open"; - info.lpFile = file; - info.lpParameters = params; - info.lpDirectory = dir; - info.nShow = showCmd; - info.cbSize = sizeof(info); - ShellExecuteEx(&info); - return info.hInstApp; -} -#endif - -// Internal Qt ----------------------------------------------------- -bool qt_wince_is_platform(const QString &platformString) { - wchar_t tszPlatform[64]; - if (SystemParametersInfo(SPI_GETPLATFORMNAME, sizeof(tszPlatform) / sizeof(wchar_t), tszPlatform, 0)) - if (0 == _tcsicmp(reinterpret_cast<const wchar_t *> (platformString.utf16()), tszPlatform)) - return true; - return false; -} - -int qt_wince_get_build() -{ - OSVERSIONINFO osvi; - osvi.dwOSVersionInfoSize = sizeof(osvi); - if (GetVersionEx(&osvi)) - return osvi.dwBuildNumber; - return 0; -} - -int qt_wince_get_version() -{ - OSVERSIONINFO osvi; - osvi.dwOSVersionInfoSize = sizeof(osvi); - if (GetVersionEx(&osvi)) - return (osvi.dwMajorVersion * 10 + osvi.dwMinorVersion); - return 0; -} - -bool qt_wince_is_windows_mobile_65() -{ - const DWORD dwFirstWM65BuildNumber = 21139; - OSVERSIONINFO osvi; - osvi.dwOSVersionInfoSize = sizeof(osvi); - if (!GetVersionEx(&osvi)) - return false; - return osvi.dwMajorVersion > 5 - || (osvi.dwMajorVersion == 5 && (osvi.dwMinorVersion > 2 || - (osvi.dwMinorVersion == 2 && osvi.dwBuildNumber >= dwFirstWM65BuildNumber))); -} - -bool qt_wince_is_pocket_pc() { - return qt_wince_is_platform(QString::fromLatin1("PocketPC")); -} - -bool qt_wince_is_smartphone() { - return qt_wince_is_platform(QString::fromLatin1("Smartphone")); -} -bool qt_wince_is_mobile() { - return (qt_wince_is_smartphone() || qt_wince_is_pocket_pc()); -} - -bool qt_wince_is_high_dpi() { - if (!qt_wince_is_pocket_pc()) - return false; - HDC deviceContext = GetDC(0); - int dpi = GetDeviceCaps(deviceContext, LOGPIXELSX); - ReleaseDC(0, deviceContext); - if ((dpi < 1000) && (dpi > 0)) - return dpi > 96; - else - return false; -} diff --git a/src/widgets/kernel/qwidgetwindow_p.h b/src/widgets/kernel/qwidgetwindow_p.h index a0d79b2b72..edf2383596 100644 --- a/src/widgets/kernel/qwidgetwindow_p.h +++ b/src/widgets/kernel/qwidgetwindow_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include <QtGui/qwindow.h> #include <QtCore/private/qobject_p.h> diff --git a/src/widgets/kernel/qwindowcontainer_p.h b/src/widgets/kernel/qwindowcontainer_p.h index 557a56169e..1d838c8dd6 100644 --- a/src/widgets/kernel/qwindowcontainer_p.h +++ b/src/widgets/kernel/qwindowcontainer_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include <QtWidgets/qwidget.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/kernel/win.pri b/src/widgets/kernel/win.pri index e2d5afdeec..7cef2d14a8 100644 --- a/src/widgets/kernel/win.pri +++ b/src/widgets/kernel/win.pri @@ -2,6 +2,6 @@ # -------------------------------------------------------------------- INCLUDEPATH += ../3rdparty/wintab -!wince:!winrt { - LIBS_PRIVATE *= -lshell32 -} +!winrt: LIBS_PRIVATE *= -lshell32 -luxtheme -ldwmapi +# Override MinGW's definition in _mingw.h +mingw: DEFINES += WINVER=0x600 _WIN32_WINNT=0x0600 |