From 59b1a5f14b2bf3bc60d75363958097a623b8b675 Mon Sep 17 00:00:00 2001 From: Adam Nash Date: Sat, 27 Nov 2021 00:46:00 -0500 Subject: [PATCH] feat: add built-in batches --- src/hobbits-gui/batches.qrc | 5 + src/hobbits-gui/batches/byte_align.hbat | 180 ++++++++++++++++++++++++ src/hobbits-gui/mainwindow.cpp | 46 ++++-- src/hobbits-gui/mainwindow.h | 2 + 4 files changed, 225 insertions(+), 8 deletions(-) create mode 100644 src/hobbits-gui/batches.qrc create mode 100644 src/hobbits-gui/batches/byte_align.hbat diff --git a/src/hobbits-gui/batches.qrc b/src/hobbits-gui/batches.qrc new file mode 100644 index 00000000..91545942 --- /dev/null +++ b/src/hobbits-gui/batches.qrc @@ -0,0 +1,5 @@ + + + batches/byte_align.hbat + + diff --git a/src/hobbits-gui/batches/byte_align.hbat b/src/hobbits-gui/batches/byte_align.hbat new file mode 100644 index 00000000..8518173f --- /dev/null +++ b/src/hobbits-gui/batches/byte_align.hbat @@ -0,0 +1,180 @@ +{ + "steps": [ + { + "action": { + "name": "Take Skip", + "state": { + "deinterleave_channels": 1, + "frame_based": false, + "interleaved": false, + "take_skip_string": "s3t*" + }, + "type": 2 + }, + "editorPosition": { + "x": -546, + "y": -642 + }, + "id": "{0b225e01-6f5a-4f67-a244-ecd48a761221}", + "inputs": [ + { + "outputPosition": 0, + "stepId": "{d1d149a7-6cab-465a-a038-bf8601f6dabb}" + } + ] + }, + { + "action": { + "name": "Take Skip", + "state": { + "deinterleave_channels": 1, + "frame_based": false, + "interleaved": false, + "take_skip_string": "s4t*" + }, + "type": 2 + }, + "editorPosition": { + "x": -546, + "y": -499 + }, + "id": "{65266ed0-2537-44fb-a701-287cb78243f3}", + "inputs": [ + { + "outputPosition": 0, + "stepId": "{d1d149a7-6cab-465a-a038-bf8601f6dabb}" + } + ] + }, + { + "action": { + "name": "Take Skip", + "state": { + "deinterleave_channels": 1, + "frame_based": false, + "interleaved": false, + "take_skip_string": "s1t*" + }, + "type": 2 + }, + "editorPosition": { + "x": -547, + "y": -928 + }, + "id": "{6653b5d2-a26d-4984-bd60-53053ea83ab3}", + "inputs": [ + { + "outputPosition": 0, + "stepId": "{d1d149a7-6cab-465a-a038-bf8601f6dabb}" + } + ] + }, + { + "action": { + "name": "Take Skip", + "state": { + "deinterleave_channels": 1, + "frame_based": false, + "interleaved": false, + "take_skip_string": "s2t*" + }, + "type": 2 + }, + "editorPosition": { + "x": -545, + "y": -784 + }, + "id": "{7aafc2be-3e37-4f1a-a409-29ffd3330445}", + "inputs": [ + { + "outputPosition": 0, + "stepId": "{d1d149a7-6cab-465a-a038-bf8601f6dabb}" + } + ] + }, + { + "action": { + "name": "Take Skip", + "state": { + "deinterleave_channels": 1, + "frame_based": false, + "interleaved": false, + "take_skip_string": "s5t*" + }, + "type": 2 + }, + "editorPosition": { + "x": -542, + "y": -360 + }, + "id": "{8c4b8a08-5a97-4302-84cc-f28ee6853f2a}", + "inputs": [ + { + "outputPosition": 0, + "stepId": "{d1d149a7-6cab-465a-a038-bf8601f6dabb}" + } + ] + }, + { + "action": { + "name": "Take Skip", + "state": { + "deinterleave_channels": 1, + "frame_based": false, + "interleaved": false, + "take_skip_string": "s6t*" + }, + "type": 2 + }, + "editorPosition": { + "x": -534, + "y": -215 + }, + "id": "{b6689e88-c491-41d9-bbb5-a4e8c8691534}", + "inputs": [ + { + "outputPosition": 0, + "stepId": "{d1d149a7-6cab-465a-a038-bf8601f6dabb}" + } + ] + }, + { + "action": { + "name": "Take Skip", + "state": { + "deinterleave_channels": 1, + "frame_based": false, + "interleaved": false, + "take_skip_string": "s7t*" + }, + "type": 2 + }, + "editorPosition": { + "x": -526, + "y": -66 + }, + "id": "{b832bd55-6554-442f-92fa-055258a7566e}", + "inputs": [ + { + "outputPosition": 0, + "stepId": "{d1d149a7-6cab-465a-a038-bf8601f6dabb}" + } + ] + }, + { + "action": { + "name": "Batch Input", + "state": { + }, + "type": 6 + }, + "editorPosition": { + "x": -1049, + "y": -295 + }, + "id": "{d1d149a7-6cab-465a-a038-bf8601f6dabb}", + "inputs": [ + ] + } + ] +} diff --git a/src/hobbits-gui/mainwindow.cpp b/src/hobbits-gui/mainwindow.cpp index b8225ee0..786e7740 100644 --- a/src/hobbits-gui/mainwindow.cpp +++ b/src/hobbits-gui/mainwindow.cpp @@ -66,6 +66,7 @@ MainWindow::MainWindow(QString extraPluginPath, QString configFilePath, QWidget // More menu initialization populateRecentBatchesMenu(); + populatePresetBatchesMenu(); // Configure Bit Container View ui->tv_bitContainers->setModel(m_bitContainerManager->getTreeModel().data()); @@ -594,17 +595,25 @@ void MainWindow::setCurrentBitContainer() } } +const QString CONFIRM_BITS_DELETION = "Confirm Bits Deletion"; + void MainWindow::deleteCurrentBitcontainer() { if (!currContainer().isNull()) { QMessageBox::StandardButton reply; - reply = QMessageBox::question( + auto confirm = SettingsManager::getUiSetting(CONFIRM_BITS_DELETION); + if (!confirm.isValid() || confirm.toBool()) { + reply = QMessageBox::question( this, "Delete Bits Confirmation", QString("Are you sure you want to delete bit container '%1'?").arg(currContainer()->name()), - QMessageBox::Yes | QMessageBox::No); - if (reply != QMessageBox::Yes) { - return; + QMessageBox::YesToAll | QMessageBox::Yes | QMessageBox::No); + if (reply == QMessageBox::YesToAll) { + SettingsManager::setUiSetting(CONFIRM_BITS_DELETION, QVariant(false)); + } + else if (reply != QMessageBox::Yes) { + return; + } } ui->tb_removeBitContainer->setEnabled(false); @@ -615,13 +624,19 @@ void MainWindow::deleteCurrentBitcontainer() void MainWindow::deleteAllBitContainers() { QMessageBox::StandardButton reply; - reply = QMessageBox::question( + auto confirm = SettingsManager::getUiSetting(CONFIRM_BITS_DELETION); + if (!confirm.isValid() || confirm.toBool()) { + reply = QMessageBox::question( this, "Delete Bits Confirmation", QString("Are you sure you want to delete all bit containers?"), - QMessageBox::Yes | QMessageBox::No); - if (reply != QMessageBox::Yes) { - return; + QMessageBox::YesToAll | QMessageBox::Yes | QMessageBox::No); + if (reply == QMessageBox::YesToAll) { + SettingsManager::setUiSetting(CONFIRM_BITS_DELETION, QVariant(false)); + } + else if (reply != QMessageBox::Yes) { + return; + } } ui->tb_removeBitContainer->setEnabled(false); @@ -916,6 +931,21 @@ void MainWindow::populateRecentBatchesMenu(QString addition, QString removal) } +void MainWindow::populatePresetBatchesMenu() +{ + QMenu* builtInBatchMenu = ui->menuFile->addMenu("Apply Built-in Batch"); + + for (QFileInfo batch: QDir(":/batches").entryInfoList()) { + QString batchPath = batch.absoluteFilePath(); + builtInBatchMenu->addAction( + batch.baseName(), + [this, batchPath]() { + this->applyBatchFile(batchPath); + }); + } +} + + void MainWindow::populateRecentImportsMenu(QPair addition, QPair removal) { populatePluginActionMenu("recently_imported", ui->menuImport_Recent, diff --git a/src/hobbits-gui/mainwindow.h b/src/hobbits-gui/mainwindow.h index 73fb8956..5662966a 100644 --- a/src/hobbits-gui/mainwindow.h +++ b/src/hobbits-gui/mainwindow.h @@ -99,6 +99,8 @@ private slots: QPair removal = QPair()); void populateRecentBatchesMenu(QString addition = QString(), QString removal = QString()); + void populatePresetBatchesMenu(); + void sendBitContainerPreview(); static void processBitPreview(QSharedPointer preview, AbstractParameterEditor* editor);