Skip to content

Commit

Permalink
feat: add built-in batches
Browse files Browse the repository at this point in the history
  • Loading branch information
hello-adam committed Nov 27, 2021
1 parent d23d63c commit 59b1a5f
Show file tree
Hide file tree
Showing 4 changed files with 225 additions and 8 deletions.
5 changes: 5 additions & 0 deletions src/hobbits-gui/batches.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/">
<file>batches/byte_align.hbat</file>
</qresource>
</RCC>
180 changes: 180 additions & 0 deletions src/hobbits-gui/batches/byte_align.hbat
Original file line number Diff line number Diff line change
@@ -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": [
]
}
]
}
46 changes: 38 additions & 8 deletions src/hobbits-gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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<QString, Parameters> addition, QPair<QString, Parameters> removal)
{
populatePluginActionMenu("recently_imported", ui->menuImport_Recent,
Expand Down
2 changes: 2 additions & 0 deletions src/hobbits-gui/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ private slots:
QPair<QString, Parameters> removal = QPair<QString, Parameters>());
void populateRecentBatchesMenu(QString addition = QString(), QString removal = QString());

void populatePresetBatchesMenu();

void sendBitContainerPreview();
static void processBitPreview(QSharedPointer<BitContainerPreview> preview, AbstractParameterEditor* editor);

Expand Down

0 comments on commit 59b1a5f

Please sign in to comment.