Merged in hotfix (pull request #114)

Merging hotfix branch
This commit is contained in:
dfighter1985 2015-02-13 19:48:42 +01:00
parent ad8d9fa391
commit 8a34288795
24 changed files with 235 additions and 48 deletions

View file

@ -25,6 +25,8 @@ extern "C"
#include "WWWInit.h"
}
#include "nel/misc/rgba.h"
namespace NLGUI
{
class CCtrlBaseButton;

View file

@ -507,6 +507,13 @@ public:
*/
static bool makePathRelative (const char *basePath, std::string &relativePath);
/** Make path absolute
* \param relativePath - The relative path
* \param directory - the directory to which the path is relative to
* returns the absolute path, or empty if something went wrong.
*/
static std::string makePathAbsolute (const std::string &relativePath, const std::string &directory );
/** If File in this list is added more than one in an addSearchPath, it doesn't launch a warning.
*/
static void addIgnoredDoubleFile(const std::string &ignoredFile);

View file

@ -2544,6 +2544,57 @@ bool CPath::makePathRelative (const char *basePath, std::string &relativePath)
return false;
}
std::string CPath::makePathAbsolute( const std::string &relativePath, const std::string &directory )
{
if( relativePath.empty() )
return "";
if( directory.empty() )
return "";
#ifdef NL_OS_WINDOWS
// Windows network address. Eg.: \\someshare\path
if( ( relativePath[ 0 ] == '\\' ) && ( relativePath[ 1 ] == '\\' ) )
return relativePath;
// Normal Windows absolute path. Eg.: C:\something
//
if( isalpha( relativePath[ 0 ] ) && ( relativePath[ 1 ] == ':' ) && ( ( relativePath[ 2 ] == '\\' ) || ( relativePath[ 2 ] == '/' ) ) )
return relativePath;
#else
// Unix filesystem absolute path
if( relativePath[ 0 ] == '/' )
return relativePath;
#endif
// Add a slash to the directory if necessary.
// If the relative path starts with dots we need a slash.
// If the relative path starts with a slash we don't.
// If it starts with neither, we need a slash.
bool needSlash = true;
char c = relativePath[ 0 ];
if( ( c == '\\' ) || ( c == '/' ) )
needSlash = false;
bool hasSlash = false;
std::string npath = directory;
c = npath[ npath.size() - 1 ];
if( ( c == '\\' ) || ( c == '/' ) )
hasSlash = true;
if( needSlash && !hasSlash )
npath += '/';
else
if( hasSlash && !needSlash )
npath.resize( npath.size() - 1 );
// Now build the new absolute path
npath += relativePath;
npath = standardizePath( npath, false );
return npath;
}
bool CFile::setRWAccess(const std::string &filename)
{
#ifdef NL_OS_WINDOWS

View file

@ -10,15 +10,18 @@ IF(WIN32)
SET(OVQT_PLUGIN_SPECS_DIR "plugins")
SET(OVQT_PLUGIN_DIR "plugins")
SET(OVQT_DATA_DIR ".")
SET(OVQT_IMP_DATA_DIR "${OVQT_DATA_DIR}")
ELSEIF(APPLE)
# TODO: under Mac OS X, don't install but copy files in application package
SET(OVQT_PLUGIN_SPECS_DIR "plugins")
SET(OVQT_PLUGIN_DIR "plugins")
SET(OVQT_DATA_DIR ".")
SET(OVQT_IMP_DATA_DIR "${OVQT_DATA_DIR}")
ELSE(WIN32)
SET(OVQT_PLUGIN_SPECS_DIR ${NL_SHARE_PREFIX}/studio/plugins)
SET(OVQT_PLUGIN_DIR ${NL_LIB_PREFIX}/studio)
SET(OVQT_DATA_DIR ${NL_SHARE_PREFIX}/studio/data)
SET(OVQT_IMP_DATA_DIR "${CMAKE_INSTALL_PREFIX}/${OVQT_DATA_DIR}")
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/ovqt_config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/ovqt_config.h)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})

View file

