From e555c03a4255bb4109a4b55d38561297ce8a2d2e Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Mon, 10 Oct 2016 16:16:24 +0300 Subject: Style sheets: Include margin while calculating QHeaderview section size Align with QCommonstyle QHeaderview section size calculation. Change-Id: I4c11e1881f48850ace3bdbb3c96f999cc298c91e Task-number: QTBUG-56457 Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: Christian Ehrlicher --- src/widgets/styles/qstylesheetstyle.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index e12aeb900b..c4fc353803 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -4983,11 +4983,13 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op if (!subRule.hasGeometry()) { QSize nativeContentsSize; bool nullIcon = hdr->icon.isNull(); + const int margin = pixelMetric(QStyle::PM_HeaderMargin, hdr, w); int iconSize = nullIcon ? 0 : pixelMetric(QStyle::PM_SmallIconSize, hdr, w); const QSize txt = subRule.hasFont ? QFontMetrics(subRule.font).size(0, hdr->text) : hdr->fontMetrics.size(0, hdr->text); - nativeContentsSize.setHeight(qMax(iconSize, txt.height())); - nativeContentsSize.setWidth(iconSize + txt.width()); + nativeContentsSize.setHeight(margin + qMax(iconSize, txt.height()) + margin); + nativeContentsSize.setWidth((nullIcon ? 0 : margin) + iconSize + + (hdr->text.isNull() ? 0 : margin) + txt.width() + margin); sz = sz.expandedTo(nativeContentsSize); } return subRule.size(sz); -- cgit v1.2.3 From a69a3594e2c4122aef91c5511d5eeb78b7bfcb5c Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 20 Mar 2018 15:07:04 +0100 Subject: Doc: Advocate use of std::initializer_list constructor in Q[String]List We're relying on C++11 since a while, so lets not advertise creating lists of strings with operator<<() anymore. Change-Id: I14a3442ff852ac2c106d90c63504eb9ebb737609 Reviewed-by: Leena Miettinen Reviewed-by: hjk --- .../doc/snippets/code/src_corelib_tools_qlistdata.cpp | 13 ++++++++----- src/corelib/doc/snippets/qstringlist/main.cpp | 11 +++++++---- src/corelib/tools/qlist.cpp | 13 +++++++++---- src/corelib/tools/qstringlist.cpp | 15 +++++++++++++-- 4 files changed, 37 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qlistdata.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qlistdata.cpp index ac17de1bee..27565a7878 100644 --- a/src/corelib/doc/snippets/code/src_corelib_tools_qlistdata.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_tools_qlistdata.cpp @@ -54,11 +54,14 @@ QList dateList; //! [0] -//! [1] -QList list; -list << "one" << "two" << "three"; -// list: ["one", "two", "three"] -//! [1] +//! [1a] +QList list = { "one", "two", "three" }; +//! [1a] + + +//! [1b] +list << "four" << "five"; +//! [1b] //! [2] diff --git a/src/corelib/doc/snippets/qstringlist/main.cpp b/src/corelib/doc/snippets/qstringlist/main.cpp index 4d9c015747..55c60650fe 100644 --- a/src/corelib/doc/snippets/qstringlist/main.cpp +++ b/src/corelib/doc/snippets/qstringlist/main.cpp @@ -61,10 +61,13 @@ public: Widget::Widget(QWidget *parent) : QWidget(parent) { -//! [0] - QStringList fonts; - fonts << "Arial" << "Helvetica" << "Times" << "Courier"; -//! [0] +//! [0a] + QStringList fonts = { "Arial", "Helvetica", "Times" }; +//! [0a] + +//! [0b] + fonts << "Courier" << "Verdana"; +//! [0b] //! [1] for (int i = 0; i < fonts.size(); ++i) diff --git a/src/corelib/tools/qlist.cpp b/src/corelib/tools/qlist.cpp index 33835e3d28..17aba8035b 100644 --- a/src/corelib/tools/qlist.cpp +++ b/src/corelib/tools/qlist.cpp @@ -408,15 +408,20 @@ void **QListData::erase(void **xi) from strings. QList stores a list of items. The default constructor creates an - empty list. To insert items into the list, you can use - operator<<(): + empty list. You can use the initializer-list constructor to create + a list with elements: - \snippet code/src_corelib_tools_qlistdata.cpp 1 + \snippet code/src_corelib_tools_qlistdata.cpp 1a QList provides these basic functions to add, move, and remove items: insert(), replace(), removeAt(), move(), and swap(). In addition, it provides the following convenience functions: - append(), prepend(), removeFirst(), and removeLast(). + append(), \l{operator<<()}, \l{operator+=()}, prepend(), removeFirst(), + and removeLast(). + + \l{operator<<()} allows to conveniently add multiple elements to a list: + + \snippet code/src_corelib_tools_qlistdata.cpp 1b QList uses 0-based indexes, just like C++ arrays. To access the item at a particular index position, you can use operator[](). On diff --git a/src/corelib/tools/qstringlist.cpp b/src/corelib/tools/qstringlist.cpp index d10d9ad9d0..c9db39a29f 100644 --- a/src/corelib/tools/qstringlist.cpp +++ b/src/corelib/tools/qstringlist.cpp @@ -98,14 +98,25 @@ QT_BEGIN_NAMESPACE \tableofcontents + \section1 Initializing + + The default constructor creates an empty list. You can use the + initializer-list constructor to create a list with elements: + + \snippet qstringlist/main.cpp 0a + \section1 Adding Strings Strings can be added to a list using the \l + {QList::insert()}{insert()} \l {QList::append()}{append()}, \l {QList::operator+=()}{operator+=()} and \l - {QStringList::operator<<()}{operator<<()} functions. For example: + {operator<<()} functions. + + \l{operator<<()} can be used to + conveniently add multiple elements to a list: - \snippet qstringlist/main.cpp 0 + \snippet qstringlist/main.cpp 0b \section1 Iterating Over the Strings -- cgit v1.2.3 From 7b87bdff1ab29066d9ef03daded6f8306022bca4 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 11 Apr 2018 10:43:46 +0200 Subject: Doc: Mark local functions in qlogging.cpp as internal This fixes qdoc warnings introduced by 67d5f79fe6f86726eff. Change-Id: I4b199e6243d9a7706befe4bc9549c78c11026d9e Reviewed-by: Simon Hausmann --- src/corelib/global/qlogging.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 17002c4231..7444145e82 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -208,6 +208,7 @@ static bool isDefaultCategory(const char *category) /*! Returns true if writing to \c stderr is supported. + \internal \sa stderrHasConsoleAttached() */ static bool systemHasStderr() @@ -236,6 +237,7 @@ static bool systemHasStderr() the output might still end up visible to the user. For this reason, we don't guard the stderr output in the default message handler with stderrHasConsoleAttached(). + \internal \sa systemHasStderr() */ bool stderrHasConsoleAttached() @@ -288,6 +290,7 @@ namespace QtPrivate { This is normally the case if \c stderr has a console attached, but may be overridden by the user by setting the QT_FORCE_STDERR_LOGGING environment variable to \c 1. + \internal \sa stderrHasConsoleAttached() */ bool shouldLogToStderr() -- cgit v1.2.3 From 994e0e4c36315fc7656568f9f1e546362dae5466 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 11 Apr 2018 09:51:19 +0200 Subject: Windows QPA: Fix Korean IME removing words when using CTRL shortcuts Ignore the WM_IME_ENDCOMPOSITION message in that case. Done-with: Tobias Koenig Task-number: QTBUG-58300 Change-Id: I9506754a149905222a324b85634964fce398d3ac Reviewed-by: Liang Qi --- src/plugins/platforms/windows/qwindowsinputcontext.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.cpp b/src/plugins/platforms/windows/qwindowsinputcontext.cpp index b9dd2c557e..2dbca6047c 100644 --- a/src/plugins/platforms/windows/qwindowsinputcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsinputcontext.cpp @@ -530,6 +530,14 @@ bool QWindowsInputContext::endComposition(HWND hwnd) if (m_compositionContext.focusObject.isNull()) return false; + // QTBUG-58300: Ignore WM_IME_ENDCOMPOSITION when CTRL is pressed to prevent + // for example the text being cleared when pressing CTRL+A + if (m_locale.language() == QLocale::Korean + && QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ControlModifier)) { + reset(); + return true; + } + m_endCompositionRecursionGuard = true; imeNotifyCancelComposition(m_compositionContext.hwnd); -- cgit v1.2.3 From b458cb312c433d9c955f5268c5db321126fef143 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 12 Mar 2018 13:43:43 +0100 Subject: doc: Make both qEnvironmentVariable() functions visible in the docs There had been a fake declaration for qEnvironmentVariable() in qglobal.h thaqt was only visible to QDoc. It was removed in favor of documenting both the actual declarations of qEnvironmentVariable(), one with a 2nd parameter for passing a defualt value and one without that parameter. But the one without the default value parameter was marked internal, so it didn't appear in the docs. When both functions were documented with a shared comment, a bug in QDoc was revealed, because these functions are global, while the shared comment functionality had only been implemented for class member functions. Now the shared comment functionality has been implemented for global functions, so these two functions are now documented with a shared comment. We can, of course, reintroduce the #ifdef QCLANG_QDOC trick, if that is pre3ferred. Change-Id: I41d85def5daa3215a995d7697d064dfae37e8b2a Reviewed-by: Thiago Macieira --- src/corelib/global/qglobal.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index b75b218201..30c80b8b6f 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -3268,14 +3268,15 @@ QByteArray qgetenv(const char *varName) /*! - QString qEnvironmentVariable(const char *varName, const QString &defaultValue); + \fn QString qEnvironmentVariable(const char *varName, const QString &defaultValue) + \fn QString qEnvironmentVariable(const char *varName) \relates \since 5.10 - Returns the value of the environment variable with name \a varName as a - QString. If no variable by that name is found in the environment, this - function returns \a defaultValue. + These functions return the value of the environment variable, \a varName, as a + QString. If no variable \a varName is found in the environment and \a defaultValue + is provided, \a defaultValue is returned. Otherwise QString() is returned. The Qt environment manipulation functions are thread-safe, but this requires that the C library equivalent functions like getenv and putenv are @@ -3344,9 +3345,6 @@ QString qEnvironmentVariable(const char *varName, const QString &defaultValue) #endif } -/*! - \internal -*/ QString qEnvironmentVariable(const char *varName) { return qEnvironmentVariable(varName, QString()); -- cgit v1.2.3 From c579f49e2a80a55a4004ff8e5b2ee76bda146387 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 14 Nov 2017 15:52:34 +0100 Subject: Fix QML integration of widgets We need to mark the object as deleted before destroying it's declarative data, otherwise all sorts of bad things can happen. This fixes the qwidgetsinqml autotest in qtdeclarative. Change-Id: I05a645ebe1ca7a50c8927e3dbd9ebb5aaf369a71 Reviewed-by: Simon Hausmann (cherry picked from commit 3e91625b58b4d7d2757678de9d77eef91e84df36) Reviewed-by: Lars Knoll --- src/widgets/kernel/qwidget.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index c347ca0b59..a86834002c 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1677,6 +1677,7 @@ QWidget::~QWidget() } } + d->wasDeleted = true; if (d->declarativeData) { if (static_cast(d->declarativeData)->ownedByQml1) { if (QAbstractDeclarativeData::destroyed_qml1) @@ -8476,7 +8477,7 @@ bool QWidgetPrivate::close_helper(CloseMode mode) data.is_closing = 1; QPointer that = q; - QPointer parentWidget = q->parentWidget(); + QPointer parentWidget = (q->parentWidget() && !QObjectPrivate::get(q->parentWidget())->wasDeleted) ? q->parentWidget() : nullptr; bool quitOnClose = q->testAttribute(Qt::WA_QuitOnClose); if (mode != CloseNoEvent) { -- cgit v1.2.3