2013-06-08 12:56:58 +00:00
|
|
|
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
|
|
|
// 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/>.
|
|
|
|
|
2013-09-29 11:44:04 +00:00
|
|
|
#include "stdpch.h"
|
2013-06-08 12:56:58 +00:00
|
|
|
#include "general_settings_widget.h"
|
2013-09-29 11:51:08 +00:00
|
|
|
|
2013-06-08 12:56:58 +00:00
|
|
|
#include "system.h"
|
|
|
|
#include <QTranslator>
|
|
|
|
|
2015-12-06 18:42:18 +00:00
|
|
|
#include <nel/misc/i18n.h>
|
2013-06-08 12:56:58 +00:00
|
|
|
|
|
|
|
CGeneralSettingsWidget::CGeneralSettingsWidget( QWidget *parent ) :
|
|
|
|
CWidgetBase( parent )
|
|
|
|
{
|
|
|
|
setupUi( this );
|
|
|
|
load();
|
|
|
|
|
2015-12-06 18:42:18 +00:00
|
|
|
connect( languageComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onSomethingChanged() ) );
|
2013-06-08 12:56:58 +00:00
|
|
|
connect( saveConfigOnQuitCheckBox, SIGNAL( stateChanged( int ) ), this, SLOT( onSomethingChanged() ) );
|
|
|
|
connect( lowPriorityProcessCheckBox, SIGNAL( stateChanged( int ) ), this, SLOT( onSomethingChanged() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
CGeneralSettingsWidget::~CGeneralSettingsWidget()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGeneralSettingsWidget::load()
|
|
|
|
{
|
|
|
|
CSystem &s = CSystem::GetInstance();
|
|
|
|
|
2015-12-06 18:42:18 +00:00
|
|
|
std::vector<std::string> codes = NLMISC::CI18N::getLanguageCodes();
|
|
|
|
std::vector<ucstring> names = NLMISC::CI18N::getLanguageNames();
|
|
|
|
|
|
|
|
languageComboBox->clear();
|
|
|
|
|
|
|
|
for(uint i = 0; i < codes.size(); ++i)
|
|
|
|
{
|
|
|
|
languageComboBox->addItem(QString::fromUtf16(names[i].c_str()), QString::fromUtf8(codes[i].c_str()));
|
|
|
|
}
|
|
|
|
|
2013-09-29 11:49:07 +00:00
|
|
|
sint32 cbIndex = getIndexForLanguageCode( QString::fromUtf8( s.config.getString( "LanguageCode" ).c_str() ) );
|
2015-12-06 18:42:18 +00:00
|
|
|
|
|
|
|
if (cbIndex != -1)
|
|
|
|
{
|
2013-06-08 12:56:58 +00:00
|
|
|
languageComboBox->setCurrentIndex( cbIndex );
|
|
|
|
}
|
|
|
|
|
2015-12-06 18:42:18 +00:00
|
|
|
if (s.config.getInt("SaveConfig"))
|
2013-06-08 12:56:58 +00:00
|
|
|
saveConfigOnQuitCheckBox->setChecked( true );
|
|
|
|
|
2015-12-06 18:42:18 +00:00
|
|
|
if (s.config.getInt("ProcessPriority") == -1)
|
|
|
|
lowPriorityProcessCheckBox->setChecked(true);
|
2013-06-08 12:56:58 +00:00
|
|
|
else
|
2015-12-06 18:42:18 +00:00
|
|
|
lowPriorityProcessCheckBox->setChecked(false);
|
2013-06-08 12:56:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CGeneralSettingsWidget::save()
|
|
|
|
{
|
|
|
|
CSystem &s = CSystem::GetInstance();
|
|
|
|
|
2015-12-06 18:42:18 +00:00
|
|
|
s.config.setString( "LanguageCode", std::string(languageComboBox->itemData(languageComboBox->currentIndex()).toString().toUtf8()));
|
2013-06-08 12:56:58 +00:00
|
|
|
|
|
|
|
if( saveConfigOnQuitCheckBox->isChecked() )
|
|
|
|
s.config.setInt( "SaveConfig", 1 );
|
|
|
|
else
|
|
|
|
s.config.setInt( "SaveConfig", 0 );
|
|
|
|
|
|
|
|
if( lowPriorityProcessCheckBox->isChecked() )
|
|
|
|
s.config.setInt( "ProcessPriority", -1 );
|
|
|
|
else
|
|
|
|
s.config.setInt( "ProcessPriority", 0 );
|
|
|
|
}
|
|
|
|
|
2013-09-29 11:49:07 +00:00
|
|
|
int CGeneralSettingsWidget::getIndexForLanguageCode(const QString &languageCode)
|
2013-06-08 12:56:58 +00:00
|
|
|
{
|
2015-12-06 18:42:18 +00:00
|
|
|
for( sint32 i = 0; i < languageComboBox->count(); i++ )
|
|
|
|
if( languageCode.compare(languageComboBox->itemData(i).toString()) == 0 )
|
2013-06-08 12:56:58 +00:00
|
|
|
return i;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|