diff options
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r-- | src/widgets/widgets/qabstractbutton.cpp | 4 | ||||
-rw-r--r-- | src/widgets/widgets/qabstractscrollarea.cpp | 2 | ||||
-rw-r--r-- | src/widgets/widgets/qcombobox.cpp | 32 | ||||
-rw-r--r-- | src/widgets/widgets/qcombobox.h | 4 | ||||
-rw-r--r-- | src/widgets/widgets/qdatetimeedit_p.h | 14 | ||||
-rw-r--r-- | src/widgets/widgets/qlineedit.cpp | 20 | ||||
-rw-r--r-- | src/widgets/widgets/qmainwindow.cpp | 10 | ||||
-rw-r--r-- | src/widgets/widgets/qmenu.cpp | 6 | ||||
-rw-r--r-- | src/widgets/widgets/qmenu.h | 2 | ||||
-rw-r--r-- | src/widgets/widgets/qmenu_p.h | 2 | ||||
-rw-r--r-- | src/widgets/widgets/qtabbar.cpp | 4 | ||||
-rw-r--r-- | src/widgets/widgets/qtoolbar.cpp | 12 | ||||
-rw-r--r-- | src/widgets/widgets/qtoolbar_p.h | 4 | ||||
-rw-r--r-- | src/widgets/widgets/qtoolbarlayout.cpp | 4 | ||||
-rw-r--r-- | src/widgets/widgets/qwidgettextcontrol.cpp | 1 |
15 files changed, 71 insertions, 50 deletions
diff --git a/src/widgets/widgets/qabstractbutton.cpp b/src/widgets/widgets/qabstractbutton.cpp index 77ffda10b0..6e42005e86 100644 --- a/src/widgets/widgets/qabstractbutton.cpp +++ b/src/widgets/widgets/qabstractbutton.cpp @@ -245,7 +245,7 @@ void QAbstractButtonPrivate::notifyChecked() void QAbstractButtonPrivate::moveFocus(int key) { - QList<QAbstractButton *> buttonList = queryButtonList();; + QList<QAbstractButton *> buttonList = queryButtonList(); #if QT_CONFIG(buttongroup) bool exclusive = group ? group->d_func()->exclusive : autoExclusive; #else @@ -265,7 +265,7 @@ void QAbstractButtonPrivate::moveFocus(int key) for (int i = 0; i < buttonList.count(); ++i) { QAbstractButton *button = buttonList.at(i); if (button != f && button->window() == f->window() && button->isEnabled() && !button->isHidden() && - (autoExclusive || (button->focusPolicy() & focus_flag) == focus_flag)) { + (exclusive || (button->focusPolicy() & focus_flag) == focus_flag)) { QRect buttonRect = button->rect().translated(button->mapToGlobal(QPoint(0,0))); QPoint p = buttonRect.center(); diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp index 257cffda62..6bc88f129d 100644 --- a/src/widgets/widgets/qabstractscrollarea.cpp +++ b/src/widgets/widgets/qabstractscrollarea.cpp @@ -308,7 +308,7 @@ void QAbstractScrollAreaPrivate::init() q->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); layoutChildren(); -#ifndef Q_OS_OSX +#ifndef Q_OS_MACOS # ifndef QT_NO_GESTURES viewport->grabGesture(Qt::PanGesture); # endif diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 47993b8f3b..8f195381e4 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtWidgets module of the Qt Toolkit. @@ -904,7 +904,8 @@ QStyleOptionComboBox QComboBoxPrivateContainer::comboStyleOption() const This signal is sent when the user chooses an item in the combobox. The item's \a index is passed. Note that this signal is sent even when the choice is not changed. If you need to know when the - choice actually changes, use signal currentIndexChanged(). + choice actually changes, use signal currentIndexChanged() or + currentTextChanged(). */ /*! @@ -914,7 +915,8 @@ QStyleOptionComboBox QComboBoxPrivateContainer::comboStyleOption() const This signal is sent when the user chooses an item in the combobox. The item's \a text is passed. Note that this signal is sent even when the choice is not changed. If you need to know when the - choice actually changes, use signal currentIndexChanged(). + choice actually changes, use signal currentIndexChanged() or + currentTextChanged(). */ /*! @@ -933,13 +935,13 @@ QStyleOptionComboBox QComboBoxPrivateContainer::comboStyleOption() const */ /*! - \fn void QComboBox::currentIndexChanged(int index, const QString &text) - \since 5.15 + \fn void QComboBox::currentIndexChanged(int index) + \since 4.1 This signal is sent whenever the currentIndex in the combobox changes either through user interaction or programmatically. The - item's \a index is passed or -1 if the combobox becomes empty or - the currentIndex was reset. The item's \a text is also passed. + item's \a index is passed or -1 if the combobox becomes empty or the + currentIndex was reset. */ /*! @@ -971,7 +973,6 @@ QComboBox::QComboBox(QComboBoxPrivate &dd, QWidget *parent) d->init(); } - /*! \class QComboBox \brief The QComboBox widget is a combined button and popup list. @@ -994,9 +995,10 @@ QComboBox::QComboBox(QComboBoxPrivate &dd, QWidget *parent) to clear the displayed string without changing the combobox's contents. - There are two signals emitted if the current item of a combobox - changes, currentIndexChanged() and activated(). - currentIndexChanged() is always emitted regardless if the change + There are three signals emitted if the current item of a combobox + changes, currentIndexChanged(), currentTextChanged() and activated(). + currentIndexChanged() and currentTextChanged() are always emitted + regardless if the change was done programmatically or by user interaction, while activated() is only emitted when the change is caused by user interaction. The highlighted() signal is emitted when the user @@ -1048,7 +1050,7 @@ QComboBox::QComboBox(QComboBoxPrivate &dd, QWidget *parent) void QComboBoxPrivate::init() { Q_Q(QComboBox); -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS // On OS X, only line edits and list views always get tab focus. It's only // when we enable full keyboard access that other controls can get tab focus. // When it's not editable, a combobox looks like a button, and it behaves as @@ -1205,7 +1207,7 @@ void QComboBoxPrivate::updateViewContainerPaletteAndOpacity() void QComboBoxPrivate::updateFocusPolicy() { -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS Q_Q(QComboBox); // See comment in QComboBoxPrivate::init() @@ -1412,7 +1414,7 @@ void QComboBoxPrivate::_q_emitCurrentIndexChanged(const QModelIndex &index) { Q_Q(QComboBox); const QString text = itemText(index); - emit q->currentIndexChanged(index.row(), text); + emit q->currentIndexChanged(index.row()); // signal lineEdit.textChanged already connected to signal currentTextChanged, so don't emit double here if (!lineEdit) emit q->currentTextChanged(text); @@ -2646,7 +2648,7 @@ bool QComboBoxPrivate::showNativePopup() const QRect targetRect = QRect(tlw->mapFromGlobal(q->mapToGlobal(offset)), QSize()); m_platformMenu->showPopup(tlw, QHighDpi::toNativePixels(targetRect, tlw), currentItem); -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS // The Cocoa popup will swallow any mouse release event. // We need to fake one here to un-press the button. QMouseEvent mouseReleased(QEvent::MouseButtonRelease, q->pos(), Qt::LeftButton, diff --git a/src/widgets/widgets/qcombobox.h b/src/widgets/widgets/qcombobox.h index 99816954fa..1411d64143 100644 --- a/src/widgets/widgets/qcombobox.h +++ b/src/widgets/widgets/qcombobox.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtWidgets module of the Qt Toolkit. @@ -233,7 +233,7 @@ Q_SIGNALS: void textActivated(const QString &); void highlighted(int index); void textHighlighted(const QString &); - void currentIndexChanged(int index, const QString &text); + void currentIndexChanged(int index); void currentTextChanged(const QString &); protected: diff --git a/src/widgets/widgets/qdatetimeedit_p.h b/src/widgets/widgets/qdatetimeedit_p.h index 0a4433846f..ac9bd4401a 100644 --- a/src/widgets/widgets/qdatetimeedit_p.h +++ b/src/widgets/widgets/qdatetimeedit_p.h @@ -94,8 +94,18 @@ public: // Override QDateTimeParser: QString displayText() const override { return edit->text(); } - QDateTime getMinimum() const override { return minimum.toDateTime(); } - QDateTime getMaximum() const override { return maximum.toDateTime(); } + QDateTime getMinimum() const override + { + if (keyboardTracking) + return minimum.toDateTime(); + return QDateTimeParser::getMinimum(); + } + QDateTime getMaximum() const override + { + if (keyboardTracking) + return maximum.toDateTime(); + return QDateTimeParser::getMaximum(); + } QLocale locale() const override { return q_func()->locale(); } int cursorPosition() const override { return edit ? edit->cursorPosition() : -1; } diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index d6db6dd5bc..055412528f 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -601,9 +601,17 @@ const QValidator * QLineEdit::validator() const } /*! - Sets this line edit to only accept input that the validator, \a v, - will accept. This allows you to place any arbitrary constraints on - the text which may be entered. + Sets the validator for values of line edit to \a v. + + The line edit's returnPressed() and editingFinished() signals will only + be emitted if \a v validates the line edit's content as \l{QValidator::}{Acceptable}. + The user may change the content to any \l{QValidator::}{Intermediate} + value during editing, but will be prevented from editing the text to a + value that \a v validates as \l{QValidator::}{Invalid}. + + This allows you to constrain the text that shall finally be entered when editing is + done, while leaving users with enough freedom to edit the text from one valid state + to another. If \a v == 0, setValidator() removes the current input validator. The initial setting is to have no input validator (i.e. any input @@ -703,7 +711,7 @@ QSize QLineEdit::sizeHint() const /*! Returns a minimum size for the line edit. - The width returned is enough for at least one character. + The width returned is usually enough for at least one character. */ QSize QLineEdit::minimumSizeHint() const @@ -715,7 +723,7 @@ QSize QLineEdit::minimumSizeHint() const int h = fm.height() + qMax(2 * QLineEditPrivate::verticalMargin, fm.leading()) + tm.top() + tm.bottom() + d->topmargin + d->bottommargin; - int w = fm.maxWidth() + int w = fm.maxWidth() + 2 * QLineEditPrivate::horizontalMargin + tm.left() + tm.right() + d->leftmargin + d->rightmargin; QStyleOptionFrame opt; @@ -1441,7 +1449,7 @@ void QLineEdit::copy() const Inserts the clipboard's text at the cursor position, deleting any selected text, providing the line edit is not \l{QLineEdit::readOnly}{read-only}. - If the end result would not be acceptable to the current + If the end result would be invalid to the current \l{setValidator()}{validator}, nothing happens. \sa copy(), cut() diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp index 4bd3e23479..e3016371ba 100644 --- a/src/widgets/widgets/qmainwindow.cpp +++ b/src/widgets/widgets/qmainwindow.cpp @@ -67,7 +67,7 @@ #include "qtoolbar_p.h" #endif #include "qwidgetanimator_p.h" -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS #include <qpa/qplatformnativeinterface.h> #endif @@ -79,7 +79,7 @@ class QMainWindowPrivate : public QWidgetPrivate public: inline QMainWindowPrivate() : layout(nullptr), explicitIconSize(false), toolButtonStyle(Qt::ToolButtonIconOnly) -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS , useUnifiedToolBar(false) #endif { } @@ -87,7 +87,7 @@ public: QSize iconSize; bool explicitIconSize; Qt::ToolButtonStyle toolButtonStyle; -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS bool useUnifiedToolBar; #endif void init(); @@ -1357,7 +1357,7 @@ bool QMainWindow::event(QEvent *event) */ void QMainWindow::setUnifiedTitleAndToolBarOnMac(bool set) { -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS Q_D(QMainWindow); if (isWindow()) { d->useUnifiedToolBar = set; @@ -1382,7 +1382,7 @@ void QMainWindow::setUnifiedTitleAndToolBarOnMac(bool set) bool QMainWindow::unifiedTitleAndToolBarOnMac() const { -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS return d_func()->useUnifiedToolBar; #endif return false; diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index e26f797501..31a7ad8695 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -49,7 +49,7 @@ #include "qlayout.h" #include "qpainter.h" #include <qpa/qplatformtheme.h> -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS #include "qmacnativewidget_mac.h" #endif #include "qapplication.h" @@ -1496,7 +1496,7 @@ void QMenuPrivate::_q_platformMenuAboutToShow() emit q->aboutToShow(); -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS if (platformMenu) { const auto actions = q->actions(); for (QAction *action : actions) { @@ -3556,7 +3556,7 @@ void QMenu::actionEvent(QActionEvent *e) d->currentAction = nullptr; if (QWidgetAction *wa = qobject_cast<QWidgetAction *>(e->action())) { if (QWidget *widget = d->widgetItems.value(wa)) { -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS QWidget *p = widget->parentWidget(); if (p != this && qobject_cast<QMacNativeWidget *>(p)) { // This widget was reparented into a native Mac view diff --git a/src/widgets/widgets/qmenu.h b/src/widgets/widgets/qmenu.h index 6ae73cf9fe..7a60907532 100644 --- a/src/widgets/widgets/qmenu.h +++ b/src/widgets/widgets/qmenu.h @@ -288,7 +288,7 @@ private: friend void qt_mac_menu_emit_hovered(QMenu *menu, QAction *action); }; -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS // ### Qt 4 compatibility; remove in Qt 6 inline QT_DEPRECATED void qt_mac_set_dock_menu(QMenu *menu) { menu->setAsDockMenu(); } #endif diff --git a/src/widgets/widgets/qmenu_p.h b/src/widgets/widgets/qmenu_p.h index 02fe9f31a1..3871d6763c 100644 --- a/src/widgets/widgets/qmenu_p.h +++ b/src/widgets/widgets/qmenu_p.h @@ -335,7 +335,7 @@ public: void copyActionToPlatformItem(const QAction *action, QPlatformMenuItem *item); QPlatformMenuItem *insertActionInPlatformMenu(const QAction *action, QPlatformMenuItem *beforeItem); -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS void moveWidgetToPlatformItem(QWidget *w, QPlatformMenuItem* item); #endif diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp index df480629da..53be917945 100644 --- a/src/widgets/widgets/qtabbar.cpp +++ b/src/widgets/widgets/qtabbar.cpp @@ -60,7 +60,7 @@ #ifndef QT_NO_ACCESSIBILITY #include "qaccessible.h" #endif -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS #include <qpa/qplatformnativeinterface.h> #endif @@ -115,7 +115,7 @@ inline static bool verticalTabs(QTabBar::Shape shape) void QTabBarPrivate::updateMacBorderMetrics() { -#if defined(Q_OS_OSX) +#if defined(Q_OS_MACOS) Q_Q(QTabBar); // Extend the unified title and toolbar area to cover the tab bar iff // 1) the tab bar is in document mode diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp index bb376e9613..9c63f98a73 100644 --- a/src/widgets/widgets/qtoolbar.cpp +++ b/src/widgets/widgets/qtoolbar.cpp @@ -61,7 +61,7 @@ #include <private/qwidgetaction_p.h> #include <private/qmainwindowlayout_p.h> -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS #include <qpa/qplatformnativeinterface.h> #endif @@ -248,7 +248,7 @@ bool QToolBarPrivate::mousePressEvent(QMouseEvent *event) QStyleOptionToolBar opt; q->initStyleOption(&opt); if (q->style()->subElementRect(QStyle::SE_ToolBarHandle, &opt, q).contains(event->pos()) == false) { -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS // When using the unified toolbar on OS X, the user can click and // drag between toolbar contents to move the window. Make this work by // implementing the standard mouse-dragging code and then call @@ -282,7 +282,7 @@ bool QToolBarPrivate::mouseReleaseEvent(QMouseEvent*) endDrag(); return true; } else { -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS if (!macWindowDragging) return false; macWindowDragging = false; @@ -298,7 +298,7 @@ bool QToolBarPrivate::mouseMoveEvent(QMouseEvent *event) Q_Q(QToolBar); if (!state) { -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS if (!macWindowDragging) return false; QWidget *w = q->window(); @@ -1084,7 +1084,7 @@ static bool waitForPopup(QToolBar *tb, QWidget *popup) return false; } -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS static void enableMacToolBar(QToolBar *toolbar, bool enable) { QPlatformNativeInterface *nativeInterface = QApplication::platformNativeInterface(); @@ -1123,7 +1123,7 @@ bool QToolBar::event(QEvent *event) Q_FALLTHROUGH(); case QEvent::Show: d->toggleViewAction->setChecked(event->type() == QEvent::Show); -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS enableMacToolBar(this, event->type() == QEvent::Show); #endif emit visibilityChanged(event->type() == QEvent::Show); diff --git a/src/widgets/widgets/qtoolbar_p.h b/src/widgets/widgets/qtoolbar_p.h index e1b786cab7..07f1af3fe0 100644 --- a/src/widgets/widgets/qtoolbar_p.h +++ b/src/widgets/widgets/qtoolbar_p.h @@ -74,7 +74,7 @@ public: allowedAreas(Qt::AllToolBarAreas), orientation(Qt::Horizontal), toolButtonStyle(Qt::ToolButtonIconOnly), layout(nullptr), state(nullptr) -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS , macWindowDragging(false) #endif { } @@ -106,7 +106,7 @@ public: }; DragState *state; -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS bool macWindowDragging; QPoint macWindowDragPressPosition; #endif diff --git a/src/widgets/widgets/qtoolbarlayout.cpp b/src/widgets/widgets/qtoolbarlayout.cpp index 8ddf27c878..e1c0df31d1 100644 --- a/src/widgets/widgets/qtoolbarlayout.cpp +++ b/src/widgets/widgets/qtoolbarlayout.cpp @@ -48,7 +48,7 @@ #include <qmenu.h> #include <qdebug.h> #include <qmath.h> -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS #include <qpa/qplatformnativeinterface.h> #endif @@ -348,7 +348,7 @@ static bool defaultWidgetAction(QToolBarItem *item) void QToolBarLayout::updateMacBorderMetrics() { -#ifdef Q_OS_OSX +#ifdef Q_OS_MACOS QToolBar *tb = qobject_cast<QToolBar*>(parentWidget()); if (!tb) return; diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index 3b9ec618bb..e22028aa49 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -2236,6 +2236,7 @@ void QWidgetTextControlPrivate::focusEvent(QFocusEvent *e) #endif } else { setCursorVisible(false); + cursorOn = false; if (cursorIsFocusIndicator && e->reason() != Qt::ActiveWindowFocusReason |