Adopt better method for setting custom pos using the pos dropdown
Make it actually work properly
This commit is contained in:
		
							parent
							
								
									f881df2415
								
							
						
					
					
						commit
						7246965e00
					
				@ -581,7 +581,6 @@ private:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  QString current_background = "default";
 | 
					  QString current_background = "default";
 | 
				
			||||||
  QString current_side = "";
 | 
					  QString current_side = "";
 | 
				
			||||||
  int temp_side_index = -1;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  QBrush free_brush;
 | 
					  QBrush free_brush;
 | 
				
			||||||
  QBrush lfp_brush;
 | 
					  QBrush lfp_brush;
 | 
				
			||||||
@ -835,6 +834,7 @@ private slots:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  void on_emote_dropdown_changed(int p_index);
 | 
					  void on_emote_dropdown_changed(int p_index);
 | 
				
			||||||
  void on_pos_dropdown_changed(int p_index);
 | 
					  void on_pos_dropdown_changed(int p_index);
 | 
				
			||||||
 | 
					  void on_pos_dropdown_changed(QString p_text);
 | 
				
			||||||
  void on_pos_remove_clicked();
 | 
					  void on_pos_remove_clicked();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void on_iniswap_dropdown_changed(int p_index);
 | 
					  void on_iniswap_dropdown_changed(int p_index);
 | 
				
			||||||
 | 
				
			|||||||
