Qt 6 works on Windows host

This commit is contained in:
2022-01-23 12:59:57 +03:00
parent fcdc142991
commit bdb2acb414
14 changed files with 139 additions and 34 deletions

View File

@@ -155,11 +155,27 @@ QuickTest;QuickWidgets;RemoteObjects;RepParser;Scxml;Sensors;SerialBus;SerialPor
Sql;Svg;Test;TextToSpeech;ThemeSupport;UiPlugin;UiTools;VulkanSupport;WebChannel;WebSockets;\
Widgets;WindowsUIAutomationSupport;WinExtras;Xml;XmlPatterns;Zlib;Charts;AndroidExtras")
set(__qt_modules_6 "Concurrent;Core;DBus;Designer;DeviceDiscoverySupport;FbSupport;\
Gui;Help;HostInfo;Linguist;Network;OpenGL;OpenGLWidgets;PacketProtocol;PrintSupport;\
Qml;QmlDebug;QmlDevTools;QmlImportScanner;QmlModels;QmlTools;QmlWorkerScript;Quick;\
QuickControls2;QuickParticles;QuickShapes;QuickTemplates2;QuickTest;QuickWidgets;\
ShaderTools;Sql;Svg;SvgWidgets;Test;Tools;UiPlugin;UiTools;Widgets;Xml")
set(__qt_modules_6 "3DAnimation;3DCore;3DExtras;3DInput;3DLogic;3DQuick;3DQuickAnimation;3DQuickExtras;\
3DQuickInput;3DQuickRender;3DQuickScene2D;3DRender;ActiveQt;AxBasePrivate;AxContainer;\
AxContainerTools;AxServer;AxServerTools;Bluetooth;BodymovinPrivate;BuildInternals;\
Bundled_Clip2Tri;BundledFreetype;BundledLibpng;BundledOpenwnn;BundledPinyin;BundledTcime;\
Charts;ChartsQml;Coap;Concurrent;Core;Core5Compat;CoreTools;DataVisualization;DBus;\
DBusTools;Designer;DesignerComponentsPrivate;DeviceDiscoverySupportPrivate;EntryPointPrivate;\
FbSupportPrivate;Gui;GuiTools;Help;HostInfo;LabsAnimation;LabsFolderListModel;LabsQmlModels;\
LabsSettings;LabsSharedImage;LabsWavefrontMesh;Linguist;LinguistTools;Mqtt;\
Multimedia;MultimediaQuickPrivate;MultimediaWidgets;Network;NetworkAuth;Nfc;OpcUa;\
OpenGL;OpenGLWidgets;PacketProtocolPrivate;Positioning;PositioningQuick;PrintSupport;\
Qml;QmlCompilerPrivate;QmlCore;QmlDebugPrivate;QmlDevToolsPrivate;QmlDomPrivate;QmlImportScanner;\
QmlLocalStorage;QmlModels;QmlTools;QmlWorkerScript;QmlXmlListModel;Quick;Quick3D;\
Quick3DAssetImport;Quick3DAssetUtils;Quick3DEffects;Quick3DHelpers;Quick3DIblBaker;Quick3DParticles;\
Quick3DRuntimeRender;Quick3DTools;Quick3DUtils;QuickControls2;QuickControls2Impl;\
QuickControlsTestUtilsPrivate;QuickDialogs2;QuickDialogs2QuickImpl;QuickDialogs2Utils;QuickLayouts;\
QuickParticlesPrivate;QuickShapesPrivate;QuickTemplates2;QuickTest;QuickTestUtilsPrivate;\
QuickTimeline;QuickWidgets;RemoteObjects;RemoteObjectsQml;RemoteObjectsTools;RepParser;\
Scxml;ScxmlQml;ScxmlTools;Sensors;SensorsQuick;SerialBus;SerialBusTools;SerialPort;\
ShaderTools;ShaderToolsTools;Sql;StateMachine;StateMachineQml;Svg;SvgWidgets;Test;Tools;\
ToolsTools;UiPlugin;UiTools;VirtualKeyboard;WebChannel;WebSockets;WebView;WebViewQuick;\
Widgets;WidgetsTools;Xml;AndroidExtras")
set(_QT_VERSIONS_ 4 5 6)

