diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-02-28 08:40:53 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-02-28 09:48:30 +0100 |
commit | a450cce6b670dbcac84fcc4a66fc632b31ce8414 (patch) | |
tree | 35b77fa22c4def97b619bd3a87f6d394e452bb2e /src/widgets | |
parent | f6f6eab89f57fb0db8f623f4a92a7b9c4ba6e9ea (diff) | |
parent | 4c86e667d220e27bb4b6e370675ffb2872e8521c (diff) |
Merge remote-tracking branch 'origin/5.15' into dev
Change-Id: I469b0501cc65fc5ce4d797a69ae89405cc69c7f8
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/dialogs/qfiledialog.cpp | 10 | ||||
-rw-r--r-- | src/widgets/dialogs/qwizard.cpp | 12 | ||||
-rw-r--r-- | src/widgets/dialogs/qwizard.h | 5 | ||||
-rw-r--r-- | src/widgets/kernel/qshortcut.h | 10 | ||||
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 2 | ||||
-rw-r--r-- | src/widgets/widgets/qcombobox.cpp | 2 | ||||
-rw-r--r-- | src/widgets/widgets/qcombobox.h | 7 | ||||
-rw-r--r-- | src/widgets/widgets/qdatetimeedit.cpp | 31 | ||||
-rw-r--r-- | src/widgets/widgets/qdockwidget.h | 5 | ||||
-rw-r--r-- | src/widgets/widgets/qlcdnumber.cpp | 2 | ||||
-rw-r--r-- | src/widgets/widgets/qlineedit.cpp | 28 | ||||
-rw-r--r-- | src/widgets/widgets/qstatusbar.h | 1 |
12 files changed, 83 insertions, 32 deletions
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index 437ce4a114..3fb5578153 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -1302,8 +1302,12 @@ QStringList QFileDialog::selectedFiles() const QStringList files; const QList<QUrl> userSelectedFiles = d->userSelectedFiles(); files.reserve(userSelectedFiles.size()); - for (const QUrl &file : userSelectedFiles) - files.append(file.toLocalFile()); + for (const QUrl &file : userSelectedFiles) { + if (file.isLocalFile() || file.isEmpty()) + files.append(file.toLocalFile()); + else + files.append(file.toString()); + } if (files.isEmpty() && d->usingWidgets()) { const FileMode fm = fileMode(); if (fm != ExistingFile && fm != ExistingFiles) @@ -3151,7 +3155,7 @@ void QFileDialogPrivate::createWidgets() // filetype qFileDialogUi->fileTypeCombo->setDuplicatesEnabled(false); - qFileDialogUi->fileTypeCombo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength); + qFileDialogUi->fileTypeCombo->setSizeAdjustPolicy(QComboBox::AdjustToContentsOnFirstShow); qFileDialogUi->fileTypeCombo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); QObject::connect(qFileDialogUi->fileTypeCombo, SIGNAL(activated(int)), q, SLOT(_q_useNameFilter(int))); diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp index 31e32bb931..b0f4312f40 100644 --- a/src/widgets/dialogs/qwizard.cpp +++ b/src/widgets/dialogs/qwizard.cpp @@ -2384,13 +2384,23 @@ bool QWizard::hasVisitedPage(int theid) const \sa hasVisitedPage() */ -QList<int> QWizard::visitedPages() const +QList<int> QWizard::visitedIds() const { Q_D(const QWizard); return d->history; } /*! + \obsolete Use visitedIds() instead +*/ +#if QT_DEPRECATED_SINCE(5, 15) +QList<int> QWizard::visitedPages() const +{ + return visitedIds(); +} +#endif + +/*! Returns the list of page IDs. \since 4.5 */ diff --git a/src/widgets/dialogs/qwizard.h b/src/widgets/dialogs/qwizard.h index ef71efa0cb..a40635c4a5 100644 --- a/src/widgets/dialogs/qwizard.h +++ b/src/widgets/dialogs/qwizard.h @@ -128,7 +128,10 @@ public: void removePage(int id); QWizardPage *page(int id) const; bool hasVisitedPage(int id) const; - QList<int> visitedPages() const; // ### Qt 6: visitedIds()? +#if QT_DEPRECATED_SINCE(5, 15) + QList<int> visitedPages() const; +#endif + QList<int> visitedIds() const; QList<int> pageIds() const; void setStartId(int id); int startId() const; diff --git a/src/widgets/kernel/qshortcut.h b/src/widgets/kernel/qshortcut.h index 6c92f87c46..a519a8696a 100644 --- a/src/widgets/kernel/qshortcut.h +++ b/src/widgets/kernel/qshortcut.h @@ -90,7 +90,8 @@ public: template<class Obj1, typename Func1> QShortcut(const QKeySequence &key, QWidget *parent, const Obj1 *object1, Func1 slot1, - Qt::ShortcutContext context = Qt::WindowShortcut) + Qt::ShortcutContext context = Qt::WindowShortcut, + typename std::enable_if<QtPrivate::IsPointerToTypeDerivedFromQObject<Obj1*>::Value>::type* = 0) : QShortcut(key, parent, static_cast<const char*>(nullptr), static_cast<const char*>(nullptr), context) { connect(this, &QShortcut::activated, object1, std::move(slot1)); @@ -98,7 +99,8 @@ public: template<class Obj1, typename Func1, typename Func2> QShortcut(const QKeySequence &key, QWidget *parent, const Obj1 *object1, Func1 slot1, Func2 slot2, - Qt::ShortcutContext context = Qt::WindowShortcut) + Qt::ShortcutContext context = Qt::WindowShortcut, + typename std::enable_if<QtPrivate::IsPointerToTypeDerivedFromQObject<Obj1*>::Value>::type* = 0) : QShortcut(key, parent, static_cast<const char*>(nullptr), static_cast<const char*>(nullptr), context) { connect(this, &QShortcut::activated, object1, std::move(slot1)); @@ -108,7 +110,9 @@ public: QShortcut(const QKeySequence &key, QWidget *parent, const Obj1 *object1, Func1 slot1, const Obj2 *object2, Func2 slot2, - Qt::ShortcutContext context = Qt::WindowShortcut) + Qt::ShortcutContext context = Qt::WindowShortcut, + typename std::enable_if<QtPrivate::IsPointerToTypeDerivedFromQObject<Obj1*>::Value>::type* = 0, + typename std::enable_if<QtPrivate::IsPointerToTypeDerivedFromQObject<Obj2*>::Value>::type* = 0) : QShortcut(key, parent, static_cast<const char*>(nullptr), static_cast<const char*>(nullptr), context) { connect(this, &QShortcut::activated, object1, std::move(slot1)); diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index b4699ae040..03d6ea31e9 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -395,7 +395,7 @@ void QWidget::setAutoFillBackground(bool enabled) Every widget's constructor accepts one or two standard arguments: \list 1 - \li \c{QWidget *parent = \nullptr} is the parent of the new widget. + \li \c{QWidget *parent = nullptr} is the parent of the new widget. If it is \nullptr (the default), the new widget will be a window. If not, it will be a child of \e parent, and be constrained by \e parent's geometry (unless you specify Qt::Window as window flag). diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 9c1bd1e79a..47993b8f3b 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -894,7 +894,7 @@ QStyleOptionComboBox QComboBoxPrivateContainer::comboStyleOption() const \value AdjustToContents The combobox will always adjust to the contents \value AdjustToContentsOnFirstShow The combobox will adjust to its contents the first time it is shown. - \value AdjustToMinimumContentsLength Use AdjustToContents or AdjustToContentsOnFirstShow instead. + \omitvalue AdjustToMinimumContentsLength \value AdjustToMinimumContentsLengthWithIcon The combobox will adjust to \l minimumContentsLength plus space for an icon. For performance reasons use this policy on large models. */ diff --git a/src/widgets/widgets/qcombobox.h b/src/widgets/widgets/qcombobox.h index 444c834e88..99816954fa 100644 --- a/src/widgets/widgets/qcombobox.h +++ b/src/widgets/widgets/qcombobox.h @@ -137,8 +137,11 @@ public: enum SizeAdjustPolicy { AdjustToContents, AdjustToContentsOnFirstShow, - AdjustToMinimumContentsLength, // ### Qt 6: remove - AdjustToMinimumContentsLengthWithIcon +#if QT_DEPRECATED_SINCE(5, 15) + AdjustToMinimumContentsLength Q_DECL_ENUMERATOR_DEPRECATED_X( + "Use AdjustToContents or AdjustToContentsOnFirstShow"), // ### Qt 6: remove +#endif + AdjustToMinimumContentsLengthWithIcon = AdjustToContentsOnFirstShow + 2 }; Q_ENUM(SizeAdjustPolicy) diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index 48588b1e8e..105318ba20 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -683,7 +683,8 @@ void QDateTimeEdit::setTimeRange(QTime min, QTime max) \brief The currently displayed fields of the date time edit. Returns a bit set of the displayed sections for this format. - \a setDisplayFormat(), displayFormat() + + \sa setDisplayFormat(), displayFormat() */ QDateTimeEdit::Sections QDateTimeEdit::displayedSections() const @@ -696,7 +697,8 @@ QDateTimeEdit::Sections QDateTimeEdit::displayedSections() const \property QDateTimeEdit::currentSection \brief The current section of the spinbox. - \a setCurrentSection() + + \sa setCurrentSection() */ QDateTimeEdit::Section QDateTimeEdit::currentSection() const @@ -776,8 +778,7 @@ int QDateTimeEdit::sectionCount() const the cursorPosition is 5, currentSectionIndex returns 1. If the cursorPosition is 3, currentSectionIndex is 0, and so on. - \a setCurrentSection() - \sa currentSection() + \sa setCurrentSection(), currentSection() */ int QDateTimeEdit::currentSectionIndex() const @@ -1448,7 +1449,16 @@ void QDateTimeEdit::fixup(QString &input) const QValidator::State state; int copy = d->edit->cursorPosition(); - d->validateAndInterpret(input, copy, state, true); + QDateTime value = d->validateAndInterpret(input, copy, state, true); + /* + String was valid, but the datetime still is not; use the time that + has the same distance from epoch. + CorrectToPreviousValue correction is handled by QAbstractSpinBox. + */ + if (!value.isValid() && d->correctionMode == QAbstractSpinBox::CorrectToNearestValue) { + value = QDateTime::fromMSecsSinceEpoch(value.toMSecsSinceEpoch(), value.timeSpec()); + input = textFromDateTime(value); + } } @@ -2085,6 +2095,17 @@ QDateTime QDateTimeEditPrivate::stepBy(int sectionIndex, int steps, bool test) c const int oldDay = v.date().day(calendar); setDigit(v, sectionIndex, val); + /* + Stepping into a daylight saving time that doesn't exist, + so use the time that has the same distance from epoch. + */ + if (!v.isValid()) { + auto msecsSinceEpoch = v.toMSecsSinceEpoch(); + // decreasing from e.g 3am to 2am would get us back to 3am, but we want 1am + if (steps < 0 && sn.type & HourSectionMask) + msecsSinceEpoch -= 3600 * 1000; + v = QDateTime::fromMSecsSinceEpoch(msecsSinceEpoch, v.timeSpec()); + } // if this sets year or month it will make // sure that days are lowered if needed. diff --git a/src/widgets/widgets/qdockwidget.h b/src/widgets/widgets/qdockwidget.h index b53a991dae..36dff4d420 100644 --- a/src/widgets/widgets/qdockwidget.h +++ b/src/widgets/widgets/qdockwidget.h @@ -78,7 +78,10 @@ public: DockWidgetVerticalTitleBar = 0x08, DockWidgetFeatureMask = 0x0f, - AllDockWidgetFeatures = DockWidgetClosable|DockWidgetMovable|DockWidgetFloatable, // ### Qt 6: remove +#if QT_DEPRECATED_SINCE(5, 15) + AllDockWidgetFeatures Q_DECL_ENUMERATOR_DEPRECATED = + DockWidgetClosable|DockWidgetMovable|DockWidgetFloatable, // ### Qt 6: remove +#endif NoDockWidgetFeatures = 0x00, Reserved = 0xff diff --git a/src/widgets/widgets/qlcdnumber.cpp b/src/widgets/widgets/qlcdnumber.cpp index 3ddada4514..4d299d8739 100644 --- a/src/widgets/widgets/qlcdnumber.cpp +++ b/src/widgets/widgets/qlcdnumber.cpp @@ -713,7 +713,7 @@ void QLCDNumber::paintEvent(QPaintEvent *) void QLCDNumberPrivate::internalSetString(const QString& s) { Q_Q(QLCDNumber); - QString buffer; + QString buffer(ndigits, QChar()); int i; int len = s.length(); QBitArray newPoints(ndigits); diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index 9faf161cb1..0ba3611cfd 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -1202,8 +1202,8 @@ QMargins QLineEdit::textMargins() const The input mask is an input template string. It can contain the following elements: \table - \row \li Mask Characters \li Defines the class of input characters that are - considered valid in this position + \row \li Mask Characters \li Defines the \l {QChar::} {Category} of input characters + that are considered valid in this position \row \li Meta Characters \li Various special meanings \row \li Separators \li All other characters are regarded as immutable separators \endtable @@ -1212,17 +1212,21 @@ QMargins QLineEdit::textMargins() const \table \header \li Mask Character \li Meaning - \row \li \c A \li ASCII alphabetic character required. A-Z, a-z. - \row \li \c a \li ASCII alphabetic character permitted but not required. - \row \li \c N \li ASCII alphanumeric character required. A-Z, a-z, 0-9. - \row \li \c n \li ASCII alphanumeric character permitted but not required. + \row \li \c A \li character of the Letter category required, such as A-Z, a-z. + \row \li \c a \li character of the Letter category permitted but not required. + \row \li \c N \li character of the Letter or Number category required, such as + A-Z, a-z, 0-9. + \row \li \c n \li character of the Letter or Number category permitted but not required. \row \li \c X \li Any non-blank character required. \row \li \c x \li Any non-blank character permitted but not required. - \row \li \c 9 \li ASCII digit required. 0-9. - \row \li \c 0 \li ASCII digit permitted but not required. - \row \li \c D \li ASCII digit required. 1-9. - \row \li \c d \li ASCII digit permitted but not required (1-9). - \row \li \c # \li ASCII digit or plus/minus sign permitted but not required. + \row \li \c 9 \li character of the Number category required, e.g 0-9. + \row \li \c 0 \li character of the Number category permitted but not required. + \row \li \c D \li character of the Number category and larger than zero required, + such as 1-9 + \row \li \c d \li character of the Number category and larger than zero permitted but not + required, such as 1-9. + \row \li \c # \li character of the Number category, or plus/minus sign permitted but not + required. \row \li \c H \li Hexadecimal character required. A-F, a-f, 0-9. \row \li \c h \li Hexadecimal character permitted but not required. \row \li \c B \li Binary character required. 0-1. @@ -1264,7 +1268,7 @@ QMargins QLineEdit::textMargins() const To get range control (e.g., for an IP address) use masks together with \l{setValidator()}{validators}. - \sa maxLength + \sa maxLength, QChar::isLetter(), QChar::isNumber(), QChar::digitValue() */ QString QLineEdit::inputMask() const { diff --git a/src/widgets/widgets/qstatusbar.h b/src/widgets/widgets/qstatusbar.h index 2492e8487f..976e45f9ed 100644 --- a/src/widgets/widgets/qstatusbar.h +++ b/src/widgets/widgets/qstatusbar.h @@ -83,7 +83,6 @@ protected: void paintEvent(QPaintEvent *) override; void resizeEvent(QResizeEvent *) override; - // ### Qt 6: consider making reformat() and hideOrShow() private void reformat(); void hideOrShow(); bool event(QEvent *) override; |