diff --git a/code/nel/tools/3d/object_viewer_qt/src/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/CMakeLists.txt index 9bca4cc8e..44c0b21bc 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/CMakeLists.txt @@ -22,8 +22,7 @@ SET(OBJECT_VIEWER_HDR main_window.h graphics_viewport.h animation_dialog.h vegetable_dialog.h global_wind_dialog.h day_night_dialog.h sun_color_dialog.h vegetable_noise_value_widget.h vegetable_density_page.h vegetable_landscape_page.h vegetable_scale_page.h vegetable_appearance_page.h vegetable_rotate_page.h - extension_system/iplugin_manager.h extension_system/plugin_manager.h - extension_system/plugin_view.h) + extension_system/iplugin_manager.h extension_system/plugin_manager.h) SET(OBJECT_VIEWER_UIS animation_form.ui animation_set_form.ui settings_form.ui setup_fog_form.ui slot_form.ui particle_control_form.ui particle_workspace_form.ui @@ -36,8 +35,7 @@ SET(OBJECT_VIEWER_UIS animation_form.ui animation_set_form.ui settings_form.ui particle_link_skeleton_form.ui water_pool_form.ui vegetable_dialog_form.ui vegetable_noise_value_form.ui global_wind_form.ui sun_color_form.ui day_night_form.ui vegetable_density_form.ui vegetable_apperance_form.ui vegetable_landscape_form.ui - vegetable_rotate_form.ui vegetable_scale_form.ui - extension_system/plugin_view.ui) + vegetable_rotate_form.ui vegetable_scale_form.ui) SET(OBJECT_VIEWER_RCS object_viewer_qt.qrc) diff --git a/code/nel/tools/3d/object_viewer_qt/src/extension_system/iplugin.h b/code/nel/tools/3d/object_viewer_qt/src/extension_system/iplugin.h index 8e7bb60f7..3d7e24028 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/extension_system/iplugin.h +++ b/code/nel/tools/3d/object_viewer_qt/src/extension_system/iplugin.h @@ -30,7 +30,7 @@ namespace NLMISC class INelContext; } -namespace NLQT +namespace ExtensionSystem { /** @@ -56,10 +56,11 @@ public: virtual QString version() const = 0; virtual QString vendor() const = 0; virtual QString description() const = 0; + virtual QList dependencies() const = 0; }; -}; //namespace NLQT +}; //namespace ExtensionSystem -Q_DECLARE_INTERFACE(NLQT::IPlugin, "com.ryzom.dev.ObjectViewerQt.IPlugin/0.9") +Q_DECLARE_INTERFACE(ExtensionSystem::IPlugin, "dev.ryzom.com.ObjectViewerQt.IPlugin/0.9.1") #endif // IPLUGIN_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/extension_system/iplugin_manager.h b/code/nel/tools/3d/object_viewer_qt/src/extension_system/iplugin_manager.h index e9485dbea..f5537fc32 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/extension_system/iplugin_manager.h +++ b/code/nel/tools/3d/object_viewer_qt/src/extension_system/iplugin_manager.h @@ -24,11 +24,10 @@ #include #include -namespace NLQT +namespace ExtensionSystem { class IPluginSpec; - /** @interface IPluginManager @brief Interface for plugin system that manages the plugins, their life cycle and their registered objects. @@ -52,7 +51,7 @@ public: virtual void loadPlugins() = 0; virtual QStringList getPluginPaths() const = 0; virtual void setPluginPaths(const QStringList &paths) = 0; - virtual QList plugins() const = 0; + virtual QList plugins() const = 0; Q_SIGNALS: void objectAdded(QObject *obj); @@ -61,6 +60,6 @@ Q_SIGNALS: void pluginsChanged(); }; -}; // namespace NLQT +}; // namespace ExtensionSystem #endif // IPLUGINMANAGER_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/extension_system/iplugin_spec.h b/code/nel/tools/3d/object_viewer_qt/src/extension_system/iplugin_spec.h index 617c240c3..a27b76cd0 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/extension_system/iplugin_spec.h +++ b/code/nel/tools/3d/object_viewer_qt/src/extension_system/iplugin_spec.h @@ -22,7 +22,7 @@ #include -namespace NLQT +namespace ExtensionSystem { class IPlugin; class IPluginManager; @@ -76,7 +76,7 @@ public: virtual QString errorString() const = 0; }; -} // namespace NLQT +} // namespace ExtensionSystem #endif // IPLUGINSPEC_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_manager.cpp b/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_manager.cpp index b2cef4a8b..d400cc6aa 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_manager.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_manager.cpp @@ -25,7 +25,7 @@ #include "plugin_spec.h" -namespace NLQT +namespace ExtensionSystem { CPluginManager::CPluginManager(QObject *parent): diff --git a/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_manager.h b/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_manager.h index 774817e60..39e1044c0 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_manager.h +++ b/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_manager.h @@ -26,7 +26,7 @@ // Project include #include "iplugin_manager.h" -namespace NLQT +namespace ExtensionSystem { class IPlugin; diff --git a/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_spec.cpp b/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_spec.cpp index 85f1ad4fd..c65d4f6f3 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_spec.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_spec.cpp @@ -30,7 +30,7 @@ #include "iplugin.h" #include "iplugin_manager.h" -namespace NLQT +namespace ExtensionSystem { CPluginSpec::CPluginSpec(): diff --git a/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_spec.h b/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_spec.h index 156b93898..aadf6be1e 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_spec.h +++ b/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_spec.h @@ -22,7 +22,7 @@ #include "iplugin_spec.h" -namespace NLQT +namespace ExtensionSystem { class CPluginSpec: public IPluginSpec diff --git a/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_view.h b/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_view.h deleted file mode 100644 index 91c81b39e..000000000 --- a/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_view.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - Object Viewer Qt - Copyright (C) 2010 Dzmitry Kamiahin - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -*/ - -#ifndef PLUGIN_VIEW_H -#define PLUGIN_VIEW_H - -#include "ui_plugin_view.h" - - -// STL includes - -// Qt includes - -// NeL includes - -// Project includes - - -namespace NLQT -{ - -class IPluginManager; - -class CPluginView: public QDialog -{ - Q_OBJECT - -public: - CPluginView(IPluginManager *pluginManager, QWidget *parent = 0); - ~CPluginView(); - -private Q_SLOTS: - void updateList(); - -private: - - IPluginManager *_pluginManager; - Ui::CPluginView _ui; -}; /* class CPluginView */ - -} /* namespace NLQT */ - -#endif // PLUGIN_VIEW_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugn_view.cpp b/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugn_view.cpp deleted file mode 100644 index 7aa610dcb..000000000 --- a/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugn_view.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - Object Viewer Qt - Copyright (C) 2010 Dzmitry Kamiahin - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -*/ - -#include "plugin_view.h" - -// Qt includes -#include -#include -#include -#include -#include -#include - -// Project includes -#include "iplugin_spec.h" -#include "iplugin_manager.h" - -namespace NLQT -{ - -CPluginView::CPluginView(IPluginManager *pluginManager, QWidget *parent) - : QDialog(parent) -{ - _ui.setupUi(this); - _pluginManager = pluginManager; - - connect(_pluginManager, SIGNAL(pluginsChanged()), this, SLOT(updateList())); - - updateList(); -} - -CPluginView::~CPluginView() -{ -} - -void CPluginView::updateList() -{ - static QIcon okIcon = QApplication::style()->standardIcon(QStyle::SP_DialogApplyButton); - static QIcon errorIcon = QApplication::style()->standardIcon(QStyle::SP_DialogCancelButton); - - QList items; - Q_FOREACH (IPluginSpec *spec, _pluginManager->plugins()) - { - QTreeWidgetItem *item = new QTreeWidgetItem(QStringList() - << "" - << spec->name() - << QString("%1").arg(spec->version()) - << spec->vendor() - << QDir::toNativeSeparators(spec->filePath())); - item->setIcon(0, spec->hasError() ? errorIcon : okIcon); - items.append(item); - } - - _ui.pluginTreeWidget->clear(); - if (!items.isEmpty()) - _ui.pluginTreeWidget->addTopLevelItems(items); -} - -} /* namespace NLQT */ \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/images/.directory b/code/nel/tools/3d/object_viewer_qt/src/images/.directory deleted file mode 100644 index 8bcdbc317..000000000 --- a/code/nel/tools/3d/object_viewer_qt/src/images/.directory +++ /dev/null @@ -1,3 +0,0 @@ -[Dolphin] -ShowPreview=true -Timestamp=2010,8,4,0,59,20 diff --git a/code/nel/tools/3d/object_viewer_qt/src/main.cpp b/code/nel/tools/3d/object_viewer_qt/src/main.cpp index 1f972e0d4..e0671f478 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/main.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/main.cpp @@ -1,3 +1,20 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010 Dzmitry Kamiahin +// +// 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 "stdpch.h" #include #include @@ -119,7 +136,7 @@ sint main(int argc, char **argv) Modules::plugMan().loadPlugins(); QStringList errors; - Q_FOREACH (NLQT::IPluginSpec *spec, Modules::plugMan().plugins()) + Q_FOREACH (ExtensionSystem::IPluginSpec *spec, Modules::plugMan().plugins()) if (spec->hasError()) errors.append(spec->fileName() + " : " + spec->errorString()); diff --git a/code/nel/tools/3d/object_viewer_qt/src/main_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/main_window.cpp index 4bf9000d5..615d7026b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/main_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/main_window.cpp @@ -46,8 +46,6 @@ #include "day_night_dialog.h" #include "sun_color_dialog.h" -#include "extension_system/plugin_view.h" - using namespace std; using namespace NLMISC; @@ -138,7 +136,6 @@ CMainWindow::~CMainWindow() delete _ParticleControlDialog; delete _ParticleWorkspaceDialog; delete _GraphicsViewport; - delete _PluginView; } void CMainWindow::setVisible(bool visible) @@ -349,10 +346,6 @@ void CMainWindow::createActions() _aboutQtAction = new QAction(tr("About &Qt"), this); _aboutQtAction->setStatusTip(tr("Show the Qt library's About box")); connect(_aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); - - _pluginViewAction = new QAction(tr("About &Plugins"), this); - _pluginViewAction->setStatusTip(tr("Show the plugin view dialog")); - connect(_pluginViewAction, SIGNAL(triggered()), _PluginView, SLOT(show())); } void CMainWindow::createMenus() @@ -422,7 +415,6 @@ void CMainWindow::createMenus() _helpMenu->setObjectName("ovqt.Menu.Help"); _helpMenu->addAction(_aboutAction); _helpMenu->addAction(_aboutQtAction); - _helpMenu->addAction(_pluginViewAction); Modules::plugMan().addObject(_fileMenu); Modules::plugMan().addObject(_viewMenu); @@ -521,8 +513,6 @@ void CMainWindow::createDialogs() addDockWidget(Qt::RightDockWidgetArea, _SetupFog); _SetupFog->setVisible(false); - _PluginView = new CPluginView(&Modules::plugMan(), this); - connect(_ParticleControlDialog, SIGNAL(changeState()), _ParticleWorkspaceDialog, SLOT(setNewState())); connect(_ParticleWorkspaceDialog, SIGNAL(changeActiveNode()), _ParticleControlDialog, SLOT(updateActiveNode())); connect(_AnimationSetDialog->ui.setLengthPushButton, SIGNAL(clicked()), _AnimationDialog, SLOT(changeAnimLength())); @@ -629,6 +619,7 @@ void CMainWindow::updateRender() if (_isGraphicsInitialized && !Modules::objView().getDriver()->isLost()) { // 01. Render Driver (background color) + Modules::objView().getDriver()->activate(); Modules::objView().renderDriver(); // clear all buffers // 02. Render Sky (sky scene) diff --git a/code/nel/tools/3d/object_viewer_qt/src/main_window.h b/code/nel/tools/3d/object_viewer_qt/src/main_window.h index e14471940..a63a1bbad 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/main_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/main_window.h @@ -53,8 +53,6 @@ class CGlobalWindDialog; class CDayNightDialog; class CSunColorDialog; -class CPluginView; - class CMainWindow : public QMainWindow { Q_OBJECT @@ -115,8 +113,6 @@ private: CDayNightDialog *_DayNightDialog; CSunColorDialog *_SunColorDialog; - CPluginView *_PluginView; - CSkeletonTreeModel *_SkeletonTreeModel; QPalette _originalPalette; @@ -139,7 +135,6 @@ private: QAction *_resetSceneAction; QAction *_saveScreenshotAction; QAction *_settingsAction; - QAction *_pluginViewAction; QAction *_aboutAction; QAction *_aboutQtAction; };/* class CMainWindow */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/modules.cpp b/code/nel/tools/3d/object_viewer_qt/src/modules.cpp index 204285d97..f2f4850c1 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/modules.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/modules.cpp @@ -26,14 +26,14 @@ NLQT::CMainWindow *Modules::_mainWindow = NULL; NLQT::CParticleEditor *Modules::_particleEditor = NULL; NLQT::CSoundSystem *Modules::_soundSystem = NULL; NLQT::CVegetableEditor *Modules::_vegetableEditor = NULL; -NLQT::CPluginManager *Modules::_pluginManager = NULL; +ExtensionSystem::CPluginManager *Modules::_pluginManager = NULL; void Modules::init() { if (_configuration == NULL) _configuration = new NLQT::CConfiguration; config().init(); - if (_pluginManager == NULL) _pluginManager = new NLQT::CPluginManager; + if (_pluginManager == NULL) _pluginManager = new ExtensionSystem::CPluginManager; if (_objectViewer == NULL) _objectViewer = new NLQT::CObjectViewer; if (_soundSystem == NULL) _soundSystem = new NLQT::CSoundSystem; if (_particleEditor == NULL) _particleEditor = new NLQT::CParticleEditor; diff --git a/code/nel/tools/3d/object_viewer_qt/src/modules.h b/code/nel/tools/3d/object_viewer_qt/src/modules.h index 02d8f01c5..441baf22e 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/modules.h +++ b/code/nel/tools/3d/object_viewer_qt/src/modules.h @@ -62,7 +62,7 @@ public: { return *_vegetableEditor; } - static NLQT::CPluginManager &plugMan() + static ExtensionSystem::CPluginManager &plugMan() { return *_pluginManager; } @@ -74,7 +74,7 @@ private: static NLQT::CParticleEditor *_particleEditor; static NLQT::CSoundSystem *_soundSystem; static NLQT::CVegetableEditor *_vegetableEditor; - static NLQT::CPluginManager *_pluginManager; + static ExtensionSystem::CPluginManager *_pluginManager; }; #endif // MODULES_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/object_viewer.cpp b/code/nel/tools/3d/object_viewer_qt/src/object_viewer.cpp index 737e81379..ac8d56d5b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/object_viewer.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/object_viewer.cpp @@ -174,6 +174,24 @@ void CObjectViewer::release() void CObjectViewer::updateInput() { _Driver->EventServer.pump(); + + // Test some keys + if (_Driver->AsyncListener.isKeyPushed(KeyQ)) + { + // Change render mode + switch (_Driver->getPolygonMode()) + { + case UDriver::Filled: + _Driver->setPolygonMode (UDriver::Line); + break; + case UDriver::Line: + _Driver->setPolygonMode (UDriver::Point); + break; + case UDriver::Point: + _Driver->setPolygonMode (UDriver::Filled); + break; + } + } // New matrix from camera _Scene->getCam().setTransformMode(NL3D::UTransformable::DirectMatrix); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/CMakeLists.txt index a866784b4..ac151cb0a 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/CMakeLists.txt @@ -1,3 +1,4 @@ +ADD_SUBDIRECTORY(core) ADD_SUBDIRECTORY(example) ADD_SUBDIRECTORY(ovqt_sheet_builder) -ADD_SUBDIRECTORY(log) +ADD_SUBDIRECTORY(log) \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/CMakeLists.txt new file mode 100644 index 000000000..36a5e3d30 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/CMakeLists.txt @@ -0,0 +1,54 @@ +INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${LIBXML2_INCLUDE_DIR} + ${QT_INCLUDES}) + +FILE(GLOB SRC *.cpp *.h) +SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.h + ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_manager.h + ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h) + +SET(OVQT_CORE_PLUGIN_HDR + ioptions_page.h + core_plugin.h + core_constants.h + main_window.h + settings_dialog.h + qnel_widget.h + search_paths_settings_page.h + plugin_view_dialog.h) + +SET(OVQT_CORE_PLUGIN_UIS settings_dialog.ui + plugin_view_dialog.ui + search_paths_settings_page.ui) + +SET(OVQT_CORE_PLUGIN_RCS core.qrc) + +SET(QT_USE_QTGUI TRUE) +SET(QT_USE_QTOPENGL TRUE) + +QT4_ADD_RESOURCES(OVQT_CORE_PLUGIN_RC_SRCS ${OVQT_CORE_PLUGIN_RCS}) +QT4_WRAP_CPP(OVQT_CORE_PLUGIN_MOC_SRC ${OVQT_CORE_PLUGIN_HDR}) +QT4_WRAP_UI(OVQT_CORE_PLUGIN_UI_HDRS ${OVQT_CORE_PLUGIN_UIS}) + +SOURCE_GROUP(QtResources FILES ${OVQT_CORE_PLUGIN_UIS} ${OVQT_CORE_PLUGIN_RCS}) +SOURCE_GROUP(QtGeneratedUiHdr FILES ${OVQT_CORE_PLUGIN_UI_HDRS}) +SOURCE_GROUP(QtGeneratedMocSrc FILES ${OVQT_CORE_PLUGIN_MOC_SRC}) +SOURCE_GROUP("Core Plugin" FILES ${SRC}) +SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC}) + +ADD_LIBRARY(ovqt_plugin_core MODULE ${SRC} ${OVQT_CORE_PLUGIN_MOC_SRC} ${OVQT_EXT_SYS_SRC} ${OVQT_CORE_PLUGIN_RC_SRCS} ${OVQT_CORE_PLUGIN_UI_HDRS}) + +TARGET_LINK_LIBRARIES(ovqt_plugin_core nelmisc nel3d ${QT_LIBRARIES}) + +IF(WITH_STLPORT) + TARGET_LINK_LIBRARIES(ovqt_plugin_core ${CMAKE_THREAD_LIBS_INIT}) +ENDIF(WITH_STLPORT) + +NL_DEFAULT_PROPS(ovqt_plugin_core "NeL, Tools, 3D: Object Viewer Qt Plugin: Core") +NL_ADD_RUNTIME_FLAGS(ovqt_plugin_core) +NL_ADD_LIB_SUFFIX(ovqt_plugin_core) + +ADD_DEFINITIONS(${LIBXML2_DEFINITIONS} -DQT_PLUGIN -DQT_SHARED ${QT_DEFINITIONS}) + +INSTALL(TARGETS ovqt_plugin_core LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib COMPONENT tools3d) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core.qrc b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core.qrc new file mode 100644 index 000000000..e6b5615d8 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core.qrc @@ -0,0 +1,6 @@ + + + images/nel.png + images/preferences.png + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core_constants.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core_constants.h index fe859a26b..051c15e9d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core_constants.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core_constants.h @@ -1,106 +1,64 @@ -/* - Object Viewer Qt - Copyright (C) 2010 Dzmitry Kamiahin - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -*/ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010 Dzmitry Kamiahin +// +// 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 CORE_CONSTANTS_H #define CORE_CONSTANTS_H -namespace Core { -namespace Constants { +namespace Core +{ +namespace Constants +{ -const char * const OVQT_VERSION_LONG = "0.0.1"; -const char * const OVQT_VENDOR = "Dzmitry Kamiahin"; -const char * const OVQT_YEAR = "2010"; +const char * const OVQT_VERSION_LONG = "0.0.1"; +const char * const OVQT_VENDOR = "Dzmitry Kamiahin"; +const char * const OVQT_YEAR = "2010, 2011"; //mainwindow -const char * const MAIN_WINDOW = "ObjectViewerQt.MainWindow"; +const char * const MAIN_WINDOW = "ObjectViewerQt.MainWindow"; //menubar -const char * const MENU_BAR = "ObjectViewerQt.MenuBar"; +const char * const MENU_BAR = "ObjectViewerQt.MenuBar"; //menus -const char * const M_FILE = "ObjectViewerQt.Menu.File"; -const char * const M_EDIT = "ObjectViewerQt.Menu.Edit"; -const char * const M_SCENE = "ObjectViewerQt.Menu.Scene"; -const char * const M_TOOLS = "ObjectViewerQt.Menu.Tools"; -const char * const M_WINDOW = "ObjectViewerQt.Menu.Window"; -const char * const M_HELP = "ObjectViewerQt.Menu.Help"; +const char * const M_FILE = "ObjectViewerQt.Menu.File"; +const char * const M_EDIT = "ObjectViewerQt.Menu.Edit"; +const char * const M_VIEW = "ObjectViewerQt.Menu.View"; +const char * const M_SCENE = "ObjectViewerQt.Menu.Scene"; +const char * const M_TOOLS = "ObjectViewerQt.Menu.Tools"; +const char * const M_WINDOW = "ObjectViewerQt.Menu.Window"; +const char * const M_HELP = "ObjectViewerQt.Menu.Help"; //actions -const char * const UNDO = "ObjectViewerQt.Undo"; -const char * const REDO = "ObjectViewerQt.Redo"; +const char * const NEW = "ObjectViewerQt.New"; +const char * const OPEN = "ObjectViewerQt.Open"; +const char * const EXIT = "ObjectViewerQt.Exit"; -const char * const NEW = "ObjectViewerQt.New"; -const char * const OPEN = "ObjectViewerQt.Open"; -const char * const SAVE = "ObjectViewerQt.Save"; -const char * const SAVEAS = "ObjectViewerQt.SaveAs"; -const char * const SAVEALL = "ObjectViewerQt.SaveAll"; -const char * const EXIT = "ObjectViewerQt.Exit"; +const char * const SETTINGS = "ObjectViewerQt.Settings"; +const char * const TOGGLE_FULLSCREEN = "ObjectViewerQt.ToggleFullScreen"; -const char * const SETTINGS = "ObjectViewerQt.Settings"; -const char * const TOGGLE_FULLSCREEN = "ObjectViewerQt.ToggleFullScreen"; - -const char * const MINIMIZE_WINDOW = "ObjectViewerQt.MinimizeWindow"; -const char * const ZOOM_WINDOW = "ObjectViewerQt.ZoomWindow"; - -const char * const CLOSE = "ObjectViewerQt.Close"; -const char * const CLOSEALL = "ObjectViewerQt.CloseAll"; -const char * const CLOSEOTHERS = "ObjectViewerQt.CloseOthers"; -const char * const ABOUT = "ObjectViewerQt.About"; -const char * const ABOUT_PLUGINS = "ObjectViewerQt.AboutPlugins"; -const char * const ABOUT_QT = "ObjectViewerQt.AboutQt"; - -const char * const ICON_NEL = ":/images/nel.png"; -const char * const ICON_NEL_IDE = ":/images/nel_ide_load.png -const char * const ICON_OPENFILE = ":/images/open-file.png"; -const char * const ICON_GO_DOWN = ":/images/go-down.png -const char * const ICON_GO_UP = ":/images/go-up.png -const char * const ICON_LIST_ADD = ":/images/list-add.png -const char * const ICON_LIST_REMOVE = ":/images/list-remove.png -const char * const ICON_PLAY = ":/images/play.png -const char * const ICON_PAUSE = ":/images/pause.png -const char * const ICON_STOP = ":/images/stop.png -const char * const ICON_SEEK_BACKWARD = ":/images/seek-backward.png -const char * const ICON_SEEK_FORWARD = ":/images/seek-forward.png -const char * const ICON_SKIP_BACKWARD = ":/images/skip-backward.png -const char * const ICON_SKIP_FORWARD = ":/images/skip-forward.png -const char * const ICON_SETTINGS = ":/images/preferences.png -const char * const ICON_TIME = ":/images/time.png -const char * const ICON_ANIM = ":/images/anim.png -const char * const ICON_ANIMSET = ":/images/animset.png -const char * const ICON_DAY_NIGHT = ":/images/dqynight.png -const char * const ICON_MIXER = ":/images/mixer.png -const char * const ICON_PARTICLES = ":/images/pqrticles.png -const char * const ICON_SOUND = ":/images/sound.png -const char * const ICON_VEGETABLE = ":/images/veget.png -const char * const ICON_WATER = ":/images/water.png -const char * const ICON_WIND = ":/images/wind.png -const char * const ICON_BACKGROUNDCOLOR = ":/images/ico_bgcolor.png -const char * const ICON_FRAMEDELAY = ":/images/ico_framedelay.png -const char * const ICON_SKELSCALE = ":/images/ico_skelscale.png -const char * const ICON_CLEAR = ":/images/clear.png -const char * const ICON_INSERT = ":/images/insert.png -const char * const ICON_NEW = ":/images/new.png -const char * const ICON_REFRESH = ":/images/refresh.png -const char * const ICON_SAVE_AS = ":/images/save-as.png -const char * const ICON_SAVE = ":/images/save.png -const char * const ICON_INSERT_HORIZONTAL = ":/images/insert-horizontal.png +const char * const CLOSE = "ObjectViewerQt.Close"; +const char * const CLOSEALL = "ObjectViewerQt.CloseAll"; +const char * const CLOSEOTHERS = "ObjectViewerQt.CloseOthers"; +const char * const ABOUT = "ObjectViewerQt.About"; +const char * const ABOUT_PLUGINS = "ObjectViewerQt.AboutPlugins"; +const char * const ABOUT_QT = "ObjectViewerQt.AboutQt"; +const char * const ICON_NEL = ":/core/images/nel.png"; +const char * const ICON_SETTINGS = ":/core/images/preferences.png"; } // namespace Constants } // namespace Core diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core_plugin.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core_plugin.cpp new file mode 100644 index 000000000..a2bc697cd --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core_plugin.cpp @@ -0,0 +1,136 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010 Dzmitry Kamiahin +// +// 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 "core_plugin.h" + +#include +#include +#include +#include +#include +#include + +#include "../../extension_system/iplugin_spec.h" + +#include "settings_dialog.h" +#include "core_constants.h" +#include "search_paths_settings_page.h" +#include "nel/misc/debug.h" + +using namespace Core; + +bool CorePlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString) +{ + Q_UNUSED(errorString); + _plugMan = pluginManager; + // for old ovqt + QMainWindow *wnd = qobject_cast(objectByName("CMainWindow")); + if (!wnd) + { + *errorString = tr("Not found QMainWindow Object Viewer Qt."); + return false; + } + + //_mainWindow = new CMainWindow(_plugMan); + //_mainWindow->show(); + //_plugMan->addObject(new CSearchPathsSettingsPage(_mainWindow)); + return true; +} + +void CorePlugin::extensionsInitialized() +{ + // for old ovqt + _pluginView = new ExtensionSystem::CPluginView(_plugMan); + + QMenu *toolsMenu = qobject_cast(objectByName("ovqt.Menu.Tools")); + QMenu *helpMenu = qobject_cast(objectByName("ovqt.Menu.Help")); + nlassert(toolsMenu); + nlassert(helpMenu); + + QAction *newAction = toolsMenu->addAction(tr("New settings")); + QAction *newAction2 = helpMenu->addAction(tr("About plugins")); + newAction->setIcon(QIcon(Constants::ICON_SETTINGS)); + + connect(newAction, SIGNAL(triggered()), this, SLOT(execSettings())); + connect(newAction2, SIGNAL(triggered()), _pluginView, SLOT(show())); +} + +void CorePlugin::shutdown() +{ + //delete _mainWindow; + delete _pluginView; +} + +void CorePlugin::execSettings() +{ + CSettingsDialog settingsDialog(_plugMan); + settingsDialog.show(); + settingsDialog.execDialog(); +} + +void CorePlugin::setNelContext(NLMISC::INelContext *nelContext) +{ +#ifdef NL_OS_WINDOWS + // Ensure that a context doesn't exist yet. + // This only applies to platforms without PIC, e.g. Windows. + nlassert(!NLMISC::INelContext::isContextInitialised()); +#endif // NL_OS_WINDOWS + _LibContext = new NLMISC::CLibraryContext(*nelContext); +} + +QString CorePlugin::name() const +{ + return QLatin1String("Core"); +} + +QString CorePlugin::version() const +{ + return Constants::OVQT_VERSION_LONG; +} + +QString CorePlugin::vendor() const +{ + return Constants::OVQT_VENDOR; +} + +QString CorePlugin::description() const +{ + return "Core plugin."; +} + +QList CorePlugin::dependencies() const +{ + return QList(); +} + +QObject* CorePlugin::objectByName(const QString &name) const +{ + Q_FOREACH (QObject *qobj, _plugMan->allObjects()) + if (qobj->objectName() == name) + return qobj; + return 0; +} + +ExtensionSystem::IPluginSpec *CorePlugin::pluginByName(const QString &name) const +{ + Q_FOREACH (ExtensionSystem::IPluginSpec *spec, _plugMan->plugins()) + if (spec->name() == name) + return spec; + return 0; +} + +Q_EXPORT_PLUGIN(CorePlugin) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core_plugin.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core_plugin.h new file mode 100644 index 000000000..1092bacaf --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core_plugin.h @@ -0,0 +1,76 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010 Dzmitry Kamiahin +// +// 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 CORE_PLUGIN_H +#define CORE_PLUGIN_H + +#include "../../extension_system/iplugin.h" +#include "main_window.h" + +#include "nel/misc/app_context.h" + +#include + +namespace NLMISC +{ +class CLibraryContext; +} + +namespace ExtensionSystem +{ +class IPluginSpec; +} + +namespace Core +{ + +class CorePlugin : public QObject, public ExtensionSystem::IPlugin +{ + Q_OBJECT + Q_INTERFACES(ExtensionSystem::IPlugin) +public: + + bool initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString); + void extensionsInitialized(); + void shutdown(); + + void setNelContext(NLMISC::INelContext *nelContext); + + QString name() const; + QString version() const; + QString vendor() const; + QString description() const; + QList dependencies() const; + + QObject *objectByName(const QString &name) const; + ExtensionSystem::IPluginSpec *pluginByName(const QString &name) const; + +protected: + NLMISC::CLibraryContext *_LibContext; + +private Q_SLOTS: + void execSettings(); + +private: + ExtensionSystem::IPluginManager *_plugMan; + ExtensionSystem::CPluginView *_pluginView; + CMainWindow *_mainWindow; +}; + +} // namespace Core + +#endif // CORE_PLUGIN_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/images/nel.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/images/nel.png new file mode 100644 index 000000000..d2139bb25 Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/images/nel.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/images/preferences.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/images/preferences.png new file mode 100644 index 000000000..729bc0393 Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/images/preferences.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/ioptions_page.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/ioptions_page.h new file mode 100644 index 000000000..b5bf4ef24 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/ioptions_page.h @@ -0,0 +1,66 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009. +// +// 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 IOPTIONS_PAGE_H +#define IOPTIONS_PAGE_H + +#include + +class QWidget; + +namespace Core +{ +/** +@interface IOptionsPage +@brief The IOptionsPage is an interface for providing options pages. +@details You need to subclass this interface and put an instance of your subclass + into the plugin manager object pool. +*/ +class IOptionsPage : public QObject +{ + Q_OBJECT +public: + IOptionsPage(QObject *parent = 0) : QObject(parent) {} + virtual ~IOptionsPage() {} + + /// id() is a unique identifier for referencing this page + virtual QString id() const = 0; + + /// trName() is the (translated) name for display. + virtual QString trName() const = 0; + + /// category() is the unique id for the category that the page should be displayed in + virtual QString category() const = 0; + + /// trCategory() is the translated category + virtual QString trCategory() const = 0; + + /// createPage() is called to retrieve the widget to show in the preferences dialog + /// The widget will be destroyed by the widget hierarchy when the dialog closes + virtual QWidget *createPage(QWidget *parent) = 0; + + /// apply() is called to store the settings. It should detect if any changes have been made and store those. + virtual void apply() = 0; + + /// finish() is called directly before the preferences dialog closes + virtual void finish() = 0; +}; + +} // namespace Core + +#endif // IOPTIONSPAGE_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.cpp new file mode 100644 index 000000000..7b15cde19 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.cpp @@ -0,0 +1,173 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// 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 . + +// Project includes +#include "main_window.h" +#include "core_constants.h" +#include "settings_dialog.h" + +// Qt includes +#include + +namespace Core +{ + +CMainWindow::CMainWindow(ExtensionSystem::IPluginManager *pluginManager, QWidget *parent) + : QMainWindow(parent), + _lastDir(".") +{ + _pluginManager = pluginManager; + + setObjectName(Constants::MAIN_WINDOW); + + _tabWidget = new QTabWidget(this); + setCentralWidget(_tabWidget); + + QWidget *qwidg1 = new QWidget(_tabWidget); + QWidget *qwidg2 = new QWidget(_tabWidget); + + _tabWidget->addTab(qwidg1, "tab1"); + _tabWidget->addTab(qwidg2, "tab2"); + + + QGridLayout *gridLayout = new QGridLayout(qwidg1); + gridLayout->setObjectName(QString::fromUtf8("gridLayout")); + NLQT::QNLWidget *_nelWidget = new NLQT::QNLWidget(qwidg1); + _nelWidget->setObjectName(QString::fromUtf8("NELWIdget1")); + gridLayout->addWidget(_nelWidget, 0, 0, 1, 1); + + QGridLayout *gridLayout2 = new QGridLayout(qwidg2); + NLQT::QNLWidget *_nelWidget2 = new NLQT::QNLWidget(qwidg2); + _nelWidget2->setObjectName(QString::fromUtf8("NELWIdget2")); + gridLayout2->addWidget(_nelWidget2, 0, 0, 1, 1); + + setDockNestingEnabled(true); + + _originalPalette = QApplication::palette(); + + createDialogs(); + createActions(); + createMenus(); + createStatusBar(); + + setWindowIcon(QIcon(Constants::ICON_NEL)); + setWindowTitle(tr("Object Viewer Qt")); +} + +CMainWindow::~CMainWindow() +{ + delete _pluginView; +} + +bool CMainWindow::showOptionsDialog(const QString &group, + const QString &page, + QWidget *parent) +{ + if (!parent) + parent = this; + CSettingsDialog _settingsDialog(_pluginManager, group, page, parent); + _settingsDialog.show(); + return _settingsDialog.execDialog(); +} + +void CMainWindow::about() +{ + QMessageBox::about(this, tr("About Object Viewer Qt"), + tr("

Object Viewer Qt NG

" + "

Author: dnk-88

Compiled on %1 %2").arg(__DATE__).arg(__TIME__)); +} + +void CMainWindow::createActions() +{ + _openAction = new QAction(tr("&Open..."), this); + _openAction->setIcon(QIcon(":/images/open-file.png")); + _openAction->setShortcut(QKeySequence::Open); + _openAction->setStatusTip(tr("Open an existing file")); +// connect(_openAction, SIGNAL(triggered()), this, SLOT(open())); + + _exitAction = new QAction(tr("E&xit"), this); + _exitAction->setShortcut(tr("Ctrl+Q")); + _exitAction->setStatusTip(tr("Exit the application")); + connect(_exitAction, SIGNAL(triggered()), this, SLOT(close())); + + _settingsAction = new QAction(tr("&Settings"), this); + _settingsAction->setIcon(QIcon(":/images/preferences.png")); + _settingsAction->setStatusTip(tr("Open the settings dialog")); + connect(_settingsAction, SIGNAL(triggered()), this, SLOT(showOptionsDialog())); + + _aboutAction = new QAction(tr("&About"), this); + _aboutAction->setStatusTip(tr("Show the application's About box")); + connect(_aboutAction, SIGNAL(triggered()), this, SLOT(about())); + + _aboutQtAction = new QAction(tr("About &Qt"), this); + _aboutQtAction->setStatusTip(tr("Show the Qt library's About box")); + connect(_aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); + + _pluginViewAction = new QAction(tr("About &Plugins"), this); + _pluginViewAction->setStatusTip(tr("Show the plugin view dialog")); + connect(_pluginViewAction, SIGNAL(triggered()), _pluginView, SLOT(show())); +} + +void CMainWindow::createMenus() +{ + _fileMenu = menuBar()->addMenu(tr("&File")); + _fileMenu->setObjectName(Constants::M_FILE); + _fileMenu->addSeparator(); + _fileMenu->addAction(_exitAction); + + _editMenu = menuBar()->addMenu(tr("&Edit")); + _editMenu->setObjectName(Constants::M_EDIT); + + _viewMenu = menuBar()->addMenu(tr("&View")); + _viewMenu->setObjectName(Constants::M_VIEW); + + _toolsMenu = menuBar()->addMenu(tr("&Tools")); + _toolsMenu->setObjectName(Constants::M_TOOLS); + + + _toolsMenu->addSeparator(); + + _toolsMenu->addAction(_settingsAction); + + menuBar()->addSeparator(); + + _helpMenu = menuBar()->addMenu(tr("&Help")); + _helpMenu->setObjectName(Constants::M_HELP); + _helpMenu->addAction(_aboutAction); + _helpMenu->addAction(_aboutQtAction); + _helpMenu->addAction(_pluginViewAction); + + _pluginManager->addObject(_fileMenu); + _pluginManager->addObject(_editMenu); + _pluginManager->addObject(_viewMenu); + _pluginManager->addObject(_toolsMenu); + _pluginManager->addObject(_helpMenu); +} + +void CMainWindow::createStatusBar() +{ + statusBar()->showMessage(tr("StatusReady")); +} + +void CMainWindow::createDialogs() +{ + _pluginView = new ExtensionSystem::CPluginView(_pluginManager, this); +} + +} /* namespace Core */ + +/* end of file */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.h new file mode 100644 index 000000000..49c668b14 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.h @@ -0,0 +1,91 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// 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 MAIN_WINDOW_H +#define MAIN_WINDOW_H + +// STL includes + +// Qt includes +#include +#include + +// Project includes +#include "qnel_widget.h" +#include "../../extension_system/iplugin.h" +#include "plugin_view_dialog.h" + +namespace Core +{ +class CSettingsDialog; + +class CMainWindow : public QMainWindow +{ + Q_OBJECT + +public: + CMainWindow(ExtensionSystem::IPluginManager *pluginManager, QWidget *parent = 0); + ~CMainWindow(); + + inline QSettings *settings() const + { + return _settings; + } + +private Q_SLOTS: + bool showOptionsDialog(const QString &group = QString(), + const QString &page = QString(), + QWidget *parent = 0); + void about(); + +private: + void createActions(); + void createMenus(); + void createStatusBar(); + void createDialogs(); + + ExtensionSystem::IPluginManager *_pluginManager; + ExtensionSystem::CPluginView *_pluginView; + + QPalette _originalPalette; + QString _lastDir; + + QSettings *_settings; + + QTimer *_mainTimer; + QTimer *_statusBarTimer; + + QTabWidget *_tabWidget; + + QMenu *_fileMenu; + QMenu *_editMenu; + QMenu *_viewMenu; + QMenu *_toolsMenu; + QMenu *_helpMenu; + + QAction *_openAction; + QAction *_exitAction; + QAction *_settingsAction; + QAction *_pluginViewAction; + QAction *_aboutAction; + QAction *_aboutQtAction; + +};/* class CMainWindow */ + +} /* namespace Core */ + +#endif // MAIN_WINDOW_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/plugin_view_dialog.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/plugin_view_dialog.cpp new file mode 100644 index 000000000..b45d46418 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/plugin_view_dialog.cpp @@ -0,0 +1,73 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// 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 "plugin_view_dialog.h" + +// Qt includes +#include +#include +#include +#include +#include +#include + +// Project includes +#include "../../extension_system/iplugin_spec.h" +#include "../../extension_system/iplugin_manager.h" + +namespace ExtensionSystem +{ + +CPluginView::CPluginView(IPluginManager *pluginManager, QWidget *parent) + : QDialog(parent) +{ + _ui.setupUi(this); + _pluginManager = pluginManager; + + connect(_pluginManager, SIGNAL(pluginsChanged()), this, SLOT(updateList())); + + updateList(); +} + +CPluginView::~CPluginView() +{ +} + +void CPluginView::updateList() +{ + static QIcon okIcon = QApplication::style()->standardIcon(QStyle::SP_DialogApplyButton); + static QIcon errorIcon = QApplication::style()->standardIcon(QStyle::SP_DialogCancelButton); + + QList items; + Q_FOREACH (IPluginSpec *spec, _pluginManager->plugins()) + { + QTreeWidgetItem *item = new QTreeWidgetItem(QStringList() + << "" + << spec->name() + << QString("%1").arg(spec->version()) + << spec->vendor() + << QDir::toNativeSeparators(spec->filePath())); + item->setIcon(0, spec->hasError() ? errorIcon : okIcon); + items.append(item); + } + + _ui.pluginTreeWidget->clear(); + if (!items.isEmpty()) + _ui.pluginTreeWidget->addTopLevelItems(items); +} + +} /* namespace NLQT */ \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/plugin_view_dialog.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/plugin_view_dialog.h new file mode 100644 index 000000000..0f12b64a3 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/plugin_view_dialog.h @@ -0,0 +1,47 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// 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 PLUGIN_VIEW_H +#define PLUGIN_VIEW_H + +#include "ui_plugin_view_dialog.h" + +namespace ExtensionSystem +{ + +class IPluginManager; + +class CPluginView: public QDialog +{ + Q_OBJECT + +public: + CPluginView(IPluginManager *pluginManager, QWidget *parent = 0); + ~CPluginView(); + +private Q_SLOTS: + void updateList(); + +private: + + IPluginManager *_pluginManager; + Ui::CPluginView _ui; +}; /* class CPluginView */ + +} /* namespace NLQT */ + +#endif // PLUGIN_VIEW_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_view.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/plugin_view_dialog.ui similarity index 88% rename from code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_view.ui rename to code/nel/tools/3d/object_viewer_qt/src/plugins/core/plugin_view_dialog.ui index 8bf90fdf3..2fb0f568e 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_view.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/plugin_view_dialog.ui @@ -17,7 +17,7 @@ true - + true @@ -37,6 +37,9 @@ true + + 100 + State @@ -84,7 +87,7 @@ - + Qt::Horizontal @@ -97,13 +100,23 @@ - + Close + + + + false + + + All objects list + + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/qnel_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/qnel_widget.cpp new file mode 100644 index 000000000..53dd4c7b3 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/qnel_widget.cpp @@ -0,0 +1,208 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// 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 "qnel_widget.h" + +// STL includes + +// Qt includes +#include +#include + +// NeL includes +#include +#include +#include +#include + +namespace NLQT +{ + +QNLWidget::QNLWidget(QWidget *parent) + : QWidget(parent), + _driver(NULL), + _initialized(false), + _interval(25) +{ + init(); + _mainTimer = new QTimer(this); + connect(_mainTimer, SIGNAL(timeout()), this, SLOT(updateRender())); +} + +QNLWidget::~QNLWidget() +{ + release(); +} + +void QNLWidget::init() +{ + // create the driver + _driver = NL3D::UDriver::createDriver(NULL, false, NULL); + nlassert(_driver); + + // initialize the nel 3d viewport + _driver->setDisplay(winId(), NL3D::UDriver::CMode(width(), height(), 32)); + + // set the cache size for the font manager(in bytes) + _driver->setFontManagerMaxMemory(2097152); + + _initialized = true; +} + +void QNLWidget::release() +{ + _mainTimer->stop(); + delete _mainTimer; + if (_initialized) + { + _driver->release(); + delete _driver; + _driver = NULL; + } +} + +void QNLWidget::setInterval(int msec) +{ + _interval = msec; + _mainTimer->setInterval(msec); +} + +void QNLWidget::updateRender() +{ + if (isVisible()) + { + if (_initialized) + _driver->EventServer.pump(); + if (_initialized && !_driver->isLost()) + { + _driver->activate(); + _driver->clearBuffers(NLMISC::CRGBA(125,12,58)); + + // swap 3d buffers + _driver->swapBuffers(); + } + } +} + +void QNLWidget::showEvent(QShowEvent *showEvent) +{ + QWidget::showEvent(showEvent); + if (isVisible()) + { + _driver->activate(); + _mainTimer->start(_interval); + } + else + _mainTimer->stop(); +} + +#if defined(NL_OS_WINDOWS) || defined(NL_OS_MAC) +// Qt does not provide wheel events through winEvent() and macEvent() (but it +// does through x11Event(), which is inconsistent...) +// Workaround is to handle wheel events like implemented below. +// +// TODO: this is not a clean solution, because all but wheel events are +// handled using winEvent(), x11Event(), macEvent(). But this seems to be a +// limitation of current (4.7.1) Qt versions. (see e.g. qapplication_mac.mm) +void QNLWidget::wheelEvent(QWheelEvent *event) +{ + // Get relative positions. + float fX = 1.0f - (float)event->pos().x() / this->width(); + float fY = 1.0f - (float)event->pos().y() / this->height(); + + // Get the buttons currently pressed. + uint32 buttons = NLMISC::noButton; + if(event->buttons() & Qt::LeftButton) buttons |= NLMISC::leftButton; + if(event->buttons() & Qt::RightButton) buttons |= NLMISC::rightButton; + if(event->buttons() & Qt::MidButton) buttons |= NLMISC::middleButton; + if(event->modifiers() & Qt::ControlModifier) buttons |= NLMISC::ctrlButton; + if(event->modifiers() & Qt::ShiftModifier) buttons |= NLMISC::shiftButton; + if(event->modifiers() & Qt::AltModifier) buttons |= NLMISC::altButton; + + if(event->delta() > 0) + _driver->EventServer.postEvent( + new NLMISC::CEventMouseWheel(-fX, fY, (NLMISC::TMouseButton)buttons, true, NULL)); + else + _driver->EventServer.postEvent( + new NLMISC::CEventMouseWheel(-fX, fY, (NLMISC::TMouseButton)buttons, false, NULL)); +} +#endif // defined(NL_OS_WINDOWS) || defined(NL_OS_MAC) + + +#if defined(NL_OS_WINDOWS) + +typedef bool (*winProc)(NL3D::IDriver *driver, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); + +bool QNLWidget::winEvent(MSG *message, long *result) +{ + if (_driver && _driver->isActive()) + { + NL3D::IDriver *driver = dynamic_cast(_driver)->getDriver(); + if (driver) + { + winProc proc = (winProc)driver->getWindowProc(); + return proc(driver, message->hwnd, message->message, message->wParam, message->lParam); + } + } + + return false; +} + +#elif defined(NL_OS_MAC) + +typedef bool (*cocoaProc)(NL3D::IDriver *, const void *e); + +bool QNLWidget::macEvent(EventHandlerCallRef caller, EventRef event) +{ + if(caller) + nlerror("You are using QtCarbon! Only QtCocoa supported, please upgrade Qt"); + + if (_driver && _driver->isActive()) + { + NL3D::IDriver *driver = dynamic_cast(_driver)->getDriver(); + if (driver) + { + cocoaProc proc = (cocoaProc)driver->getWindowProc(); + return proc(driver, event); + } + } + + return false; +} + +#elif defined(NL_OS_UNIX) + +typedef bool (*x11Proc)(NL3D::IDriver *drv, XEvent *e); + +bool QNLWidget::x11Event(XEvent *event) +{ + if (_driver && _driver->isActive()) + { + NL3D::IDriver *driver = dynamic_cast(_driver)->getDriver(); + if (driver) + { + x11Proc proc = (x11Proc)driver->getWindowProc(); + return proc(driver, event); + } + } + + return false; +} +#endif + +} /* namespace NLQT */ + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/qnel_widget.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/qnel_widget.h new file mode 100644 index 000000000..a8238fa39 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/qnel_widget.h @@ -0,0 +1,97 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// 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 QNEL_WIDGET_H +#define QNEL_WIDGET_H + +// NeL includes +#include +#include + +// Qt includes +#include +#include + +class QAction; + +namespace NL3D +{ +class UDriver; +class UScene; +} + +namespace NLQT +{ + +/** +@class QNLWidget +@brief Responsible for interaction between Qt and NeL. +@details Automatically begins to update the render if the widget is visible +or suspends the updating of render if the widget is hidden. +*/ +class QNLWidget : public QWidget +{ + Q_OBJECT + +public: + QNLWidget(QWidget *parent); + virtual ~QNLWidget(); + + /// Set the update interval renderer + void setInterval(int msec); + + virtual QPaintEngine* paintEngine() const + { + return NULL; + } + +private Q_SLOTS: + void updateRender(); + +protected: + virtual void showEvent(QShowEvent *showEvent); + +#if defined(NL_OS_WINDOWS) || defined(NL_OS_MAC) + virtual void wheelEvent(QWheelEvent *event); +#endif + +#if defined(NL_OS_WINDOWS) + virtual bool winEvent(MSG *message, long *result); +#elif defined(NL_OS_MAC) + virtual bool macEvent(EventHandlerCallRef caller, EventRef event); +#elif defined(NL_OS_UNIX) + virtual bool x11Event(XEvent *event); +#endif + +private: + void init(); + void release(); + + QNLWidget(const QNLWidget &); + QNLWidget &operator=(const QNLWidget &); + + NL3D::UDriver *_driver; + QTimer *_mainTimer; + bool _initialized; + int _interval; + +}; /* class QNLWidget */ + +} /* namespace NLQT */ + + +#endif // QNEL_WIDGET_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/search_paths_settings_page.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/search_paths_settings_page.cpp new file mode 100644 index 000000000..21a9aa12c --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/search_paths_settings_page.cpp @@ -0,0 +1,67 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// 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 "search_paths_settings_page.h" + +// Qt includes +#include + +// NeL includes + +// Project includes + +namespace Core +{ + +CSearchPathsSettingsPage::CSearchPathsSettingsPage(QObject *parent) + : IOptionsPage(parent), + _currentPage(NULL) +{ +} + +QString CSearchPathsSettingsPage::id() const +{ + return QLatin1String("SearchPaths"); +} + +QString CSearchPathsSettingsPage::trName() const +{ + return tr("Search Paths"); +} + +QString CSearchPathsSettingsPage::category() const +{ + return QLatin1String("General"); +} + +QString CSearchPathsSettingsPage::trCategory() const +{ + return tr("General"); +} + +QWidget *CSearchPathsSettingsPage::createPage(QWidget *parent) +{ + _currentPage = new QWidget(parent); + _ui.setupUi(_currentPage); + return _currentPage; +} + +void CSearchPathsSettingsPage::apply() +{ +} + +} /* namespace Core */ \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/search_paths_settings_page.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/search_paths_settings_page.h new file mode 100644 index 000000000..b2f2398a0 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/search_paths_settings_page.h @@ -0,0 +1,58 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// 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 SEARCH_PATHS_SETTINGS_PAGE_H +#define SEARCH_PATHS_SETTINGS_PAGE_H + +#include + +#include "ioptions_page.h" + +#include "ui_search_paths_settings_page.h" + +class QWidget; + +namespace Core +{ +/** +@class CSearchPathsSettingsPage +*/ +class CSearchPathsSettingsPage : public IOptionsPage +{ + Q_OBJECT +public: + CSearchPathsSettingsPage(QObject *parent = 0); + virtual ~CSearchPathsSettingsPage() {} + + virtual QString id() const; + virtual QString trName() const; + virtual QString category() const; + virtual QString trCategory() const; + virtual QWidget *createPage(QWidget *parent); + + virtual void apply(); + virtual void finish() {} + +private: + QWidget *_currentPage; + Ui::CSearchPathsSettingsPage _ui; +}; + +} // namespace Core + +#endif // SEARCH_PATHS_SETTINGS_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/search_paths_settings_page.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/search_paths_settings_page.ui new file mode 100644 index 000000000..4a034ba25 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/search_paths_settings_page.ui @@ -0,0 +1,108 @@ + + + CSearchPathsSettingsPage + + + + 0 + 0 + 422 + 272 + + + + Form + + + + + + Search paths + + + + + + + + + + + + 0 + 0 + + + + ... + + + + :/images/list-add.png:/images/list-add.png + + + + 16 + 16 + + + + + + + + ... + + + + :/images/list-remove.png:/images/list-remove.png + + + + + + + ... + + + + :/images/go-up.png:/images/go-up.png + + + + + + + ... + + + + :/images/go-down.png:/images/go-down.png + + + + + + + + + Qt::Vertical + + + + 20 + 195 + + + + + + + + + + + + + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/settings_dialog.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/settings_dialog.cpp new file mode 100644 index 000000000..acb8ca856 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/settings_dialog.cpp @@ -0,0 +1,188 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009. +// +// 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 "settings_dialog.h" + +// Qt includes +#include +#include + +namespace Core +{ + +struct PageData +{ + int index; + QString category; + QString id; +}; + +Q_DECLARE_METATYPE(PageData); + +CSettingsDialog::CSettingsDialog(ExtensionSystem::IPluginManager *pluginManager, + const QString &categoryId, + const QString &pageId, + QWidget *parent) + : QDialog(parent), + _applied(false) +{ + _ui.setupUi(this); + + _plugMan = pluginManager; + + QString initialCategory = categoryId; + QString initialPage = pageId; + + _ui.buttonBox->button(QDialogButtonBox::Ok)->setDefault(true); + + connect(_ui.buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply())); + + _ui.splitter->setCollapsible(1, false); + _ui.pageTree->header()->setVisible(false); + + connect(_ui.pageTree, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), + this, SLOT(pageSelected())); + + QMap categories; + + QList pages; + QList all = _plugMan->allObjects(); + Q_FOREACH(QObject *obj, all) + { + IOptionsPage *page = qobject_cast(obj); + if (page) + pages.append(page); + } + + int index = 0; + Q_FOREACH(IOptionsPage *page, pages) + { + PageData pageData; + pageData.index = index; + pageData.category = page->category(); + pageData.id = page->id(); + + QTreeWidgetItem *item = new QTreeWidgetItem; + item->setText(0, page->trName()); + item->setData(0, Qt::UserRole, qVariantFromValue(pageData)); + + QStringList categoriesId = page->category().split(QLatin1Char('|')); + QStringList trCategories = page->trCategory().split(QLatin1Char('|')); + QString currentCategory = categoriesId.at(0); + + QTreeWidgetItem *treeitem; + if (!categories.contains(currentCategory)) + { + treeitem = new QTreeWidgetItem(_ui.pageTree); + treeitem->setText(0, trCategories.at(0)); + treeitem->setData(0, Qt::UserRole, qVariantFromValue(pageData)); + categories.insert(currentCategory, treeitem); + } + + int catCount = 1; + while (catCount < categoriesId.count()) + { + if (!categories.contains(currentCategory + QLatin1Char('|') + categoriesId.at(catCount))) + { + treeitem = new QTreeWidgetItem(categories.value(currentCategory)); + currentCategory += QLatin1Char('|') + categoriesId.at(catCount); + treeitem->setText(0, trCategories.at(catCount)); + treeitem->setData(0, Qt::UserRole, qVariantFromValue(pageData)); + categories.insert(currentCategory, treeitem); + } + else + { + currentCategory += QLatin1Char('|') + categoriesId.at(catCount); + } + ++catCount; + } + + categories.value(currentCategory)->addChild(item); + + _pages.append(page); + _ui.stackedPages->addWidget(page->createPage(_ui.stackedPages)); + + if (page->id() == initialPage && currentCategory == initialCategory) + { + _ui.stackedPages->setCurrentIndex(_ui.stackedPages->count()); + _ui.pageTree->setCurrentItem(item); + } + + index++; + } + + QList sizes; + sizes << 150 << 300; + _ui.splitter->setSizes(sizes); + + _ui.splitter->setStretchFactor(_ui.splitter->indexOf(_ui.pageTree), 0); + _ui.splitter->setStretchFactor(_ui.splitter->indexOf(_ui.layoutWidget), 1); +} + +CSettingsDialog::~CSettingsDialog() +{ +} + +void CSettingsDialog::pageSelected() +{ + QTreeWidgetItem *item = _ui.pageTree->currentItem(); + PageData data = item->data(0, Qt::UserRole).value(); + int index = data.index; + _currentCategory = data.category; + _currentPage = data.id; + _ui.stackedPages->setCurrentIndex(index); +} + +void CSettingsDialog::accept() +{ + _applied = true; + Q_FOREACH(IOptionsPage *page, _pages) + { + page->apply(); + page->finish(); + } + done(QDialog::Accepted); +} + +void CSettingsDialog::reject() +{ + Q_FOREACH(IOptionsPage *page, _pages) + page->finish(); + done(QDialog::Rejected); +} + +void CSettingsDialog::apply() +{ + Q_FOREACH(IOptionsPage *page, _pages) + page->apply(); + _applied = true; +} + +bool CSettingsDialog::execDialog() +{ + _applied = false; + exec(); + return _applied; +} + +void CSettingsDialog::done(int val) +{ + QDialog::done(val); +} + +} /* namespace Core */ \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/settings_dialog.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/settings_dialog.h new file mode 100644 index 000000000..2ca58236a --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/settings_dialog.h @@ -0,0 +1,75 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009. +// +// 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 SETTINGS_DIALOG_H +#define SETTINGS_DIALOG_H + +#include "ui_settings_dialog.h" + +// Qt includes +#include + +// Project includes +#include "ioptions_page.h" +#include "../../extension_system/iplugin.h" + +namespace Core +{ + +/** +@class CSettingsDialog +@brief Settings dialog +*/ +class CSettingsDialog: public QDialog +{ + Q_OBJECT + +public: + CSettingsDialog(ExtensionSystem::IPluginManager *pluginManager, + const QString &initialCategory = QString(), + const QString &initialPage = QString(), + QWidget *parent = 0); + + ~CSettingsDialog(); + + /// Run the dialog and return true if 'Ok' was choosen or 'Apply' was invoked at least once + bool execDialog(); + +public Q_SLOTS: + void done(int); + +private Q_SLOTS: + void pageSelected(); + void accept(); + void reject(); + void apply(); + +private: + QList _pages; + bool _applied; + QString _currentCategory; + QString _currentPage; + + ExtensionSystem::IPluginManager *_plugMan; + + Ui::CSettingsDialog _ui; +}; /* class CSettingsDialog */ + +} /* namespace Core */ + +#endif // SETTINGS_DIALOG_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/settings_dialog.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/settings_dialog.ui new file mode 100644 index 000000000..e536f0dc2 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/settings_dialog.ui @@ -0,0 +1,126 @@ + + + CSettingsDialog + + + + 0 + 0 + 697 + 476 + + + + Settings + + + + :/core/images/preferences.png:/core/images/preferences.png + + + + 6 + + + 9 + + + + + Qt::Horizontal + + + + + 0 + 0 + + + + 1 + + + + 0 + + + + + + + 6 + + + 0 + + + + + + 350 + 250 + + + + + + + + Qt::Horizontal + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + CSettingsDialog + accept() + + + 297 + 361 + + + 297 + 193 + + + + + buttonBox + rejected() + CSettingsDialog + reject() + + + 297 + 361 + + + 297 + 193 + + + + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/example/plugin1.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/example/plugin1.cpp index 3c5c3864e..c79ad079e 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/example/plugin1.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/example/plugin1.cpp @@ -13,15 +13,15 @@ using namespace Plugin; -bool MyPlugin::initialize(NLQT::IPluginManager *pluginManager, QString *errorString) +bool MyPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString) { Q_UNUSED(errorString); _plugMan = pluginManager; QString str; - QList listPlug = pluginManager->plugins(); + QList listPlug = pluginManager->plugins(); - Q_FOREACH (NLQT::IPluginSpec *plugSpec, listPlug) + Q_FOREACH (ExtensionSystem::IPluginSpec *plugSpec, listPlug) str += plugSpec->name(); nlinfo(str.toStdString().c_str()); @@ -99,9 +99,9 @@ QObject* MyPlugin::objectByName(const QString &name) const return 0; } -NLQT::IPluginSpec *MyPlugin::pluginByName(const QString &name) const +ExtensionSystem::IPluginSpec *MyPlugin::pluginByName(const QString &name) const { - Q_FOREACH (NLQT::IPluginSpec *spec, _plugMan->plugins()) + Q_FOREACH (ExtensionSystem::IPluginSpec *spec, _plugMan->plugins()) if (spec->name() == name) return spec; return 0; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/example/plugin1.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/example/plugin1.h index 02d80e1dc..f5a458873 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/example/plugin1.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/example/plugin1.h @@ -12,7 +12,7 @@ namespace NLMISC class CLibraryContext; } -namespace NLQT +namespace ExtensionSystem { class IPluginSpec; } @@ -20,13 +20,13 @@ class IPluginSpec; namespace Plugin { -class MyPlugin : public QObject, public NLQT::IPlugin +class MyPlugin : public QObject, public ExtensionSystem::IPlugin { Q_OBJECT - Q_INTERFACES(NLQT::IPlugin) + Q_INTERFACES(ExtensionSystem::IPlugin) public: - bool initialize(NLQT::IPluginManager *pluginManager, QString *errorString); + bool initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString); void extensionsInitialized(); void setNelContext(NLMISC::INelContext *nelContext); @@ -37,7 +37,7 @@ public: QString description() const; QObject *objectByName(const QString &name) const; - NLQT::IPluginSpec *pluginByName(const QString &name) const; + ExtensionSystem::IPluginSpec *pluginByName(const QString &name) const; private Q_SLOTS: void execMessageBox(); @@ -46,10 +46,10 @@ protected: NLMISC::CLibraryContext *_LibContext; private: - NLQT::IPluginManager *_plugMan; + ExtensionSystem::IPluginManager *_plugMan; }; -} // namespace Plugin1 +} // namespace Plugin #endif // PLUGIN1_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/log/log_plugin.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/log/log_plugin.cpp index 82f65a85a..c93503ad5 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/log/log_plugin.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/log/log_plugin.cpp @@ -55,7 +55,7 @@ CLogPlugin::~CLogPlugin() delete _displayer; } -bool CLogPlugin::initialize(NLQT::IPluginManager *pluginManager, QString *errorString) +bool CLogPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString) { Q_UNUSED(errorString); _plugMan = pluginManager; @@ -120,9 +120,9 @@ QObject* CLogPlugin::objectByName(const QString &name) const return 0; } -NLQT::IPluginSpec *CLogPlugin::pluginByName(const QString &name) const +ExtensionSystem::IPluginSpec *CLogPlugin::pluginByName(const QString &name) const { - Q_FOREACH (NLQT::IPluginSpec *spec, _plugMan->plugins()) + Q_FOREACH (ExtensionSystem::IPluginSpec *spec, _plugMan->plugins()) if (spec->name() == name) return spec; return 0; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/log/log_plugin.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/log/log_plugin.h index c7661342c..7f81ec8d4 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/log/log_plugin.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/log/log_plugin.h @@ -35,24 +35,28 @@ namespace NLMISC class CLibraryContext; } -namespace NLQT +namespace ExtensionSystem { class IPluginSpec; +} + +namespace NLQT +{ class CQtDisplayer; } namespace Plugin { - class CLogPlugin : public QDockWidget, public NLQT::IPlugin + class CLogPlugin : public QDockWidget, public ExtensionSystem::IPlugin { Q_OBJECT - Q_INTERFACES(NLQT::IPlugin) + Q_INTERFACES(ExtensionSystem::IPlugin) public: CLogPlugin(QWidget *parent = 0); ~CLogPlugin(); - bool initialize(NLQT::IPluginManager *pluginManager, QString *errorString); + bool initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString); void extensionsInitialized(); void setNelContext(NLMISC::INelContext *nelContext); @@ -63,13 +67,13 @@ namespace Plugin QString description() const; QObject *objectByName(const QString &name) const; - NLQT::IPluginSpec *pluginByName(const QString &name) const; + ExtensionSystem::IPluginSpec *pluginByName(const QString &name) const; protected: NLMISC::CLibraryContext *_LibContext; private: - NLQT::IPluginManager *_plugMan; + ExtensionSystem::IPluginManager *_plugMan; Ui::CLogPlugin _ui; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/ovqt_sheet_builder/ovqt_sheet_builder.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/ovqt_sheet_builder/ovqt_sheet_builder.cpp index 13ae954e6..daf907d09 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/ovqt_sheet_builder/ovqt_sheet_builder.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/ovqt_sheet_builder/ovqt_sheet_builder.cpp @@ -31,7 +31,7 @@ using namespace Plugin; -bool SheetBuilderPlugin::initialize(NLQT::IPluginManager *pluginManager, QString *errorString) +bool SheetBuilderPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString) { Q_UNUSED(errorString); _plugMan = pluginManager; @@ -100,6 +100,11 @@ QString SheetBuilderPlugin::description() const return "make_sheet_id equivalent"; } +QList SheetBuilderPlugin::dependencies() const +{ + return QList(); +} + QObject* SheetBuilderPlugin::objectByName(const QString &name) const { Q_FOREACH (QObject *qobj, _plugMan->allObjects()) @@ -108,9 +113,9 @@ QObject* SheetBuilderPlugin::objectByName(const QString &name) const return 0; } -NLQT::IPluginSpec *SheetBuilderPlugin::pluginByName(const QString &name) const +ExtensionSystem::IPluginSpec *SheetBuilderPlugin::pluginByName(const QString &name) const { - Q_FOREACH (NLQT::IPluginSpec *spec, _plugMan->plugins()) + Q_FOREACH (ExtensionSystem::IPluginSpec *spec, _plugMan->plugins()) if (spec->name() == name) return spec; return 0; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/ovqt_sheet_builder/ovqt_sheet_builder.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/ovqt_sheet_builder/ovqt_sheet_builder.h index dc2b18c30..d134c35fc 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/ovqt_sheet_builder/ovqt_sheet_builder.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/ovqt_sheet_builder/ovqt_sheet_builder.h @@ -28,7 +28,7 @@ namespace NLMISC class CLibraryContext; } -namespace NLQT +namespace ExtensionSystem { class IPluginSpec; } @@ -36,12 +36,12 @@ namespace NLQT namespace Plugin { - class SheetBuilderPlugin : public QObject, public NLQT::IPlugin + class SheetBuilderPlugin : public QObject, public ExtensionSystem::IPlugin { Q_OBJECT - Q_INTERFACES(NLQT::IPlugin) + Q_INTERFACES(ExtensionSystem::IPlugin) public: - bool initialize(NLQT::IPluginManager *pluginManager, QString *errorString); + bool initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString); void extensionsInitialized(); void setNelContext(NLMISC::INelContext *nelContext); @@ -50,9 +50,9 @@ namespace Plugin QString version() const; QString vendor() const; QString description() const; - + QList dependencies() const; QObject *objectByName(const QString &name) const; - NLQT::IPluginSpec *pluginByName(const QString &name) const; + ExtensionSystem::IPluginSpec *pluginByName(const QString &name) const; void buildSheet(bool clean); @@ -63,7 +63,7 @@ namespace Plugin NLMISC::CLibraryContext *_LibContext; private: - NLQT::IPluginManager *_plugMan; + ExtensionSystem::IPluginManager *_plugMan; };