Changed: #1206 Works search settings page. Update core and example plugin.

This commit is contained in:
dnk-88 2011-02-24 15:07:23 +02:00
parent bc381fd3d3
commit 4e8fa8bd72
17 changed files with 343 additions and 104 deletions

View file

@ -2,3 +2,4 @@ ADD_SUBDIRECTORY(core)
ADD_SUBDIRECTORY(example)
ADD_SUBDIRECTORY(ovqt_sheet_builder)
ADD_SUBDIRECTORY(log)
ADD_SUBDIRECTORY(disp_sheet_id)

View file

@ -19,6 +19,7 @@
#include "core.h"
#include "imenu_manager.h"
#include "main_window.h"
#include "../../extension_system/iplugin_manager.h"
static Core::CoreImpl *m_coreInstance = 0;
@ -63,4 +64,9 @@ QMainWindow *CoreImpl::mainWindow() const
return m_mainWindow;
}
ExtensionSystem::IPluginManager *CoreImpl::pluginManager() const
{
return m_mainWindow->pluginManager();
}
} // namespace Core

View file

@ -42,6 +42,7 @@ public:
virtual QSettings *settings() const;
virtual QMainWindow *mainWindow() const;
virtual ExtensionSystem::IPluginManager *pluginManager() const;
private:
MainWindow *m_mainWindow;
friend class MainWindow;

View file

@ -1,6 +1,10 @@
<RCC>
<qresource prefix="/core" >
<qresource prefix="/core">
<file>images/list-add.png</file>
<file>images/list-remove.png</file>
<file>images/go-up.png</file>
<file>images/go-down.png</file>
<file>images/nel.png</file>
<file>images/preferences.png</file>
</qresource>
</qresource>
</RCC>

View file

@ -57,6 +57,14 @@ const char * const ABOUT = "ObjectViewerQt.About";
const char * const ABOUT_PLUGINS = "ObjectViewerQt.AboutPlugins";
const char * const ABOUT_QT = "ObjectViewerQt.AboutQt";
//settings
const char * const DATA_PATH_SECTION = "DataPath";
const char * const SEARCH_PATHS = "SearchPaths";
const char * const RECURSIVE_SEARCH_PATHS = "RecursiveSearchPathes";
const char * const LEVELDESIGN_PATH = "LevelDesignPath";
const char * const ASSETS_PATH = "LevelDesignPath";
//resources
const char * const ICON_NEL = ":/core/images/nel.png";
const char * const ICON_SETTINGS = ":/core/images/preferences.png";
} // namespace Constants

View file

@ -75,6 +75,7 @@ bool CorePlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QStr
connect(newAction, SIGNAL(triggered()), this, SLOT(execSettings()));
connect(newAction2, SIGNAL(triggered()), _pluginView, SLOT(show()));
_oldOVQT = false;
return true;
}
else
{
@ -97,11 +98,12 @@ bool CorePlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QStr
}
_oldOVQT = true;
bool success = _mainWindow->initialize(errorString);
CSearchPathsSettingsPage *serchPathPage = new CSearchPathsSettingsPage(this);
serchPathPage->applySearchPaths();
addAutoReleasedObject(serchPathPage);
return success;
}
addAutoReleasedObject(new CSearchPathsSettingsPage(this));
return true;
}
void CorePlugin::extensionsInitialized()

View file

