Changed: #1193 Added general settings page. ICore emits a signal changeSettings() when changing settings. Enabled sound in object viewer plugin.

This commit is contained in:
dnk-88 2011-05-09 18:27:09 +03:00
parent 92e6544944
commit bfa32f26e1
18 changed files with 551 additions and 272 deletions

View file

@ -1,6 +1,6 @@
/** /**
@mainpage Object Viewer Qt @mainpage Object Viewer Qt
@author Dzmitry Kamiahin <dnk-88@tut.by>, (C) 2010 @author Dzmitry Kamiahin <dnk-88@tut.by>, (C) 2011
@section introduce Introduce @section introduce Introduce
@details @details
@ -15,130 +15,22 @@ The tool can be used in different tasks:
- Create and modify micro-vegetation material (.vegetset files) - Create and modify micro-vegetation material (.vegetset files)
- Viewing landscape (.zonel files) - Viewing landscape (.zonel files)
- Dialog allows to specify graphical, sound, search path and landscape settings. - Dialog allows to specify graphical, sound, search path and landscape settings.
- OVQT supports loading third-party plug-ins.
@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.
<b>
The structure of the GUI in the editor of the particles.
</b><br>
This can be useful for new developers who want to add more new dialogs or to improve the functionality of existing dialogues.
<img src="gui_struct.png" alt="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 <a href="http://doc.qt.nokia.com/4.5/designer-using-custom-widgets.html"> here </a>.
<ol>
<li><b>
CEditRangeUIntWidget / CEditRangeIntWidget / CEditRangeFloatWidget
</b><br>
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.
<br><br>
<img src="cedit_range_int_widget.png" alt="CEditRangeIntWidget">
<br>
<img src="cedit_range_float_widget.png" alt="CEditRangeFloatWidget">
@see
@ref NLQT::CEditRangeUIntWidget, @ref NLQT::CEditRangeIntWidget, @ref NLQT::CEditRangeFloatWidget
<li><b>
CColorEditWidget
</b><br>
Using this widget you can set the color(RGBA) using the four sliders or through the color selection dialog.
<br><br>
<img src="cedit_color_widget.png" alt="CColorEditWidget">
@see
@ref NLQT::CColorEditWidget
<li><b>
CDirectionWidget
</b><br>
This widget helps to choose from several preset directions, or to choose a custom one.
<br><br>
<img src="cdirection_widget.png" alt="CDirectionWidget">
@see
@ref NLQT::CDirectionWidget
</ol><br><br>
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).
<img src="object_viewer_qt_window.png" alt="Object Viewer Qt">
<ol>
<li>
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.
<li>
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.
<li>
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.
</ol>
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, <b>all dialogs must use the qt layout manager</b>. And if you do not use the designer,
make sure you use the qt tools internationalization applications.
<br><br>
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().
@section license_ovqt License Object Viewer Qt @section license_ovqt License Object Viewer Qt
@details @details
Object Viewer Qt Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom>
<br> <br>
Copyright (C) 2010 Dzmitry Kamiahin <dnk-88@tut.by> 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.
<br><br> <br><br>
This program is free software: you can redistribute it and/or modify This program is distributed in the hope that it will be useful,
it under the terms of the GNU General Public License as published by but WITHOUT ANY WARRANTY; without even the implied warranty of
the Free Software Foundation, either version 3 of the License, or MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
(at your option) any later version. GNU Affero General Public License for more details.
<br><br> <br><br>
This program is distributed in the hope that it will be useful, You should have received a copy of the GNU Affero General Public License
but WITHOUT ANY WARRANTY; without even the implied warranty of along with this program. If not, see <http://www.gnu.org/licenses/>.
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
<br><br>
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */

View file

@ -20,10 +20,12 @@ SET(OVQT_CORE_PLUGIN_HDR
menu_manager.h menu_manager.h
settings_dialog.h settings_dialog.h
search_paths_settings_page.h search_paths_settings_page.h
general_settings_page.h
plugin_view_dialog.h) plugin_view_dialog.h)
SET(OVQT_CORE_PLUGIN_UIS settings_dialog.ui SET(OVQT_CORE_PLUGIN_UIS settings_dialog.ui
plugin_view_dialog.ui plugin_view_dialog.ui
general_settings_page.ui
search_paths_settings_page.ui) search_paths_settings_page.ui)
SET(OVQT_CORE_PLUGIN_RCS core.qrc) SET(OVQT_CORE_PLUGIN_RCS core.qrc)

