Skip to content

Commit

Permalink
Added check in case user cancels export history. Added disable close …
Browse files Browse the repository at this point in the history
…env button when scans are running.
  • Loading branch information
Arthur Glowacki committed Oct 30, 2024
1 parent bdec347 commit 717105d
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 36 deletions.
86 changes: 50 additions & 36 deletions src/mvc/LiveMapsElementsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,35 +347,38 @@ void LiveMapsElementsWidget::exportHistory()
"Scan History", apath,
tr("JSON (*.json)"));

if (!fileName.endsWith(".json"))
if(fileName.length() > 0)
{
fileName += ".json";
}
QFile file(fileName);
if (!fileName.endsWith(".json"))
{
fileName += ".json";
}
QFile file(fileName);

if (!file.open(QIODevice::WriteOnly))
{
QMessageBox::warning(nullptr, "Export History", "The file is in read only mode");
}
QString msg;
if (false == _qserverComm->get_scan_history(msg, _finished_scans, true))
{
QMessageBox::warning(nullptr, "Export History", "Failed to get scan history from QServer");
_scan_queue_widget->newDataArrived( msg );
}
if (!file.open(QIODevice::WriteOnly))
{
QMessageBox::warning(nullptr, "Export History", "The file is in read only mode");
}
QString msg;
if (false == _qserverComm->get_scan_history(msg, _finished_scans, true))
{
QMessageBox::warning(nullptr, "Export History", "Failed to get scan history from QServer");
_scan_queue_widget->newDataArrived( msg );
}

file.write(msg.toUtf8());
file.close();
file.write(msg.toUtf8());
file.close();

QMessageBox::information(this, "Export History", "Saved!");
QMessageBox::information(this, "Export History", "Saved!");

if (false == _qserverComm->clear_history(msg))
{
QMessageBox::warning(nullptr, "Export History", "Failed to clear scan history from QServer");
_scan_queue_widget->newDataArrived( msg );
}
if (false == _qserverComm->clear_history(msg))
{
QMessageBox::warning(nullptr, "Export History", "Failed to clear scan history from QServer");
_scan_queue_widget->newDataArrived( msg );
}

getQueuedScans();
getQueuedScans();
}
}

//---------------------------------------------------------------------------
Expand Down Expand Up @@ -403,21 +406,32 @@ void LiveMapsElementsWidget::callOpenEnv()

void LiveMapsElementsWidget::callCloseEnv()
{
QString msg;
if(_qserverComm == nullptr)
{
updateIp();
}
if (false == _qserverComm->close_env(msg))
{
//_scan_queue_widget->newDataArrived( msg );
}
else
QMessageBox msgBox;
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
msgBox.setIcon(QMessageBox::Question);
msgBox.setText("Are you sure you want to close the environment? This will kill the QServer run process. Only do this if you need to restart.");

int ret = msgBox.exec();

if (ret == QMessageBox::Yes)
{
//_scan_queue_widget->updateQueuedItems(_queued_scans, _running_scan);
}
QString msg;
if(_qserverComm == nullptr)
{
updateIp();
}
if (false == _qserverComm->close_env(msg))
{
//_scan_queue_widget->newDataArrived( msg );
}
else
{
//_scan_queue_widget->updateQueuedItems(_queued_scans, _running_scan);
}

_scan_queue_widget->newDataArrived( msg );
_scan_queue_widget->newDataArrived( msg );
}
}

//---------------------------------------------------------------------------
Expand Down
8 changes: 8 additions & 0 deletions src/mvc/ScanQueueWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,14 @@ void ScanQueueWidget::updateQueuedItems(std::vector<BlueskyPlan> &finished_plans
{
_scan_queue_table_model->setAllData(finished_plans, queued_plans, running_plan);
_scan_queue_table_view->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents);
if( running_plan.uuid.length() > 0)
{
_btn_close_env->setEnabled(false);
}
else
{
_btn_close_env->setEnabled(true);
}
}

//---------------------------------------------------------------------------
Expand Down

0 comments on commit 717105d

Please sign in to comment.