@ -11,7 +11,7 @@ FILE(GLOB STUDIO_SRC extension_system/*.h
SET(STUDIO_HDR extension_system/iplugin_manager.h
extension_system/plugin_manager.h
settings_dialog.h
startup_settings_dlg.h
splash_screen.h
pm_watcher.h )
@ -22,7 +22,7 @@ SET(STUDIO_TS translations/object_viewer_qt_en.ts
translations/object_viewer_qt_de.ts
translations/object_viewer_qt_ru.ts)
SET(STUDIO_PLUGIN_UIS settings_dialog.ui )
SET(STUDIO_PLUGIN_UIS startup_settings_dlg.ui )
SET(QT_USE_QTGUI TRUE)
SET(QT_USE_QTOPENGL TRUE)

View file

@ -41,7 +41,7 @@
#include <QtGui/QFileDialog>
#include <QtGui/QInputDialog>
#include "settings_dialog.h"
#include "startup_settings_dlg.h"
#include "splash_screen.h"
#include "pm_watcher.h"
@ -160,7 +160,7 @@ int main(int argc, char **argv)
{
settings->setValue( "FirstRun", false );
SettingsDialog sd;
StartupSettingsDlg sd;
sd.setSettings( settings );
sd.load();
sd.exec();

View file

@ -38,6 +38,10 @@ SET(OVQT_CORE_PLUGIN_UIS settings_dialog.ui
SET(OVQT_CORE_PLUGIN_RCS core.qrc)
IF(NOT WIN32)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/core_config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/core_config.h)
ENDIF(NOT WIN32)
SET(QT_USE_QTGUI TRUE)
SET(QT_USE_QTOPENGL TRUE)

View file

@ -0,0 +1,7 @@
#ifndef CORE_CONFIG_H
#define CORE_CONFIG_H
#define STUDIO_DATA_DIR "${OVQT_IMP_DATA_DIR}"
#endif

View file

@ -28,6 +28,10 @@
#include <QtGui/QWidget>
#include <QtGui/QFileDialog>
#if !defined NL_OS_WINDOWS
#include "core_config.h"
#endif
namespace Core
{
@ -118,6 +122,10 @@ void SearchPathsSettingsPage::applySearchPaths()
for (int i = 1; i < remapExt.size(); i += 2)
NLMISC::CPath::remapExtension(remapExt.at(i - 1).toUtf8().constData(), remapExt.at(i).toUtf8().constData(), true);
#if !defined NL_OS_WINDOWS
NLMISC::CPath::addSearchPath(std::string(STUDIO_DATA_DIR), false, false);
#endif
Q_FOREACH(QString path, paths)
{
NLMISC::CPath::addSearchPath(path.toUtf8().constData(), m_recurse, false);
@ -216,4 +224,4 @@ void SearchPathsSettingsPage::checkEnabledButton()
m_ui.downToolButton->setEnabled(bEnabled);
}
} /* namespace Core */
} /* namespace Core */

View file

@ -145,11 +145,17 @@ void SettingsDialog::pageSelected()
void SettingsDialog::accept()
{
m_applied = true;
setCursor( Qt::WaitCursor );
Q_FOREACH(IOptionsPage *page, m_pages)
{
page->apply();
page->finish();
}
setCursor( Qt::ArrowCursor );
done(QDialog::Accepted);
}
@ -162,8 +168,13 @@ void SettingsDialog::reject()
void SettingsDialog::apply()
{
setCursor( Qt::WaitCursor );
Q_FOREACH(IOptionsPage *page, m_pages)
page->apply();
setCursor( Qt::ArrowCursor );
m_applied = true;
}

View file

@ -19,7 +19,7 @@
#ifndef SETTINGS_DIALOG_H
#define SETTINGS_DIALOG_H
#include "../core/ui_settings_dialog.h"
#include "ui_settings_dialog.h"
// Qt includes
#include <QtCore/QList>

View file