View file

@ -24,7 +24,7 @@ namespace Constants
{ {
const char * const OVQT_VERSION_LONG = "0.0.1"; 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_YEAR = "2010, 2011";
const char * const OVQT_CORE_PLUGIN = "Core"; 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"; const char * const ABOUT_QT = "ObjectViewerQt.AboutQt";
//settings //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 DATA_PATH_SECTION = "DataPath";
const char * const SEARCH_PATHS = "SearchPaths"; const char * const SEARCH_PATHS = "SearchPaths";
const char * const RECURSIVE_SEARCH_PATHS = "RecursiveSearchPathes"; const char * const RECURSIVE_SEARCH_PATHS = "RecursiveSearchPathes";

View file

@ -20,8 +20,8 @@
#include "settings_dialog.h" #include "settings_dialog.h"
#include "core_constants.h" #include "core_constants.h"
#include "search_paths_settings_page.h" #include "search_paths_settings_page.h"
#include "general_settings_page.h"
#include "../../extension_system/iplugin_spec.h" #include "../../extension_system/iplugin_spec.h"
#include "qtwin.h"
// NeL includes // NeL includes
#include "nel/misc/debug.h" #include "nel/misc/debug.h"
@ -42,37 +42,37 @@ CorePlugin::CorePlugin()
CorePlugin::~CorePlugin() CorePlugin::~CorePlugin()
{ {
Q_FOREACH(QObject *obj, _autoReleaseObjects) Q_FOREACH(QObject *obj, m_autoReleaseObjects)
{ {
_plugMan->removeObject(obj); m_plugMan->removeObject(obj);
} }
qDeleteAll(_autoReleaseObjects); qDeleteAll(m_autoReleaseObjects);
_autoReleaseObjects.clear(); m_autoReleaseObjects.clear();
delete _mainWindow; delete m_mainWindow;
} }
bool CorePlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString) bool CorePlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString)
{ {
Q_UNUSED(errorString); Q_UNUSED(errorString);
_plugMan = pluginManager; m_plugMan = pluginManager;
_mainWindow = new MainWindow(pluginManager); m_mainWindow = new MainWindow(pluginManager);
/*if (QtWin::isCompositionEnabled()) bool success = m_mainWindow->initialize(errorString);
{
QtWin::extendFrameIntoClientArea(_mainWindow); GeneralSettingsPage *generalSettings = new GeneralSettingsPage(this);
_mainWindow->setContentsMargins(0, 0, 0, 0); CSearchPathsSettingsPage *searchPathPage = new CSearchPathsSettingsPage(this);
}*/
bool success = _mainWindow->initialize(errorString); generalSettings->applyGeneralSettings();
CSearchPathsSettingsPage *serchPathPage = new CSearchPathsSettingsPage(this); searchPathPage->applySearchPaths();
serchPathPage->applySearchPaths(); addAutoReleasedObject(generalSettings);
addAutoReleasedObject(serchPathPage); addAutoReleasedObject(searchPathPage);
return success; return success;
} }
void CorePlugin::extensionsInitialized() void CorePlugin::extensionsInitialized()
{ {
_mainWindow->extensionsInitialized(); m_mainWindow->extensionsInitialized();
} }
void CorePlugin::shutdown() void CorePlugin::shutdown()
@ -86,7 +86,7 @@ void CorePlugin::setNelContext(NLMISC::INelContext *nelContext)
// This only applies to platforms without PIC, e.g. Windows. // This only applies to platforms without PIC, e.g. Windows.
nlassert(!NLMISC::INelContext::isContextInitialised()); nlassert(!NLMISC::INelContext::isContextInitialised());
#endif // NL_OS_WINDOWS #endif // NL_OS_WINDOWS
_LibContext = new NLMISC::CLibraryContext(*nelContext); m_libContext = new NLMISC::CLibraryContext(*nelContext);
} }
QString CorePlugin::name() const QString CorePlugin::name() const
@ -116,8 +116,8 @@ QStringList CorePlugin::dependencies() const
void CorePlugin::addAutoReleasedObject(QObject *obj) void CorePlugin::addAutoReleasedObject(QObject *obj)
{ {
_plugMan->addObject(obj); m_plugMan->addObject(obj);
_autoReleaseObjects.prepend(obj); m_autoReleaseObjects.prepend(obj);
} }
Q_EXPORT_PLUGIN(CorePlugin) Q_EXPORT_PLUGIN(CorePlugin)

