From d319b5574f7eb180618cf1d8f9efb0dd6415cced Mon Sep 17 00:00:00 2001 From: mjbudd77 Date: Tue, 23 Nov 2021 21:00:41 -0500 Subject: [PATCH] Added input dialogs for setting greenzone and max undo capacities in Qt TAS editor. --- src/drivers/Qt/TasEditor/TasEditorWindow.cpp | 80 +++++++++++++++++++- src/drivers/Qt/TasEditor/TasEditorWindow.h | 2 + 2 files changed, 80 insertions(+), 2 deletions(-) diff --git a/src/drivers/Qt/TasEditor/TasEditorWindow.cpp b/src/drivers/Qt/TasEditor/TasEditorWindow.cpp index 6d520756..7123489f 100644 --- a/src/drivers/Qt/TasEditor/TasEditorWindow.cpp +++ b/src/drivers/Qt/TasEditor/TasEditorWindow.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -675,7 +676,7 @@ QMenuBar *TasEditorWindow::buildMenuBar(void) //act->setShortcut(QKeySequence(tr("Ctrl+N"))); act->setStatusTip(tr("Set Max Undo History")); //act->setIcon( style()->standardIcon( QStyle::SP_FileDialogStart ) ); - //connect(act, SIGNAL(triggered()), this, SLOT(createNewProject(void)) ); + connect(act, SIGNAL(triggered()), this, SLOT(setMaxUndoCapacity(void)) ); confMenu->addAction(act); @@ -684,7 +685,7 @@ QMenuBar *TasEditorWindow::buildMenuBar(void) //act->setShortcut(QKeySequence(tr("Ctrl+N"))); act->setStatusTip(tr("Set Greenzone Capacity")); //act->setIcon( style()->standardIcon( QStyle::SP_FileDialogStart ) ); - //connect(act, SIGNAL(triggered()), this, SLOT(createNewProject(void)) ); + connect(act, SIGNAL(triggered()), this, SLOT(setGreenzoneCapacity(void)) ); confMenu->addAction(act); @@ -2415,6 +2416,81 @@ void TasEditorWindow::tabViewChanged(int idx) bookmarks.redrawBookmarksSectionCaption(); } // ---------------------------------------------------------------------------------------------- +void TasEditorWindow::setGreenzoneCapacity(void) +{ + int ret; + int newValue = taseditorConfig.greenzoneCapacity; + QInputDialog dialog(this); + fceuCriticalSection emuLock; + + dialog.setWindowTitle( tr("Greenzone Capacity") ); + dialog.setInputMode( QInputDialog::IntInput ); + dialog.setIntRange( GREENZONE_CAPACITY_MIN, GREENZONE_CAPACITY_MAX ); + dialog.setLabelText( tr("Keep savestates for how many frames?\n(actual limit of savestates can be 5 times more than the number provided)") ); + dialog.setIntValue( newValue ); + + ret = dialog.exec(); + + if ( ret == QDialog::Accepted ) + { + newValue = dialog.intValue(); + + if (newValue < GREENZONE_CAPACITY_MIN) + { + newValue = GREENZONE_CAPACITY_MIN; + } + else if (newValue > GREENZONE_CAPACITY_MAX) + { + newValue = GREENZONE_CAPACITY_MAX; + } + if (newValue < taseditorConfig.greenzoneCapacity) + { + taseditorConfig.greenzoneCapacity = newValue; + greenzone.runGreenzoneCleaning(); + } + else + { + taseditorConfig.greenzoneCapacity = newValue; + } + } +} +// ---------------------------------------------------------------------------------------------- +void TasEditorWindow::setMaxUndoCapacity(void) +{ + int ret; + int newValue = taseditorConfig.maxUndoLevels; + QInputDialog dialog(this); + fceuCriticalSection emuLock; + + dialog.setWindowTitle( tr("Max undo levels") ); + dialog.setInputMode( QInputDialog::IntInput ); + dialog.setIntRange( UNDO_LEVELS_MIN, UNDO_LEVELS_MAX ); + dialog.setLabelText( tr("Keep history of how many changes?") ); + dialog.setIntValue( newValue ); + + ret = dialog.exec(); + + if ( ret == QDialog::Accepted ) + { + newValue = dialog.intValue(); + + if (newValue < UNDO_LEVELS_MIN) + { + newValue = UNDO_LEVELS_MIN; + } + else if (newValue > UNDO_LEVELS_MAX) + { + newValue = UNDO_LEVELS_MAX; + } + if (newValue != taseditorConfig.maxUndoLevels) + { + taseditorConfig.maxUndoLevels = newValue; + history.updateHistoryLogSize(); + selection.updateHistoryLogSize(); + } + } +} +// ---------------------------------------------------------------------------------------------- void TasEditorWindow::loadClipboard(const char *txt) { clipboard->setText( tr(txt), QClipboard::Clipboard ); diff --git a/src/drivers/Qt/TasEditor/TasEditorWindow.h b/src/drivers/Qt/TasEditor/TasEditorWindow.h index bcaa4d6e..c65940cd 100644 --- a/src/drivers/Qt/TasEditor/TasEditorWindow.h +++ b/src/drivers/Qt/TasEditor/TasEditorWindow.h @@ -354,6 +354,8 @@ class TasEditorWindow : public QDialog void upperMarkerLabelClicked(void); void lowerMarkerLabelClicked(void); void histTreeItemActivated(QTreeWidgetItem*,int); + void setGreenzoneCapacity(void); + void setMaxUndoCapacity(void); void tabViewChanged(int); friend class RECORDER;