diff --git a/src/Mod/Sandbox/App/AppSandbox.cpp b/src/Mod/Sandbox/App/AppSandbox.cpp index 37b569ce65..4618589aa8 100644 --- a/src/Mod/Sandbox/App/AppSandbox.cpp +++ b/src/Mod/Sandbox/App/AppSandbox.cpp @@ -146,7 +146,7 @@ public: return genericSetAttro( name_, value ); } } - virtual int sequence_length() + virtual PyCxx_ssize_t sequence_length() { // len(x) return m_array.size(); diff --git a/src/Mod/Sandbox/App/DocumentThread.cpp b/src/Mod/Sandbox/App/DocumentThread.cpp index ecec31d779..b1a68a867f 100644 --- a/src/Mod/Sandbox/App/DocumentThread.cpp +++ b/src/Mod/Sandbox/App/DocumentThread.cpp @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -88,7 +89,7 @@ void WorkerThread::run() // -------------------------------------- -QMutex PythonThread::mutex(QMutex::Recursive); +QRecursiveMutex PythonThread::mutex; PythonThread::PythonThread(QObject* parent) : QThread(parent) diff --git a/src/Mod/Sandbox/App/DocumentThread.h b/src/Mod/Sandbox/App/DocumentThread.h index b8329c38c8..aa607d86a2 100644 --- a/src/Mod/Sandbox/App/DocumentThread.h +++ b/src/Mod/Sandbox/App/DocumentThread.h @@ -25,7 +25,7 @@ #define SANDBOX_DOCUMENTTHREAD_H #include -#include +#include #include #include @@ -63,7 +63,7 @@ public: protected: void run(); - static QMutex mutex; + static QRecursiveMutex mutex; }; class SandboxAppExport MeshLoaderThread : public QThread diff --git a/src/Mod/Sandbox/Gui/CMakeLists.txt b/src/Mod/Sandbox/Gui/CMakeLists.txt index 0af92b6efd..4476da5eaf 100644 --- a/src/Mod/Sandbox/Gui/CMakeLists.txt +++ b/src/Mod/Sandbox/Gui/CMakeLists.txt @@ -37,14 +37,7 @@ set(SandboxGui_MOC_HDRS GLGraphicsView.h ) -fc_wrap_cpp(SandboxGui_MOC_SRCS ${SandboxGui_MOC_HDRS}) -SOURCE_GROUP("Moc" FILES ${SandboxGui_MOC_SRCS}) - -if(BUILD_QT5) - qt5_add_resources(Resource_SRCS Resources/Sandbox.qrc) -else() - qt6_add_resources(Resource_SRCS Resources/Sandbox.qrc) -endif() +qt_add_resources(Resource_SRCS Resources/Sandbox.qrc) SET(Resource_SRCS ${Resource_SRCS} Resources/Sandbox.qrc diff --git a/src/Mod/Sandbox/Gui/Command.cpp b/src/Mod/Sandbox/Gui/Command.cpp index 0f034ec871..5709af9019 100644 --- a/src/Mod/Sandbox/Gui/Command.cpp +++ b/src/Mod/Sandbox/Gui/Command.cpp @@ -68,6 +68,7 @@ #include #include #include +#include #include #include #include @@ -933,7 +934,7 @@ void CmdTestGrabWidget::activated(int) { QCalendarWidget* c = new QCalendarWidget(); c->hide(); - QPixmap p = QPixmap::grabWidget(c, c->rect()); + QPixmap p = c->grab(c->rect()); QLabel* label = new QLabel(); label->resize(c->size()); label->setPixmap(p); @@ -1055,7 +1056,7 @@ void CmdTestImageNode::activated(int) QString text = QString::fromLatin1("Distance: 2.7jgiorjgor84mm"); QFont font; QFontMetrics fm(font); - int w = fm.width(text); + int w = Gui::QtTools::horizontalAdvance(fm, text); int h = fm.height(); diff --git a/src/Mod/Sandbox/Gui/GLGraphicsView.cpp b/src/Mod/Sandbox/Gui/GLGraphicsView.cpp index b3ee4eb1ac..6cae14de5f 100644 --- a/src/Mod/Sandbox/Gui/GLGraphicsView.cpp +++ b/src/Mod/Sandbox/Gui/GLGraphicsView.cpp @@ -48,7 +48,6 @@ #include #include #include -#include #include #include #include @@ -57,6 +56,7 @@ #include #include "GLGraphicsView.h" +#include #include #include @@ -239,10 +239,12 @@ SceneEventFilter::eventFilter(QObject *, QEvent * qevent) } case QEvent::GraphicsSceneWheel: { +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) QGraphicsSceneWheelEvent* ev = static_cast(qevent); sceneev.reset(new QWheelEvent(ev->pos().toPoint(), ev->delta(), ev->buttons(), ev->modifiers(), ev->orientation())); qevent = sceneev.get(); +#endif break; } case QEvent::GraphicsSceneResize: @@ -351,7 +353,9 @@ GraphicsScene::GraphicsScene() pos += QPointF(0, 10 + rect.height()); } +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) m_time.start(); +#endif sorendermanager = new SoRenderManager; sorendermanager->setAutoClipping(SoRenderManager::VARIABLE_NEAR_PLANE); @@ -572,14 +576,18 @@ void GraphicsScene::drawBackground(QPainter *painter, const QRectF &) return; } +#if 0 glViewport(0, 0, width(), height()); /**/ glClearColor(m_backgroundColor.redF(), m_backgroundColor.greenF(), m_backgroundColor.blueF(), 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); +#endif +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) const int delta = m_time.elapsed() - m_lastTime; m_lastTime += delta; +#endif sorendermanager->render(true/*PRIVATE(this)->clearwindow*/, @@ -625,7 +633,9 @@ void GraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *event) if (event->isAccepted()) return; +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) m_mouseEventTime = m_time.elapsed(); +#endif event->accept(); } @@ -654,10 +664,12 @@ GraphicsView3D::GraphicsView3D(Gui::Document* doc, QWidget* parent) : Gui::MDIView(doc, parent), m_scene(new GraphicsScene()), m_view(new GraphicsView) { m_view->installEventFilter(m_scene->getEventFilter()); - QGLFormat f; +#if 0 + QtGLFormat f; f.setSampleBuffers(true); f.setSamples(8); m_view->setViewport(new QGLWidget(f)); +#endif m_view->setViewportUpdateMode(QGraphicsView::FullViewportUpdate); m_view->setScene(m_scene); m_scene->setNavigationModeFile(QUrl(QString::fromLatin1("coin:///scxml/navigation/examiner.xml"))); @@ -698,5 +710,4 @@ void GraphicsView3D::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::M m_scene->setBackgroundColor(QColor::fromRgbF(r1, g1, b1)); } } - #include "moc_GLGraphicsView.cpp" diff --git a/src/Mod/Sandbox/Gui/Overlay.cpp b/src/Mod/Sandbox/Gui/Overlay.cpp index e7fa9e8f7c..61ca950f4d 100644 --- a/src/Mod/Sandbox/Gui/Overlay.cpp +++ b/src/Mod/Sandbox/Gui/Overlay.cpp @@ -63,20 +63,11 @@ public: p.drawText(200,200,QString::fromLatin1("Render to QImage")); } -#if !defined(HAVE_QT5_OPENGL) - img = QtGLWidget::convertToGLFormat(img); -#endif fbo = new QtGLFramebufferObject(v->getGLWidget()->size()); fbo->bind(); //glClear(GL_COLOR_BUFFER_BIT); fbo->release(); { -#if !defined(HAVE_QT5_OPENGL) - QPainter p(fbo); - p.setPen(Qt::white); - p.drawText(200,200,QString::fromLatin1("Render to QtGLFramebufferObject")); - p.end(); -#endif //img = fbo->toImage(); //img = QtGLWidget::convertToGLFormat(img); } @@ -626,18 +617,6 @@ void DrawingPlane::drawLineTo(const QPoint &endPoint) { Q_UNUSED(endPoint); return; -#if !defined(HAVE_QT5_OPENGL) - QPainter painter(fbo); - //QPainter painter(_pcView3D->getGLWidget()); - painter.setPen(QPen(myPenColor, myPenWidth, Qt::SolidLine, Qt::RoundCap, - Qt::RoundJoin)); - //painter.setOpacity(0.5); - //painter.drawLine(lastPoint.x(), fbo->height()-lastPoint.y(), endPoint.x(), fbo->height()-endPoint.y()); - painter.drawLine(lastPoint.x(), lastPoint.y(), endPoint.x(), endPoint.y()); - - //_pcView3D->scheduleRedraw(); - lastPoint = endPoint; -#endif } //Gui::Document* doc = Gui::Application::Instance->activeDocument(); //Gui::View3DInventorViewer* view = static_cast(doc->getActiveView())->getViewer(); diff --git a/src/Mod/Sandbox/Gui/TaskPanelView.cpp b/src/Mod/Sandbox/Gui/TaskPanelView.cpp index ad2e78b1ad..10ac3b1f5c 100644 --- a/src/Mod/Sandbox/Gui/TaskPanelView.cpp +++ b/src/Mod/Sandbox/Gui/TaskPanelView.cpp @@ -364,8 +364,6 @@ public: Q_UNUSED(MainWindow); } // retranslateUi }; -#else -#include #endif TaskPanelView::TaskPanelView(QWidget *parent) @@ -580,96 +578,6 @@ TaskPanelView::TaskPanelView(QWidget *parent) connect(ui->rbAndroidScheme, SIGNAL(toggled(bool)), androidAction, SIGNAL(toggled(bool))); func->toggle(androidAction, boost::bind(&TaskPanelView::on_rbAndroidScheme_toggled, this, bp::_1)); } -#else - setWindowTitle(QLatin1String("Task View")); - - QGridLayout* gridLayout = new QGridLayout(this); - iisTaskPanel *taskPanel = new iisTaskPanel(this); - iisTaskBox *tb1 = new iisTaskBox( - QPixmap(QString::fromLatin1(":/icons/document-save.svg")),QLatin1String("Expandable Group"),true, this); - taskPanel->addWidget(tb1); - gridLayout->addWidget(taskPanel, 0, 0, 2, 1); - - iisIconLabel *i1 = new iisIconLabel( - Gui::BitmapFactory().iconFromTheme("document-new"), QLatin1String("Create new file"), tb1); - tb1->addIconLabel(i1); - connect(i1, SIGNAL(activated()), action, SIGNAL(triggered())); - - iisIconLabel *i2 = new iisIconLabel( - Gui::BitmapFactory().iconFromTheme("document-open"), QLatin1String("Load a file"), tb1); - tb1->addIconLabel(i2); - connect(i2, SIGNAL(activated()), action, SIGNAL(triggered())); - - tb1->groupLayout()->addWidget(new QPushButton(QLatin1String("Just a button"), this)); - - iisIconLabel *i3 = new iisIconLabel( - Gui::BitmapFactory().iconFromTheme("document-save"), QLatin1String("Save current file"), tb1); - tb1->addIconLabel(i3); - - iisIconLabel *i4 = new iisIconLabel( - Gui::BitmapFactory().iconFromTheme("document-print"), QLatin1String("Print file contents"), tb1); - tb1->addIconLabel(i4); - i4->setColors(Qt::red, Qt::green, Qt::gray); - i4->setFocusPen(QPen()); - - tb1->groupLayout()->addWidget(new QPushButton(QLatin1String("Just another button"), this)); - - iisTaskBox *tb2 = new iisTaskBox( - Gui::BitmapFactory().pixmap("edit-redo"), QLatin1String("Non-expandable Group"), false, this); - taskPanel->addWidget(tb2); - - iisIconLabel *i21 = new iisIconLabel( - Gui::BitmapFactory().iconFromTheme("document-new"), QLatin1String("Create new file"), tb2); - tb2->addIconLabel(i21); - - iisIconLabel *i22 = new iisIconLabel( - Gui::BitmapFactory().iconFromTheme("document-open"), QLatin1String("Load a file"), tb2); - tb2->addIconLabel(i22); - - iisIconLabel *i23 = new iisIconLabel( - Gui::BitmapFactory().iconFromTheme("document-save"), QLatin1String("Save current file"), tb2); - tb2->addIconLabel(i23); - i23->setEnabled(false); - - iisIconLabel *i24 = new iisIconLabel( - Gui::BitmapFactory().iconFromTheme("document-print"), QLatin1String("Print file contents"), tb2); - tb2->addIconLabel(i24); - - - // Other widgets can be also added to the panel - QLabel *l1 = new QLabel(QLatin1String("Action Group without header"), this); - taskPanel->addWidget(l1); - - iisTaskGroup *tb3 = new iisTaskGroup(this); - taskPanel->addWidget(tb3); - - iisIconLabel *i31 = new iisIconLabel( - Gui::BitmapFactory().iconFromTheme("document-new"), QLatin1String("Create new file"), tb3); - tb3->addIconLabel(i31); - - QHBoxLayout *hb3 = new QHBoxLayout(); - tb3->groupLayout()->addLayout(hb3); - - iisIconLabel *i32 = new iisIconLabel( - Gui::BitmapFactory().iconFromTheme("document-open"), QLatin1String("Load a file"), tb3); - tb3->addIconLabel(i32); - hb3->addWidget(i32); - - iisIconLabel *i33 = new iisIconLabel( - Gui::BitmapFactory().iconFromTheme("document-save"), QLatin1String("Save current file"), tb3); - tb3->addIconLabel(i33); - i33->setDisabled(true); - hb3->addWidget(i33); - - iisIconLabel *i34 = new iisIconLabel( - Gui::BitmapFactory().iconFromTheme("document-print"), QLatin1String("Print file contents"), tb3); - tb3->addIconLabel(i34); - - taskPanel->addStretch(); - taskPanel->setScheme(iisWinXPTaskPanelScheme::defaultScheme()); - tb1->setScheme(iisWinXPTaskPanelScheme::defaultScheme()); - tb2->setScheme(iisWinXPTaskPanelScheme2::defaultScheme()); - tb3->setScheme(iisTaskPanelScheme::defaultScheme()); #endif } diff --git a/src/Mod/Sandbox/Gui/Workbench.cpp b/src/Mod/Sandbox/Gui/Workbench.cpp index 11a9fb9e61..baae5e1508 100644 --- a/src/Mod/Sandbox/Gui/Workbench.cpp +++ b/src/Mod/Sandbox/Gui/Workbench.cpp @@ -37,6 +37,7 @@ #include #include "Workbench.h" +#include #include #include #include @@ -61,7 +62,7 @@ Workbench::Workbench() QGridLayout* pLayout = new QGridLayout(tree); pLayout->setSpacing(0); - pLayout->setMargin (0); + pLayout->setContentsMargins(0, 0, 0, 0); pLayout->addWidget(treeWidget, 0, 0); tree->setObjectName @@ -159,8 +160,7 @@ void SoWidgetShape::GLRender(SoGLRenderAction * /*action*/) #if defined(HAVE_QT5_OPENGL) this->image = QPixmap::grabWidget(w, w->rect()).toImage(); #else - this->image = QPixmap::grabWidget(w, w->rect()).toImage(); - this->image = QtGLWidget::convertToGLFormat(this->image); + this->image = w->grab(w->rect()).toImage(); #endif glRasterPos2d(10,10); glDrawPixels(this->image.width(),this->image.height(),GL_RGBA,GL_UNSIGNED_BYTE,this->image.bits()); @@ -285,7 +285,6 @@ void SoWidgetShape::setWidget(QWidget* w) this->image = img.toImage(); #if !defined(HAVE_QT5_OPENGL) - this->image = QPixmap::grabWidget(w, w->rect()).toImage(); - this->image = QtGLWidget::convertToGLFormat(this->image); + this->image = w->grab(w->rect()).toImage(); #endif }