From 27d31eee19eb7594f2d18109a20c00fc2815554d Mon Sep 17 00:00:00 2001 From: Tobias Peters Date: Tue, 27 Aug 2024 17:30:37 +0000 Subject: [PATCH] move object viewer widget to qt5 and remove qt4 specifics --- nel/tools/3d/CMakeLists.txt | 2 +- .../3d/object_viewer_widget/CMakeLists.txt | 2 +- .../object_viewer_widget/src/CMakeLists.txt | 31 ++------- .../src/object_viewer_widget.cpp | 65 ------------------- .../src/object_viewer_widget.h | 14 ---- .../3d/object_viewer_widget/src/stdpch.h | 6 -- 6 files changed, 9 insertions(+), 111 deletions(-) diff --git a/nel/tools/3d/CMakeLists.txt b/nel/tools/3d/CMakeLists.txt index bad0382bf8..bb72259da7 100644 --- a/nel/tools/3d/CMakeLists.txt +++ b/nel/tools/3d/CMakeLists.txt @@ -70,10 +70,10 @@ IF(WITH_NEL_TOOLS AND WITH_3D) IF(WITH_QT OR WITH_QT5) ADD_SUBDIRECTORY(tile_edit_qt) - ADD_SUBDIRECTORY(object_viewer_widget) ENDIF() IF(WITH_QT5) + ADD_SUBDIRECTORY(object_viewer_widget) ADD_SUBDIRECTORY(shared_widgets) ADD_SUBDIRECTORY(panoply_preview) ENDIF() diff --git a/nel/tools/3d/object_viewer_widget/CMakeLists.txt b/nel/tools/3d/object_viewer_widget/CMakeLists.txt index 20e5b69e86..7561d30bb0 100644 --- a/nel/tools/3d/object_viewer_widget/CMakeLists.txt +++ b/nel/tools/3d/object_viewer_widget/CMakeLists.txt @@ -1,7 +1,7 @@ #----------------------------------------------------------------------------- # # Object Viewer Widget -# Copyright (C) 2010 Adrian Jäkel +# Copyright (C) 2010 Adrian Jäkel # #----------------------------------------------------------------------------- diff --git a/nel/tools/3d/object_viewer_widget/src/CMakeLists.txt b/nel/tools/3d/object_viewer_widget/src/CMakeLists.txt index 62df9e33fc..00a7d6ef64 100644 --- a/nel/tools/3d/object_viewer_widget/src/CMakeLists.txt +++ b/nel/tools/3d/object_viewer_widget/src/CMakeLists.txt @@ -1,30 +1,7 @@ -INCLUDE_DIRECTORIES( - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} - ${NEL_INCLUDE_DIR}) - FILE(GLOB OBJECT_VIEWER_WIDGET_SRC *.cpp *.h) SET(OBJECT_VIEWER_WIDGET_HDR object_viewer_widget.h) -IF(WITH_QT) - INCLUDE_DIRECTORIES(${QT_INCLUDES}) - INCLUDE(${QT_USE_FILE}) - - SET(QT_USE_QTGUI TRUE) - SET(QT_USE_QTOPENGL TRUE) - - QT4_WRAP_CPP(OBJECT_VIEWER_WIDGET_MOC_SRCS ${OBJECT_VIEWER_WIDGET_HDR}) - - ADD_DEFINITIONS(${QT_DEFINITIONS}) - ADD_DEFINITIONS(-DQT_NO_KEYWORDS) - ADD_DEFINITIONS(-DQT_PLUGIN) - ADD_DEFINITIONS(-DQT_SHARED) - #ADD_DEFINITIONS(-DQT_NO_DEBUG) - - SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_QTOPENGL_LIBRARY}) -ELSE() - QT5_WRAP_CPP(OBJECT_VIEWER_WIDGET_MOC_SRCS ${OBJECT_VIEWER_WIDGET_HDR}) -ENDIF() +QT5_WRAP_CPP(OBJECT_VIEWER_WIDGET_MOC_SRCS ${OBJECT_VIEWER_WIDGET_HDR}) SOURCE_GROUP(QtGeneratedMocSrc FILES ${OBJECT_VIEWER_WIDGET_MOC_SRCS}) @@ -38,6 +15,12 @@ ADD_LIBRARY(object_viewer_widget_qt ${TYPE} ${OBJECT_VIEWER_WIDGET_SRC} ${OBJECT_VIEWER_WIDGET_MOC_SRCS}) +TARGET_INCLUDE_DIRECTORIES(object_viewer_widget_qt + PUBLIC + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${NEL_INCLUDE_DIR}) + TARGET_LINK_LIBRARIES(object_viewer_widget_qt nelmisc nel3d diff --git a/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.cpp b/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.cpp index fbc379d957..f0e4cb9f2f 100644 --- a/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.cpp +++ b/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.cpp @@ -47,10 +47,6 @@ along with this program. If not, see . // Project includes -#ifndef USE_QT5 -Q_EXPORT_PLUGIN2(object_viewer_widget_qt, NLQT::CObjectViewerWidget) -#endif - #if defined(NL_OS_WINDOWS) typedef bool (*winProc)(NL3D::IDriver *driver, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); #elif defined(NL_OS_MAC) @@ -743,8 +739,6 @@ namespace NLQT _Scene->animate ( fdelta); } -#ifdef USE_QT5 - bool CObjectViewerWidget::nativeEvent(const QByteArray &eventType, void *message, long *result) { if (getDriver() && getDriver()->isActive()) @@ -770,63 +764,4 @@ namespace NLQT return false; } -#else - -#if defined(NL_OS_WINDOWS) - - bool CObjectViewerWidget::winEvent(MSG *message, long *result) - { - if (getDriver() && getDriver()->isActive()) - { - NL3D::IDriver *driver = dynamic_cast(getDriver())->getDriver(); - if (driver) - { - winProc proc = (winProc)driver->getWindowProc(); - return proc(driver, message->hwnd, message->message, message->wParam, message->lParam); - } - } - - return false; - } - -#elif defined(NL_OS_MAC) - - bool CObjectViewerWidget::macEvent(EventHandlerCallRef caller, EventRef event) - { - if(caller) - nlerror("You are using QtCarbon! Only QtCocoa supported, please upgrade Qt"); - - if (getDriver() && getDriver()->isActive()) - { - NL3D::IDriver *driver = dynamic_cast(getDriver())->getDriver(); - if (driver) - { - cocoaProc proc = (cocoaProc)driver->getWindowProc(); - return proc(driver, event); - } - } - - return false; - } - -#elif defined(NL_OS_UNIX) - - bool CObjectViewerWidget::x11Event(XEvent *event) - { - if (getDriver() && getDriver()->isActive()) - { - NL3D::IDriver *driver = dynamic_cast(getDriver())->getDriver(); - if (driver) - { - x11Proc proc = (x11Proc)driver->getWindowProc(); - return proc(driver, event); - } - } - - return false; - } -#endif - -#endif - } /* namespace NLQT */ diff --git a/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.h b/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.h index 91ed4cdeac..2845552b51 100644 --- a/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.h +++ b/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.h @@ -57,9 +57,7 @@ namespace NLQT public IObjectViewer { Q_OBJECT -#ifdef USE_QT5 Q_PLUGIN_METADATA(IID IObjectViewer_iid FILE "object_viewer.json") -#endif Q_INTERFACES(NLQT::IObjectViewer) public: @@ -169,19 +167,7 @@ namespace NLQT virtual QString name() const {return ("ObjectViewerWidget");} protected: -#ifdef USE_QT5 virtual bool nativeEvent(const QByteArray &eventType, void *message, long *result); -#else - -#if defined(NL_OS_WINDOWS) - virtual bool winEvent(MSG * message, long * result); -#elif defined(NL_OS_MAC) - virtual bool macEvent(EventHandlerCallRef caller, EventRef event); -#elif defined(NL_OS_UNIX) - virtual bool x11Event(XEvent *event); -#endif - -#endif private Q_SLOTS: void updateRender(); diff --git a/nel/tools/3d/object_viewer_widget/src/stdpch.h b/nel/tools/3d/object_viewer_widget/src/stdpch.h index d1dd781d7e..0eb46ba74e 100644 --- a/nel/tools/3d/object_viewer_widget/src/stdpch.h +++ b/nel/tools/3d/object_viewer_widget/src/stdpch.h @@ -32,14 +32,8 @@ along with this program. If not, see . #include #include -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) -#define USE_QT5 -#endif - -#ifdef USE_QT5 #include #include -#endif #include #include