Maj terminée. Pour consulter la release notes associée voici le lien :
https://about.gitlab.com/releases/2021/07/07/critical-security-release-gitlab-14-0-4-released/

Commit 760629d5 authored by Mathieu Faverge's avatar Mathieu Faverge
Browse files

Finish to cleanup the code factoring in settings_window

parent 5b1e78a4
...@@ -193,7 +193,6 @@ public: ...@@ -193,7 +193,6 @@ public:
static const int _MAX_NB_RECENT_FILES = 10; static const int _MAX_NB_RECENT_FILES = 10;
static void save_config_file(); static void save_config_file();
static void load_config_file(); static void load_config_file();
/*! /*!
......
...@@ -631,8 +631,7 @@ void Interface_graphic::on_reload_triggered() { ...@@ -631,8 +631,7 @@ void Interface_graphic::on_reload_triggered() {
if(_is_rendering_trace) { if(_is_rendering_trace) {
Element_pos zoom[2]={Info::Splitter::_x_min,Info::Splitter::_x_max}; Element_pos zoom[2]={Info::Splitter::_x_min,Info::Splitter::_x_max};
if(_ui_settings != NULL){ if(_ui_settings != NULL){
//_ui_settings->updateTrace( _core->get_trace() ); _ui_settings->refresh();
//_ui_settings->on_apply_clicked();
} }
if(_ui_node_selection!=NULL) if(_ui_node_selection!=NULL)
_ui_node_selection->on_reset_button_clicked(); _ui_node_selection->on_reset_button_clicked();
...@@ -1244,5 +1243,3 @@ void Interface_graphic::update_settings() { ...@@ -1244,5 +1243,3 @@ void Interface_graphic::update_settings() {
_core->launch_action(Core::_STATE_RENDER_UPDATE); _core->launch_action(Core::_STATE_RENDER_UPDATE);
} }
...@@ -159,22 +159,7 @@ Settings_tab::Settings_tab(Core *core, std::string ecname) ...@@ -159,22 +159,7 @@ Settings_tab::Settings_tab(Core *core, std::string ecname)
background->addWidget(content); background->addWidget(content);
background->addLayout(footer); background->addLayout(footer);
// Initialize the parameters of the tab refresh();
{
Session &S = Session::getSession();
QStringList palettes;
string current;
S.get_palettes_name( _ecname, palettes );
current = S.get_current_palette( _ecname );
list_palette->clear();
list_palette->addItems(palettes);
// Set the combobox at the good index.
list_palette->setCurrentIndex(list_palette->findText(QString::fromStdString(current)));
fill_table();
}
QMetaObject::connectSlotsByName(this); QMetaObject::connectSlotsByName(this);
} }
...@@ -197,78 +182,46 @@ Settings_tab::~Settings_tab() ...@@ -197,78 +182,46 @@ Settings_tab::~Settings_tab()
} }
void void
Settings_tab::color_changed(const QColor &qc, int row) Settings_tab::refresh()
{ {
_changed = true; // Initialize the parameters of the tab
Session &S = Session::getSession();
if( !content || !list_palette) QStringList palettes;
return; string current;
Color color(qc.red()/255., qc.green()/255., qc.blue()/255.);
if (row == -1) {
// Find the row of the colorPicker
row = 0;
while(content->cellWidget(row, 1) &&
content->cellWidget(row, 1) != sender()) {
row ++;
}
}
if(!content->cellWidget(row, 1))
return; // epic fail...
std::string palette_name = list_palette->currentText().toStdString();
std::string ev_name = content->item(row, 0)->text().toStdString();
std::string ev_alias = content->item(row, 3)->text().toStdString();
Session &S = Session::getSession();
Palette *p = S.get_palette(_ecname, palette_name);
// Get the former color S.get_palettes_name( _ecname, palettes );
// Quick and dirty patch current = S.get_current_palette( _ecname );
Color *old = p->get_color(ev_name);
if ( old == NULL ) {
old = new Color(1, 1, 1);
}
QColor q(old->get_red()*255, old->get_green()*255, old->get_blue()*255);
// Get the check status list_palette->clear();
bool checked = qobject_cast<QCheckBox *>(content->cellWidget(row, 2))->checkState()== Qt::Checked; list_palette->addItems(palettes);
// Set the combobox at the good index.
list_palette->setCurrentIndex(list_palette->findText(QString::fromStdString(current)));
// If the state has not already been changed, we register it fill_table();
if( _changes.count(ev_alias) == 0 ) {
_changes[ev_alias] = row;
}
return;
} }
void void
Settings_tab::visible_changed(const int checked, int row) Settings_tab::item_changed(int row)
{ {
_changed = true; _changed = true;
if( !content || !list_palette ) if( !content || !list_palette)
return; return;
if (row == -1) { if (row == -1) {
// Find the row of the checkBox // Find the row of the colorPicker
row = 0; row = 0;
while(content->cellWidget(row, 2) && while(content->cellWidget(row, 1) &&
content->cellWidget(row, 2) != sender()) { content->cellWidget(row, 1) != sender()) {
row ++; row ++;
} }
} }
if(!content->cellWidget(row, 2)) if(!content->cellWidget(row, 1))
return; // epic fail... return; // epic fail...
std::string ev_alias = content->item(row, 3)->text().toStdString(); std::string ev_alias = content->item(row, 3)->text().toStdString();
// Get the color
QColor qc = qobject_cast<QtColorPicker *>(content->cellWidget(row, 1))->currentColor();
Color color(qc.red()/255, qc.green()/255, qc.blue()/255);
// If the state has not already been changed, we register it // If the state has not already been changed, we register it
if( _changes.count(ev_alias) == 0 ) { if( _changes.count(ev_alias) == 0 ) {
_changes[ev_alias] = row; _changes[ev_alias] = row;
...@@ -302,13 +255,13 @@ Settings_tab::add_table_line(int &row, ...@@ -302,13 +255,13 @@ Settings_tab::add_table_line(int &row,
color_widget->setCurrentColor(qc); color_widget->setCurrentColor(qc);
color_widget->setColorDialogEnabled(false); color_widget->setColorDialogEnabled(false);
connect(color_widget, SIGNAL(colorChanged(const QColor &)), connect(color_widget, SIGNAL(colorChanged(const QColor &)),
this, SLOT(color_changed(const QColor &)) ); this, SLOT(item_changed()) );
/* Visible */ /* Visible */
QCheckBox *cb = new QCheckBox(); QCheckBox *cb = new QCheckBox();
cb->setChecked( ev->get_visible() ); cb->setChecked( ev->get_visible() );
connect(cb, SIGNAL(stateChanged(int)), connect(cb, SIGNAL(stateChanged(int)),
this, SLOT(visible_changed(int))); this, SLOT(item_changed()));
/* Set the row */ /* Set the row */
content->insertRow(row); content->insertRow(row);
...@@ -319,14 +272,13 @@ Settings_tab::add_table_line(int &row, ...@@ -319,14 +272,13 @@ Settings_tab::add_table_line(int &row,
// If we reload from file, backup the changes // If we reload from file, backup the changes
if( !used ) { if( !used ) {
if (c != ev->get_used_color()) { // Change the color test
color_changed( qc, row ); if ( (c != ev->get_used_color()) ||
} (!ev->get_visible()) )
if (!ev->get_visible()) { {
visible_changed( true, row ); item_changed( row );
} }
} }
row ++; row ++;
} }
...@@ -360,10 +312,43 @@ Settings_tab::fill_table( bool used ) ...@@ -360,10 +312,43 @@ Settings_tab::fill_table( bool used )
} }
} }
void
Settings_tab::update_table_from_palette( string pname )
{
Session &S = Session::getSession();
Palette *p = S.get_palette(_ecname, pname);
map<string, EntityValue*> *ev_list;
map<string, EntityValue*>::const_iterator ev;
int rownbr = content->rowCount();
for( int i=0; i < rownbr; i++ ) {
string ev_name = content->item(i, 0)->text().toStdString();
string ev_alias = content->item(i, 3)->text().toStdString();
Color *c = p->get_color( ev_name );
if ( c != NULL ) {
_changed = true;
bool v = p->is_visible( ev_name );
QtColorPicker *color_widget = qobject_cast<QtColorPicker *>(content->cellWidget(i, 1));
color_widget->setCurrentColor(QColor(c->get_red() *255,
c->get_green()*255,
c->get_blue() *255));
QCheckBox *cb = qobject_cast<QCheckBox *>(content->cellWidget(i, 2));
cb->setCheckState( v ? Qt::Checked : Qt::Unchecked );
_changes[ev_alias] = i;
}
}
}
void void
Settings_tab::on_list_palette_currentIndexChanged(const QString & text) Settings_tab::on_list_palette_currentIndexChanged(const QString & text)
{ {
//fill_table_from_palette( text.toStdString() ); update_table_from_palette( text.toStdString() );
} }
void void
...@@ -423,8 +408,7 @@ Settings_tab::on_btn_palette_rm_clicked() ...@@ -423,8 +408,7 @@ Settings_tab::on_btn_palette_rm_clicked()
assert(index != -1); assert(index != -1);
list_palette->setCurrentIndex( index ); list_palette->setCurrentIndex( index );
// TODO: Switch to default update_table_from_palette( "Default" );
//fill_table_from_palette( "Default" );
} }
} }
...@@ -513,7 +497,6 @@ void ...@@ -513,7 +497,6 @@ void
Settings_tab::on_btn_reload_clicked() Settings_tab::on_btn_reload_clicked()
{ {
fill_table(false); fill_table(false);
on_btn_apply_clicked();
} }
Settings_window::Settings_window(Core *c, QWidget *parent) Settings_window::Settings_window(Core *c, QWidget *parent)
...@@ -548,8 +531,17 @@ void Settings_window::on_tabWidget_currentChanged(int ) { ...@@ -548,8 +531,17 @@ void Settings_window::on_tabWidget_currentChanged(int ) {
} }
void
Settings_window::refresh()
{
_tab_states->refresh();
_tab_events->refresh();
_tab_links ->refresh();
}
void Settings_window::show() { void Settings_window::show() {
// The plugin tab // The plugin tab
refresh();
dir_list->clear(); dir_list->clear();
plugin_load_dirs_name(); plugin_load_dirs_name();
reload_minimap_tab(); reload_minimap_tab();
...@@ -641,6 +633,10 @@ void Settings_window::plugin_load_dirs_name() { ...@@ -641,6 +633,10 @@ void Settings_window::plugin_load_dirs_name() {
void void
Settings_window::on_btn_ok_clicked() Settings_window::on_btn_ok_clicked()
{ {
_tab_states->on_btn_apply_clicked();
_tab_events->on_btn_apply_clicked();
_tab_links ->on_btn_apply_clicked();
if( _changed ) { if( _changed ) {
//on_apply_clicked(); //on_apply_clicked();
// Catch by at least the interface_graphic which will dispatch it to the classes which needs // Catch by at least the interface_graphic which will dispatch it to the classes which needs
...@@ -654,6 +650,10 @@ Settings_window::on_btn_ok_clicked() ...@@ -654,6 +650,10 @@ Settings_window::on_btn_ok_clicked()
void void
Settings_window::on_btn_cancel_clicked() Settings_window::on_btn_cancel_clicked()
{ {
_tab_states->on_btn_cancel_clicked();
_tab_events->on_btn_cancel_clicked();
_tab_links ->on_btn_cancel_clicked();
hide(); hide();
} }
...@@ -668,13 +668,12 @@ Settings_window::on_cb_tip_currentIndexChanged(int index) ...@@ -668,13 +668,12 @@ Settings_window::on_cb_tip_currentIndexChanged(int index)
void void
Settings_window::on_cb_nolinks_stateChanged(int index) Settings_window::on_cb_nolinks_stateChanged(int index)
{ {
Info::Render::_arrows_shape = index;
//_core->launch_action(Core::_STATE_RENDER_UPDATE); //_core->launch_action(Core::_STATE_RENDER_UPDATE);
} }
void void
Settings_window::on_cb_noevents_stateChanged(int index) Settings_window::on_cb_noevents_stateChanged(int index)
{ {
Info::Render::_arrows_shape = index;
//_core->launch_action(Core::_STATE_RENDER_UPDATE); //_core->launch_action(Core::_STATE_RENDER_UPDATE);
} }
...@@ -99,37 +99,30 @@ public: ...@@ -99,37 +99,30 @@ public:
~Settings_tab(); ~Settings_tab();
void refresh(); void refresh();
void updateTrace();
private: private:
void add_table_line( int &row, void add_table_line( int &row,
EntityValue *ev, EntityValue *ev,
bool used ); bool used );
void fill_table( bool used=true ); void fill_table( bool used=true );
void fill_table_from_palette( std::string ); void update_table_from_palette( std::string );
private slots: public slots:
void on_btn_apply_clicked();
void on_btn_cancel_clicked();
/*! private slots:
* \fn color_changed(const QColor &c)
* \brief Slot called when the user changes an object color in the table.
* \param c : the new color
*/
void color_changed(const QColor &c, int row = -1);
/*! /*!
* \fn visible_changed(const QColor &c) * \fn item_changed(int row = -1)
* \brief Slot called when the user changes the visible state of an object * \brief Slot called when the user changes an object color, or the
* in the table. * visibility in the table.
* \param c : the new color
*/ */
void visible_changed(const int checked, int row = -1); void item_changed(int row = -1);
void on_list_palette_currentIndexChanged(const QString &text); void on_list_palette_currentIndexChanged(const QString &text);
void on_btn_palette_cp_clicked(); void on_btn_palette_cp_clicked();
void on_btn_palette_rm_clicked(); void on_btn_palette_rm_clicked();
void on_btn_apply_clicked();
void on_btn_cancel_clicked();
void on_btn_reload_clicked(); void on_btn_reload_clicked();
}; };
...@@ -175,6 +168,7 @@ public: ...@@ -175,6 +168,7 @@ public:
* (to get them back if we cancel for example) * (to get them back if we cancel for example)
*/ */
void show(); void show();
void refresh();
public slots: public slots:
/*! /*!
......
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