Skip to content

Commit

Permalink
Feature/studio qt5 (#703)
Browse files Browse the repository at this point in the history
migrate studio to qt5
  • Loading branch information
zerotacg authored Feb 6, 2024
1 parent cd6bc5b commit dc28187
Show file tree
Hide file tree
Showing 223 changed files with 1,161 additions and 528 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/build-studio.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: build studio

on:
push:
branches: [ "core4", "feature/*" ]
pull_request:
branches: [ "core4" ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set reusable strings
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name: Dependencies
run: |
sudo apt update
sudo apt install --yes software-properties-common
sudo apt update
sudo apt install --yes \
cmake build-essential ninja-build ccache \
bison autoconf automake \
libpng-dev \
libjpeg-dev \
libgif-dev libfreetype6-dev \
freeglut3-dev \
liblua5.2-dev libluabind-dev libcpptest-dev \
libogg-dev libvorbis-dev libopenal-dev \
libavcodec-dev libavformat-dev libavdevice-dev libswscale-dev libpostproc-dev \
libmysqlclient-dev \
libxml2-dev \
libcurl4-openssl-dev libssl-dev \
libsquish-dev \
liblzma-dev \
libgsf-1-dev \
qtbase5-dev qttools5-dev qttools5-dev-tools libqtpropertybrowser-dev
- name: Configure CMake
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-G "Ninja"
-DWITH_QT5=ON
-DWITH_STUDIO=ON
-DWITH_RYZOM=OFF
-DWITH_NEL_TOOLS=OFF
-DWITH_NEL_SAMPLES=OFF
-DWITH_NEL_TESTS=OFF
-S ${{ github.workspace }}
- name: Build
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --target studio
43 changes: 43 additions & 0 deletions CMakeModules/FindQtPropertyBrowser.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Locate QtPropertyBrowser library
# This module defines
# QtPropertyBrowser_FOUND, if false, do not try to link to QtPropertyBrowser
# QtPropertyBrowser_LIBRARY
# QtPropertyBrowser_INCLUDE_DIR, where to find qtpropertybrowser.h
# QtPropertyBrowser_DIR - Can be set to QtPropertyBrowser install path or Windows build path

find_path(QtPropertyBrowser_INCLUDE_DIR qtpropertybrowser.h
HINTS ${QTPROPERTYBROWSER_DIR}
PATH_SUFFIXES include QtPropertyBrowser qtpropertybrowser
PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
/opt
)

find_library(QtPropertyBrowser_LIBRARY
NAMES QtPropertyBrowser qtpropertybrowser
HINTS ${QTPROPERTYBROWSER_DIR}
PATH_SUFFIXES lib64 lib
PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/sw
/opt/local
/opt/csw
/opt
)

include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set QtPropertyBrowser_FOUND to TRUE if
# all listed variables are TRUE
FIND_PACKAGE_HANDLE_STANDARD_ARGS(QtPropertyBrowser DEFAULT_MSG QtPropertyBrowser_LIBRARY QtPropertyBrowser_INCLUDE_DIR)

mark_as_advanced(QtPropertyBrowser_INCLUDE_DIR QtPropertyBrowser_LIBRARY)

2 changes: 1 addition & 1 deletion CMakeModules/nel.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ Remove the CMakeCache.txt file and try again from another folder, e.g.:
ENDMACRO(CHECK_OUT_OF_SOURCE)

MACRO(NL_SETUP_DEFAULT_OPTIONS)
IF(WITH_QT)
IF(WITH_QT5)
OPTION(WITH_STUDIO "Build Core Studio" OFF )
ENDIF()

Expand Down
2 changes: 2 additions & 0 deletions studio/src/3rdparty/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
also see:
https://github.com/greenjava/QtPropertyBrowser
30 changes: 24 additions & 6 deletions studio/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
ADD_SUBDIRECTORY(3rdparty)
#ADD_SUBDIRECTORY(3rdparty)

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${NEL_INCLUDE_DIR} ${QT_INCLUDES})
INCLUDE( ${QT_USE_FILE} )

CONFIGURE_FILE(translations/translations.qrc ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc COPYONLY)

Expand Down Expand Up @@ -31,10 +30,10 @@ IF(WIN32)
SET(STUDIO_RC studio.rc)
ENDIF()

QT4_ADD_TRANSLATION(STUDIO_QM ${STUDIO_TS})
QT4_ADD_RESOURCES( STUDIO_RC_SRCS ${STUDIO_RCS})
QT4_WRAP_CPP( STUDIO_MOC_SRCS ${STUDIO_HDR} )
QT4_WRAP_UI( STUDIO_PLUGIN_UI_HDRS ${STUDIO_PLUGIN_UIS})
QT5_ADD_TRANSLATION(STUDIO_QM ${STUDIO_TS})
QT5_ADD_RESOURCES( STUDIO_RC_SRCS ${STUDIO_RCS})
QT5_WRAP_CPP( STUDIO_MOC_SRCS ${STUDIO_HDR} )
QT5_WRAP_UI( STUDIO_PLUGIN_UI_HDRS ${STUDIO_PLUGIN_UIS})

SOURCE_GROUP(QtResources FILES ${STUDIO_RCS} ${STUDIO_PLUGIN_UIS} )
SOURCE_GROUP(QtGeneratedMocQrcSrc FILES ${STUDIO_MOC_SRCS} ${STUDIO_RC_SRCS})
Expand All @@ -55,6 +54,25 @@ ADD_DEFINITIONS(-DQT_NO_KEYWORDS ${QT_DEFINITIONS})
NL_DEFAULT_PROPS(studio "Tools: Studio")
NL_ADD_RUNTIME_FLAGS(studio)

ADD_SUBDIRECTORY(libqtpropertybrowser-text)
ADD_SUBDIRECTORY(plugins)

add_dependencies(studio
studio_plugin_bnp_manager
studio_plugin_core
studio_plugin_disp_sheet_id
studio_plugin_example
studio_plugin_georges_editor
studio_plugin_gui_editor
studio_plugin_landscape_editor
studio_plugin_log
studio_plugin_mission_compiler
studio_plugin_object_viewer
studio_plugin_sheet_builder
studio_plugin_tile_editor
# studio_plugin_translation_manager # requires QFtp which is removed in qt5
studio_plugin_world_editor
# studio_plugin_zone_painter
)

INSTALL(TARGETS studio RUNTIME DESTINATION ${NL_BIN_PREFIX} COMPONENT runtime BUNDLE DESTINATION /Applications)
1 change: 1 addition & 0 deletions studio/src/extension_system/iplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class IPlugin

}; //namespace ExtensionSystem

