Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/5.15' into dev
Browse files Browse the repository at this point in the history
 Conflicts:
	tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp

Change-Id: I6b82507bf9a80a374c40393e72f4843f1557de89
  • Loading branch information
Qt Forward Merge Bot authored and ediosyncratic committed Dec 11, 2019
2 parents bef74b6 + e6de661 commit a4a7c1b
Show file tree
Hide file tree
Showing 101 changed files with 1,234 additions and 507 deletions.
52 changes: 35 additions & 17 deletions examples/widgets/doc/src/shapedclock.qdoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,18 @@
\example widgets/shapedclock
\title Shaped Clock Example
\ingroup examples-widgets
\brief The Shaped Clock example shows how to apply a widget mask to a top-level
widget to produce a shaped window.
\brief The Shaped Clock example shows how to apply a translucent background
and a widget mask to a top-level widget to produce a shaped window.

\borderedimage shapedclock-example.png

Widget masks are used to customize the shapes of top-level widgets by restricting
the available area for painting. On some window systems, setting certain window flags
will cause the window decoration (title bar, window frame, buttons) to be disabled,
allowing specially-shaped windows to be created. In this example, we use this feature
to create a circular window containing an analog clock.
Widget masks are used to customize the shapes of top-level widgets by
restricting the area available for painting and mouse input. Using a
translucent background facilitates partially transparent windows and smooth
edges. On most window systems, setting certain window flags will cause the
window decoration (title bar, window frame, buttons) to be disabled,
allowing specially-shaped windows to be created. In this example, we use
this feature to create a circular window containing an analog clock.

Since this example's window does not provide a \uicontrol File menu or a close
button, we provide a context menu with an \uicontrol Exit entry so that the example
Expand All @@ -52,8 +54,10 @@

\snippet widgets/shapedclock/shapedclock.h 0

The \l{QWidget::paintEvent()}{paintEvent()} implementation is the same as that found
in the \c AnalogClock class. We implement \l{QWidget::sizeHint()}{sizeHint()}
The \l{QWidget::paintEvent()}{paintEvent()} implementation is the same as
that found in the \c AnalogClock class, with one important exception: we
now must also draw background (the clock face) ourselves, since the widget
background is just transparent. We implement \l{QWidget::sizeHint()}{sizeHint()}
so that we don't have to resize the widget explicitly. We also provide an event
handler for resize events. This allows us to update the mask if the clock is resized.

Expand All @@ -70,9 +74,11 @@

\snippet widgets/shapedclock/shapedclock.cpp 0

We inform the window manager that the widget is not to be decorated with a window
frame by setting the Qt::FramelessWindowHint flag on the widget. As a result, we need
to provide a way for the user to move the clock around the screen.
We request a transparent window by setting the Qt::WA_TranslucentBackground
widget attribute. We inform the window manager that the widget is not to be
decorated with a window frame by setting the Qt::FramelessWindowHint flag
on the widget. As a result, we need to provide a way for the user to move
the clock around the screen.

Mouse button events are delivered to the \c mousePressEvent() handler:

Expand All @@ -94,14 +100,20 @@
widget is moved to the point given by subtracting the \c dragPosition from the current
cursor position in global coordinates. If we drag the widget, we also accept the event.

The \c paintEvent() function is given for completeness. See the
\l{Analog Clock Example}{Analog Clock} example for a description of the process used
to render the clock.
The \c paintEvent() function is mainly the same as described in the
\l{Analog Clock Example}{Analog Clock} example. The one addition is that we
use QPainter::drawEllipse() to draw a round clock face with the current
palette's default background color. We make the clock face a bit smaller
than the widget mask, so that the anti-aliased, semi-transparent pixels on
the edge are not clipped away by the widget mask. This gives the shaped
window smooth edges on the screen.

\snippet widgets/shapedclock/shapedclock.cpp 3

In the \c resizeEvent() handler, we re-use some of the code from the \c paintEvent()
to determine the region of the widget that is visible to the user:
In the \c resizeEvent() handler, we re-use some of the code from the \c
paintEvent() to determine the region of the widget that is visible to the
user. This tells the system the area where mouse clicks should go to us,
and not to whatever window is behind us:

