From 2011120cb2c8fb06245c0093b176ff479b2249ea Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Mon, 9 May 2011 18:27:09 +0300 Subject: [PATCH] Changed: #1193 Added general settings page. ICore emits a signal changeSettings() when changing settings. Enabled sound in object viewer plugin. --- .../3d/object_viewer_qt/src/description.h | 134 ++---------- .../src/plugins/core/CMakeLists.txt | 2 + .../src/plugins/core/core_constants.h | 14 +- .../src/plugins/core/core_plugin.cpp | 42 ++-- .../src/plugins/core/core_plugin.h | 10 +- .../plugins/core/general_settings_page.cpp | 187 ++++++++++++++++ .../src/plugins/core/general_settings_page.h | 71 +++++++ .../src/plugins/core/general_settings_page.ui | 199 ++++++++++++++++++ .../object_viewer_qt/src/plugins/core/icore.h | 1 + .../src/plugins/core/main_window.cpp | 25 ++- .../src/plugins/core/main_window.h | 1 + .../core/search_paths_settings_page.cpp | 6 +- .../src/plugins/log/log_plugin.cpp | 18 +- .../src/plugins/object_viewer/attrib_form.ui | 2 +- .../object_viewer/graphics_settings_page.cpp | 17 -- .../object_viewer/graphics_settings_page.ui | 51 +---- .../src/plugins/object_viewer/main_window.cpp | 34 +-- .../src/plugins/object_viewer/main_window.h | 9 - 18 files changed, 551 insertions(+), 272 deletions(-) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.ui diff --git a/code/nel/tools/3d/object_viewer_qt/src/description.h b/code/nel/tools/3d/object_viewer_qt/src/description.h index d22a1918b..a1a041de9 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/description.h +++ b/code/nel/tools/3d/object_viewer_qt/src/description.h @@ -1,6 +1,6 @@ /** @mainpage Object Viewer Qt -@author Dzmitry Kamiahin , (C) 2010 +@author Dzmitry Kamiahin , (C) 2011 @section introduce Introduce @details @@ -15,130 +15,22 @@ The tool can be used in different tasks: - Create and modify micro-vegetation material (.vegetset files) - Viewing landscape (.zonel files) - Dialog allows to specify graphical, sound, search path and landscape settings. - -@section project_structure Overview of the Object Viewer Qt Project Structure -@details -OVQT - consists of several major subsystems. Each subsystem performs its defined part of the task. -Through Modules:: provides access to all other program subsystems. - -Program has the following subsystems: -- @ref Modules - Main modules aggregated all parts of the program. -- @ref NLQT::CConfiguration - is responsible for loading and saving settings from the configuration file. As well as search path of data. -- @ref NLQT::CObjectViewer - main subsystem of the program, which initializes the driver, creates a scene and other supporting elements. -It is a container for loaded models, which can further be viewed and animated. -- @ref NLQT::CMainWindow - is responsible for the GUI. -- @ref NLQT::CParticleEditor - is responsible for the particle systems and provides access to a container that keeps all the loaded particle systems. -And also allows you to view an animation of particle systems, with the ability to control its parameters. -- @ref NLQT::CVegetableEditor - is responsible for the landscape zones and the editor of vegetation. -Allows you to load and view the landscape. Also has the ability to create and edit the parameters of the micro-vegetation. -- @ref NLQT::CSoundSystem - is responsible for the sound in the program. - - -The structure of the GUI in the editor of the particles. -
-This can be useful for new developers who want to add more new dialogs or to improve the functionality of existing dialogues. -Particle Workspace -ParticleWorkspace dialogue uses the technique of model-view. -Using the signal/slot link QTreeView with QStackWidget, Editor properties dialog. -When you select an item in QTreeView, QStackWidget displays the necessary page(PageWidget) where you can edit the element of the particles system. -Each page is made in the designer and has a separate forms(.ui). -In accordance with the recommendations of dialogues design, with a large number of items,every page uses QTabWidget. -In case when there is a great number of controls, and not everything you want to display, -it's used the dynamic creation of tabs. Moreover, each tab uses a separate forms(.ui). - -@section for_new_developer Guide for new developers of the Object Viewer Qt. -@details - First of all, to begin developing dialogues that add new features ovqt, -it is needed to read the documentation Qt libs (http://doc.qt.nokia.com/) and NeL documentation. - - In order to have convenient using of the tool and its further development, -it is expected to make a unified interface that is why all dialogs should adhere to a standard design, -which will be written further. For this goals program provides some additional widgets, -which are recommended to use. As in the development Qt Designer is actively used. -To get access to founded here widgets from the designer,the technique promotion is used, -which can be found here . -
    -
  1. -CEditRangeUIntWidget / CEditRangeIntWidget / CEditRangeFloatWidget -
    -Widgets provides a slider that allows you to specify an integer (or float, depending on which widget used) number within a set range. -The range is also can be set by the user, or for a more accurate selection of numbers, either for receiving large values. -As there may be situations when the range that a user requests,has to be restricted, and widget provides methods that allow you to do so. -

    -CEditRangeIntWidget -
    -CEditRangeFloatWidget -@see -@ref NLQT::CEditRangeUIntWidget, @ref NLQT::CEditRangeIntWidget, @ref NLQT::CEditRangeFloatWidget - -
  2. -CColorEditWidget -
    -Using this widget you can set the color(RGBA) using the four sliders or through the color selection dialog. -

    -CColorEditWidget -@see -@ref NLQT::CColorEditWidget - -
  3. -CDirectionWidget -
    -This widget helps to choose from several preset directions, or to choose a custom one. -

    -CDirectionWidget -@see -@ref NLQT::CDirectionWidget -