#define IPlugin_iid "dev.ryzom.com.ObjectViewerQt.IPlugin/0.9.2"
Q_DECLARE_INTERFACE(ExtensionSystem::IPlugin, "dev.ryzom.com.ObjectViewerQt.IPlugin/0.9.2")

#endif // IPLUGIN_H
2 changes: 1 addition & 1 deletion studio/src/extension_system/plugin_spec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ void PluginSpec::kill()
bool b = loader->unload();
if( !b )
{
nlinfo( "Plugin %s couldn't be unloaded.", this->m_name.toAscii().data() );
nlinfo( "Plugin %s couldn't be unloaded.", this->m_name.toLatin1().data() );
}

//delete m_plugin;
Expand Down
32 changes: 32 additions & 0 deletions studio/src/libqtpropertybrowser-text/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FIND_PACKAGE(QtPropertyBrowser REQUIRED)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_AUTOMOC ON)

set(SRC
libqtpropertybrowser-text/QtTextEditorFactory.cpp
libqtpropertybrowser-text/QtTextEditWidget.cpp
libqtpropertybrowser-text/QtTextPropertyManager.cpp
)

SOURCE_GROUP("" FILES ${SRC})

ADD_LIBRARY(QtPropertyBrowserText ${SRC})

ADD_LIBRARY(QtPropertyBrowser::Text ALIAS QtPropertyBrowserText)

TARGET_LINK_LIBRARIES(QtPropertyBrowserText ${QT_LIBRARIES} ${QtPropertyBrowser_LIBRARY})

INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}
${QT_INCLUDES}
${QtPropertyBrowser_INCLUDE_DIR}
)