\snippet widgets/shapedclock/shapedclock.cpp 4

Expand All @@ -121,6 +133,12 @@

\section1 Notes on Widget Masks

Widget masks are used to hint to the window system that the application
does not want mouse events for areas outside the mask. On most systems,
they also result in coarse visual clipping. To get smooth window edges, one
should use translucent background and anti-aliased painting, as shown in
this example.

Since QRegion allows arbitrarily complex regions to be created, widget masks can be
made to suit the most unconventionally-shaped windows, and even allow widgets to be
displayed with holes in them.
Expand Down
7 changes: 6 additions & 1 deletion examples/widgets/widgets/shapedclock/shapedclock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
ShapedClock::ShapedClock(QWidget *parent)
: QWidget(parent, Qt::FramelessWindowHint | Qt::WindowSystemMenuHint)
{
setAttribute(Qt::WA_TranslucentBackground);
QTimer *timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, QOverload<>::of(&ShapedClock::update));
timer->start(1000);
Expand Down Expand Up @@ -122,6 +123,10 @@ void ShapedClock::paintEvent(QPaintEvent *)
painter.translate(width() / 2, height() / 2);
painter.scale(side / 200.0, side / 200.0);

painter.setPen(Qt::NoPen);
painter.setBrush(palette().window());
painter.drawEllipse(QPoint(0, 0), 98, 98);

painter.setPen(Qt::NoPen);
painter.setBrush(hourColor);