View file

@ -63,16 +63,16 @@ public:
ExtensionSystem::IPluginManager *pluginManager() const ExtensionSystem::IPluginManager *pluginManager() const
{ {
return _plugMan; return m_plugMan;
} }
protected: protected:
NLMISC::CLibraryContext *_LibContext; NLMISC::CLibraryContext *m_libContext;
private: private:
ExtensionSystem::IPluginManager *_plugMan; ExtensionSystem::IPluginManager *m_plugMan;
MainWindow *_mainWindow; MainWindow *m_mainWindow;
QList<QObject *> _autoReleaseObjects; QList<QObject *> m_autoReleaseObjects;
}; };
} // namespace Core } // namespace Core

View file

@ -0,0 +1,187 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
//
// 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 <http://www.gnu.org/licenses/>.
// Project includes
#include "general_settings_page.h"
#include "core_constants.h"
#include "icore.h"
// NeL includes
#include <nel/misc/path.h>
// Qt includes
#include <QtCore/QSettings>
#include <QtGui/QWidget>
#include <QtGui/QMessageBox>
#include <QtGui/QFileDialog>
#include <QtGui/QStyleFactory>
#include <QtGui/QStyle>
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 */

View file

@ -0,0 +1,71 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
//
// 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 <http://www.gnu.org/licenses/>.
#ifndef GENERAL_SETTINGS_PAGE_H
#define GENERAL_SETTINGS_PAGE_H
#include <QtCore/QObject>
#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

View file

@ -0,0 +1,199 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GeneralSettingsPage</class>
<widget class="QWidget" name="GeneralSettingsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>267</width>
<height>282</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="margin">
<number>6</number>
</property>
<property name="spacing">
<number>3</number>
</property>
<item row="0" column="0">
<widget class="QGroupBox" name="qtStyleGroupBox">
<property name="title">
<string>Qt Style</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>6</number>
</property>
<item>
<widget class="QComboBox" name="styleComboBox">
<item>
<property name="text">
<string>default</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QCheckBox" name="paletteCheckBox">
<property name="text">
<string>Use style's standard palette</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="languageGroupBox">
<property name="title">
<string>Language</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="margin">
<number>6</number>
</property>
<item>
<widget class="QComboBox" name="languageComboBox">
<property name="enabled">
<bool>false</bool>
</property>
<item>
<property name="text">
<string>English</string>
</property>
</item>
<item>
<property name="text">
<string>German</string>
</property>
</item>
<item>
<property name="text">
<string>French</string>
</property>
</item>
<item>
<property name="text">
<string>Russian</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QGroupBox" name="pathsGroupBox">
<property name="title">
<string>Paths</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>6</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="pluginsPathLabel">
<property name="text">
<string>Plugins path:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="pluginsPathLineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="pluginsPathButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="leveldesignPathLabel">
<property name="text">
<string>Level design path:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="leveldesignPathLineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="leveldesignPathButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="assetsPathLabel">
<property name="text">
<string>Assets path:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="assetsPathLineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QToolButton" name="assetsPathButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources>
<include location="core.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -59,6 +59,7 @@ public:
virtual ExtensionSystem::IPluginManager *pluginManager() const = 0; virtual ExtensionSystem::IPluginManager *pluginManager() const = 0;
Q_SIGNALS: Q_SIGNALS:
void changeSettings();
void closeMainWindow(); void closeMainWindow();
}; };

View file

