MCPcopy Create free account
hub / github.com/IJHack/QtPass / addToGridLayout

Method addToGridLayout

src/mainwindow.cpp:1393–1468  ·  view source on GitHub ↗

* @brief MainWindow::addToGridLayout add a field to the template grid * @param position * @param field * @param value */

Source from the content-addressed store, hash-verified

1391 * @param value
1392 */
1393void MainWindow::addToGridLayout(int position, const QString &field,
1394 const QString &value) {
1395 QString trimmedField = field.trimmed();
1396 QString trimmedValue = value.trimmed();
1397
1398 const QString buttonStyle =
1399 "border-style: none; background: transparent; padding: 0; margin: 0; "
1400 "icon-size: 16px; color: inherit;";
1401
1402 // Combine the Copy button and the line edit in one widget
1403 auto *frame = new QFrame();
1404 QLayout *ly = new QHBoxLayout();
1405 ly->setContentsMargins(5, 2, 2, 2);
1406 ly->setSpacing(0);
1407 frame->setLayout(ly);
1408 if (QtPassSettings::getClipBoardType() != Enums::CLIPBOARD_NEVER) {
1409 auto *fieldLabel = new QPushButtonWithClipboard(trimmedValue, this);
1410 connect(fieldLabel, &QPushButtonWithClipboard::clicked, m_qtPass,
1411 &QtPass::copyTextToClipboard);
1412
1413 fieldLabel->setStyleSheet(buttonStyle);
1414 frame->layout()->addWidget(fieldLabel);
1415 }
1416
1417 if (QtPassSettings::isUseQrencode()) {
1418 auto *qrbutton = new QPushButtonAsQRCode(trimmedValue, this);
1419 connect(qrbutton, &QPushButtonAsQRCode::clicked, m_qtPass,
1420 &QtPass::showTextAsQRCode);
1421 qrbutton->setStyleSheet(buttonStyle);
1422 frame->layout()->addWidget(qrbutton);
1423 }
1424
1425 // set the echo mode to password, if the field is "password"
1426 const QString lineStyle =
1427 QtPassSettings::isUseMonospace()
1428 ? "border-style: none; background: transparent; font-family: "
1429 "monospace;"
1430 : "border-style: none; background: transparent;";
1431
1432 if (QtPassSettings::isHidePassword() && trimmedField == tr("Password")) {
1433 auto *line = new QLineEdit();
1434 line->setObjectName(trimmedField);
1435 line->setText(trimmedValue);
1436 line->setReadOnly(true);
1437 line->setStyleSheet(lineStyle);
1438 line->setContentsMargins(0, 0, 0, 0);
1439 line->setEchoMode(QLineEdit::Password);
1440 auto *showButton = new QPushButtonShowPassword(line, this);
1441 showButton->setStyleSheet(buttonStyle);
1442 showButton->setContentsMargins(0, 0, 0, 0);
1443 frame->layout()->addWidget(showButton);
1444 frame->layout()->addWidget(line);
1445 } else {
1446 auto *line = new QTextBrowser();
1447 line->setOpenExternalLinks(true);
1448 line->setOpenLinks(true);
1449 line->setMaximumHeight(26);
1450 line->setMinimumHeight(26);

Callers

nothing calls this directly

Calls 1

replaceMethod · 0.80

Tested by

no test coverage detected