Expand Down Expand Up @@ -168,6 +173,6 @@ void ShapedClock::resizeEvent(QResizeEvent * /* event */)
//! [5]
QSize ShapedClock::sizeHint() const
{
return QSize(100, 100);
return QSize(200, 200);
}
//! [5]
2 changes: 1 addition & 1 deletion mkspecs/features/wasm/wasm.prf
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ contains(TEMPLATE, .*app) {
# replacing the app name placeholder with the actual app name.
apphtml.name = application main html file
apphtml.output = $$DESTDIR/$$TARGET_HTML
apphtml.commands = sed -e s/@APPNAME@/$$TARGET_BASE/g $$WASM_PLUGIN_PATH/wasm_shell.html > $$DESTDIR/$$TARGET_HTML
apphtml.commands = $$QMAKE_STREAM_EDITOR -e s/@APPNAME@/$$TARGET_BASE/g $$WASM_PLUGIN_PATH/wasm_shell.html > $$DESTDIR/$$TARGET_HTML
apphtml.input = $$WASM_PLUGIN_PATH/wasm_shell.html
apphtml.depends = $$apphtml.input
QMAKE_EXTRA_COMPILERS += apphtml
Expand Down
2 changes: 1 addition & 1 deletion mkspecs/wasm-emscripten/qmake.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ EMTERP_FLAGS = \
-s ASSERTIONS=1 \
--profiling-funcs

EMCC_COMMON_LFLAGS = \
EMCC_COMMON_LFLAGS += \
-s WASM=1 \
-s FULL_ES2=1 \
-s FULL_ES3=1 \
Expand Down
2 changes: 1 addition & 1 deletion qmake/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ static int doSed(int argc, char **argv)
FILE *f;
if (!strcmp(inFile, "-")) {
f = stdin;
} else if (!(f = fopen(inFile, "r"))) {
} else if (!(f = fopen(inFile, "rb"))) {
perror(inFile);
return 1;
}
Expand Down
77 changes: 37 additions & 40 deletions src/corelib/global/qcompilerdetection.h
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,39 @@
# error "Qt has not been tested with this compiler - see http://www.qt-project.org/"
#endif

/*
* SG10's SD-6 feature detection and some useful extensions from Clang and GCC
* https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations
* http://clang.llvm.org/docs/LanguageExtensions.html#feature-checking-macros
* Not using wrapper macros, per http://eel.is/c++draft/cpp.cond#7.sentence-2
*/
#ifndef __has_builtin
# define __has_builtin(x) 0
#endif
#ifndef __has_feature
# define __has_feature(x) 0
#endif
#ifndef __has_attribute
# define __has_attribute(x) 0
#endif
#ifndef __has_cpp_attribute
# define __has_cpp_attribute(x) 0
#endif
#ifndef __has_include
# define __has_include(x) 0
#endif
#ifndef __has_include_next
# define __has_include_next(x) 0
#endif

// Kept around until all submodules have transitioned
#define QT_HAS_BUILTIN(x) __has_builtin(x)
#define QT_HAS_FEATURE(x) __has_feature(x)
#define QT_HAS_ATTRIBUTE(x) __has_attribute(x)
#define QT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
#define QT_HAS_INCLUDE(x) __has_include(x)
#define QT_HAS_INCLUDE_NEXT(x) __has_include_next(x)

/*
* C++11 support
*
Expand Down Expand Up @@ -1018,37 +1051,6 @@
# endif
#endif

/*
* SG10's SD-6 feature detection and some useful extensions from Clang and GCC
* https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations
* http://clang.llvm.org/docs/LanguageExtensions.html#feature-checking-macros
*/
#ifdef __has_builtin
# define QT_HAS_BUILTIN(x) __has_builtin(x)
#else
# define QT_HAS_BUILTIN(x) 0
#endif
#ifdef __has_attribute
# define QT_HAS_ATTRIBUTE(x) __has_attribute(x)
#else
# define QT_HAS_ATTRIBUTE(x) 0
#endif
#ifdef __has_cpp_attribute
# define QT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
#else
# define QT_HAS_CPP_ATTRIBUTE(x) 0
#endif
#ifdef __has_include
# define QT_HAS_INCLUDE(x) __has_include(x)
#else
# define QT_HAS_INCLUDE(x) 0
#endif
#ifdef __has_include_next
# define QT_HAS_INCLUDE_NEXT(x) __has_include_next(x)
#else
# define QT_HAS_INCLUDE_NEXT(x) 0
#endif

/*
* C++11 keywords and expressions
*/
Expand Down Expand Up @@ -1123,7 +1125,7 @@
# define Q_DECL_ALIGN(n) alignas(n)
#endif

#if QT_HAS_CPP_ATTRIBUTE(nodiscard) && !defined(Q_CC_CLANG) // P0188R1
#if __has_cpp_attribute(nodiscard) && !defined(Q_CC_CLANG) // P0188R1
// Can't use [[nodiscard]] with Clang, see https://bugs.llvm.org/show_bug.cgi?id=33518
# undef Q_REQUIRED_RESULT
# define Q_REQUIRED_RESULT [[nodiscard]]
Expand Down Expand Up @@ -1225,11 +1227,6 @@
#ifndef QT_MAKE_CHECKED_ARRAY_ITERATOR
# define QT_MAKE_CHECKED_ARRAY_ITERATOR(x, N) (x)
#endif
#ifdef __has_feature
# define QT_HAS_FEATURE(x) __has_feature(x)
#else
# define QT_HAS_FEATURE(x) 0
#endif

/*
* Warning/diagnostic handling
Expand Down Expand Up @@ -1320,11 +1317,11 @@
} while (false)

#if defined(__cplusplus)
#if QT_HAS_CPP_ATTRIBUTE(clang::fallthrough)
#if __has_cpp_attribute(clang::fallthrough)
# define Q_FALLTHROUGH() [[clang::fallthrough]]
#elif QT_HAS_CPP_ATTRIBUTE(gnu::fallthrough)
#elif __has_cpp_attribute(gnu::fallthrough)
# define Q_FALLTHROUGH() [[gnu::fallthrough]]
#elif QT_HAS_CPP_ATTRIBUTE(fallthrough)
#elif __has_cpp_attribute(fallthrough)
# define Q_FALLTHROUGH() [[fallthrough]]
#endif
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/corelib/global/qconfig-bootstrapped.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@
#define QT_FEATURE_binaryjson -1
#define QT_FEATURE_cborstream -1
#define QT_CRYPTOGRAPHICHASH_ONLY_SHA1
#define QT_FEATURE_cxx11_random (QT_HAS_INCLUDE(<random>) ? 1 : -1)
#define QT_FEATURE_cxx11_random (__has_include(<random>) ? 1 : -1)
#define QT_NO_DATASTREAM
#define QT_FEATURE_datestring 1
#define QT_FEATURE_datetimeparser -1
#define QT_FEATURE_easingcurve -1
#define QT_FEATURE_etw -1
#define QT_FEATURE_getauxval (QT_HAS_INCLUDE(<sys/auxv.h>) ? 1 : -1)
#define QT_FEATURE_getauxval (__has_include(<sys/auxv.h>) ? 1 : -1)
#define QT_FEATURE_getentropy -1
#define QT_NO_GEOM_VARIANT
#define QT_FEATURE_hijricalendar -1
Expand Down
4 changes: 2 additions & 2 deletions src/corelib/global/qendian.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ template <typename T> Q_ALWAYS_INLINE void qToUnaligned(const T src, void *dest)
// Using sizeof(T) inside memcpy function produces internal compiler error with
// MSVC2008/ARM in tst_endian -> use extra indirection to resolve size of T.
const size_t size = sizeof(T);
#if QT_HAS_BUILTIN(__builtin_memcpy)
#if __has_builtin(__builtin_memcpy)
__builtin_memcpy
#else
memcpy
Expand All @@ -78,7 +78,7 @@ template <typename T> Q_ALWAYS_INLINE T qFromUnaligned(const void *src)
{
T dest;
const size_t size = sizeof(T);
#if QT_HAS_BUILTIN(__builtin_memcpy)
#if __has_builtin(__builtin_memcpy)
__builtin_memcpy
#else
memcpy
Expand Down
4 changes: 2 additions & 2 deletions src/corelib/global/qglobal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
# include <sys/systeminfo.h>
#endif

#if defined(Q_OS_DARWIN) && QT_HAS_INCLUDE(<IOKit/IOKitLib.h>)
#if defined(Q_OS_DARWIN) && __has_include(<IOKit/IOKitLib.h>)
# include <IOKit/IOKitLib.h>
# include <private/qcore_mac_p.h>
#endif
Expand Down Expand Up @@ -3067,7 +3067,7 @@ enum {
*/
QByteArray QSysInfo::machineUniqueId()
{
#if defined(Q_OS_DARWIN) && QT_HAS_INCLUDE(<IOKit/IOKitLib.h>)
#if defined(Q_OS_DARWIN) && __has_include(<IOKit/IOKitLib.h>)
char uuid[UuidStringLen + 1];
io_service_t service = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice"));
QCFString stringRef = (CFStringRef)IORegistryEntryCreateCFProperty(service, CFSTR(kIOPlatformUUIDKey), kCFAllocatorDefault, 0);
Expand Down
2 changes: 1 addition & 1 deletion src/corelib/global/qglobal.h
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ inline void qt_noop(void) {}

#if !defined(QT_NO_EXCEPTIONS)
# if !defined(Q_MOC_RUN)
# if (defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) && !QT_HAS_FEATURE(cxx_exceptions)) || \
# if (defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) && !__has_feature(cxx_exceptions)) || \
(defined(Q_CC_GNU) && !defined(__EXCEPTIONS))
# define QT_NO_EXCEPTIONS
# endif
Expand Down
4 changes: 2 additions & 2 deletions src/corelib/global/qglobal_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Q_CORE_EXPORT time_t qMkTime(struct tm *when);

QT_END_NAMESPACE

#if !QT_HAS_BUILTIN(__builtin_available)
#if !__has_builtin(__builtin_available)
#include <initializer_list>
#include <QtCore/qoperatingsystemversion.h>
#include <QtCore/qversionnumber.h>
Expand Down Expand Up @@ -142,7 +142,7 @@ QT_END_NAMESPACE
QT_BUILTIN_AVAILABLE1, \
QT_BUILTIN_AVAILABLE0, )
#define __builtin_available(...) QT_BUILTIN_AVAILABLE_CHOOSER(__VA_ARGS__)(__VA_ARGS__)
#endif // !QT_HAS_BUILTIN(__builtin_available)
#endif // !__has_builtin(__builtin_available)
#endif // defined(__cplusplus)

#endif // QGLOBAL_P_H
Expand Down
8 changes: 4 additions & 4 deletions src/corelib/global/qlogging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
#if QT_CONFIG(slog2)
#include <sys/slog2.h>
#endif
#if QT_HAS_INCLUDE(<paths.h>)
#if __has_include(<paths.h>)
#include <paths.h>
#endif

Expand Down Expand Up @@ -106,7 +106,7 @@
# if __UCLIBC_HAS_BACKTRACE__
# define QLOGGING_HAVE_BACKTRACE
# endif
# elif (defined(__GLIBC__) && defined(__GLIBCXX__)) || (QT_HAS_INCLUDE(<cxxabi.h>) && QT_HAS_INCLUDE(<execinfo.h>))
# elif (defined(__GLIBC__) && defined(__GLIBCXX__)) || (__has_include(<cxxabi.h>) && __has_include(<execinfo.h>))
# define QLOGGING_HAVE_BACKTRACE
# endif
#endif
Expand All @@ -116,7 +116,7 @@ extern char *__progname;
#endif

#ifndef QT_BOOTSTRAPPED
#if defined(Q_OS_LINUX) && (defined(__GLIBC__) || QT_HAS_INCLUDE(<sys/syscall.h>))
#if defined(Q_OS_LINUX) && (defined(__GLIBC__) || __has_include(<sys/syscall.h>))
# include <sys/syscall.h>

# if defined(Q_OS_ANDROID) && !defined(SYS_gettid)
Expand Down Expand Up @@ -1276,7 +1276,7 @@ void QMessagePattern::setPattern(const QString &pattern)
#if defined(QLOGGING_HAVE_BACKTRACE) && !defined(QT_BOOTSTRAPPED)
// make sure the function has "Message" in the name so the function is removed

#if ((defined(Q_CC_GNU) && defined(QT_COMPILER_SUPPORTS_SIMD_ALWAYS)) || QT_HAS_ATTRIBUTE(optimize)) \
#if ((defined(Q_CC_GNU) && defined(QT_COMPILER_SUPPORTS_SIMD_ALWAYS)) || __has_attribute(optimize)) \
&& !defined(Q_CC_INTEL) && !defined(Q_CC_CLANG)
// force skipping the frame pointer, to save the backtrace() function some work
__attribute__((optimize("omit-frame-pointer")))
Expand Down
2 changes: 1 addition & 1 deletion src/corelib/global/qnumeric_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ QT_WARNING_POP
// size_t. Implementations for 8- and 16-bit types will work but may not be as
// efficient. Implementations for 64-bit may be missing on 32-bit platforms.

#if (defined(Q_CC_GNU) && (Q_CC_GNU >= 500) || (defined(Q_CC_INTEL) && !defined(Q_OS_WIN))) || QT_HAS_BUILTIN(__builtin_add_overflow)
#if (defined(Q_CC_GNU) && (Q_CC_GNU >= 500) || (defined(Q_CC_INTEL) && !defined(Q_OS_WIN))) || __has_builtin(__builtin_add_overflow)
// GCC 5, ICC 18, and Clang 3.8 have builtins to detect overflows

template <typename T> inline
Expand Down
2 changes: 1 addition & 1 deletion src/corelib/io/qfilesystemengine_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
#include <stdio.h>
#include <errno.h>

#if QT_HAS_INCLUDE(<paths.h>)
#if __has_include(<paths.h>)
# include <paths.h>
#endif
#ifndef _PATH_TMP // from <paths.h>
Expand Down
Loading

0 comments on commit a4a7c1b

Please sign in to comment.