Qt5 NeL sample

--HG--
branch : qt5
hg/feature/qt5
kaetemi 10 years ago
parent 902a873e78
commit 86ed0efc65

@ -142,6 +142,11 @@ IF(WITH_QT)
FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui QtXml QtOpenGL REQUIRED) FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui QtXml QtOpenGL REQUIRED)
ENDIF(WITH_QT) 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)
IF(WITH_NEL_TESTS) IF(WITH_NEL_TESTS)
FIND_PACKAGE(CppTest) FIND_PACKAGE(CppTest)

@ -265,7 +265,8 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS)
# GUI toolkits # GUI toolkits
### ###
OPTION(WITH_GTK "With GTK Support" OFF) 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) IF(WIN32 AND MFC_FOUND)
OPTION(WITH_MFC "With MFC Support" ON ) OPTION(WITH_MFC "With MFC Support" ON )

@ -6,6 +6,6 @@ IF(WITH_NEL_CEGUI)
ADD_SUBDIRECTORY(cegui) ADD_SUBDIRECTORY(cegui)
ENDIF(WITH_NEL_CEGUI) ENDIF(WITH_NEL_CEGUI)
#IF(WITH_QT) IF(WITH_QT5)
# ADD_SUBDIRECTORY(qtnel) ADD_SUBDIRECTORY(nel_qt)
#ENDIF(WITH_QT) ENDIF(WITH_QT5)

@ -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)

@ -20,7 +20,7 @@
// STL includes // STL includes
// Qt includes // Qt includes
#include <QtGui/QVBoxLayout> #include <QVBoxLayout>
// NeL includes // NeL includes
#include <nel/misc/debug.h> #include <nel/misc/debug.h>
@ -173,7 +173,7 @@ void CCommandLog::returnPressed()
if (text.isEmpty()) if (text.isEmpty())
return; return;
std::string cmd = text.toAscii().data(); std::string cmd = text.toLocal8Bit().data();
ICommand::execute(cmd, InfoLog()); ICommand::execute(cmd, InfoLog());
m_CommandInput->clear(); m_CommandInput->clear();

@ -21,9 +21,9 @@
// STL includes // STL includes
// Qt includes // Qt includes
#include <QtGui/QWidget> #include <QWidget>
#include <QtGui/QTextEdit> #include <QTextEdit>
#include <QtGui/QLineEdit> #include <QLineEdit>
// NeL includes // NeL includes
#include <nel/misc/log.h> #include <nel/misc/log.h>

@ -20,9 +20,9 @@
// STL includes // STL includes
// Qt includes // Qt includes
#include <QtGui/QVBoxLayout> #include <QVBoxLayout>
#include <QtGui/QHBoxLayout> #include <QHBoxLayout>
#include <QtGui/QUndoStack> #include <QUndoStack>
// NeL includes // NeL includes
// #include <nel/misc/debug.h> // #include <nel/misc/debug.h>

@ -21,13 +21,13 @@
// STL includes // STL includes
// Qt includes // Qt includes
#include <QtGui/QWidget> #include <QWidget>
#include <QtGui/QCheckBox> #include <QCheckBox>
#include <QtGui/QPushButton> #include <QPushButton>
#include <QtGui/QGroupBox> #include <QGroupBox>
#include <QtGui/QComboBox> #include <QComboBox>
#include <QtGui/QLabel> #include <QLabel>
#include <QtGui/QLineEdit> #include <QLineEdit>
// NeL includes // NeL includes
#include <nel/misc/config_file.h> #include <nel/misc/config_file.h>
@ -60,8 +60,8 @@ public:
void incbTranslate(); void incbTranslate();
inline bool getGraphicsEnabled() const { return m_Enabled->isChecked(); } 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 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().toAscii()); 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 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(); } inline bool getFontShadow() const { return m_FontShadow->isChecked(); }

