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

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

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

@ -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
// Qt includes
#include <QtGui/QVBoxLayout>
#include <QVBoxLayout>
// NeL includes
#include <nel/misc/debug.h>
@ -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();

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

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

@ -21,13 +21,13 @@
// STL includes
// Qt includes
#include <QtGui/QWidget>
#include <QtGui/QCheckBox>
#include <QtGui/QPushButton>
#include <QtGui/QGroupBox>
#include <QtGui/QComboBox>
#include <QtGui/QLabel>
#include <QtGui/QLineEdit>
#include <QWidget>
#include <QCheckBox>
#include <QPushButton>
#include <QGroupBox>
#include <QComboBox>
#include <QLabel>
#include <QLineEdit>
// NeL includes
#include <nel/misc/config_file.h>
@ -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(); }

@ -20,7 +20,7 @@
// STL includes
// Qt includes
#include <QtGui/QAction>
#include <QAction>
// NeL includes
#include <nel/misc/debug.h>
@ -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)),

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

@ -20,11 +20,20 @@
// STL includes
// Qt includes
#include <QtGui/QtGui>
#include <QtGui/QTreeView>
#include <QtGui/QDirModel>
#include <QtGui/QUndoStack>
#include <QtGui/QScrollArea>
#include <QtGui>
#include <QTreeView>
#include <QDirModel>
#include <QUndoStack>
#include <QScrollArea>
#include <QApplication>
#include <QAction>
#include <QMenuBar>
#include <QMenu>
#include <QDockWidget>
#include <QToolBar>
#include <QStatusBar>
#include <QStyleFactory>
#include <QMessageBox>
// NeL includes
// #include <nel/misc/debug.h>
@ -69,10 +78,6 @@ CMainWindow::CMainWindow(const QMap<QString, QSize> &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

@ -21,7 +21,7 @@
// STL includes
// Qt includes
#include <QtGui/QMainWindow>
#include <QMainWindow>
// NeL includes
#include <nel/misc/rgba.h>
@ -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;

@ -26,9 +26,10 @@
#endif
// Qt includes
#include <QtGui/QApplication>
#include <QApplication>
#include <QtCore/QMap>
#include <QtCore/qdebug.h>
#include <QStyleFactory>
// NeL includes
#include <nel/misc/debug.h>
@ -36,6 +37,7 @@
#include <nel/misc/file.h>
#include <nel/misc/path.h>
#include <nel/misc/command.h>
#include <nel/misc/sheet_id.h>
// 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<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);
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;
}

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

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

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

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

Loading…
Cancel
Save