- -To further convinience of instrument using dialogues interface is recommended to make as follows. -The most sophisticated tools of the program, should take the form of three dock windows (example shown in the screenshot). -Object Viewer Qt -
    -
  1. -The first dock window - is a control dock window, it should focus all of the control functions of general purpose -(for example: start/stop/pause animations or particles system). -It is recommended to perform of the horizontal type window and placed in the bottom of the main window. -
  2. -The second dock window - is a list or a tree of items. In which selecting of the current element, -which assumes to modify or viewis possible.Operations "add/remove/insert or other" items are recommended to make as a popur menu. -It is recommended to perform of the vertical type window and placed in the left of the main window. -
  3. -The third dock - is an editor for properties of the element that was selected in the list or in the tree of elements. -As all the controls occupy much space or do not fit at all, you have to use tabs QTabWidget, -which in total can contains quite a lot of elements. -For a small number of tabs it is allowed to use both horizontal and vertical location. -But with a large number of tabs, it is necessary to apply the vertical arrangement. -It is recommended to perform of the vertical type of window and placed in the right of the main window. -
-In the simple dialogues do not necessary to use all three windows, but user has to adhere to the recommendations given above as well. -Also, all dialogs must use the qt layout manager. And if you do not use the designer, -make sure you use the qt tools internationalization applications. -

-In ovqt for most dialogs their owner is NLQT::CMainWindow and in its methods creating and initializing all dependent dialogs occur. -For the convenience of the program using, most dialogues are created in the form of docking windows. -Creating all the dialogues are carried out in a private method NLQT::CMainWindow::createDialogs(). -Hence, it is necessary to add operations in this method to create new dialogues. -But we must take into account that at this moment is fully available only one component of the program CConfiguration, -to read the settings from the configuration file. The remaining components of the program are available only after the main window stays visible. -Calling the dialogues going through the menu or the toolbar, usually it is a checkable item. -Adding of the new menu items or items toolbars is need in methods NLQT::CMainWindow::createMenus(), NLQT::CMainWindow::createToolBars(). +- OVQT supports loading third-party plug-ins. @section license_ovqt License Object Viewer Qt @details - Object Viewer Qt +Object Viewer Qt - MMORPG Framework
- 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 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 Affero General Public License for more details.

