Changed: #1206 Update plugin system. Added experimental core plugin. Added new settings dialog.
parent
83f82697c0
commit
2539e40403
@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
Object Viewer Qt
|
|
||||||
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 General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef PLUGIN_VIEW_H
|
|
||||||
#define PLUGIN_VIEW_H
|
|
||||||
|
|
||||||
#include "ui_plugin_view.h"
|
|
||||||
|
|
||||||
|
|
||||||
// STL includes
|
|
||||||
|
|
||||||
// Qt includes
|
|
||||||
|
|
||||||
// NeL includes
|
|
||||||
|
|
||||||
// Project includes
|
|
||||||
|
|
||||||
|
|
||||||
namespace NLQT
|
|
||||||
{
|
|
||||||
|
|
||||||
class IPluginManager;
|
|
||||||
|
|
||||||
class CPluginView: public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
CPluginView(IPluginManager *pluginManager, QWidget *parent = 0);
|
|
||||||
~CPluginView();
|
|
||||||
|
|
||||||
private Q_SLOTS:
|
|
||||||
void updateList();
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
IPluginManager *_pluginManager;
|
|
||||||
Ui::CPluginView _ui;
|
|
||||||
}; /* class CPluginView */
|
|
||||||
|
|
||||||
} /* namespace NLQT */
|
|
||||||
|
|
||||||
#endif // PLUGIN_VIEW_H
|
|
@ -1,75 +0,0 @@
|
|||||||
/*
|
|
||||||
Object Viewer Qt
|
|
||||||
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 General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "plugin_view.h"
|
|
||||||
|
|
||||||
// Qt includes
|
|
||||||
#include <QtCore/QDir>
|
|
||||||
#include <QtCore/QString>
|
|
||||||
#include <QtCore/QStringList>
|
|
||||||
#include <QtGui/QIcon>
|
|
||||||
#include <QtGui/QStyle>
|
|
||||||
#include <QtGui/QTreeWidgetItem>
|
|
||||||
|
|
||||||
// Project includes
|
|
||||||
#include "iplugin_spec.h"
|
|
||||||
#include "iplugin_manager.h"
|
|
||||||
|
|
||||||
namespace NLQT
|
|
||||||
{
|
|
||||||
|
|
||||||
CPluginView::CPluginView(IPluginManager *pluginManager, QWidget *parent)
|
|
||||||
: QDialog(parent)
|
|
||||||
{
|
|
||||||
_ui.setupUi(this);
|
|
||||||
_pluginManager = pluginManager;
|
|
||||||
|
|
||||||
connect(_pluginManager, SIGNAL(pluginsChanged()), this, SLOT(updateList()));
|
|
||||||
|
|
||||||
updateList();
|
|
||||||
}
|
|
||||||
|
|
||||||
CPluginView::~CPluginView()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void CPluginView::updateList()
|
|
||||||
{
|
|
||||||
static QIcon okIcon = QApplication::style()->standardIcon(QStyle::SP_DialogApplyButton);
|
|
||||||
static QIcon errorIcon = QApplication::style()->standardIcon(QStyle::SP_DialogCancelButton);
|
|
||||||
|
|
||||||
QList<QTreeWidgetItem *> items;
|
|
||||||
Q_FOREACH (IPluginSpec *spec, _pluginManager->plugins())
|
|
||||||
{
|
|
||||||
QTreeWidgetItem *item = new QTreeWidgetItem(QStringList()
|
|
||||||
<< ""
|
|
||||||
<< spec->name()
|
|
||||||
<< QString("%1").arg(spec->version())
|
|
||||||
<< spec->vendor()
|
|
||||||
<< QDir::toNativeSeparators(spec->filePath()));
|
|
||||||
item->setIcon(0, spec->hasError() ? errorIcon : okIcon);
|
|
||||||
items.append(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
_ui.pluginTreeWidget->clear();
|
|
||||||
if (!items.isEmpty())
|
|
||||||
_ui.pluginTreeWidget->addTopLevelItems(items);
|
|
||||||
}
|
|
||||||
|
|
||||||
} /* namespace NLQT */
|
|
@ -1,3 +0,0 @@
|
|||||||
[Dolphin]
|
|
||||||
ShowPreview=true
|
|
||||||
Timestamp=2010,8,4,0,59,20
|
|
@ -1,3 +1,4 @@
|
|||||||
|
ADD_SUBDIRECTORY(core)
|
||||||
ADD_SUBDIRECTORY(example)
|
ADD_SUBDIRECTORY(example)
|
||||||
ADD_SUBDIRECTORY(ovqt_sheet_builder)
|
ADD_SUBDIRECTORY(ovqt_sheet_builder)
|
||||||
ADD_SUBDIRECTORY(log)
|
ADD_SUBDIRECTORY(log)
|
@ -0,0 +1,54 @@
|
|||||||
|
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
${LIBXML2_INCLUDE_DIR}
|
||||||
|
${QT_INCLUDES})
|
||||||
|
|
||||||
|
FILE(GLOB SRC *.cpp *.h)
|
||||||
|
SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_manager.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h)
|
||||||
|
|
||||||
|
SET(OVQT_CORE_PLUGIN_HDR
|
||||||
|
ioptions_page.h
|
||||||
|
core_plugin.h
|
||||||
|
core_constants.h
|
||||||
|
main_window.h
|
||||||
|
settings_dialog.h
|
||||||
|
qnel_widget.h
|
||||||
|
search_paths_settings_page.h
|
||||||
|
plugin_view_dialog.h)
|
||||||
|
|
||||||
|
SET(OVQT_CORE_PLUGIN_UIS settings_dialog.ui
|
||||||
|
plugin_view_dialog.ui
|
||||||
|
search_paths_settings_page.ui)
|
||||||
|
|
||||||
|
SET(OVQT_CORE_PLUGIN_RCS core.qrc)
|
||||||
|
|
||||||
|
SET(QT_USE_QTGUI TRUE)
|
||||||
|
SET(QT_USE_QTOPENGL TRUE)
|
||||||
|
|
||||||
|
QT4_ADD_RESOURCES(OVQT_CORE_PLUGIN_RC_SRCS ${OVQT_CORE_PLUGIN_RCS})
|
||||||
|
QT4_WRAP_CPP(OVQT_CORE_PLUGIN_MOC_SRC ${OVQT_CORE_PLUGIN_HDR})
|
||||||
|
QT4_WRAP_UI(OVQT_CORE_PLUGIN_UI_HDRS ${OVQT_CORE_PLUGIN_UIS})
|
||||||
|
|
||||||
|
SOURCE_GROUP(QtResources FILES ${OVQT_CORE_PLUGIN_UIS} ${OVQT_CORE_PLUGIN_RCS})
|
||||||
|
SOURCE_GROUP(QtGeneratedUiHdr FILES ${OVQT_CORE_PLUGIN_UI_HDRS})
|
||||||
|
SOURCE_GROUP(QtGeneratedMocSrc FILES ${OVQT_CORE_PLUGIN_MOC_SRC})
|
||||||
|
SOURCE_GROUP("Core Plugin" FILES ${SRC})
|
||||||
|
SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC})
|
||||||
|
|
||||||
|
ADD_LIBRARY(ovqt_plugin_core MODULE ${SRC} ${OVQT_CORE_PLUGIN_MOC_SRC} ${OVQT_EXT_SYS_SRC} ${OVQT_CORE_PLUGIN_RC_SRCS} ${OVQT_CORE_PLUGIN_UI_HDRS})
|
||||||
|
|
||||||
|
TARGET_LINK_LIBRARIES(ovqt_plugin_core nelmisc nel3d ${QT_LIBRARIES})
|
||||||
|
|
||||||
|
IF(WITH_STLPORT)
|
||||||
|
TARGET_LINK_LIBRARIES(ovqt_plugin_core ${CMAKE_THREAD_LIBS_INIT})
|
||||||
|
ENDIF(WITH_STLPORT)
|
||||||
|
|
||||||
|
NL_DEFAULT_PROPS(ovqt_plugin_core "NeL, Tools, 3D: Object Viewer Qt Plugin: Core")
|
||||||
|
NL_ADD_RUNTIME_FLAGS(ovqt_plugin_core)
|
||||||
|
NL_ADD_LIB_SUFFIX(ovqt_plugin_core)
|
||||||
|
|
||||||
|
ADD_DEFINITIONS(${LIBXML2_DEFINITIONS} -DQT_PLUGIN -DQT_SHARED ${QT_DEFINITIONS})
|
||||||
|
|
||||||
|
INSTALL(TARGETS ovqt_plugin_core LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib COMPONENT tools3d)
|
@ -0,0 +1,6 @@
|
|||||||
|
<RCC>
|
||||||
|
<qresource prefix="/core" >
|
||||||
|
<file>images/nel.png</file>
|
||||||
|
<file>images/preferences.png</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
@ -0,0 +1,136 @@
|
|||||||
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||||
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
|
// 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.
|
||||||
|
//
|
||||||
|
// 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/>.
|
||||||
|
|
||||||
|
#include "core_plugin.h"
|
||||||
|
|
||||||
|
#include <QtCore/QObject>
|
||||||
|
#include <QtGui/QMessageBox>
|
||||||
|
#include <QtGui/QMainWindow>
|
||||||
|
#include <QtGui/QMenu>
|
||||||
|
#include <QtGui/QAction>
|
||||||
|
#include <QtGui/QMenuBar>
|
||||||
|
|
||||||
|
#include "../../extension_system/iplugin_spec.h"
|
||||||
|
|
||||||
|
#include "settings_dialog.h"
|
||||||
|
#include "core_constants.h"
|
||||||
|
#include "search_paths_settings_page.h"
|
||||||
|
#include "nel/misc/debug.h"
|
||||||
|
|
||||||
|
using namespace Core;
|
||||||
|
|
||||||
|
bool CorePlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString)
|
||||||
|
{
|
||||||
|
Q_UNUSED(errorString);
|
||||||
|
_plugMan = pluginManager;
|
||||||
|
// for old ovqt
|
||||||
|
QMainWindow *wnd = qobject_cast<QMainWindow *>(objectByName("CMainWindow"));
|
||||||
|
if (!wnd)
|
||||||
|
{
|
||||||
|
*errorString = tr("Not found QMainWindow Object Viewer Qt.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//_mainWindow = new CMainWindow(_plugMan);
|
||||||
|
//_mainWindow->show();
|
||||||
|
//_plugMan->addObject(new CSearchPathsSettingsPage(_mainWindow));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CorePlugin::extensionsInitialized()
|
||||||
|
{
|
||||||
|
// for old ovqt
|
||||||
|
_pluginView = new ExtensionSystem::CPluginView(_plugMan);
|
||||||
|
|
||||||
|
QMenu *toolsMenu = qobject_cast<QMenu *>(objectByName("ovqt.Menu.Tools"));
|
||||||
|
QMenu *helpMenu = qobject_cast<QMenu *>(objectByName("ovqt.Menu.Help"));
|
||||||
|
nlassert(toolsMenu);
|
||||||
|
nlassert(helpMenu);
|
||||||
|
|
||||||
|
QAction *newAction = toolsMenu->addAction(tr("New settings"));
|
||||||
|
QAction *newAction2 = helpMenu->addAction(tr("About plugins"));
|
||||||
|
newAction->setIcon(QIcon(Constants::ICON_SETTINGS));
|
||||||
|
|
||||||
|
connect(newAction, SIGNAL(triggered()), this, SLOT(execSettings()));
|
||||||
|
connect(newAction2, SIGNAL(triggered()), _pluginView, SLOT(show()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CorePlugin::shutdown()
|
||||||
|
{
|
||||||
|
//delete _mainWindow;
|
||||||
|
delete _pluginView;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CorePlugin::execSettings()
|
||||||
|
{
|
||||||
|
CSettingsDialog settingsDialog(_plugMan);
|
||||||
|
settingsDialog.show();
|
||||||
|
settingsDialog.execDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CorePlugin::setNelContext(NLMISC::INelContext *nelContext)
|
||||||
|
{
|
||||||
|
#ifdef NL_OS_WINDOWS
|
||||||
|
// Ensure that a context doesn't exist yet.
|
||||||
|
// This only applies to platforms without PIC, e.g. Windows.
|
||||||
|
nlassert(!NLMISC::INelContext::isContextInitialised());
|
||||||
|
#endif // NL_OS_WINDOWS
|
||||||
|
_LibContext = new NLMISC::CLibraryContext(*nelContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CorePlugin::name() const
|
||||||
|
{
|
||||||
|
return QLatin1String("Core");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CorePlugin::version() const
|
||||||
|
{
|
||||||
|
return Constants::OVQT_VERSION_LONG;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CorePlugin::vendor() const
|
||||||
|
{
|
||||||
|
return Constants::OVQT_VENDOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CorePlugin::description() const
|
||||||
|
{
|
||||||
|
return "Core plugin.";
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QString> CorePlugin::dependencies() const
|
||||||
|
{
|
||||||
|
return QList<QString>();
|
||||||
|
}
|
||||||
|
|
||||||
|
QObject* CorePlugin::objectByName(const QString &name) const
|
||||||
|
{
|
||||||
|
Q_FOREACH (QObject *qobj, _plugMan->allObjects())
|
||||||
|
if (qobj->objectName() == name)
|
||||||
|
return qobj;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ExtensionSystem::IPluginSpec *CorePlugin::pluginByName(const QString &name) const
|
||||||
|
{
|
||||||
|
Q_FOREACH (ExtensionSystem::IPluginSpec *spec, _plugMan->plugins())
|
||||||
|
if (spec->name() == name)
|
||||||
|
return spec;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_EXPORT_PLUGIN(CorePlugin)
|
@ -0,0 +1,76 @@
|
|||||||
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||||
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
|
// 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.
|
||||||
|
//
|
||||||
|
// 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 CORE_PLUGIN_H
|
||||||
|
#define CORE_PLUGIN_H
|
||||||
|
|
||||||
|
#include "../../extension_system/iplugin.h"
|
||||||
|
#include "main_window.h"
|
||||||
|
|
||||||
|
#include "nel/misc/app_context.h"
|
||||||
|
|
||||||
|
#include <QtCore/QObject>
|
||||||
|
|
||||||
|
namespace NLMISC
|
||||||
|
{
|
||||||
|
class CLibraryContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace ExtensionSystem
|
||||||
|
{
|
||||||
|
class IPluginSpec;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Core
|
||||||
|
{
|
||||||
|
|
||||||
|
class CorePlugin : public QObject, public ExtensionSystem::IPlugin
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_INTERFACES(ExtensionSystem::IPlugin)
|
||||||
|
public:
|
||||||
|
|
||||||
|
bool initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString);
|
||||||
|
void extensionsInitialized();
|
||||||
|
void shutdown();
|
||||||
|
|
||||||
|
void setNelContext(NLMISC::INelContext *nelContext);
|
||||||
|
|
||||||
|
QString name() const;
|
||||||
|
QString version() const;
|
||||||
|
QString vendor() const;
|
||||||
|
QString description() const;
|
||||||
|
QList<QString> dependencies() const;
|
||||||
|
|
||||||
|
QObject *objectByName(const QString &name) const;
|
||||||
|
ExtensionSystem::IPluginSpec *pluginByName(const QString &name) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
NLMISC::CLibraryContext *_LibContext;
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void execSettings();
|
||||||
|
|
||||||
|
private:
|
||||||
|
ExtensionSystem::IPluginManager *_plugMan;
|
||||||
|
ExtensionSystem::CPluginView *_pluginView;
|
||||||
|
CMainWindow *_mainWindow;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Core
|
||||||
|
|
||||||
|
#endif // CORE_PLUGIN_H
|
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
@ -0,0 +1,66 @@
|
|||||||
|
// 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>
|
||||||
|
// Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#ifndef IOPTIONS_PAGE_H
|
||||||
|
#define IOPTIONS_PAGE_H
|
||||||
|
|
||||||
|
#include <QtCore/QObject>
|
||||||
|
|
||||||
|
class QWidget;
|
||||||
|
|
||||||
|
namespace Core
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
@interface IOptionsPage
|
||||||
|
@brief The IOptionsPage is an interface for providing options pages.
|
||||||
|
@details You need to subclass this interface and put an instance of your subclass
|
||||||
|
into the plugin manager object pool.
|
||||||
|
*/
|
||||||
|
class IOptionsPage : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
IOptionsPage(QObject *parent = 0) : QObject(parent) {}
|
||||||
|
virtual ~IOptionsPage() {}
|
||||||
|
|
||||||
|
/// id() is a unique identifier for referencing this page
|
||||||
|
virtual QString id() const = 0;
|
||||||
|
|
||||||
|
/// trName() is the (translated) name for display.
|
||||||
|
virtual QString trName() const = 0;
|
||||||
|
|
||||||
|
/// category() is the unique id for the category that the page should be displayed in
|
||||||
|
virtual QString category() const = 0;
|
||||||
|
|
||||||
|
/// trCategory() is the translated category
|
||||||
|
virtual QString trCategory() const = 0;
|
||||||
|
|
||||||
|
/// createPage() is called to retrieve the widget to show in the preferences dialog
|
||||||
|
/// The widget will be destroyed by the widget hierarchy when the dialog closes
|
||||||
|
virtual QWidget *createPage(QWidget *parent) = 0;
|
||||||
|
|
||||||
|
/// apply() is called to store the settings. It should detect if any changes have been made and store those.
|
||||||
|
virtual void apply() = 0;
|
||||||
|
|
||||||
|
/// finish() is called directly before the preferences dialog closes
|
||||||
|
virtual void finish() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Core
|
||||||
|
|
||||||
|
#endif // IOPTIONSPAGE_H
|
@ -0,0 +1,173 @@
|
|||||||
|
// 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 "main_window.h"
|
||||||
|
#include "core_constants.h"
|
||||||
|
#include "settings_dialog.h"
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
#include <QtGui/QtGui>
|
||||||
|
|
||||||
|
namespace Core
|
||||||
|
{
|
||||||
|
|
||||||
|
CMainWindow::CMainWindow(ExtensionSystem::IPluginManager *pluginManager, QWidget *parent)
|
||||||
|
: QMainWindow(parent),
|
||||||
|
_lastDir(".")
|
||||||
|
{
|
||||||
|
_pluginManager = pluginManager;
|
||||||
|
|
||||||
|
setObjectName(Constants::MAIN_WINDOW);
|
||||||
|
|
||||||
|
_tabWidget = new QTabWidget(this);
|
||||||
|
setCentralWidget(_tabWidget);
|
||||||
|
|
||||||
|
QWidget *qwidg1 = new QWidget(_tabWidget);
|
||||||
|
QWidget *qwidg2 = new QWidget(_tabWidget);
|
||||||
|
|
||||||
|
_tabWidget->addTab(qwidg1, "tab1");
|
||||||
|
_tabWidget->addTab(qwidg2, "tab2");
|
||||||
|
|
||||||
|
|
||||||
|
QGridLayout *gridLayout = new QGridLayout(qwidg1);
|
||||||
|
gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
|
||||||
|
NLQT::QNLWidget *_nelWidget = new NLQT::QNLWidget(qwidg1);
|
||||||
|
_nelWidget->setObjectName(QString::fromUtf8("NELWIdget1"));
|
||||||
|
gridLayout->addWidget(_nelWidget, 0, 0, 1, 1);
|
||||||
|
|
||||||
|
QGridLayout *gridLayout2 = new QGridLayout(qwidg2);
|
||||||
|
NLQT::QNLWidget *_nelWidget2 = new NLQT::QNLWidget(qwidg2);
|
||||||
|
_nelWidget2->setObjectName(QString::fromUtf8("NELWIdget2"));
|
||||||
|
gridLayout2->addWidget(_nelWidget2, 0, 0, 1, 1);
|
||||||
|
|
||||||
|
setDockNestingEnabled(true);
|
||||||
|
|
||||||
|
_originalPalette = QApplication::palette();
|
||||||
|
|
||||||
|
createDialogs();
|
||||||
|
createActions();
|
||||||
|
createMenus();
|
||||||
|
createStatusBar();
|
||||||
|
|
||||||
|
setWindowIcon(QIcon(Constants::ICON_NEL));
|
||||||
|
setWindowTitle(tr("Object Viewer Qt"));
|
||||||
|
}
|
||||||
|
|
||||||
|
CMainWindow::~CMainWindow()
|
||||||
|
{
|
||||||
|
delete _pluginView;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CMainWindow::showOptionsDialog(const QString &group,
|
||||||
|
const QString &page,
|
||||||
|
QWidget *parent)
|
||||||
|
{
|
||||||
|
if (!parent)
|
||||||
|
parent = this;
|
||||||
|
CSettingsDialog _settingsDialog(_pluginManager, group, page, parent);
|
||||||
|
_settingsDialog.show();
|
||||||
|
return _settingsDialog.execDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMainWindow::about()
|
||||||
|
{
|
||||||
|
QMessageBox::about(this, tr("About Object Viewer Qt"),
|
||||||
|
tr("<h2>Object Viewer Qt NG</h2>"
|
||||||
|
"<p> Author: dnk-88 <p>Compiled on %1 %2").arg(__DATE__).arg(__TIME__));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMainWindow::createActions()
|
||||||
|
{
|
||||||
|
_openAction = new QAction(tr("&Open..."), this);
|
||||||
|
_openAction->setIcon(QIcon(":/images/open-file.png"));
|
||||||
|
_openAction->setShortcut(QKeySequence::Open);
|
||||||
|
_openAction->setStatusTip(tr("Open an existing file"));
|
||||||
|
// connect(_openAction, SIGNAL(triggered()), this, SLOT(open()));
|
||||||
|
|
||||||
|
_exitAction = new QAction(tr("E&xit"), this);
|
||||||
|
_exitAction->setShortcut(tr("Ctrl+Q"));
|
||||||
|
_exitAction->setStatusTip(tr("Exit the application"));
|
||||||
|
connect(_exitAction, SIGNAL(triggered()), this, SLOT(close()));
|
||||||
|
|
||||||
|
_settingsAction = new QAction(tr("&Settings"), this);
|
||||||
|
_settingsAction->setIcon(QIcon(":/images/preferences.png"));
|
||||||
|
_settingsAction->setStatusTip(tr("Open the settings dialog"));
|
||||||
|
connect(_settingsAction, SIGNAL(triggered()), this, SLOT(showOptionsDialog()));
|
||||||
|
|
||||||
|
_aboutAction = new QAction(tr("&About"), this);
|
||||||
|
_aboutAction->setStatusTip(tr("Show the application's About box"));
|
||||||
|
connect(_aboutAction, SIGNAL(triggered()), this, SLOT(about()));
|
||||||
|
|
||||||
|
_aboutQtAction = new QAction(tr("About &Qt"), this);
|
||||||
|
_aboutQtAction->setStatusTip(tr("Show the Qt library's About box"));
|
||||||
|
connect(_aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
|
||||||
|
|
||||||
|
_pluginViewAction = new QAction(tr("About &Plugins"), this);
|
||||||
|
_pluginViewAction->setStatusTip(tr("Show the plugin view dialog"));
|
||||||
|
connect(_pluginViewAction, SIGNAL(triggered()), _pluginView, SLOT(show()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMainWindow::createMenus()
|
||||||
|
{
|
||||||
|
_fileMenu = menuBar()->addMenu(tr("&File"));
|
||||||
|
_fileMenu->setObjectName(Constants::M_FILE);
|
||||||
|
_fileMenu->addSeparator();
|
||||||
|
_fileMenu->addAction(_exitAction);
|
||||||
|
|
||||||
|
_editMenu = menuBar()->addMenu(tr("&Edit"));
|
||||||
|
_editMenu->setObjectName(Constants::M_EDIT);
|
||||||
|
|
||||||
|
_viewMenu = menuBar()->addMenu(tr("&View"));
|
||||||
|
_viewMenu->setObjectName(Constants::M_VIEW);
|
||||||
|
|
||||||
|
_toolsMenu = menuBar()->addMenu(tr("&Tools"));
|
||||||
|
_toolsMenu->setObjectName(Constants::M_TOOLS);
|
||||||
|
|
||||||
|
|
||||||
|
_toolsMenu->addSeparator();
|
||||||
|
|
||||||
|
_toolsMenu->addAction(_settingsAction);
|
||||||
|
|
||||||
|
menuBar()->addSeparator();
|
||||||
|
|
||||||
|
_helpMenu = menuBar()->addMenu(tr("&Help"));
|
||||||
|
_helpMenu->setObjectName(Constants::M_HELP);
|
||||||
|
_helpMenu->addAction(_aboutAction);
|
||||||
|
_helpMenu->addAction(_aboutQtAction);
|
||||||
|
_helpMenu->addAction(_pluginViewAction);
|
||||||
|
|
||||||
|
_pluginManager->addObject(_fileMenu);
|
||||||
|
_pluginManager->addObject(_editMenu);
|
||||||
|
_pluginManager->addObject(_viewMenu);
|
||||||
|
_pluginManager->addObject(_toolsMenu);
|
||||||
|
_pluginManager->addObject(_helpMenu);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMainWindow::createStatusBar()
|
||||||
|
{
|
||||||
|
statusBar()->showMessage(tr("StatusReady"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMainWindow::createDialogs()
|
||||||
|
{
|
||||||
|
_pluginView = new ExtensionSystem::CPluginView(_pluginManager, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
} /* namespace Core */
|
||||||
|
|
||||||
|
/* end of file */
|
@ -0,0 +1,91 @@
|
|||||||
|
// 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 MAIN_WINDOW_H
|
||||||
|
#define MAIN_WINDOW_H
|
||||||
|
|
||||||
|
// STL includes
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
#include <QtGui/QMainWindow>
|
||||||
|
#include <QtCore/QSettings>
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
#include "qnel_widget.h"
|
||||||
|
#include "../../extension_system/iplugin.h"
|
||||||
|
#include "plugin_view_dialog.h"
|
||||||
|
|
||||||
|
namespace Core
|
||||||
|
{
|
||||||
|
class CSettingsDialog;
|
||||||
|
|
||||||
|
class CMainWindow : public QMainWindow
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
CMainWindow(ExtensionSystem::IPluginManager *pluginManager, QWidget *parent = 0);
|
||||||
|
~CMainWindow();
|
||||||
|
|
||||||
|
inline QSettings *settings() const
|
||||||
|
{
|
||||||
|
return _settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
bool showOptionsDialog(const QString &group = QString(),
|
||||||
|
const QString &page = QString(),
|
||||||
|
QWidget *parent = 0);
|
||||||
|
void about();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void createActions();
|
||||||
|
void createMenus();
|
||||||
|
void createStatusBar();
|
||||||
|
void createDialogs();
|
||||||
|
|
||||||
|
ExtensionSystem::IPluginManager *_pluginManager;
|
||||||
|
ExtensionSystem::CPluginView *_pluginView;
|
||||||
|
|
||||||
|
QPalette _originalPalette;
|
||||||
|
QString _lastDir;
|
||||||
|
|
||||||
|
QSettings *_settings;
|
||||||
|
|
||||||
|
QTimer *_mainTimer;
|
||||||
|
QTimer *_statusBarTimer;
|
||||||
|
|
||||||
|
QTabWidget *_tabWidget;
|
||||||
|
|
||||||
|
QMenu *_fileMenu;
|
||||||
|
QMenu *_editMenu;
|
||||||
|
QMenu *_viewMenu;
|
||||||
|
QMenu *_toolsMenu;
|
||||||
|
QMenu *_helpMenu;
|
||||||
|
|
||||||
|
QAction *_openAction;
|
||||||
|
QAction *_exitAction;
|
||||||
|
QAction *_settingsAction;
|
||||||
|
QAction *_pluginViewAction;
|
||||||
|
QAction *_aboutAction;
|
||||||
|
QAction *_aboutQtAction;
|
||||||
|
|
||||||
|
};/* class CMainWindow */
|
||||||
|
|
||||||
|
} /* namespace Core */
|
||||||
|
|
||||||
|
#endif // MAIN_WINDOW_H
|
@ -0,0 +1,73 @@
|
|||||||
|
// 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/>.
|
||||||
|
|
||||||
|
#include "plugin_view_dialog.h"
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
#include <QtCore/QDir>
|
||||||
|
#include <QtCore/QString>
|
||||||
|
#include <QtCore/QStringList>
|
||||||
|
#include <QtGui/QIcon>
|
||||||
|
#include <QtGui/QStyle>
|
||||||
|
#include <QtGui/QTreeWidgetItem>
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
#include "../../extension_system/iplugin_spec.h"
|
||||||
|
#include "../../extension_system/iplugin_manager.h"
|
||||||
|
|
||||||
|
namespace ExtensionSystem
|
||||||
|
{
|
||||||
|
|
||||||
|
CPluginView::CPluginView(IPluginManager *pluginManager, QWidget *parent)
|
||||||
|
: QDialog(parent)
|
||||||
|
{
|
||||||
|
_ui.setupUi(this);
|
||||||
|
_pluginManager = pluginManager;
|
||||||
|
|
||||||
|
connect(_pluginManager, SIGNAL(pluginsChanged()), this, SLOT(updateList()));
|
||||||
|
|
||||||
|
updateList();
|
||||||
|
}
|
||||||
|
|
||||||
|
CPluginView::~CPluginView()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CPluginView::updateList()
|
||||||
|
{
|
||||||
|
static QIcon okIcon = QApplication::style()->standardIcon(QStyle::SP_DialogApplyButton);
|
||||||
|
static QIcon errorIcon = QApplication::style()->standardIcon(QStyle::SP_DialogCancelButton);
|
||||||
|
|
||||||
|
QList<QTreeWidgetItem *> items;
|
||||||
|
Q_FOREACH (IPluginSpec *spec, _pluginManager->plugins())
|
||||||
|
{
|
||||||
|
QTreeWidgetItem *item = new QTreeWidgetItem(QStringList()
|
||||||
|
<< ""
|
||||||
|
<< spec->name()
|
||||||
|
<< QString("%1").arg(spec->version())
|
||||||
|
<< spec->vendor()
|
||||||
|
<< QDir::toNativeSeparators(spec->filePath()));
|
||||||
|
item->setIcon(0, spec->hasError() ? errorIcon : okIcon);
|
||||||
|
items.append(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
_ui.pluginTreeWidget->clear();
|
||||||
|
if (!items.isEmpty())
|
||||||
|
_ui.pluginTreeWidget->addTopLevelItems(items);
|
||||||
|
}
|
||||||
|
|
||||||
|
} /* namespace NLQT */
|
@ -0,0 +1,47 @@
|
|||||||
|
// 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 PLUGIN_VIEW_H
|
||||||
|
#define PLUGIN_VIEW_H
|
||||||
|
|
||||||
|
#include "ui_plugin_view_dialog.h"
|
||||||
|
|
||||||
|
namespace ExtensionSystem
|
||||||
|
{
|
||||||
|
|
||||||
|
class IPluginManager;
|
||||||
|
|
||||||
|
class CPluginView: public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
CPluginView(IPluginManager *pluginManager, QWidget *parent = 0);
|
||||||
|
~CPluginView();
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void updateList();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
IPluginManager *_pluginManager;
|
||||||
|
Ui::CPluginView _ui;
|
||||||
|
}; /* class CPluginView */
|
||||||
|
|
||||||
|
} /* namespace NLQT */
|
||||||
|
|
||||||
|
#endif // PLUGIN_VIEW_H
|
@ -0,0 +1,208 @@
|
|||||||
|
// 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/>.
|
||||||
|
|
||||||
|
#include "qnel_widget.h"
|
||||||
|
|
||||||
|
// STL includes
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
#include <QtCore/QTimer>
|
||||||
|
#include <QtGui/QResizeEvent>
|
||||||
|
|
||||||
|
// NeL includes
|
||||||
|
#include <nel/misc/event_server.h>
|
||||||
|
#include <nel/misc/debug.h>
|
||||||
|
#include <nel/3d/u_driver.h>
|
||||||
|
#include <nel/3d/driver_user.h>
|
||||||
|
|
||||||
|
namespace NLQT
|
||||||
|
{
|
||||||
|
|
||||||
|
QNLWidget::QNLWidget(QWidget *parent)
|
||||||
|
: QWidget(parent),
|
||||||
|
_driver(NULL),
|
||||||
|
_initialized(false),
|
||||||
|
_interval(25)
|
||||||
|
{
|
||||||
|
init();
|
||||||
|
_mainTimer = new QTimer(this);
|
||||||
|
connect(_mainTimer, SIGNAL(timeout()), this, SLOT(updateRender()));
|
||||||
|
}
|
||||||
|
|
||||||
|
QNLWidget::~QNLWidget()
|
||||||
|
{
|
||||||
|
release();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QNLWidget::init()
|
||||||
|
{
|
||||||
|
// create the driver
|
||||||
|
_driver = NL3D::UDriver::createDriver(NULL, false, NULL);
|
||||||
|
nlassert(_driver);
|
||||||
|
|
||||||
|
// initialize the nel 3d viewport
|
||||||
|
_driver->setDisplay(winId(), NL3D::UDriver::CMode(width(), height(), 32));
|
||||||
|
|
||||||
|
// set the cache size for the font manager(in bytes)
|
||||||
|
_driver->setFontManagerMaxMemory(2097152);
|
||||||
|
|
||||||
|
_initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QNLWidget::release()
|
||||||
|
{
|
||||||
|
_mainTimer->stop();
|
||||||
|
delete _mainTimer;
|
||||||
|
if (_initialized)
|
||||||
|
{
|
||||||
|
_driver->release();
|
||||||
|
delete _driver;
|
||||||
|
_driver = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QNLWidget::setInterval(int msec)
|
||||||
|
{
|
||||||
|
_interval = msec;
|
||||||
|
_mainTimer->setInterval(msec);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QNLWidget::updateRender()
|
||||||
|
{
|
||||||
|
if (isVisible())
|
||||||
|
{
|
||||||
|
if (_initialized)
|
||||||
|
_driver->EventServer.pump();
|
||||||
|
if (_initialized && !_driver->isLost())
|
||||||
|
{
|
||||||
|
_driver->activate();
|
||||||
|
_driver->clearBuffers(NLMISC::CRGBA(125,12,58));
|
||||||
|
|
||||||
|
// swap 3d buffers
|
||||||
|
_driver->swapBuffers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QNLWidget::showEvent(QShowEvent *showEvent)
|
||||||
|
{
|
||||||
|
QWidget::showEvent(showEvent);
|
||||||
|
if (isVisible())
|
||||||
|
{
|
||||||
|
_driver->activate();
|
||||||
|
_mainTimer->start(_interval);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
_mainTimer->stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(NL_OS_WINDOWS) || defined(NL_OS_MAC)
|
||||||
|
// Qt does not provide wheel events through winEvent() and macEvent() (but it
|
||||||
|
// does through x11Event(), which is inconsistent...)
|
||||||
|
// Workaround is to handle wheel events like implemented below.
|
||||||
|
//
|
||||||
|
// TODO: this is not a clean solution, because all but wheel events are
|
||||||
|
// handled using winEvent(), x11Event(), macEvent(). But this seems to be a
|
||||||
|
// limitation of current (4.7.1) Qt versions. (see e.g. qapplication_mac.mm)
|
||||||
|
void QNLWidget::wheelEvent(QWheelEvent *event)
|
||||||
|
{
|
||||||
|
// Get relative positions.
|
||||||
|
float fX = 1.0f - (float)event->pos().x() / this->width();
|
||||||
|
float fY = 1.0f - (float)event->pos().y() / this->height();
|
||||||
|
|
||||||
|
// Get the buttons currently pressed.
|
||||||
|
uint32 buttons = NLMISC::noButton;
|
||||||
|
if(event->buttons() & Qt::LeftButton) buttons |= NLMISC::leftButton;
|
||||||
|
if(event->buttons() & Qt::RightButton) buttons |= NLMISC::rightButton;
|
||||||
|
if(event->buttons() & Qt::MidButton) buttons |= NLMISC::middleButton;
|
||||||
|
if(event->modifiers() & Qt::ControlModifier) buttons |= NLMISC::ctrlButton;
|
||||||
|
if(event->modifiers() & Qt::ShiftModifier) buttons |= NLMISC::shiftButton;
|
||||||
|
if(event->modifiers() & Qt::AltModifier) buttons |= NLMISC::altButton;
|
||||||
|
|
||||||
|
if(event->delta() > 0)
|
||||||
|
_driver->EventServer.postEvent(
|
||||||
|
new NLMISC::CEventMouseWheel(-fX, fY, (NLMISC::TMouseButton)buttons, true, NULL));
|
||||||
|
else
|
||||||
|
_driver->EventServer.postEvent(
|
||||||
|
new NLMISC::CEventMouseWheel(-fX, fY, (NLMISC::TMouseButton)buttons, false, NULL));
|
||||||
|
}
|
||||||
|
#endif // defined(NL_OS_WINDOWS) || defined(NL_OS_MAC)
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(NL_OS_WINDOWS)
|
||||||
|
|
||||||
|
typedef bool (*winProc)(NL3D::IDriver *driver, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
|
bool QNLWidget::winEvent(MSG *message, long *result)
|
||||||
|
{
|
||||||
|
if (_driver && _driver->isActive())
|
||||||
|
{
|
||||||
|
NL3D::IDriver *driver = dynamic_cast<NL3D::CDriverUser *>(_driver)->getDriver();
|
||||||
|
if (driver)
|
||||||
|
{
|
||||||
|
winProc proc = (winProc)driver->getWindowProc();
|
||||||
|
return proc(driver, message->hwnd, message->message, message->wParam, message->lParam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined(NL_OS_MAC)
|
||||||
|
|
||||||
|
typedef bool (*cocoaProc)(NL3D::IDriver *, const void *e);
|
||||||
|
|
||||||
|
bool QNLWidget::macEvent(EventHandlerCallRef caller, EventRef event)
|
||||||
|
{
|
||||||
|
if(caller)
|
||||||
|
nlerror("You are using QtCarbon! Only QtCocoa supported, please upgrade Qt");
|
||||||
|
|
||||||
|
if (_driver && _driver->isActive())
|
||||||
|
{
|
||||||
|
NL3D::IDriver *driver = dynamic_cast<NL3D::CDriverUser *>(_driver)->getDriver();
|
||||||
|
if (driver)
|
||||||
|
{
|
||||||
|
cocoaProc proc = (cocoaProc)driver->getWindowProc();
|
||||||
|
return proc(driver, event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined(NL_OS_UNIX)
|
||||||
|
|
||||||
|
typedef bool (*x11Proc)(NL3D::IDriver *drv, XEvent *e);
|
||||||
|
|
||||||
|
bool QNLWidget::x11Event(XEvent *event)
|
||||||
|
{
|
||||||
|
if (_driver && _driver->isActive())
|
||||||
|
{
|
||||||
|
NL3D::IDriver *driver = dynamic_cast<NL3D::CDriverUser *>(_driver)->getDriver();
|
||||||
|
if (driver)
|
||||||
|
{
|
||||||
|
x11Proc proc = (x11Proc)driver->getWindowProc();
|
||||||
|
return proc(driver, event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} /* namespace NLQT */
|
||||||
|
|
@ -0,0 +1,97 @@
|
|||||||
|
// 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 QNEL_WIDGET_H
|
||||||
|
#define QNEL_WIDGET_H
|
||||||
|
|
||||||
|
// NeL includes
|
||||||
|
#include <nel/misc/types_nl.h>
|
||||||
|
#include <nel/misc/event_emitter.h>
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
#include <QtOpenGL/QGLWidget>
|
||||||
|
#include <QtGui/QWidget>
|
||||||
|
|
||||||
|
class QAction;
|
||||||
|
|
||||||
|
namespace NL3D
|
||||||
|
{
|
||||||
|
class UDriver;
|
||||||
|
class UScene;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace NLQT
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
@class QNLWidget
|
||||||
|
@brief Responsible for interaction between Qt and NeL.
|
||||||
|
@details Automatically begins to update the render if the widget is visible
|
||||||
|
or suspends the updating of render if the widget is hidden.
|
||||||
|
*/
|
||||||
|
class QNLWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
QNLWidget(QWidget *parent);
|
||||||
|
virtual ~QNLWidget();
|
||||||
|
|
||||||
|
/// Set the update interval renderer
|
||||||
|
void setInterval(int msec);
|
||||||
|
|
||||||
|
virtual QPaintEngine* paintEngine() const
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void updateRender();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void showEvent(QShowEvent *showEvent);
|
||||||
|
|
||||||
|
#if defined(NL_OS_WINDOWS) || defined(NL_OS_MAC)
|
||||||
|
virtual void wheelEvent(QWheelEvent *event);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(NL_OS_WINDOWS)
|
||||||
|
virtual bool winEvent(MSG *message, long *result);
|
||||||
|
#elif defined(NL_OS_MAC)
|
||||||
|
virtual bool macEvent(EventHandlerCallRef caller, EventRef event);
|
||||||
|
#elif defined(NL_OS_UNIX)
|
||||||
|
virtual bool x11Event(XEvent *event);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private:
|
||||||
|
void init();
|
||||||
|
void release();
|
||||||
|
|
||||||
|
QNLWidget(const QNLWidget &);
|
||||||
|
QNLWidget &operator=(const QNLWidget &);
|
||||||
|
|
||||||
|
NL3D::UDriver *_driver;
|
||||||
|
QTimer *_mainTimer;
|
||||||
|
bool _initialized;
|
||||||
|
int _interval;
|
||||||
|
|
||||||
|
}; /* class QNLWidget */
|
||||||
|
|
||||||
|
} /* namespace NLQT */
|
||||||
|
|
||||||
|
|
||||||
|
#endif // QNEL_WIDGET_H
|
@ -0,0 +1,67 @@
|
|||||||
|
// 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/>.
|
||||||
|
|
||||||
|
#include "search_paths_settings_page.h"
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
#include <QtGui/QWidget>
|
||||||
|
|
||||||
|
// NeL includes
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
|
||||||
|
namespace Core
|
||||||
|
{
|
||||||
|
|
||||||
|
CSearchPathsSettingsPage::CSearchPathsSettingsPage(QObject *parent)
|
||||||
|
: IOptionsPage(parent),
|
||||||
|
_currentPage(NULL)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CSearchPathsSettingsPage::id() const
|
||||||
|
{
|
||||||
|
return QLatin1String("SearchPaths");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CSearchPathsSettingsPage::trName() const
|
||||||
|
{
|
||||||
|
return tr("Search Paths");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CSearchPathsSettingsPage::category() const
|
||||||
|
{
|
||||||
|
return QLatin1String("General");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CSearchPathsSettingsPage::trCategory() const
|
||||||
|
{
|
||||||
|
return tr("General");
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *CSearchPathsSettingsPage::createPage(QWidget *parent)
|
||||||
|
{
|
||||||
|
_currentPage = new QWidget(parent);
|
||||||
|
_ui.setupUi(_currentPage);
|
||||||
|
return _currentPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSearchPathsSettingsPage::apply()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
} /* namespace Core */
|
@ -0,0 +1,58 @@
|
|||||||
|
// 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 SEARCH_PATHS_SETTINGS_PAGE_H
|
||||||
|
#define SEARCH_PATHS_SETTINGS_PAGE_H
|
||||||
|
|
||||||
|
#include <QtCore/QObject>
|
||||||
|
|
||||||
|
#include "ioptions_page.h"
|
||||||
|
|
||||||
|
#include "ui_search_paths_settings_page.h"
|
||||||
|
|
||||||
|
class QWidget;
|
||||||
|
|
||||||
|
namespace Core
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
@class CSearchPathsSettingsPage
|
||||||
|
*/
|
||||||
|
class CSearchPathsSettingsPage : public IOptionsPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CSearchPathsSettingsPage(QObject *parent = 0);
|
||||||
|
virtual ~CSearchPathsSettingsPage() {}
|
||||||
|
|
||||||
|
virtual QString id() const;
|
||||||
|
virtual QString trName() const;
|
||||||
|
virtual QString category() const;
|
||||||
|
virtual QString trCategory() const;
|
||||||
|
virtual QWidget *createPage(QWidget *parent);
|
||||||
|
|
||||||
|
virtual void apply();
|
||||||
|
virtual void finish() {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QWidget *_currentPage;
|
||||||
|
Ui::CSearchPathsSettingsPage _ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Core
|
||||||
|
|
||||||
|
#endif // SEARCH_PATHS_SETTINGS_H
|
@ -0,0 +1,108 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>CSearchPathsSettingsPage</class>
|
||||||
|
<widget class="QWidget" name="CSearchPathsSettingsPage">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>422</width>
|
||||||
|
<height>272</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QGroupBox" name="searchPathsGroupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Search paths</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_6">
|
||||||
|
<item row="0" column="0" rowspan="2">
|
||||||
|
<widget class="QListWidget" name="pathsListWidget"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="addToolButton">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../object_viewer_qt.qrc">
|
||||||
|
<normaloff>:/images/list-add.png</normaloff>:/images/list-add.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="iconSize">
|
||||||
|
<size>
|
||||||
|
<width>16</width>
|
||||||
|
<height>16</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="removeToolButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../object_viewer_qt.qrc">
|
||||||
|
<normaloff>:/images/list-remove.png</normaloff>:/images/list-remove.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="upToolButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../object_viewer_qt.qrc">
|
||||||
|
<normaloff>:/images/go-up.png</normaloff>:/images/go-up.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="downToolButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../object_viewer_qt.qrc">
|
||||||
|
<normaloff>:/images/go-down.png</normaloff>:/images/go-down.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<spacer name="verticalSpacer_4">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>195</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources>
|
||||||
|
<include location="../../object_viewer_qt.qrc"/>
|
||||||
|
</resources>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
@ -0,0 +1,188 @@
|
|||||||
|
// 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>
|
||||||
|
// Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#include "settings_dialog.h"
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
#include <QtGui/QHeaderView>
|
||||||
|
#include <QtGui/QPushButton>
|
||||||
|
|
||||||
|
namespace Core
|
||||||
|
{
|
||||||
|
|
||||||
|
struct PageData
|
||||||
|
{
|
||||||
|
int index;
|
||||||
|
QString category;
|
||||||
|
QString id;
|
||||||
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(PageData);
|
||||||
|
|
||||||
|
CSettingsDialog::CSettingsDialog(ExtensionSystem::IPluginManager *pluginManager,
|
||||||
|
const QString &categoryId,
|
||||||
|
const QString &pageId,
|
||||||
|
QWidget *parent)
|
||||||
|
: QDialog(parent),
|
||||||
|
_applied(false)
|
||||||
|
{
|
||||||
|
_ui.setupUi(this);
|
||||||
|
|
||||||
|
_plugMan = pluginManager;
|
||||||
|
|
||||||
|
QString initialCategory = categoryId;
|
||||||
|
QString initialPage = pageId;
|
||||||
|
|
||||||
|
_ui.buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
|
||||||
|
|
||||||
|
connect(_ui.buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply()));
|
||||||
|
|
||||||
|
_ui.splitter->setCollapsible(1, false);
|
||||||
|
_ui.pageTree->header()->setVisible(false);
|
||||||
|
|
||||||
|
connect(_ui.pageTree, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
|
||||||
|
this, SLOT(pageSelected()));
|
||||||
|
|
||||||
|
QMap<QString, QTreeWidgetItem *> categories;
|
||||||
|
|
||||||
|
QList<IOptionsPage *> pages;
|
||||||
|
QList<QObject *> all = _plugMan->allObjects();
|
||||||
|
Q_FOREACH(QObject *obj, all)
|
||||||
|
{
|
||||||
|
IOptionsPage *page = qobject_cast<IOptionsPage *>(obj);
|
||||||
|
if (page)
|
||||||
|
pages.append(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
int index = 0;
|
||||||
|
Q_FOREACH(IOptionsPage *page, pages)
|
||||||
|
{
|
||||||
|
PageData pageData;
|
||||||
|
pageData.index = index;
|
||||||
|
pageData.category = page->category();
|
||||||
|
pageData.id = page->id();
|
||||||
|
|
||||||
|
QTreeWidgetItem *item = new QTreeWidgetItem;
|
||||||
|
item->setText(0, page->trName());
|
||||||
|
item->setData(0, Qt::UserRole, qVariantFromValue(pageData));
|
||||||
|
|
||||||
|
QStringList categoriesId = page->category().split(QLatin1Char('|'));
|
||||||
|
QStringList trCategories = page->trCategory().split(QLatin1Char('|'));
|
||||||
|
QString currentCategory = categoriesId.at(0);
|
||||||
|
|
||||||
|
QTreeWidgetItem *treeitem;
|
||||||
|
if (!categories.contains(currentCategory))
|
||||||
|
{
|
||||||
|
treeitem = new QTreeWidgetItem(_ui.pageTree);
|
||||||
|
treeitem->setText(0, trCategories.at(0));
|
||||||
|
treeitem->setData(0, Qt::UserRole, qVariantFromValue(pageData));
|
||||||
|
categories.insert(currentCategory, treeitem);
|
||||||
|
}
|
||||||
|
|
||||||
|
int catCount = 1;
|
||||||
|
while (catCount < categoriesId.count())
|
||||||
|
{
|
||||||
|
if (!categories.contains(currentCategory + QLatin1Char('|') + categoriesId.at(catCount)))
|
||||||
|
{
|
||||||
|
treeitem = new QTreeWidgetItem(categories.value(currentCategory));
|
||||||
|
currentCategory += QLatin1Char('|') + categoriesId.at(catCount);
|
||||||
|
treeitem->setText(0, trCategories.at(catCount));
|
||||||
|
treeitem->setData(0, Qt::UserRole, qVariantFromValue(pageData));
|
||||||
|
categories.insert(currentCategory, treeitem);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
currentCategory += QLatin1Char('|') + categoriesId.at(catCount);
|
||||||
|
}
|
||||||
|
++catCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
categories.value(currentCategory)->addChild(item);
|
||||||
|
|
||||||
|
_pages.append(page);
|
||||||
|
_ui.stackedPages->addWidget(page->createPage(_ui.stackedPages));
|
||||||
|
|
||||||
|
if (page->id() == initialPage && currentCategory == initialCategory)
|
||||||
|
{
|
||||||
|
_ui.stackedPages->setCurrentIndex(_ui.stackedPages->count());
|
||||||
|
_ui.pageTree->setCurrentItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<int> sizes;
|
||||||
|
sizes << 150 << 300;
|
||||||
|
_ui.splitter->setSizes(sizes);
|
||||||
|
|
||||||
|
_ui.splitter->setStretchFactor(_ui.splitter->indexOf(_ui.pageTree), 0);
|
||||||
|
_ui.splitter->setStretchFactor(_ui.splitter->indexOf(_ui.layoutWidget), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
CSettingsDialog::~CSettingsDialog()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSettingsDialog::pageSelected()
|
||||||
|
{
|
||||||
|
QTreeWidgetItem *item = _ui.pageTree->currentItem();
|
||||||
|
PageData data = item->data(0, Qt::UserRole).value<PageData>();
|
||||||
|
int index = data.index;
|
||||||
|
_currentCategory = data.category;
|
||||||
|
_currentPage = data.id;
|
||||||
|
_ui.stackedPages->setCurrentIndex(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSettingsDialog::accept()
|
||||||
|
{
|
||||||
|
_applied = true;
|
||||||
|
Q_FOREACH(IOptionsPage *page, _pages)
|
||||||
|
{
|
||||||
|
page->apply();
|
||||||
|
page->finish();
|
||||||
|
}
|
||||||
|
done(QDialog::Accepted);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSettingsDialog::reject()
|
||||||
|
{
|
||||||
|
Q_FOREACH(IOptionsPage *page, _pages)
|
||||||
|
page->finish();
|
||||||
|
done(QDialog::Rejected);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSettingsDialog::apply()
|
||||||
|
{
|
||||||
|
Q_FOREACH(IOptionsPage *page, _pages)
|
||||||
|
page->apply();
|
||||||
|
_applied = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CSettingsDialog::execDialog()
|
||||||
|
{
|
||||||
|
_applied = false;
|
||||||
|
exec();
|
||||||
|
return _applied;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSettingsDialog::done(int val)
|
||||||
|
{
|
||||||
|
QDialog::done(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
} /* namespace Core */
|
@ -0,0 +1,75 @@
|
|||||||
|
// 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>
|
||||||
|
// Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#ifndef SETTINGS_DIALOG_H
|
||||||
|
#define SETTINGS_DIALOG_H
|
||||||
|
|
||||||
|
#include "ui_settings_dialog.h"
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
#include <QtCore/QList>
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
#include "ioptions_page.h"
|
||||||
|
#include "../../extension_system/iplugin.h"
|
||||||
|
|
||||||
|
namespace Core
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
@class CSettingsDialog
|
||||||
|
@brief Settings dialog
|
||||||
|
*/
|
||||||
|
class CSettingsDialog: public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
CSettingsDialog(ExtensionSystem::IPluginManager *pluginManager,
|
||||||
|
const QString &initialCategory = QString(),
|
||||||
|
const QString &initialPage = QString(),
|
||||||
|
QWidget *parent = 0);
|
||||||
|
|
||||||
|
~CSettingsDialog();
|
||||||
|
|
||||||
|
/// Run the dialog and return true if 'Ok' was choosen or 'Apply' was invoked at least once
|
||||||
|
bool execDialog();
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
|
void done(int);
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void pageSelected();
|
||||||
|
void accept();
|
||||||
|
void reject();
|
||||||
|
void apply();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QList<Core::IOptionsPage*> _pages;
|
||||||
|
bool _applied;
|
||||||
|
QString _currentCategory;
|
||||||
|
QString _currentPage;
|
||||||
|
|
||||||
|
ExtensionSystem::IPluginManager *_plugMan;
|
||||||
|
|
||||||
|
Ui::CSettingsDialog _ui;
|
||||||
|
}; /* class CSettingsDialog */
|
||||||
|
|
||||||
|
} /* namespace Core */
|
||||||
|
|
||||||
|
#endif // SETTINGS_DIALOG_H
|
@ -0,0 +1,126 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>CSettingsDialog</class>
|
||||||
|
<widget class="QDialog" name="CSettingsDialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>697</width>
|
||||||
|
<height>476</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Settings</string>
|
||||||
|
</property>
|
||||||
|
<property name="windowIcon">
|
||||||
|
<iconset resource="core.qrc">
|
||||||
|
<normaloff>:/core/images/preferences.png</normaloff>:/core/images/preferences.png</iconset>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QSplitter" name="splitter">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<widget class="QTreeWidget" name="pageTree">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="columnCount">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>0</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="layoutWidget">
|
||||||
|
<layout class="QVBoxLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QStackedWidget" name="stackedPages">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>350</width>
|
||||||
|
<height>250</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="Line" name="line">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources>
|
||||||
|
<include location="core.qrc"/>
|
||||||
|
</resources>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>CSettingsDialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>297</x>
|
||||||
|
<y>361</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>297</x>
|
||||||
|
<y>193</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>CSettingsDialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>297</x>
|
||||||
|
<y>361</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>297</x>
|
||||||
|
<y>193</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
Loading…
Reference in New Issue