commit
e0df09fbeb
@ -0,0 +1,187 @@
|
||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||
//
|
||||
// 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/>.
|
||||
|
||||
// Project includes
|
||||
#include "general_settings_page.h"
|
||||
#include "core_constants.h"
|
||||
#include "icore.h"
|
||||
|
||||
// NeL includes
|
||||
#include <nel/misc/path.h>
|
||||
|
||||
// Qt includes
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QMessageBox>
|
||||
#include <QtGui/QFileDialog>
|
||||
#include <QtGui/QStyleFactory>
|
||||
#include <QtGui/QStyle>
|
||||
|
||||
namespace Core
|
||||
{
|
||||
|
||||
GeneralSettingsPage::GeneralSettingsPage(QObject *parent)
|
||||
: IOptionsPage(parent),
|
||||
m_page(0)
|
||||
{
|
||||
m_originalPalette = QApplication::palette();
|
||||
}
|
||||
|
||||
GeneralSettingsPage::~GeneralSettingsPage()
|
||||
{
|
||||
}
|
||||
|
||||
QString GeneralSettingsPage::id() const
|
||||
{
|
||||
return QLatin1String("general_settings");
|
||||
}
|
||||
|
||||
QString GeneralSettingsPage::trName() const
|
||||
{
|
||||
return tr("General");
|
||||
}
|
||||
|
||||
QString GeneralSettingsPage::category() const
|
||||
{
|
||||
return QLatin1String(Constants::SETTINGS_CATEGORY_GENERAL);
|
||||
}
|
||||
|
||||
QString GeneralSettingsPage::trCategory() const
|
||||
{
|
||||
return tr(Constants::SETTINGS_TR_CATEGORY_GENERAL);
|
||||
}
|
||||
|
||||
void GeneralSettingsPage::applyGeneralSettings()
|
||||
{
|
||||
QSettings *settings = Core::ICore::instance()->settings();
|
||||
|
||||
settings->beginGroup(Constants::MAIN_WINDOW_SECTION);
|
||||
QApplication::setStyle(QStyleFactory::create(settings->value(Constants::QT_STYLE, "").toString()));
|
||||
|
||||
if (settings->value(Constants::QT_PALETTE, true).toBool())
|
||||
QApplication::setPalette(QApplication::style()->standardPalette());
|
||||
else
|
||||
QApplication::setPalette(m_originalPalette);
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
QWidget *GeneralSettingsPage::createPage(QWidget *parent)
|
||||
{
|
||||
m_page = new QWidget(parent);
|
||||
m_ui.setupUi(m_page);
|
||||
|
||||
readSettings();
|
||||
connect(m_ui.languageComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeLanguage(QString)));
|
||||
connect(m_ui.pluginsPathButton, SIGNAL(clicked()), this, SLOT(setPluginsPath()));
|
||||
connect(m_ui.leveldesignPathButton, SIGNAL(clicked()), this, SLOT(setLevelDesignPath()));
|
||||
connect(m_ui.assetsPathButton, SIGNAL(clicked()), this, SLOT(setAssetsPath()));
|
||||
return m_page;
|
||||
}
|
||||
|
||||
void GeneralSettingsPage::apply()
|
||||
{
|
||||
writeSettings();
|
||||
applyGeneralSettings();
|
||||
}
|
||||
|
||||
void GeneralSettingsPage::finish()
|
||||
{
|
||||
delete m_page;
|
||||
m_page = 0;
|
||||
}
|
||||
|
||||
void GeneralSettingsPage::changeLanguage(const QString &lang)
|
||||
{
|
||||
QMessageBox::information(0, tr("Restart required"),
|
||||
tr("The language change will take effect after a restart of Object Viewer Qt."));
|
||||
}
|
||||
|
||||
void GeneralSettingsPage::setPluginsPath()
|
||||
{
|
||||
QString newPath = QFileDialog::getExistingDirectory(0, tr("Set the plugins path"),
|
||||
m_ui.pluginsPathLineEdit->text());
|
||||
if (!newPath.isEmpty())
|
||||
{
|
||||
m_ui.pluginsPathLineEdit->setText(newPath);
|
||||
}
|
||||
}
|
||||
|
||||
void GeneralSettingsPage::setLevelDesignPath()
|
||||
{
|
||||
QString newPath = QFileDialog::getExistingDirectory(0, tr("Set the level design path"),
|
||||
m_ui.leveldesignPathLineEdit->text());
|
||||
if (!newPath.isEmpty())
|
||||
{
|
||||
m_ui.leveldesignPathLineEdit->setText(newPath);
|
||||
}
|
||||
}
|
||||
|
||||
void GeneralSettingsPage::setAssetsPath()
|
||||
{
|
||||
QString newPath = QFileDialog::getExistingDirectory(0, tr("Set the assets path"),
|
||||
m_ui.assetsPathLineEdit->text());
|
||||
if (!newPath.isEmpty())
|
||||
{
|
||||
m_ui.assetsPathLineEdit->setText(newPath);
|
||||
}
|
||||
}
|
||||
|
||||
void GeneralSettingsPage::readSettings()
|
||||
{
|
||||
QSettings *settings = Core::ICore::instance()->settings();
|
||||
|
||||
m_ui.pluginsPathLineEdit->setText(settings->value(Core::Constants::PLUGINS_PATH, "./plugins").toString());
|
||||
|
||||
settings->beginGroup(Constants::MAIN_WINDOW_SECTION);
|
||||
m_ui.styleComboBox->addItems(QStyleFactory::keys());
|
||||
QString style = settings->value(Constants::QT_STYLE, "").toString();
|
||||
if (style == "")
|
||||
m_ui.styleComboBox->setCurrentIndex(0);
|
||||
else
|
||||
m_ui.styleComboBox->setCurrentIndex(m_ui.styleComboBox->findText(style));
|
||||
m_ui.paletteCheckBox->setChecked(settings->value(Constants::QT_PALETTE, true).toBool());
|
||||
settings->endGroup();
|
||||
|
||||
QStringList paths;
|
||||
settings->beginGroup(Core::Constants::DATA_PATH_SECTION);
|
||||
m_ui.leveldesignPathLineEdit->setText(settings->value(Core::Constants::LEVELDESIGN_PATH, "l:/leveldesign").toString());
|
||||
m_ui.assetsPathLineEdit->setText(settings->value(Core::Constants::ASSETS_PATH, "w:/database").toString());
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
void GeneralSettingsPage::writeSettings()
|
||||
{
|
||||
QSettings *settings = Core::ICore::instance()->settings();
|
||||
|
||||
settings->setValue(Core::Constants::PLUGINS_PATH, m_ui.pluginsPathLineEdit->text());
|
||||
|
||||
settings->beginGroup(Constants::MAIN_WINDOW_SECTION);
|
||||
if (m_ui.styleComboBox->currentIndex() == 0)
|
||||
settings->setValue(Constants::QT_STYLE, "");
|
||||
else
|
||||
settings->setValue(Constants::QT_STYLE, m_ui.styleComboBox->currentText());
|
||||
settings->setValue(Constants::QT_PALETTE, m_ui.paletteCheckBox->isChecked());
|
||||
settings->endGroup();
|
||||
|
||||
settings->beginGroup(Core::Constants::DATA_PATH_SECTION);
|
||||
settings->setValue(Core::Constants::LEVELDESIGN_PATH, m_ui.leveldesignPathLineEdit->text());
|
||||
settings->setValue(Core::Constants::ASSETS_PATH, m_ui.assetsPathLineEdit->text());
|
||||
settings->endGroup();
|
||||
settings->sync();
|
||||
}
|
||||
|
||||
} /* namespace Core */
|
@ -0,0 +1,71 @@
|
||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||
//
|
||||
// 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/>.
|
||||
|
||||
|
||||
#ifndef GENERAL_SETTINGS_PAGE_H
|
||||
#define GENERAL_SETTINGS_PAGE_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
#include "ioptions_page.h"
|
||||
|
||||
#include "ui_general_settings_page.h"
|
||||
|
||||
class QWidget;
|
||||
|
||||
namespace Core
|
||||
{
|
||||
/**
|
||||
@class GeneralSettingsPage
|
||||
*/
|
||||
class GeneralSettingsPage : public Core::IOptionsPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GeneralSettingsPage(QObject *parent = 0);
|
||||
~GeneralSettingsPage();
|
||||
|
||||
QString id() const;
|
||||
QString trName() const;
|
||||
QString category() const;
|
||||
QString trCategory() const;
|
||||
QWidget *createPage(QWidget *parent);
|
||||
|
||||
void apply();
|
||||
void finish();
|
||||
|
||||
void applyGeneralSettings();
|
||||
|
||||
private Q_SLOTS:
|
||||
void changeLanguage(const QString &lang);
|
||||
void setPluginsPath();
|
||||
void setLevelDesignPath();
|
||||
void setAssetsPath();
|
||||
|
||||
private:
|
||||
void readSettings();
|
||||
void writeSettings();
|
||||
|
||||
QPalette m_originalPalette;
|
||||
QWidget *m_page;
|
||||
Ui::GeneralSettingsPage m_ui;
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
|
||||
#endif // GENERAL_SETTINGS_H
|
@ -0,0 +1,199 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>GeneralSettingsPage</class>
|
||||
<widget class="QWidget" name="GeneralSettingsPage">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>267</width>
|
||||
<height>282</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="margin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="qtStyleGroupBox">
|
||||
<property name="title">
|
||||
<string>Qt Style</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QComboBox" name="styleComboBox">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>default</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="paletteCheckBox">
|
||||
<property name="text">
|
||||
<string>Use style's standard palette</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="languageGroupBox">
|
||||
<property name="title">
|
||||
<string>Language</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="margin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QComboBox" name="languageComboBox">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>English</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>German</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>French</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Russian</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QGroupBox" name="pathsGroupBox">
|
||||
<property name="title">
|
||||
<string>Paths</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="margin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="pluginsPathLabel">
|
||||
<property name="text">
|
||||
<string>Plugins path:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="pluginsPathLineEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QToolButton" name="pluginsPathButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="leveldesignPathLabel">
|
||||
<property name="text">
|
||||
<string>Level design path:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="leveldesignPathLineEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QToolButton" name="leveldesignPathButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="assetsPathLabel">
|
||||
<property name="text">
|
||||
<string>Assets path:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="assetsPathLineEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QToolButton" name="assetsPathButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="core.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Reference in New Issue