@ -308,6 +308,8 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  connect(ui_pos_dropdown, SIGNAL(currentIndexChanged(int)), this,
 | 
					  connect(ui_pos_dropdown, SIGNAL(currentIndexChanged(int)), this,
 | 
				
			||||||
          SLOT(on_pos_dropdown_changed(int)));
 | 
					          SLOT(on_pos_dropdown_changed(int)));
 | 
				
			||||||
 | 
					  connect(ui_pos_dropdown, SIGNAL(editTextChanged(QString)), this,
 | 
				
			||||||
 | 
					          SLOT(on_pos_dropdown_changed(QString)));
 | 
				
			||||||
  connect(ui_pos_remove, SIGNAL(clicked()), this, SLOT(on_pos_remove_clicked()));
 | 
					  connect(ui_pos_remove, SIGNAL(clicked()), this, SLOT(on_pos_remove_clicked()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  connect(ui_iniswap_dropdown, SIGNAL(currentIndexChanged(int)), this,
 | 
					  connect(ui_iniswap_dropdown, SIGNAL(currentIndexChanged(int)), this,
 | 
				
			||||||
@ -728,6 +730,7 @@ void Courtroom::set_widgets()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  set_size_and_pos(ui_pos_dropdown, "pos_dropdown");
 | 
					  set_size_and_pos(ui_pos_dropdown, "pos_dropdown");
 | 
				
			||||||
  ui_pos_dropdown->setEditable(true);
 | 
					  ui_pos_dropdown->setEditable(true);
 | 
				
			||||||
 | 
					  ui_pos_dropdown->setInsertPolicy(QComboBox::NoInsert);
 | 
				
			||||||
  ui_pos_dropdown->setToolTip(
 | 
					  ui_pos_dropdown->setToolTip(
 | 
				
			||||||
      tr("Set your character's supplementary background."));
 | 
					      tr("Set your character's supplementary background."));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1322,15 +1325,8 @@ void Courtroom::set_side(QString p_side, bool block_signals)
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  // We will only get there if we failed the last step
 | 
					  // We will only get there if we failed the last step
 | 
				
			||||||
  if (block_signals)
 | 
					  ui_pos_dropdown->setEditText(f_side);
 | 
				
			||||||
    ui_pos_dropdown->blockSignals(true);
 | 
					  ui_pos_remove->show();
 | 
				
			||||||
  if (temp_side_index > -1)
 | 
					 | 
				
			||||||
    ui_pos_dropdown->removeItem(temp_side_index);
 | 
					 | 
				
			||||||
  ui_pos_dropdown->addItem(f_side);
 | 
					 | 
				
			||||||
  temp_side_index = ui_pos_dropdown->count()-1;
 | 
					 | 
				
			||||||
  ui_pos_dropdown->setCurrentIndex(temp_side_index);
 | 
					 | 
				
			||||||
  if (block_signals)
 | 
					 | 
				
			||||||
    ui_pos_dropdown->blockSignals(false);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Courtroom::set_pos_dropdown(QStringList pos_dropdowns)
 | 
					void Courtroom::set_pos_dropdown(QStringList pos_dropdowns)
 | 
				
			||||||
@ -1338,13 +1334,11 @@ void Courtroom::set_pos_dropdown(QStringList pos_dropdowns)
 | 
				
			|||||||
  // Block the signals to prevent setCurrentIndex from triggering a pos change
 | 
					  // Block the signals to prevent setCurrentIndex from triggering a pos change
 | 
				
			||||||
  ui_pos_dropdown->blockSignals(true);
 | 
					  ui_pos_dropdown->blockSignals(true);
 | 
				
			||||||
  pos_dropdown_list = pos_dropdowns;
 | 
					  pos_dropdown_list = pos_dropdowns;
 | 
				
			||||||
  temp_side_index = -1;
 | 
					 | 
				
			||||||
  ui_pos_dropdown->clear();
 | 
					  ui_pos_dropdown->clear();
 | 
				
			||||||
  ui_pos_dropdown->addItems(pos_dropdown_list);
 | 
					  ui_pos_dropdown->addItems(pos_dropdown_list);
 | 
				
			||||||
  // Custom pos
 | 
					 | 
				
			||||||
  if (current_side != "" && !pos_dropdown_list.contains(current_side)) {
 | 
					  if (current_side != "" && !pos_dropdown_list.contains(current_side)) {
 | 
				
			||||||
    ui_pos_dropdown->addItem(current_side);
 | 
					    ui_pos_dropdown->setEditText(current_side);
 | 
				
			||||||
    temp_side_index = ui_pos_dropdown->count() - 1;
 | 
					    ui_pos_remove->show();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  // Unblock the signals so the element can be used for setting pos again
 | 
					  // Unblock the signals so the element can be used for setting pos again
 | 
				
			||||||
  ui_pos_dropdown->blockSignals(false);
 | 
					  ui_pos_dropdown->blockSignals(false);
 | 
				
			||||||
@ -4281,37 +4275,27 @@ void Courtroom::on_pos_dropdown_changed(int p_index)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  if (p_index < 0)
 | 
					  if (p_index < 0)
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
 | 
					  on_pos_dropdown_changed(ui_pos_dropdown->itemText(p_index));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void Courtroom::on_pos_dropdown_changed(QString p_text)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
  toggle_judge_buttons(false);
 | 
					  toggle_judge_buttons(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  QString f_pos = ui_pos_dropdown->itemText(p_index);
 | 
					  if (p_text == "jud")
 | 
				
			||||||
 | 
					 | 
				
			||||||
  if (f_pos == "")
 | 
					 | 
				
			||||||
    return;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  if (f_pos == "jud")
 | 
					 | 
				
			||||||
    toggle_judge_buttons(true);
 | 
					    toggle_judge_buttons(true);
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
  ui_pos_remove->show();
 | 
					  ui_pos_remove->show();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  current_side = f_pos;
 | 
					  current_side = p_text;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // YEAH SENDING LIKE 20 PACKETS IF THE USER SCROLLS THROUGH, GREAT IDEA
 | 
					  // YEAH SENDING LIKE 20 PACKETS IF THE USER SCROLLS THROUGH, GREAT IDEA
 | 
				
			||||||
  // how about this instead
 | 
					  // how about this instead
 | 
				
			||||||
  set_side(f_pos);
 | 
					  set_side(p_text);
 | 
				
			||||||
  if (temp_side_index > -1 && p_index == temp_side_index) {
 | 
					 | 
				
			||||||
    ui_pos_dropdown->removeItem(temp_side_index);
 | 
					 | 
				
			||||||
    temp_side_index = -1;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Courtroom::on_pos_remove_clicked()
 | 
					void Courtroom::on_pos_remove_clicked()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  if (temp_side_index > -1) {
 | 
					 | 
				
			||||||
    ui_pos_dropdown->removeItem(temp_side_index);
 | 
					 | 
				
			||||||
    temp_side_index = -1;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  QString default_side = ao_app->get_char_side(current_char);
 | 
					  QString default_side = ao_app->get_char_side(current_char);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for (int i = 0; i < ui_pos_dropdown->count(); ++i) {
 | 
					  for (int i = 0; i < ui_pos_dropdown->count(); ++i) {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user