- 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 . +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . */ \ 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 index 726cb4a2d..06095790b 100644 --- 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 @@ -20,10 +20,12 @@ SET(OVQT_CORE_PLUGIN_HDR menu_manager.h settings_dialog.h search_paths_settings_page.h + general_settings_page.h plugin_view_dialog.h) SET(OVQT_CORE_PLUGIN_UIS settings_dialog.ui plugin_view_dialog.ui + general_settings_page.ui search_paths_settings_page.ui) SET(OVQT_CORE_PLUGIN_RCS core.qrc) 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 2adf4f35a..eb59cddd2 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 @@ -24,7 +24,7 @@ namespace Constants { const char * const OVQT_VERSION_LONG = "0.0.1"; -const char * const OVQT_VENDOR = "Dzmitry Kamiahin"; +const char * const OVQT_VENDOR = "Ryzom Core"; const char * const OVQT_YEAR = "2010, 2011"; const char * const OVQT_CORE_PLUGIN = "Core"; @@ -61,6 +61,18 @@ const char * const ABOUT_PLUGINS = "ObjectViewerQt.AboutPlugins"; const char * const ABOUT_QT = "ObjectViewerQt.AboutQt"; //settings +const char * const SETTINGS_CATEGORY_GENERAL = "general"; +const char * const SETTINGS_CATEGORY_GENERAL_ICON = ":/icons/ic_nel_generic_settings.png"; +const char * const SETTINGS_TR_CATEGORY_GENERAL = QT_TR_NOOP("General"); + +const char * const MAIN_WINDOW_SECTION = "MainWindow"; +const char * const MAIN_WINDOW_STATE = "WindowState"; +const char * const MAIN_WINDOW_GEOMETRY = "WindowGeometry"; +const char * const QT_STYLE = "QtStyle"; +const char * const QT_PALETTE = "QtPalette"; + +const char * const LANGUAGE = "Language"; +const char * const PLUGINS_PATH = "PluginPath"; const char * const DATA_PATH_SECTION = "DataPath"; const char * const SEARCH_PATHS = "SearchPaths"; const char * const RECURSIVE_SEARCH_PATHS = "RecursiveSearchPathes"; 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 6d051d64d..6cb58ba67 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 @@ -20,8 +20,8 @@ #include "settings_dialog.h" #include "core_constants.h" #include "search_paths_settings_page.h" +#include "general_settings_page.h" #include "../../extension_system/iplugin_spec.h" -#include "qtwin.h" // NeL includes #include "nel/misc/debug.h" @@ -42,37 +42,37 @@ CorePlugin::CorePlugin() CorePlugin::~CorePlugin() { - Q_FOREACH(QObject *obj, _autoReleaseObjects) + Q_FOREACH(QObject *obj, m_autoReleaseObjects) { - _plugMan->removeObject(obj); + m_plugMan->removeObject(obj); } - qDeleteAll(_autoReleaseObjects); - _autoReleaseObjects.clear(); + qDeleteAll(m_autoReleaseObjects); + m_autoReleaseObjects.clear(); - delete _mainWindow; + delete m_mainWindow; } bool CorePlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString) { Q_UNUSED(errorString); - _plugMan = pluginManager; + m_plugMan = pluginManager; - _mainWindow = new MainWindow(pluginManager); - /*if (QtWin::isCompositionEnabled()) - { - QtWin::extendFrameIntoClientArea(_mainWindow); - _mainWindow->setContentsMargins(0, 0, 0, 0); - }*/ - bool success = _mainWindow->initialize(errorString); - CSearchPathsSettingsPage *serchPathPage = new CSearchPathsSettingsPage(this); - serchPathPage->applySearchPaths(); - addAutoReleasedObject(serchPathPage); + m_mainWindow = new MainWindow(pluginManager); + bool success = m_mainWindow->initialize(errorString); + + GeneralSettingsPage *generalSettings = new GeneralSettingsPage(this); + CSearchPathsSettingsPage *searchPathPage = new CSearchPathsSettingsPage(this); + + generalSettings->applyGeneralSettings(); + searchPathPage->applySearchPaths(); + addAutoReleasedObject(generalSettings); + addAutoReleasedObject(searchPathPage); return success; } void CorePlugin::extensionsInitialized() { - _mainWindow->extensionsInitialized(); + m_mainWindow->extensionsInitialized(); } void CorePlugin::shutdown() @@ -86,7 +86,7 @@ void CorePlugin::setNelContext(NLMISC::INelContext *nelContext) // This only applies to platforms without PIC, e.g. Windows. nlassert(!NLMISC::INelContext::isContextInitialised()); #endif // NL_OS_WINDOWS - _LibContext = new NLMISC::CLibraryContext(*nelContext); + m_libContext = new NLMISC::CLibraryContext(*nelContext); } QString CorePlugin::name() const @@ -116,8 +116,8 @@ QStringList CorePlugin::dependencies() const void CorePlugin::addAutoReleasedObject(QObject *obj) { - _plugMan->addObject(obj); - _autoReleaseObjects.prepend(obj); + m_plugMan->addObject(obj); + m_autoReleaseObjects.prepend(obj); } 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 index ef590e1fc..5c95d22c9 100644 --- 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 @@ -63,16 +63,16 @@ public: ExtensionSystem::IPluginManager *pluginManager() const { - return _plugMan; + return m_plugMan; } protected: - NLMISC::CLibraryContext *_LibContext; + NLMISC::CLibraryContext *m_libContext; private: - ExtensionSystem::IPluginManager *_plugMan; - MainWindow *_mainWindow; - QList _autoReleaseObjects; + ExtensionSystem::IPluginManager *m_plugMan; + MainWindow *m_mainWindow; + QList m_autoReleaseObjects; }; } // namespace Core diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.cpp new file mode 100644 index 000000000..47bf4026a --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.cpp @@ -0,0 +1,187 @@ +// 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 "general_settings_page.h" +#include "core_constants.h" +#include "icore.h" + +// NeL includes +#include + +// Qt includes +#include +#include +#include +#include +#include +#include + +namespace Core +{ + +GeneralSettingsPage::GeneralSettingsPage(QObject *parent) + : IOptionsPage(parent), + m_page(0) +{ + m_originalPalette = QApplication::palette(); +} + +GeneralSettingsPage::~GeneralSettingsPage() +{ +} + +QString GeneralSettingsPage::id() const +{ + return QLatin1String("general_settings"); +} + +QString GeneralSettingsPage::trName() const +{ + return tr("General"); +} + +QString GeneralSettingsPage::category() const +{ + return QLatin1String(Constants::SETTINGS_CATEGORY_GENERAL); +} + +QString GeneralSettingsPage::trCategory() const +{ + return tr(Constants::SETTINGS_TR_CATEGORY_GENERAL); +} + +void GeneralSettingsPage::applyGeneralSettings() +{ + QSettings *settings = Core::ICore::instance()->settings(); + + settings->beginGroup(Constants::MAIN_WINDOW_SECTION); + QApplication::setStyle(QStyleFactory::create(settings->value(Constants::QT_STYLE, "").toString())); + + if (settings->value(Constants::QT_PALETTE, true).toBool()) + QApplication::setPalette(QApplication::style()->standardPalette()); + else + QApplication::setPalette(m_originalPalette); + settings->endGroup(); +} + +QWidget *GeneralSettingsPage::createPage(QWidget *parent) +{ + m_page = new QWidget(parent); + m_ui.setupUi(m_page); + + readSettings(); + connect(m_ui.languageComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeLanguage(QString))); + connect(m_ui.pluginsPathButton, SIGNAL(clicked()), this, SLOT(setPluginsPath())); + connect(m_ui.leveldesignPathButton, SIGNAL(clicked()), this, SLOT(setLevelDesignPath())); + connect(m_ui.assetsPathButton, SIGNAL(clicked()), this, SLOT(setAssetsPath())); + return m_page; +} + +void GeneralSettingsPage::apply() +{ + writeSettings(); + applyGeneralSettings(); +} + +void GeneralSettingsPage::finish() +{ + delete m_page; + m_page = 0; +} + +void GeneralSettingsPage::changeLanguage(const QString &lang) +{ + QMessageBox::information(0, tr("Restart required"), + tr("The language change will take effect after a restart of Object Viewer Qt.")); +} + +void GeneralSettingsPage::setPluginsPath() +{ + QString newPath = QFileDialog::getExistingDirectory(0, tr("Set the plugins path"), + m_ui.pluginsPathLineEdit->text()); + if (!newPath.isEmpty()) + { + m_ui.pluginsPathLineEdit->setText(newPath); + } +} + +void GeneralSettingsPage::setLevelDesignPath() +{ + QString newPath = QFileDialog::getExistingDirectory(0, tr("Set the level design path"), + m_ui.leveldesignPathLineEdit->text()); + if (!newPath.isEmpty()) + { + m_ui.leveldesignPathLineEdit->setText(newPath); + } +} + +void GeneralSettingsPage::setAssetsPath() +{ + QString newPath = QFileDialog::getExistingDirectory(0, tr("Set the assets path"), + m_ui.assetsPathLineEdit->text()); + if (!newPath.isEmpty()) + { + m_ui.assetsPathLineEdit->setText(newPath); + } +} + +void GeneralSettingsPage::readSettings() +{ + QSettings *settings = Core::ICore::instance()->settings(); + + m_ui.pluginsPathLineEdit->setText(settings->value(Core::Constants::PLUGINS_PATH, "./plugins").toString()); + + settings->beginGroup(Constants::MAIN_WINDOW_SECTION); + m_ui.styleComboBox->addItems(QStyleFactory::keys()); + QString style = settings->value(Constants::QT_STYLE, "").toString(); + if (style == "") + m_ui.styleComboBox->setCurrentIndex(0); + else + m_ui.styleComboBox->setCurrentIndex(m_ui.styleComboBox->findText(style)); + m_ui.paletteCheckBox->setChecked(settings->value(Constants::QT_PALETTE, true).toBool()); + settings->endGroup(); + + QStringList paths; + settings->beginGroup(Core::Constants::DATA_PATH_SECTION); + m_ui.leveldesignPathLineEdit->setText(settings->value(Core::Constants::LEVELDESIGN_PATH, "l:/leveldesign").toString()); + m_ui.assetsPathLineEdit->setText(settings->value(Core::Constants::ASSETS_PATH, "w:/database").toString()); + settings->endGroup(); +} + +void GeneralSettingsPage::writeSettings() +{ + QSettings *settings = Core::ICore::instance()->settings(); + + settings->setValue(Core::Constants::PLUGINS_PATH, m_ui.pluginsPathLineEdit->text()); + + settings->beginGroup(Constants::MAIN_WINDOW_SECTION); + if (m_ui.styleComboBox->currentIndex() == 0) + settings->setValue(Constants::QT_STYLE, ""); + else + settings->setValue(Constants::QT_STYLE, m_ui.styleComboBox->currentText()); + settings->setValue(Constants::QT_PALETTE, m_ui.paletteCheckBox->isChecked()); + settings->endGroup(); + + settings->beginGroup(Core::Constants::DATA_PATH_SECTION); + settings->setValue(Core::Constants::LEVELDESIGN_PATH, m_ui.leveldesignPathLineEdit->text()); + settings->setValue(Core::Constants::ASSETS_PATH, m_ui.assetsPathLineEdit->text()); + settings->endGroup(); + settings->sync(); +} + +} /* namespace Core */ \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.h new file mode 100644 index 000000000..2f73f8715 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.h @@ -0,0 +1,71 @@ +// 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 GENERAL_SETTINGS_PAGE_H +#define GENERAL_SETTINGS_PAGE_H + +#include + +#include "ioptions_page.h" + +#include "ui_general_settings_page.h" + +class QWidget; + +namespace Core +{ +/** +@class GeneralSettingsPage +*/ +class GeneralSettingsPage : public Core::IOptionsPage +{ + Q_OBJECT + +public: + GeneralSettingsPage(QObject *parent = 0); + ~GeneralSettingsPage(); + + QString id() const; + QString trName() const; + QString category() const; + QString trCategory() const; + QWidget *createPage(QWidget *parent); + + void apply(); + void finish(); + + void applyGeneralSettings(); + +private Q_SLOTS: + void changeLanguage(const QString &lang); + void setPluginsPath(); + void setLevelDesignPath(); + void setAssetsPath(); + +private: + void readSettings(); + void writeSettings(); + + QPalette m_originalPalette; + QWidget *m_page; + Ui::GeneralSettingsPage m_ui; +}; + +} // namespace Core + +#endif // GENERAL_SETTINGS_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.ui new file mode 100644 index 000000000..d2aa042e3 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.ui @@ -0,0 +1,199 @@ + + + GeneralSettingsPage + + + + 0 + 0 + 267 + 282 + + + + Form + + + + 6 + + + 3 + + + + + Qt Style + + + + 6 + + + 6 + + + + + + default + + + + + + + + Use style's standard palette + + + + + + + + + + Language + + + + 6 + + + + + false + + + + English + + + + + German + + + + + French + + + + + Russian + + + + + + + + + + + Paths + + + + 6 + + + 6 + + + + + Plugins path: + + + + + + + + 0 + 0 + + + + + + + + ... + + + + + + + Level design path: + + + + + + + + 0 + 0 + + + + + + + + ... + + + + + + + Assets path: + + + + + + + + 0 + 0 + + + + + + + + ... + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + 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 8f0c5b4ca..71f075973 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 @@ -59,6 +59,7 @@ public: virtual ExtensionSystem::IPluginManager *pluginManager() const = 0; Q_SIGNALS: + void changeSettings(); void closeMainWindow(); }; 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 44f415a25..e048aa80b 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 @@ -60,6 +60,7 @@ MainWindow::MainWindow(ExtensionSystem::IPluginManager *pluginManager, QWidget * m_tabWidget = new QTabWidget(this); m_tabWidget->setTabPosition(QTabWidget::South); m_tabWidget->setMovable(true); + m_tabWidget->setDocumentMode(true); setCentralWidget(m_tabWidget); setDockNestingEnabled(true); @@ -118,6 +119,10 @@ ExtensionSystem::IPluginManager *MainWindow::pluginManager() const return m_pluginManager; } +void MainWindow::open() +{ +} + void MainWindow::checkObject(QObject *obj) { IContext *context = qobject_cast(obj); @@ -133,7 +138,10 @@ bool MainWindow::showOptionsDialog(const QString &group, parent = this; CSettingsDialog settingsDialog(m_pluginManager, group, page, parent); settingsDialog.show(); - return settingsDialog.execDialog(); + bool ok = settingsDialog.execDialog(); + if (ok) + Q_EMIT m_coreImpl->changeSettings(); + return ok; } void MainWindow::about() @@ -177,7 +185,7 @@ void MainWindow::createActions() m_openAction->setShortcut(QKeySequence::Open); m_openAction->setStatusTip(tr("Open an existing file")); menuManager()->registerAction(m_openAction, Constants::OPEN); -// connect(m_openAction, SIGNAL(triggered()), this, SLOT(open())); + connect(m_openAction, SIGNAL(triggered()), this, SLOT(open())); m_exitAction = new QAction(tr("E&xit"), this); m_exitAction->setShortcut(QKeySequence(tr("Ctrl+Q"))); @@ -220,6 +228,7 @@ void MainWindow::createMenus() { m_fileMenu = menuBar()->addMenu(tr("&File")); menuManager()->registerMenu(m_fileMenu, Constants::M_FILE); +// m_fileMenu->addAction(m_openAction); m_fileMenu->addSeparator(); m_fileMenu->addAction(m_exitAction); @@ -260,17 +269,17 @@ void MainWindow::createDialogs() void MainWindow::readSettings() { - m_settings->beginGroup("MainWindow"); - restoreState(m_settings->value("WindowState").toByteArray()); - restoreGeometry(m_settings->value("WindowGeometry").toByteArray()); + m_settings->beginGroup(Constants::MAIN_WINDOW_SECTION); + restoreState(m_settings->value(Constants::MAIN_WINDOW_STATE).toByteArray()); + restoreGeometry(m_settings->value(Constants::MAIN_WINDOW_GEOMETRY).toByteArray()); m_settings->endGroup(); } void MainWindow::writeSettings() { - m_settings->beginGroup("MainWindow"); - m_settings->setValue("WindowState", saveState()); - m_settings->setValue("WindowGeometry", saveGeometry()); + m_settings->beginGroup(Constants::MAIN_WINDOW_SECTION); + m_settings->setValue(Constants::MAIN_WINDOW_STATE, saveState()); + m_settings->setValue(Constants::MAIN_WINDOW_GEOMETRY, saveGeometry()); m_settings->endGroup(); } 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 21d091ef3..4cc24e5eb 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 @@ -59,6 +59,7 @@ public Q_SLOTS: QWidget *parent = 0); private Q_SLOTS: + void open(); void checkObject(QObject *obj); void about(); 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 c52624717..6f0fcb47d 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 @@ -45,7 +45,7 @@ CSearchPathsSettingsPage::~CSearchPathsSettingsPage() QString CSearchPathsSettingsPage::id() const { - return QLatin1String("SearchPaths"); + return QLatin1String("search_paths"); } QString CSearchPathsSettingsPage::trName() const @@ -55,12 +55,12 @@ QString CSearchPathsSettingsPage::trName() const QString CSearchPathsSettingsPage::category() const { - return QLatin1String("General"); + return QLatin1String(Constants::SETTINGS_CATEGORY_GENERAL); } QString CSearchPathsSettingsPage::trCategory() const { - return tr("General"); + return tr(Constants::SETTINGS_TR_CATEGORY_GENERAL); } QWidget *CSearchPathsSettingsPage::createPage(QWidget *parent) 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 439cce7d9..ad772f593 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 @@ -45,7 +45,7 @@ using namespace Plugin; namespace ExtensionSystem { - class IPluginSpec; +class IPluginSpec; } CLogPlugin::CLogPlugin(QWidget *parent): QDockWidget(parent) @@ -53,9 +53,9 @@ CLogPlugin::CLogPlugin(QWidget *parent): QDockWidget(parent) _ui.setupUi(this); } -CLogPlugin::~CLogPlugin() +CLogPlugin::~CLogPlugin() { - _plugMan->removeObject(_logSettingsPage); + //_plugMan->removeObject(_logSettingsPage); delete _logSettingsPage; NLMISC::ErrorLog->removeDisplayer(_displayer); @@ -71,7 +71,7 @@ bool CLogPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QStr Q_UNUSED(errorString); _plugMan = pluginManager; _logSettingsPage = new CLogSettingsPage(this); - _plugMan->addObject(_logSettingsPage); + //_plugMan->addObject(_logSettingsPage); return true; } @@ -96,12 +96,12 @@ void CLogPlugin::extensionsInitialized() void CLogPlugin::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()); +#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 // fdef NL_OS_WINDOWS^M - _LibContext = new NLMISC::CLibraryContext(*nelContext); + _LibContext = new NLMISC::CLibraryContext(*nelContext); _displayer = new NLQT::CQtDisplayer(_ui.plainTextEdit); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/attrib_form.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/attrib_form.ui index 404444fc0..77c4b895f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/attrib_form.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/attrib_form.ui @@ -91,7 +91,7 @@ - true + false diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/graphics_settings_page.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/graphics_settings_page.cpp index 4e11ee15c..eabb67f3d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/graphics_settings_page.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/graphics_settings_page.cpp @@ -25,8 +25,6 @@ // Qt includes #include #include -#include -#include // NeL includes #include @@ -75,11 +73,6 @@ QWidget *GraphicsSettingsPage::createPage(QWidget *parent) m_ui.squareBloomCheckBox->setChecked(NL3D::CBloomEffect::instance().getSquareBloom()); m_ui.bloomDensityHorizontalSlider->setValue(NL3D::CBloomEffect::instance().getDensityBloom()); - m_ui.styleComboBox->addItems(QStyleFactory::keys()); - QString style = settings->value(Constants::QT_STYLE, "").toString(); - m_ui.styleComboBox->setCurrentIndex(m_ui.styleComboBox->findText(style)); - m_ui.paletteCheckBox->setChecked(settings->value(Constants::QT_PALETTE, true).toBool()); - settings->endGroup(); connect(m_ui.enableBloomCheckBox, SIGNAL(toggled(bool)), this, SLOT(setEnableBloom(bool))); @@ -103,16 +96,6 @@ void GraphicsSettingsPage::apply() settings->setValue(Constants::ENABLE_BLOOM, m_ui.enableBloomCheckBox->isChecked()); settings->setValue(Constants::ENABLE_SQUARE_BLOOM, m_ui.squareBloomCheckBox->isChecked()); settings->setValue(Constants::BLOOM_DENSITY, m_ui.bloomDensityHorizontalSlider->value()); - settings->setValue(Constants::QT_STYLE, m_ui.styleComboBox->currentText()); - settings->setValue(Constants::QT_PALETTE, m_ui.paletteCheckBox->isChecked()); - - // apply qt style and palette - QApplication::setStyle(QStyleFactory::create(m_ui.styleComboBox->currentText())); - - if (m_ui.paletteCheckBox->isChecked()) - QApplication::setPalette(QApplication::style()->standardPalette()); - else - QApplication::setPalette(Modules::mainWin().getOriginalPalette()); settings->endGroup(); settings->sync(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/graphics_settings_page.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/graphics_settings_page.ui index 24058d3d3..e6b4952a5 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/graphics_settings_page.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/graphics_settings_page.ui @@ -117,50 +117,7 @@ - - - - Qt Style - - - - - - - - Style - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - Use style's standard palette - - - - - - - + false @@ -170,14 +127,14 @@ - + false - + false @@ -187,7 +144,7 @@ - + Qt::Vertical diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/main_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/main_window.cpp index fa077cfed..6e183d913 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/main_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/main_window.cpp @@ -66,7 +66,7 @@ CMainWindow::CMainWindow(QWidget *parent) _isGraphicsInitialized(false), _isGraphicsEnabled(false), _isSoundInitialized(false), - _isSoundEnabled(false), + _isSoundEnabled(true), _GraphicsViewport(NULL), _lastDir("."), _mouseMode(NL3D::U3dMouseListener::edit3d) @@ -80,19 +80,6 @@ CMainWindow::CMainWindow(QWidget *parent) setDockNestingEnabled(true); - QSettings *settings = Core::ICore::instance()->settings(); - settings->beginGroup(Constants::OBJECT_VIEWER_SECTION); - - // setup Qt style and palette from config file - _originalPalette = QApplication::palette(); - - QApplication::setStyle(QStyleFactory::create(settings->value(Constants::QT_STYLE, "").toString())); - - if (settings->value(Constants::QT_PALETTE, true).toBool()) - QApplication::setPalette(QApplication::style()->standardPalette()); - else - QApplication::setPalette(_originalPalette); - _GraphicsViewport->init(); _isGraphicsInitialized = true; @@ -111,6 +98,9 @@ CMainWindow::CMainWindow(QWidget *parent) setWindowIcon(QIcon(":/images/nel.png")); + QSettings *settings = Core::ICore::instance()->settings(); + settings->beginGroup(Constants::OBJECT_VIEWER_SECTION); + restoreState(settings->value("QtWindowState").toByteArray()); restoreGeometry(settings->value("QtWindowGeometry").toByteArray()); @@ -484,22 +474,6 @@ bool CMainWindow::loadFile(const QString &fileName, const QString &skelName) return true; } -void CMainWindow::cfcbQtStyle(NLMISC::CConfigFile::CVar &var) -{ - QApplication::setStyle(QStyleFactory::create(var.asString().c_str())); -} - -void CMainWindow::cfcbQtPalette(NLMISC::CConfigFile::CVar &var) -{ - if (var.asBool()) QApplication::setPalette(QApplication::style()->standardPalette()); - else QApplication::setPalette(_originalPalette); -} - -void CMainWindow::cfcbSoundEnabled(NLMISC::CConfigFile::CVar &var) -{ - _isSoundEnabled = var.asBool(); // update loop inits -} - void CMainWindow::updateRender() { if (isVisible()) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/main_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/main_window.h index 3a6411df2..52b3dc8d5 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/main_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/main_window.h @@ -71,10 +71,6 @@ public: { return _SkeletonTreeModel; } - QPalette getOriginalPalette() const - { - return _originalPalette; - } private Q_SLOTS: void open(); @@ -96,10 +92,6 @@ private: bool loadFile(const QString &fileName, const QString &skelName); - void cfcbQtStyle(NLMISC::CConfigFile::CVar &var); - void cfcbQtPalette(NLMISC::CConfigFile::CVar &var); - void cfcbSoundEnabled(NLMISC::CConfigFile::CVar &var); - bool _isGraphicsInitialized, _isGraphicsEnabled; bool _isSoundInitialized, _isSoundEnabled; @@ -122,7 +114,6 @@ private: CCameraControl *_cameraControl; - QPalette _originalPalette; QString _lastDir; QTimer *_mainTimer;