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 ac151cb0a..e36da9e65 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,4 +1,5 @@ ADD_SUBDIRECTORY(core) ADD_SUBDIRECTORY(example) ADD_SUBDIRECTORY(ovqt_sheet_builder) -ADD_SUBDIRECTORY(log) \ No newline at end of file +ADD_SUBDIRECTORY(log) +ADD_SUBDIRECTORY(disp_sheet_id) \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core.cpp index 380413077..6c681f15a 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core.cpp @@ -19,6 +19,7 @@ #include "core.h" #include "imenu_manager.h" #include "main_window.h" +#include "../../extension_system/iplugin_manager.h" static Core::CoreImpl *m_coreInstance = 0; @@ -63,4 +64,9 @@ QMainWindow *CoreImpl::mainWindow() const return m_mainWindow; } +ExtensionSystem::IPluginManager *CoreImpl::pluginManager() const +{ + return m_mainWindow->pluginManager(); +} + } // namespace Core diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core.h index e138b73ca..d3b25b918 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core.h @@ -42,6 +42,7 @@ public: virtual QSettings *settings() const; virtual QMainWindow *mainWindow() const; + virtual ExtensionSystem::IPluginManager *pluginManager() const; private: MainWindow *m_mainWindow; friend class MainWindow; 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 index e6b5615d8..c9cae1893 100644 --- 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 @@ -1,6 +1,10 @@ - + + images/list-add.png + images/list-remove.png + images/go-up.png + images/go-down.png 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 051c15e9d..6f1c0f06d 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 @@ -57,6 +57,14 @@ const char * const ABOUT = "ObjectViewerQt.About"; const char * const ABOUT_PLUGINS = "ObjectViewerQt.AboutPlugins"; const char * const ABOUT_QT = "ObjectViewerQt.AboutQt"; +//settings +const char * const DATA_PATH_SECTION = "DataPath"; +const char * const SEARCH_PATHS = "SearchPaths"; +const char * const RECURSIVE_SEARCH_PATHS = "RecursiveSearchPathes"; +const char * const LEVELDESIGN_PATH = "LevelDesignPath"; +const char * const ASSETS_PATH = "LevelDesignPath"; + +//resources const char * const ICON_NEL = ":/core/images/nel.png"; const char * const ICON_SETTINGS = ":/core/images/preferences.png"; } // namespace Constants 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 index adf00409b..f8f4a6ea0 100644 --- 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 @@ -75,6 +75,7 @@ bool CorePlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QStr connect(newAction, SIGNAL(triggered()), this, SLOT(execSettings())); connect(newAction2, SIGNAL(triggered()), _pluginView, SLOT(show())); _oldOVQT = false; + return true; } else { @@ -97,11 +98,12 @@ bool CorePlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QStr } _oldOVQT = true; bool success = _mainWindow->initialize(errorString); + CSearchPathsSettingsPage *serchPathPage = new CSearchPathsSettingsPage(this); + serchPathPage->applySearchPaths(); + addAutoReleasedObject(serchPathPage); + return success; } - - addAutoReleasedObject(new CSearchPathsSettingsPage(this)); - return true; } void CorePlugin::extensionsInitialized() diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/icore.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/icore.h index 942daedc2..8f0c5b4ca 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/icore.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/icore.h @@ -28,6 +28,11 @@ class QMainWindow; class QSettings; QT_END_NAMESPACE +namespace ExtensionSystem +{ +class IPluginManager; +} + namespace Core { class IMenuManager; @@ -51,6 +56,8 @@ public: virtual QSettings *settings() const = 0; virtual QMainWindow *mainWindow() const = 0; + virtual ExtensionSystem::IPluginManager *pluginManager() const = 0; + Q_SIGNALS: void closeMainWindow(); }; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/images/go-down.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/images/go-down.png new file mode 100644 index 000000000..780714b8f Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/images/go-down.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/images/go-up.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/images/go-up.png new file mode 100644 index 000000000..7174fa8be Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/images/go-up.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/images/list-add.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/images/list-add.png new file mode 100644 index 000000000..af5b56e3c Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/images/list-add.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/images/list-remove.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/images/list-remove.png new file mode 100644 index 000000000..678b34df7 Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/images/list-remove.png differ 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 index aff6bcd3f..087f5d3c5 100644 --- 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 @@ -111,6 +111,11 @@ QSettings *MainWindow::settings() const return m_settings; } +ExtensionSystem::IPluginManager *MainWindow::pluginManager() const +{ + return m_pluginManager; +} + void MainWindow::checkObject(QObject *obj) { IContext *context = qobject_cast(obj); 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 index 11a77cc56..76eca3a42 100644 --- 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 @@ -19,7 +19,7 @@ #define MAIN_WINDOW_H // Project includes -#include "../../extension_system/iplugin.h" +#include "../../extension_system/iplugin_manager.h" #include "plugin_view_dialog.h" // STL includes @@ -51,6 +51,8 @@ public: IMenuManager *menuManager() const; QSettings *settings() const; + ExtensionSystem::IPluginManager *pluginManager() const; + public Q_SLOTS: bool showOptionsDialog(const QString &group = QString(), const QString &page = QString(), 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 index 585fb2089..ead8451f0 100644 --- 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 @@ -15,21 +15,29 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +// Project includes #include "search_paths_settings_page.h" - -// Qt includes -#include +#include "core_constants.h" +#include "icore.h" // NeL includes +#include -// Project includes +// Qt includes +#include +#include +#include namespace Core { CSearchPathsSettingsPage::CSearchPathsSettingsPage(QObject *parent) : IOptionsPage(parent), - _currentPage(0) + m_page(0) +{ +} + +CSearchPathsSettingsPage::~CSearchPathsSettingsPage() { } @@ -55,13 +63,127 @@ QString CSearchPathsSettingsPage::trCategory() const QWidget *CSearchPathsSettingsPage::createPage(QWidget *parent) { - _currentPage = new QWidget(parent); - _ui.setupUi(_currentPage); - return _currentPage; + m_page = new QWidget(parent); + m_ui.setupUi(m_page); + + readSettings(); + checkEnabledButton(); + connect(m_ui.addToolButton, SIGNAL(clicked()), this, SLOT(addPath())); + connect(m_ui.removeToolButton, SIGNAL(clicked()), this, SLOT(delPath())); + connect(m_ui.upToolButton, SIGNAL(clicked()), this, SLOT(upPath())); + connect(m_ui.downToolButton, SIGNAL(clicked()), this, SLOT(downPath())); + return m_page; } void CSearchPathsSettingsPage::apply() { + writeSettings(); + applySearchPaths(); +} + +void CSearchPathsSettingsPage::finish() +{ + delete m_page; + m_page = 0; +} + +void CSearchPathsSettingsPage::applySearchPaths() +{ + QStringList paths; + QSettings *settings = Core::ICore::instance()->settings(); + settings->beginGroup(Core::Constants::DATA_PATH_SECTION); + paths = settings->value(Core::Constants::SEARCH_PATHS).toStringList(); + settings->endGroup(); + Q_FOREACH(QString path, paths) + { + NLMISC::CPath::addSearchPath(path.toStdString(), false, false); + } + NLMISC::CPath::remapExtension("png", "tga", true); + NLMISC::CPath::remapExtension("png", "dds", true); +} + +void CSearchPathsSettingsPage::addPath() +{ + QString newPath = QFileDialog::getExistingDirectory(m_page); + if (!newPath.isEmpty()) + { + QListWidgetItem *newItem = new QListWidgetItem; + newItem->setText(newPath); + newItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable); + m_ui.pathsListWidget->addItem(newItem); + } + + checkEnabledButton(); +} + +void CSearchPathsSettingsPage::delPath() +{ + QListWidgetItem *removeItem = m_ui.pathsListWidget->takeItem(m_ui.pathsListWidget->currentRow()); + if (!removeItem) + delete removeItem; + + checkEnabledButton(); +} + +void CSearchPathsSettingsPage::upPath() +{ + int currentRow = m_ui.pathsListWidget->currentRow(); + if (!(currentRow == 0)) + { + QListWidgetItem *item = m_ui.pathsListWidget->takeItem(currentRow); + m_ui.pathsListWidget->insertItem(--currentRow, item); + m_ui.pathsListWidget->setCurrentRow(currentRow); + } +} + +void CSearchPathsSettingsPage::downPath() +{ + int currentRow = m_ui.pathsListWidget->currentRow(); + if (!(currentRow == m_ui.pathsListWidget->count()-1)) + { + QListWidgetItem *item = m_ui.pathsListWidget->takeItem(currentRow); + m_ui.pathsListWidget->insertItem(++currentRow, item); + m_ui.pathsListWidget->setCurrentRow(currentRow); + } +} + +void CSearchPathsSettingsPage::readSettings() +{ + QStringList paths; + QSettings *settings = Core::ICore::instance()->settings(); + settings->beginGroup(Core::Constants::DATA_PATH_SECTION); + paths = settings->value(Core::Constants::SEARCH_PATHS).toStringList(); + settings->endGroup(); + Q_FOREACH(QString path, paths) + { + QListWidgetItem *newItem = new QListWidgetItem; + newItem->setText(path); + newItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable); + m_ui.pathsListWidget->addItem(newItem); + } +} + +void CSearchPathsSettingsPage::writeSettings() +{ + QStringList paths; + for (int i = 0; i < m_ui.pathsListWidget->count(); ++i) + paths << m_ui.pathsListWidget->item(i)->text(); + + QSettings *settings = Core::ICore::instance()->settings(); + settings->beginGroup(Core::Constants::DATA_PATH_SECTION); + settings->setValue(Core::Constants::SEARCH_PATHS, paths); + settings->endGroup(); +} + +void CSearchPathsSettingsPage::checkEnabledButton() +{ + bool bEnabled = true; + if (m_ui.pathsListWidget->count() == 0) + bEnabled = false; + + m_ui.removeToolButton->setEnabled(bEnabled); + m_ui.upToolButton->setEnabled(bEnabled); + m_ui.downToolButton->setEnabled(bEnabled); } } /* 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 index cbea4239c..15f28f6c8 100644 --- 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 @@ -38,7 +38,7 @@ class CSearchPathsSettingsPage : public Core::IOptionsPage public: CSearchPathsSettingsPage(QObject *parent = 0); - ~CSearchPathsSettingsPage() {} + ~CSearchPathsSettingsPage(); QString id() const; QString trName() const; @@ -47,11 +47,23 @@ public: QWidget *createPage(QWidget *parent); void apply(); - void finish() {} + void finish(); + + void applySearchPaths(); + +private Q_SLOTS: + void addPath(); + void delPath(); + void upPath(); + void downPath(); private: - QWidget *_currentPage; - Ui::CSearchPathsSettingsPage _ui; + void readSettings(); + void writeSettings(); + void checkEnabledButton(); + + QWidget *m_page; + Ui::CSearchPathsSettingsPage m_ui; }; } // namespace Core 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 index f0d08e40b..e250cfdda 100644 --- 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 @@ -6,8 +6,8 @@ 0 0 - 422 - 272 + 431 + 285 @@ -15,97 +15,149 @@ - 0 + 6 + + + 3 - - + + 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 - - - - - + + + + Qt::Horizontal + + + + 228 + 20 + + + + + + + + 3 + + + + + + 0 + 0 + + + + + + + + :/core/images/list-add.png:/core/images/list-add.png + + + + 20 + 20 + + + + true + + + + + + + + 0 + 0 + + + + + + + + :/core/images/list-remove.png:/core/images/list-remove.png + + + + 20 + 20 + + + + true + + + + + + + + 0 + 0 + + + + + + + + :/core/images/go-up.png:/core/images/go-up.png + + + + 20 + 20 + + + + true + + + + + + + + 0 + 0 + + + + + + + + :/core/images/go-down.png:/core/images/go-down.png + + + + 20 + 20 + + + + true + + + + + + + + - + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/example/qnel_widget.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/example/qnel_widget.h index b0969c3a2..25f8fa651 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/example/qnel_widget.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/example/qnel_widget.h @@ -20,6 +20,7 @@ // NeL includes #include +#include #include // Qt includes @@ -54,11 +55,24 @@ public: /// Set the update interval renderer void setInterval(int msec); - float getFPS() const + /// Set the background color. + void setBackgroundColor(NLMISC::CRGBA backgroundColor); + + float fps() const { return m_fps; } + inline NLMISC::CRGBA backgroundColor() const + { + return m_backgroundColor; + } + + NL3D::UDriver *driver() const + { + return m_driver; + } + virtual QPaintEngine* paintEngine() const { return NULL; @@ -90,7 +104,10 @@ private: QNLWidget &operator=(const QNLWidget &); NL3D::UDriver *m_driver; + NLMISC::CRGBA m_backgroundColor; + QTimer *m_mainTimer; + bool m_initialized; int m_interval; float m_fps;