* @brief Copies the password of the selected file from the tree view to the * clipboard. * @example * MainWindow::copyPasswordFromTreeview(); * * @return void - This function does not return a value. */
| 1365 | * @return void - This function does not return a value. |
| 1366 | */ |
| 1367 | void MainWindow::copyPasswordFromTreeview() { |
| 1368 | QFileInfo fileOrFolder = |
| 1369 | model.fileInfo(proxyModel.mapToSource(ui->treeView->currentIndex())); |
| 1370 | |
| 1371 | if (fileOrFolder.isFile()) { |
| 1372 | QString file = getFile(ui->treeView->currentIndex(), true); |
| 1373 | // Disconnect any previous connection to avoid accumulation |
| 1374 | disconnect(QtPassSettings::getPass(), &Pass::finishedShow, this, |
| 1375 | &MainWindow::passwordFromFileToClipboard); |
| 1376 | connect(QtPassSettings::getPass(), &Pass::finishedShow, this, |
| 1377 | &MainWindow::passwordFromFileToClipboard); |
| 1378 | QtPassSettings::getPass()->Show(file); |
| 1379 | } |
| 1380 | } |
| 1381 | |
| 1382 | void MainWindow::passwordFromFileToClipboard(const QString &text) { |
| 1383 | QStringList tokens = text.split('\n'); |