diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc | 5 | ||||
-rw-r--r-- | src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc | 20 | ||||
-rw-r--r-- | src/widgets/styles/qcommonstyle.cpp | 3 | ||||
-rw-r--r-- | src/widgets/styles/qstyle.cpp | 3 | ||||
-rw-r--r-- | src/widgets/styles/qstyle.h | 1 | ||||
-rw-r--r-- | src/widgets/styles/qstylesheetstyle.cpp | 2 | ||||
-rw-r--r-- | src/widgets/widgets/qlineedit.cpp | 1 | ||||
-rw-r--r-- | src/widgets/widgets/qlineedit_p.cpp | 1 | ||||
-rw-r--r-- | src/widgets/widgets/qwidgetlinecontrol.cpp | 6 | ||||
-rw-r--r-- | src/widgets/widgets/qwidgetlinecontrol_p.h | 5 |
10 files changed, 45 insertions, 2 deletions
diff --git a/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc b/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc index 36d3dc6af4..702c17bc26 100644 --- a/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc +++ b/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc @@ -1864,3 +1864,8 @@ QTabBar::close-button:hover { } //! [159] + +//! [160] +* { lineedit-password-mask-delay: 1000 } +//! [160] + diff --git a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc index e8c1be4c46..32fe384c75 100644 --- a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc +++ b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc @@ -862,6 +862,9 @@ \l{#lineedit-password-character-prop}{lineedit-password-character} property. + The password mask delay can be changed using the + \l{#lineedit-password-mask-delay-prop}{lineedit-password-mask-delay} + See \l{Qt Style Sheets Examples#Customizing QLineEdit}{Customizing QLineEdit} for an example. @@ -2009,6 +2012,23 @@ \snippet code/doc_src_stylesheet.qdoc 61 \row + \li \b{\c lineedit-password-mask-delay*} \target lineedit-password-mask-delay-prop + \li \l{#Number}{Number} + \li The QLineEdit password mask delay in milliseconds before + \l{#lineedit-password-character-prop}{lineedit-password-character} is applied to visible character. + + If this property is not specified, it defaults to the + value specified by the current style for the + \l{QStyle::}{SH_LineEdit_PasswordMaskDelay} style hint. + + \b{This property was added in Qt 5.4.} + + Example: + + \snippet code/doc_src_stylesheet.qdoc 160 + + + \row \li \b{\c margin} \target margin-prop \li \l {Box Lengths} \li The widget's margins. Equivalent to specifying \c diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 9c2163ac8f..6b5af8ed8b 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -4917,6 +4917,9 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget ret = hint.toChar().unicode(); break; } + case SH_LineEdit_PasswordMaskDelay: + ret = QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::PasswordMaskDelay).toInt(); + break; case SH_ToolBox_SelectedPageTitleBold: ret = 1; break; diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp index 7568ba4e6e..005e324442 100644 --- a/src/widgets/styles/qstyle.cpp +++ b/src/widgets/styles/qstyle.cpp @@ -1779,6 +1779,9 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value SH_LineEdit_PasswordCharacter The Unicode character to be used for passwords. + \value SH_LineEdit_PasswordMaskDelay Determines the delay before visible character is masked + with password character, in milliseconds. This enum value was added in Qt 5.4. + \value SH_Table_GridLineColor The RGB value of the grid for a table. \value SH_UnderlineShortcut Whether shortcuts are underlined. diff --git a/src/widgets/styles/qstyle.h b/src/widgets/styles/qstyle.h index 04112169ca..82c40a954c 100644 --- a/src/widgets/styles/qstyle.h +++ b/src/widgets/styles/qstyle.h @@ -702,6 +702,7 @@ public: SH_ToolTip_FallAsleepDelay, SH_Widget_Animate, SH_Splitter_OpaqueResize, + SH_LineEdit_PasswordMaskDelay, // Add new style hint values here SH_CustomBase = 0xf0000000 diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 6bd0ba37c8..711b0f579d 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -645,6 +645,7 @@ static const char *knownStyleHints[] = { "icon-size", "leftarrow-icon", "lineedit-password-character", + "lineedit-password-mask-delay", "mdi-fill-space-on-maximize", "menu-scrollable", "menubar-altkey-navigation", @@ -5134,6 +5135,7 @@ int QStyleSheetStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWi QString s; switch (sh) { case SH_LineEdit_PasswordCharacter: s = QLatin1String("lineedit-password-character"); break; + case SH_LineEdit_PasswordMaskDelay: s = QLatin1String("lineedit-password-mask-delay"); break; case SH_DitherDisabledText: s = QLatin1String("dither-disabled-text"); break; case SH_EtchDisabledText: s = QLatin1String("etch-disabled-text"); break; case SH_ItemView_ActivateItemOnSingleClick: s = QLatin1String("activate-on-singleclick"); break; diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index 8ba3486b9b..b6b7ffb1a2 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -2190,6 +2190,7 @@ void QLineEdit::changeEvent(QEvent *ev) QStyleOptionFrameV2 opt; initStyleOption(&opt); d->control->setPasswordCharacter(style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, this)); + d->control->setPasswordMaskDelay(style()->styleHint(QStyle::SH_LineEdit_PasswordMaskDelay, &opt, this)); } d->m_iconSize = QSize(); update(); diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp index 9ff77c87de..7521feb72d 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -205,6 +205,7 @@ void QLineEditPrivate::init(const QString& txt) QStyleOptionFrameV2 opt; q->initStyleOption(&opt); control->setPasswordCharacter(q->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, q)); + control->setPasswordMaskDelay(q->style()->styleHint(QStyle::SH_LineEdit_PasswordMaskDelay, &opt, q)); #ifndef QT_NO_CURSOR q->setCursor(Qt::IBeamCursor); #endif diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index b16477246f..1f70dd719b 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -355,8 +355,10 @@ void QWidgetLineControl::init(const QString &txt) m_text = txt; updateDisplayText(); m_cursor = m_text.length(); - if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) { m_keyboardScheme = theme->themeHint(QPlatformTheme::KeyboardScheme).toInt(); + m_passwordMaskDelay = theme->themeHint(QPlatformTheme::PasswordMaskDelay).toInt(); + } // Generalize for X11 if (m_keyboardScheme == QPlatformTheme::KdeKeyboardScheme || m_keyboardScheme == QPlatformTheme::GnomeKeyboardScheme @@ -787,7 +789,7 @@ void QWidgetLineControl::internalInsert(const QString &s) if (m_echoMode == QLineEdit::Password) { if (m_passwordEchoTimer != 0) killTimer(m_passwordEchoTimer); - int delay = qGuiApp->styleHints()->passwordMaskDelay(); + int delay = m_passwordMaskDelay; #ifdef QT_BUILD_INTERNAL if (m_passwordMaskDelayOverride >= 0) delay = m_passwordMaskDelayOverride; diff --git a/src/widgets/widgets/qwidgetlinecontrol_p.h b/src/widgets/widgets/qwidgetlinecontrol_p.h index 1cee67bfd2..ba73e9e25e 100644 --- a/src/widgets/widgets/qwidgetlinecontrol_p.h +++ b/src/widgets/widgets/qwidgetlinecontrol_p.h @@ -90,6 +90,7 @@ public: m_tripleClickTimer(0), m_maskData(0), m_modifiedState(0), m_undoState(0), m_selstart(0), m_selend(0), m_passwordEchoEditing(false) , m_passwordEchoTimer(0) + , m_passwordMaskDelay(-1) #if defined(Q_WS_MAC) , m_threadChecks(false) , m_textLayoutThread(0) @@ -313,6 +314,9 @@ public: QChar passwordCharacter() const { return m_passwordCharacter; } void setPasswordCharacter(QChar character) { m_passwordCharacter = character; updateDisplayText(); } + int passwordMaskDelay() const { return m_passwordMaskDelay; } + void setPasswordMaskDelay(int delay) { m_passwordMaskDelay = delay; } + Qt::LayoutDirection layoutDirection() const { if (m_layoutDirection == Qt::LayoutDirectionAuto) { if (m_text.isEmpty()) @@ -481,6 +485,7 @@ private: bool m_passwordEchoEditing; QChar m_passwordCharacter; int m_passwordEchoTimer; + int m_passwordMaskDelay; void cancelPasswordEchoTimer() { if (m_passwordEchoTimer != 0) { |