mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2024-11-16 07:47:39 +01:00
Allow deactivating the warning before replaying a turn
This commit is contained in:
parent
5b1e228fb5
commit
846374e37b
4 changed files with 35 additions and 16 deletions
|
@ -843,18 +843,22 @@ void MainWindow::onHistoryReplayTurn()
|
|||
if (m_game == NULL)
|
||||
return;
|
||||
|
||||
// Ask for a confirmation, because this may lead to data loss
|
||||
QString msg = _q("Replaying this turn will modify the game history "
|
||||
"by deleting the turns after the displayed one (i.e. "
|
||||
"turns \"in the future\").");
|
||||
QMessageBox confirmationBox(QMessageBox::Question, _q("Eliot"), msg,
|
||||
QMessageBox::Yes | QMessageBox::No, this);
|
||||
confirmationBox.setInformativeText(_q("Do you want to continue?"));
|
||||
confirmationBox.setDefaultButton(QMessageBox::Yes);
|
||||
confirmationBox.setEscapeButton(QMessageBox::No);
|
||||
int ret = confirmationBox.exec();
|
||||
if (ret != QMessageBox::Yes)
|
||||
return;
|
||||
QSettings settings(ORGANIZATION, PACKAGE_NAME);
|
||||
QVariant warn = settings.value(PrefsDialog::kINTF_WARN_REPLAY_TURN);
|
||||
if (warn.isNull() || warn.toBool()) {
|
||||
// Ask for a confirmation, because this may lead to data loss
|
||||
QString msg = _q("Replaying this turn will modify the game history "
|
||||
"by deleting the turns after the displayed one (i.e. "
|
||||
"turns \"in the future\").");
|
||||
QMessageBox confirmationBox(QMessageBox::Question, _q("Eliot"), msg,
|
||||
QMessageBox::Yes | QMessageBox::No, this);
|
||||
confirmationBox.setInformativeText(_q("Do you want to continue?"));
|
||||
confirmationBox.setDefaultButton(QMessageBox::Yes);
|
||||
confirmationBox.setEscapeButton(QMessageBox::No);
|
||||
int ret = confirmationBox.exec();
|
||||
if (ret != QMessageBox::Yes)
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int currTurn = m_game->getCurrTurn();
|
||||
m_game->clearFuture();
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
const QString PrefsDialog::kINTF_ALIGN_HISTORY = "Interface/AlignHistory";
|
||||
const QString PrefsDialog::kINTF_DIC_PATH = "Interface/DicPath";
|
||||
const QString PrefsDialog::kINTF_WARN_REPLAY_TURN = "Interface/WarnReplayTurn";
|
||||
|
||||
|
||||
PrefsDialog::PrefsDialog(QWidget *iParent)
|
||||
|
@ -42,8 +43,10 @@ PrefsDialog::PrefsDialog(QWidget *iParent)
|
|||
{
|
||||
// Interface settings
|
||||
QSettings qs(ORGANIZATION, PACKAGE_NAME);
|
||||
checkBoxIntfAlignHistory->setChecked(qs.value(kINTF_ALIGN_HISTORY).toBool());
|
||||
lineEditIntfDicPath->setText(qs.value(kINTF_DIC_PATH, "").toString());
|
||||
checkBoxIntfAlignHistory->setChecked(qs.value(kINTF_ALIGN_HISTORY).toBool());
|
||||
QVariant warnReplayTurn = qs.value(kINTF_WARN_REPLAY_TURN);
|
||||
checkBoxIntfWarnReplayTurn->setChecked(warnReplayTurn.isNull() || warnReplayTurn.toBool());
|
||||
|
||||
// Duplicate settings
|
||||
checkBoxDuplRefuseInvalid->setChecked(Settings::Instance().getBool("duplicate.reject-invalid"));
|
||||
|
@ -92,13 +95,14 @@ void PrefsDialog::updateSettings()
|
|||
{
|
||||
// Interface settings
|
||||
QSettings qs(ORGANIZATION, PACKAGE_NAME);
|
||||
qs.setValue(kINTF_DIC_PATH, lineEditIntfDicPath->text());
|
||||
if (qs.value(kINTF_ALIGN_HISTORY).toBool() != checkBoxIntfAlignHistory->isChecked())
|
||||
{
|
||||
// We need to redraw the history widget
|
||||
shouldEmitUpdate = true;
|
||||
qs.setValue(kINTF_ALIGN_HISTORY, checkBoxIntfAlignHistory->isChecked());
|
||||
}
|
||||
qs.setValue(kINTF_DIC_PATH, lineEditIntfDicPath->text());
|
||||
qs.setValue(kINTF_WARN_REPLAY_TURN, checkBoxIntfWarnReplayTurn->isChecked());
|
||||
|
||||
// Duplicate settings
|
||||
Settings::Instance().setBool("duplicate.reject-invalid",
|
||||
|
|
|
@ -36,6 +36,7 @@ public:
|
|||
|
||||
static const QString kINTF_ALIGN_HISTORY;
|
||||
static const QString kINTF_DIC_PATH;
|
||||
static const QString kINTF_WARN_REPLAY_TURN;
|
||||
|
||||
public slots:
|
||||
/// Update the settings when the user selects "OK"
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>401</width>
|
||||
<height>432</height>
|
||||
<width>404</width>
|
||||
<height>437</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
|
@ -66,6 +66,16 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxIntfWarnReplayTurn" >
|
||||
<property name="text" >
|
||||
<string>_("Warn before replaying a turn")</string>
|
||||
</property>
|
||||
<property name="checked" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
Loading…
Reference in a new issue