Changed: #1206 Update core plugin. Added IAppPage.

This commit is contained in:
dnk-88 2011-02-11 21:02:47 +02:00
parent 79bf594261
commit bcb7d15f8e
6 changed files with 81 additions and 23 deletions

View file

@ -0,0 +1,55 @@
// 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 IAPP_PAGE_H
#define IAPP_PAGE_H
#include <QtCore/QObject>
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

View file

@ -63,4 +63,4 @@ public:
Q_DECLARE_INTERFACE(Core::IOptionsPage, "dev.ryzom.com.IOptionsPage/1.0") Q_DECLARE_INTERFACE(Core::IOptionsPage, "dev.ryzom.com.IOptionsPage/1.0")
#endif // IOPTIONSPAGE_H #endif // IOPTIONS_PAGE_H

View file

@ -17,9 +17,12 @@
// Project includes // Project includes
#include "main_window.h" #include "main_window.h"
#include "iapp_page.h"
#include "core_constants.h" #include "core_constants.h"
#include "settings_dialog.h" #include "settings_dialog.h"
// NeL includes
#include <nel/misc/debug.h>
// Qt includes // Qt includes
#include <QtGui/QtGui> #include <QtGui/QtGui>
@ -37,23 +40,24 @@ CMainWindow::CMainWindow(ExtensionSystem::IPluginManager *pluginManager, QWidget
_tabWidget = new QTabWidget(this); _tabWidget = new QTabWidget(this);
setCentralWidget(_tabWidget); setCentralWidget(_tabWidget);
QWidget *qwidg1 = new QWidget(_tabWidget); QList<QObject *> listObjects = _pluginManager->allObjects();
QWidget *qwidg2 = new QWidget(_tabWidget); QList<IAppPage *> listAppPages;
Q_FOREACH(QObject *obj, listObjects)
{
IAppPage *appPage = dynamic_cast<IAppPage *>(obj);
if (appPage)
listAppPages.append(appPage);
}
_tabWidget->addTab(qwidg1, "tab1"); Q_FOREACH(IAppPage *appPage, listAppPages)
_tabWidget->addTab(qwidg2, "tab2"); {
QWidget *tabWidget = new QWidget(_tabWidget);
_tabWidget->addTab(tabWidget, appPage->icon(), appPage->trName());
QGridLayout *gridLayout = new QGridLayout(qwidg1); QGridLayout *gridLayout = new QGridLayout(tabWidget);
gridLayout->setObjectName(QString::fromUtf8("gridLayout")); gridLayout->setObjectName(QString::fromUtf8("gridLayout_") + appPage->id());
NLQT::QNLWidget *_nelWidget = new NLQT::QNLWidget(qwidg1); gridLayout->setContentsMargins(0, 0, 0, 0);
_nelWidget->setObjectName(QString::fromUtf8("NELWIdget1")); gridLayout->addWidget(appPage->widget(tabWidget), 0, 0, 1, 1);
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); setDockNestingEnabled(true);

View file

@ -48,8 +48,8 @@ public:
private Q_SLOTS: private Q_SLOTS:
bool showOptionsDialog(const QString &group = QString(), bool showOptionsDialog(const QString &group = QString(),
const QString &page = QString(), const QString &page = QString(),
QWidget *parent = 0); QWidget *parent = 0);
void about(); void about();
private: private:

View file

@ -55,8 +55,7 @@ void QNLWidget::init()
nlassert(_driver); nlassert(_driver);
// initialize the nel 3d viewport // initialize the nel 3d viewport
_driver->setDisplay((nlWindow)winId(), _driver->setDisplay((nlWindow)winId(), NL3D::UDriver::CMode(width(), height(), 32));
NL3D::UDriver::CMode(width(), height(), 32));
// set the cache size for the font manager(in bytes) // set the cache size for the font manager(in bytes)
_driver->setFontManagerMaxMemory(2097152); _driver->setFontManagerMaxMemory(2097152);

View file

@ -32,7 +32,7 @@ namespace Core
/** /**
@class CSearchPathsSettingsPage @class CSearchPathsSettingsPage
*/ */
class CSearchPathsSettingsPage : public QObject, public Core::IOptionsPage class CSearchPathsSettingsPage : public QObject, public Core::IOptionsPage
{ {
Q_OBJECT Q_OBJECT
Q_INTERFACES(Core::IOptionsPage) Q_INTERFACES(Core::IOptionsPage)