Example #1
0
inline void
ProfileListWidget::DeleteClicked()
{
  assert(GetList().GetCursorIndex() < list.size());

  const auto &item = list[GetList().GetCursorIndex()];

  const auto password_result = CheckProfileFilePassword(item.path);
  switch (password_result) {
  case ProfilePasswordResult::UNPROTECTED:
    if (!ConfirmDeleteProfile(item.name))
      return;

    break;

  case ProfilePasswordResult::MATCH:
    break;

  case ProfilePasswordResult::MISMATCH:
  case ProfilePasswordResult::CANCEL:
    CheckProfilePasswordResult(password_result);
    return;
  }

  File::Delete(item.path);
  UpdateList();
}
Example #2
0
static bool
SelectProfile(Path path)
{
  try {
    if (!CheckProfilePasswordResult(CheckProfileFilePassword(path)))
      return false;
  } catch (const std::runtime_error &e) {
    ShowError(e, _("Password"));
    return false;
  }

  Profile::SetFiles(path);

  if (RelativePath(path) == nullptr)
    /* When a profile from a secondary data path is used, this path
       becomes the primary data path */
    SetPrimaryDataPath(path.GetParent());

  File::Touch(path);
  return true;
}