View File

@@ -795,6 +795,9 @@ void BlockView::keyReleaseEvent(QKeyEvent * e) {
void BlockView::resizeEvent(QResizeEvent * event) {
QGraphicsView::resizeEvent(event);
thick = lineThickness(this);
#if QT_VERSION_MAJOR >= 6
thick *= devicePixelRatioF();
#endif
adjustThumb();
updateNavRect();
nav_target = _nav();

View File

@@ -154,12 +154,16 @@ Graphic::Graphic(QWidget * parent): QFrame(parent), canvas(0), line_x_min(this),
axis_type_x = Numeric;
floating_axis_type = Free;
min_repaint_int = 25;
lastw = lasth = 0;
inc_x = 1.;
buffer = 0;
//buffer = 0;
gridx = gridy = 1.;
history = 5.;
visible_time = -1.;
thick = lineThickness(this);
#if QT_VERSION_MAJOR >= 5
thick *= devicePixelRatio();
#endif
pause_phase = 0.;
def_rect.setRect(0., 0., 1., 1.);
selrect = def_rect;
@@ -193,7 +197,7 @@ Graphic::~Graphic() {
delete buttons_menu;
#endif
delete conf;
if (buffer != 0) delete buffer;
//if (buffer != 0) delete buffer;
}
@@ -360,8 +364,21 @@ void Graphic::totalUpdate() {
void Graphic::canvasPaintEvent() {
if (is_lines_update) return;
int wid = canvas->width(), hei = canvas->height();
int wid = canvas->width (),hei = canvas->height();
if (canvas->isHidden() || wid <= 1 || hei <= 1) return;
if (!buffer.isNull()) {
if (lastw != wid || lasth != hei)
buffer = QPixmap();
}
if (buffer.isNull()) {
#if QT_VERSION_MAJOR >= 5
const qreal dpr = canvas->devicePixelRatio();
buffer = QPixmap(canvas->size() * dpr);
buffer.setDevicePixelRatio(dpr);
#else
buffer = QPixmap(canvas->size());
#endif
}
lastw = wid;
lasth = hei;
font_sz = fontMetrics().size(0, "0");
@@ -372,11 +389,12 @@ void Graphic::canvasPaintEvent() {
font_sz.setWidth(font_sz.width() * 8);
#endif
thick = lineThickness(this);
if (buffer != 0) if (buffer->width() != wid || buffer->height() != hei) {delete buffer; buffer = 0;}
if (buffer == 0) buffer = new QImage(wid, hei, QImage::Format_RGB32);
#if QT_VERSION_MAJOR >= 5
thick *= canvas->devicePixelRatio();
#endif
if (bufferActive) {
QPainter p(canvas);
p.drawImage(0, 0, *buffer);
p.drawPixmap(QPoint(), buffer);
painter = &p;
fp_size.clear();
if (curpos != startpos) drawAction();
@@ -391,7 +409,7 @@ void Graphic::canvasPaintEvent() {
p.begin(canvas);
} else
#endif
p.begin(buffer);
p.begin(&buffer);
p.fillRect(canvas->rect(), back_color);
painter = &p;
p.setFont(font());
@@ -423,7 +441,7 @@ void Graphic::canvasPaintEvent() {
p.end();
if (isOGL && !m_fakeGL) return;
p.begin(canvas);
p.drawImage(0, 0, *buffer);
p.drawPixmap(QPoint(), buffer);
p.end();
}
@@ -1137,6 +1155,9 @@ void Graphic::drawGrid() {
cy = 0;
cx = gbx - 5;
grid_pen.setWidth(qMax<int>(qMax<int>(qRound(thick / 1.4), 1), grid_pen.width()));
#if QT_VERSION_MAJOR >= 5
grid_pen.setCosmetic(true);
#endif
QFont sf = font();
QFont nf = sf;
sf.setPointSizeF(qMax<qreal>(sf.pointSizeF() / 1.6, 7.));
@@ -1254,7 +1275,11 @@ void Graphic::drawGrid() {
painter->drawText(gbx, chei - font_sz.height(), wid, font_sz.height(), Qt::AlignCenter, label_x);
}
painter->setPen(QPen(grid_pen.color(), qMax<int>(thick, grid_pen.width())));
QPen outer_pen(grid_pen.color(), qMax<int>(thick, grid_pen.width()));
#if QT_VERSION_MAJOR >= 5
outer_pen.setCosmetic(true);
#endif
painter->setPen(outer_pen);
painter->drawRect(gbx, -1, wid + 6, hei + 6);
}
@@ -1369,7 +1394,12 @@ QString Graphic::pointCoords(QPointF point, bool x, bool y) {
if (axis_type_x == Numeric)
ret += QString::number(point.x(), 'f', 3);
else
ret += QDateTime::fromMSecsSinceEpoch(point.x()).toString(Qt::SystemLocaleShortDate);
ret +=
#if QT_VERSION_MAJOR <= 5
QDateTime::fromMSecsSinceEpoch(point.x()).toString(Qt::SystemLocaleShortDate);
#else
locale().toString(QDateTime::fromMSecsSinceEpoch(point.x()), QLocale::ShortFormat);
#endif
}
if (y) {
if (ret.size() > 1) ret += " ; ";
@@ -1384,7 +1414,11 @@ void Graphic::drawGuides() {
if (!guides || !isHover) return;
int wid = canvas->width(), hei = canvas->height();
painter->setRenderHint(QPainter::Antialiasing, false);
painter->setPen(QPen(grid_pen.color(), qMax<int>(qRound(thick / 1.4), 1)));
QPen gpen(grid_pen.color(), qMax<int>(qRound(thick / 1.4), 1));
#if QT_VERSION_MAJOR >= 5
gpen.setCosmetic(true);
#endif
painter->setPen(gpen);
painter->resetTransform();
painter->setClipping(true);
painter->setClipRect(QRect(gridborder.x(), 0, wid - gridborder.x(), hei - gridborder.y()));
@@ -1640,7 +1674,7 @@ void Graphic::swapToBuffer() {
#ifdef HAS_GL
if (isOGL && canvas_gl) {
timg = canvas_gl->grabFrameBuffer();
QPainter p(buffer);
QPainter p(&buffer);
p.drawImage(0, 0, timg);
p.end();
}

View File

@@ -385,7 +385,7 @@ protected:
Ui::Graphic * ui;
UGLWidget * canvas_gl;
QWidget * canvas;
QImage * buffer;
QPixmap buffer;
QPainter * painter;
QBrush selbrush;
QPen grid_pen, selpen;

View File

@@ -1,6 +1,6 @@
if (((DEFINED QGLVIEW) AND QGLVIEW) OR (NOT DEFINED QGLVIEW))
find_package(OpenGL REQUIRED)
shstk_qad_project(qglview FALSE "qad" "Gui;OpenGL;Xml" "qad_widgets;qad_utils;${OPENGL_LIBRARIES}")
shstk_qad_project(qglview FALSE "qad" "Gui;OpenGL;OpenGLWidgets;Xml" "qad_widgets;qad_utils;${OPENGL_LIBRARIES}")
shstk_qad_install("qad" FALSE qglview "${out_HDR}" "${out_QM}")
qad_sources(test_SRC DIR "qglview_test")

View File

@@ -135,7 +135,7 @@ void GLParticlesSystem::draw(QOpenGLShaderProgram * prog, bool) {
for (int i = 0; i < particles.size(); ++i)
//particles[i].pos_h.setZ((particles[i].pos - apos).lengthSquared());
particles[i].pos_h.setZ(particles[i].pos.distanceToPlane(apos, dir));
qSort(particles.begin(), particles.end());
std::sort(particles.begin(), particles.end());
glBegin(GL_POINTS);
foreach (const Particle & i, particles) {
//glVertex3f(i.pos.x(), i.pos.y(), i.pos.z());

View File

@@ -223,15 +223,12 @@ GLObjectBase * loadFromDAEFile(const QString & filepath, float scale) {
qDebug() << "[Loader DAE] Error: can`t open \"" + filepath + "\"";
return nullptr;
}
QTime tm;
tm.restart();
QDomDocument dom(filepath);
if (!dom.setContent(&f)) {
qDebug() << "[Loader DAE] Error: can`t parse \"" + filepath + "\"";
return nullptr;
}
//qDebug() << "parse" << tm.elapsed();
tm.restart();
QDomElement maine = dom.firstChildElement("COLLADA");
bool fbx = maine.firstChildElement("asset").firstChildElement("contributor").firstChildElement("authoring_tool").firstChild().nodeValue().startsWith("FBX");
QVector<Material> materials = LoaderDAE::readMaterials(maine.firstChildElement("library_effects"),

View File

@@ -43,7 +43,10 @@ private slots:
typedef QPair<QMetaProperty, QVariant> PropertyValuePair;
Q_DECLARE_METATYPE (PropertyValuePair)
Q_DECLARE_METATYPE (QMetaProperty)
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
Q_DECLARE_METATYPE (QMetaProperty)
#endif
class PropertyEditor: public QTreeWidget {
Q_OBJECT

View File

@@ -17,6 +17,7 @@
*/
#include "qglview.h"
#include <qad_types.h>
#include <QApplication>
#include <QKeyEvent>
@@ -747,8 +748,14 @@ void QGLView::mouseMoveEvent(QMouseEvent * e) {
void QGLView::wheelEvent(QWheelEvent * e) {
if (mouseRotate_) {
if (e->delta() > 0) camera()->flyCloser(0.1f); //camera().pos.setZ(camera().pos.z() - 0.1 * camera().pos.z());
if (e->delta() < 0) camera()->flyFarer(0.1f); //camera().pos.setZ(camera().pos.z() + 0.1 * camera().pos.z());
double ang =
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
e->delta();
#else
e->angleDelta().y();
#endif
if (ang > 0) camera()->flyCloser(0.1f); //camera().pos.setZ(camera().pos.z() - 0.1 * camera().pos.z());
if (ang < 0) camera()->flyFarer(0.1f); //camera().pos.setZ(camera().pos.z() + 0.1 * camera().pos.z());
emit cameraPosChanged(camera()->pos());
}
emit glWheelEvent(e);
@@ -782,7 +789,7 @@ void QGLView::focusOutEvent(QFocusEvent *) {
void QGLView::mouseDoubleClickEvent(QMouseEvent * e) {
if (e->buttons().testFlag(Qt::MidButton))
if (e->buttons().testFlag(QT_MID_BUTTON))
emit doubleClick();
}

View File

@@ -24,6 +24,7 @@
#include "glprimitives.h"
#include "glparticles_system.h"
#include "glrendererbase.h"
#include <QElapsedTimer>
#include <QTime>
@@ -225,7 +226,7 @@ private:
QSet<int> keys_;
FogMode fogMode_;
QColor backColor_, fogColor_, ambientColor_, hoverHaloColor_, selectionHaloColor_;
QTime time, ktm_;
QElapsedTimer time, ktm_;
GLint max_anisotropic, max_texture_chanels;
GLObjectBase::RenderMode rmode;
GLObjectBase * sel_obj, * hov_obj;

View File

@@ -141,7 +141,12 @@ void TouchSlider::updateCaption() {
void TouchSlider::on_barPos_mouseMoveEvent(QMouseEvent * e) {
if (m_readOnly) return;
int tx = e->x();
int tx =
#if QT_VERSION_MAJOR <= 5
e->x();
#else
e->position().toPoint().x();
#endif
if (tx > ui->barPos->width()) tx = ui->barPos->width();
if (tx < 0) {
if (hasZero) {
@@ -161,7 +166,12 @@ void TouchSlider::on_barPos_mouseMoveEvent(QMouseEvent * e) {
void TouchSlider::on_barNeg_mouseMoveEvent(QMouseEvent * e) {
if (m_readOnly) return;
int tx = e->x();
int tx =
#if QT_VERSION_MAJOR <= 5
e->x();
#else
e->position().toPoint().x();
#endif
if (tx < 0) tx = 0;
if (tx > ui->barNeg->width()) {
int nx = tx - ui->barPos->width() - layout()->spacing();
@@ -179,14 +189,26 @@ void TouchSlider::on_barNeg_mouseMoveEvent(QMouseEvent * e) {
void TouchSlider::on_barPos_mousePressEvent(QMouseEvent * e) {
if (m_readOnly) return;
ui->barPos->setValue(ui->barPos->minimum() + qRound((double)(e->x() * (ui->barPos->maximum() - ui->barPos->minimum())) / (double)(ui->barPos->width())));
int tx =
#if QT_VERSION_MAJOR <= 5
e->x();
#else
e->position().toPoint().x();
#endif
ui->barPos->setValue(ui->barPos->minimum() + qRound((double)(tx * (ui->barPos->maximum() - ui->barPos->minimum())) / (double)(ui->barPos->width())));
ui->barNeg->setValue(ui->barNeg->minimum());
}
void TouchSlider::on_barNeg_mousePressEvent(QMouseEvent * e) {
if (m_readOnly) return;
ui->barNeg->setValue(ui->barNeg->maximum() - qRound((double)(e->x()*ui->barNeg->maximum()) / (double)(ui->barNeg->width())));
int tx =
#if QT_VERSION_MAJOR <= 5
e->x();
#else
e->position().toPoint().x();
#endif
ui->barNeg->setValue(ui->barNeg->maximum() - qRound((double)(tx * ui->barNeg->maximum()) / (double)(ui->barNeg->width())));
ui->barPos->setValue(ui->barPos->minimum());
}

View File

@@ -270,7 +270,11 @@ int fontHeight(const QWidget * w) {
qDebug() << s->logicalDotsPerInch() << s->logicalDotsPerInch()/96.*QApplication::font().pointSizeF();
}
}*/
return QFontMetrics(QApplication::font(), pw).size(0, "0").height();
return QFontMetrics(QApplication::font(), pw).size(0, "0").height()
#if QT_VERSION_MAJOR == 6
/ 1.25
#endif
;
}
}
# endif
@@ -310,3 +314,14 @@ void enableHighDPI() {
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true);
#endif
}
const QMetaObject * getQtMetaObject() {
#if QT_VERSION_MAJOR <= 5
return qt_getQtMetaObject();
#endif
#if QT_VERSION_MAJOR == 6
return &(Qt::staticMetaObject);
#endif
return nullptr;
}

View File

@@ -218,6 +218,7 @@ QAD_UTILS_EXPORT int lineThickness(const QWidget * w = 0);
QAD_UTILS_EXPORT QSize preferredIconSize(float x = 1.f, const QWidget * w = 0);
QAD_UTILS_EXPORT double appScale(const QWidget * w = 0);
QAD_UTILS_EXPORT void enableHighDPI();
QAD_UTILS_EXPORT const QMetaObject * getQtMetaObject();
#endif // QAD_TYPES_H

View File

@@ -41,7 +41,13 @@ void ColorButton::resizeEvent(QResizeEvent * ) {
void ColorButton::mousePressEvent(QMouseEvent * e) {
pp = e->pos();
if (e->buttons().testFlag(Qt::RightButton)) {
menu.popup(e->globalPos());
menu.popup(
#if QT_VERSION_MAJOR <= 5
((QMouseEvent*)e)->globalPos()
#else
((QMouseEvent*)e)->globalPosition().toPoint()
#endif
);
return;
}
QPushButton::mousePressEvent(e);