* @brief Handles displaying parsed password entry content in the main window. * @example * void result = MainWindow::passShowHandler(p_output); * // Updates the UI with parsed fields and emits * passShowHandlerFinished(output) * * @param p_output - The raw output text containing the password entry data. * @return void - This function does not return a value. */
| 441 | * @return void - This function does not return a value. |
| 442 | */ |
| 443 | void MainWindow::passShowHandler(const QString &p_output) { |
| 444 | QStringList templ = QtPassSettings::isUseTemplate() |
| 445 | ? QtPassSettings::getPassTemplate().split("\n") |
| 446 | : QStringList(); |
| 447 | bool allFields = |
| 448 | QtPassSettings::isUseTemplate() && QtPassSettings::isTemplateAllFields(); |
| 449 | FileContent fileContent = FileContent::parse(p_output, templ, allFields); |
| 450 | QString output = p_output; |
| 451 | QString password = fileContent.getPassword(); |
| 452 | |
| 453 | // set clipped text |
| 454 | m_qtPass->setClippedText(password, p_output); |
| 455 | |
| 456 | // first clear the current view: |
| 457 | clearTemplateWidgets(); |
| 458 | |
| 459 | // show what is needed: |
| 460 | if (QtPassSettings::isHideContent()) { |
| 461 | output = "***" + tr("Content hidden") + "***"; |
| 462 | } else if (!QtPassSettings::isDisplayAsIs()) { |
| 463 | if (!password.isEmpty()) { |
| 464 | // set the password, it is hidden if needed in addToGridLayout |
| 465 | addToGridLayout(0, tr("Password"), password); |
| 466 | } |
| 467 | |
| 468 | NamedValues namedValues = fileContent.getNamedValues(); |
| 469 | for (int j = 0; j < namedValues.length(); ++j) { |
| 470 | const NamedValue &nv = namedValues.at(j); |
| 471 | addToGridLayout(j + 1, nv.name, nv.value); |
| 472 | } |
| 473 | if (ui->gridLayout->count() == 0) { |
| 474 | ui->verticalLayoutPassword->setSpacing(0); |
| 475 | } else { |
| 476 | ui->verticalLayoutPassword->setSpacing(6); |
| 477 | } |
| 478 | |
| 479 | output = fileContent.getRemainingDataForDisplay(); |
| 480 | } |
| 481 | |
| 482 | if (QtPassSettings::isUseAutoclearPanel()) { |
| 483 | clearPanelTimer.start(); |
| 484 | } |
| 485 | |
| 486 | emit passShowHandlerFinished(output); |
| 487 | setUiElementsEnabled(true); |
| 488 | } |
| 489 | |
| 490 | /** |
| 491 | * @brief Handles the OTP output by displaying it, copying it to the clipboard, |
nothing calls this directly
no test coverage detected