Settings dialog on first startup.

This commit is contained in:
dfighter1985 2014-05-26 21:04:05 +02:00
parent 172d0d0e01
commit 8532727052
5 changed files with 576 additions and 4 deletions

View file

@ -10,7 +10,8 @@ FILE(GLOB STUDIO_SRC extension_system/*.h
*.h *.cpp) *.h *.cpp)
SET(STUDIO_HDR extension_system/iplugin_manager.h SET(STUDIO_HDR extension_system/iplugin_manager.h
extension_system/plugin_manager.h) extension_system/plugin_manager.h
settings_dialog.h )
SET(STUDIO_RCS studio.qrc ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc) SET(STUDIO_RCS studio.qrc ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc)
@ -19,6 +20,8 @@ SET(STUDIO_TS translations/object_viewer_qt_en.ts
translations/object_viewer_qt_de.ts translations/object_viewer_qt_de.ts
translations/object_viewer_qt_ru.ts) translations/object_viewer_qt_ru.ts)
SET(STUDIO_PLUGIN_UIS settings_dialog.ui )
SET(QT_USE_QTGUI TRUE) SET(QT_USE_QTGUI TRUE)
SET(QT_USE_QTOPENGL TRUE) SET(QT_USE_QTOPENGL TRUE)
@ -29,15 +32,17 @@ ENDIF(WIN32)
QT4_ADD_TRANSLATION(STUDIO_QM ${STUDIO_TS}) QT4_ADD_TRANSLATION(STUDIO_QM ${STUDIO_TS})
QT4_ADD_RESOURCES( STUDIO_RC_SRCS ${STUDIO_RCS}) QT4_ADD_RESOURCES( STUDIO_RC_SRCS ${STUDIO_RCS})
QT4_WRAP_CPP( STUDIO_MOC_SRCS ${STUDIO_HDR} ) QT4_WRAP_CPP( STUDIO_MOC_SRCS ${STUDIO_HDR} )
QT4_WRAP_UI( STUDIO_PLUGIN_UI_HDRS ${STUDIO_PLUGIN_UIS})
SOURCE_GROUP(QtResources FILES ${STUDIO_RCS}) SOURCE_GROUP(QtResources FILES ${STUDIO_RCS} ${STUDIO_PLUGIN_UIS} )
SOURCE_GROUP(QtGeneratedMocQrcSrc FILES ${STUDIO_MOC_SRCS} ${STUDIO_RC_SRCS}) SOURCE_GROUP(QtGeneratedMocQrcSrc FILES ${STUDIO_MOC_SRCS} ${STUDIO_RC_SRCS})
ADD_EXECUTABLE(studio WIN32 MACOSX_BUNDLE ADD_EXECUTABLE(studio WIN32 MACOSX_BUNDLE
${STUDIO_SRC} ${STUDIO_SRC}
${STUDIO_MOC_SRCS} ${STUDIO_MOC_SRCS}
${STUDIO_RC_SRCS} ${STUDIO_RC_SRCS}
${STUDIO_RC}) ${STUDIO_RC}
${STUDIO_PLUGIN_UIS} )
TARGET_LINK_LIBRARIES(studio TARGET_LINK_LIBRARIES(studio
nelmisc nelmisc

View file

@ -41,11 +41,13 @@
#include <QtGui/QFileDialog> #include <QtGui/QFileDialog>
#include <QtGui/QInputDialog> #include <QtGui/QInputDialog>
#include "settings_dialog.h"
#ifdef HAVE_OVQT_CONFIG_H #ifdef HAVE_OVQT_CONFIG_H
#include "ovqt_config.h" #include "ovqt_config.h"
#endif #endif
static const char *appNameC = "ObjectViewerQt"; static const char *appNameC = "RyzomCoreStudio";
// nel_qt log file name // nel_qt log file name
#define NLQT_LOG_FILE "nel_qt.log" #define NLQT_LOG_FILE "nel_qt.log"
@ -138,6 +140,7 @@ int main(int argc, char **argv)
#else // NL_OS_WINDOWS #else // NL_OS_WINDOWS
QApplication app(argc, argv); QApplication app(argc, argv);
#endif // NL_OS_WINDOWS #endif // NL_OS_WINDOWS
QSplashScreen *splash = new QSplashScreen(); QSplashScreen *splash = new QSplashScreen();
splash->setPixmap(QPixmap(":/images/studio_splash.png")); splash->setPixmap(QPixmap(":/images/studio_splash.png"));
splash->show(); splash->show();
@ -146,6 +149,17 @@ int main(int argc, char **argv)
QSettings *settings = new QSettings(QSettings::IniFormat, QSettings::UserScope, QSettings *settings = new QSettings(QSettings::IniFormat, QSettings::UserScope,
QLatin1String("RyzomCore"), QLatin1String(appNameC)); QLatin1String("RyzomCore"), QLatin1String(appNameC));
bool firstRun = settings->value( "FirstRun", true ).toBool();
if( firstRun )
{
settings->setValue( "FirstRun", false );
SettingsDialog sd;
sd.setSettings( settings );
sd.load();
sd.exec();
}
QTranslator translator; QTranslator translator;
QTranslator qtTranslator; QTranslator qtTranslator;
QString locale = settings->value("Language", QLocale::system().name()).toString(); QString locale = settings->value("Language", QLocale::system().name()).toString();

View file

@ -0,0 +1,236 @@
// Object Viewer Qt - 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/>.
#include "settings_dialog.h"
#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;
}
SettingsDialog::SettingsDialog( QDialog *parent ) :
QDialog( parent )
{
setupUi( this );
setupConnections();
settings = NULL;
}
SettingsDialog::~SettingsDialog()
{
}
void SettingsDialog::load()
{
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();
}
void SettingsDialog::saveSearchPaths()
{
QStringList l;
for( int i = 0; i < searchLW->count(); i++ )
{
l.push_back( searchLW->item( i )->text() );
}
settings->setValue( "SearchPaths", l );
}
void SettingsDialog::saveRecursivePaths()
{
QStringList l;
for( int i = 0; i < recursiveLW->count(); i++ )
{
l.push_back( recursiveLW->item( i )->text() );
}
settings->setValue( "RecursiveSearchPathes", l );
}
void SettingsDialog::save()
{
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();
}
void SettingsDialog::accept()
{
save();
QDialog::accept();
}
void SettingsDialog::reject()
{
QDialog::reject();
}
void SettingsDialog::onOKClicked()
{
accept();
}
void SettingsDialog::onCancelClicked()
{
reject();
}
void SettingsDialog::onPluginBClicked()
{
QString p = QFileDialog::getExistingDirectory( this, tr( "Plugins directory" ), "" );
pluginsLE->setText( p );
}
void SettingsDialog::onSheetsBClicked()
{
QString p = QFileDialog::getExistingDirectory( this, tr( "Sheets directory" ), "" );
sheetsLE->setText( p );
}
void SettingsDialog::onAssetsBClicked()
{
QString p = QFileDialog::getExistingDirectory( this, tr( "Assets directory" ), "" );
assetsLE->setText( p );
}
void SettingsDialog::onPrimitivesBClicked()
{
QString p = QFileDialog::getExistingDirectory( this, tr( "Primitives directory" ), "" );
primitivesLE->setText( p );
}
void SettingsDialog::onLigoBClicked()
{
QString p = QFileDialog::getExistingDirectory( this, tr( "LIGO directory" ), "" );
ligoLE->setText( p );
}
void SettingsDialog::onPathAddClicked()
{
QString p = QFileDialog::getExistingDirectory( this, tr( "Search path" ), "" );
if( p.isEmpty() )
return;
if( findListItem( searchLW, p ) != -1 )
return;
searchLW->addItem( p );
}
void SettingsDialog::onPathRemoveClicked()
{
QListWidgetItem *i = searchLW->currentItem();
if( i == NULL )
return;
delete i;
}
void SettingsDialog::onRecursiveAddClicked()
{
QString p = QFileDialog::getExistingDirectory( this, tr( "Recursive search path" ), "" );
if( p.isEmpty() )
return;
if( findListItem( recursiveLW, p ) != -1 )
return;
recursiveLW->addItem( p );
}
void SettingsDialog::onRecursiveRemoveClicked()
{
QListWidgetItem *i = recursiveLW->currentItem();
if( i == NULL )
return;
delete i;
}
void SettingsDialog::setupConnections()
{
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() ) );
}

View file

@ -0,0 +1,62 @@
// Object Viewer Qt - 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/>.
#ifndef SETTINGS_DIALOG_H
#define SETTINGS_DIALOG_H
#include "ui_settings_dialog.h"
class QSettings;
class SettingsDialog : public QDialog, public Ui::SettingsDialog
{
Q_OBJECT
public:
SettingsDialog( QDialog *parent = NULL );
~SettingsDialog();
void setSettings( QSettings *s ){ settings = s; }
void load();
public Q_SLOTS:
void accept();
void reject();
void onOKClicked();
void onCancelClicked();
void onPluginBClicked();
void onSheetsBClicked();
void onAssetsBClicked();
void onPrimitivesBClicked();
void onLigoBClicked();
void onPathAddClicked();
void onPathRemoveClicked();
void onRecursiveAddClicked();
void onRecursiveRemoveClicked();
private:
void setupConnections();
void save();
void saveSearchPaths();
void saveRecursivePaths();
QSettings *settings;
};
#endif

View file

@ -0,0 +1,255 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SettingsDialog</class>
<widget class="QDialog" name="SettingsDialog">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>451</width>
<height>539</height>
</rect>
</property>
<property name="windowTitle">
<string>Ryzom Core Studio settings</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Paths</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Plugins</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="pluginsLE"/>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="pluginsB">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Sheets</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="sheetsLE"/>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="sheetsB">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Assets database</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="assetsLE"/>
</item>
<item row="2" column="2">
<widget class="QToolButton" name="assetsB">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Primitives</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="primitivesLE"/>
</item>
<item row="3" column="2">
<widget class="QToolButton" name="primitivesB">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>LIGO config file</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="ligoLE"/>
</item>
<item row="4" column="2">
<widget class="QToolButton" name="ligoB">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Search paths</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0" rowspan="3">
<widget class="QListWidget" name="searchLW"/>
</item>
<item row="0" column="1">
<widget class="QToolButton" name="pathAddB">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Add</string>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextOnly</enum>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QToolButton" name="pathRemoveB">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Remove</string>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextOnly</enum>
</property>
</widget>
</item>
<item row="2" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>75</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Recursive search paths</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0" rowspan="3">
<widget class="QListWidget" name="recursiveLW"/>
</item>
<item row="0" column="1">
<widget class="QToolButton" name="recAddB">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Add</string>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextOnly</enum>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QToolButton" name="recRemoveB">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Remove</string>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextOnly</enum>
</property>
</widget>
</item>
<item row="2" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>76</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>120</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="1">
<widget class="QDialogButtonBox" name="bb">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>