@ -20,7 +20,7 @@
// STL includes // STL includes
// Qt includes // Qt includes
#include <QtGui/QAction> #include <QAction>
// NeL includes // NeL includes
#include <nel/misc/debug.h> #include <nel/misc/debug.h>
@ -92,7 +92,7 @@ void CGraphicsViewport::init(CGraphicsConfig *graphicsConfig)
nlassert(m_Driver); nlassert(m_Driver);
// initialize the window with config file values // 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 // register config callbacks
connect(m_GraphicsConfig, SIGNAL(onBackgroundColor(NLMISC::CRGBA)), connect(m_GraphicsConfig, SIGNAL(onBackgroundColor(NLMISC::CRGBA)),

@ -21,7 +21,7 @@
// STL includes // STL includes
// Qt includes // Qt includes
#include <QtGui/QWidget> #include <QWidget>
// NeL includes // NeL includes
#include <nel/misc/config_file.h> #include <nel/misc/config_file.h>

@ -20,11 +20,20 @@
// STL includes // STL includes
// Qt includes // Qt includes
#include <QtGui/QtGui> #include <QtGui>
#include <QtGui/QTreeView> #include <QTreeView>
#include <QtGui/QDirModel> #include <QDirModel>
#include <QtGui/QUndoStack> #include <QUndoStack>
#include <QtGui/QScrollArea> #include <QScrollArea>
#include <QApplication>
#include <QAction>
#include <QMenuBar>
#include <QMenu>
#include <QDockWidget>
#include <QToolBar>
#include <QStatusBar>
#include <QStyleFactory>
#include <QMessageBox>
// NeL includes // NeL includes
// #include <nel/misc/debug.h> // #include <nel/misc/debug.h>
@ -69,10 +78,6 @@ CMainWindow::CMainWindow(const QMap<QString, QSize> &customSizeHints, QWidget *p
m_Configuration.init(); 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.init(&m_Configuration);
m_Internationalization.enableCallback(CEmptyCallback(this, &CMainWindow::incbLanguageCode)); 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()); 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() void CMainWindow::applyGraphicsConfig()
{ {
// reinitializes the graphics system completely // reinitializes the graphics system completely

@ -21,7 +21,7 @@
// STL includes // STL includes
// Qt includes // Qt includes
#include <QtGui/QMainWindow> #include <QMainWindow>
// NeL includes // NeL includes
#include <nel/misc/rgba.h> #include <nel/misc/rgba.h>
@ -105,9 +105,6 @@ private:
void recalculateMinimumWidth(); void recalculateMinimumWidth();
void cfcbQtStyle(NLMISC::CConfigFile::CVar &var);
void cfcbQtPalette(NLMISC::CConfigFile::CVar &var);
void cfcbSoundEnabled(NLMISC::CConfigFile::CVar &var); void cfcbSoundEnabled(NLMISC::CConfigFile::CVar &var);
void incbLanguageCode(); void incbLanguageCode();
@ -123,8 +120,6 @@ private:
QUndoStack *m_UndoStack; QUndoStack *m_UndoStack;
QPalette m_OriginalPalette;
bool m_IsGraphicsInitialized, m_IsGraphicsEnabled; bool m_IsGraphicsInitialized, m_IsGraphicsEnabled;
bool m_IsSoundInitialized, m_IsSoundEnabled; bool m_IsSoundInitialized, m_IsSoundEnabled;

@ -26,9 +26,10 @@
#endif #endif
// Qt includes // Qt includes
#include <QtGui/QApplication> #include <QApplication>
#include <QtCore/QMap> #include <QtCore/QMap>
#include <QtCore/qdebug.h> #include <QtCore/qdebug.h>
#include <QStyleFactory>
// NeL includes // NeL includes
#include <nel/misc/debug.h> #include <nel/misc/debug.h>
@ -36,6 +37,7 @@
#include <nel/misc/file.h> #include <nel/misc/file.h>
#include <nel/misc/path.h> #include <nel/misc/path.h>
#include <nel/misc/command.h> #include <nel/misc/command.h>
#include <nel/misc/sheet_id.h>
// Project includes // Project includes
#include "nel_qt_config.h" #include "nel_qt_config.h"
@ -178,15 +180,39 @@ sint main(int argc, char **argv)
hr = hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); hr = hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
bool coInitOk = (hr == S_OK) || (hr == S_FALSE); bool coInitOk = (hr == S_OK) || (hr == S_FALSE);
#endif #endif
CSheetId::initWithoutSheet();
QApplication app(argc, const_cast<char **>(argv)); QApplication app(argc, const_cast<char **>(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<QString, QSize> customSizeHints = parseCustomSizeHints(argc, argv); QMap<QString, QSize> customSizeHints = parseCustomSizeHints(argc, argv);
NLQT::CMainWindow mainWin(customSizeHints); NLQT::CMainWindow mainWin(customSizeHints);
mainWin.resize(800, 600); mainWin.resize(800, 600);
mainWin.show(); // calls isVisible(true) mainWin.show(); // calls isVisible(true)
int result = app.exec(); int result = app.exec();
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
if (coInitOk) CoUninitialize(); if (coInitOk) CoUninitialize();
#endif #endif
return result; return result;
} }

@ -46,13 +46,13 @@
#ifndef QTCOLORPICKER_H #ifndef QTCOLORPICKER_H
#define QTCOLORPICKER_H #define QTCOLORPICKER_H
#include <QtGui/QPushButton> #include <QPushButton>
#include <QtCore/QString> #include <QtCore/QString>
#include <QtGui/QColor> #include <QColor>
#include <QtGui/QLabel> #include <QLabel>
#include <QtCore/QEvent> #include <QtCore/QEvent>
#include <QtGui/QFocusEvent> #include <QFocusEvent>
#define QT_QTCOLORPICKER_EXPORT #define QT_QTCOLORPICKER_EXPORT

@ -44,24 +44,24 @@
** **
****************************************************************************/ ****************************************************************************/
#include <QtGui/QApplication> #include <QApplication>
#include <QtGui/QDesktopWidget> #include <QDesktopWidget>
#include <QtGui/QPainter> #include <QPainter>
#include <QtGui/QPushButton> #include <QPushButton>
#include <QtGui/QColorDialog> #include <QColorDialog>
#include <QtCore/QMap> #include <QtCore/QMap>
#include <QtGui/QLayout> #include <QLayout>
#include <QtGui/QStyle> #include <QStyle>
#include <QtGui/QLabel> #include <QLabel>
#include <QtGui/QToolTip> #include <QToolTip>
#include <QtGui/QPixmap> #include <QPixmap>
#include <QtGui/QFocusEvent> #include <QFocusEvent>
#include <QtGui/QPaintEvent> #include <QPaintEvent>
#include <QtGui/QGridLayout> #include <QGridLayout>
#include <QtGui/QHideEvent> #include <QHideEvent>
#include <QtGui/QKeyEvent> #include <QKeyEvent>
#include <QtGui/QShowEvent> #include <QShowEvent>
#include <QtGui/QMouseEvent> #include <QMouseEvent>
#include <math.h> #include <math.h>
#include "qtcolorpicker.h" #include "qtcolorpicker.h"

@ -20,10 +20,10 @@
// STL includes // STL includes
// Qt includes // Qt includes
#include <QtGui/QUndoStack> #include <QUndoStack>
#include <QtGui/QAbstractButton> #include <QAbstractButton>
#include <QtGui/QLineEdit> #include <QLineEdit>
#include <QtGui/QComboBox> #include <QComboBox>
// NeL includes // NeL includes
#include <nel/misc/debug.h> #include <nel/misc/debug.h>

@ -23,8 +23,8 @@
// Qt includes // Qt includes
#include <QtCore/QObject> #include <QtCore/QObject>
#include <QtCore/QString> #include <QtCore/QString>
#include <QtGui/QColor> #include <QColor>
#include <QtGui/QUndoCommand> #include <QUndoCommand>
// NeL includes // NeL includes

Loading…
Cancel
Save