Merge remote-tracking branch 'origin/5.14' into 5.15
Change-Id: If8e9d88771243fd9e221b49f53d7d8b111a8ce2abb10
commit
2eead078c8
|
|
@ -222,6 +222,21 @@
|
|||
{ "type": "pkgConfig", "args": "libudev" },
|
||||
"-ludev"
|
||||
]
|
||||
},
|
||||
"libdl": {
|
||||
"label": "dlopen()",
|
||||
"test": {
|
||||
"main": [
|
||||
"dlclose(dlopen(0, 0));",
|
||||
"dlsym(RTLD_DEFAULT, 0);",
|
||||
"dlerror();"
|
||||
]
|
||||
},
|
||||
"headers": "dlfcn.h",
|
||||
"sources": [
|
||||
"",
|
||||
"-ldl"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -1340,6 +1355,17 @@
|
|||
"autoDetect": false,
|
||||
"condition": "!features.shared",
|
||||
"output": [ "publicConfig", "publicQtConfig" ]
|
||||
},
|
||||
"dlopen": {
|
||||
"label": "dlopen()",
|
||||
"condition": "config.unix && libs.libdl",
|
||||
"output": [ "privateFeature" ]
|
||||
},
|
||||
"relocatable": {
|
||||
"label": "Relocatable",
|
||||
"autoDetect": "features.shared",
|
||||
"condition": "features.dlopen || config.win32 || !features.shared",
|
||||
"output": [ "privateFeature" ]
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -1466,6 +1492,7 @@ Configure with '-qreal float' to create a build that is binary-compatible with 5
|
|||
"args": "enable_gdb_index",
|
||||
"condition": "config.gcc && !config.clang && (features.debug || features.force_debug_info || features.debug_and_release)"
|
||||
},
|
||||
"relocatable",
|
||||
"precompile_header",
|
||||
"ltcg",
|
||||
{
|
||||
|
|
|
|||
|
|
@ -763,6 +763,11 @@ defineTest(qtConfOutput_preparePaths) {
|
|||
have_hostprefix = true
|
||||
}
|
||||
|
||||
equals(config.input.prefix, $$config.input.extprefix): \
|
||||
qmake_crossbuild = false
|
||||
else: \
|
||||
qmake_crossbuild = true
|
||||
|
||||
PREFIX_COMPLAINTS =
|
||||
PREFIX_REMINDER = false
|
||||
win32: \
|
||||
|
|
@ -802,6 +807,18 @@ defineTest(qtConfOutput_preparePaths) {
|
|||
processQtPath(host, hostdatadir, $$config.rel_input.archdatadir)
|
||||
}
|
||||
|
||||
win32:$$qtConfEvaluate("features.shared") {
|
||||
# Windows DLLs are in the bin dir.
|
||||
libloc_absolute_path = $$absolute_path($$config.rel_input.bindir, $$config.input.prefix)
|
||||
} else {
|
||||
libloc_absolute_path = $$absolute_path($$config.rel_input.libdir, $$config.input.prefix)
|
||||
}
|
||||
config.input.liblocation_to_prefix = $$relative_path($$config.input.prefix, $$libloc_absolute_path)
|
||||
|
||||
hostbindir_absolute_path = $$absolute_path($$config.rel_input.hostbindir, $$config.input.hostprefix)
|
||||
config.input.hostbindir_to_hostprefix = $$relative_path($$config.input.hostprefix, $$hostbindir_absolute_path)
|
||||
config.input.hostbindir_to_extprefix = $$relative_path($$config.input.extprefix, $$hostbindir_absolute_path)
|
||||
|
||||
!isEmpty(PREFIX_COMPLAINTS) {
|
||||
PREFIX_COMPLAINTS = "$$join(PREFIX_COMPLAINTS, "$$escape_expand(\\n)Note: ")"
|
||||
$$PREFIX_REMINDER: \
|
||||
|
|
@ -864,9 +881,13 @@ defineTest(qtConfOutput_preparePaths) {
|
|||
";" \
|
||||
"" \
|
||||
"$${LITERAL_HASH}define QT_CONFIGURE_SETTINGS_PATH \"$$config.rel_input.sysconfdir\"" \
|
||||
"$${LITERAL_HASH}define QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH \"$$config.input.liblocation_to_prefix\"" \
|
||||
"$${LITERAL_HASH}define QT_CONFIGURE_HOSTBINDIR_TO_EXTPREFIX_PATH \"$$config.input.hostbindir_to_extprefix\"" \
|
||||
"$${LITERAL_HASH}define QT_CONFIGURE_HOSTBINDIR_TO_HOSTPREFIX_PATH \"$$config.input.hostbindir_to_hostprefix\"" \
|
||||
"" \
|
||||
"$${LITERAL_HASH}ifdef QT_BUILD_QMAKE" \
|
||||
"$${LITERAL_HASH} define QT_CONFIGURE_SYSROOTIFY_PREFIX $$qmake_sysrootify" \
|
||||
"$${LITERAL_HASH} define QT_CONFIGURE_CROSSBUILD $$qmake_crossbuild" \
|
||||
"$${LITERAL_HASH}endif" \
|
||||
"" \
|
||||
"$${LITERAL_HASH}define QT_CONFIGURE_PREFIX_PATH qt_configure_prefix_path_str + 12" \
|
||||
|
|
|
|||
|
|
@ -75,7 +75,8 @@
|
|||
\section1 Mouse Class Definition
|
||||
|
||||
When constructing a mouse item, we first ensure that all the item's
|
||||
private variables are properly initialized:
|
||||
private variables which were no yet initialized directly in the class
|
||||
are properly initialized:
|
||||
|
||||
\snippet graphicsview/collidingmice/mouse.cpp 0
|
||||
|
||||
|
|
|
|||
|
|
@ -643,7 +643,9 @@
|
|||
This function is called when the item is removed from the scene
|
||||
and removes all arrows that are connected to this item. The arrow
|
||||
must be removed from the \c arrows list of both its start and end
|
||||
item.
|
||||
item. Since either the start or the end item is the object where
|
||||
this function is currently called, we have to make sure to work on
|
||||
a copy of arrows since removeArrow() is modifying this container.
|
||||
|
||||
Here is the \c addArrow() function:
|
||||
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ int main(int argc, char **argv)
|
|||
QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
|
||||
l->setSpacing(0);
|
||||
|
||||
QGraphicsWidget *w = new QGraphicsWidget(0, Qt::Window);
|
||||
QGraphicsWidget *w = new QGraphicsWidget(nullptr, Qt::Window);
|
||||
w->setPos(20, 20);
|
||||
w->setLayout(l);
|
||||
|
||||
|
|
|
|||
|
|
@ -51,33 +51,26 @@
|
|||
#include "layoutitem.h"
|
||||
|
||||
#include <QGradient>
|
||||
#include <QGraphicsLinearLayout>
|
||||
#include <QPainter>
|
||||
|
||||
//! [0]
|
||||
LayoutItem::LayoutItem(QGraphicsItem *parent/* = 0*/)
|
||||
: QGraphicsLayoutItem(), QGraphicsItem(parent)
|
||||
LayoutItem::LayoutItem(QGraphicsItem *parent)
|
||||
: QGraphicsLayoutItem(), QGraphicsItem(parent),
|
||||
m_pix(QPixmap(QLatin1String(":/images/block.png")))
|
||||
{
|
||||
m_pix = new QPixmap(QLatin1String(":/images/block.png"));
|
||||
setGraphicsItem(this);
|
||||
}
|
||||
//! [0]
|
||||
|
||||
LayoutItem::~LayoutItem()
|
||||
{
|
||||
delete m_pix;
|
||||
}
|
||||
|
||||
//! [1]
|
||||
void LayoutItem::paint(QPainter *painter,
|
||||
const QStyleOptionGraphicsItem *option, QWidget *widget /*= 0*/)
|
||||
void LayoutItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(widget);
|
||||
Q_UNUSED(option);
|
||||
|
||||
QRectF frame(QPointF(0,0), geometry().size());
|
||||
qreal w = m_pix->width();
|
||||
qreal h = m_pix->height();
|
||||
QRectF frame(QPointF(0, 0), geometry().size());
|
||||
const QSize pmSize = m_pix.size();
|
||||
QGradientStops stops;
|
||||
//! [1]
|
||||
|
||||
|
|
@ -94,8 +87,8 @@ void LayoutItem::paint(QPainter *painter,
|
|||
painter->drawRoundedRect(frame, 10.0, 10.0);
|
||||
|
||||
// paint a rect around the pixmap (with gradient)
|
||||
QPointF pixpos = frame.center() - (QPointF(w, h) / 2);
|
||||
QRectF innerFrame(pixpos, QSizeF(w, h));
|
||||
QPointF pixpos = frame.center() - (QPointF(pmSize.width(), pmSize.height()) / 2);
|
||||
QRectF innerFrame(pixpos, pmSize);
|
||||
innerFrame.adjust(-4, -4, 4, 4);
|
||||
gradient.setStart(innerFrame.topLeft());
|
||||
gradient.setFinalStop(innerFrame.bottomRight());
|
||||
|
|
@ -106,14 +99,14 @@ void LayoutItem::paint(QPainter *painter,
|
|||
gradient.setStops(stops);
|
||||
painter->setBrush(QBrush(gradient));
|
||||
painter->drawRoundedRect(innerFrame, 10.0, 10.0);
|
||||
painter->drawPixmap(pixpos, *m_pix);
|
||||
painter->drawPixmap(pixpos, m_pix);
|
||||
}
|
||||
//! [2]
|
||||
|
||||
//! [3]
|
||||
QRectF LayoutItem::boundingRect() const
|
||||
{
|
||||
return QRectF(QPointF(0,0), geometry().size());
|
||||
return QRectF(QPointF(0, 0), geometry().size());
|
||||
}
|
||||
//! [3]
|
||||
|
||||
|
|
@ -133,7 +126,7 @@ QSizeF LayoutItem::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
|
|||
case Qt::MinimumSize:
|
||||
case Qt::PreferredSize:
|
||||
// Do not allow a size smaller than the pixmap with two frames around it.
|
||||
return m_pix->size() + QSize(12, 12);
|
||||
return m_pix.size() + QSize(12, 12);
|
||||
case Qt::MaximumSize:
|
||||
return QSizeF(1000,1000);
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -53,23 +53,24 @@
|
|||
|
||||
#include <QGraphicsLayoutItem>
|
||||
#include <QGraphicsItem>
|
||||
#include <QPixmap>
|
||||
|
||||
//! [0]
|
||||
class LayoutItem : public QGraphicsLayoutItem, public QGraphicsItem
|
||||
{
|
||||
public:
|
||||
LayoutItem(QGraphicsItem *parent = 0);
|
||||
~LayoutItem();
|
||||
LayoutItem(QGraphicsItem *parent = nullptr);
|
||||
|
||||
// Inherited from QGraphicsLayoutItem
|
||||
void setGeometry(const QRectF &geom) override;
|
||||
QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const override;
|
||||
|
||||
// Inherited from QGraphicsItem
|
||||
QRectF boundingRect() const override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override;
|
||||
|
||||
private:
|
||||
QPixmap *m_pix;
|
||||
QPixmap m_pix;
|
||||
};
|
||||
//! [0]
|
||||
|
||||
|
|
|
|||
|
|
@ -54,11 +54,11 @@
|
|||
#include <QGraphicsWidget>
|
||||
|
||||
//! [0]
|
||||
class Window : public QGraphicsWidget {
|
||||
class Window : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Window(QGraphicsWidget *parent = 0);
|
||||
Window(QGraphicsWidget *parent = nullptr);
|
||||
|
||||
};
|
||||
//! [0]
|
||||
|
|
|
|||
|
|
@ -49,8 +49,6 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "glbuffers.h"
|
||||
#include <QtGui/qmatrix4x4.h>
|
||||
#include <QtCore/qmath.h>
|
||||
|
||||
void qgluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar)
|
||||
{
|
||||
|
|
@ -65,7 +63,7 @@ void qgluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zF
|
|||
// GLTexture //
|
||||
//============================================================================//
|
||||
|
||||
GLTexture::GLTexture() : m_texture(0), m_failed(false)
|
||||
GLTexture::GLTexture()
|
||||
{
|
||||
glGenTextures(1, &m_texture);
|
||||
}
|
||||
|
|
@ -83,7 +81,7 @@ GLTexture2D::GLTexture2D(int width, int height)
|
|||
{
|
||||
glBindTexture(GL_TEXTURE_2D, m_texture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, 4, width, height, 0,
|
||||
GL_BGRA, GL_UNSIGNED_BYTE, 0);
|
||||
GL_BGRA, GL_UNSIGNED_BYTE, nullptr);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
|
|
@ -95,7 +93,7 @@ GLTexture2D::GLTexture2D(int width, int height)
|
|||
}
|
||||
|
||||
|
||||
GLTexture2D::GLTexture2D(const QString& fileName, int width, int height)
|
||||
GLTexture2D::GLTexture2D(const QString &fileName, int width, int height)
|
||||
{
|
||||
// TODO: Add error handling.
|
||||
QImage image(fileName);
|
||||
|
|
@ -162,7 +160,7 @@ GLTexture3D::GLTexture3D(int width, int height, int depth)
|
|||
|
||||
glBindTexture(GL_TEXTURE_3D, m_texture);
|
||||
glTexImage3D(GL_TEXTURE_3D, 0, 4, width, height, depth, 0,
|
||||
GL_BGRA, GL_UNSIGNED_BYTE, 0);
|
||||
GL_BGRA, GL_UNSIGNED_BYTE, nullptr);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
|
|
@ -206,7 +204,7 @@ GLTextureCube::GLTextureCube(int size)
|
|||
|
||||
for (int i = 0; i < 6; ++i)
|
||||
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, 4, size, size, 0,
|
||||
GL_BGRA, GL_UNSIGNED_BYTE, 0);
|
||||
GL_BGRA, GL_UNSIGNED_BYTE, nullptr);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
|
@ -252,7 +250,7 @@ GLTextureCube::GLTextureCube(const QStringList &fileNames, int size)
|
|||
// Clear remaining faces.
|
||||
while (index < 6) {
|
||||
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + index, 0, 4, size, size, 0,
|
||||
GL_BGRA, GL_UNSIGNED_BYTE, 0);
|
||||
GL_BGRA, GL_UNSIGNED_BYTE, nullptr);
|
||||
++index;
|
||||
}
|
||||
|
||||
|
|
@ -291,11 +289,8 @@ void GLTextureCube::unbind()
|
|||
//============================================================================//
|
||||
|
||||
GLFrameBufferObject::GLFrameBufferObject(int width, int height)
|
||||
: m_fbo(0)
|
||||
, m_depthBuffer(0)
|
||||
, m_width(width)
|
||||
: m_width(width)
|
||||
, m_height(height)
|
||||
, m_failed(false)
|
||||
{
|
||||
GLBUFFERS_ASSERT_OPENGL("GLFrameBufferObject::GLFrameBufferObject",
|
||||
glGenFramebuffersEXT && glGenRenderbuffersEXT && glBindRenderbufferEXT && glRenderbufferStorageEXT, return)
|
||||
|
|
@ -373,7 +368,7 @@ void GLRenderTargetCube::getViewMatrix(QMatrix4x4& mat, int face)
|
|||
return;
|
||||
}
|
||||
|
||||
static int perm[6][3] = {
|
||||
static constexpr int perm[6][3] = {
|
||||
{2, 1, 0},
|
||||
{2, 1, 0},
|
||||
{0, 2, 1},
|
||||
|
|
@ -382,7 +377,7 @@ void GLRenderTargetCube::getViewMatrix(QMatrix4x4& mat, int face)
|
|||
{0, 1, 2},
|
||||
};
|
||||
|
||||
static float signs[6][3] = {
|
||||
static constexpr float signs[6][3] = {
|
||||
{-1.0f, -1.0f, -1.0f},
|
||||
{+1.0f, -1.0f, +1.0f},
|
||||
{+1.0f, +1.0f, -1.0f},
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@
|
|||
#include <QtOpenGL>
|
||||
|
||||
#define BUFFER_OFFSET(i) ((char*)0 + (i))
|
||||
#define SIZE_OF_MEMBER(cls, member) sizeof(static_cast<cls *>(0)->member)
|
||||
#define SIZE_OF_MEMBER(cls, member) sizeof(static_cast<cls *>(nullptr)->member)
|
||||
|
||||
#define GLBUFFERS_ASSERT_OPENGL(prefix, assertion, returnStatement) \
|
||||
if (m_failed || !(assertion)) { \
|
||||
|
|
@ -82,8 +82,8 @@ public:
|
|||
virtual void unbind() = 0;
|
||||
virtual bool failed() const {return m_failed;}
|
||||
protected:
|
||||
GLuint m_texture;
|
||||
bool m_failed;
|
||||
GLuint m_texture = 0;
|
||||
bool m_failed = false;
|
||||
};
|
||||
|
||||
class GLFrameBufferObject
|
||||
|
|
@ -98,17 +98,17 @@ public:
|
|||
virtual bool failed() const {return m_failed;}
|
||||
protected:
|
||||
void setAsRenderTarget(bool state = true);
|
||||
GLuint m_fbo;
|
||||
GLuint m_depthBuffer;
|
||||
GLuint m_fbo = 0;
|
||||
GLuint m_depthBuffer = 0;
|
||||
int m_width, m_height;
|
||||
bool m_failed;
|
||||
bool m_failed = false;
|
||||
};
|
||||
|
||||
class GLTexture2D : public GLTexture
|
||||
{
|
||||
public:
|
||||
GLTexture2D(int width, int height);
|
||||
explicit GLTexture2D(const QString& fileName, int width = 0, int height = 0);
|
||||
explicit GLTexture2D(const QString &fileName, int width = 0, int height = 0);
|
||||
void load(int width, int height, QRgb *data);
|
||||
void bind() override;
|
||||
void unbind() override;
|
||||
|
|
@ -197,11 +197,7 @@ template<class T>
|
|||
class GLVertexBuffer
|
||||
{
|
||||
public:
|
||||
GLVertexBuffer(int length, const T *data = 0, int mode = GL_STATIC_DRAW)
|
||||
: m_length(0)
|
||||
, m_mode(mode)
|
||||
, m_buffer(0)
|
||||
, m_failed(false)
|
||||
GLVertexBuffer(int length, const T *data = nullptr, int mode = GL_STATIC_DRAW)
|
||||
{
|
||||
GLBUFFERS_ASSERT_OPENGL("GLVertexBuffer::GLVertexBuffer", glGenBuffers && glBindBuffer && glBufferData, return)
|
||||
|
||||
|
|
@ -275,12 +271,12 @@ public:
|
|||
|
||||
T *lock()
|
||||
{
|
||||
GLBUFFERS_ASSERT_OPENGL("GLVertexBuffer::lock", glBindBuffer && glMapBuffer, return 0)
|
||||
GLBUFFERS_ASSERT_OPENGL("GLVertexBuffer::lock", glBindBuffer && glMapBuffer, return nullptr)
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, m_buffer);
|
||||
//glBufferData(GL_ARRAY_BUFFER, m_length, NULL, m_mode);
|
||||
GLvoid* buffer = glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);
|
||||
m_failed = (buffer == 0);
|
||||
m_failed = (buffer == nullptr);
|
||||
return reinterpret_cast<T *>(buffer);
|
||||
}
|
||||
|
||||
|
|
@ -298,16 +294,17 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
int m_length, m_mode;
|
||||
GLuint m_buffer;
|
||||
bool m_failed;
|
||||
int m_length = 0;
|
||||
int m_mode = 0;
|
||||
GLuint m_buffer = 0;
|
||||
bool m_failed = false;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
class GLIndexBuffer
|
||||
{
|
||||
public:
|
||||
GLIndexBuffer(int length, const T *data = 0, int mode = GL_STATIC_DRAW)
|
||||
GLIndexBuffer(int length, const T *data = nullptr, int mode = GL_STATIC_DRAW)
|
||||
: m_length(0)
|
||||
, m_mode(mode)
|
||||
, m_buffer(0)
|
||||
|
|
@ -345,11 +342,11 @@ public:
|
|||
|
||||
T *lock()
|
||||
{
|
||||
GLBUFFERS_ASSERT_OPENGL("GLIndexBuffer::lock", glBindBuffer && glMapBuffer, return 0)
|
||||
GLBUFFERS_ASSERT_OPENGL("GLIndexBuffer::lock", glBindBuffer && glMapBuffer, return nullptr)
|
||||
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_buffer);
|
||||
GLvoid* buffer = glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_READ_WRITE);
|
||||
m_failed = (buffer == 0);
|
||||
m_failed = (buffer == nullptr);
|
||||
return reinterpret_cast<T *>(buffer);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,13 +51,12 @@
|
|||
#ifndef GLTRIANGLEMESH_H
|
||||
#define GLTRIANGLEMESH_H
|
||||
|
||||
//#include <GL/glew.h>
|
||||
#include "glbuffers.h"
|
||||
#include "glextensions.h"
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <QtOpenGL>
|
||||
|
||||
#include "glbuffers.h"
|
||||
|
||||
template<class TVertex, class TIndex>
|
||||
class GLTriangleMesh
|
||||
|
|
|
|||
|
|
@ -48,13 +48,11 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
//#include <GL/glew.h>
|
||||
#include "glextensions.h"
|
||||
|
||||
#include "scene.h"
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <QGLWidget>
|
||||
#include <QtWidgets>
|
||||
|
||||
class GraphicsView : public QGraphicsView
|
||||
{
|
||||
|
|
@ -114,7 +112,7 @@ int main(int argc, char **argv)
|
|||
QApplication app(argc, argv);
|
||||
|
||||
if ((QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_1_5) == 0) {
|
||||
QMessageBox::critical(0, "OpenGL features missing",
|
||||
QMessageBox::critical(nullptr, "OpenGL features missing",
|
||||
"OpenGL version 1.5 or higher is required to run this demo.\n"
|
||||
"The program will now exit.");
|
||||
return -1;
|
||||
|
|
@ -125,7 +123,7 @@ int main(int argc, char **argv)
|
|||
widget->makeCurrent();
|
||||
|
||||
if (!necessaryExtensionsSupported()) {
|
||||
QMessageBox::critical(0, "OpenGL features missing",
|
||||
QMessageBox::critical(nullptr, "OpenGL features missing",
|
||||
"The OpenGL extensions required to run this demo are missing.\n"
|
||||
"The program will now exit.");
|
||||
delete widget;
|
||||
|
|
@ -134,7 +132,7 @@ int main(int argc, char **argv)
|
|||
|
||||
// Check if all the necessary functions are resolved.
|
||||
if (!getGLExtensionFunctions().resolve(widget->context())) {
|
||||
QMessageBox::critical(0, "OpenGL features missing",
|
||||
QMessageBox::critical(nullptr, "OpenGL features missing",
|
||||
"Failed to resolve OpenGL functions required to run this demo.\n"
|
||||
"The program will now exit.");
|
||||
delete widget;
|
||||
|
|
@ -142,7 +140,7 @@ int main(int argc, char **argv)
|
|||
}
|
||||
|
||||
// TODO: Make conditional for final release
|
||||
QMessageBox::information(0, "For your information",
|
||||
QMessageBox::information(nullptr, "For your information",
|
||||
"This demo can be GPU and CPU intensive and may\n"
|
||||
"work poorly or not at all on your system.");
|
||||
|
||||
|
|
|
|||
|
|
@ -50,28 +50,23 @@
|
|||
|
||||
#include "qtbox.h"
|
||||
|
||||
const qreal ROTATE_SPEED_X = 30.0 / 1000.0;
|
||||
const qreal ROTATE_SPEED_Y = 20.0 / 1000.0;
|
||||
const qreal ROTATE_SPEED_Z = 40.0 / 1000.0;
|
||||
const int MAX_ITEM_SIZE = 512;
|
||||
const int MIN_ITEM_SIZE = 16;
|
||||
constexpr qreal ROTATE_SPEED_X = 30.0 / 1000.0;
|
||||
constexpr qreal ROTATE_SPEED_Y = 20.0 / 1000.0;
|
||||
constexpr qreal ROTATE_SPEED_Z = 40.0 / 1000.0;
|
||||
constexpr int MAX_ITEM_SIZE = 512;
|
||||
constexpr int MIN_ITEM_SIZE = 16;
|
||||
|
||||
//============================================================================//
|
||||
// ItemBase //
|
||||
//============================================================================//
|
||||
|
||||
ItemBase::ItemBase(int size, int x, int y) : m_size(size), m_isResizing(false)
|
||||
ItemBase::ItemBase(int size, int x, int y) : m_size(size), m_startTime(QTime::currentTime())
|
||||
{
|
||||
setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||
setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||
setFlag(QGraphicsItem::ItemIsFocusable, true);
|
||||
setAcceptHoverEvents(true);
|
||||
setPos(x, y);
|
||||
m_startTime = QTime::currentTime();
|
||||
}
|
||||
|
||||
ItemBase::~ItemBase()
|
||||
{
|
||||
}
|
||||
|
||||
QRectF ItemBase::boundingRect() const
|
||||
|
|
@ -252,10 +247,7 @@ void ItemBase::wheelEvent(QGraphicsSceneWheelEvent *event)
|
|||
{
|
||||
prepareGeometryChange();
|
||||
m_size = int(m_size * qExp(-event->delta() / 600.0));
|
||||
if (m_size > MAX_ITEM_SIZE)
|
||||
m_size = MAX_ITEM_SIZE;
|
||||
else if (m_size < MIN_ITEM_SIZE)
|
||||
m_size = MIN_ITEM_SIZE;
|
||||
m_size = qBound(MIN_ITEM_SIZE, m_size, MAX_ITEM_SIZE);
|
||||
}
|
||||
|
||||
int ItemBase::type() const
|
||||
|
|
@ -273,7 +265,7 @@ bool ItemBase::isInResizeArea(const QPointF &pos)
|
|||
// QtBox //
|
||||
//============================================================================//
|
||||
|
||||
QtBox::QtBox(int size, int x, int y) : ItemBase(size, x, y), m_texture(0)
|
||||
QtBox::QtBox(int size, int x, int y) : ItemBase(size, x, y)
|
||||
{
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
m_vertices[i].setX(i & 1 ? 0.5f : -0.5f);
|
||||
|
|
@ -294,8 +286,7 @@ QtBox::QtBox(int size, int x, int y) : ItemBase(size, x, y), m_texture(0)
|
|||
|
||||
QtBox::~QtBox()
|
||||
{
|
||||
if (m_texture)
|
||||
delete m_texture;
|
||||
delete m_texture;
|
||||
}
|
||||
|
||||
ItemBase *QtBox::createNew(int size, int x, int y)
|
||||
|
|
@ -337,7 +328,7 @@ void QtBox::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWi
|
|||
glEnable(GL_COLOR_MATERIAL);
|
||||
glEnable(GL_NORMALIZE);
|
||||
|
||||
if(m_texture == 0)
|
||||
if (m_texture == nullptr)
|
||||
m_texture = new GLTexture2D(":/res/boxes/qt-logo.jpg", 64, 64);
|
||||
m_texture->bind();
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
|
@ -405,9 +396,8 @@ void QtBox::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWi
|
|||
//============================================================================//
|
||||
|
||||
CircleItem::CircleItem(int size, int x, int y) : ItemBase(size, x, y)
|
||||
{
|
||||
m_color = QColor::fromHsv(QRandomGenerator::global()->bounded(360), 255, 255);
|
||||
}
|
||||
, m_color(QColor::fromHsv(QRandomGenerator::global()->bounded(360), 255, 255))
|
||||
{}
|
||||
|
||||
void CircleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
|
|
@ -455,9 +445,8 @@ ItemBase *CircleItem::createNew(int size, int x, int y)
|
|||
//============================================================================//
|
||||
|
||||
SquareItem::SquareItem(int size, int x, int y) : ItemBase(size, x, y)
|
||||
{
|
||||
m_image = QPixmap(":/res/boxes/square.jpg");
|
||||
}
|
||||
, m_image(QPixmap(":/res/boxes/square.jpg"))
|
||||
{}
|
||||
|
||||
void SquareItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -51,18 +51,17 @@
|
|||
#ifndef QTBOX_H
|
||||
#define QTBOX_H
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
#include <QtGui/qvector3d.h>
|
||||
#include "glbuffers.h"
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <QVector3D>
|
||||
|
||||
class ItemBase : public QGraphicsItem
|
||||
{
|
||||
public:
|
||||
enum { Type = UserType + 1 };
|
||||
|
||||
ItemBase(int size, int x, int y);
|
||||
virtual ~ItemBase();
|
||||
QRectF boundingRect() const override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
protected:
|
||||
|
|
@ -84,7 +83,7 @@ protected:
|
|||
|
||||
int m_size;
|
||||
QTime m_startTime;
|
||||
bool m_isResizing;
|
||||
bool m_isResizing = false;
|
||||
};
|
||||
|
||||
class QtBox : public ItemBase
|
||||
|
|
@ -99,7 +98,7 @@ private:
|
|||
QVector3D m_vertices[8];
|
||||
QVector3D m_texCoords[4];
|
||||
QVector3D m_normals[6];
|
||||
GLTexture *m_texture;
|
||||
GLTexture *m_texture = nullptr;
|
||||
};
|
||||
|
||||
class CircleItem : public ItemBase
|
||||
|
|
|
|||
|
|
@ -51,16 +51,12 @@
|
|||
#ifndef ROUNDEDBOX_H
|
||||
#define ROUNDEDBOX_H
|
||||
|
||||
//#include <GL/glew.h>
|
||||
#include "glextensions.h"
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <QtOpenGL>
|
||||
|
||||
#include "gltrianglemesh.h"
|
||||
#include <QtGui/qvector3d.h>
|
||||
#include <QtGui/qvector2d.h>
|
||||
#include "glbuffers.h"
|
||||
#include "glextensions.h"
|
||||
#include "gltrianglemesh.h"
|
||||
|
||||
#include <QVector2D>
|
||||
#include <QVector3D>
|
||||
|
||||
struct P3T2N3Vertex
|
||||
{
|
||||
|
|
|
|||
|
|
@ -48,45 +48,15 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QDebug>
|
||||
#include "scene.h"
|
||||
#include <QtCore/QRandomGenerator>
|
||||
#include <QtGui/qmatrix4x4.h>
|
||||
#include <QtGui/qvector3d.h>
|
||||
|
||||
#include <QMatrix4x4>
|
||||
#include <QRandomGenerator>
|
||||
#include <QVector3D>
|
||||
#include <qmath.h>
|
||||
|
||||
#include "3rdparty/fbm.h"
|
||||
|
||||
void checkGLErrors(const QString& prefix)
|
||||
{
|
||||
switch (glGetError()) {
|
||||
case GL_NO_ERROR:
|
||||
//qDebug() << prefix << tr("No error.");
|
||||
break;
|
||||
case GL_INVALID_ENUM:
|
||||
qDebug() << prefix << QObject::tr("Invalid enum.");
|
||||
break;
|
||||
case GL_INVALID_VALUE:
|
||||
qDebug() << prefix << QObject::tr("Invalid value.");
|
||||
break;
|
||||
case GL_INVALID_OPERATION:
|
||||
qDebug() << prefix << QObject::tr("Invalid operation.");
|
||||
break;
|
||||
case GL_STACK_OVERFLOW:
|
||||
qDebug() << prefix << QObject::tr("Stack overflow.");
|
||||
break;
|
||||
case GL_STACK_UNDERFLOW:
|
||||
qDebug() << prefix << QObject::tr("Stack underflow.");
|
||||
break;
|
||||
case GL_OUT_OF_MEMORY:
|
||||
qDebug() << prefix << QObject::tr("Out of memory.");
|
||||
break;
|
||||
default:
|
||||
qDebug() << prefix << QObject::tr("Unknown error.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//============================================================================//
|
||||
// ColorEdit //
|
||||
//============================================================================//
|
||||
|
|
@ -126,7 +96,7 @@ void ColorEdit::mousePressEvent(QMouseEvent *event)
|
|||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
QColor color(m_color);
|
||||
QColorDialog dialog(color, 0);
|
||||
QColorDialog dialog(color, nullptr);
|
||||
dialog.setOption(QColorDialog::ShowAlphaChannel, true);
|
||||
dialog.move(280, 120);
|
||||
if (dialog.exec() == QDialog::Rejected)
|
||||
|
|
@ -179,17 +149,6 @@ void FloatEdit::editDone()
|
|||
//============================================================================//
|
||||
// TwoSidedGraphicsWidget //
|
||||
//============================================================================//
|
||||
|
||||
TwoSidedGraphicsWidget::TwoSidedGraphicsWidget(QGraphicsScene *scene)
|
||||
: QObject(scene)
|
||||
, m_current(0)
|
||||
, m_angle(0)
|
||||
, m_delta(0)
|
||||
{
|
||||
for (int i = 0; i < 2; ++i)
|
||||
m_proxyWidgets[i] = 0;
|
||||
}
|
||||
|
||||
void TwoSidedGraphicsWidget::setWidget(int index, QWidget *widget)
|
||||
{
|
||||
if (index < 0 || index >= 2)
|
||||
|
|
@ -201,8 +160,7 @@ void TwoSidedGraphicsWidget::setWidget(int index, QWidget *widget)
|
|||
GraphicsWidget *proxy = new GraphicsWidget;
|
||||
proxy->setWidget(widget);
|
||||
|
||||
if (m_proxyWidgets[index])
|
||||
delete m_proxyWidgets[index];
|
||||
delete m_proxyWidgets[index];
|
||||
m_proxyWidgets[index] = proxy;
|
||||
|
||||
proxy->setCacheMode(QGraphicsItem::ItemCoordinateCache);
|
||||
|
|
@ -219,7 +177,7 @@ QWidget *TwoSidedGraphicsWidget::widget(int index)
|
|||
if (index < 0 || index >= 2)
|
||||
{
|
||||
qWarning("TwoSidedGraphicsWidget::widget: Index out of bounds, index == %d", index);
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
return m_proxyWidgets[index]->widget();
|
||||
}
|
||||
|
|
@ -289,7 +247,7 @@ void GraphicsWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
|
|||
//============================================================================//
|
||||
|
||||
RenderOptionsDialog::RenderOptionsDialog()
|
||||
: QDialog(0, Qt::CustomizeWindowHint | Qt::WindowTitleHint)
|
||||
: QDialog(nullptr, Qt::CustomizeWindowHint | Qt::WindowTitleHint)
|
||||
{
|
||||
setWindowOpacity(0.75);
|
||||
setWindowTitle(tr("Options (double click to flip)"));
|
||||
|
|
@ -423,7 +381,7 @@ void RenderOptionsDialog::mouseDoubleClickEvent(QMouseEvent *event)
|
|||
//============================================================================//
|
||||
|
||||
ItemDialog::ItemDialog()
|
||||
: QDialog(0, Qt::CustomizeWindowHint | Qt::WindowTitleHint)
|
||||
: QDialog(nullptr, Qt::CustomizeWindowHint | Qt::WindowTitleHint)
|
||||
{
|
||||
setWindowTitle(tr("Items (double click to flip)"));
|
||||
setWindowOpacity(0.75);
|
||||
|
|
@ -487,10 +445,10 @@ Scene::Scene(int width, int height, int maxTextureSize)
|
|||
, m_currentTexture(0)
|
||||
, m_dynamicCubemap(false)
|
||||
, m_updateAllCubemaps(true)
|
||||
, m_box(0)
|
||||
, m_vertexShader(0)
|
||||
, m_environmentShader(0)
|
||||
, m_environmentProgram(0)
|
||||
, m_box(nullptr)
|
||||
, m_vertexShader(nullptr)
|
||||
, m_environmentShader(nullptr)
|
||||
, m_environmentProgram(nullptr)
|
||||
{
|
||||
setSceneRect(0, 0, width, height);
|
||||
|
||||
|
|
@ -564,9 +522,8 @@ void Scene::initGL()
|
|||
|
||||
const int NOISE_SIZE = 128; // for a different size, B and BM in fbm.c must also be changed
|
||||
m_noise = new GLTexture3D(NOISE_SIZE, NOISE_SIZE, NOISE_SIZE);
|
||||
QRgb *data = new QRgb[NOISE_SIZE * NOISE_SIZE * NOISE_SIZE];
|
||||
memset(data, 0, NOISE_SIZE * NOISE_SIZE * NOISE_SIZE * sizeof(QRgb));
|
||||
QRgb *p = data;
|
||||
QVector<QRgb> data(NOISE_SIZE * NOISE_SIZE * NOISE_SIZE, QRgb(0));
|
||||
QRgb *p = data.data();
|
||||
float pos[3];
|
||||
for (int k = 0; k < NOISE_SIZE; ++k) {
|
||||
pos[2] = k * (0x20 / (float)NOISE_SIZE);
|
||||
|
|
@ -581,8 +538,7 @@ void Scene::initGL()
|
|||
}
|
||||
}
|
||||
}
|
||||
m_noise->load(NOISE_SIZE, NOISE_SIZE, NOISE_SIZE, data);
|
||||
delete[] data;
|
||||
m_noise->load(NOISE_SIZE, NOISE_SIZE, NOISE_SIZE, data.data());
|
||||
|
||||
m_mainCubemap = new GLRenderTargetCube(512);
|
||||
|
||||
|
|
@ -634,7 +590,7 @@ void Scene::initGL()
|
|||
m_renderOptions->addShader(file.baseName());
|
||||
|
||||
program->bind();
|
||||
m_cubemaps << ((program->uniformLocation("env") != -1) ? new GLRenderTargetCube(qMin(256, m_maxTextureSize)) : 0);
|
||||
m_cubemaps << ((program->uniformLocation("env") != -1) ? new GLRenderTargetCube(qMin(256, m_maxTextureSize)) : nullptr);
|
||||
program->release();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,17 +51,12 @@
|
|||
#ifndef SCENE_H
|
||||
#define SCENE_H
|
||||
|
||||
//#include <GL/glew.h>
|
||||
#include "glextensions.h"
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <QtOpenGL>
|
||||
|
||||
#include "roundedbox.h"
|
||||
#include "gltrianglemesh.h"
|
||||
#include "trackball.h"
|
||||
#include "glbuffers.h"
|
||||
#include "glextensions.h"
|
||||
#include "gltrianglemesh.h"
|
||||
#include "qtbox.h"
|
||||
#include "roundedbox.h"
|
||||
#include "trackball.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QMatrix4x4;
|
||||
|
|
@ -116,7 +111,7 @@ private:
|
|||
class GraphicsWidget : public QGraphicsProxyWidget
|
||||
{
|
||||
public:
|
||||
GraphicsWidget() : QGraphicsProxyWidget(0, Qt::Window) {}
|
||||
GraphicsWidget() : QGraphicsProxyWidget(nullptr, Qt::Window) {}
|
||||
protected:
|
||||
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
||||
void resizeEvent(QGraphicsSceneResizeEvent *event) override;
|
||||
|
|
@ -127,7 +122,7 @@ class TwoSidedGraphicsWidget : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TwoSidedGraphicsWidget(QGraphicsScene *scene);
|
||||
using QObject::QObject;
|
||||
void setWidget(int index, QWidget *widget);
|
||||
QWidget *widget(int index);
|
||||
public slots:
|
||||
|
|
@ -135,10 +130,10 @@ public slots:
|
|||
protected slots:
|
||||
void animateFlip();
|
||||
private:
|
||||
GraphicsWidget *m_proxyWidgets[2];
|
||||
int m_current;
|
||||
int m_angle; // angle in degrees
|
||||
int m_delta;
|
||||
GraphicsWidget *m_proxyWidgets[2] = {nullptr, nullptr};
|
||||
int m_current = 0;
|
||||
int m_angle = 0; // angle in degrees
|
||||
int m_delta = 0;
|
||||
};
|
||||
|
||||
class RenderOptionsDialog : public QDialog
|
||||
|
|
|
|||
|
|
@ -50,34 +50,21 @@
|
|||
|
||||
#include "trackball.h"
|
||||
#include "scene.h"
|
||||
#include <qmath.h>
|
||||
#include <cmath>
|
||||
|
||||
//============================================================================//
|
||||
// TrackBall //
|
||||
//============================================================================//
|
||||
|
||||
TrackBall::TrackBall(TrackMode mode)
|
||||
: m_angularVelocity(0)
|
||||
, m_paused(false)
|
||||
, m_pressed(false)
|
||||
, m_mode(mode)
|
||||
: TrackBall(0, QVector3D(0, 1, 0), mode)
|
||||
{
|
||||
m_axis = QVector3D(0, 1, 0);
|
||||
m_rotation = QQuaternion();
|
||||
m_lastTime = QTime::currentTime();
|
||||
}
|
||||
|
||||
TrackBall::TrackBall(float angularVelocity, const QVector3D& axis, TrackMode mode)
|
||||
: m_axis(axis)
|
||||
, m_angularVelocity(angularVelocity)
|
||||
, m_paused(false)
|
||||
, m_pressed(false)
|
||||
, m_mode(mode)
|
||||
{
|
||||
m_rotation = QQuaternion();
|
||||
m_lastTime = QTime::currentTime();
|
||||
}
|
||||
{}
|
||||
|
||||
void TrackBall::push(const QPointF& p, const QQuaternion &)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -51,10 +51,9 @@
|
|||
#ifndef TRACKBALL_H
|
||||
#define TRACKBALL_H
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
#include <QtGui/qvector3d.h>
|
||||
#include <QtGui/qquaternion.h>
|
||||
#include <QQuaternion>
|
||||
#include <QTime>
|
||||
#include <QVector3D>
|
||||
|
||||
class TrackBall
|
||||
{
|
||||
|
|
@ -65,24 +64,24 @@ public:
|
|||
Sphere,
|
||||
};
|
||||
TrackBall(TrackMode mode = Sphere);
|
||||
TrackBall(float angularVelocity, const QVector3D& axis, TrackMode mode = Sphere);
|
||||
TrackBall(float angularVelocity, const QVector3D &axis, TrackMode mode = Sphere);
|
||||
// coordinates in [-1,1]x[-1,1]
|
||||
void push(const QPointF& p, const QQuaternion &transformation);
|
||||
void move(const QPointF& p, const QQuaternion &transformation);
|
||||
void release(const QPointF& p, const QQuaternion &transformation);
|
||||
void push(const QPointF &p, const QQuaternion &transformation);
|
||||
void move(const QPointF &p, const QQuaternion &transformation);
|
||||
void release(const QPointF &p, const QQuaternion &transformation);
|
||||
void start(); // starts clock
|
||||
void stop(); // stops clock
|
||||
QQuaternion rotation() const;
|
||||
private:
|
||||
QQuaternion m_rotation;
|
||||
QVector3D m_axis;
|
||||
float m_angularVelocity;
|
||||
QVector3D m_axis = QVector3D(0, 1, 0);
|
||||
float m_angularVelocity = 0;
|
||||
|
||||
QPointF m_lastPos;
|
||||
QTime m_lastTime;
|
||||
bool m_paused;
|
||||
bool m_pressed;
|
||||
QTime m_lastTime = QTime::currentTime();
|
||||
TrackMode m_mode;
|
||||
bool m_paused = false;
|
||||
bool m_pressed = false;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -50,7 +50,9 @@
|
|||
|
||||
#include "chip.h"
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QPainter>
|
||||
#include <QStyleOptionGraphicsItem>
|
||||
|
||||
Chip::Chip(const QColor &color, int x, int y)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -56,13 +56,11 @@
|
|||
#include <QSplitter>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
: QWidget(parent), scene(new QGraphicsScene(this))
|
||||
, h1Splitter(new QSplitter(this)), h2Splitter(new QSplitter(this))
|
||||
{
|
||||
populateScene();
|
||||
|
||||
h1Splitter = new QSplitter;
|
||||
h2Splitter = new QSplitter;
|
||||
|
||||
QSplitter *vSplitter = new QSplitter;
|
||||
vSplitter->setOrientation(Qt::Vertical);
|
||||
vSplitter->addWidget(h1Splitter);
|
||||
|
|
@ -93,8 +91,6 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
|
||||
void MainWindow::populateScene()
|
||||
{
|
||||
scene = new QGraphicsScene(this);
|
||||
|
||||
QImage image(":/qt4logo.png");
|
||||
|
||||
// Populate scene
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class MainWindow : public QWidget
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MainWindow(QWidget *parent = 0);
|
||||
MainWindow(QWidget *parent = nullptr);
|
||||
|
||||
private:
|
||||
void setupMatrix();
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@
|
|||
#else
|
||||
#include <QtWidgets>
|
||||
#endif
|
||||
#include <qmath.h>
|
||||
#include <QtMath>
|
||||
|
||||
#if QT_CONFIG(wheelevent)
|
||||
void GraphicsView::wheelEvent(QWheelEvent *e)
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class View : public QFrame
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit View(const QString &name, QWidget *parent = 0);
|
||||
explicit View(const QString &name, QWidget *parent = nullptr);
|
||||
|
||||
QGraphicsView *view() const;
|
||||
|
||||
|
|
|
|||
|
|
@ -48,13 +48,12 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtMath>
|
||||
#include <QtWidgets>
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "mouse.h"
|
||||
|
||||
static const int MouseCount = 7;
|
||||
static constexpr int MouseCount = 7;
|
||||
|
||||
//! [0]
|
||||
int main(int argc, char **argv)
|
||||
|
|
|
|||
|
|
@ -54,10 +54,10 @@
|
|||
#include <QPainter>
|
||||
#include <QRandomGenerator>
|
||||
#include <QStyleOption>
|
||||
#include <qmath.h>
|
||||
#include <QtMath>
|
||||
|
||||
const qreal Pi = M_PI;
|
||||
const qreal TwoPi = 2 * M_PI;
|
||||
constexpr qreal Pi = M_PI;
|
||||
constexpr qreal TwoPi = 2 * M_PI;
|
||||
|
||||
static qreal normalizeAngle(qreal angle)
|
||||
{
|
||||
|
|
@ -70,8 +70,7 @@ static qreal normalizeAngle(qreal angle)
|
|||
|
||||
//! [0]
|
||||
Mouse::Mouse()
|
||||
: angle(0), speed(0), mouseEyeDirection(0),
|
||||
color(QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256))
|
||||
: color(QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256))
|
||||
{
|
||||
setRotation(QRandomGenerator::global()->bounded(360 * 16));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,9 +68,9 @@ protected:
|
|||
void advance(int step) override;
|
||||
|
||||
private:
|
||||
qreal angle;
|
||||
qreal speed;
|
||||
qreal mouseEyeDirection;
|
||||
qreal angle = 0;
|
||||
qreal speed = 0;
|
||||
qreal mouseEyeDirection = 0;
|
||||
QColor color;
|
||||
};
|
||||
//! [0]
|
||||
|
|
|
|||
|
|
@ -50,19 +50,17 @@
|
|||
|
||||
|
||||
#include "arrow.h"
|
||||
#include "diagramitem.h"
|
||||
|
||||
#include <qmath.h>
|
||||
#include <QPen>
|
||||
#include <QPainter>
|
||||
#include <QPen>
|
||||
#include <QtMath>
|
||||
|
||||
//! [0]
|
||||
Arrow::Arrow(DiagramItem *startItem, DiagramItem *endItem, QGraphicsItem *parent)
|
||||
: QGraphicsLineItem(parent)
|
||||
: QGraphicsLineItem(parent), myStartItem(startItem), myEndItem(endItem)
|
||||
{
|
||||
myStartItem = startItem;
|
||||
myEndItem = endItem;
|
||||
setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||
myColor = Qt::black;
|
||||
setPen(QPen(myColor, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
||||
}
|
||||
//! [0]
|
||||
|
|
@ -98,7 +96,7 @@ void Arrow::updatePosition()
|
|||
|
||||
//! [4]
|
||||
void Arrow::paint(QPainter *painter, const QStyleOptionGraphicsItem *,
|
||||
QWidget *)
|
||||
QWidget *)
|
||||
{
|
||||
if (myStartItem->collidesWithItem(myEndItem))
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -53,16 +53,7 @@
|
|||
|
||||
#include <QGraphicsLineItem>
|
||||
|
||||
#include "diagramitem.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QGraphicsPolygonItem;
|
||||
class QGraphicsLineItem;
|
||||
class QGraphicsScene;
|
||||
class QRectF;
|
||||
class QGraphicsSceneMouseEvent;
|
||||
class QPainterPath;
|
||||
QT_END_NAMESPACE
|
||||
class DiagramItem;
|
||||
|
||||
//! [0]
|
||||
class Arrow : public QGraphicsLineItem
|
||||
|
|
@ -71,7 +62,7 @@ public:
|
|||
enum { Type = UserType + 4 };
|
||||
|
||||
Arrow(DiagramItem *startItem, DiagramItem *endItem,
|
||||
QGraphicsItem *parent = 0);
|
||||
QGraphicsItem *parent = nullptr);
|
||||
|
||||
int type() const override { return Type; }
|
||||
QRectF boundingRect() const override;
|
||||
|
|
@ -83,13 +74,14 @@ public:
|
|||
void updatePosition();
|
||||
|
||||
protected:
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr) override;
|
||||
|
||||
private:
|
||||
DiagramItem *myStartItem;
|
||||
DiagramItem *myEndItem;
|
||||
QColor myColor;
|
||||
QPolygonF arrowHead;
|
||||
QColor myColor = Qt::black;
|
||||
};
|
||||
//! [0]
|
||||
|
||||
|
|
|
|||
|
|
@ -58,12 +58,10 @@
|
|||
|
||||
//! [0]
|
||||
DiagramItem::DiagramItem(DiagramType diagramType, QMenu *contextMenu,
|
||||
QGraphicsItem *parent)
|
||||
: QGraphicsPolygonItem(parent)
|
||||
QGraphicsItem *parent)
|
||||
: QGraphicsPolygonItem(parent), myDiagramType(diagramType)
|
||||
, myContextMenu(contextMenu)
|
||||
{
|
||||
myDiagramType = diagramType;
|
||||
myContextMenu = contextMenu;
|
||||
|
||||
QPainterPath path;
|
||||
switch (myDiagramType) {
|
||||
case StartEnd:
|
||||
|
|
@ -101,17 +99,17 @@ DiagramItem::DiagramItem(DiagramType diagramType, QMenu *contextMenu,
|
|||
//! [1]
|
||||
void DiagramItem::removeArrow(Arrow *arrow)
|
||||
{
|
||||
int index = arrows.indexOf(arrow);
|
||||
|
||||
if (index != -1)
|
||||
arrows.removeAt(index);
|
||||
arrows.removeAll(arrow);
|
||||
}
|
||||
//! [1]
|
||||
|
||||
//! [2]
|
||||
void DiagramItem::removeArrows()
|
||||
{
|
||||
for (Arrow *arrow : qAsConst(arrows)) {
|
||||
// need a copy here since removeArrow() will
|
||||
// modify the arrows container
|
||||
const auto arrowsCopy = arrows;
|
||||
for (Arrow *arrow : arrowsCopy) {
|
||||
arrow->startItem()->removeArrow(arrow);
|
||||
arrow->endItem()->removeArrow(arrow);
|
||||
scene()->removeItem(arrow);
|
||||
|
|
|
|||
|
|
@ -52,19 +52,12 @@
|
|||
#define DIAGRAMITEM_H
|
||||
|
||||
#include <QGraphicsPixmapItem>
|
||||
#include <QList>
|
||||
#include <QVector>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QPixmap;
|
||||
class QGraphicsItem;
|
||||
class QGraphicsScene;
|
||||
class QTextEdit;
|
||||
class QGraphicsSceneMouseEvent;
|
||||
class QMenu;
|
||||
class QGraphicsSceneContextMenuEvent;
|
||||
class QPainter;
|
||||
class QStyleOptionGraphicsItem;
|
||||
class QWidget;
|
||||
class QMenu;
|
||||
class QPolygonF;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
|
@ -77,7 +70,7 @@ public:
|
|||
enum { Type = UserType + 15 };
|
||||
enum DiagramType { Step, Conditional, StartEnd, Io };
|
||||
|
||||
DiagramItem(DiagramType diagramType, QMenu *contextMenu, QGraphicsItem *parent = 0);
|
||||
DiagramItem(DiagramType diagramType, QMenu *contextMenu, QGraphicsItem *parent = nullptr);
|
||||
|
||||
void removeArrow(Arrow *arrow);
|
||||
void removeArrows();
|
||||
|
|
@ -85,7 +78,7 @@ public:
|
|||
QPolygonF polygon() const { return myPolygon; }
|
||||
void addArrow(Arrow *arrow);
|
||||
QPixmap image() const;
|
||||
int type() const override { return Type;}
|
||||
int type() const override { return Type; }
|
||||
|
||||
protected:
|
||||
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override;
|
||||
|
|
@ -95,7 +88,7 @@ private:
|
|||
DiagramType myDiagramType;
|
||||
QPolygonF myPolygon;
|
||||
QMenu *myContextMenu;
|
||||
QList<Arrow *> arrows;
|
||||
QVector<Arrow *> arrows;
|
||||
};
|
||||
//! [0]
|
||||
|
||||
|
|
|
|||
|
|
@ -51,8 +51,8 @@
|
|||
#include "diagramscene.h"
|
||||
#include "arrow.h"
|
||||
|
||||
#include <QTextCursor>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QTextCursor>
|
||||
|
||||
//! [0]
|
||||
DiagramScene::DiagramScene(QMenu *itemMenu, QObject *parent)
|
||||
|
|
@ -61,8 +61,8 @@ DiagramScene::DiagramScene(QMenu *itemMenu, QObject *parent)
|
|||
myItemMenu = itemMenu;
|
||||
myMode = MoveItem;
|
||||
myItemType = DiagramItem::Step;
|
||||
line = 0;
|
||||
textItem = 0;
|
||||
line = nullptr;
|
||||
textItem = nullptr;
|
||||
myItemColor = Qt::white;
|
||||
myTextColor = Qt::black;
|
||||
myLineColor = Qt::black;
|
||||
|
|
@ -188,7 +188,7 @@ void DiagramScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
|||
//! [10]
|
||||
void DiagramScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
||||
{
|
||||
if (myMode == InsertLine && line != 0) {
|
||||
if (myMode == InsertLine && line != nullptr) {
|
||||
QLineF newLine(line->line().p1(), mouseEvent->scenePos());
|
||||
line->setLine(newLine);
|
||||
} else if (myMode == MoveItem) {
|
||||
|
|
@ -200,7 +200,7 @@ void DiagramScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
|||
//! [11]
|
||||
void DiagramScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
||||
{
|
||||
if (line != 0 && myMode == InsertLine) {
|
||||
if (line != nullptr && myMode == InsertLine) {
|
||||
QList<QGraphicsItem *> startItems = items(line->line().p1());
|
||||
if (startItems.count() && startItems.first() == line)
|
||||
startItems.removeFirst();
|
||||
|
|
@ -228,7 +228,7 @@ void DiagramScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
|||
}
|
||||
}
|
||||
//! [12] //! [13]
|
||||
line = 0;
|
||||
line = nullptr;
|
||||
QGraphicsScene::mouseReleaseEvent(mouseEvent);
|
||||
}
|
||||
//! [13]
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class DiagramScene : public QGraphicsScene
|
|||
public:
|
||||
enum Mode { InsertItem, InsertLine, InsertText, MoveItem };
|
||||
|
||||
explicit DiagramScene(QMenu *itemMenu, QObject *parent = 0);
|
||||
explicit DiagramScene(QMenu *itemMenu, QObject *parent = nullptr);
|
||||
QFont font() const { return myFont; }
|
||||
QColor textColor() const { return myTextColor; }
|
||||
QColor itemColor() const { return myItemColor; }
|
||||
|
|
|
|||
|
|
@ -52,12 +52,8 @@
|
|||
#define DIAGRAMTEXTITEM_H
|
||||
|
||||
#include <QGraphicsTextItem>
|
||||
#include <QPen>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QFocusEvent;
|
||||
class QGraphicsItem;
|
||||
class QGraphicsScene;
|
||||
class QGraphicsSceneMouseEvent;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
|
@ -69,7 +65,7 @@ class DiagramTextItem : public QGraphicsTextItem
|
|||
public:
|
||||
enum { Type = UserType + 3 };
|
||||
|
||||
DiagramTextItem(QGraphicsItem *parent = 0);
|
||||
DiagramTextItem(QGraphicsItem *parent = nullptr);
|
||||
|
||||
int type() const override { return Type; }
|
||||
|
||||
|
|
|
|||
|
|
@ -48,10 +48,18 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
#include "coloritem.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QBitmap>
|
||||
#include <QCursor>
|
||||
#include <QDrag>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QMimeData>
|
||||
#include <QPainter>
|
||||
#include <QRandomGenerator>
|
||||
#include <QWidget>
|
||||
|
||||
//! [0]
|
||||
ColorItem::ColorItem()
|
||||
: color(QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256))
|
||||
|
|
@ -128,7 +136,7 @@ void ColorItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||
QPainter painter(&pixmap);
|
||||
painter.translate(15, 15);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
paint(&painter, 0, 0);
|
||||
paint(&painter, nullptr, nullptr);
|
||||
painter.end();
|
||||
|
||||
pixmap.setMask(pixmap.createHeuristicMask());
|
||||
|
|
|
|||
|
|
@ -48,19 +48,20 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <QApplication>
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsView>
|
||||
|
||||
#include "coloritem.h"
|
||||
#include "robot.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
|
||||
|
||||
class GraphicsView : public QGraphicsView
|
||||
{
|
||||
public:
|
||||
GraphicsView(QGraphicsScene *scene) : QGraphicsView(scene)
|
||||
{
|
||||
}
|
||||
using QGraphicsView::QGraphicsView;
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *) override
|
||||
|
|
@ -96,7 +97,7 @@ int main(int argc, char **argv)
|
|||
view.setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
|
||||
view.setBackgroundBrush(QColor(230, 200, 167));
|
||||
view.setWindowTitle("Drag and Drop Robot");
|
||||
view.show();
|
||||
view.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,13 +48,17 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
#include "robot.h"
|
||||
|
||||
#include <QGraphicsSceneDragDropEvent>
|
||||
#include <QMimeData>
|
||||
#include <QPainter>
|
||||
#include <QParallelAnimationGroup>
|
||||
#include <QPropertyAnimation>
|
||||
|
||||
//! [0]
|
||||
RobotPart::RobotPart(QGraphicsItem *parent)
|
||||
: QGraphicsObject(parent), color(Qt::lightGray), dragOver(false)
|
||||
: QGraphicsObject(parent), color(Qt::lightGray)
|
||||
{
|
||||
setAcceptDrops(true);
|
||||
}
|
||||
|
|
@ -157,11 +161,6 @@ void RobotHead::dropEvent(QGraphicsSceneDragDropEvent *event)
|
|||
}
|
||||
//! [8]
|
||||
|
||||
RobotTorso::RobotTorso(QGraphicsItem *parent)
|
||||
: RobotPart(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QRectF RobotTorso::boundingRect() const
|
||||
{
|
||||
return QRectF(-30, -20, 60, 60);
|
||||
|
|
|
|||
|
|
@ -62,15 +62,15 @@ QT_END_NAMESPACE
|
|||
class RobotPart : public QGraphicsObject
|
||||
{
|
||||
public:
|
||||
RobotPart(QGraphicsItem *parent = 0);
|
||||
RobotPart(QGraphicsItem *parent = nullptr);
|
||||
|
||||
protected:
|
||||
void dragEnterEvent(QGraphicsSceneDragDropEvent *event) override;
|
||||
void dragLeaveEvent(QGraphicsSceneDragDropEvent *event) override;
|
||||
void dropEvent(QGraphicsSceneDragDropEvent *event) override;
|
||||
|
||||
QColor color;
|
||||
bool dragOver;
|
||||
QColor color = Qt::lightGray;
|
||||
bool dragOver = false;
|
||||
};
|
||||
//! [0]
|
||||
|
||||
|
|
@ -78,10 +78,10 @@ protected:
|
|||
class RobotHead : public RobotPart
|
||||
{
|
||||
public:
|
||||
RobotHead(QGraphicsItem *parent = 0);
|
||||
RobotHead(QGraphicsItem *parent = nullptr);
|
||||
|
||||
QRectF boundingRect() const override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override;
|
||||
|
||||
protected:
|
||||
void dragEnterEvent(QGraphicsSceneDragDropEvent *event) override;
|
||||
|
|
@ -96,10 +96,10 @@ private:
|
|||
class RobotTorso : public RobotPart
|
||||
{
|
||||
public:
|
||||
RobotTorso(QGraphicsItem *parent = 0);
|
||||
using RobotPart::RobotPart;
|
||||
|
||||
QRectF boundingRect() const override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override;
|
||||
};
|
||||
//! [2]
|
||||
|
||||
|
|
@ -107,10 +107,10 @@ public:
|
|||
class RobotLimb : public RobotPart
|
||||
{
|
||||
public:
|
||||
RobotLimb(QGraphicsItem *parent = 0);
|
||||
RobotLimb(QGraphicsItem *parent = nullptr);
|
||||
|
||||
QRectF boundingRect() const override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override;
|
||||
};
|
||||
//! [3]
|
||||
|
||||
|
|
@ -118,10 +118,10 @@ public:
|
|||
class Robot : public RobotPart
|
||||
{
|
||||
public:
|
||||
Robot(QGraphicsItem *parent = 0);
|
||||
Robot(QGraphicsItem *parent = nullptr);
|
||||
|
||||
QRectF boundingRect() const override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override;
|
||||
};
|
||||
//! [4]
|
||||
|
||||
|
|
|
|||
|
|
@ -51,16 +51,14 @@
|
|||
#include "edge.h"
|
||||
#include "node.h"
|
||||
|
||||
#include <qmath.h>
|
||||
#include <QPainter>
|
||||
#include <QtMath>
|
||||
|
||||
//! [0]
|
||||
Edge::Edge(Node *sourceNode, Node *destNode)
|
||||
: arrowSize(10)
|
||||
: source(sourceNode), dest(destNode)
|
||||
{
|
||||
setAcceptedMouseButtons(0);
|
||||
source = sourceNode;
|
||||
dest = destNode;
|
||||
setAcceptedMouseButtons(Qt::NoButton);
|
||||
source->addEdge(this);
|
||||
dest->addEdge(this);
|
||||
adjust();
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ private:
|
|||
|
||||
QPointF sourcePoint;
|
||||
QPointF destPoint;
|
||||
qreal arrowSize;
|
||||
qreal arrowSize = 10;
|
||||
};
|
||||
//! [0]
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@
|
|||
|
||||
//! [0]
|
||||
GraphWidget::GraphWidget(QWidget *parent)
|
||||
: QGraphicsView(parent), timerId(0)
|
||||
: QGraphicsView(parent)
|
||||
{
|
||||
QGraphicsScene *scene = new QGraphicsScene(this);
|
||||
scene->setItemIndexMethod(QGraphicsScene::NoIndex);
|
||||
|
|
@ -163,7 +163,7 @@ void GraphWidget::timerEvent(QTimerEvent *event)
|
|||
{
|
||||
Q_UNUSED(event);
|
||||
|
||||
QList<Node *> nodes;
|
||||
QVector<Node *> nodes;
|
||||
const QList<QGraphicsItem *> items = scene()->items();
|
||||
for (QGraphicsItem *item : items) {
|
||||
if (Node *node = qgraphicsitem_cast<Node *>(item))
|
||||
|
|
@ -190,7 +190,7 @@ void GraphWidget::timerEvent(QTimerEvent *event)
|
|||
//! [5]
|
||||
void GraphWidget::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
scaleView(pow((double)2, -event->angleDelta().y() / 240.0));
|
||||
scaleView(pow(2., -event->angleDelta().y() / 240.0));
|
||||
}
|
||||
//! [5]
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class GraphWidget : public QGraphicsView
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GraphWidget(QWidget *parent = 0);
|
||||
GraphWidget(QWidget *parent = nullptr);
|
||||
|
||||
void itemMoved();
|
||||
|
||||
|
|
@ -81,7 +81,7 @@ protected:
|
|||
void scaleView(qreal scaleFactor);
|
||||
|
||||
private:
|
||||
int timerId;
|
||||
int timerId = 0;
|
||||
Node *centerNode;
|
||||
};
|
||||
//! [0]
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ void Node::addEdge(Edge *edge)
|
|||
edge->adjust();
|
||||
}
|
||||
|
||||
QList<Edge *> Node::edges() const
|
||||
QVector<Edge *> Node::edges() const
|
||||
{
|
||||
return edgeList;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,13 +52,10 @@
|
|||
#define NODE_H
|
||||
|
||||
#include <QGraphicsItem>
|
||||
#include <QList>
|
||||
#include <QVector>
|
||||
|
||||
class Edge;
|
||||
class GraphWidget;
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QGraphicsSceneMouseEvent;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
//! [0]
|
||||
class Node : public QGraphicsItem
|
||||
|
|
@ -67,7 +64,7 @@ public:
|
|||
Node(GraphWidget *graphWidget);
|
||||
|
||||
void addEdge(Edge *edge);
|
||||
QList<Edge *> edges() const;
|
||||
QVector<Edge *> edges() const;
|
||||
|
||||
enum { Type = UserType + 1 };
|
||||
int type() const override { return Type; }
|
||||
|
|
@ -86,7 +83,7 @@ protected:
|
|||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
|
||||
private:
|
||||
QList<Edge *> edgeList;
|
||||
QVector<Edge *> edgeList;
|
||||
QPointF newPos;
|
||||
GraphWidget *graph;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -50,14 +50,13 @@
|
|||
|
||||
#include "customproxy.h"
|
||||
|
||||
#include <QStyleOptionGraphicsItem>
|
||||
#include <QPainter>
|
||||
#include <QGraphicsScene>
|
||||
#include <QPainter>
|
||||
#include <QStyleOptionGraphicsItem>
|
||||
|
||||
CustomProxy::CustomProxy(QGraphicsItem *parent, Qt::WindowFlags wFlags)
|
||||
: QGraphicsProxyWidget(parent, wFlags), popupShown(false), currentPopup(nullptr)
|
||||
: QGraphicsProxyWidget(parent, wFlags), timeLine(new QTimeLine(250, this))
|
||||
{
|
||||
timeLine = new QTimeLine(250, this);
|
||||
connect(timeLine, &QTimeLine::valueChanged,
|
||||
this, &CustomProxy::updateStep);
|
||||
connect(timeLine, &QTimeLine::stateChanged,
|
||||
|
|
@ -99,7 +98,7 @@ void CustomProxy::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
|||
{
|
||||
QGraphicsProxyWidget::hoverEnterEvent(event);
|
||||
scene()->setActiveWindow(this);
|
||||
if (timeLine->currentValue() != 1)
|
||||
if (qFuzzyCompare(timeLine->currentValue(), 1))
|
||||
zoomIn();
|
||||
}
|
||||
|
||||
|
|
@ -107,7 +106,7 @@ void CustomProxy::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||
{
|
||||
QGraphicsProxyWidget::hoverLeaveEvent(event);
|
||||
if (!popupShown
|
||||
&& (timeLine->direction() != QTimeLine::Backward || timeLine->currentValue() != 0)) {
|
||||
&& (timeLine->direction() != QTimeLine::Backward || qFuzzyIsNull(timeLine->currentValue()))) {
|
||||
zoomOut();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class CustomProxy : public QGraphicsProxyWidget
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CustomProxy(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
|
||||
explicit CustomProxy(QGraphicsItem *parent = nullptr, Qt::WindowFlags wFlags = nullptr);
|
||||
|
||||
QRectF boundingRect() const override;
|
||||
void paintWindowFrame(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
|
|
@ -79,8 +79,8 @@ private slots:
|
|||
|
||||
private:
|
||||
QTimeLine *timeLine;
|
||||
bool popupShown;
|
||||
QGraphicsItem *currentPopup;
|
||||
QGraphicsItem *currentPopup = nullptr;
|
||||
bool popupShown = false;
|
||||
};
|
||||
|
||||
#endif // CUSTOMPROXY_H
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class EmbeddedDialog : public QDialog
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
EmbeddedDialog(QWidget *parent = 0);
|
||||
EmbeddedDialog(QWidget *parent = nullptr);
|
||||
~EmbeddedDialog();
|
||||
|
||||
private slots:
|
||||
|
|
|
|||
|
|
@ -50,14 +50,10 @@
|
|||
|
||||
#include "flowlayout.h"
|
||||
|
||||
#include <qmath.h>
|
||||
#include <QtMath>
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
FlowLayout::FlowLayout()
|
||||
FlowLayout::FlowLayout(QGraphicsLayoutItem *parent) : QGraphicsLayout(parent)
|
||||
{
|
||||
m_spacing[0] = 6;
|
||||
m_spacing[1] = 6;
|
||||
QSizePolicy sp = sizePolicy();
|
||||
sp.setHeightForWidth(true);
|
||||
setSizePolicy(sp);
|
||||
|
|
@ -66,7 +62,7 @@ FlowLayout::FlowLayout()
|
|||
void FlowLayout::insertItem(int index, QGraphicsLayoutItem *item)
|
||||
{
|
||||
item->setParentLayoutItem(this);
|
||||
if (uint(index) > uint(m_items.count()))
|
||||
if (index > m_items.count())
|
||||
index = m_items.count();
|
||||
m_items.insert(index, item);
|
||||
invalidate();
|
||||
|
|
@ -117,15 +113,14 @@ qreal FlowLayout::doLayout(const QRectF &geom, bool applyNewGeometry) const
|
|||
qreal y = 0;
|
||||
qreal maxRowHeight = 0;
|
||||
QSizeF pref;
|
||||
for (int i = 0; i < m_items.count(); ++i) {
|
||||
QGraphicsLayoutItem *item = m_items.at(i);
|
||||
for (QGraphicsLayoutItem *item : m_items) {
|
||||
pref = item->effectiveSizeHint(Qt::PreferredSize);
|
||||
maxRowHeight = qMax(maxRowHeight, pref.height());
|
||||
|
||||
qreal next_x;
|
||||
next_x = x + pref.width();
|
||||
if (next_x > maxw) {
|
||||
if (x == 0) {
|
||||
if (qFuzzyIsNull(x)) {
|
||||
pref.setWidth(maxw);
|
||||
} else {
|
||||
x = 0;
|
||||
|
|
@ -156,7 +151,7 @@ QSizeF FlowLayout::minSize(const QSizeF &constraint) const
|
|||
} else {
|
||||
for (const QGraphicsLayoutItem *item : qAsConst(m_items))
|
||||
size = size.expandedTo(item->effectiveSizeHint(Qt::MinimumSize));
|
||||
size += QSize(left + right, top + bottom);
|
||||
size += QSizeF(left + right, top + bottom);
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
|
@ -164,7 +159,7 @@ QSizeF FlowLayout::minSize(const QSizeF &constraint) const
|
|||
QSizeF FlowLayout::prefSize() const
|
||||
{
|
||||
qreal left, right;
|
||||
getContentsMargins(&left, 0, &right, 0);
|
||||
getContentsMargins(&left, nullptr, &right, nullptr);
|
||||
|
||||
qreal maxh = 0;
|
||||
qreal totalWidth = 0;
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@
|
|||
class FlowLayout : public QGraphicsLayout
|
||||
{
|
||||
public:
|
||||
FlowLayout();
|
||||
FlowLayout(QGraphicsLayoutItem *parent = nullptr);
|
||||
inline void addItem(QGraphicsLayoutItem *item);
|
||||
void insertItem(int index, QGraphicsLayoutItem *item);
|
||||
void setSpacing(Qt::Orientations o, qreal spacing);
|
||||
|
|
@ -75,8 +75,8 @@ private:
|
|||
QSizeF prefSize() const;
|
||||
QSizeF maxSize() const;
|
||||
|
||||
QList<QGraphicsLayoutItem*> m_items;
|
||||
qreal m_spacing[2];
|
||||
QVector<QGraphicsLayoutItem*> m_items;
|
||||
qreal m_spacing[2] = {6, 6};
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -59,12 +59,12 @@ int main(int argc, char *argv[])
|
|||
QApplication app(argc, argv);
|
||||
|
||||
QGraphicsScene scene;
|
||||
QGraphicsView *view = new QGraphicsView(&scene);
|
||||
QGraphicsView view(&scene);
|
||||
Window *w = new Window;
|
||||
scene.addItem(w);
|
||||
|
||||
view->resize(400, 300);
|
||||
view->show();
|
||||
view.resize(400, 300);
|
||||
view.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,23 +48,21 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "flowlayout.h"
|
||||
#include "window.h"
|
||||
#include "flowlayout.h"
|
||||
|
||||
#include <QGraphicsProxyWidget>
|
||||
#include <QLabel>
|
||||
|
||||
Window::Window()
|
||||
: QGraphicsWidget(0, Qt::Window)
|
||||
Window::Window(QGraphicsItem *parent) : QGraphicsWidget(parent, Qt::Window)
|
||||
{
|
||||
FlowLayout *lay = new FlowLayout;
|
||||
QLatin1String wiseWords("I am not bothered by the fact that I am unknown."
|
||||
" I am bothered when I do not know others. (Confucius)");
|
||||
QString sentence(wiseWords);
|
||||
QStringList words = sentence.split(QLatin1Char(' '), QString::SkipEmptyParts);
|
||||
for (int i = 0; i < words.count(); ++i) {
|
||||
const QString sentence(QLatin1String("I am not bothered by the fact that I am unknown."
|
||||
" I am bothered when I do not know others. (Confucius)"));
|
||||
const QVector<QStringRef> words = sentence.splitRef(QLatin1Char(' '), QString::SkipEmptyParts);
|
||||
for (const QStringRef &word : words) {
|
||||
QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(this);
|
||||
QLabel *label = new QLabel(words.at(i));
|
||||
QLabel *label = new QLabel(word.toString());
|
||||
label->setFrameStyle(QFrame::Box | QFrame::Plain);
|
||||
proxy->setWidget(label);
|
||||
lay->addItem(proxy);
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@
|
|||
class Window : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Window();
|
||||
Window(QGraphicsItem *parent = nullptr);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -75,8 +75,8 @@ FlippablePad::FlippablePad(const QSize &size, QGraphicsItem *parent)
|
|||
//! [2]
|
||||
//! [3]
|
||||
int numIcons = size.width() * size.height();
|
||||
QList<QPixmap> pixmaps;
|
||||
QDirIterator it(":/images", QStringList() << "*.png");
|
||||
QVector<QPixmap> pixmaps;
|
||||
QDirIterator it(":/images", {"*.png"});
|
||||
while (it.hasNext() && pixmaps.size() < numIcons)
|
||||
pixmaps << it.next();
|
||||
//! [3]
|
||||
|
|
|
|||
|
|
@ -53,15 +53,13 @@
|
|||
|
||||
#include "roundrectitem.h"
|
||||
|
||||
#include <QGraphicsObject>
|
||||
#include <QLinearGradient>
|
||||
#include <QVector>
|
||||
|
||||
//! [0]
|
||||
class FlippablePad : public RoundRectItem
|
||||
{
|
||||
public:
|
||||
explicit FlippablePad(const QSize &size, QGraphicsItem *parent = 0);
|
||||
explicit FlippablePad(const QSize &size, QGraphicsItem *parent = nullptr);
|
||||
|
||||
RoundRectItem *iconAt(int column, int row) const;
|
||||
|
||||
|
|
|
|||
|
|
@ -52,10 +52,18 @@
|
|||
#include "padnavigator.h"
|
||||
#include "splashitem.h"
|
||||
|
||||
#include <QEventTransition>
|
||||
#include <QGraphicsProxyWidget>
|
||||
#include <QGraphicsRotation>
|
||||
#include <QHistoryState>
|
||||
#include <QKeyEventTransition>
|
||||
#include <QParallelAnimationGroup>
|
||||
#include <QPropertyAnimation>
|
||||
#include <QSequentialAnimationGroup>
|
||||
#include <QStateMachine>
|
||||
|
||||
#ifndef QT_NO_OPENGL
|
||||
#include <QtOpenGL>
|
||||
#else
|
||||
#include <QtWidgets>
|
||||
#include <QOpenGLWidget>
|
||||
#endif
|
||||
|
||||
//! [0]
|
||||
|
|
|
|||
|
|
@ -54,17 +54,12 @@
|
|||
#include <QGraphicsView>
|
||||
#include "ui_form.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QState;
|
||||
class QStateMachine;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
//! [0]
|
||||
class PadNavigator : public QGraphicsView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PadNavigator(const QSize &size, QWidget *parent = 0);
|
||||
explicit PadNavigator(const QSize &size, QWidget *parent = nullptr);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@
|
|||
|
||||
#include "roundrectitem.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QGuiApplication>
|
||||
#include <QPainter>
|
||||
#include <QPalette>
|
||||
|
||||
|
|
@ -98,7 +98,7 @@ void RoundRectItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
|
|||
//! [3]
|
||||
//! [4]
|
||||
if (fillRect)
|
||||
painter->setBrush(QApplication::palette().brush(QPalette::Window));
|
||||
painter->setBrush(QGuiApplication::palette().brush(QPalette::Window));
|
||||
else
|
||||
painter->setBrush(gradient);
|
||||
painter->setPen(QPen(Qt::black, 1));
|
||||
|
|
|
|||
|
|
@ -61,13 +61,13 @@ class RoundRectItem : public QGraphicsObject
|
|||
Q_PROPERTY(bool fill READ fill WRITE setFill)
|
||||
public:
|
||||
RoundRectItem(const QRectF &bounds, const QColor &color,
|
||||
QGraphicsItem *parent = 0);
|
||||
QGraphicsItem *parent = nullptr);
|
||||
|
||||
QPixmap pixmap() const;
|
||||
void setPixmap(const QPixmap &pixmap);
|
||||
|
||||
QRectF boundingRect() const override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override;
|
||||
|
||||
bool fill() const;
|
||||
void setFill(bool fill);
|
||||
|
|
|
|||
|
|
@ -58,10 +58,10 @@ class SplashItem : public QGraphicsObject
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SplashItem(QGraphicsItem *parent = 0);
|
||||
explicit SplashItem(QGraphicsItem *parent = nullptr);
|
||||
|
||||
QRectF boundingRect() const override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override;
|
||||
|
||||
private:
|
||||
QString text;
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class Widget : public QGraphicsWidget
|
|||
{
|
||||
public:
|
||||
Widget(const QColor &color, const QColor &textColor, const QString &caption,
|
||||
QGraphicsItem *parent = 0)
|
||||
QGraphicsItem *parent = nullptr)
|
||||
: QGraphicsWidget(parent)
|
||||
, caption(caption)
|
||||
, color(color)
|
||||
|
|
@ -62,7 +62,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget * = 0) override
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override
|
||||
{
|
||||
QFont font;
|
||||
font.setPixelSize(0.75 * qMin(boundingRect().width(), boundingRect().height()));
|
||||
|
|
@ -85,7 +85,7 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
QGraphicsScene *scene = new QGraphicsScene();
|
||||
QGraphicsScene scene;
|
||||
|
||||
Widget *a = new Widget(Qt::blue, Qt::white, "a");
|
||||
a->setPreferredSize(100, 100);
|
||||
|
|
@ -94,7 +94,7 @@ int main(int argc, char *argv[])
|
|||
Widget *c = new Widget(Qt::red, Qt::black, "c");
|
||||
c->setPreferredSize(100, 100);
|
||||
|
||||
QGraphicsAnchorLayout *layout = new QGraphicsAnchorLayout();
|
||||
QGraphicsAnchorLayout *layout = new QGraphicsAnchorLayout;
|
||||
/*
|
||||
//! [adding a corner anchor in two steps]
|
||||
layout->addAnchor(a, Qt::AnchorTop, layout, Qt::AnchorTop);
|
||||
|
|
@ -128,20 +128,20 @@ int main(int argc, char *argv[])
|
|||
// corner of the layout.
|
||||
layout->addCornerAnchors(c, Qt::BottomRightCorner, layout, Qt::BottomRightCorner);
|
||||
|
||||
QGraphicsWidget *w = new QGraphicsWidget(0, Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint);
|
||||
auto w = new QGraphicsWidget(nullptr, Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint);
|
||||
w->setPos(20, 20);
|
||||
w->setMinimumSize(100, 100);
|
||||
w->setPreferredSize(320, 240);
|
||||
w->setLayout(layout);
|
||||
w->setWindowTitle(QApplication::translate("simpleanchorlayout", "QGraphicsAnchorLayout in use"));
|
||||
scene->addItem(w);
|
||||
scene.addItem(w);
|
||||
|
||||
QGraphicsView *view = new QGraphicsView();
|
||||
view->setScene(scene);
|
||||
view->setWindowTitle(QApplication::translate("simpleanchorlayout", "Simple Anchor Layout"));
|
||||
QGraphicsView view;
|
||||
view.setScene(&scene);
|
||||
view.setWindowTitle(QApplication::translate("simpleanchorlayout", "Simple Anchor Layout"));
|
||||
|
||||
view->resize(360, 320);
|
||||
view->show();
|
||||
view.resize(360, 320);
|
||||
view.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,15 +50,14 @@
|
|||
|
||||
#include <QApplication>
|
||||
#include <QLabel>
|
||||
#include <QPainter>
|
||||
#include <QPushButton>
|
||||
|
||||
#include <QGraphicsAnchorLayout>
|
||||
#include <QGraphicsProxyWidget>
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsSceneResizeEvent>
|
||||
#include <QGraphicsView>
|
||||
#include <QGraphicsWidget>
|
||||
#include <QPainter>
|
||||
#include <QPushButton>
|
||||
|
||||
|
||||
class GraphicsView : public QGraphicsView
|
||||
|
|
@ -79,20 +78,18 @@ public:
|
|||
|
||||
class PixmapWidget : public QGraphicsLayoutItem
|
||||
{
|
||||
|
||||
public:
|
||||
PixmapWidget(const QPixmap &pix)
|
||||
: QGraphicsLayoutItem()
|
||||
: QGraphicsLayoutItem(), original(new QGraphicsPixmapItem(pix))
|
||||
, r(QRectF(QPointF(0, 0), pix.size()))
|
||||
{
|
||||
original = new QGraphicsPixmapItem(pix);
|
||||
setGraphicsItem(original);
|
||||
original->show();
|
||||
r = QRectF(QPointF(0, 0), pix.size());
|
||||
}
|
||||
|
||||
~PixmapWidget()
|
||||
{
|
||||
setGraphicsItem(0);
|
||||
setGraphicsItem(nullptr);
|
||||
delete original;
|
||||
}
|
||||
|
||||
|
|
@ -101,7 +98,7 @@ public:
|
|||
original->setZValue(z);
|
||||
}
|
||||
|
||||
void setGeometry (const QRectF &rect) override
|
||||
void setGeometry(const QRectF &rect) override
|
||||
{
|
||||
original->setTransform(QTransform::fromScale(rect.width() / r.width(),
|
||||
rect.height() / r.height()), true);
|
||||
|
|
@ -150,8 +147,7 @@ public:
|
|||
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) override
|
||||
{
|
||||
QPointF reflection = QPointF();
|
||||
reflection.setY(scaled.height() + 2);
|
||||
const QPointF reflection(0, scaled.height() + 2);
|
||||
|
||||
painter->drawPixmap(QPointF(), scaled);
|
||||
|
||||
|
|
@ -239,7 +235,7 @@ int main(int argc, char *argv[])
|
|||
layout->setSpacing(0);
|
||||
|
||||
// setup the main widget
|
||||
QGraphicsWidget *widget = new QGraphicsWidget(0, Qt::Window);
|
||||
QGraphicsWidget *widget = new QGraphicsWidget(nullptr, Qt::Window);
|
||||
QPalette p;
|
||||
p.setColor(QPalette::Window, Qt::black);
|
||||
widget->setPalette(p);
|
||||
|
|
|
|||
|
|
@ -42,6 +42,9 @@ CMAKE_INCLUDE_NAME = $$eval(QT.$${MODULE}.name)
|
|||
# (or QtCore_{libinfix_suffix}, Foo_{libinfix_suffix} on macos with -framework).
|
||||
CMAKE_QT_STEM = $${TARGET}
|
||||
|
||||
# ANDROID_ABI is set by the android toolchain file, see https://developer.android.com/ndk/guides/cmake
|
||||
android: CMAKE_QT_STEM = $$replace(CMAKE_QT_STEM, "_$${QT_ARCH}", '_\$\{ANDROID_ABI\}')
|
||||
|
||||
# On macOS when building just a debug configuration which is not part of debug_and_release,
|
||||
# $${TARGET} already contains a _debug suffix, as per the following call chain:
|
||||
# qt_module.prf -> qt5LibraryTarget -> qtLibraryTarget -> qtPlatformTargetSuffix.
|
||||
|
|
|
|||
|
|
@ -658,4 +658,9 @@ QString qmake_libraryInfoFile()
|
|||
return QString();
|
||||
}
|
||||
|
||||
QString qmake_abslocation()
|
||||
{
|
||||
return Option::globals->qmake_abslocation;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -158,21 +158,6 @@
|
|||
"-latomic"
|
||||
]
|
||||
},
|
||||
"libdl": {
|
||||
"label": "dlopen()",
|
||||
"test": {
|
||||
"main": [
|
||||
"dlclose(dlopen(0, 0));",
|
||||
"dlsym(RTLD_DEFAULT, 0);",
|
||||
"dlerror();"
|
||||
]
|
||||
},
|
||||
"headers": "dlfcn.h",
|
||||
"sources": [
|
||||
"",
|
||||
"-ldl"
|
||||
]
|
||||
},
|
||||
"librt": {
|
||||
"label": "clock_gettime()",
|
||||
"test": {
|
||||
|
|
@ -612,11 +597,6 @@
|
|||
"condition": "features.clock-gettime && tests.clock-monotonic",
|
||||
"output": [ "feature" ]
|
||||
},
|
||||
"dlopen": {
|
||||
"label": "dlopen()",
|
||||
"condition": "config.unix && libs.libdl",
|
||||
"output": [ "privateFeature" ]
|
||||
},
|
||||
"doubleconversion": {
|
||||
"label": "DoubleConversion",
|
||||
"output": [ "privateFeature", "feature" ]
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ CONFIG += simd optimize_full
|
|||
QMAKE_DOCS = $$PWD/doc/qtcore.qdocconf
|
||||
|
||||
ANDROID_LIB_DEPENDENCIES = \
|
||||
plugins/platforms/android/libqtforandroid.so
|
||||
plugins/platforms/libqtforandroid.so
|
||||
ANDROID_BUNDLED_JAR_DEPENDENCIES = \
|
||||
jar/QtAndroid.jar
|
||||
ANDROID_PERMISSIONS = \
|
||||
|
|
|
|||
|
|
@ -55,16 +55,25 @@ QT_END_NAMESPACE
|
|||
# include "qcoreapplication.h"
|
||||
#endif
|
||||
|
||||
#ifndef QT_BUILD_QMAKE_BOOTSTRAP
|
||||
# include "private/qglobal_p.h"
|
||||
# include "qconfig.cpp"
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_DARWIN
|
||||
# include "private/qcore_mac_p.h"
|
||||
#endif
|
||||
|
||||
#ifndef QT_BUILD_QMAKE_BOOTSTRAP
|
||||
# include "qconfig.cpp"
|
||||
#endif
|
||||
#endif // Q_OS_DARWIN
|
||||
|
||||
#include "archdetect.cpp"
|
||||
|
||||
#if !defined(QT_BUILD_QMAKE) && QT_CONFIG(relocatable) && QT_CONFIG(dlopen) && !QT_CONFIG(framework)
|
||||
# include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#if !defined(QT_BUILD_QMAKE) && QT_CONFIG(relocatable) && defined(Q_OS_WIN)
|
||||
# include <qt_windows.h>
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
extern void qDumpCPUFeatures(); // in qsimd.cpp
|
||||
|
|
@ -453,6 +462,160 @@ void QLibraryInfo::sysrootify(QString *path)
|
|||
}
|
||||
#endif // QT_BUILD_QMAKE
|
||||
|
||||
#ifndef QT_BUILD_QMAKE
|
||||
static QString prefixFromAppDirHelper()
|
||||
{
|
||||
QString appDir;
|
||||
|
||||
if (QCoreApplication::instance()) {
|
||||
#ifdef Q_OS_DARWIN
|
||||
CFBundleRef bundleRef = CFBundleGetMainBundle();
|
||||
if (bundleRef) {
|
||||
QCFType<CFURLRef> urlRef = CFBundleCopyBundleURL(bundleRef);
|
||||
if (urlRef) {
|
||||
QCFString path = CFURLCopyFileSystemPath(urlRef, kCFURLPOSIXPathStyle);
|
||||
#ifdef Q_OS_MACOS
|
||||
QString bundleContentsDir = QString(path) + QLatin1String("/Contents/");
|
||||
if (QDir(bundleContentsDir).exists())
|
||||
return QDir::cleanPath(bundleContentsDir);
|
||||
#else
|
||||
return QDir::cleanPath(QString(path)); // iOS
|
||||
#endif // Q_OS_MACOS
|
||||
}
|
||||
}
|
||||
#endif // Q_OS_DARWIN
|
||||
// We make the prefix path absolute to the executable's directory.
|
||||
appDir = QCoreApplication::applicationDirPath();
|
||||
} else {
|
||||
appDir = QDir::currentPath();
|
||||
}
|
||||
|
||||
return appDir;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(QT_BUILD_QMAKE) && QT_CONFIG(relocatable)
|
||||
static QString prefixFromQtCoreLibraryHelper(const QString &qtCoreLibraryPath)
|
||||
{
|
||||
const QString qtCoreLibrary = QDir::fromNativeSeparators(qtCoreLibraryPath);
|
||||
const QString libDir = QFileInfo(qtCoreLibrary).absolutePath();
|
||||
const QString prefixDir = libDir + QLatin1Char('/')
|
||||
+ QLatin1String(QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH);
|
||||
return QDir::cleanPath(prefixDir);
|
||||
}
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
#if defined(Q_OS_WINRT)
|
||||
EXTERN_C IMAGE_DOS_HEADER __ImageBase;
|
||||
static HMODULE getWindowsModuleHandle()
|
||||
{
|
||||
return reinterpret_cast<HMODULE>(&__ImageBase);
|
||||
}
|
||||
#else // Q_OS_WINRT
|
||||
static HMODULE getWindowsModuleHandle()
|
||||
{
|
||||
HMODULE hModule = NULL;
|
||||
GetModuleHandleEx(
|
||||
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
|
||||
(LPCTSTR)&QLibraryInfo::isDebugBuild, &hModule);
|
||||
return hModule;
|
||||
}
|
||||
#endif // !Q_OS_WINRT
|
||||
#endif // Q_OS_WIN
|
||||
|
||||
static QString getRelocatablePrefix()
|
||||
{
|
||||
QString prefixPath;
|
||||
|
||||
// For static builds, the prefix will be the app directory.
|
||||
// For regular builds, the prefix will be relative to the location of the QtCore shared library.
|
||||
#if defined(QT_STATIC)
|
||||
prefixPath = prefixFromAppDirHelper();
|
||||
#elif defined(Q_OS_DARWIN) && QT_CONFIG(framework)
|
||||
CFBundleRef qtCoreBundle = CFBundleGetBundleWithIdentifier(
|
||||
CFSTR("org.qt-project.QtCore"));
|
||||
Q_ASSERT(qtCoreBundle);
|
||||
|
||||
QCFType<CFURLRef> qtCorePath = CFBundleCopyBundleURL(qtCoreBundle);
|
||||
Q_ASSERT(qtCorePath);
|
||||
|
||||
QCFType<CFURLRef> qtCorePathAbsolute = CFURLCopyAbsoluteURL(qtCorePath);
|
||||
Q_ASSERT(qtCorePathAbsolute);
|
||||
|
||||
QCFType<CFURLRef> libDirCFPath = CFURLCreateCopyDeletingLastPathComponent(NULL, qtCorePathAbsolute);
|
||||
|
||||
const QCFString libDirCFString = CFURLCopyFileSystemPath(libDirCFPath, kCFURLPOSIXPathStyle);
|
||||
|
||||
const QString prefixDir = QString(libDirCFString) + QLatin1Char('/')
|
||||
+ QLatin1String(QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH);
|
||||
|
||||
prefixPath = QDir::cleanPath(prefixDir);
|
||||
#elif QT_CONFIG(dlopen)
|
||||
Dl_info info;
|
||||
int result = dladdr(reinterpret_cast<void *>(&QLibraryInfo::isDebugBuild), &info);
|
||||
if (result > 0 && info.dli_fname)
|
||||
prefixPath = prefixFromQtCoreLibraryHelper(QString::fromLatin1(info.dli_fname));
|
||||
#elif defined(Q_OS_WIN)
|
||||
HMODULE hModule = getWindowsModuleHandle();
|
||||
const int kBufferSize = 4096;
|
||||
wchar_t buffer[kBufferSize];
|
||||
const int pathSize = GetModuleFileName(hModule, buffer, kBufferSize);
|
||||
if (pathSize > 0)
|
||||
prefixPath = prefixFromQtCoreLibraryHelper(QString::fromWCharArray(buffer, pathSize));
|
||||
#else
|
||||
#error "The chosen platform / config does not support querying for a dynamic prefix."
|
||||
#endif
|
||||
|
||||
Q_ASSERT_X(!prefixPath.isEmpty(), "getRelocatablePrefix",
|
||||
"Failed to find the Qt prefix path.");
|
||||
return prefixPath;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(QT_BUILD_QMAKE) && !defined(QT_BUILD_QMAKE_BOOTSTRAP)
|
||||
QString qmake_abslocation();
|
||||
|
||||
static QString getPrefixFromHostBinDir(const char *hostBinDirToPrefixPath)
|
||||
{
|
||||
const QFileInfo qmfi = QFileInfo(qmake_abslocation()).canonicalFilePath();
|
||||
return QDir::cleanPath(qmfi.absolutePath() + QLatin1Char('/')
|
||||
+ QLatin1String(hostBinDirToPrefixPath));
|
||||
}
|
||||
|
||||
static QString getExtPrefixFromHostBinDir()
|
||||
{
|
||||
return getPrefixFromHostBinDir(QT_CONFIGURE_HOSTBINDIR_TO_EXTPREFIX_PATH);
|
||||
}
|
||||
|
||||
static QString getHostPrefixFromHostBinDir()
|
||||
{
|
||||
return getPrefixFromHostBinDir(QT_CONFIGURE_HOSTBINDIR_TO_HOSTPREFIX_PATH);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef QT_BUILD_QMAKE_BOOTSTRAP
|
||||
static const char *getPrefix(
|
||||
#ifdef QT_BUILD_QMAKE
|
||||
QLibraryInfo::PathGroup group
|
||||
#endif
|
||||
)
|
||||
{
|
||||
#if defined(QT_BUILD_QMAKE)
|
||||
# if QT_CONFIGURE_CROSSBUILD
|
||||
if (group == QLibraryInfo::DevicePaths)
|
||||
return QT_CONFIGURE_PREFIX_PATH;
|
||||
# endif
|
||||
static QByteArray extPrefixPath = getExtPrefixFromHostBinDir().toLatin1();
|
||||
return extPrefixPath.constData();
|
||||
#elif QT_CONFIG(relocatable)
|
||||
static QByteArray prefixPath = getRelocatablePrefix().toLatin1();
|
||||
return prefixPath.constData();
|
||||
#else
|
||||
return QT_CONFIGURE_PREFIX_PATH;
|
||||
#endif
|
||||
}
|
||||
#endif // QT_BUILD_QMAKE_BOOTSTRAP
|
||||
|
||||
/*!
|
||||
Returns the location specified by \a loc.
|
||||
*/
|
||||
|
|
@ -564,12 +727,11 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group)
|
|||
if (!fromConf) {
|
||||
const char * volatile path = 0;
|
||||
if (loc == PrefixPath) {
|
||||
path =
|
||||
# ifdef QT_BUILD_QMAKE
|
||||
(group != DevicePaths) ?
|
||||
QT_CONFIGURE_EXT_PREFIX_PATH :
|
||||
# endif
|
||||
QT_CONFIGURE_PREFIX_PATH;
|
||||
path = getPrefix(
|
||||
#ifdef QT_BUILD_QMAKE
|
||||
group
|
||||
#endif
|
||||
);
|
||||
} else if (unsigned(loc) <= sizeof(qt_configure_str_offsets)/sizeof(qt_configure_str_offsets[0])) {
|
||||
path = qt_configure_strs + qt_configure_str_offsets[loc - 1];
|
||||
#ifndef Q_OS_WIN // On Windows we use the registry
|
||||
|
|
@ -578,7 +740,8 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group)
|
|||
#endif
|
||||
# ifdef QT_BUILD_QMAKE
|
||||
} else if (loc == HostPrefixPath) {
|
||||
path = QT_CONFIGURE_HOST_PREFIX_PATH;
|
||||
static const QByteArray hostPrefixPath = getHostPrefixFromHostBinDir().toLatin1();
|
||||
path = hostPrefixPath.constData();
|
||||
# endif
|
||||
}
|
||||
|
||||
|
|
@ -612,28 +775,7 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group)
|
|||
}
|
||||
#else
|
||||
if (loc == PrefixPath) {
|
||||
if (QCoreApplication::instance()) {
|
||||
#ifdef Q_OS_DARWIN
|
||||
CFBundleRef bundleRef = CFBundleGetMainBundle();
|
||||
if (bundleRef) {
|
||||
QCFType<CFURLRef> urlRef = CFBundleCopyBundleURL(bundleRef);
|
||||
if (urlRef) {
|
||||
QCFString path = CFURLCopyFileSystemPath(urlRef, kCFURLPOSIXPathStyle);
|
||||
#ifdef Q_OS_OSX
|
||||
QString bundleContentsDir = QString(path) + QLatin1String("/Contents/");
|
||||
if (QDir(bundleContentsDir).exists())
|
||||
return QDir::cleanPath(bundleContentsDir + ret);
|
||||
#else
|
||||
return QDir::cleanPath(QString(path) + QLatin1Char('/') + ret); // iOS
|
||||
#endif // Q_OS_OSX
|
||||
}
|
||||
}
|
||||
#endif // Q_OS_DARWIN
|
||||
// We make the prefix path absolute to the executable's directory.
|
||||
baseDir = QCoreApplication::applicationDirPath();
|
||||
} else {
|
||||
baseDir = QDir::currentPath();
|
||||
}
|
||||
baseDir = prefixFromAppDirHelper();
|
||||
} else {
|
||||
// we make any other path absolute to the prefix directory
|
||||
baseDir = location(PrefixPath);
|
||||
|
|
|
|||
|
|
@ -355,14 +355,6 @@ bool QOperatingSystemVersion::isAnyOfType(std::initializer_list<OSType> types) c
|
|||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
\variable QOperatingSystemVersion::WindowsVista
|
||||
\brief a version corresponding to Windows Vista (version 6.0).
|
||||
\since 6.0
|
||||
*/
|
||||
const QOperatingSystemVersion QOperatingSystemVersion::WindowsVista =
|
||||
QOperatingSystemVersion(QOperatingSystemVersion::Windows, 6, 0);
|
||||
|
||||
/*!
|
||||
\variable QOperatingSystemVersion::Windows7
|
||||
\brief a version corresponding to Windows 7 (version 6.1).
|
||||
|
|
|
|||
|
|
@ -60,7 +60,6 @@ public:
|
|||
Android
|
||||
};
|
||||
|
||||
static const QOperatingSystemVersion WindowsVista;
|
||||
static const QOperatingSystemVersion Windows7;
|
||||
static const QOperatingSystemVersion Windows8;
|
||||
static const QOperatingSystemVersion Windows8_1;
|
||||
|
|
|
|||
|
|
@ -44,12 +44,13 @@
|
|||
#include <QtCore/QHash>
|
||||
#include <QtCore/QMutex>
|
||||
#include <QtCore/QSemaphore>
|
||||
#include <QtCore/QSharedPointer>
|
||||
#include <QtCore/qfunctions_winrt.h>
|
||||
#include <private/qabstracteventdispatcher_p.h>
|
||||
#include <private/qcoreapplication_p.h>
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
#include <wrl.h>
|
||||
#include <windows.foundation.h>
|
||||
#include <windows.system.threading.h>
|
||||
|
|
@ -300,19 +301,19 @@ HRESULT QEventDispatcherWinRT::runOnMainThread(const std::function<HRESULT()> &d
|
|||
if (QThread::currentThread() == QCoreApplication::instance()->thread())
|
||||
return delegate();
|
||||
|
||||
auto semaphore = QSharedPointer<QSemaphore>(new QSemaphore);
|
||||
auto ptrSemaphore = new QSharedPointer<QSemaphore>(semaphore);
|
||||
auto result = QSharedPointer<HRESULT>(new HRESULT);
|
||||
auto ptrResult = new QSharedPointer<HRESULT>(result);
|
||||
struct State {
|
||||
QSemaphore semaphore;
|
||||
HRESULT result;
|
||||
};
|
||||
|
||||
QMetaObject::invokeMethod(QCoreApplication::instance(), [delegate, ptrSemaphore, ptrResult]() {
|
||||
**ptrResult = delegate();
|
||||
delete ptrResult;
|
||||
(*ptrSemaphore)->release();
|
||||
delete ptrSemaphore;
|
||||
const auto state = std::make_shared<State>();
|
||||
|
||||
QMetaObject::invokeMethod(QCoreApplication::instance(), [delegate, state]() {
|
||||
const QSemaphoreReleaser releaser{state->semaphore};
|
||||
state->result = delegate();
|
||||
}, nullptr);
|
||||
|
||||
return semaphore->tryAcquire(1, timeout) ? *result : E_FAIL;
|
||||
return state->semaphore.tryAcquire(1, timeout) ? state->result : E_FAIL;
|
||||
}
|
||||
|
||||
bool QEventDispatcherWinRT::processEvents(QEventLoop::ProcessEventsFlags flags)
|
||||
|
|
|
|||
|
|
@ -221,8 +221,8 @@ QString QCalendar::name() const
|
|||
Calendars with intercallary days may represent these as extra days of the
|
||||
preceding month, or as short months separate from the usual ones. In the
|
||||
former case, daysInMonth(month, year) should be the number of ordinary days
|
||||
in the month, although \c{isDateValid(year, month, day)} might return \c true for
|
||||
some larger values of \c day.
|
||||
in the month, although \c{isDateValid(year, month, day)} might return \c true
|
||||
for some larger values of \c day.
|
||||
|
||||
\sa daysInYear(), monthsInYear(), minimumDaysInMonth(), maximumDaysInMonth()
|
||||
*/
|
||||
|
|
@ -725,7 +725,8 @@ QCalendar::QCalendar(QStringView name)
|
|||
Returns the number of days in the given \a month of the given \a year.
|
||||
|
||||
Months are numbered consecutively, starting with 1 for the first month of each
|
||||
year.
|
||||
year. If \a year is \c Unspecified (its default, if not passed), the month's
|
||||
length in a normal year is returned.
|
||||
|
||||
\sa maximumDaysInMonth(), minimumDaysInMonth()
|
||||
*/
|
||||
|
|
@ -837,29 +838,29 @@ bool QCalendar::isProleptic() const
|
|||
}
|
||||
|
||||
/*!
|
||||
Returns \c true if this calendar has a year zero.
|
||||
Returns \c true if this calendar has a year zero.
|
||||
|
||||
A non-proleptic calendar with no year zero represents years from its first
|
||||
year onwards but provides no way to describe years before its first; such a
|
||||
calendar has no year zero and is not proleptic.
|
||||
A calendar may represent years from its first year onwards but provide no
|
||||
way to describe years before its first; such a calendar has no year zero and
|
||||
is not proleptic.
|
||||
|
||||
A calendar which represents years before its first may number these years
|
||||
simply by following the usual integer counting, so that the year before the
|
||||
first is year zero, with negative-numbered years preceding this; such a
|
||||
calendar is proleptic and has a year zero. A calendar might also have a year
|
||||
zero (for example, the year of some great event, with subsequent years being
|
||||
the first year after that event, the second year after, and so on) without
|
||||
describing years before its year zero. Such a calendar would have a year zero
|
||||
without being proleptic.
|
||||
A calendar which represents years before its first may number these years
|
||||
simply by following the usual integer counting, so that the year before the
|
||||
first is year zero, with negative-numbered years preceding this; such a
|
||||
calendar is proleptic and has a year zero. A calendar might also have a year
|
||||
zero (for example, the year of some great event, with subsequent years being
|
||||
the first year after that event, the second year after, and so on) without
|
||||
describing years before its year zero. Such a calendar would have a year
|
||||
zero without being proleptic.
|
||||
|
||||
Some calendars, however, represent years before their first by an alternate
|
||||
numbering; for example, the proleptic Gregorian calendar's first year is 1 CE
|
||||
and the year before it is 1 BCE, preceded by 2 BCE and so on. In this case,
|
||||
we use negative year numbers, with year -1 as the year before year 1, year -2
|
||||
as the year before year -1 and so on. Such a calendar is proleptic but has no
|
||||
year zero.
|
||||
Some calendars, however, represent years before their first by an alternate
|
||||
numbering; for example, the proleptic Gregorian calendar's first year is 1
|
||||
CE and the year before it is 1 BCE, preceded by 2 BCE and so on. In this
|
||||
case, we use negative year numbers for this alternate numbering, with year
|
||||
-1 as the year before year 1, year -2 as the year before year -1 and so
|
||||
on. Such a calendar is proleptic but has no year zero.
|
||||
|
||||
\sa isProleptic()
|
||||
\sa isProleptic()
|
||||
*/
|
||||
bool QCalendar::hasYearZero() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3370,7 +3370,7 @@ void QImage::mirrored_inplace(bool horizontal, bool vertical)
|
|||
\sa {QImage#Image Transformations}{Image Transformations}
|
||||
*/
|
||||
|
||||
inline void rgbSwapped_generic(int width, int height, const QImage *src, QImage *dst, const QPixelLayout* layout)
|
||||
static inline void rgbSwapped_generic(int width, int height, const QImage *src, QImage *dst, const QPixelLayout* layout)
|
||||
{
|
||||
const RbSwapFunc func = layout->rbSwap;
|
||||
if (!func) {
|
||||
|
|
|
|||
|
|
@ -564,6 +564,67 @@ static bool convert_RGBA_to_ARGB_inplace(QImageData *data, Qt::ImageConversionFl
|
|||
return true;
|
||||
}
|
||||
|
||||
static void convert_rgbswap_generic(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
|
||||
{
|
||||
Q_ASSERT(src->width == dest->width);
|
||||
Q_ASSERT(src->height == dest->height);
|
||||
|
||||
const RbSwapFunc func = qPixelLayouts[src->format].rbSwap;
|
||||
Q_ASSERT(func);
|
||||
|
||||
const qsizetype sbpl = src->bytes_per_line;
|
||||
const qsizetype dbpl = dest->bytes_per_line;
|
||||
const uchar *src_data = src->data;
|
||||
uchar *dest_data = dest->data;
|
||||
|
||||
for (int i = 0; i < src->height; ++i) {
|
||||
func(dest_data, src_data, src->width);
|
||||
|
||||
src_data += sbpl;
|
||||
dest_data += dbpl;
|
||||
}
|
||||
}
|
||||
|
||||
static bool convert_rgbswap_generic_inplace(QImageData *data, Qt::ImageConversionFlags)
|
||||
{
|
||||
const RbSwapFunc func = qPixelLayouts[data->format].rbSwap;
|
||||
Q_ASSERT(func);
|
||||
|
||||
const qsizetype bpl = data->bytes_per_line;
|
||||
uchar *line_data = data->data;
|
||||
|
||||
for (int i = 0; i < data->height; ++i) {
|
||||
func(line_data, line_data, data->width);
|
||||
line_data += bpl;
|
||||
}
|
||||
|
||||
switch (data->format) {
|
||||
case QImage::Format_RGB888:
|
||||
data->format = QImage::Format_BGR888;
|
||||
break;
|
||||
case QImage::Format_BGR888:
|
||||
data->format = QImage::Format_RGB888;
|
||||
break;
|
||||
case QImage::Format_BGR30:
|
||||
data->format = QImage::Format_RGB30;
|
||||
break;
|
||||
case QImage::Format_A2BGR30_Premultiplied:
|
||||
data->format = QImage::Format_A2RGB30_Premultiplied;
|
||||
break;
|
||||
case QImage::Format_RGB30:
|
||||
data->format = QImage::Format_BGR30;
|
||||
break;
|
||||
case QImage::Format_A2RGB30_Premultiplied:
|
||||
data->format = QImage::Format_A2BGR30_Premultiplied;
|
||||
break;
|
||||
default:
|
||||
Q_UNREACHABLE();
|
||||
data->format = QImage::Format_Invalid;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template<QtPixelOrder PixelOrder, bool RGBA>
|
||||
static void convert_RGB_to_RGB30(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
|
||||
{
|
||||
|
|
@ -693,74 +754,10 @@ static bool convert_A2RGB30_PM_to_RGB30_inplace(QImageData *data, Qt::ImageConve
|
|||
return true;
|
||||
}
|
||||
|
||||
static void convert_BGR30_to_RGB30(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
|
||||
{
|
||||
Q_ASSERT(src->format == QImage::Format_RGB30 || src->format == QImage::Format_BGR30 ||
|
||||
src->format == QImage::Format_A2RGB30_Premultiplied || src->format == QImage::Format_A2BGR30_Premultiplied);
|
||||
Q_ASSERT(dest->format == QImage::Format_RGB30 || dest->format == QImage::Format_BGR30 ||
|
||||
dest->format == QImage::Format_A2RGB30_Premultiplied || dest->format == QImage::Format_A2BGR30_Premultiplied);
|
||||
Q_ASSERT(src->width == dest->width);
|
||||
Q_ASSERT(src->height == dest->height);
|
||||
|
||||
const int src_pad = (src->bytes_per_line >> 2) - src->width;
|
||||
const int dest_pad = (dest->bytes_per_line >> 2) - dest->width;
|
||||
const quint32 *src_data = (quint32 *) src->data;
|
||||
quint32 *dest_data = (quint32 *) dest->data;
|
||||
|
||||
for (int i = 0; i < src->height; ++i) {
|
||||
const quint32 *end = src_data + src->width;
|
||||
while (src_data < end) {
|
||||
*dest_data = qRgbSwapRgb30(*src_data);
|
||||
++src_data;
|
||||
++dest_data;
|
||||
}
|
||||
src_data += src_pad;
|
||||
dest_data += dest_pad;
|
||||
}
|
||||
}
|
||||
|
||||
static bool convert_BGR30_to_RGB30_inplace(QImageData *data, Qt::ImageConversionFlags)
|
||||
{
|
||||
Q_ASSERT(data->format == QImage::Format_RGB30 || data->format == QImage::Format_BGR30 ||
|
||||
data->format == QImage::Format_A2RGB30_Premultiplied || data->format == QImage::Format_A2BGR30_Premultiplied);
|
||||
|
||||
const int pad = (data->bytes_per_line >> 2) - data->width;
|
||||
uint *rgb_data = (uint *) data->data;
|
||||
|
||||
for (int i = 0; i < data->height; ++i) {
|
||||
const uint *end = rgb_data + data->width;
|
||||
while (rgb_data < end) {
|
||||
*rgb_data = qRgbSwapRgb30(*rgb_data);
|
||||
++rgb_data;
|
||||
}
|
||||
rgb_data += pad;
|
||||
}
|
||||
|
||||
switch (data->format) {
|
||||
case QImage::Format_BGR30:
|
||||
data->format = QImage::Format_RGB30;
|
||||
break;
|
||||
case QImage::Format_A2BGR30_Premultiplied:
|
||||
data->format = QImage::Format_A2RGB30_Premultiplied;
|
||||
break;
|
||||
case QImage::Format_RGB30:
|
||||
data->format = QImage::Format_BGR30;
|
||||
break;
|
||||
case QImage::Format_A2RGB30_Premultiplied:
|
||||
data->format = QImage::Format_A2BGR30_Premultiplied;
|
||||
break;
|
||||
default:
|
||||
Q_UNREACHABLE();
|
||||
data->format = QImage::Format_Invalid;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool convert_BGR30_to_A2RGB30_inplace(QImageData *data, Qt::ImageConversionFlags flags)
|
||||
{
|
||||
Q_ASSERT(data->format == QImage::Format_RGB30 || data->format == QImage::Format_BGR30);
|
||||
if (!convert_BGR30_to_RGB30_inplace(data, flags))
|
||||
if (!convert_rgbswap_generic_inplace(data, flags))
|
||||
return false;
|
||||
|
||||
if (data->format == QImage::Format_RGB30)
|
||||
|
|
@ -1421,69 +1418,6 @@ static void convert_RGBA64_to_gray16(QImageData *dest, const QImageData *src, Qt
|
|||
}
|
||||
}
|
||||
|
||||
static void convert_RGB888_to_BGR888(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
|
||||
{
|
||||
Q_ASSERT(src->format == QImage::Format_RGB888 || src->format == QImage::Format_BGR888);
|
||||
Q_ASSERT(dest->format == QImage::Format_RGB888 || dest->format == QImage::Format_BGR888);
|
||||
Q_ASSERT(src->width == dest->width);
|
||||
Q_ASSERT(src->height == dest->height);
|
||||
|
||||
const qsizetype sbpl = src->bytes_per_line;
|
||||
const qsizetype dbpl = dest->bytes_per_line;
|
||||
const uchar *src_data = src->data;
|
||||
uchar *dest_data = dest->data;
|
||||
|
||||
for (int i = 0; i < src->height; ++i) {
|
||||
int pixel = 0;
|
||||
// Handle 4 pixels (12 bytes) at a time
|
||||
for (; pixel + 3 < src->width; pixel += 4) {
|
||||
const uchar *src = src_data + pixel * 3;
|
||||
quint32 *dest_packed = (quint32 *) (dest_data + pixel * 3);
|
||||
dest_packed[0] = (src[5] << 24) | (src[0] << 16) | (src[1] << 8) | (src[2] << 0);
|
||||
dest_packed[1] = (src[7] << 24) | (src[8] << 16) | (src[3] << 8) | (src[4] << 0);
|
||||
dest_packed[2] = (src[9] << 24) | (src[10] << 16) | (src[11] << 8) | (src[6] << 0);
|
||||
}
|
||||
|
||||
// epilog: handle left over pixels
|
||||
for (; pixel < src->width; ++pixel) {
|
||||
dest_data[pixel * 3 + 0] = src_data[pixel * 3 + 2];
|
||||
dest_data[pixel * 3 + 1] = src_data[pixel * 3 + 1];
|
||||
dest_data[pixel * 3 + 2] = src_data[pixel * 3 + 0];
|
||||
}
|
||||
|
||||
src_data += sbpl;
|
||||
dest_data += dbpl;
|
||||
}
|
||||
}
|
||||
|
||||
static bool convert_RGB888_to_BGR888_inplace(QImageData *data, Qt::ImageConversionFlags)
|
||||
{
|
||||
Q_ASSERT(data->format == QImage::Format_RGB888 || data->format == QImage::Format_BGR888);
|
||||
|
||||
const qsizetype bpl = data->bytes_per_line;
|
||||
uchar *line_data = data->data;
|
||||
|
||||
for (int i = 0; i < data->height; ++i) {
|
||||
for (int j = 0; j < data->width; ++j)
|
||||
qSwap(line_data[j * 3 + 0], line_data[j * 3 + 2]);
|
||||
line_data += bpl;
|
||||
}
|
||||
|
||||
switch (data->format) {
|
||||
case QImage::Format_RGB888:
|
||||
data->format = QImage::Format_BGR888;
|
||||
break;
|
||||
case QImage::Format_BGR888:
|
||||
data->format = QImage::Format_RGB888;
|
||||
break;
|
||||
default:
|
||||
Q_UNREACHABLE();
|
||||
data->format = QImage::Format_Invalid;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static QVector<QRgb> fix_color_table(const QVector<QRgb> &ctbl, QImage::Format format)
|
||||
{
|
||||
QVector<QRgb> colorTable = ctbl;
|
||||
|
|
@ -2635,7 +2569,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
|
|||
convert_RGB888_to_RGB<true>,
|
||||
convert_RGB888_to_RGB<true>,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
convert_RGB888_to_BGR888,
|
||||
convert_rgbswap_generic,
|
||||
}, // Format_RGB888
|
||||
|
||||
{
|
||||
|
|
@ -2781,8 +2715,8 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
|
|||
0,
|
||||
0,
|
||||
convert_passthrough,
|
||||
convert_BGR30_to_RGB30,
|
||||
convert_BGR30_to_RGB30,
|
||||
convert_rgbswap_generic,
|
||||
convert_rgbswap_generic,
|
||||
0, 0,
|
||||
0, 0, 0, 0, 0
|
||||
}, // Format_BGR30
|
||||
|
|
@ -2809,7 +2743,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
|
|||
convert_A2RGB30_PM_to_RGB30<false>,
|
||||
0,
|
||||
convert_A2RGB30_PM_to_RGB30<true>,
|
||||
convert_BGR30_to_RGB30,
|
||||
convert_rgbswap_generic,
|
||||
0, 0,
|
||||
0, 0, 0, 0, 0
|
||||
}, // Format_A2BGR30_Premultiplied
|
||||
|
|
@ -2833,8 +2767,8 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
|
|||
0,
|
||||
0,
|
||||
0,
|
||||
convert_BGR30_to_RGB30,
|
||||
convert_BGR30_to_RGB30,
|
||||
convert_rgbswap_generic,
|
||||
convert_rgbswap_generic,
|
||||
0,
|
||||
convert_passthrough,
|
||||
0, 0, 0, 0, 0, 0, 0
|
||||
|
|
@ -2860,7 +2794,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
|
|||
convert_A2RGB30_PM_to_ARGB<PixelOrderRGB, true>,
|
||||
0,
|
||||
convert_A2RGB30_PM_to_RGB30<true>,
|
||||
convert_BGR30_to_RGB30,
|
||||
convert_rgbswap_generic,
|
||||
convert_A2RGB30_PM_to_RGB30<false>,
|
||||
0,
|
||||
0, 0,
|
||||
|
|
@ -3013,7 +2947,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
|
|||
0,
|
||||
0,
|
||||
0,
|
||||
convert_RGB888_to_BGR888,
|
||||
convert_rgbswap_generic,
|
||||
0,
|
||||
0,
|
||||
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
|
||||
|
|
@ -3161,7 +3095,7 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma
|
|||
}, // Format_ARGB8555_Premultiplied
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
convert_RGB888_to_BGR888_inplace
|
||||
convert_rgbswap_generic_inplace
|
||||
}, // Format_RGB888
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
|
|
@ -3267,7 +3201,7 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma
|
|||
0,
|
||||
0, // self
|
||||
convert_passthrough_inplace<QImage::Format_A2BGR30_Premultiplied>,
|
||||
convert_BGR30_to_RGB30_inplace,
|
||||
convert_rgbswap_generic_inplace,
|
||||
convert_BGR30_to_A2RGB30_inplace,
|
||||
0, 0,
|
||||
0, 0, 0, 0, 0
|
||||
|
|
@ -3295,7 +3229,7 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma
|
|||
convert_A2RGB30_PM_to_RGB30_inplace<false>,
|
||||
0, // self
|
||||
convert_A2RGB30_PM_to_RGB30_inplace<true>,
|
||||
convert_BGR30_to_RGB30_inplace,
|
||||
convert_rgbswap_generic_inplace,
|
||||
0, 0, 0, 0, 0, 0, 0
|
||||
}, // Format_A2BGR30_Premultiplied
|
||||
{
|
||||
|
|
@ -3318,7 +3252,7 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma
|
|||
0,
|
||||
0,
|
||||
0,
|
||||
convert_BGR30_to_RGB30_inplace,
|
||||
convert_rgbswap_generic_inplace,
|
||||
convert_BGR30_to_A2RGB30_inplace,
|
||||
0, // self
|
||||
convert_passthrough_inplace<QImage::Format_A2RGB30_Premultiplied>,
|
||||
|
|
@ -3345,7 +3279,7 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma
|
|||
convert_A2RGB30_PM_to_ARGB_inplace<PixelOrderRGB, true>,
|
||||
0,
|
||||
convert_A2RGB30_PM_to_RGB30_inplace<true>,
|
||||
convert_BGR30_to_RGB30_inplace,
|
||||
convert_rgbswap_generic_inplace,
|
||||
convert_A2RGB30_PM_to_RGB30_inplace<false>,
|
||||
0, // self
|
||||
0, 0,
|
||||
|
|
@ -3427,7 +3361,7 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma
|
|||
}, // Format_Grayscale16
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
convert_RGB888_to_BGR888_inplace,
|
||||
convert_rgbswap_generic_inplace,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
}, // Format_BGR888
|
||||
};
|
||||
|
|
|
|||
|
|
@ -226,12 +226,6 @@ public:
|
|||
{ 0.1351922452f, 0.7118769884f, 0.0000000000f },
|
||||
{ 0.0313525312f, 0.0000856627f, 0.8251883388f } };
|
||||
}
|
||||
static QColorMatrix toXyzFromBt2020()
|
||||
{
|
||||
return QColorMatrix { { 0.6506130099f, 0.2695676684f, -0.0018652577f },
|
||||
{ 0.1865101457f, 0.6840794086f, 0.0172256753f },
|
||||
{ 0.1270887405f, 0.0463530831f, 0.8098278046f } };
|
||||
}
|
||||
};
|
||||
|
||||
inline bool operator==(const QColorMatrix &m1, const QColorMatrix &m2)
|
||||
|
|
|
|||
|
|
@ -70,12 +70,6 @@ QColorSpacePrimaries::QColorSpacePrimaries(QColorSpace::Primaries primaries)
|
|||
bluePoint = QPointF(0.150, 0.060);
|
||||
whitePoint = QColorVector::D65Chromaticity();
|
||||
break;
|
||||
case QColorSpace::Primaries::Bt2020:
|
||||
redPoint = QPointF(0.708, 0.292);
|
||||
greenPoint = QPointF(0.190, 0.797);
|
||||
bluePoint = QPointF(0.131, 0.046);
|
||||
whitePoint = QColorVector::D65Chromaticity();
|
||||
break;
|
||||
case QColorSpace::Primaries::AdobeRgb:
|
||||
redPoint = QPointF(0.640, 0.330);
|
||||
greenPoint = QPointF(0.210, 0.710);
|
||||
|
|
@ -191,11 +185,6 @@ QColorSpacePrivate::QColorSpacePrivate(QColorSpace::NamedColorSpace namedColorSp
|
|||
transferFunction = QColorSpace::TransferFunction::ProPhotoRgb;
|
||||
description = QStringLiteral("ProPhoto RGB");
|
||||
break;
|
||||
case QColorSpace::Bt2020:
|
||||
primaries = QColorSpace::Primaries::Bt2020;
|
||||
transferFunction = QColorSpace::TransferFunction::Bt2020;
|
||||
description = QStringLiteral("BT.2020");
|
||||
break;
|
||||
default:
|
||||
Q_UNREACHABLE();
|
||||
}
|
||||
|
|
@ -277,14 +266,6 @@ void QColorSpacePrivate::identifyColorSpace()
|
|||
}
|
||||
}
|
||||
break;
|
||||
case QColorSpace::Primaries::Bt2020:
|
||||
if (transferFunction == QColorSpace::TransferFunction::Bt2020) {
|
||||
namedColorSpace = QColorSpace::Bt2020;
|
||||
if (description.isEmpty())
|
||||
description = QStringLiteral("BT.2020");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
@ -335,12 +316,6 @@ void QColorSpacePrivate::setTransferFunction()
|
|||
if (qFuzzyIsNull(gamma))
|
||||
gamma = 1.8f;
|
||||
break;
|
||||
case QColorSpace::TransferFunction::Bt2020:
|
||||
trc[0].m_type = QColorTrc::Type::Function;
|
||||
trc[0].m_fun = QColorTransferFunction::fromBt2020();
|
||||
if (qFuzzyIsNull(gamma))
|
||||
gamma = 1.961f;
|
||||
break;
|
||||
case QColorSpace::TransferFunction::Custom:
|
||||
break;
|
||||
default:
|
||||
|
|
@ -415,8 +390,6 @@ QColorTransform QColorSpacePrivate::transformationToColorSpace(const QColorSpace
|
|||
\l{http://www.color.org/chardata/rgb/DCIP3.xalter}{ICC registration of DCI-P3}
|
||||
\value ProPhotoRgb The Pro Photo RGB color space, also known as ROMM RGB is a very wide gamut color space.
|
||||
\l{http://www.color.org/chardata/rgb/rommrgb.xalter}{ICC registration of ROMM RGB}
|
||||
\value Bt2020 BT.2020 also known as Rec.2020 is the color space of HDR TVs.
|
||||
\l{http://www.color.org/chardata/rgb/BT2020.xalter}{ICC registration of BT.2020}
|
||||
*/
|
||||
|
||||
/*!
|
||||
|
|
@ -429,7 +402,6 @@ QColorTransform QColorSpacePrivate::transformationToColorSpace(const QColorSpace
|
|||
\value AdobeRgb The Adobe RGB primaries
|
||||
\value DciP3D65 The DCI-P3 primaries with the D65 whitepoint
|
||||
\value ProPhotoRgb The ProPhoto RGB primaries with the D50 whitepoint
|
||||
\value Bt2020 The BT.2020 primaries
|
||||
*/
|
||||
|
||||
/*!
|
||||
|
|
@ -442,7 +414,6 @@ QColorTransform QColorSpacePrivate::transformationToColorSpace(const QColorSpace
|
|||
\value Gamma A transfer function that is a real gamma curve based on the value of gamma()
|
||||
\value SRgb The sRGB transfer function, composed of linear and gamma parts
|
||||
\value ProPhotoRgb The ProPhoto RGB transfer function, composed of linear and gamma parts
|
||||
\value Bt2020 The BT.2020 transfer function, composed of linear and gamma parts
|
||||
*/
|
||||
|
||||
/*!
|
||||
|
|
@ -457,7 +428,7 @@ QColorSpace::QColorSpace()
|
|||
*/
|
||||
QColorSpace::QColorSpace(NamedColorSpace namedColorSpace)
|
||||
{
|
||||
static QColorSpacePrivate *predefinedColorspacePrivates[QColorSpace::Bt2020 + 1];
|
||||
static QColorSpacePrivate *predefinedColorspacePrivates[QColorSpace::ProPhotoRgb + 1];
|
||||
if (!predefinedColorspacePrivates[namedColorSpace]) {
|
||||
predefinedColorspacePrivates[namedColorSpace] = new QColorSpacePrivate(namedColorSpace);
|
||||
predefinedColorspacePrivates[namedColorSpace]->ref.ref();
|
||||
|
|
|
|||
|
|
@ -59,8 +59,7 @@ public:
|
|||
SRgbLinear,
|
||||
AdobeRgb,
|
||||
DisplayP3,
|
||||
ProPhotoRgb,
|
||||
Bt2020,
|
||||
ProPhotoRgb
|
||||
};
|
||||
Q_ENUM(NamedColorSpace)
|
||||
enum class Primaries {
|
||||
|
|
@ -68,8 +67,7 @@ public:
|
|||
SRgb,
|
||||
AdobeRgb,
|
||||
DciP3D65,
|
||||
ProPhotoRgb,
|
||||
Bt2020,
|
||||
ProPhotoRgb
|
||||
};
|
||||
Q_ENUM(Primaries)
|
||||
enum class TransferFunction {
|
||||
|
|
@ -77,8 +75,7 @@ public:
|
|||
Linear,
|
||||
Gamma,
|
||||
SRgb,
|
||||
ProPhotoRgb,
|
||||
Bt2020,
|
||||
ProPhotoRgb
|
||||
};
|
||||
Q_ENUM(TransferFunction)
|
||||
|
||||
|
|
|
|||
|
|
@ -130,10 +130,6 @@ public:
|
|||
{
|
||||
return QColorTransferFunction(1.0f / 1.055f, 0.055f / 1.055f, 1.0f / 12.92f, 0.04045f, 0.0f, 0.0f, 2.4f);
|
||||
}
|
||||
static QColorTransferFunction fromBt2020()
|
||||
{
|
||||
return QColorTransferFunction(1.0f / 1.0993f, 0.0993f / 1.0993f, 1.0f / 4.5f, 0.08145f, 0.0f, 0.0f, 2.2f);
|
||||
}
|
||||
static QColorTransferFunction fromProPhotoRgb()
|
||||
{
|
||||
return QColorTransferFunction(1.0f, 0.0f, 1.0f / 16.0f, 16.0f / 512.0f, 0.0f, 0.0f, 1.8f);
|
||||
|
|
|
|||
|
|
@ -669,8 +669,7 @@ static void QT_FASTCALL rbSwap_rgb30(uchar *d, const uchar *s, int count)
|
|||
{
|
||||
const uint *src = reinterpret_cast<const uint *>(s);
|
||||
uint *dest = reinterpret_cast<uint *>(d);
|
||||
for (int i = 0; i < count; ++i)
|
||||
dest[i] = qRgbSwapRgb30(src[i]);
|
||||
UNALIASED_CONVERSION_LOOP(dest, src, count, qRgbSwapRgb30);
|
||||
}
|
||||
|
||||
template<QImage::Format Format> Q_DECL_CONSTEXPR static inline QPixelLayout pixelLayoutRGB()
|
||||
|
|
@ -6774,6 +6773,9 @@ static void qInitDrawhelperFunctions()
|
|||
qBlendFunctions[QImage::Format_RGBX8888][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32_ssse3;
|
||||
qBlendFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32_ssse3;
|
||||
sourceFetchUntransformed[QImage::Format_RGB888] = qt_fetchUntransformed_888_ssse3;
|
||||
extern void QT_FASTCALL rbSwap_888_ssse3(uchar *dst, const uchar *src, int count);
|
||||
qPixelLayouts[QImage::Format_RGB888].rbSwap = rbSwap_888_ssse3;
|
||||
qPixelLayouts[QImage::Format_BGR888].rbSwap = rbSwap_888_ssse3;
|
||||
}
|
||||
#endif // SSSE3
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
|
||||
#include <private/qdrawhelper_x86_p.h>
|
||||
|
||||
#ifdef QT_COMPILER_SUPPORTS_SSSE3
|
||||
#if defined(QT_COMPILER_SUPPORTS_SSSE3)
|
||||
|
||||
#include <private/qdrawingprimitive_sse2_p.h>
|
||||
|
||||
|
|
@ -254,6 +254,49 @@ void qt_memfill24_ssse3(quint24 *dest, quint24 color, qsizetype count)
|
|||
}
|
||||
}
|
||||
|
||||
void QT_FASTCALL rbSwap_888_ssse3(uchar *dst, const uchar *src, int count)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
const static __m128i shuffleMask1 = _mm_setr_epi8(2, 1, 0, 5, 4, 3, 8, 7, 6, 11, 10, 9, 14, 13, 12, /*!!*/15);
|
||||
const static __m128i shuffleMask2 = _mm_setr_epi8(0, /*!!*/1, 4, 3, 2, 7, 6, 5, 10, 9, 8, 13, 12, 11, /*!!*/14, 15);
|
||||
const static __m128i shuffleMask3 = _mm_setr_epi8(/*!!*/0, 3, 2, 1, 6, 5, 4, 9, 8, 7, 12, 11, 10, 15, 14, 13);
|
||||
|
||||
for (; i + 15 < count; i += 16) {
|
||||
__m128i s1 = _mm_loadu_si128((const __m128i *)src);
|
||||
__m128i s2 = _mm_loadu_si128((const __m128i *)(src + 16));
|
||||
__m128i s3 = _mm_loadu_si128((const __m128i *)(src + 32));
|
||||
s1 = _mm_shuffle_epi8(s1, shuffleMask1);
|
||||
s2 = _mm_shuffle_epi8(s2, shuffleMask2);
|
||||
s3 = _mm_shuffle_epi8(s3, shuffleMask3);
|
||||
_mm_storeu_si128((__m128i *)dst, s1);
|
||||
_mm_storeu_si128((__m128i *)(dst + 16), s2);
|
||||
_mm_storeu_si128((__m128i *)(dst + 32), s3);
|
||||
|
||||
// Now fix the last four misplaced values
|
||||
std::swap(dst[15], dst[17]);
|
||||
std::swap(dst[30], dst[32]);
|
||||
|
||||
src += 48;
|
||||
dst += 48;
|
||||
}
|
||||
|
||||
if (src != dst) {
|
||||
SIMD_EPILOGUE(i, count, 15) {
|
||||
dst[0] = src[2];
|
||||
dst[1] = src[1];
|
||||
dst[2] = src[0];
|
||||
dst += 3;
|
||||
src += 3;
|
||||
}
|
||||
} else {
|
||||
SIMD_EPILOGUE(i, count, 15) {
|
||||
std::swap(dst[0], dst[2]);
|
||||
dst += 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_COMPILER_SUPPORTS_SSSE3
|
||||
|
|
|
|||
|
|
@ -687,9 +687,6 @@ bool fromIccProfile(const QByteArray &data, QColorSpace *colorSpace)
|
|||
} else if (colorspaceDPtr->toXyz == QColorMatrix::toXyzFromDciP3D65()) {
|
||||
qCDebug(lcIcc) << "fromIccProfile: DCI-P3 D65 primaries detected";
|
||||
colorspaceDPtr->primaries = QColorSpace::Primaries::DciP3D65;
|
||||
} else if (colorspaceDPtr->toXyz == QColorMatrix::toXyzFromBt2020()) {
|
||||
qCDebug(lcIcc) << "fromIccProfile: BT.2020 primaries detected";
|
||||
colorspaceDPtr->primaries = QColorSpace::Primaries::Bt2020;
|
||||
}
|
||||
if (colorspaceDPtr->toXyz == QColorMatrix::toXyzFromProPhotoRgb()) {
|
||||
qCDebug(lcIcc) << "fromIccProfile: ProPhoto RGB primaries detected";
|
||||
|
|
|
|||
|
|
@ -446,14 +446,22 @@ void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion ®i
|
|||
d_ptr->blitter->setRedBlueSwizzle(false);
|
||||
}
|
||||
|
||||
// There is no way to tell if the OpenGL-rendered content is premultiplied or not.
|
||||
// For compatibility, assume that it is not, and use normal alpha blend always.
|
||||
if (d_ptr->premultiplied)
|
||||
funcs->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
|
||||
|
||||
// Textures for renderToTexture widgets that have WA_AlwaysStackOnTop set.
|
||||
bool blendIsPremultiplied = d_ptr->premultiplied;
|
||||
for (int i = 0; i < textures->count(); ++i) {
|
||||
if (textures->flags(i).testFlag(QPlatformTextureList::StacksOnTop))
|
||||
const QPlatformTextureList::Flags flags = textures->flags(i);
|
||||
if (flags.testFlag(QPlatformTextureList::NeedsPremultipliedAlphaBlending)) {
|
||||
if (!blendIsPremultiplied) {
|
||||
funcs->glBlendFuncSeparate(GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
|
||||
blendIsPremultiplied = true;
|
||||
}
|
||||
} else {
|
||||
if (blendIsPremultiplied) {
|
||||
funcs->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
|
||||
blendIsPremultiplied = false;
|
||||
}
|
||||
}
|
||||
if (flags.testFlag(QPlatformTextureList::StacksOnTop))
|
||||
blitTextureForWidget(textures, i, window, deviceWindowRect, d_ptr->blitter, offset, canUseSrgb);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,8 @@ class Q_GUI_EXPORT QPlatformTextureList : public QObject
|
|||
public:
|
||||
enum Flag {
|
||||
StacksOnTop = 0x01,
|
||||
TextureIsSrgb = 0x02
|
||||
TextureIsSrgb = 0x02,
|
||||
NeedsPremultipliedAlphaBlending = 0x04
|
||||
};
|
||||
Q_DECLARE_FLAGS(Flags, Flag)
|
||||
|
||||
|
|
|
|||
|
|
@ -1220,7 +1220,6 @@ void QRhiD3D11::enqueueSubresUpload(QD3D11Texture *texD, QD3D11CommandBuffer *cb
|
|||
const QSize size = subresDesc.sourceSize().isEmpty() ? q->sizeForMipLevel(level, texD->m_pixelSize)
|
||||
: subresDesc.sourceSize();
|
||||
quint32 bpl = 0;
|
||||
QSize blockDim;
|
||||
textureFormatInfo(texD->m_format, size, &bpl, nullptr);
|
||||
box.left = dp.x();
|
||||
box.top = dp.y();
|
||||
|
|
|
|||
|
|
@ -997,11 +997,44 @@ void QRhiMetal::setVertexInput(QRhiCommandBuffer *cb,
|
|||
}
|
||||
}
|
||||
|
||||
QSize safeOutputSize(QRhiMetal *rhiD, QMetalCommandBuffer *cbD)
|
||||
{
|
||||
QSize size = cbD->currentTarget->pixelSize();
|
||||
|
||||
// So now we have the issue that the texture (drawable) size may have
|
||||
// changed again since swapchain buildOrResize() was called. This can
|
||||
// happen for example when interactively resizing the window a lot in one
|
||||
// go, and command buffer building happens on a dedicated thread (f.ex.
|
||||
// using the threaded render loop of Qt Quick).
|
||||
//
|
||||
// This is only an issue when running in debug mode with XCode because Metal
|
||||
// validation will fail when setting viewport or scissor with the real size
|
||||
// being smaller than what we think it is. So query the drawable size right
|
||||
// here, in debug mode at least.
|
||||
//
|
||||
// In addition, we have to take the smaller of the two widths and heights
|
||||
// to be safe, apparently. In some cases validation seems to think that the
|
||||
// "render pass width" (or height) is the old(?) value.
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
if (cbD->currentTarget->resourceType() == QRhiResource::RenderTarget) {
|
||||
Q_ASSERT(rhiD->currentSwapChain);
|
||||
const QSize otherSize = rhiD->currentSwapChain->surfacePixelSize();
|
||||
size.setWidth(qMin(size.width(), otherSize.width()));
|
||||
size.setHeight(qMin(size.height(), otherSize.height()));
|
||||
}
|
||||
#else
|
||||
Q_UNUSED(rhiD);
|
||||
#endif
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
void QRhiMetal::setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport)
|
||||
{
|
||||
QMetalCommandBuffer *cbD = QRHI_RES(QMetalCommandBuffer, cb);
|
||||
Q_ASSERT(cbD->recordingPass == QMetalCommandBuffer::RenderPass);
|
||||
const QSize outputSize = cbD->currentTarget->pixelSize();
|
||||
const QSize outputSize = safeOutputSize(this, cbD);
|
||||
|
||||
// x,y is top-left in MTLViewportRect but bottom-left in QRhiViewport
|
||||
float x, y, w, h;
|
||||
|
|
@ -1033,7 +1066,7 @@ void QRhiMetal::setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor)
|
|||
QMetalCommandBuffer *cbD = QRHI_RES(QMetalCommandBuffer, cb);
|
||||
Q_ASSERT(cbD->recordingPass == QMetalCommandBuffer::RenderPass);
|
||||
Q_ASSERT(QRHI_RES(QMetalGraphicsPipeline, cbD->currentGraphicsPipeline)->m_flags.testFlag(QRhiGraphicsPipeline::UsesScissor));
|
||||
const QSize outputSize = cbD->currentTarget->pixelSize();
|
||||
const QSize outputSize = safeOutputSize(this, cbD);
|
||||
|
||||
// x,y is top-left in MTLScissorRect but bottom-left in QRhiScissor
|
||||
int x, y, w, h;
|
||||
|
|
|
|||
|
|
@ -58,6 +58,8 @@
|
|||
#include <QtNetwork/qnetworkproxy.h>
|
||||
#endif
|
||||
|
||||
#include <qcoreapplication.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
|
|
@ -195,6 +197,29 @@ QHttp2ProtocolHandler::QHttp2ProtocolHandler(QHttpNetworkConnectionChannel *chan
|
|||
}
|
||||
}
|
||||
|
||||
void QHttp2ProtocolHandler::handleConnectionClosure()
|
||||
{
|
||||
// The channel has just received RemoteHostClosedError and since it will
|
||||
// not try (for HTTP/2) to re-connect, it's time to finish all replies
|
||||
// with error.
|
||||
|
||||
// Maybe we still have some data to read and can successfully finish
|
||||
// a stream/request?
|
||||
_q_receiveReply();
|
||||
|
||||
// Finish all still active streams. If we previously had GOAWAY frame,
|
||||
// we probably already closed some (or all) streams with ContentReSend
|
||||
// error, but for those still active, not having any data to finish,
|
||||
// we now report RemoteHostClosedError.
|
||||
const auto errorString = QCoreApplication::translate("QHttp", "Connection closed");
|
||||
for (auto it = activeStreams.begin(), eIt = activeStreams.end(); it != eIt; ++it)
|
||||
finishStreamWithError(it.value(), QNetworkReply::RemoteHostClosedError, errorString);
|
||||
|
||||
// Make sure we'll never try to read anything later:
|
||||
activeStreams.clear();
|
||||
goingAway = true;
|
||||
}
|
||||
|
||||
void QHttp2ProtocolHandler::_q_uploadDataReadyRead()
|
||||
{
|
||||
if (!sender()) // QueuedConnection, firing after sender (byte device) was deleted.
|
||||
|
|
|
|||
|
|
@ -92,6 +92,8 @@ public:
|
|||
QHttp2ProtocolHandler &operator = (const QHttp2ProtocolHandler &rhs) = delete;
|
||||
QHttp2ProtocolHandler &operator = (QHttp2ProtocolHandler &&rhs) = delete;
|
||||
|
||||
Q_INVOKABLE void handleConnectionClosure();
|
||||
|
||||
private slots:
|
||||
void _q_uploadDataReadyRead();
|
||||
void _q_replyDestroyed(QObject* reply);
|
||||
|
|
|
|||
|
|
@ -977,7 +977,18 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket
|
|||
if (!reply && state == QHttpNetworkConnectionChannel::IdleState) {
|
||||
// Not actually an error, it is normal for Keep-Alive connections to close after some time if no request
|
||||
// is sent on them. No need to error the other replies below. Just bail out here.
|
||||
// The _q_disconnected will handle the possibly pipelined replies
|
||||
// The _q_disconnected will handle the possibly pipelined replies. HTTP/2 is special for now,
|
||||
// we do not resend, but must report errors if any request is in progress (note, while
|
||||
// not in its sendRequest(), protocol handler switches the channel to IdleState, thus
|
||||
// this check is under this condition in 'if'):
|
||||
if (protocolHandler.data()) {
|
||||
if (connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP2Direct
|
||||
|| connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP2) {
|
||||
auto h2Handler = static_cast<QHttp2ProtocolHandler *>(protocolHandler.data());
|
||||
h2Handler->handleConnectionClosure();
|
||||
protocolHandler.reset();
|
||||
}
|
||||
}
|
||||
return;
|
||||
} else if (state != QHttpNetworkConnectionChannel::IdleState && state != QHttpNetworkConnectionChannel::ReadingState) {
|
||||
// Try to reconnect/resend before sending an error.
|
||||
|
|
|
|||
|
|
@ -143,13 +143,12 @@ void QSslSocketPrivate::ensureCiphersAndCertsLoaded()
|
|||
if (!s_loadRootCertsOnDemand)
|
||||
setDefaultCaCertificates(systemCaCertificates());
|
||||
#ifdef Q_OS_WIN
|
||||
//Enabled for fetching additional root certs from windows update on windows 6+
|
||||
//Enabled for fetching additional root certs from windows update on windows.
|
||||
//This flag is set false by setDefaultCaCertificates() indicating the app uses
|
||||
//its own cert bundle rather than the system one.
|
||||
//Same logic that disables the unix on demand cert loading.
|
||||
//Unlike unix, we do preload the certificates from the cert store.
|
||||
if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::WindowsVista)
|
||||
s_loadRootCertsOnDemand = true;
|
||||
s_loadRootCertsOnDemand = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -93,7 +93,3 @@ qtConfig(vulkan) {
|
|||
|
||||
PLUGIN_TYPE = platforms
|
||||
load(qt_plugin)
|
||||
|
||||
#Non-standard install directory, QTBUG-29859
|
||||
DESTDIR = $$DESTDIR/android
|
||||
target.path = $${target.path}/android
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@
|
|||
#include <QtGui/qaccessible.h>
|
||||
#include <QtCore/qloggingcategory.h>
|
||||
#include <QtCore/qstring.h>
|
||||
#include <QtCore/qvarlengtharray.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
|
@ -227,7 +228,7 @@ HRESULT QWindowsUiaTextRangeProvider::GetBoundingRectangles(SAFEARRAY **pRetVal)
|
|||
return UIA_E_ELEMENTNOTAVAILABLE;
|
||||
|
||||
int len = textInterface->characterCount();
|
||||
QList<QRect> rectList;
|
||||
QVarLengthArray<QRect> rectList;
|
||||
|
||||
if ((m_startOffset >= 0) && (m_endOffset <= len) && (m_startOffset < m_endOffset)) {
|
||||
int start, end;
|
||||
|
|
|
|||
|
|
@ -84,8 +84,7 @@ static const int windowsRightBorder = 15; // right border on windows
|
|||
*/
|
||||
bool QWindowsVistaStylePrivate::useVista()
|
||||
{
|
||||
return QOperatingSystemVersion::current() >= QOperatingSystemVersion::WindowsVista
|
||||
&& QWindowsVistaStylePrivate::useXP();
|
||||
return QWindowsVistaStylePrivate::useXP();
|
||||
}
|
||||
|
||||
/* \internal
|
||||
|
|
|
|||
|
|
@ -107,7 +107,9 @@ public:
|
|||
Q_ENUM(ViewportUpdateMode)
|
||||
|
||||
enum OptimizationFlag {
|
||||
DontClipPainter = 0x1, // obsolete
|
||||
#if QT_DEPRECATED_SINCE(5, 14)
|
||||
DontClipPainter Q_DECL_ENUMERATOR_DEPRECATED_X("This flag is unused") = 0x1, // obsolete
|
||||
#endif
|
||||
DontSavePainterState = 0x2,
|
||||
DontAdjustForAntialiasing = 0x4,
|
||||
IndirectPainting = 0x8
|
||||
|
|
|
|||
|
|
@ -2098,8 +2098,7 @@ void tst_QFileInfo::owner()
|
|||
DWORD bufSize = 1024;
|
||||
if (GetUserNameW(usernameBuf, &bufSize)) {
|
||||
userName = QString::fromWCharArray(usernameBuf);
|
||||
if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::WindowsVista
|
||||
&& IsUserAdmin()) {
|
||||
if (IsUserAdmin()) {
|
||||
// Special case : If the user is a member of Administrators group, all files
|
||||
// created by the current user are owned by the Administrators group.
|
||||
LPLOCALGROUP_USERS_INFO_0 pBuf = NULL;
|
||||
|
|
|
|||
|
|
@ -123,9 +123,6 @@ void tst_QColorSpace::namedColorSpaces_data()
|
|||
QTest::newRow("ProPhoto RGB") << QColorSpace::ProPhotoRgb
|
||||
<< QColorSpace::Primaries::ProPhotoRgb
|
||||
<< QColorSpace::TransferFunction::ProPhotoRgb;
|
||||
QTest::newRow("BT.2020") << QColorSpace::Bt2020
|
||||
<< QColorSpace::Primaries::Bt2020
|
||||
<< QColorSpace::TransferFunction::Bt2020;
|
||||
}
|
||||
|
||||
void tst_QColorSpace::namedColorSpaces()
|
||||
|
|
@ -220,7 +217,6 @@ void tst_QColorSpace::imageConversion_data()
|
|||
QTest::newRow("Display-P3 -> sRGB") << QColorSpace::DisplayP3 << QColorSpace::SRgb << 0;
|
||||
QTest::newRow("Adobe RGB -> sRGB") << QColorSpace::AdobeRgb << QColorSpace::SRgb << 2;
|
||||
QTest::newRow("Display-P3 -> Adobe RGB") << QColorSpace::DisplayP3 << QColorSpace::AdobeRgb << 2;
|
||||
QTest::newRow("Display-P3 -> BT.2020") << QColorSpace::DisplayP3 << QColorSpace::Bt2020 << 4;
|
||||
QTest::newRow("sRGB -> sRGB Linear") << QColorSpace::SRgb << QColorSpace::SRgbLinear << 0;
|
||||
}
|
||||
|
||||
|
|
@ -351,14 +347,12 @@ void tst_QColorSpace::primariesXyz()
|
|||
QColorSpace adobeRgb = QColorSpace::AdobeRgb;
|
||||
QColorSpace displayP3 = QColorSpace::DisplayP3;
|
||||
QColorSpace proPhotoRgb = QColorSpace::ProPhotoRgb;
|
||||
QColorSpace bt2020 = QColorSpace::Bt2020;
|
||||
|
||||
// Check if our calculated matrices, match the precalculated ones.
|
||||
QCOMPARE(QColorSpacePrivate::get(sRgb)->toXyz, QColorMatrix::toXyzFromSRgb());
|
||||
QCOMPARE(QColorSpacePrivate::get(adobeRgb)->toXyz, QColorMatrix::toXyzFromAdobeRgb());
|
||||
QCOMPARE(QColorSpacePrivate::get(displayP3)->toXyz, QColorMatrix::toXyzFromDciP3D65());
|
||||
QCOMPARE(QColorSpacePrivate::get(proPhotoRgb)->toXyz, QColorMatrix::toXyzFromProPhotoRgb());
|
||||
QCOMPARE(QColorSpacePrivate::get(bt2020)->toXyz, QColorMatrix::toXyzFromBt2020());
|
||||
}
|
||||
|
||||
#ifdef QT_BUILD_INTERNAL
|
||||
|
|
@ -370,7 +364,6 @@ void tst_QColorSpace::primaries2_data()
|
|||
QTest::newRow("DCI-P3 (D65)") << QColorSpace::Primaries::DciP3D65;
|
||||
QTest::newRow("Adobe RGB (1998)") << QColorSpace::Primaries::AdobeRgb;
|
||||
QTest::newRow("ProPhoto RGB") << QColorSpace::Primaries::ProPhotoRgb;
|
||||
QTest::newRow("BT.2020") << QColorSpace::Primaries::Bt2020;
|
||||
}
|
||||
|
||||
void tst_QColorSpace::primaries2()
|
||||
|
|
|
|||
|
|
@ -881,11 +881,6 @@ void tst_QTcpServer::serverAddress_data()
|
|||
{
|
||||
QTest::addColumn<QHostAddress>("listenAddress");
|
||||
QTest::addColumn<QHostAddress>("serverAddress");
|
||||
#ifdef Q_OS_WIN
|
||||
if (QOperatingSystemVersion::current() < QOperatingSystemVersion::WindowsVista)
|
||||
QTest::newRow("Any") << QHostAddress(QHostAddress::Any) << QHostAddress(QHostAddress::AnyIPv4); //windows XP doesn't support dual stack sockets
|
||||
else
|
||||
#endif
|
||||
if (QtNetworkSettings::hasIPv6())
|
||||
QTest::newRow("Any") << QHostAddress(QHostAddress::Any) << QHostAddress(QHostAddress::Any);
|
||||
else
|
||||
|
|
|
|||
|
|
@ -2610,11 +2610,6 @@ void tst_QGraphicsView::optimizationFlags()
|
|||
QGraphicsView view;
|
||||
QVERIFY(!view.optimizationFlags());
|
||||
|
||||
view.setOptimizationFlag(QGraphicsView::DontClipPainter);
|
||||
QVERIFY(view.optimizationFlags() & QGraphicsView::DontClipPainter);
|
||||
view.setOptimizationFlag(QGraphicsView::DontClipPainter, false);
|
||||
QVERIFY(!view.optimizationFlags());
|
||||
|
||||
view.setOptimizationFlag(QGraphicsView::DontSavePainterState);
|
||||
QVERIFY(view.optimizationFlags() & QGraphicsView::DontSavePainterState);
|
||||
view.setOptimizationFlag(QGraphicsView::DontSavePainterState, false);
|
||||
|
|
@ -2625,10 +2620,8 @@ void tst_QGraphicsView::optimizationFlags()
|
|||
view.setOptimizationFlag(QGraphicsView::DontAdjustForAntialiasing, false);
|
||||
QVERIFY(!view.optimizationFlags());
|
||||
|
||||
view.setOptimizationFlags(QGraphicsView::DontAdjustForAntialiasing
|
||||
| QGraphicsView::DontClipPainter);
|
||||
QCOMPARE(view.optimizationFlags(), QGraphicsView::OptimizationFlags(QGraphicsView::DontAdjustForAntialiasing
|
||||
| QGraphicsView::DontClipPainter));
|
||||
view.setOptimizationFlags(QGraphicsView::DontAdjustForAntialiasing);
|
||||
QCOMPARE(view.optimizationFlags(), QGraphicsView::OptimizationFlags(QGraphicsView::DontAdjustForAntialiasing));
|
||||
}
|
||||
|
||||
class MessUpPainterItem : public QGraphicsRectItem
|
||||
|
|
|
|||
|
|
@ -7704,9 +7704,7 @@ void tst_QWidget::moveWindowInShowEvent()
|
|||
void tst_QWidget::repaintWhenChildDeleted()
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::WindowsVista) {
|
||||
QTest::qWait(1000);
|
||||
}
|
||||
QTest::qWait(1000);
|
||||
#endif
|
||||
ColorWidget w(nullptr, Qt::FramelessWindowHint, Qt::red);
|
||||
w.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
|
||||
|
|
@ -8903,11 +8901,10 @@ void tst_QWidget::translucentWidget()
|
|||
|
||||
#ifdef Q_OS_WIN
|
||||
QWidget *desktopWidget = QApplication::desktop()->screen(0);
|
||||
if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::WindowsVista)
|
||||
widgetSnapshot = grabWindow(desktopWidget->windowHandle(), labelPos.x(), labelPos.y(), label.width(), label.height());
|
||||
else
|
||||
widgetSnapshot = grabWindow(desktopWidget->windowHandle(), labelPos.x(), labelPos.y(), label.width(), label.height());
|
||||
#else
|
||||
widgetSnapshot = label.grab(QRect(QPoint(0, 0), label.size()));
|
||||
#endif
|
||||
widgetSnapshot = label.grab(QRect(QPoint(0, 0), label.size()));
|
||||
const QImage actual = widgetSnapshot.toImage().convertToFormat(QImage::Format_RGB32);
|
||||
const QImage expected = pm.toImage().scaled(label.devicePixelRatioF() * pm.size());
|
||||
if (m_platform == QStringLiteral("winrt"))
|
||||
|
|
|
|||
|
|
@ -171,11 +171,8 @@ void tst_QProgressBar::format()
|
|||
bar.setFormat("%v of %m (%p%)");
|
||||
qApp->processEvents();
|
||||
|
||||
#ifndef Q_OS_MAC
|
||||
#if !defined(Q_OS_MACOS) && !defined(Q_OS_WIN)
|
||||
// Animated scroll bars get paint events all the time
|
||||
#ifdef Q_OS_WIN
|
||||
if (QOperatingSystemVersion::current() < QOperatingSystemVersion::WindowsVista)
|
||||
#endif
|
||||
QVERIFY(!bar.repainted);
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -342,6 +342,7 @@ void tst_QImageConversion::convertGenericInplace_data()
|
|||
QImage argb6666 = argb32.convertToFormat(QImage::Format_ARGB6666_Premultiplied);
|
||||
QImage argb4444 = argb32.convertToFormat(QImage::Format_ARGB4444_Premultiplied);
|
||||
QImage rgb16 = argb32.convertToFormat(QImage::Format_RGB16);
|
||||
QImage rgb30 = argb32.convertToFormat(QImage::Format_RGB30);
|
||||
QImage rgb888 = argb32.convertToFormat(QImage::Format_RGB888);
|
||||
|
||||
QTest::newRow("argb32 -> argb32pm -> argb32") << argb32 << QImage::Format_ARGB32_Premultiplied;
|
||||
|
|
@ -370,6 +371,7 @@ void tst_QImageConversion::convertGenericInplace_data()
|
|||
QTest::newRow("rgb16 -> rgb444 -> rgb16") << rgb16 << QImage::Format_RGB444;
|
||||
QTest::newRow("rgb16 -> argb4444pm -> rgb16") << rgb16 << QImage::Format_ARGB4444_Premultiplied;
|
||||
|
||||
QTest::newRow("rgb30 -> bgr30 -> rgb30") << rgb30 << QImage::Format_BGR30;
|
||||
QTest::newRow("rgb888 -> bgr888 -> rgb888") << rgb888 << QImage::Format_BGR888;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ public:
|
|||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
painter->setBrush(m_brush);
|
||||
painter->drawRoundedRect(rect(), Qt::RelativeSize);
|
||||
painter->drawRoundedRect(rect(), 25, 25, Qt::RelativeSize);
|
||||
painter->drawLine(rect().topLeft(), rect().bottomRight());
|
||||
painter->drawLine(rect().bottomLeft(), rect().topRight());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue