--User changes

-Add toolbar buttons to switch some rendering options without having to open the options dialog.

--Bug fixes
 -Only update summary on render completion, no need to constantly update it.
 -Properly handle cancel even on variations dialog.

--Code changes
 -Add small function ShutdownAndRecreateFromOptions() to wrap shutting down the timer and recreating the renderer.
 -Use the overridden accept() and reject() functions more consistently across dialogs.
This commit is contained in:
mfeemster
2015-07-29 17:25:02 -07:00
parent e16c6a825f
commit 2317be332a
12 changed files with 268 additions and 76 deletions

View File

@ -26,23 +26,6 @@ FractoriumVariationsDialog::FractoriumVariationsDialog(FractoriumSettings* setti
connect(ui.SelectAllButton, SIGNAL(clicked(bool)), this, SLOT(OnSelectAllButtonClicked(bool)), Qt::QueuedConnection);
connect(ui.InvertSelectionButton, SIGNAL(clicked(bool)), this, SLOT(OnInvertSelectionButtonClicked(bool)), Qt::QueuedConnection);
connect(ui.SelectNoneButton, SIGNAL(clicked(bool)), this, SLOT(OnSelectNoneButtonClicked(bool)), Qt::QueuedConnection);
connect(ui.ButtonBox, SIGNAL(accepted()), this, SLOT(Accept()));
}
/// <summary>
/// Copy the values of the checkboxes to the map.
/// </summary>
void FractoriumVariationsDialog::SyncSettings()
{
QMap<QString, QVariant> m;
ForEachCell([&](QTableWidgetItem* cb)
{
if (!cb->text().isEmpty())
m[cb->text()] = cb->checkState() == Qt::CheckState::Checked;
});
m_Settings->Variations(m);
}
/// <summary>
@ -85,6 +68,32 @@ void FractoriumVariationsDialog::ForEachSelectedCell(std::function<void(QTableWi
table->model()->layoutChanged();
}
/// <summary>
/// Copy the values of the checkboxes to the map.
/// </summary>
void FractoriumVariationsDialog::SyncSettings()
{
QMap<QString, QVariant> m;
ForEachCell([&](QTableWidgetItem* cb)
{
if (!cb->text().isEmpty())
m[cb->text()] = cb->checkState() == Qt::CheckState::Checked;
});
m_Settings->Variations(m);
}
/// <summary>
/// Return a const reference to the map.
/// This will contains the state of the checkboxes after
/// the user clicks ok.
/// </summary>
const QMap<QString, QVariant>& FractoriumVariationsDialog::Map()
{
return m_Vars;
}
/// <summary>
/// Check all of the checkboxes.
/// </summary>
@ -172,19 +181,21 @@ void FractoriumVariationsDialog::OnVariationsTableItemChanged(QTableWidgetItem*
/// Called when the user clicks ok.
/// Copy the state of the checkboxes to the map.
/// </summary>
void FractoriumVariationsDialog::Accept()
void FractoriumVariationsDialog::accept()
{
CheckBoxesToMap();
GuiToData();
QDialog::accept();
}
/// <summary>
/// Return a const reference to the map.
/// This will contains the state of the checkboxes after
/// the user clicks ok.
/// Called when the user clicks cancel.
/// Reset the state of the the checkboxes to what the map previously was
/// when the dialog was shown.
/// </summary>
const QMap<QString, QVariant>& FractoriumVariationsDialog::Map()
void FractoriumVariationsDialog::reject()
{
return m_Vars;
DataToGui();
QDialog::reject();
}
/// <summary>
@ -193,10 +204,34 @@ const QMap<QString, QVariant>& FractoriumVariationsDialog::Map()
/// <param name="e">Event, passed to base.</param>
void FractoriumVariationsDialog::showEvent(QShowEvent* e)
{
MapToCheckBoxes();
DataToGui();
QDialog::showEvent(e);
}
/// <summary>
/// Copy the values in the map to the state of the checkboxes.
/// </summary>
void FractoriumVariationsDialog::DataToGui()
{
ForEachCell([&](QTableWidgetItem* cb)
{
if (auto var = m_VariationList.GetVariation(cb->text().toStdString()))
SetCheckFromMap(cb, var);
});
}
/// <summary>
/// Copy the state of the checkboxes to the map.
/// </summary>
void FractoriumVariationsDialog::GuiToData()
{
ForEachCell([&](QTableWidgetItem* cb)
{
if (auto var = m_VariationList.GetVariation(cb->text().toStdString()))
m_Vars[cb->text()] = (cb->checkState() == Qt::Checked);
});
}
/// <summary>
/// Set the state of the passed in table item checkbox based on the boolean contained
/// in the map for the passed in variation.
@ -216,27 +251,3 @@ void FractoriumVariationsDialog::SetCheckFromMap(QTableWidgetItem* cb, const Var
cb->setCheckState(chk ? Qt::Checked : Qt::Unchecked);
}
}
/// <summary>
/// Copy the values in the map to the state of the checkboxes.
/// </summary>
void FractoriumVariationsDialog::MapToCheckBoxes()
{
ForEachCell([&](QTableWidgetItem* cb)
{
if (auto var = m_VariationList.GetVariation(cb->text().toStdString()))
SetCheckFromMap(cb, var);
});
}
/// <summary>
/// Copy the state of the checkboxes to the map.
/// </summary>
void FractoriumVariationsDialog::CheckBoxesToMap()
{
ForEachCell([&](QTableWidgetItem* cb)
{
if (auto var = m_VariationList.GetVariation(cb->text().toStdString()))
m_Vars[cb->text()] = (cb->checkState() == Qt::Checked);
});
}