@ -60,6 +60,7 @@ MainWindow::MainWindow(ExtensionSystem::IPluginManager *pluginManager, QWidget *
m_tabWidget = new QTabWidget(this); m_tabWidget = new QTabWidget(this);
m_tabWidget->setTabPosition(QTabWidget::South); m_tabWidget->setTabPosition(QTabWidget::South);
m_tabWidget->setMovable(true); m_tabWidget->setMovable(true);
m_tabWidget->setDocumentMode(true);
setCentralWidget(m_tabWidget); setCentralWidget(m_tabWidget);
setDockNestingEnabled(true); setDockNestingEnabled(true);
@ -118,6 +119,10 @@ ExtensionSystem::IPluginManager *MainWindow::pluginManager() const
return m_pluginManager; return m_pluginManager;
} }
void MainWindow::open()
{
}
void MainWindow::checkObject(QObject *obj) void MainWindow::checkObject(QObject *obj)
{ {
IContext *context = qobject_cast<IContext *>(obj); IContext *context = qobject_cast<IContext *>(obj);
@ -133,7 +138,10 @@ bool MainWindow::showOptionsDialog(const QString &group,
parent = this; parent = this;
CSettingsDialog settingsDialog(m_pluginManager, group, page, parent); CSettingsDialog settingsDialog(m_pluginManager, group, page, parent);
settingsDialog.show(); settingsDialog.show();
return settingsDialog.execDialog(); bool ok = settingsDialog.execDialog();
if (ok)
Q_EMIT m_coreImpl->changeSettings();
return ok;
} }
void MainWindow::about() void MainWindow::about()
@ -177,7 +185,7 @@ void MainWindow::createActions()
m_openAction->setShortcut(QKeySequence::Open); m_openAction->setShortcut(QKeySequence::Open);
m_openAction->setStatusTip(tr("Open an existing file")); m_openAction->setStatusTip(tr("Open an existing file"));
menuManager()->registerAction(m_openAction, Constants::OPEN); 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 = new QAction(tr("E&xit"), this);
m_exitAction->setShortcut(QKeySequence(tr("Ctrl+Q"))); m_exitAction->setShortcut(QKeySequence(tr("Ctrl+Q")));
@ -220,6 +228,7 @@ void MainWindow::createMenus()
{ {
m_fileMenu = menuBar()->addMenu(tr("&File")); m_fileMenu = menuBar()->addMenu(tr("&File"));
menuManager()->registerMenu(m_fileMenu, Constants::M_FILE); menuManager()->registerMenu(m_fileMenu, Constants::M_FILE);
// m_fileMenu->addAction(m_openAction);
m_fileMenu->addSeparator(); m_fileMenu->addSeparator();
m_fileMenu->addAction(m_exitAction); m_fileMenu->addAction(m_exitAction);
@ -260,17 +269,17 @@ void MainWindow::createDialogs()
void MainWindow::readSettings() void MainWindow::readSettings()
{ {
m_settings->beginGroup("MainWindow"); m_settings->beginGroup(Constants::MAIN_WINDOW_SECTION);
restoreState(m_settings->value("WindowState").toByteArray()); restoreState(m_settings->value(Constants::MAIN_WINDOW_STATE).toByteArray());
restoreGeometry(m_settings->value("WindowGeometry").toByteArray()); restoreGeometry(m_settings->value(Constants::MAIN_WINDOW_GEOMETRY).toByteArray());
m_settings->endGroup(); m_settings->endGroup();
} }
void MainWindow::writeSettings() void MainWindow::writeSettings()
{ {
m_settings->beginGroup("MainWindow"); m_settings->beginGroup(Constants::MAIN_WINDOW_SECTION);
m_settings->setValue("WindowState", saveState()); m_settings->setValue(Constants::MAIN_WINDOW_STATE, saveState());
m_settings->setValue("WindowGeometry", saveGeometry()); m_settings->setValue(Constants::MAIN_WINDOW_GEOMETRY, saveGeometry());
m_settings->endGroup(); m_settings->endGroup();
} }

View file

@ -59,6 +59,7 @@ public Q_SLOTS:
QWidget *parent = 0); QWidget *parent = 0);
private Q_SLOTS: private Q_SLOTS:
void open();
void checkObject(QObject *obj); void checkObject(QObject *obj);
void about(); void about();

View file

@ -45,7 +45,7 @@ CSearchPathsSettingsPage::~CSearchPathsSettingsPage()
QString CSearchPathsSettingsPage::id() const QString CSearchPathsSettingsPage::id() const
{ {
return QLatin1String("SearchPaths"); return QLatin1String("search_paths");
} }
QString CSearchPathsSettingsPage::trName() const QString CSearchPathsSettingsPage::trName() const
@ -55,12 +55,12 @@ QString CSearchPathsSettingsPage::trName() const
QString CSearchPathsSettingsPage::category() const QString CSearchPathsSettingsPage::category() const
{ {
return QLatin1String("General"); return QLatin1String(Constants::SETTINGS_CATEGORY_GENERAL);
} }
QString CSearchPathsSettingsPage::trCategory() const QString CSearchPathsSettingsPage::trCategory() const
{ {
return tr("General"); return tr(Constants::SETTINGS_TR_CATEGORY_GENERAL);
} }
QWidget *CSearchPathsSettingsPage::createPage(QWidget *parent) QWidget *CSearchPathsSettingsPage::createPage(QWidget *parent)

View file

@ -45,7 +45,7 @@ using namespace Plugin;
namespace ExtensionSystem namespace ExtensionSystem
{ {
class IPluginSpec; class IPluginSpec;
} }
CLogPlugin::CLogPlugin(QWidget *parent): QDockWidget(parent) CLogPlugin::CLogPlugin(QWidget *parent): QDockWidget(parent)
@ -55,7 +55,7 @@ CLogPlugin::CLogPlugin(QWidget *parent): QDockWidget(parent)
CLogPlugin::~CLogPlugin() CLogPlugin::~CLogPlugin()
{ {
_plugMan->removeObject(_logSettingsPage); //_plugMan->removeObject(_logSettingsPage);
delete _logSettingsPage; delete _logSettingsPage;
NLMISC::ErrorLog->removeDisplayer(_displayer); NLMISC::ErrorLog->removeDisplayer(_displayer);
@ -71,7 +71,7 @@ bool CLogPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QStr
Q_UNUSED(errorString); Q_UNUSED(errorString);
_plugMan = pluginManager; _plugMan = pluginManager;
_logSettingsPage = new CLogSettingsPage(this); _logSettingsPage = new CLogSettingsPage(this);
_plugMan->addObject(_logSettingsPage); //_plugMan->addObject(_logSettingsPage);
return true; return true;
} }
@ -97,11 +97,11 @@ void CLogPlugin::extensionsInitialized()
void CLogPlugin::setNelContext(NLMISC::INelContext *nelContext) void CLogPlugin::setNelContext(NLMISC::INelContext *nelContext)
{ {
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
// Ensure that a context doesn't exist yet. // Ensure that a context doesn't exist yet.
// This only applies to platforms without PIC, e.g. Windows. // This only applies to platforms without PIC, e.g. Windows.
nlassert(!NLMISC::INelContext::isContextInitialised()); nlassert(!NLMISC::INelContext::isContextInitialised());
#endif // fdef NL_OS_WINDOWS^M #endif // fdef NL_OS_WINDOWS^M
_LibContext = new NLMISC::CLibraryContext(*nelContext); _LibContext = new NLMISC::CLibraryContext(*nelContext);
_displayer = new NLQT::CQtDisplayer(_ui.plainTextEdit); _displayer = new NLQT::CQtDisplayer(_ui.plainTextEdit);

View file

@ -91,7 +91,7 @@
<item> <item>
<widget class="QPushButton" name="bankButton"> <widget class="QPushButton" name="bankButton">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>false</bool>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">

View file

@ -25,8 +25,6 @@
// Qt includes // Qt includes
#include <QtCore/QSettings> #include <QtCore/QSettings>
#include <QtGui/QWidget> #include <QtGui/QWidget>
#include <QtGui/QStyleFactory>
#include <QtGui/QStyle>
// NeL includes // NeL includes
#include <nel/3d/bloom_effect.h> #include <nel/3d/bloom_effect.h>
@ -75,11 +73,6 @@ QWidget *GraphicsSettingsPage::createPage(QWidget *parent)
m_ui.squareBloomCheckBox->setChecked(NL3D::CBloomEffect::instance().getSquareBloom()); m_ui.squareBloomCheckBox->setChecked(NL3D::CBloomEffect::instance().getSquareBloom());
m_ui.bloomDensityHorizontalSlider->setValue(NL3D::CBloomEffect::instance().getDensityBloom()); 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(); settings->endGroup();
connect(m_ui.enableBloomCheckBox, SIGNAL(toggled(bool)), this, SLOT(setEnableBloom(bool))); 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_BLOOM, m_ui.enableBloomCheckBox->isChecked());
settings->setValue(Constants::ENABLE_SQUARE_BLOOM, m_ui.squareBloomCheckBox->isChecked()); settings->setValue(Constants::ENABLE_SQUARE_BLOOM, m_ui.squareBloomCheckBox->isChecked());
settings->setValue(Constants::BLOOM_DENSITY, m_ui.bloomDensityHorizontalSlider->value()); 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->endGroup();
settings->sync(); settings->sync();

View file

@ -117,50 +117,7 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="2" column="0" colspan="3"> <item row="2" column="0">
<widget class="QGroupBox" name="qtStyleGroupBox">
<property name="title">
<string>Qt Style</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Style</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="styleComboBox"/>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="paletteCheckBox">
<property name="text">
<string>Use style's standard palette</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
@ -170,14 +127,14 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="2" column="1">
<widget class="QLineEdit" name="fontLineEdit"> <widget class="QLineEdit" name="fontLineEdit">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="2"> <item row="2" column="2">
<widget class="QToolButton" name="fontSelectButton"> <widget class="QToolButton" name="fontSelectButton">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
@ -187,7 +144,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="1"> <item row="3" column="1">
<spacer name="verticalSpacer_2"> <spacer name="verticalSpacer_2">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>

View file

@ -66,7 +66,7 @@ CMainWindow::CMainWindow(QWidget *parent)
_isGraphicsInitialized(false), _isGraphicsInitialized(false),
_isGraphicsEnabled(false), _isGraphicsEnabled(false),
_isSoundInitialized(false), _isSoundInitialized(false),
_isSoundEnabled(false), _isSoundEnabled(true),
_GraphicsViewport(NULL), _GraphicsViewport(NULL),
_lastDir("."), _lastDir("."),
_mouseMode(NL3D::U3dMouseListener::edit3d) _mouseMode(NL3D::U3dMouseListener::edit3d)
@ -80,19 +80,6 @@ CMainWindow::CMainWindow(QWidget *parent)
setDockNestingEnabled(true); 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(); _GraphicsViewport->init();
_isGraphicsInitialized = true; _isGraphicsInitialized = true;
@ -111,6 +98,9 @@ CMainWindow::CMainWindow(QWidget *parent)
setWindowIcon(QIcon(":/images/nel.png")); setWindowIcon(QIcon(":/images/nel.png"));
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Constants::OBJECT_VIEWER_SECTION);
restoreState(settings->value("QtWindowState").toByteArray()); restoreState(settings->value("QtWindowState").toByteArray());
restoreGeometry(settings->value("QtWindowGeometry").toByteArray()); restoreGeometry(settings->value("QtWindowGeometry").toByteArray());
@ -484,22 +474,6 @@ bool CMainWindow::loadFile(const QString &fileName, const QString &skelName)
return true; 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() void CMainWindow::updateRender()
{ {
if (isVisible()) if (isVisible())

View file

@ -71,10 +71,6 @@ public:
{ {
return _SkeletonTreeModel; return _SkeletonTreeModel;
} }
QPalette getOriginalPalette() const
{
return _originalPalette;
}
private Q_SLOTS: private Q_SLOTS:
void open(); void open();
@ -96,10 +92,6 @@ private:
bool loadFile(const QString &fileName, const QString &skelName); 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 _isGraphicsInitialized, _isGraphicsEnabled;
bool _isSoundInitialized, _isSoundEnabled; bool _isSoundInitialized, _isSoundEnabled;
@ -122,7 +114,6 @@ private:
CCameraControl *_cameraControl; CCameraControl *_cameraControl;
QPalette _originalPalette;
QString _lastDir; QString _lastDir;
QTimer *_mainTimer; QTimer *_mainTimer;