@ -4,6 +4,8 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}
${QT_INCLUDES}
${LUA_INCLUDE_DIR})
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/gui_editor_config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/gui_editor_config.h)
FILE(GLOB SRC *.cpp *.h)
SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.h
@ -112,3 +114,11 @@ ELSE(WIN32)
ENDIF(WIN32)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/studio_plugin_gui_editor.xml DESTINATION ${OVQT_PLUGIN_SPECS_DIR} COMPONENT tools3d)
FILE(GLOB widgets "${CMAKE_CURRENT_SOURCE_DIR}/widgets/*.xml")
FILE(GLOB expressions "${CMAKE_CURRENT_SOURCE_DIR}/expressions/*.xml")
INSTALL(FILES ${widgets} DESTINATION "${OVQT_DATA_DIR}/widgets" COMPONENT tools3d)
INSTALL(FILES ${expressions} DESTINATION "${OVQT_DATA_DIR}/expressions" COMPONENT tools3d)
INSTALL(DIRECTORY fonts/ DESTINATION ${OVQT_DATA_DIR} COMPONENT data)

View file

@ -21,6 +21,7 @@
#include "expression_loader.h"
#include <QMap>
#include <QDir>
#include "gui_editor_config.h"
class ExpressionStorePvt
{
@ -50,7 +51,7 @@ ExpressionStore::~ExpressionStore()
bool ExpressionStore::load()
{
QDir d( "expressions" );
QDir d( EXPRESSIONS_DIR );
if( !d.exists() )
return false;

Binary file not shown.

View file

@ -0,0 +1,8 @@
#ifndef GUI_EDITOR_CONFIG_H
#define GUI_EDITOR_CONFIG_H
#define WIDGETS_DIR "${OVQT_IMP_DATA_DIR}/widgets"
#define EXPRESSIONS_DIR "${OVQT_IMP_DATA_DIR}/expressions"
#endif

View file

@ -20,6 +20,7 @@
#include <QStringList>
#include "nel/misc/debug.h"
#include "widget_info_tree.h"
#include "gui_editor_config.h"
using namespace NLMISC;
@ -36,7 +37,7 @@ namespace GUIEditor
void CWidgetPropParser::parseGUIWidgets()
{
QDir d( "widgets" );
QDir d( WIDGETS_DIR );
if( !d.exists() )
{
nlwarning( "GUI widgets directory doesn't exist!" );
@ -55,7 +56,7 @@ namespace GUIEditor
QStringListIterator itr( files );
while( itr.hasNext() )
parseGUIWidget( "widgets/" + itr.next() );
parseGUIWidget( QString( WIDGETS_DIR ) + QString( "/" ) + itr.next() );
buildWidgetInfoTree();

View file

@ -59,6 +59,8 @@ bool loadWorldEditFile(const std::string &fileName, WorldEditList &worldEditList
lastError = "";
std::string p = NLMISC::CFile::getPath( fileName );
// Load the document
NLMISC::CIFile file;
if (file.open(fileName))
@ -122,6 +124,8 @@ bool loadWorldEditFile(const std::string &fileName, WorldEditList &worldEditList
{
std::string dataDir;
NLMISC::CIXml::getPropertyString(dataDir, node, "VALUE");
dataDir = NLMISC::CPath::makePathAbsolute( dataDir, p );
worldEditList.push_back(WorldEditItem(DataDirectoryType, dataDir));
}
@ -149,6 +153,9 @@ bool loadWorldEditFile(const std::string &fileName, WorldEditList &worldEditList
std::string filenameChild;
if ( NLMISC::CIXml::getPropertyString(filenameChild, node, "FILENAME"))
{
filenameChild = NLMISC::CPath::makePathAbsolute( filenameChild, p );
// Is it a landscape ?
if (type == "landscape")
{

View file

@ -17,9 +17,11 @@
// Project includes
#include "world_editor_settings_page.h"
#include "world_editor_constants.h"
#include "../core/icore.h"
// Qt includes
#include <QtGui/QWidget>
#include <QSettings>
// NeL includes
@ -61,11 +63,31 @@ QWidget *WorldEditorSettingsPage::createPage(QWidget *parent)
{
m_currentPage = new QWidget(parent);
m_ui.setupUi(m_currentPage);
readSettings();
return m_currentPage;
}
void WorldEditorSettingsPage::readSettings()
{
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Constants::WORLD_EDITOR_SECTION);
bool b = false;
b = settings->value( Constants::WORLD_EDITOR_USE_OPENGL, true ).toBool();
m_ui.glCB->setChecked( b );
settings->endGroup();
}
void WorldEditorSettingsPage::apply()
{
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Constants::WORLD_EDITOR_SECTION);
bool b = false;
b = m_ui.glCB->isChecked();
settings->setValue( Constants::WORLD_EDITOR_USE_OPENGL, b );
settings->endGroup();
}
} /* namespace WorldEditor */

View file

@ -46,6 +46,7 @@ public:
QIcon categoryIcon() const;
virtual QWidget *createPage(QWidget *parent);
virtual void readSettings();
virtual void apply();
virtual void finish() {}

View file

@ -3,7 +3,7 @@
<class>WorldEditorSettingsPage</class>
<widget class="QWidget" name="WorldEditorSettingsPage">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="geometry">
<rect>
@ -25,6 +25,9 @@
</property>
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="title">
<string>Workspace</string>
</property>
@ -37,10 +40,18 @@
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="spinBox_3"/>
<widget class="QSpinBox" name="spinBox_3">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QSpinBox" name="spinBox_4"/>
<widget class="QSpinBox" name="spinBox_4">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
@ -50,15 +61,32 @@
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="spinBox_5"/>
<widget class="QSpinBox" name="spinBox_5">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QSpinBox" name="spinBox_6"/>
<widget class="QSpinBox" name="spinBox_6">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="0" colspan="3">
<widget class="QCheckBox" name="checkBox">
<widget class="QCheckBox" name="glCB">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Use OpenGL</string>
<string>Use OpenGL ( requires restart )</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
@ -79,7 +107,11 @@
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="spinBox"/>
<widget class="QSpinBox" name="spinBox">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
@ -89,7 +121,11 @@
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="spinBox_2"/>
<widget class="QSpinBox" name="spinBox_2">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
@ -101,10 +137,17 @@
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="lineEdit"/>
<widget class="QLineEdit" name="lineEdit">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>...</string>
</property>

View file

@ -436,6 +436,7 @@ void WorldEditorWindow::writeSettings()
settings->beginGroup(Constants::WORLD_EDITOR_SECTION);
settings->setValue(Constants::WORLD_WINDOW_STATE, saveState());
settings->setValue(Constants::WORLD_WINDOW_GEOMETRY, saveGeometry());
settings->setValue(Constants::WORLD_EDITOR_USE_OPENGL, settings->value(Constants::WORLD_EDITOR_USE_OPENGL));
settings->endGroup();
settings->sync();
}

View file

@ -15,7 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "settings_dialog.h"
#include "startup_settings_dlg.h"
#include <QFileDialog>
#include <QSettings>
#include <QStringList>
@ -32,7 +32,7 @@ int findListItem( QListWidget *l, const QString &s )
return -1;
}
SettingsDialog::SettingsDialog( QDialog *parent ) :
StartupSettingsDlg::StartupSettingsDlg( QDialog *parent ) :
QDialog( parent )
{
setupUi( this );
@ -40,11 +40,11 @@ QDialog( parent )
settings = NULL;
}
SettingsDialog::~SettingsDialog()
StartupSettingsDlg::~StartupSettingsDlg()
{
}
void SettingsDialog::load()
void StartupSettingsDlg::load()
{
pluginsLE->setText( settings->value( "PluginPath" ).toString() );
@ -82,7 +82,7 @@ void SettingsDialog::load()
settings->endGroup();
}
void SettingsDialog::saveSearchPaths()
void StartupSettingsDlg::saveSearchPaths()
{
QStringList l;
for( int i = 0; i < searchLW->count(); i++ )
@ -93,7 +93,7 @@ void SettingsDialog::saveSearchPaths()
settings->setValue( "SearchPaths", l );
}
void SettingsDialog::saveRecursivePaths()
void StartupSettingsDlg::saveRecursivePaths()
{
QStringList l;
for( int i = 0; i < recursiveLW->count(); i++ )
@ -104,7 +104,7 @@ void SettingsDialog::saveRecursivePaths()
settings->setValue( "RecursiveSearchPathes", l );
}
void SettingsDialog::save()
void StartupSettingsDlg::save()
{
settings->setValue( "PluginPath", pluginsLE->text() );
@ -123,59 +123,59 @@ void SettingsDialog::save()
settings->sync();
}
void SettingsDialog::accept()
void StartupSettingsDlg::accept()
{
save();
QDialog::accept();
}
void SettingsDialog::reject()
void StartupSettingsDlg::reject()
{
QDialog::reject();
}
void SettingsDialog::onOKClicked()
void StartupSettingsDlg::onOKClicked()
{
accept();
}
void SettingsDialog::onCancelClicked()
void StartupSettingsDlg::onCancelClicked()
{
reject();
}
void SettingsDialog::onPluginBClicked()
void StartupSettingsDlg::onPluginBClicked()
{
QString p = QFileDialog::getExistingDirectory( this, tr( "Plugins directory" ), "" );
pluginsLE->setText( p );
}
void SettingsDialog::onSheetsBClicked()
void StartupSettingsDlg::onSheetsBClicked()
{
QString p = QFileDialog::getExistingDirectory( this, tr( "Sheets directory" ), "" );
sheetsLE->setText( p );
}
void SettingsDialog::onAssetsBClicked()
void StartupSettingsDlg::onAssetsBClicked()
{
QString p = QFileDialog::getExistingDirectory( this, tr( "Assets directory" ), "" );
assetsLE->setText( p );
}
void SettingsDialog::onPrimitivesBClicked()
void StartupSettingsDlg::onPrimitivesBClicked()
{
QString p = QFileDialog::getExistingDirectory( this, tr( "Primitives directory" ), "" );
primitivesLE->setText( p );
}
void SettingsDialog::onLigoBClicked()
void StartupSettingsDlg::onLigoBClicked()
{
QString p;
p = QFileDialog::getOpenFileName( this, tr( "LIGO config file" ), "" );
ligoLE->setText( p );
}
void SettingsDialog::onPathAddClicked()
void StartupSettingsDlg::onPathAddClicked()
{
QString p = QFileDialog::getExistingDirectory( this, tr( "Search path" ), "" );
if( p.isEmpty() )
@ -187,7 +187,7 @@ void SettingsDialog::onPathAddClicked()
searchLW->addItem( p );
}
void SettingsDialog::onPathRemoveClicked()
void StartupSettingsDlg::onPathRemoveClicked()
{
QListWidgetItem *i = searchLW->currentItem();
if( i == NULL )
@ -196,7 +196,7 @@ void SettingsDialog::onPathRemoveClicked()
delete i;
}
void SettingsDialog::onRecursiveAddClicked()
void StartupSettingsDlg::onRecursiveAddClicked()
{
QString p = QFileDialog::getExistingDirectory( this, tr( "Recursive search path" ), "" );
if( p.isEmpty() )
@ -208,7 +208,7 @@ void SettingsDialog::onRecursiveAddClicked()
recursiveLW->addItem( p );
}
void SettingsDialog::onRecursiveRemoveClicked()
void StartupSettingsDlg::onRecursiveRemoveClicked()
{
QListWidgetItem *i = recursiveLW->currentItem();
if( i == NULL )
@ -218,7 +218,7 @@ void SettingsDialog::onRecursiveRemoveClicked()
}
void SettingsDialog::setupConnections()
void StartupSettingsDlg::setupConnections()
{
connect( bb, SIGNAL( accepted() ), this, SLOT( onOKClicked() ) );
connect( bb, SIGNAL( rejected() ), this, SLOT( onCancelClicked() ) );

View file

@ -14,19 +14,19 @@
// 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
#ifndef STARTUP_SETTINGS_DIALOG_H
#define STARTUP_SETTINGS_DIALOG_H
#include "ui_settings_dialog.h"
#include "ui_startup_settings_dlg.h"
class QSettings;
class SettingsDialog : public QDialog, public Ui::SettingsDialog
class StartupSettingsDlg : public QDialog, public Ui::StartupSettingsDlg
{
Q_OBJECT
public:
SettingsDialog( QDialog *parent = NULL );
~SettingsDialog();
StartupSettingsDlg( QDialog *parent = NULL );
~StartupSettingsDlg();
void setSettings( QSettings *s ){ settings = s; }

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SettingsDialog</class>
<widget class="QDialog" name="SettingsDialog">
<class>StartupSettingsDlg</class>
<widget class="QDialog" name="StartupSettingsDlg">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>