@ -28,6 +28,11 @@ class QMainWindow;
class QSettings;
QT_END_NAMESPACE
namespace ExtensionSystem
{
class IPluginManager;
}
namespace Core
{
class IMenuManager;
@ -51,6 +56,8 @@ public:
virtual QSettings *settings() const = 0;
virtual QMainWindow *mainWindow() const = 0;
virtual ExtensionSystem::IPluginManager *pluginManager() const = 0;
Q_SIGNALS:
void closeMainWindow();
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -111,6 +111,11 @@ QSettings *MainWindow::settings() const
return m_settings;
}
ExtensionSystem::IPluginManager *MainWindow::pluginManager() const
{
return m_pluginManager;
}
void MainWindow::checkObject(QObject *obj)
{
IContext *context = qobject_cast<IContext *>(obj);

View file

@ -19,7 +19,7 @@
#define MAIN_WINDOW_H
// Project includes
#include "../../extension_system/iplugin.h"
#include "../../extension_system/iplugin_manager.h"
#include "plugin_view_dialog.h"
// STL includes
@ -51,6 +51,8 @@ public:
IMenuManager *menuManager() const;
QSettings *settings() const;
ExtensionSystem::IPluginManager *pluginManager() const;
public Q_SLOTS:
bool showOptionsDialog(const QString &group = QString(),
const QString &page = QString(),

View file

@ -15,21 +15,29 @@
// 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 "search_paths_settings_page.h"
// Qt includes
#include <QtGui/QWidget>
#include "core_constants.h"
#include "icore.h"
// NeL includes
#include <nel/misc/path.h>
// Project includes
// Qt includes
#include <QtCore/QSettings>
#include <QtGui/QWidget>
#include <QtGui/QFileDialog>
namespace Core
{
CSearchPathsSettingsPage::CSearchPathsSettingsPage(QObject *parent)
: IOptionsPage(parent),
_currentPage(0)
m_page(0)
{
}
CSearchPathsSettingsPage::~CSearchPathsSettingsPage()
{
}
@ -55,13 +63,127 @@ QString CSearchPathsSettingsPage::trCategory() const
QWidget *CSearchPathsSettingsPage::createPage(QWidget *parent)
{
_currentPage = new QWidget(parent);
_ui.setupUi(_currentPage);
return _currentPage;
m_page = new QWidget(parent);
m_ui.setupUi(m_page);
readSettings();
checkEnabledButton();
connect(m_ui.addToolButton, SIGNAL(clicked()), this, SLOT(addPath()));
connect(m_ui.removeToolButton, SIGNAL(clicked()), this, SLOT(delPath()));
connect(m_ui.upToolButton, SIGNAL(clicked()), this, SLOT(upPath()));
connect(m_ui.downToolButton, SIGNAL(clicked()), this, SLOT(downPath()));
return m_page;
}
void CSearchPathsSettingsPage::apply()
{
writeSettings();
applySearchPaths();
}
void CSearchPathsSettingsPage::finish()
{
delete m_page;
m_page = 0;
}
void CSearchPathsSettingsPage::applySearchPaths()
{
QStringList paths;
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Core::Constants::DATA_PATH_SECTION);
paths = settings->value(Core::Constants::SEARCH_PATHS).toStringList();
settings->endGroup();
Q_FOREACH(QString path, paths)
{
NLMISC::CPath::addSearchPath(path.toStdString(), false, false);
}
NLMISC::CPath::remapExtension("png", "tga", true);
NLMISC::CPath::remapExtension("png", "dds", true);
}
void CSearchPathsSettingsPage::addPath()
{
QString newPath = QFileDialog::getExistingDirectory(m_page);
if (!newPath.isEmpty())
{
QListWidgetItem *newItem = new QListWidgetItem;
newItem->setText(newPath);
newItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
m_ui.pathsListWidget->addItem(newItem);
}
checkEnabledButton();
}
void CSearchPathsSettingsPage::delPath()
{
QListWidgetItem *removeItem = m_ui.pathsListWidget->takeItem(m_ui.pathsListWidget->currentRow());
if (!removeItem)
delete removeItem;
checkEnabledButton();
}
void CSearchPathsSettingsPage::upPath()
{
int currentRow = m_ui.pathsListWidget->currentRow();
if (!(currentRow == 0))
{
QListWidgetItem *item = m_ui.pathsListWidget->takeItem(currentRow);
m_ui.pathsListWidget->insertItem(--currentRow, item);
m_ui.pathsListWidget->setCurrentRow(currentRow);
}
}
void CSearchPathsSettingsPage::downPath()
{
int currentRow = m_ui.pathsListWidget->currentRow();
if (!(currentRow == m_ui.pathsListWidget->count()-1))
{
QListWidgetItem *item = m_ui.pathsListWidget->takeItem(currentRow);
m_ui.pathsListWidget->insertItem(++currentRow, item);
m_ui.pathsListWidget->setCurrentRow(currentRow);
}
}
void CSearchPathsSettingsPage::readSettings()
{
QStringList paths;
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Core::Constants::DATA_PATH_SECTION);
paths = settings->value(Core::Constants::SEARCH_PATHS).toStringList();
settings->endGroup();
Q_FOREACH(QString path, paths)
{
QListWidgetItem *newItem = new QListWidgetItem;
newItem->setText(path);
newItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
m_ui.pathsListWidget->addItem(newItem);
}
}
void CSearchPathsSettingsPage::writeSettings()
{
QStringList paths;
for (int i = 0; i < m_ui.pathsListWidget->count(); ++i)
paths << m_ui.pathsListWidget->item(i)->text();
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Core::Constants::DATA_PATH_SECTION);
settings->setValue(Core::Constants::SEARCH_PATHS, paths);
settings->endGroup();
}
void CSearchPathsSettingsPage::checkEnabledButton()
{
bool bEnabled = true;
if (m_ui.pathsListWidget->count() == 0)
bEnabled = false;
m_ui.removeToolButton->setEnabled(bEnabled);
m_ui.upToolButton->setEnabled(bEnabled);
m_ui.downToolButton->setEnabled(bEnabled);
}
} /* namespace Core */

