diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 071554e06..85a2ad670 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -142,6 +142,11 @@ IF(WITH_QT) FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui QtXml QtOpenGL REQUIRED) ENDIF(WITH_QT) +IF(WITH_QT5) + CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11 FATAL_ERROR) + FIND_PACKAGE(Qt5Widgets) +ENDIF(WITH_QT5) + IF(WITH_NEL) IF(WITH_NEL_TESTS) FIND_PACKAGE(CppTest) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index 0474c7d7b..0c13f8cb9 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -265,7 +265,8 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS) # GUI toolkits ### OPTION(WITH_GTK "With GTK Support" OFF) - OPTION(WITH_QT "With QT Support" OFF) + OPTION(WITH_QT "With QT4 Support" OFF) + OPTION(WITH_QT5 "With QT5 Support" OFF) IF(WIN32 AND MFC_FOUND) OPTION(WITH_MFC "With MFC Support" ON ) diff --git a/code/nel/samples/3d/CMakeLists.txt b/code/nel/samples/3d/CMakeLists.txt index 6cd2e49ef..458adc804 100644 --- a/code/nel/samples/3d/CMakeLists.txt +++ b/code/nel/samples/3d/CMakeLists.txt @@ -6,6 +6,6 @@ IF(WITH_NEL_CEGUI) ADD_SUBDIRECTORY(cegui) ENDIF(WITH_NEL_CEGUI) -#IF(WITH_QT) -# ADD_SUBDIRECTORY(qtnel) -#ENDIF(WITH_QT) +IF(WITH_QT5) + ADD_SUBDIRECTORY(nel_qt) +ENDIF(WITH_QT5) diff --git a/code/nel/samples/3d/nel_qt/CMakeLists.txt b/code/nel/samples/3d/nel_qt/CMakeLists.txt new file mode 100644 index 000000000..1d2b4f056 --- /dev/null +++ b/code/nel/samples/3d/nel_qt/CMakeLists.txt @@ -0,0 +1,27 @@ + +FILE(GLOB SRCS *.cpp) +FILE(GLOB HDRS *.h) +FILE(GLOB RESOURCES *.qrc) + +SET(CMAKE_AUTOMOC ON) + +QT5_ADD_RESOURCES(RESOURCE_ADDED ${RESOURCES}) + +ADD_EXECUTABLE(nl_sample_qt WIN32 ${SRC} + ${SRCS} + ${HDRS} + ${RESOURCE_ADDED} + ) + +TARGET_LINK_LIBRARIES(nl_sample_qt + nelmisc + nel3d + nelsound + Qt5::Widgets) + +NL_DEFAULT_PROPS(nl_sample_qt "NeL, Samples, 3D: Qt") +NL_ADD_RUNTIME_FLAGS(nl_sample_qt) + +qt5_use_modules(nl_sample_qt Widgets) + +INSTALL(TARGETS nl_sample_qt RUNTIME DESTINATION ${NL_BIN_PREFIX} COMPONENT samples3d) diff --git a/code/nel/samples/3d/nel_qt/command_log.cpp b/code/nel/samples/3d/nel_qt/command_log.cpp index a1c846efd..556dbcf68 100644 --- a/code/nel/samples/3d/nel_qt/command_log.cpp +++ b/code/nel/samples/3d/nel_qt/command_log.cpp @@ -20,7 +20,7 @@ // STL includes // Qt includes -#include +#include // NeL includes #include @@ -173,7 +173,7 @@ void CCommandLog::returnPressed() if (text.isEmpty()) return; - std::string cmd = text.toAscii().data(); + std::string cmd = text.toLocal8Bit().data(); ICommand::execute(cmd, InfoLog()); m_CommandInput->clear(); diff --git a/code/nel/samples/3d/nel_qt/command_log.h b/code/nel/samples/3d/nel_qt/command_log.h index d8053eb39..c7e38667c 100644 --- a/code/nel/samples/3d/nel_qt/command_log.h +++ b/code/nel/samples/3d/nel_qt/command_log.h @@ -21,9 +21,9 @@ // STL includes // Qt includes -#include -#include -#include +#include +#include +#include // NeL includes #include diff --git a/code/nel/samples/3d/nel_qt/graphics_config.cpp b/code/nel/samples/3d/nel_qt/graphics_config.cpp index 74e8ad2b4..9100e5728 100644 --- a/code/nel/samples/3d/nel_qt/graphics_config.cpp +++ b/code/nel/samples/3d/nel_qt/graphics_config.cpp @@ -20,9 +20,9 @@ // STL includes // Qt includes -#include -#include -#include +#include +#include +#include // NeL includes // #include diff --git a/code/nel/samples/3d/nel_qt/graphics_config.h b/code/nel/samples/3d/nel_qt/graphics_config.h index 9044ef8a8..3faabc800 100644 --- a/code/nel/samples/3d/nel_qt/graphics_config.h +++ b/code/nel/samples/3d/nel_qt/graphics_config.h @@ -21,13 +21,13 @@ // STL includes // Qt includes -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include // NeL includes #include @@ -60,8 +60,8 @@ public: void incbTranslate(); inline bool getGraphicsEnabled() const { return m_Enabled->isChecked(); } - inline std::string getGraphicsDriver() const { std::string v = std::string(m_Driver->currentText().toAscii()); return v; } - inline std::string getFontName() const { std::string v = std::string(m_FontName->text().toAscii()); return v; } + inline std::string getGraphicsDriver() const { std::string v = std::string(m_Driver->currentText().toLocal8Bit()); return v; } + inline std::string getFontName() const { std::string v = std::string(m_FontName->text().toLocal8Bit()); return v; } inline NLMISC::CRGBA getBackgroundColor() const { QColor c = m_BackgroundColor->currentColor(); NLMISC::CRGBA v(c.red(), c.green(), c.blue()); return v; } inline bool getFontShadow() const { return m_FontShadow->isChecked(); } diff --git a/code/nel/samples/3d/nel_qt/graphics_viewport.cpp b/code/nel/samples/3d/nel_qt/graphics_viewport.cpp index 611e0d440..2c94a36bd 100644 --- a/code/nel/samples/3d/nel_qt/graphics_viewport.cpp +++ b/code/nel/samples/3d/nel_qt/graphics_viewport.cpp @@ -20,7 +20,7 @@ // STL includes // Qt includes -#include +#include // NeL includes #include @@ -92,7 +92,7 @@ void CGraphicsViewport::init(CGraphicsConfig *graphicsConfig) nlassert(m_Driver); // initialize the window with config file values - m_Driver->setDisplay(winId(), NL3D::UDriver::CMode(width(), height(), 32)); + m_Driver->setDisplay((nlWindow)winId(), NL3D::UDriver::CMode(width(), height(), 32)); // register config callbacks connect(m_GraphicsConfig, SIGNAL(onBackgroundColor(NLMISC::CRGBA)), diff --git a/code/nel/samples/3d/nel_qt/graphics_viewport.h b/code/nel/samples/3d/nel_qt/graphics_viewport.h index 0b9dde03a..ac9fadbc3 100644 --- a/code/nel/samples/3d/nel_qt/graphics_viewport.h +++ b/code/nel/samples/3d/nel_qt/graphics_viewport.h @@ -21,7 +21,7 @@ // STL includes // Qt includes -#include +#include // NeL includes #include diff --git a/code/nel/samples/3d/nel_qt/main_window.cpp b/code/nel/samples/3d/nel_qt/main_window.cpp index bf83e625c..a566723ef 100644 --- a/code/nel/samples/3d/nel_qt/main_window.cpp +++ b/code/nel/samples/3d/nel_qt/main_window.cpp @@ -20,11 +20,20 @@ // STL includes // Qt includes -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // NeL includes // #include @@ -69,10 +78,6 @@ CMainWindow::CMainWindow(const QMap &customSizeHints, QWidget *p m_Configuration.init(); - m_OriginalPalette = QApplication::palette(); - m_Configuration.setAndCallback("QtStyle", CConfigCallback(this, &CMainWindow::cfcbQtStyle)); - m_Configuration.setAndCallback("QtPalette", CConfigCallback(this, &CMainWindow::cfcbQtPalette)); - m_Internationalization.init(&m_Configuration); m_Internationalization.enableCallback(CEmptyCallback(this, &CMainWindow::incbLanguageCode)); @@ -361,18 +366,6 @@ void CMainWindow::recalculateMinimumWidth() m_GraphicsConfigScroll->setMinimumWidth(m_GraphicsConfig->minimumSizeHint().width() + m_GraphicsConfigScroll->minimumSizeHint().width()); } -void CMainWindow::cfcbQtStyle(NLMISC::CConfigFile::CVar &var) -{ - QApplication::setStyle(QStyleFactory::create(var.asString().c_str())); - recalculateMinimumWidth(); -} - -void CMainWindow::cfcbQtPalette(NLMISC::CConfigFile::CVar &var) -{ - if (var.asBool()) QApplication::setPalette(QApplication::style()->standardPalette()); - else QApplication::setPalette(m_OriginalPalette); -} - void CMainWindow::applyGraphicsConfig() { // reinitializes the graphics system completely diff --git a/code/nel/samples/3d/nel_qt/main_window.h b/code/nel/samples/3d/nel_qt/main_window.h index dedbf18c7..7fbafa6a6 100644 --- a/code/nel/samples/3d/nel_qt/main_window.h +++ b/code/nel/samples/3d/nel_qt/main_window.h @@ -21,7 +21,7 @@ // STL includes // Qt includes -#include +#include // NeL includes #include @@ -105,9 +105,6 @@ private: void recalculateMinimumWidth(); - void cfcbQtStyle(NLMISC::CConfigFile::CVar &var); - void cfcbQtPalette(NLMISC::CConfigFile::CVar &var); - void cfcbSoundEnabled(NLMISC::CConfigFile::CVar &var); void incbLanguageCode(); @@ -123,8 +120,6 @@ private: QUndoStack *m_UndoStack; - QPalette m_OriginalPalette; - bool m_IsGraphicsInitialized, m_IsGraphicsEnabled; bool m_IsSoundInitialized, m_IsSoundEnabled; diff --git a/code/nel/samples/3d/nel_qt/nel_qt.cpp b/code/nel/samples/3d/nel_qt/nel_qt.cpp index 178943aa8..cd06ee136 100644 --- a/code/nel/samples/3d/nel_qt/nel_qt.cpp +++ b/code/nel/samples/3d/nel_qt/nel_qt.cpp @@ -26,9 +26,10 @@ #endif // Qt includes -#include +#include #include #include +#include // NeL includes #include @@ -36,6 +37,7 @@ #include #include #include +#include // Project includes #include "nel_qt_config.h" @@ -178,15 +180,39 @@ sint main(int argc, char **argv) hr = hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); bool coInitOk = (hr == S_OK) || (hr == S_FALSE); #endif + + CSheetId::initWithoutSheet(); + QApplication app(argc, const_cast(argv)); + + QApplication::setStyle(QStyleFactory::create("Fusion")); + QPalette palette = app.palette(); + palette.setColor(QPalette::Window, QColor(64, 64, 64)); + palette.setColor(QPalette::WindowText, Qt::white); + palette.setColor(QPalette::Base, QColor(48, 48, 48)); + palette.setColor(QPalette::AlternateBase, QColor(64, 64, 64)); + palette.setColor(QPalette::ToolTipBase, Qt::white); + palette.setColor(QPalette::ToolTipText, Qt::white); + palette.setColor(QPalette::Text, Qt::white); + palette.setColor(QPalette::Button, QColor(64, 64, 64)); + palette.setColor(QPalette::ButtonText, Qt::white); + palette.setColor(QPalette::BrightText, Qt::red); + palette.setColor(QPalette::Highlight, QColor(64, 128, 96)); + palette.setColor(QPalette::HighlightedText, Qt::white); + app.setPalette(palette); + QMap customSizeHints = parseCustomSizeHints(argc, argv); + NLQT::CMainWindow mainWin(customSizeHints); mainWin.resize(800, 600); mainWin.show(); // calls isVisible(true) + int result = app.exec(); + #ifdef NL_OS_WINDOWS if (coInitOk) CoUninitialize(); #endif + return result; } diff --git a/code/nel/samples/3d/nel_qt/qtcolorpicker.h b/code/nel/samples/3d/nel_qt/qtcolorpicker.h index 9363cd0cc..446abbdcb 100644 --- a/code/nel/samples/3d/nel_qt/qtcolorpicker.h +++ b/code/nel/samples/3d/nel_qt/qtcolorpicker.h @@ -46,13 +46,13 @@ #ifndef QTCOLORPICKER_H #define QTCOLORPICKER_H -#include +#include #include -#include +#include -#include +#include #include -#include +#include #define QT_QTCOLORPICKER_EXPORT diff --git a/code/nel/samples/3d/nel_qt/qtcolorpicker_cpp.h b/code/nel/samples/3d/nel_qt/qtcolorpicker_cpp.h index 0701a803f..e22d290e4 100644 --- a/code/nel/samples/3d/nel_qt/qtcolorpicker_cpp.h +++ b/code/nel/samples/3d/nel_qt/qtcolorpicker_cpp.h @@ -44,24 +44,24 @@ ** ****************************************************************************/ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include "qtcolorpicker.h" diff --git a/code/nel/samples/3d/nel_qt/undo_redo_binders.cpp b/code/nel/samples/3d/nel_qt/undo_redo_binders.cpp index 52bd2c02a..2b955825d 100644 --- a/code/nel/samples/3d/nel_qt/undo_redo_binders.cpp +++ b/code/nel/samples/3d/nel_qt/undo_redo_binders.cpp @@ -20,10 +20,10 @@ // STL includes // Qt includes -#include -#include -#include -#include +#include +#include +#include +#include // NeL includes #include diff --git a/code/nel/samples/3d/nel_qt/undo_redo_binders.h b/code/nel/samples/3d/nel_qt/undo_redo_binders.h index 2a3d4afa0..12fc29f67 100644 --- a/code/nel/samples/3d/nel_qt/undo_redo_binders.h +++ b/code/nel/samples/3d/nel_qt/undo_redo_binders.h @@ -23,8 +23,8 @@ // Qt includes #include #include -#include -#include +#include +#include // NeL includes