mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-17 13:01:42 +00:00
Changed: #1206 Update sheet builder plugin. Now plugin is using ICore for reading and writing settings, and it adds action in menu Sheet.
This commit is contained in:
parent
b9df3fb0f5
commit
05613b0f66
12 changed files with 561 additions and 573 deletions
|
@ -43,6 +43,8 @@ const char * const M_TOOLS = "ObjectViewerQt.Menu.Tools";
|
|||
const char * const M_WINDOW = "ObjectViewerQt.Menu.Window";
|
||||
const char * const M_HELP = "ObjectViewerQt.Menu.Help";
|
||||
|
||||
const char * const M_SHEET = "ObjectViewerQt.Menu.Sheet";
|
||||
|
||||
//actions
|
||||
const char * const NEW = "ObjectViewerQt.New";
|
||||
const char * const OPEN = "ObjectViewerQt.Open";
|
||||
|
|
|
@ -62,8 +62,7 @@ bool CorePlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QStr
|
|||
{
|
||||
QtWin::extendFrameIntoClientArea(_mainWindow);
|
||||
_mainWindow->setContentsMargins(0, 0, 0, 0);
|
||||
}
|
||||
*/
|
||||
}*/
|
||||
bool success = _mainWindow->initialize(errorString);
|
||||
CSearchPathsSettingsPage *serchPathPage = new CSearchPathsSettingsPage(this);
|
||||
serchPathPage->applySearchPaths();
|
||||
|
|
|
@ -231,8 +231,10 @@ void MainWindow::createMenus()
|
|||
m_toolsMenu = menuBar()->addMenu(tr("&Tools"));
|
||||
menuManager()->registerMenu(m_toolsMenu, Constants::M_TOOLS);
|
||||
|
||||
m_sheetMenu = m_toolsMenu->addMenu(tr("&Sheet"));
|
||||
menuManager()->registerMenu(m_sheetMenu, Constants::M_SHEET);
|
||||
|
||||
m_toolsMenu->addSeparator();
|
||||
// m_toolsMenu->addSeparator();
|
||||
|
||||
m_toolsMenu->addAction(m_settingsAction);
|
||||
|
||||
|
|
|
@ -97,6 +97,8 @@ private:
|
|||
QMenu *m_toolsMenu;
|
||||
QMenu *m_helpMenu;
|
||||
|
||||
QMenu *m_sheetMenu;
|
||||
|
||||
QAction *m_openAction;
|
||||
QAction *m_exitAction;
|
||||
QAction *m_settingsAction;
|
||||
|
|
|
@ -21,7 +21,7 @@ SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC})
|
|||
|
||||
ADD_LIBRARY(ovqt_plugin_sheet_builder MODULE ${SRC} ${OVQT_PLUG_SHEET_BUILDER_MOC_SRC} ${OVQT_EXT_SYS_SRC})
|
||||
|
||||
TARGET_LINK_LIBRARIES(ovqt_plugin_sheet_builder nelmisc ${QT_LIBRARIES})
|
||||
TARGET_LINK_LIBRARIES(ovqt_plugin_sheet_builder ovqt_plugin_core nelmisc ${QT_LIBRARIES})
|
||||
|
||||
NL_DEFAULT_PROPS(ovqt_plugin_sheet_builder "NeL, Tools, 3D: Object Viewer Qt Plugin: Sheet builder")
|
||||
NL_ADD_RUNTIME_FLAGS(ovqt_plugin_sheet_builder)
|
||||
|
|
|
@ -14,8 +14,18 @@
|
|||
// 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 "ovqt_sheet_builder.h"
|
||||
#include "sheetbuilderdialog.h"
|
||||
#include "sheetbuilderconfgdialog.h"
|
||||
#include "../core/icore.h"
|
||||
#include "../core/imenu_manager.h"
|
||||
#include "../core/core_constants.h"
|
||||
|
||||
// NeL includes
|
||||
#include <nel/misc/debug.h>
|
||||
|
||||
// Qt includes
|
||||
#include <QtCore/QObject>
|
||||
#include <QtGui/QMessageBox>
|
||||
#include <QtGui/QMainWindow>
|
||||
|
@ -23,47 +33,29 @@
|
|||
#include <QtGui/QAction>
|
||||
#include <QtGui/QMenuBar>
|
||||
|
||||
#include "../../extension_system/iplugin_spec.h"
|
||||
|
||||
#include "nel/misc/debug.h"
|
||||
#include "sheetbuilderdialog.h"
|
||||
#include "sheetbuilderconfgdialog.h"
|
||||
|
||||
using namespace Plugin;
|
||||
|
||||
bool SheetBuilderPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString)
|
||||
{
|
||||
Q_UNUSED(errorString);
|
||||
_plugMan = pluginManager;
|
||||
QMainWindow *wnd = qobject_cast<QMainWindow *>(objectByName("CMainWindow"));
|
||||
if (!wnd)
|
||||
{
|
||||
*errorString = tr("Not found MainWindow Object Viewer Qt.");
|
||||
return false;
|
||||
}
|
||||
QMenu *toolsMenu = qobject_cast<QMenu *>(objectByName("ovqt.Menu.Tools"));
|
||||
if (!toolsMenu)
|
||||
{
|
||||
*errorString = tr("Not found QMenu Tools.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SheetBuilderPlugin::extensionsInitialized()
|
||||
{
|
||||
QMenu *toolsMenu = qobject_cast<QMenu *>(objectByName("ovqt.Menu.Tools"));
|
||||
nlassert(toolsMenu);
|
||||
Core::IMenuManager *menuManager = Core::ICore::instance()->menuManager();
|
||||
|
||||
toolsMenu->addSeparator();
|
||||
|
||||
QAction *actBuilder = toolsMenu->addAction("Sheet builder");
|
||||
connect(actBuilder, SIGNAL(triggered()), this, SLOT(execBuilderDialog()));
|
||||
QMenu *sheetMenu = menuManager->menu(Core::Constants::M_SHEET);
|
||||
QAction *sheetBuilderAction = sheetMenu->addAction(tr("Sheet builder"));
|
||||
menuManager->registerAction(sheetBuilderAction, "SheetBuilder");
|
||||
connect(sheetBuilderAction, SIGNAL(triggered()), this, SLOT(execBuilderDialog()));
|
||||
}
|
||||
|
||||
void SheetBuilderPlugin::execBuilderDialog()
|
||||
{
|
||||
QMainWindow *wnd = qobject_cast<QMainWindow *>(objectByName("CMainWindow"));
|
||||
QMainWindow *wnd = Core::ICore::instance()->mainWindow();
|
||||
nlassert(wnd);
|
||||
|
||||
SheetBuilderDialog dlg(wnd);
|
||||
|
@ -100,25 +92,11 @@ QString SheetBuilderPlugin::description() const
|
|||
return "make_sheet_id equivalent";
|
||||
}
|
||||
|
||||
QList<QString> SheetBuilderPlugin::dependencies() const
|
||||
QStringList SheetBuilderPlugin::dependencies() const
|
||||
{
|
||||
return QList<QString>();
|
||||
}
|
||||
|
||||
QObject* SheetBuilderPlugin::objectByName(const QString &name) const
|
||||
{
|
||||
Q_FOREACH (QObject *qobj, _plugMan->allObjects())
|
||||
if (qobj->objectName() == name)
|
||||
return qobj;
|
||||
return 0;
|
||||
}
|
||||
|
||||
ExtensionSystem::IPluginSpec *SheetBuilderPlugin::pluginByName(const QString &name) const
|
||||
{
|
||||
Q_FOREACH (ExtensionSystem::IPluginSpec *spec, _plugMan->plugins())
|
||||
if (spec->name() == name)
|
||||
return spec;
|
||||
return 0;
|
||||
QStringList list;
|
||||
list.append(Core::Constants::OVQT_CORE_PLUGIN);
|
||||
return list;
|
||||
}
|
||||
|
||||
Q_EXPORT_PLUGIN(SheetBuilderPlugin)
|
||||
|
|
|
@ -50,10 +50,7 @@ namespace Plugin
|
|||
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;
|
||||
QStringList dependencies() const;
|
||||
|
||||
void buildSheet(bool clean);
|
||||
|
||||
|
|
|
@ -26,10 +26,8 @@
|
|||
// std
|
||||
#include <string>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
using namespace NLMISC;
|
||||
using namespace std;
|
||||
|
||||
|
@ -50,10 +48,16 @@ union TFormId
|
|||
uint32 Id : 24;
|
||||
} FormIDInfos;
|
||||
|
||||
void serial(NLMISC::IStream &f) { f.serial(Id); }
|
||||
void serial(NLMISC::IStream &f)
|
||||
{
|
||||
f.serial(Id);
|
||||
}
|
||||
};
|
||||
|
||||
bool operator<(const TFormId& fid1, const TFormId& fid2) { return fid1.Id<fid2.Id; }
|
||||
bool operator<(const TFormId& fid1, const TFormId& fid2)
|
||||
{
|
||||
return fid1.Id<fid2.Id;
|
||||
}
|
||||
|
||||
|
||||
map<string,TFormId> FormToId;
|
||||
|
@ -185,8 +189,6 @@ void readFormId( string& outputFileName )
|
|||
} // readFormId //
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// makeId
|
||||
//
|
||||
|
@ -210,8 +212,6 @@ void makeId( list<string>& dirs )
|
|||
} // makeId //
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// addId
|
||||
//
|
||||
|
@ -311,7 +311,6 @@ void addId( string fileName )
|
|||
} // addId //
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// getFileType
|
||||
//
|
||||
|
@ -324,7 +323,6 @@ bool getFileType( string& fileName, string& fileType )
|
|||
} // getFileType //
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// display
|
||||
//
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "sheetbuilderconfgdialog.h"
|
||||
#include "../core/icore.h"
|
||||
|
||||
#include <QListWidget>
|
||||
#include <QPushButton>
|
||||
|
@ -25,8 +26,8 @@
|
|||
#include <QCloseEvent>
|
||||
#include <QFileDialog>
|
||||
|
||||
SheetBuilderConfigDialog::SheetBuilderConfigDialog(QWidget *parent) :
|
||||
QDialog(parent)
|
||||
SheetBuilderConfigDialog::SheetBuilderConfigDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
/*
|
||||
* Paths
|
||||
|
@ -117,8 +118,9 @@ SheetBuilderConfigDialog::SheetBuilderConfigDialog(QWidget *parent) :
|
|||
void SheetBuilderConfigDialog::addPath()
|
||||
{
|
||||
QString path =
|
||||
QFileDialog::getExistingDirectory(this, "Choose path");
|
||||
if (!path.isEmpty()) {
|
||||
QFileDialog::getExistingDirectory(this, tr("Choose path"));
|
||||
if (!path.isEmpty())
|
||||
{
|
||||
QListWidgetItem *newItem = new QListWidgetItem;
|
||||
newItem->setText(path);
|
||||
newItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
||||
|
@ -164,18 +166,20 @@ void SheetBuilderConfigDialog::readSettings()
|
|||
QString outputFile;
|
||||
QStringList extensions;
|
||||
|
||||
QSettings settings("ovqt_sheet_builder.ini", QSettings::IniFormat);
|
||||
|
||||
paths = settings.value("SheetPaths").toStringList();
|
||||
outputFile = settings.value("SheetOutputFile").toString();
|
||||
extensions = settings.value("ExtensionsAllowed").toStringList();
|
||||
QSettings *settings = Core::ICore::instance()->settings();
|
||||
settings->beginGroup("SheetBuilder");
|
||||
paths = settings->value("SheetPaths").toStringList();
|
||||
outputFile = settings->value("SheetOutputFile").toString();
|
||||
extensions = settings->value("ExtensionsAllowed").toStringList();
|
||||
settings->endGroup();
|
||||
|
||||
lstPaths->clear();
|
||||
lstExtensionsAllowed->clear();
|
||||
|
||||
QListWidgetItem *newItem;
|
||||
|
||||
Q_FOREACH (QString path, paths) {
|
||||
Q_FOREACH (QString path, paths)
|
||||
{
|
||||
newItem = new QListWidgetItem;
|
||||
newItem->setText(path);
|
||||
newItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
||||
|
@ -184,7 +188,8 @@ void SheetBuilderConfigDialog::readSettings()
|
|||
|
||||
txtOutputFile->setText(outputFile);
|
||||
|
||||
Q_FOREACH (QString extension, extensions) {
|
||||
Q_FOREACH (QString extension, extensions)
|
||||
{
|
||||
newItem = new QListWidgetItem;
|
||||
newItem->setText(extension);
|
||||
newItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
||||
|
@ -204,8 +209,13 @@ void SheetBuilderConfigDialog::writeSettings()
|
|||
for (int i = 0; i < lstExtensionsAllowed->count(); i++)
|
||||
extensions.push_back(lstExtensionsAllowed->item(i)->text());
|
||||
|
||||
QSettings settings("./ovqt_sheet_builder.ini", QSettings::IniFormat);
|
||||
settings.setValue("SheetPaths", paths);
|
||||
settings.setValue("SheetOutputFile", outputFile);
|
||||
settings.setValue("ExtensionsAllowed", extensions);
|
||||
QSettings *settings = Core::ICore::instance()->settings();
|
||||
settings->beginGroup("SheetBuilder");
|
||||
settings->setValue("SheetPaths", paths);
|
||||
settings->setValue("SheetOutputFile", outputFile);
|
||||
settings->setValue("ExtensionsAllowed", extensions);
|
||||
settings->endGroup();
|
||||
|
||||
// Forced save settings
|
||||
settings->sync();
|
||||
}
|
||||
|
|
|
@ -15,6 +15,11 @@
|
|||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "sheetbuilderdialog.h"
|
||||
#include "sheetbuilder.h"
|
||||
#include "sheetbuilderconfgdialog.h"
|
||||
#include "../core/icore.h"
|
||||
#include "../core/core_constants.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QPushButton>
|
||||
#include <QLayout>
|
||||
|
@ -23,13 +28,9 @@
|
|||
#include <QTreeWidget>
|
||||
#include <QDebug>
|
||||
|
||||
#include "sheetbuilder.h"
|
||||
#include "sheetbuilderconfgdialog.h"
|
||||
|
||||
SheetBuilderDialog::SheetBuilderDialog(QWidget *parent) :
|
||||
QDialog(parent)
|
||||
SheetBuilderDialog::SheetBuilderDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
|
||||
QPushButton *btnOk = new QPushButton(tr("Make sheet"));
|
||||
connect(btnOk, SIGNAL(clicked()), SLOT(buildSheet()));
|
||||
|
||||
|
@ -81,7 +82,8 @@ void SheetBuilderDialog::showConfig()
|
|||
|
||||
void SheetBuilderDialog::detailsShowHide()
|
||||
{
|
||||
if (!detailsVisible) {
|
||||
if (!detailsVisible)
|
||||
{
|
||||
defHeight = height();
|
||||
defWidth = width();
|
||||
}
|
||||
|
@ -89,7 +91,8 @@ void SheetBuilderDialog::detailsShowHide()
|
|||
detailsVisible = !detailsVisible;
|
||||
txtOutput->setVisible(detailsVisible);
|
||||
|
||||
if (!detailsVisible) {
|
||||
if (!detailsVisible)
|
||||
{
|
||||
adjustSize();
|
||||
resize(defWidth, defHeight);
|
||||
}
|
||||
|
@ -106,16 +109,20 @@ void SheetBuilderDialog::buildSheet()
|
|||
QString outputFile;
|
||||
QStringList extensions;
|
||||
|
||||
QSettings settings("ovqt_sheet_builder.ini", QSettings::IniFormat);
|
||||
paths = settings.value("SheetPaths").toStringList();
|
||||
outputFile = settings.value("SheetOutputFile").toString();
|
||||
extensions = settings.value("ExtensionsAllowed").toStringList();
|
||||
// read settings
|
||||
QSettings *settings = Core::ICore::instance()->settings();
|
||||
settings->beginGroup("SheetBuilder");
|
||||
paths = settings->value("SheetPaths").toStringList();
|
||||
outputFile = settings->value("SheetOutputFile").toString();
|
||||
extensions = settings->value("ExtensionsAllowed").toStringList();
|
||||
settings->endGroup();
|
||||
|
||||
bool clean = chckClean->isChecked();
|
||||
string configFileName("ovqt_sheet_builder.ini");
|
||||
|
||||
string outputFileName(outputFile.toStdString());
|
||||
|
||||
if (outputFileName.empty()) {
|
||||
if (outputFileName.empty())
|
||||
{
|
||||
displayInfo("Error: Output file is not specified");
|
||||
return;
|
||||
}
|
||||
|
@ -124,18 +131,10 @@ void SheetBuilderDialog::buildSheet()
|
|||
Q_FOREACH (QString str, paths)
|
||||
inputDirs.push_back(str.toStdString());
|
||||
|
||||
// load the config files
|
||||
CConfigFile configFile;
|
||||
if(!CFile::fileExists(configFileName))
|
||||
Q_FOREACH (QString str, extensions)
|
||||
{
|
||||
displayInfo(QString("Config file '%1' not found, working whithout filter").arg(configFileName.c_str()) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Q_FOREACH (QString str, extensions) {
|
||||
ExtensionsAllowed.insert(str.toStdString());
|
||||
}
|
||||
}
|
||||
|
||||
// get the current associations (read the sheet_id and fill the working structures)
|
||||
readFormId( outputFileName );
|
||||
|
@ -152,7 +151,7 @@ void SheetBuilderDialog::buildSheet()
|
|||
if( clean )
|
||||
{
|
||||
if( ExtensionsAllowed.empty() )
|
||||
displayInfo("None extension list provided, the input will not be cleaned");
|
||||
displayInfo(tr("None extension list provided, the input will not be cleaned"));
|
||||
else
|
||||
{
|
||||
map<TFormId,string>::iterator itSheets;
|
||||
|
@ -176,9 +175,10 @@ void SheetBuilderDialog::buildSheet()
|
|||
displayInfo("The file has been cleaned");
|
||||
return;
|
||||
}
|
||||
|
||||
setCursor(Qt::WaitCursor);
|
||||
// make the ids
|
||||
makeId( inputDirs );
|
||||
setCursor(Qt::ArrowCursor);
|
||||
|
||||
// save the new map
|
||||
COFile f( outputFileName );
|
||||
|
@ -188,7 +188,7 @@ void SheetBuilderDialog::buildSheet()
|
|||
COFile output;
|
||||
if( !output.open(sheetListFileName,false,true) )
|
||||
{
|
||||
displayInfo(QString("Can't open output file %1").arg(sheetListFileName.c_str()));
|
||||
displayInfo(tr("Can't open output file %1").arg(sheetListFileName.c_str()));
|
||||
return;
|
||||
}
|
||||
map<TFormId,string>::iterator it1;
|
||||
|
@ -198,13 +198,13 @@ void SheetBuilderDialog::buildSheet()
|
|||
output.serialBuffer((uint8*)(const_cast<char*>(outputLine.data())),(uint)outputLine.size());
|
||||
}
|
||||
|
||||
displayInfo ("------------- results ----------------");
|
||||
displayInfo (QString("%1 files added in '%2'").arg(NbFilesAdded).arg(outputFileName.c_str()));
|
||||
displayInfo (QString("%1 files discarded because they are empty, begin with .# _ and so on").arg(NbFilesDiscarded));
|
||||
displayInfo (QString("%1 files skipped because don't have extension").arg(NbFilesUnknownType));
|
||||
displayInfo (QString("%1 types added in '%1'").arg(NbTypesAdded).arg(outputFileName.c_str()));
|
||||
displayInfo (tr("------------- results ----------------"));
|
||||
displayInfo (tr("%1 files added in '%2'").arg(NbFilesAdded).arg(outputFileName.c_str()));
|
||||
displayInfo (tr("%1 files discarded because they are empty, begin with .# _ and so on").arg(NbFilesDiscarded));
|
||||
displayInfo (tr("%1 files skipped because don't have extension").arg(NbFilesUnknownType));
|
||||
displayInfo (tr("%1 types added in '%1'").arg(NbTypesAdded).arg(outputFileName.c_str()));
|
||||
|
||||
displayInfo (QString("%1 supported file types :").arg(FileTypeToId.size()));
|
||||
displayInfo (tr("%1 supported file types :").arg(FileTypeToId.size()));
|
||||
for ( map<string,uint8>::iterator it = FileTypeToId.begin(); it != FileTypeToId.end(); ++it )
|
||||
{
|
||||
displayInfo(QString("%1").arg((*it).first.c_str()));
|
||||
|
|
Loading…
Reference in a new issue