From ba81d0ad85191e38e10c4af89b223a45014d1e3e Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 6 Jan 2016 12:29:34 +0100 Subject: [PATCH] Fixed: Compilation of tile_edit_qt with Qt 5 --- code/nel/tools/3d/tile_edit_qt/CMakeLists.txt | 33 +++++++---- .../tools/3d/tile_edit_qt/browser_model.cpp | 16 +----- code/nel/tools/3d/tile_edit_qt/common.cpp | 17 ++++++ code/nel/tools/3d/tile_edit_qt/common.h | 56 +++++++++++++++++++ .../tools/3d/tile_edit_qt/items_edit_dlg.cpp | 1 + .../tools/3d/tile_edit_qt/items_edit_dlg.h | 2 - code/nel/tools/3d/tile_edit_qt/main.cpp | 17 +++++- .../3d/tile_edit_qt/tile_browser_dlg.cpp | 20 ++----- .../tools/3d/tile_edit_qt/tile_browser_dlg.h | 4 -- .../tools/3d/tile_edit_qt/tile_edit_dlg.cpp | 9 +-- .../nel/tools/3d/tile_edit_qt/tile_edit_dlg.h | 2 - .../3d/tile_edit_qt/tile_listwidgetitem.cpp | 1 + .../3d/tile_edit_qt/tile_rotation_dlg.cpp | 1 + .../tools/3d/tile_edit_qt/tile_rotation_dlg.h | 4 -- .../nel/tools/3d/tile_edit_qt/tile_widget.cpp | 1 + code/nel/tools/3d/tile_edit_qt/tile_widget.h | 1 - .../nel/tools/3d/tile_edit_qt/tiles_model.cpp | 8 +-- code/nel/tools/3d/tile_edit_qt/tiles_model.h | 9 --- 18 files changed, 126 insertions(+), 76 deletions(-) create mode 100644 code/nel/tools/3d/tile_edit_qt/common.cpp create mode 100644 code/nel/tools/3d/tile_edit_qt/common.h diff --git a/code/nel/tools/3d/tile_edit_qt/CMakeLists.txt b/code/nel/tools/3d/tile_edit_qt/CMakeLists.txt index 18ced90ed..0fd5e72a0 100644 --- a/code/nel/tools/3d/tile_edit_qt/CMakeLists.txt +++ b/code/nel/tools/3d/tile_edit_qt/CMakeLists.txt @@ -1,8 +1,4 @@ -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${QT_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR}/pic) -INCLUDE( ${QT_USE_FILE} ) - -FIND_PACKAGE(JPEG) -INCLUDE_DIRECTORIES(${JPEG_INCLUDE_DIR}) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) FILE(GLOB TILE_EDIT_SRC *.cpp *.h) FILE(GLOB PIC_SRC pic/*.c pic/*.cpp) @@ -10,22 +6,35 @@ SET(TILE_EDIT_HDR items_edit_dlg.h tile_browser_dlg.h tile_edit_dlg.h tile_rotat SET(TILE_EDIT_UIS tile_widget_qt.ui tile_rotation_qt.ui tile_edit_qt.ui tile_browser_qt.ui items_edit_qt.ui) SET(TILE_EDIT_RCS tile_edit_qt.qrc) -QT4_ADD_RESOURCES( TILE_EDIT_RC_SRCS ${TILE_EDIT_RCS} ) -QT4_WRAP_UI( TILE_EDIT_UI_HDRS ${TILE_EDIT_UIS} ) -QT4_WRAP_CPP( TILE_EDIT_MOC_SRCS ${TILE_EDIT_HDR}) +IF(WITH_QT) + INCLUDE_DIRECTORIES(${QT_INCLUDES}) + INCLUDE(${QT_USE_FILE}) + + QT4_ADD_RESOURCES(TILE_EDIT_RC_SRCS ${TILE_EDIT_RCS}) + QT4_WRAP_UI(TILE_EDIT_UI_HDRS ${TILE_EDIT_UIS}) + QT4_WRAP_CPP(TILE_EDIT_MOC_SRCS ${TILE_EDIT_HDR}) + + ADD_DEFINITIONS(${QT_DEFINITIONS}) +ELSEIF(WITH_QT5) + QT5_ADD_RESOURCES(TILE_EDIT_RC_SRCS ${TILE_EDIT_RCS}) + QT5_WRAP_UI(TILE_EDIT_UI_HDRS ${TILE_EDIT_UIS}) + QT5_WRAP_CPP(TILE_EDIT_MOC_SRCS ${TILE_EDIT_HDR}) +ENDIF() + SOURCE_GROUP(QtResources FILES ${TILE_EDIT_UIS} ${TILE_EDIT_RCS}) SOURCE_GROUP(QtGeneratedUiHdr FILES ${TILE_EDIT_UI_HDRS}) SOURCE_GROUP(QtGeneratedMocSrc FILES ${TILE_EDIT_MOC_SRCS}) -SOURCE_GROUP(PICLibrary FILES ${PIC_SRC}) -ADD_EXECUTABLE(tile_edit_qt ${TILE_EDIT_SRC} ${PIC_SRC} ${TILE_EDIT_MOC_SRCS} ${TILE_EDIT_RC_SRCS} ${TILE_EDIT_UI_HDRS}) +ADD_EXECUTABLE(tile_edit_qt WIN32 ${TILE_EDIT_SRC} ${TILE_EDIT_MOC_SRCS} ${TILE_EDIT_RC_SRCS} ${TILE_EDIT_UI_HDRS}) -TARGET_LINK_LIBRARIES(tile_edit_qt ${QT_LIBRARIES} ${JPEG_LIBRARY} nelmisc nel3d) +TARGET_LINK_LIBRARIES(tile_edit_qt ${QT_LIBRARIES} nelmisc nel3d) NL_DEFAULT_PROPS(tile_edit_qt "NeL, Tools, 3D: Qt Tile Editor") NL_ADD_RUNTIME_FLAGS(tile_edit_qt) -ADD_DEFINITIONS(${QT_DEFINITIONS}) +IF(WITH_PCH) + ADD_NATIVE_PRECOMPILED_HEADER(tile_edit_qt ${CMAKE_CURRENT_SOURCE_DIR}/common.h ${CMAKE_CURRENT_SOURCE_DIR}/common.cpp) +ENDIF() INSTALL(TARGETS tile_edit_qt RUNTIME DESTINATION ${NL_BIN_PREFIX} COMPONENT tools3d) diff --git a/code/nel/tools/3d/tile_edit_qt/browser_model.cpp b/code/nel/tools/3d/tile_edit_qt/browser_model.cpp index 6b22e2f8e..bd26eb791 100644 --- a/code/nel/tools/3d/tile_edit_qt/browser_model.cpp +++ b/code/nel/tools/3d/tile_edit_qt/browser_model.cpp @@ -14,19 +14,9 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include +#include "common.h" #include "browser_model.h" -#include - -#include -#include -#include - -#include - -#include "pic/readpic.h" - using namespace std; using namespace NL3D; using namespace NLMISC; @@ -272,8 +262,8 @@ int TileList::addTile256 () bool TileList::setTile128 (int tile, const std::string& name, NL3D::CTile::TBitmap type) { // Remove the absolute path from the path name - std::string troncated=name; - if (RemovePath (troncated, tileBankBrowser.getAbsPath ().c_str())) + std::string troncated = name; + if (RemovePath(troncated, tileBankBrowser.getAbsPath ().c_str())) { vector tampon; uint Width; diff --git a/code/nel/tools/3d/tile_edit_qt/common.cpp b/code/nel/tools/3d/tile_edit_qt/common.cpp new file mode 100644 index 000000000..e415c3f6f --- /dev/null +++ b/code/nel/tools/3d/tile_edit_qt/common.cpp @@ -0,0 +1,17 @@ +// NeL - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include "common.h" diff --git a/code/nel/tools/3d/tile_edit_qt/common.h b/code/nel/tools/3d/tile_edit_qt/common.h new file mode 100644 index 000000000..685195251 --- /dev/null +++ b/code/nel/tools/3d/tile_edit_qt/common.h @@ -0,0 +1,56 @@ +// NeL - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef COMMON_H +#define COMMON_H + +#if defined(_MSC_VER) && defined(_DEBUG) + #define _CRTDBG_MAP_ALLOC + #include + #include + #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) + #undef realloc + #undef free +#endif + +#include + +#ifdef Q_COMPILER_RVALUE_REFS +#undef Q_COMPILER_RVALUE_REFS +#endif + +#include +#include + +#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#define USE_QT5 +#endif + +#ifdef USE_QT5 +#include +#include +#endif + +#include + +#include +#include +#include +#include +#include +#include + +#endif diff --git a/code/nel/tools/3d/tile_edit_qt/items_edit_dlg.cpp b/code/nel/tools/3d/tile_edit_qt/items_edit_dlg.cpp index 3fd9d3350..0ac2f2eda 100644 --- a/code/nel/tools/3d/tile_edit_qt/items_edit_dlg.cpp +++ b/code/nel/tools/3d/tile_edit_qt/items_edit_dlg.cpp @@ -1,3 +1,4 @@ +#include "common.h" #include #include #include "items_edit_dlg.h" diff --git a/code/nel/tools/3d/tile_edit_qt/items_edit_dlg.h b/code/nel/tools/3d/tile_edit_qt/items_edit_dlg.h index 0f65bcef5..73ed5b0b8 100644 --- a/code/nel/tools/3d/tile_edit_qt/items_edit_dlg.h +++ b/code/nel/tools/3d/tile_edit_qt/items_edit_dlg.h @@ -1,8 +1,6 @@ #ifndef ITEMS_EDITDLG_H #define ITEMS_EDITDLG_H -#include -#include #include "ui_items_edit_qt.h" class CItems_edit_dlg : public QDialog diff --git a/code/nel/tools/3d/tile_edit_qt/main.cpp b/code/nel/tools/3d/tile_edit_qt/main.cpp index 2f3d51012..4a6ff4cbf 100644 --- a/code/nel/tools/3d/tile_edit_qt/main.cpp +++ b/code/nel/tools/3d/tile_edit_qt/main.cpp @@ -1,7 +1,20 @@ -#include -#include "nel/misc/app_context.h" +#include "common.h" + #include "tile_edit_dlg.h" +#ifdef QT_STATICPLUGIN + +#include + +#if defined(Q_OS_WIN32) + Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin) +#elif defined(Q_OS_MAC) + Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin) +#elif defined(Q_OS_UNIX) + Q_IMPORT_PLUGIN(QXcbIntegrationPlugin) +#endif + +#endif int main(int argc, char *argv[]) { diff --git a/code/nel/tools/3d/tile_edit_qt/tile_browser_dlg.cpp b/code/nel/tools/3d/tile_edit_qt/tile_browser_dlg.cpp index 037ac65e8..d73a9a969 100644 --- a/code/nel/tools/3d/tile_edit_qt/tile_browser_dlg.cpp +++ b/code/nel/tools/3d/tile_edit_qt/tile_browser_dlg.cpp @@ -14,18 +14,8 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include -#include -#include -#include -#include -#include -#include -#include "nel/3d/tile_bank.h" -#include "nel/misc/bitmap.h" -#include "nel/misc/file.h" -#include "pic/readpic.h" -#include "pic/pic.h" +#include "common.h" + #include "tile_browser_dlg.h" #include "tile_rotation_dlg.h" @@ -109,10 +99,10 @@ void CTile_browser_dlg::initDialog(const int& tileSetIndex) tileZoomButtonGroup->button(settings.value("browser/TileZoom").toInt())->setChecked(true); //GroupBox checkedIdChanged subscription - connect(tileTypeButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(on_tileTypeButtonGroup_clicked(int))); + connect(tileTypeButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(on_tileTypeButtonGroup_clicked(int))); connect(tileTextureButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(on_tileTextureButtonGroup_clicked(int))); - connect(tileLabelButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(on_tileLabelButtonGroup_clicked(int))); - connect(tileZoomButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(on_tileZoomButtonGroup_clicked(int))); + connect(tileLabelButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(on_tileLabelButtonGroup_clicked(int))); + connect(tileZoomButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(on_tileZoomButtonGroup_clicked(int))); //Tile View Model tileViewModel = new tiles_model(this); diff --git a/code/nel/tools/3d/tile_edit_qt/tile_browser_dlg.h b/code/nel/tools/3d/tile_edit_qt/tile_browser_dlg.h index bfb45722c..b25bc4279 100644 --- a/code/nel/tools/3d/tile_edit_qt/tile_browser_dlg.h +++ b/code/nel/tools/3d/tile_edit_qt/tile_browser_dlg.h @@ -17,14 +17,10 @@ #ifndef TILE_BROWSERDLG_H #define TILE_BROWSERDLG_H -#include -#include -#include #include "ui_tile_browser_qt.h" #include "tiles_model.h" #include "browser_model.h" - class CTile_browser_dlg : public QDialog { Q_OBJECT diff --git a/code/nel/tools/3d/tile_edit_qt/tile_edit_dlg.cpp b/code/nel/tools/3d/tile_edit_qt/tile_edit_dlg.cpp index 595067cd2..2b6612e9c 100644 --- a/code/nel/tools/3d/tile_edit_qt/tile_edit_dlg.cpp +++ b/code/nel/tools/3d/tile_edit_qt/tile_edit_dlg.cpp @@ -14,14 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include -#include -#include -#include -#include -#include -#include -#include +#include "common.h" #include "tile_edit_dlg.h" #include "items_edit_dlg.h" #include "tile_browser_dlg.h" diff --git a/code/nel/tools/3d/tile_edit_qt/tile_edit_dlg.h b/code/nel/tools/3d/tile_edit_qt/tile_edit_dlg.h index 97d0dd760..88c32bd05 100644 --- a/code/nel/tools/3d/tile_edit_qt/tile_edit_dlg.h +++ b/code/nel/tools/3d/tile_edit_qt/tile_edit_dlg.h @@ -17,8 +17,6 @@ #ifndef TILE_EDITDLG_H #define TILE_EDITDLG_H -#include -#include #include "ui_tile_edit_qt.h" class QCheckBox; diff --git a/code/nel/tools/3d/tile_edit_qt/tile_listwidgetitem.cpp b/code/nel/tools/3d/tile_edit_qt/tile_listwidgetitem.cpp index 475b9da73..9b70e4c24 100644 --- a/code/nel/tools/3d/tile_edit_qt/tile_listwidgetitem.cpp +++ b/code/nel/tools/3d/tile_edit_qt/tile_listwidgetitem.cpp @@ -14,6 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +#include "common.h" #include "tile_listwidgetitem.h" //tile_listwidgetitem::tile_listwidgetitem(void) diff --git a/code/nel/tools/3d/tile_edit_qt/tile_rotation_dlg.cpp b/code/nel/tools/3d/tile_edit_qt/tile_rotation_dlg.cpp index c053bab8e..a1d4a2786 100644 --- a/code/nel/tools/3d/tile_edit_qt/tile_rotation_dlg.cpp +++ b/code/nel/tools/3d/tile_edit_qt/tile_rotation_dlg.cpp @@ -14,6 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +#include "common.h" #include "tile_rotation_dlg.h" CTile_rotation_dlg::CTile_rotation_dlg(QWidget *parent, Qt::WindowFlags flags) diff --git a/code/nel/tools/3d/tile_edit_qt/tile_rotation_dlg.h b/code/nel/tools/3d/tile_edit_qt/tile_rotation_dlg.h index 1891873a5..852aa17ad 100644 --- a/code/nel/tools/3d/tile_edit_qt/tile_rotation_dlg.h +++ b/code/nel/tools/3d/tile_edit_qt/tile_rotation_dlg.h @@ -17,10 +17,6 @@ #ifndef TILE_ROTATIONDLG_H #define TILE_ROTATIONDLG_H - -#include -#include -#include #include "ui_tile_rotation_qt.h" class CTile_rotation_dlg : public QDialog diff --git a/code/nel/tools/3d/tile_edit_qt/tile_widget.cpp b/code/nel/tools/3d/tile_edit_qt/tile_widget.cpp index bd4a58b8c..d789e45c2 100644 --- a/code/nel/tools/3d/tile_edit_qt/tile_widget.cpp +++ b/code/nel/tools/3d/tile_edit_qt/tile_widget.cpp @@ -1,3 +1,4 @@ +#include "common.h" #include #include "tile_widget.h" diff --git a/code/nel/tools/3d/tile_edit_qt/tile_widget.h b/code/nel/tools/3d/tile_edit_qt/tile_widget.h index e0ca41d10..994c4b8f4 100644 --- a/code/nel/tools/3d/tile_edit_qt/tile_widget.h +++ b/code/nel/tools/3d/tile_edit_qt/tile_widget.h @@ -1,7 +1,6 @@ #ifndef TILE_WIDGET_H #define TILE_WIDGET_H -#include #include "tiles_model.h" #include "ui_tile_widget_qt.h" diff --git a/code/nel/tools/3d/tile_edit_qt/tiles_model.cpp b/code/nel/tools/3d/tile_edit_qt/tiles_model.cpp index 252b39298..cbe6e05a1 100644 --- a/code/nel/tools/3d/tile_edit_qt/tiles_model.cpp +++ b/code/nel/tools/3d/tile_edit_qt/tiles_model.cpp @@ -14,6 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +#include "common.h" #include #include "tiles_model.h" #include "tile_widget.h" @@ -57,10 +58,9 @@ QVariant tiles_model::data(const QModelIndex &index, int role) const if (role == Qt::DecorationRole || role == Qt::UserRole) { - CTile_Widget* wiwi = new CTile_Widget; - wiwi->initWidget( tiles.value(index.row()).getPixmap(), tiles.value(index.row()).getPixmapSide(), tiles.value(index.row()).getTileLabel() ); - QPixmap pixpix = QPixmap::grabWidget(wiwi, wiwi->contentsRect()); - delete wiwi; + CTile_Widget wiwi; + wiwi.initWidget(tiles.value(index.row()).getPixmap(), tiles.value(index.row()).getPixmapSide(), tiles.value(index.row()).getTileLabel()); + QPixmap pixpix = wiwi.grab(wiwi.contentsRect()); return pixpix; } else if (role == Qt::UserRole + 1) diff --git a/code/nel/tools/3d/tile_edit_qt/tiles_model.h b/code/nel/tools/3d/tile_edit_qt/tiles_model.h index b224adf3b..57aee8687 100644 --- a/code/nel/tools/3d/tile_edit_qt/tiles_model.h +++ b/code/nel/tools/3d/tile_edit_qt/tiles_model.h @@ -1,15 +1,6 @@ #ifndef TILESMODEL_H #define TILESMODEL_H -#include -#include -#include -#include -#include -#include -#include -#include - class TileModel {