2014-12-21 21:55:27 +00:00
|
|
|
// Ryzom Core - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
|
|
|
// Copyright (C) 2010 Winch Gate Property Limited
|
|
|
|
//
|
|
|
|
// 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/>.
|
|
|
|
|
|
|
|
|
2015-02-09 16:54:27 +00:00
|
|
|
#include "startup_settings_dlg.h"
|
2014-12-21 21:55:27 +00:00
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QSettings>
|
|
|
|
#include <QStringList>
|
|
|
|
|
|
|
|
int findListItem( QListWidget *l, const QString &s )
|
|
|
|
{
|
|
|
|
for( int i = 0; i < l->count(); i++ )
|
|
|
|
{
|
|
|
|
QListWidgetItem *item = l->item( i );
|
|
|
|
if( item->text() == s )
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2015-02-09 16:54:27 +00:00
|
|
|
StartupSettingsDlg::StartupSettingsDlg( QDialog *parent ) :
|
2014-12-21 21:55:27 +00:00
|
|
|
QDialog( parent )
|
|
|
|
{
|
|
|
|
setupUi( this );
|
|
|
|
setupConnections();
|
|
|
|
settings = NULL;
|
|
|
|
}
|
|
|
|
|
2015-02-09 16:54:27 +00:00
|
|
|
StartupSettingsDlg::~StartupSettingsDlg()
|
2014-12-21 21:55:27 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-02-09 16:54:27 +00:00
|
|
|
void StartupSettingsDlg::load()
|
2014-12-21 21:55:27 +00:00
|
|
|
{
|
|
|
|
pluginsLE->setText( settings->value( "PluginPath" ).toString() );
|
|
|
|
|
|
|
|
settings->beginGroup( "DataPath" );
|
|
|
|
|
|
|
|
sheetsLE->setText( settings->value( "LevelDesignPath" ).toString() );
|
|
|
|
assetsLE->setText( settings->value( "AssetsPath" ).toString() );
|
|
|
|
primitivesLE->setText( settings->value( "PrimitivesPath" ).toString() );
|
|
|
|
ligoLE->setText( settings->value( "LigoConfigFile" ).toString() );
|
|
|
|
|
|
|
|
QStringList l = settings->value( "SearchPaths" ).toStringList();
|
|
|
|
{
|
|
|
|
QStringListIterator itr( l );
|
|
|
|
while( itr.hasNext() )
|
|
|
|
{
|
|
|
|
QString p = itr.next();
|
|
|
|
if( findListItem( searchLW, p ) == -1 )
|
|
|
|
searchLW->addItem( p );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
l.clear();
|
|
|
|
|
|
|
|
l = settings->value( "RecursiveSearchPathes" ).toStringList();
|
|
|
|
{
|
|
|
|
QStringListIterator itr( l );
|
|
|
|
while( itr.hasNext() )
|
|
|
|
{
|
|
|
|
QString p = itr.next();
|
|
|
|
if( findListItem( recursiveLW, p ) == -1 )
|
|
|
|
recursiveLW->addItem( p );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
settings->endGroup();
|
|
|
|
}
|
|
|
|
|
2015-02-09 16:54:27 +00:00
|
|
|
void StartupSettingsDlg::saveSearchPaths()
|
2014-12-21 21:55:27 +00:00
|
|
|
{
|
|
|
|
QStringList l;
|
|
|
|
for( int i = 0; i < searchLW->count(); i++ )
|
|
|
|
{
|
|
|
|
l.push_back( searchLW->item( i )->text() );
|
|
|
|
}
|
|
|
|
|
|
|
|
settings->setValue( "SearchPaths", l );
|
|
|
|
}
|
|
|
|
|
2015-02-09 16:54:27 +00:00
|
|
|
void StartupSettingsDlg::saveRecursivePaths()
|
2014-12-21 21:55:27 +00:00
|
|
|
{
|
|
|
|
QStringList l;
|
|
|
|
for( int i = 0; i < recursiveLW->count(); i++ )
|
|
|
|
{
|
|
|
|
l.push_back( recursiveLW->item( i )->text() );
|
|
|
|
}
|
|
|
|
|
|
|
|
settings->setValue( "RecursiveSearchPathes", l );
|
|
|
|
}
|
|
|
|
|
2015-02-09 16:54:27 +00:00
|
|
|
void StartupSettingsDlg::save()
|
2014-12-21 21:55:27 +00:00
|
|
|
{
|
|
|
|
settings->setValue( "PluginPath", pluginsLE->text() );
|
|
|
|
|
|
|
|
settings->beginGroup( "DataPath" );
|
|
|
|
|
|
|
|
settings->setValue( "LevelDesignPath", sheetsLE->text() );
|
|
|
|
settings->setValue( "AssetsPath", assetsLE->text() );
|
|
|
|
settings->setValue( "PrimitivesPath", primitivesLE->text() );
|
|
|
|
settings->setValue( "LigoConfigFile", ligoLE->text() );
|
|
|
|
|
|
|
|
saveSearchPaths();
|
|
|
|
saveRecursivePaths();
|
|
|
|
|
|
|
|
settings->endGroup();
|
|
|
|
|
|
|
|
settings->sync();
|
|
|
|
}
|
|
|
|
|
2015-02-09 16:54:27 +00:00
|
|
|
void StartupSettingsDlg::accept()
|
2014-12-21 21:55:27 +00:00
|
|
|
{
|
|
|
|
save();
|
|
|
|
QDialog::accept();
|
|
|
|
}
|
|
|
|
|
2015-02-09 16:54:27 +00:00
|
|
|
void StartupSettingsDlg::reject()
|
2014-12-21 21:55:27 +00:00
|
|
|
{
|
|
|
|
QDialog::reject();
|
|
|
|
}
|
|
|
|
|
2015-02-09 16:54:27 +00:00
|
|
|
void StartupSettingsDlg::onOKClicked()
|
2014-12-21 21:55:27 +00:00
|
|
|
{
|
|
|
|
accept();
|
|
|
|
}
|
|
|
|
|
2015-02-09 16:54:27 +00:00
|
|
|
void StartupSettingsDlg::onCancelClicked()
|
2014-12-21 21:55:27 +00:00
|
|
|
{
|
|
|
|
reject();
|
|
|
|
}
|
|
|
|
|
2015-02-09 16:54:27 +00:00
|
|
|
void StartupSettingsDlg::onPluginBClicked()
|
2014-12-21 21:55:27 +00:00
|
|
|
{
|
|
|
|
QString p = QFileDialog::getExistingDirectory( this, tr( "Plugins directory" ), "" );
|
|
|
|
pluginsLE->setText( p );
|
|
|
|
}
|
|
|
|
|
2015-02-09 16:54:27 +00:00
|
|
|
void StartupSettingsDlg::onSheetsBClicked()
|
2014-12-21 21:55:27 +00:00
|
|
|
{
|
|
|
|
QString p = QFileDialog::getExistingDirectory( this, tr( "Sheets directory" ), "" );
|
|
|
|
sheetsLE->setText( p );
|
|
|
|
}
|
|
|
|
|
2015-02-09 16:54:27 +00:00
|
|
|
void StartupSettingsDlg::onAssetsBClicked()
|
2014-12-21 21:55:27 +00:00
|
|
|
{
|
|
|
|
QString p = QFileDialog::getExistingDirectory( this, tr( "Assets directory" ), "" );
|
|
|
|
assetsLE->setText( p );
|
|
|
|
}
|
|
|
|
|
2015-02-09 16:54:27 +00:00
|
|
|
void StartupSettingsDlg::onPrimitivesBClicked()
|
2014-12-21 21:55:27 +00:00
|
|
|
{
|
|
|
|
QString p = QFileDialog::getExistingDirectory( this, tr( "Primitives directory" ), "" );
|
|
|
|
primitivesLE->setText( p );
|
|
|
|
}
|
|
|
|
|
2015-02-09 16:54:27 +00:00
|
|
|
void StartupSettingsDlg::onLigoBClicked()
|
2014-12-21 21:55:27 +00:00
|
|
|
{
|
2015-02-05 22:50:38 +00:00
|
|
|
QString p;
|
|
|
|
p = QFileDialog::getOpenFileName( this, tr( "LIGO config file" ), "" );
|
2014-12-21 21:55:27 +00:00
|
|
|
ligoLE->setText( p );
|
|
|
|
}
|
|
|
|
|
2015-02-09 16:54:27 +00:00
|
|
|
void StartupSettingsDlg::onPathAddClicked()
|
2014-12-21 21:55:27 +00:00
|
|
|
{
|
|
|
|
QString p = QFileDialog::getExistingDirectory( this, tr( "Search path" ), "" );
|
|
|
|
if( p.isEmpty() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( findListItem( searchLW, p ) != -1 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
searchLW->addItem( p );
|
|
|
|
}
|
|
|
|
|
2015-02-09 16:54:27 +00:00
|
|
|
void StartupSettingsDlg::onPathRemoveClicked()
|
2014-12-21 21:55:27 +00:00
|
|
|
{
|
|
|
|
QListWidgetItem *i = searchLW->currentItem();
|
|
|
|
if( i == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
delete i;
|
|
|
|
}
|
|
|
|
|
2015-02-09 16:54:27 +00:00
|
|
|
void StartupSettingsDlg::onRecursiveAddClicked()
|
2014-12-21 21:55:27 +00:00
|
|
|
{
|
|
|
|
QString p = QFileDialog::getExistingDirectory( this, tr( "Recursive search path" ), "" );
|
|
|
|
if( p.isEmpty() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( findListItem( recursiveLW, p ) != -1 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
recursiveLW->addItem( p );
|
|
|
|
}
|
|
|
|
|
2015-02-09 16:54:27 +00:00
|
|
|
void StartupSettingsDlg::onRecursiveRemoveClicked()
|
2014-12-21 21:55:27 +00:00
|
|
|
{
|
|
|
|
QListWidgetItem *i = recursiveLW->currentItem();
|
|
|
|
if( i == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
delete i;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-09 16:54:27 +00:00
|
|
|
void StartupSettingsDlg::setupConnections()
|
2014-12-21 21:55:27 +00:00
|
|
|
{
|
|
|
|
connect( bb, SIGNAL( accepted() ), this, SLOT( onOKClicked() ) );
|
|
|
|
connect( bb, SIGNAL( rejected() ), this, SLOT( onCancelClicked() ) );
|
|
|
|
|
|
|
|
connect( pluginsB, SIGNAL( clicked( bool ) ), this, SLOT( onPluginBClicked() ) );
|
|
|
|
connect( sheetsB, SIGNAL( clicked( bool ) ), this, SLOT( onSheetsBClicked() ) );
|
|
|
|
connect( assetsB, SIGNAL( clicked( bool ) ), this, SLOT( onAssetsBClicked() ) );
|
|
|
|
connect( primitivesB, SIGNAL( clicked( bool ) ), this, SLOT( onPrimitivesBClicked() ) );
|
|
|
|
connect( ligoB, SIGNAL( clicked( bool ) ), this, SLOT( onLigoBClicked() ) );
|
|
|
|
|
|
|
|
connect( pathAddB, SIGNAL( clicked( bool ) ), this, SLOT( onPathAddClicked() ) );
|
|
|
|
connect( pathRemoveB, SIGNAL( clicked( bool ) ), this, SLOT( onPathRemoveClicked() ) );
|
|
|
|
connect( recAddB, SIGNAL( clicked( bool ) ), this, SLOT( onRecursiveAddClicked() ) );
|
|
|
|
connect( recRemoveB, SIGNAL( clicked( bool ) ), this, SLOT( onRecursiveRemoveClicked() ) );
|
|
|
|
}
|
|
|
|
|