TARGET_INCLUDE_DIRECTORIES(QtPropertyBrowserText
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#include <QDialog>
#include <QDialogButtonBox>
#include <QHBoxLayout>
#include <QPlainTextEdit>
#include <QToolButton>

#include <libqtpropertybrowser-text/QtTextEditWidget.h>

#if defined(Q_CC_MSVC)
# pragma warning(disable: 4786) /* MS VS 6: truncating debug info after 255 characters */
#endif

#if QT_VERSION >= 0x040400
QT_BEGIN_NAMESPACE
#endif


QtTextEditWidget::QtTextEditWidget(QWidget *parent) :
QWidget(parent),
m_lineEdit(new QLineEdit),
m_defaultButton(new QToolButton),
m_button(new QToolButton)
{
QHBoxLayout *lt = new QHBoxLayout(this);
lt->setContentsMargins(0, 0, 0, 0);
lt->setSpacing(0);
lt->addWidget(m_lineEdit);
m_lineEdit->setReadOnly(true);

m_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored);
m_button->setFixedWidth(20);
m_button->setText(tr("..."));
m_button->installEventFilter(this);

setFocusProxy(m_button);
setFocusPolicy(m_button->focusPolicy());

m_defaultButton->setIcon(QIcon(":/trolltech/qtpropertybrowser/images/resetproperty.png"));
m_defaultButton->setMaximumWidth(16);

connect(m_button, SIGNAL(clicked()), this, SLOT(buttonClicked()));
connect(m_defaultButton, SIGNAL(clicked()), this, SIGNAL(resetProperty()));
lt->addWidget(m_button);
lt->addWidget(m_defaultButton);
m_defaultButton->setEnabled(false);
}

void QtTextEditWidget::setValue(const QString &value)
{
if (m_lineEdit->text() != value)
m_lineEdit->setText(value);
}

void QtTextEditWidget::setStateResetButton(bool enabled)
{
m_defaultButton->setEnabled(enabled);
}

void QtTextEditWidget::buttonClicked()
{
QGridLayout *gridLayout;
QPlainTextEdit *plainTextEdit;
QDialogButtonBox *buttonBox;
QDialog *dialog;

dialog = new QDialog(this);
dialog->resize(400, 300);
gridLayout = new QGridLayout(dialog);
plainTextEdit = new QPlainTextEdit(dialog);

gridLayout->addWidget(plainTextEdit, 0, 0, 1, 1);

buttonBox = new QDialogButtonBox(dialog);
buttonBox->setOrientation(Qt::Horizontal);
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);

gridLayout->addWidget(buttonBox, 1, 0, 1, 1);

QObject::connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept()));
QObject::connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject()));

plainTextEdit->textCursor().insertText(m_lineEdit->text());

dialog->setModal(true);
dialog->show();
int result = dialog->exec();

if (result == QDialog::Accepted)
{
QString newText = plainTextEdit->document()->toPlainText();

setValue(newText);
if (plainTextEdit->document()->isModified())
Q_EMIT valueChanged(newText);
}

delete dialog;
}

bool QtTextEditWidget::eventFilter(QObject *obj, QEvent *ev)
{
if (obj == m_button) {
switch (ev->type()) {
case QEvent::KeyPress:
case QEvent::KeyRelease: { // Prevent the QToolButton from handling Enter/Escape meant control the delegate
switch (static_cast<const QKeyEvent*>(ev)->key()) {
case Qt::Key_Escape:
case Qt::Key_Enter:
case Qt::Key_Return:
ev->ignore();
return true;
default:
break;
}
}
break;
default:
break;
}
}
return QWidget::eventFilter(obj, ev);
}

#if QT_VERSION >= 0x040400
QT_END_NAMESPACE
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#ifndef LIBQTPROPERTYMANAGER_TEXT_EDIT_WIDGET_H
#define LIBQTPROPERTYMANAGER_TEXT_EDIT_WIDGET_H

#include <QWidget>
#include <QLineEdit>
#include <QToolButton>

#if QT_VERSION >= 0x040400
QT_BEGIN_NAMESPACE
#endif

class QtTextEditWidget : public QWidget
{
Q_OBJECT

public:
QtTextEditWidget(QWidget *parent);

bool eventFilter(QObject *obj, QEvent *ev);

public Q_SLOTS:
void setValue(const QString &value);
void setStateResetButton(bool enabled);

private Q_SLOTS:
void buttonClicked();

Q_SIGNALS:
void valueChanged(const QString &value);
void resetProperty();

private:
QLineEdit *m_lineEdit;
QToolButton *m_defaultButton;
QToolButton *m_button;
};

#if QT_VERSION >= 0x040400
QT_END_NAMESPACE
#endif

#endif // LIBQTPROPERTYMANAGER_TEXT_EDIT_WIDGET_H
Loading

0 comments on commit dc28187

Please sign in to comment.