Commit a238e980 authored by Frédéric Larue's avatar Frédéric Larue

Application settings moved from GUI_main project to the new UISettings project.

parent 96168f79
......@@ -109,6 +109,7 @@ include_directories(
${UI_COMMONGUI_SOURCE_DIR}/NodeEditor
${UI_COMMONGUI_SOURCE_DIR}/UIData
${UI_COMMONGUI_SOURCE_DIR}/UIParam
${UI_COMMONGUI_SOURCE_DIR}/UISettings
${UI_COMMONGUI_SOURCE_DIR}/Widgets
${Qt5Widgets_INCLUDE_DIRS}
${GLEW_DIR}/include
......@@ -129,6 +130,7 @@ set( UI_CORE_COMPONENTS
NodeEditor
UIData
UIParam
UISettings
Widgets
)
......
......@@ -29,6 +29,7 @@ target_link_libraries( ${CURRENT_TARGET}
NodeEditor
UIData
UIParam
UISettings
Widgets
glew32 opengl32
)
......@@ -41,6 +42,7 @@ target_link_libraries( ${CURRENT_TARGET}
NodeEditor
UIData
UIParam
UISettings
Widgets
${GLEW_LIBRARIES}
GL
......
......@@ -6,7 +6,7 @@
*/
#include "UIMainWindow.h"
#include "UISettings.h"
#include "ColorMapSelectionDialog.h"
......@@ -23,7 +23,7 @@ ColorMapSelectionDialog::ColorMapSelectionDialog( QWidget *parent, const QString
// If no color map can be found in the application settings, create a default list.
QSettings *settings = UIMainWindow::getUserSettings();
QSettings *settings = UI::GetUserSettings();
if( !settings->contains("ColorMaps/list") )
{
QStringList colorMapList;
......@@ -248,7 +248,7 @@ void ColorMapSelectionDialog::saveToApplicationSettings()
colorMapList << ((GradientWidget*) m_ColorMapListLayout->itemAtPosition(i,1)->widget())->ValueString();
}
QSettings *settings = UIMainWindow::getUserSettings();
QSettings *settings = UI::GetUserSettings();
settings->beginGroup( "ColorMaps" );
settings->setValue( "list", colorMapList );
settings->endGroup();
......
......@@ -24,6 +24,7 @@ public:
ThemeSettingsDialog( QWidget *parent = NULL );
void setButtonColor( QPushButton *button, const QColor& c );
public slots:
void onColorButtonTrigger();
};
......
......@@ -6,7 +6,7 @@
*/
#include "UIMainWindow.h"
#include "UISettings.h"
#include "ToolCategory.h"
......@@ -43,7 +43,7 @@ void ToolCategory::declareCategory( int id, const QString& name, const QString &
// Save the icon to the style destination directory.
QString themePath = UIMainWindow::getUserSettings()->value("uiStyle").toString();
QString themePath = UI::GetUserSettings()->value("uiStyle").toString();
QString iconFilePath = QFileInfo(themePath).absolutePath() + "/" + QFileInfo(iconName).fileName();
icon.save( iconFilePath );
......
......@@ -14,6 +14,7 @@
#include "GUI_mainDefs.h"
#include "UIMainWindow.h"
#include "UISettings.h"
GUIMAIN_API void UILoadApplicationStyle( QApplication &app, QSettings *userSettings );
......@@ -49,7 +50,7 @@ int UILaunch( int argc, char **argv )
UIMainWindow *mainWin = new UIMainWindowT(); // Use default GUI main window.
mainWin->initializeUserSettings();
UILoadApplicationStyle( app, mainWin->getUserSettings() );
UILoadApplicationStyle( app, UI::GetUserSettings() );
mainWin->onInitializingApp();
mainWin->init();
......
......@@ -25,6 +25,7 @@
#include "Interfaces.h"
#include "UIParamDialog.h"
#include "ThemeSettingsDialog.h"
#include "UISettings.h"
#include "NodeEditor.h"
//#include "ShaderGraph.h"
......@@ -37,11 +38,6 @@
QSettings* UIMainWindow::m_UserSettings = NULL;
UIMainWindow::UIMainWindow(QWidget *parent) :
QMainWindow( parent ),
ui( new Ui::MainWindow ),
......@@ -60,7 +56,7 @@ bool UIMainWindow::saveUISettings() const
{
// Get user settings file.
QSettings *settings = getUserSettings();
QSettings *settings = UI::GetUserSettings();
// Store geometry and state of the main window and the dock widgets.
......@@ -82,7 +78,7 @@ bool UIMainWindow::loadUISettings()
{
// Get user settings file.
QSettings *settings = getUserSettings();
QSettings *settings = UI::GetUserSettings();
// Load geometry and state of the main window and the dock widgets.
......@@ -200,11 +196,9 @@ void UIMainWindow::declareCustomMenuAction( const QString& menuName, QAction* ac
void UIMainWindow::initializeUserSettings()
{
assert( m_UserSettings == NULL );
QString compagnyName, applicationName, shortDescription;
applicationInfo( compagnyName, applicationName, shortDescription );
m_UserSettings = new QSettings( QSettings::IniFormat, QSettings::UserScope, compagnyName + "/" + applicationName, "Settings" );
UI::InitializeUserSettings( compagnyName + "/" + applicationName );
}
......@@ -290,7 +284,7 @@ void UIMainWindow::release()
closeAllProjects();
delete m_UserSettings;
UI::ReleaseUserSettings();
ui->toolSelector->releaseAllTools();
delete ui;
......@@ -2020,7 +2014,7 @@ bool UIMainWindow::initRenderOptions()
};
std::function<QVector3D(const QColor&)> ColorToVector = []( const QColor &col ) { return QVector3D( col.red(), col.green(), col.blue() ) / 255.0f; };
QSettings *settings = UIMainWindow::getUserSettings();
QSettings *settings = UI::GetUserSettings();
if( settings->contains( "RenderOptions/bgTopColor") )
GLViewer::BgTopColor = colorFromHexa( settings->value( "RenderOptions/bgTopColor" ).toString() );
......@@ -2061,7 +2055,7 @@ bool UIMainWindow::updateRenderOptions()
return QString::number(colorVal,16).toUpper().rightJustified(6,'0');
};
QSettings *settings = UIMainWindow::getUserSettings();
QSettings *settings = UI::GetUserSettings();
settings->beginGroup( "RenderOptions" );
settings->setValue( "bgTopColor" , QVariant( hexaFromColor(GLViewer::BgTopColor) ) );
......
......@@ -84,8 +84,6 @@ class GUIMAIN_API UIMainWindow : public QMainWindow
QList< WidgetStackItem > m_CentralWidgetStack;
static QSettings *m_UserSettings;
public:
UIMainWindow( QWidget *parent = NULL );
~UIMainWindow();
......@@ -106,8 +104,6 @@ public:
virtual QString projectFileExtension() const = 0;
void initializeUserSettings();
static inline QSettings*getUserSettings() { return m_UserSettings; }
static inline QString getUserSettingsPath() { return QFileInfo(getUserSettings()->fileName()).absolutePath(); }
virtual void onInitializingApp() {}
virtual void onReleasingApp() {}
......
/*
* (c) LSIIT, UMR CNRS/UdS
* Authors: F. Larue.
*
* See licence.txt for additional information.
*/
#include "UIParamGradient.h"
//#include ""
void UIParamGradient::InitWidget( GradientWidget *gdtWidget )
{
m_Widget = gdtWidget;
if( !m_Description.isNull() && !m_Description.isEmpty() )
m_Widget->setToolTip( m_Description );
QHBoxLayout *l = new QHBoxLayout();
l->setContentsMargins( 0, 0, 0, 0 );
l->setSpacing( 2 );
QWidget *w = new QWidget();
w->setLayout( l );
int buttonSize = gdtWidget->minimumHeight() - 2;
QPushButton *pickGradient = new QPushButton();
pickGradient->setMinimumSize( buttonSize, buttonSize );
pickGradient->setMaximumSize( buttonSize, buttonSize );
l->addWidget( m_Widget );
l->addWidget( pickGradient );
connect( pickGradient, SIGNAL(clicked(bool)), this, SLOT(openColorMapSelector()) );
}
void UIParamGradient::openColorMapSelector()
{
// ColorMapSele
}
cmake_minimum_required( VERSION 3.0 )
get_filename_component( CURRENT_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME )
message( STATUS " - " ${CURRENT_TARGET} )
project( ${CURRENT_TARGET} LANGUAGES CXX )
set( CMAKE_AUTOMOC ON )
file( GLOB LIB_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/*.h )
file( GLOB LIB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp )
add_library( ${CURRENT_TARGET} SHARED ${LIB_HEADERS} ${LIB_SOURCES} )
include_directories( ${CMAKE_BINARY_DIR}/UISettings )
if( WIN32 )
target_link_libraries( ${CURRENT_TARGET}
${Qt5Widgets_LIBRARIES}
)
else()
target_link_libraries( ${CURRENT_TARGET}
${Qt5Widgets_LIBRARIES}
)
endif()
if( ENABLE_SOLUTION_FOLDERS )
set_target_properties( ${PROJECT_NAME} PROPERTIES FOLDER "Core" )
endif()
#install( TARGETS ${PROJECT_NAME} RUNTIME DESTINATION . )
/*
* (c) LSIIT, UMR CNRS/UdS
* Authors: F. Larue.
*
* See licence.txt for additional information.
*/
#include "UISettings.h"
#include <cassert>
QSettings* UI::s_UserSettings = NULL;
void UI::InitializeUserSettings( const QString& appName )
{
assert( m_UserSettings == NULL );
s_UserSettings = new QSettings( QSettings::IniFormat, QSettings::UserScope, appName, "Settings" );
}
void UI::ReleaseUserSettings()
{
delete s_UserSettings;
s_UserSettings = NULL;
}
/*
* (c) LSIIT, UMR CNRS/UdS
* Authors: F. Larue.
*
* See licence.txt for additional information.
*/
#ifndef __UISETTINGS_H__
#define __UISETTINGS_H__
#include "UISettingsDefs.h"
#include <QtGui>
class UISETTINGS_API UI
{
static QSettings* s_UserSettings;
public:
static void InitializeUserSettings( const QString& appName );
static void ReleaseUserSettings();
static inline QSettings* GetUserSettings() { return s_UserSettings; }
static inline QString GetUserSettingsPath() { return QFileInfo(GetUserSettings()->fileName()).absolutePath(); }
};
#endif // __UISETTINGS_H__
/*
* (c) LSIIT, UMR CNRS/UdS
* Authors: F. Larue.
*
* See licence.txt for additional information.
*/
#ifdef _WIN32
#ifdef UISettings_EXPORTS
#define UISETTINGS_API __declspec(dllexport)
#else
#define UISETTINGS_API __declspec(dllimport)
#endif
#else
#define UISETTINGS_API
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment