Mise à jour terminée. Pour connaître les apports de la version 13.8.4 par rapport à notre ancienne version vous pouvez lire les "Release Notes" suivantes :
https://about.gitlab.com/releases/2021/02/11/security-release-gitlab-13-8-4-released/
https://about.gitlab.com/releases/2021/02/05/gitlab-13-8-3-released/

Commit ce4e70c5 authored by Mathieu Faverge's avatar Mathieu Faverge

Keep restruring settings

parent 465ec3e7
......@@ -50,8 +50,8 @@
#include <string>
using namespace std;
unsigned int Info::Screen::width = 800;
unsigned int Info::Screen::height = 600;
unsigned int Info::Screen::width = 800;
unsigned int Info::Screen::height = 600;
Element_pos Info::Container::x_min = 0;
Element_pos Info::Container::x_max = 0;
......@@ -79,9 +79,9 @@ Element_pos Info::Render::_info_accurate = 0.0;
bool Info::Render::_no_arrows = false;
bool Info::Render::_no_events = false;
bool Info::Render::_shaded_states = Session::get_shaded_states_setting();
bool Info::Render::_shaded_states = Session::getSession().get_shaded_states_setting();
//true;/* By default, enable shaded state */
bool Info::Render::_vertical_line = Session::get_vertical_line_setting();
bool Info::Render::_vertical_line = Session::getSession().get_vertical_line_setting();
//true;/* By default, enable vertical line */
bool Info::Splitter::split = false;
......
......@@ -65,50 +65,100 @@
using namespace std;
const QByteArray Session::Export::DEFAULT_STATE = QByteArray::number(-1);
QByteArray Session::Export::file_dialog_state = Session::Export::DEFAULT_STATE;
MinimapSettings::MinimapSettings(){
// Initialize Minimap default
_x = 0;
_y = 0;
_width = 200;
_height = 150;
_pen_size = 3;
_pen_color = Qt::red;
_brush_color = QColor::fromRgbF(1, 1, 0, 0.5);
_is_closed = true;
load();
}
MinimapSettings::~MinimapSettings() {
save();
}
void MinimapSettings::load() {
Session &s = Session::getSession();
//Session::Minimap::is_closed = isHidden();
if (s.contains("minimap/x")) {
_x = s.value("minimap/x").value<int>();
_y = s.value("minimap/y").value<int>();
_width = s.value("minimap/width").value<int>();
_height = s.value("minimap/height").value<int>();
_pen_size = s.value("minimap/pen_size").value<int>();
_pen_color = s.value("minimap/pen_color").value<QColor>();
_brush_color = s.value("minimap/brush_color").value<QColor>();
_is_closed = s.value("minimap/is_closed").value<bool>();
}
}
void MinimapSettings::save( ) {
Session &s = Session::getSession();
s.setValue( "minimap/x" , _x );
s.setValue( "minimap/y" , _y );
s.setValue( "minimap/width" , _width );
s.setValue( "minimap/height" , _height );
s.setValue( "minimap/is_closed", _is_closed );
s.sync();
}
void MinimapSettings::save(int x, int y, int w, int h, bool hidden ) {
_x = x;
_y = y;
_width = w;
_height = h;
_is_closed = hidden;
save();
}
int Session::Minimap::x;
int Session::Minimap::y;
int Session::Minimap::width;
int Session::Minimap::height;
int Session::Minimap::pen_size;
QColor Session::Minimap::pen_color;
QColor Session::Minimap::brush_color;
bool Session::Minimap::is_closed;
Palette *Session::_palette = NULL;
Palette *Session::_link_types = NULL;
Palette *Session::_event_types = NULL;
bool Session::_use_palettes= false;
bool Session::_use_palettes_is_set=false;
const QByteArray Session::Export::DEFAULT_STATE = QByteArray::number(-1);
QByteArray Session::Export::file_dialog_state = Session::Export::DEFAULT_STATE;
QSettings *Session::settings = NULL;
//QSettings *Session::_settings = NULL;
Session *Session::S = NULL;
Palette *Session::_palettes_state = NULL;
Palette *Session::_palettes_link = NULL;
Palette *Session::_palettes_event = NULL;
bool Session::_use_palettes = false;
bool Session::_use_palettes_is_set = false;
Session::Session() {
MinimapSettings *Session::_mmSettings = NULL;
Session::Session() : QSettings( VITE_ORGANISATION_NAME, VITE_APPLICATION_NAME ) {
QCoreApplication::setOrganizationName(VITE_ORGANISATION_NAME);
QCoreApplication::setOrganizationDomain(VITE_ORGANISATION_DOMAIN);
QCoreApplication::setApplicationName(VITE_APPLICATION_NAME);
settings = new QSettings( VITE_ORGANISATION_DOMAIN,
VITE_APPLICATION_NAME );
_palette = get_palette("palette", get_current_palette("palette"));
_link_types = get_palette("link_types", get_current_palette("link_types"));
_event_types = get_palette("event_types", get_current_palette("event_types"));
}
Session::~Session() {
delete settings;
}
void Session::init() {
_palettes_state = get_palette("palette", get_current_palette("palette"));
_palettes_link = get_palette("link_types", get_current_palette("link_types"));
_palettes_event = get_palette("event_types", get_current_palette("event_types"));
_mmSettings = new MinimapSettings();
}
const QStringList Session::get_recent_files() {
return settings->value(RECENT_FILES).toStringList();
return S->value(RECENT_FILES).toStringList();
}
void Session::add_recent_file(const QString &filename) {
QStringList files = settings->value(RECENT_FILES).toStringList();
QStringList files = S->value(RECENT_FILES).toStringList();
// We delete if the file was already call in order to be on the top of the list
files.removeAll(filename);
......@@ -116,68 +166,52 @@ void Session::add_recent_file(const QString &filename) {
while (files.size() > _MAX_NB_RECENT_FILES)
files.removeLast();
settings->setValue(RECENT_FILES, files);
S->setValue(RECENT_FILES, files);
}
void Session::clear_recent_files() {
settings->remove(RECENT_FILES);
}
/*** Minimap ***/
void Session::save_minimap(int x, int y, int w, int h, bool hide_on_start) {
// Doublon ?
Session::Minimap::x = x;
Session::Minimap::y = y;
Session::Minimap::width = w;
Session::Minimap::height = h;
Session::Minimap::is_closed = hide_on_start;
settings->setValue("minimap/x" , x);
settings->setValue("minimap/y" , y);
settings->setValue("minimap/width" , w);
settings->setValue("minimap/height" , h);
settings->setValue("minimap/is_closed", hide_on_start);
S->remove(RECENT_FILES);
}
bool Session::get_vertical_line_setting(){
//set 1 as the default value if not set in the file
return settings->value(VERTICAL_LINE,1).toBool();
return S->value(VERTICAL_LINE,1).toBool();
}
void Session::update_vertical_line_setting(bool b) {
settings->setValue(VERTICAL_LINE, b);
S->setValue(VERTICAL_LINE, b);
}
bool Session::get_hide_warnings_setting(){
//set 0 as the default value if not set in the file
return settings->value(HIDE_WARNINGS,0).toBool();
return S->value(HIDE_WARNINGS,0).toBool();
}
void Session::update_hide_warnings_settings(bool b) {
settings->setValue(HIDE_WARNINGS, b);
S->setValue(HIDE_WARNINGS, b);
}
bool Session::get_shaded_states_setting(){
//set 1 as the default value if not set in the file
return settings->value(SHADED_STATE,1).toBool();
return S->value(SHADED_STATE,1).toBool();
}
void Session::update_shaded_states_setting(bool b) {
settings->setValue(SHADED_STATE, b);
S->setValue(SHADED_STATE, b);
}
bool Session::get_reload_type_setting(){
//set 1 as the default value if not set in the file
return settings->value(RELOAD_TYPE,1).toBool();
return S->value(RELOAD_TYPE,1).toBool();
}
void Session::update_reload_type_setting(bool b){
settings->setValue(RELOAD_TYPE, b);
S->setValue(RELOAD_TYPE, b);
}
/*** Plugins ***/
void Session::load_plugin_directories(QStringList &list) {
list = settings->value(PLUGIN_DIR).toStringList();
list = S->value(PLUGIN_DIR).toStringList();
/* We add the $HOME/.vite if not exists as a default path */
const QString home_dir = QDir::toNativeSeparators(QDir::homePath()+"/.vite");
......@@ -187,51 +221,60 @@ void Session::load_plugin_directories(QStringList &list) {
}
void Session::save_plugin_directories(const QStringList &list) {
settings->setValue(PLUGIN_DIR, list);
S->setValue(PLUGIN_DIR, list);
}
/*** States color ***/
void Session::set_use_palette(const std::string type, bool use) {
settings->setValue(QString::fromStdString(type+"/is_used"), use);
S->setValue(QString::fromStdString(type+"/is_used"), use);
_use_palettes = use;
}
bool Session::get_use_palette(const std::string type) {
//quick way, if we use the palettes, we don't need to check each time that we use them in the settings file, only the first time
//quick way, if we use the palettes, we don't need to check each time that we use them in the _settings file, only the first time
if(_use_palettes_is_set)
return _use_palettes;
else {
_use_palettes=settings->value(QString::fromStdString(type+"/is_used")).toBool();
_use_palettes=S->value(QString::fromStdString(type+"/is_used")).toBool();
_use_palettes_is_set=true;
return _use_palettes;
}
}
std::string Session::get_current_palette(const std::string type) {
std::string tmp = settings->value(QString::fromStdString(type+CUR_PALETTE)).toString().toStdString();
std::string tmp = S->value(QString::fromStdString(type+CUR_PALETTE)).toString().toStdString();
if(tmp == "")
tmp = "default";
return tmp;
}
void Session::set_current_palette(const std::string type, const std::string &name) {
settings->setValue(QString::fromStdString(type+CUR_PALETTE), QString::fromStdString(name));
S->setValue(QString::fromStdString(type+CUR_PALETTE), QString::fromStdString(name));
}
void Session::get_palettes_name(const std::string type, QStringList &list) {
list = settings->value(QString::fromStdString(type+PALETTE_NAMES)).toStringList();
list = S->value(QString::fromStdString(type+PALETTE_NAMES)).toStringList();
if(!list.contains("default")) {
list.append("default");
}
}
Palette *Session::get_palette(const std::string type, const std::string &palette_name) {
QMap <QString, QVariant> qmap = settings->value(QString::fromStdString(type+"/"+palette_name+"/map")).toMap();
QMap <QString, QVariant> qmap = S->value(QString::fromStdString(type+"/"+palette_name+"/map")).toMap();
Palette *p, **where_from;
if(type=="palette") {p = _palette; where_from = &_palette;}
else if(type=="link_types") { p=_link_types; where_from = &_link_types;}
else if(type=="event_types") { p=_event_types; where_from = &_event_types;}
if( type == "palette" ) {
p = _palettes_state;
where_from = &_palettes_state;
}
else if( type == "link_types" ) {
p = _palettes_link;
where_from = &_palettes_link;
}
else if( type == "event_types" ) {
p = _palettes_event;
where_from = &_palettes_event;
}
if(!p || p->get_name() != palette_name) {
delete p;
......@@ -249,46 +292,47 @@ Palette *Session::get_palette(const std::string type, const std::string &palette
void Session::create_palette(const std::string type, const std::string &name) {
QStringList list = settings->value(QString::fromStdString(type+PALETTE_NAMES)).toStringList();
QStringList list = S->value(QString::fromStdString(type+PALETTE_NAMES)).toStringList();
list.append(QString::fromStdString(name));
settings->setValue(QString::fromStdString(type+PALETTE_NAMES), list);
S->setValue(QString::fromStdString(type+PALETTE_NAMES), list);
}
void Session::remove_palette(const std::string type, const std::string &name) {
QStringList list = settings->value(QString::fromStdString(type+PALETTE_NAMES)).toStringList();
QStringList list = S->value(QString::fromStdString(type+PALETTE_NAMES)).toStringList();
list.removeOne(QString::fromStdString(name));
settings->setValue(QString::fromStdString(type+PALETTE_NAMES), list);
S->setValue(QString::fromStdString(type+PALETTE_NAMES), list);
QString _name = QString::fromStdString(type+"/"+name+"/map");
settings->setValue(_name, QMap <QString, QVariant>());
S->setValue(_name, QMap <QString, QVariant>());
}
void Session::copy_palette(const std::string type, const std::string &src, const std::string &dest) {
// Save the palette
QStringList list = settings->value(QString::fromStdString(type+PALETTE_NAMES)).toStringList();
QStringList list = S->value(QString::fromStdString(type+PALETTE_NAMES)).toStringList();
list.append(QString::fromStdString(dest));
settings->setValue(QString::fromStdString(type+PALETTE_NAMES), list);
S->setValue(QString::fromStdString(type+PALETTE_NAMES), list);
// Copy the states
QString name_src = QString::fromStdString(type+"/"+src+"/map");
QString name_dest = QString::fromStdString(type+"/"+dest+"/map");
QMap <QString, QVariant> qmap = settings->value(name_src).toMap();
QMap <QString, QVariant> qmap = S->value(name_src).toMap();
settings->setValue(name_dest, qmap);
S->setValue(name_dest, qmap);
}
void Session::add_state_to_palette(const std::string type, const std::string &palette_name, const std::string &state_name, const Color &c, bool visible) {
QString name = QString::fromStdString(type+"/"+palette_name+"/map");
QMap <QString, QVariant> qmap = settings->value(name).toMap();
QMap <QString, QVariant> qmap = S->value(name).toMap();
qmap[QString::fromStdString(state_name)] = QColor((int)(c.get_red()*255), (int)(c.get_green()*255), (int)(c.get_blue()*255), visible==true?255:0);
settings->setValue(name, qmap);
S->setValue(name, qmap);
}
void Session::remove_state_to_palette(const std::string type, const std::string &palette_name, const std::string &state_name) {
QString name = QString::fromStdString(type+"/"+palette_name+"/map");
QMap <QString, QVariant> qmap = settings->value(name).toMap();
QMap <QString, QVariant> qmap = S->value(name).toMap();
qmap.remove(QString::fromStdString(state_name));
settings->setValue(name, qmap);
S->setValue(name, qmap);
}
......@@ -50,9 +50,9 @@
class Palette;
class Color;
class QByteArray;
class QColor;
class QString;
class QStringList;
#include <QColor>
#include <QSettings>
#include <list>
......@@ -103,36 +103,57 @@ class QStringList;
*/
#define PALETTE_NAMES "/palettes_name"
class MinimapSettings {
public:
int _x, _y;
int _width, _height;
int _pen_size;
QColor _pen_color, _brush_color;
bool _is_closed;
MinimapSettings();
~MinimapSettings();
void load();
void save();
void save(int x, int y, int w, int h, bool hidden );
};
/*!
* \brief Class used to store information between two software launch.
*
*/
class Session {
private:
/*!
* \brief The class constructor.
*/
Session();
static QSettings *settings;
class Session : public QSettings {
static Palette *_palette;
protected:
static Session *S;
static MinimapSettings *_mmSettings;
static Palette *_link_types;
static Palette *_event_types;
public:
static Palette *_palettes_state;
static Palette *_palettes_link;
static Palette *_palettes_event;
//boolean used to know if palettes are used (only one boolean for all types of palettes)
static bool _use_palettes;
//boolean used to know if the previous one is set (ugly but avoids rereading from settings file each time)
static bool _use_palettes_is_set;
/*!
* \brief The class destructor.
* \brief Sub structure to store render information.
*/
struct Render{
};
/*!
* \brief The class constructor.
*/
virtual ~Session();
Session();
static void init();
public:
/*!
* \brief Sub structure to store export information.
......@@ -150,25 +171,22 @@ public:
const static QByteArray DEFAULT_STATE;
};
/*!
* \brief Sub structure to store render information.
*/
struct Render{
static Session &getSession() {
if (S == NULL) {
S = new Session();
init();
}
return *S;
}
};
static MinimapSettings &getSessionMinimap() {
return *(getSession()._mmSettings);
}
/*!
* \brief Sub structure to store the Minimap information.
* \brief The class destructor.
*/
struct Minimap{
static int x, y;
static int width, height;
static int pen_size;
static QColor pen_color, brush_color;
static bool is_closed;
};
static void save_minimap(int x, int y, int w, int h, bool hide_on_start);
~Session();
/*!
* \brief maximum number of file shown in the recent files menu.
......@@ -331,7 +349,6 @@ public:
* \param state_name : the state name
*/
static void remove_state_to_palette(const std::string type, const std::string &palette_name, const std::string &state_name);
};
#endif
......@@ -87,6 +87,7 @@
#include "common/Session.hpp"
#include "common/Message.hpp"
#include "common/Palette.hpp"
#include "common/Session.hpp"
/* -- */
#include "render/Geometry.hpp"
#include "render/Hook_event.hpp"
......@@ -213,7 +214,7 @@ Core::~Core(){
if( _trace != NULL )
delete _trace;
if ( _run_env[0] != NULL )
if ( _run_env[0] != NULL )
delete _run_env[0];
if ( _run_env[1] != NULL )
......
......@@ -75,14 +75,16 @@ Settings_window::Settings_window(Core *c, QWidget *parent) : QWidget(parent), _c
_changed=false;
Session &S = Session::getSession();
// const string &tabName = tabWidget->tabText(index).toStdString();
// Need to load the current palette.
palette_list->clear();
QStringList palettes;
Session::get_palettes_name("palette", palettes);
S.get_palettes_name("palette", palettes);
palette_list->addItems(palettes);
string current = Session::get_current_palette("palette");
string current = S.get_current_palette("palette");
fill_table(current);
palette_list->setCurrentIndex(palette_list->findText(QString::fromStdString(current))); // Set the combobox at the good index.
......@@ -90,17 +92,17 @@ Settings_window::Settings_window(Core *c, QWidget *parent) : QWidget(parent), _c
reload_minimap_tab();
event_types_palette_list->clear();
Session::get_palettes_name("event_types", palettes);
S.get_palettes_name("event_types", palettes);
event_types_palette_list->addItems(palettes);
current = Session::get_current_palette("event_types");
current = S.get_current_palette("event_types");
// Need to load the types
fill_event_types_table(current);
event_types_palette_list->setCurrentIndex(event_types_palette_list->findText(QString::fromStdString(current))); // Set the combobox at the good index.
link_types_palette_list->clear();
// QStringList palettes;
Session::get_palettes_name("link_types", palettes);
S.get_palettes_name("link_types", palettes);
link_types_palette_list->addItems(palettes);
current = Session::get_current_palette("link_types");
current = S.get_current_palette("link_types");
// Need to load the types
fill_link_types_table(current);
link_types_palette_list->setCurrentIndex(link_types_palette_list->findText(QString::fromStdString(current))); // Set the combobox at the good index.
......@@ -125,18 +127,21 @@ void Settings_window::show() {
/***** General tab. *****/
/************************/
void Settings_window::reload_general_tab() {
use_palette_cb->setChecked(Session::get_use_palette("palette"));
Session &S = Session::getSession();
use_palette_cb->setChecked(S.get_use_palette("palette"));
}
/************************/
/***** Minimap tab. *****/
/************************/
void Settings_window::reload_minimap_tab() {
minimap_hide_cb->setChecked(Session::Minimap::is_closed);
minimap_x_sb->setValue(Session::Minimap::x);
minimap_y_sb->setValue(Session::Minimap::y);
minimap_w_sb->setValue(Session::Minimap::width);
minimap_h_sb->setValue(Session::Minimap::height);
MinimapSettings &ms = Session::getSessionMinimap();
minimap_hide_cb->setChecked(ms._is_closed);
minimap_x_sb->setValue(ms._x);
minimap_y_sb->setValue(ms._y);
minimap_w_sb->setValue(ms._width);
minimap_h_sb->setValue(ms._height);
// \todo Square border size? kesako?
// \todo maybe colors?
}
......@@ -163,7 +168,7 @@ void Settings_window::on_add_dir_btn_clicked() {
void Settings_window::plugin_load_dirs_name() {
QStringList dirs;
Session::load_plugin_directories(dirs);
Session::getSession().load_plugin_directories(dirs);
dir_list->addItems(dirs);
}
......@@ -179,7 +184,7 @@ void Settings_window::fill_table(const string &palette_name) {
map<string, Color *> colors;
int row = 0;
Palette* p=Session::get_palette("palette",palette_name);
Palette* p = Session::getSession().get_palette("palette",palette_name);
colors = p->get_map();
if(colors.empty() ) { // Loads the colors of the current trace
......@@ -236,7 +241,7 @@ void Settings_window::add_palette(QComboBox* list, const std::string type){
"", &ok);
if (ok && !text.isEmpty()) { // Palette name is set
list->addItem(text);
Session::create_palette(type,text.toStdString());
Session::getSession().create_palette(type,text.toStdString());
}
}
......@@ -253,6 +258,9 @@ QString Settings_window::copy_palette(QTableWidget* , QComboBox* list, const std
tr("new palette name:"), QLineEdit::Normal,
"", &ok);
string current = list->currentText().toStdString();
Session &S = Session::getSession();