View file

@ -38,7 +38,7 @@ class CSearchPathsSettingsPage : public Core::IOptionsPage
public:
CSearchPathsSettingsPage(QObject *parent = 0);
~CSearchPathsSettingsPage() {}
~CSearchPathsSettingsPage();
QString id() const;
QString trName() const;
@ -47,11 +47,23 @@ public:
QWidget *createPage(QWidget *parent);
void apply();
void finish() {}
void finish();
void applySearchPaths();
private Q_SLOTS:
void addPath();
void delPath();
void upPath();
void downPath();
private:
QWidget *_currentPage;
Ui::CSearchPathsSettingsPage _ui;
void readSettings();
void writeSettings();
void checkEnabledButton();
QWidget *m_page;
Ui::CSearchPathsSettingsPage m_ui;
};
} // namespace Core

View file

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>422</width>
<height>272</height>
<width>431</width>
<height>285</height>
</rect>
</property>
<property name="windowTitle">
@ -15,97 +15,149 @@
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>0</number>
<number>6</number>
</property>
<property name="spacing">
<number>3</number>
</property>
<item row="0" column="0">
<widget class="QGroupBox" name="searchPathsGroupBox">
<property name="title">
<widget class="QLabel" name="label">
<property name="text">
<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>
<item row="0" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>228</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>3</number>
</property>
<item>
<widget class="QToolButton" name="addToolButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="core.qrc">
<normaloff>:/core/images/list-add.png</normaloff>:/core/images/list-add.png</iconset>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="removeToolButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="core.qrc">
<normaloff>:/core/images/list-remove.png</normaloff>:/core/images/list-remove.png</iconset>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="upToolButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="core.qrc">
<normaloff>:/core/images/go-up.png</normaloff>:/core/images/go-up.png</iconset>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="downToolButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="core.qrc">
<normaloff>:/core/images/go-down.png</normaloff>:/core/images/go-down.png</iconset>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0" colspan="3">
<widget class="QListWidget" name="pathsListWidget"/>
</item>
</layout>
</widget>
<resources>
<include location="../../object_viewer_qt.qrc"/>
<include location="core.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -20,6 +20,7 @@
// NeL includes
#include <nel/misc/types_nl.h>
#include <nel/misc/rgba.h>
#include <nel/misc/event_emitter.h>
// Qt includes
@ -54,11 +55,24 @@ public:
/// Set the update interval renderer
void setInterval(int msec);
float getFPS() const
/// Set the background color.
void setBackgroundColor(NLMISC::CRGBA backgroundColor);
float fps() const
{
return m_fps;
}
inline NLMISC::CRGBA backgroundColor() const
{
return m_backgroundColor;
}
NL3D::UDriver *driver() const
{
return m_driver;
}
virtual QPaintEngine* paintEngine() const
{
return NULL;
@ -90,7 +104,10 @@ private:
QNLWidget &operator=(const QNLWidget &);
NL3D::UDriver *m_driver;
NLMISC::CRGBA m_backgroundColor;
QTimer *m_mainTimer;
bool m_initialized;
int m_interval;
float m_fps;