From bcb7d15f8ef08a6340500c113c9f75e863bcdda9 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Fri, 11 Feb 2011 21:02:47 +0200 Subject: [PATCH] Changed: #1206 Update core plugin. Added IAppPage. --- .../src/plugins/core/iapp_page.h | 55 +++++++++++++++++++ .../src/plugins/core/ioptions_page.h | 4 +- .../src/plugins/core/main_window.cpp | 36 ++++++------ .../src/plugins/core/main_window.h | 4 +- .../src/plugins/core/qnel_widget.cpp | 3 +- .../plugins/core/search_paths_settings_page.h | 2 +- 6 files changed, 81 insertions(+), 23 deletions(-) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/core/iapp_page.h diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/iapp_page.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/iapp_page.h new file mode 100644 index 000000000..bdcd1191f --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/iapp_page.h @@ -0,0 +1,55 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Dzmitry Kamiahin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef IAPP_PAGE_H +#define IAPP_PAGE_H + +#include + +class QWidget; + +namespace Core +{ +/** +@interface IAppPage +@brief The IAppPage is an interface for providing app pages in main window. +@details You need to subclass this interface and put an instance of your subclass + into the plugin manager object pool. +*/ +class IAppPage +{ +public: + virtual ~IAppPage() {} + + /// 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; + + /// icon() is the icon for display + virtual QIcon icon() const = 0; + + /// The widget will be destroyed by the widget hierarchy when the main window closes + virtual QWidget *widget(QWidget *parent) = 0; +}; + +} // namespace Core + +Q_DECLARE_INTERFACE(Core::IAppPage, "dev.ryzom.com.IAppPage/0.1") + +#endif // IAPP_PAGE_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/ioptions_page.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/ioptions_page.h index 912adc1de..2d780bc2d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/ioptions_page.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/ioptions_page.h @@ -31,7 +31,7 @@ namespace Core @details You need to subclass this interface and put an instance of your subclass into the plugin manager object pool. */ -class IOptionsPage +class IOptionsPage { public: virtual ~IOptionsPage() {} @@ -63,4 +63,4 @@ public: Q_DECLARE_INTERFACE(Core::IOptionsPage, "dev.ryzom.com.IOptionsPage/1.0") -#endif // IOPTIONSPAGE_H +#endif // IOPTIONS_PAGE_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.cpp index 7b15cde19..89d5d48a0 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.cpp @@ -17,9 +17,12 @@ // Project includes #include "main_window.h" +#include "iapp_page.h" #include "core_constants.h" #include "settings_dialog.h" +// NeL includes +#include // Qt includes #include @@ -37,23 +40,24 @@ CMainWindow::CMainWindow(ExtensionSystem::IPluginManager *pluginManager, QWidget _tabWidget = new QTabWidget(this); setCentralWidget(_tabWidget); - QWidget *qwidg1 = new QWidget(_tabWidget); - QWidget *qwidg2 = new QWidget(_tabWidget); + QList listObjects = _pluginManager->allObjects(); + QList listAppPages; + Q_FOREACH(QObject *obj, listObjects) + { + IAppPage *appPage = dynamic_cast(obj); + if (appPage) + listAppPages.append(appPage); + } - _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); + Q_FOREACH(IAppPage *appPage, listAppPages) + { + QWidget *tabWidget = new QWidget(_tabWidget); + _tabWidget->addTab(tabWidget, appPage->icon(), appPage->trName()); + QGridLayout *gridLayout = new QGridLayout(tabWidget); + gridLayout->setObjectName(QString::fromUtf8("gridLayout_") + appPage->id()); + gridLayout->setContentsMargins(0, 0, 0, 0); + gridLayout->addWidget(appPage->widget(tabWidget), 0, 0, 1, 1); + } setDockNestingEnabled(true); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.h index e26cb4aab..49c668b14 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.h @@ -48,8 +48,8 @@ public: private Q_SLOTS: bool showOptionsDialog(const QString &group = QString(), - const QString &page = QString(), - QWidget *parent = 0); + const QString &page = QString(), + QWidget *parent = 0); void about(); private: diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/qnel_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/qnel_widget.cpp index 36013b35f..a422ec5d1 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/qnel_widget.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/qnel_widget.cpp @@ -55,8 +55,7 @@ void QNLWidget::init() nlassert(_driver); // initialize the nel 3d viewport - _driver->setDisplay((nlWindow)winId(), - NL3D::UDriver::CMode(width(), height(), 32)); + _driver->setDisplay((nlWindow)winId(), NL3D::UDriver::CMode(width(), height(), 32)); // set the cache size for the font manager(in bytes) _driver->setFontManagerMaxMemory(2097152); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/search_paths_settings_page.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/search_paths_settings_page.h index 72d2a2e40..bafad8f40 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/search_paths_settings_page.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/search_paths_settings_page.h @@ -32,7 +32,7 @@ namespace Core /** @class CSearchPathsSettingsPage */ - class CSearchPathsSettingsPage : public QObject, public Core::IOptionsPage +class CSearchPathsSettingsPage : public QObject, public Core::IOptionsPage { Q_OBJECT Q_INTERFACES(Core::IOptionsPage)