Changeset View
Changeset View
Standalone View
Standalone View
src/mainwindow.cpp
/* | /* | ||||
SPDX-FileCopyrightText: 2014-2023 Anne Jan Brouwer <brouwer@annejan.com> | SPDX-FileCopyrightText: 2014-2023 Anne Jan Brouwer <brouwer@annejan.com> | ||||
SPDX-FileCopyrightText: 2016-2017 tezeb <tezeb+github@outoftheblue.pl> | SPDX-FileCopyrightText: 2016-2017 tezeb <tezeb+github@outoftheblue.pl> | ||||
SPDX-FileCopyrightText: 2018 Lukas Vogel <lukedirtwalker@gmail.com> | SPDX-FileCopyrightText: 2018 Lukas Vogel <lukedirtwalker@gmail.com> | ||||
SPDX-FileCopyrightText: 2018 Claudio Maradonna <penguyman@stronzi.org> | SPDX-FileCopyrightText: 2018 Claudio Maradonna <penguyman@stronzi.org> | ||||
SPDX-FileCopyrightText: 2019Maciej S. Szmigiero <mail@maciej.szmigiero.name> | SPDX-FileCopyrightText: 2019Maciej S. Szmigiero <mail@maciej.szmigiero.name> | ||||
SPDX-FileCopyrightText: 2023 g10 Code GmbH | SPDX-FileCopyrightText: 2023 g10 Code GmbH | ||||
SPDX-FileContributor: Sune Stolborg Vuorela <sune@vuorela.dk> | SPDX-FileContributor: Sune Stolborg Vuorela <sune@vuorela.dk> | ||||
SPDX-License-Identifier: GPL-3.0-or-later | SPDX-License-Identifier: GPL-3.0-or-later | ||||
*/ | */ | ||||
#include "mainwindow.h" | #include "mainwindow.h" | ||||
#include <gpgpass_version.h> | |||||
#include "clipboardhelper.h" | #include "clipboardhelper.h" | ||||
#include "configdialog.h" | #include "configdialog.h" | ||||
#include "filecontent.h" | #include "filecontent.h" | ||||
#include "pass.h" | #include "pass.h" | ||||
#include "passworddialog.h" | #include "passworddialog.h" | ||||
#include "qpushbuttonfactory.h" | #include "qpushbuttonfactory.h" | ||||
#include "settings.h" | #include "settings.h" | ||||
#include "ui_mainwindow.h" | #include "ui_mainwindow.h" | ||||
▲ Show 20 Lines • Show All 224 Lines • ▼ Show 20 Lines | void MainWindow::initToolBarButtons() | ||||
ui->actionAddFolder->setIcon(QIcon::fromTheme(QStringLiteral("folder-new"))); | ui->actionAddFolder->setIcon(QIcon::fromTheme(QStringLiteral("folder-new"))); | ||||
ui->actionEdit->setIcon(QIcon::fromTheme(QStringLiteral("document-properties"))); | ui->actionEdit->setIcon(QIcon::fromTheme(QStringLiteral("document-properties"))); | ||||
ui->actionDelete->setIcon(QIcon::fromTheme(QStringLiteral("edit-delete"))); | ui->actionDelete->setIcon(QIcon::fromTheme(QStringLiteral("edit-delete"))); | ||||
ui->actionUsers->setIcon(QIcon::fromTheme(QStringLiteral("x-office-address-book"))); | ui->actionUsers->setIcon(QIcon::fromTheme(QStringLiteral("x-office-address-book"))); | ||||
ui->actionConfig->setIcon(QIcon::fromTheme(QStringLiteral("configure-symbolic"))); | ui->actionConfig->setIcon(QIcon::fromTheme(QStringLiteral("configure-symbolic"))); | ||||
} | } | ||||
/** | /** | ||||
* @brief MainWindow::initStatusBar init statusBar with default message and logo | * @brief MainWindow::initStatusBar init statusBar | ||||
*/ | */ | ||||
void MainWindow::initStatusBar() | void MainWindow::initStatusBar() | ||||
{ | { | ||||
ui->statusBar->showMessage(i18nc("placeholder is version number","Welcome to GnuPG Password Manager %1", QString::fromLocal8Bit(GPGPASS_VERSION_STRING))); | statusBar()->hide(); | ||||
connect(statusBar(), &QStatusBar::messageChanged, [this](const QString &message) { | |||||
QPixmap logo = QPixmap(QStringLiteral(":/artwork/32-gpgpass.png")); | statusBar()->setVisible(!message.isEmpty()); | ||||
QLabel *logoApp = new QLabel(statusBar()); | }); | ||||
logoApp->setPixmap(logo); | |||||
statusBar()->addPermanentWidget(logoApp); | |||||
} | } | ||||
const QModelIndex MainWindow::getCurrentTreeViewIndex() | const QModelIndex MainWindow::getCurrentTreeViewIndex() | ||||
{ | { | ||||
return ui->treeView->currentIndex(); | return ui->treeView->currentIndex(); | ||||
} | } | ||||
void MainWindow::showRemainingHtml(const QString &text) | void MainWindow::showRemainingHtml(const QString &text) | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
bool cleared = ui->treeView->currentIndex().flags() == Qt::NoItemFlags; | bool cleared = ui->treeView->currentIndex().flags() == Qt::NoItemFlags; | ||||
// TODO(bezet): "Could not decrypt"; | // TODO(bezet): "Could not decrypt"; | ||||
m_clipboardHelper->clearClippedText(); | m_clipboardHelper->clearClippedText(); | ||||
QString file = index.data(QFileSystemModel::FilePathRole).toString(); | QString file = index.data(QFileSystemModel::FilePathRole).toString(); | ||||
ui->passwordName->setText(index.data().toString()); | ui->passwordName->setText(index.data().toString()); | ||||
if (!file.isEmpty() && QFileInfo(file).isFile() && !cleared) { | if (!file.isEmpty() && QFileInfo(file).isFile() && !cleared) { | ||||
m_pass->Show(file); | m_pass->Show(file); | ||||
ui->stackedWidget->setCurrentIndex(1); | |||||
} else { | } else { | ||||
clearPanel(); | clearPanel(); | ||||
ui->actionEdit->setEnabled(false); | ui->actionEdit->setEnabled(false); | ||||
ui->actionDelete->setEnabled(true); | ui->actionDelete->setEnabled(true); | ||||
ui->stackedWidget->setCurrentIndex(0); | |||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* @brief MainWindow::on_treeView_doubleClicked when doubleclicked on | * @brief MainWindow::on_treeView_doubleClicked when doubleclicked on | ||||
* TreeViewItem, open the edit Window | * TreeViewItem, open the edit Window | ||||
* @param index | * @param index | ||||
*/ | */ | ||||
Show All 12 Lines | |||||
void MainWindow::deselect() | void MainWindow::deselect() | ||||
{ | { | ||||
m_clipboardHelper->clearClipboard(); | m_clipboardHelper->clearClipboard(); | ||||
ui->treeView->clearSelection(); | ui->treeView->clearSelection(); | ||||
ui->actionEdit->setEnabled(false); | ui->actionEdit->setEnabled(false); | ||||
ui->actionDelete->setEnabled(false); | ui->actionDelete->setEnabled(false); | ||||
ui->passwordName->setText(QString{}); | ui->passwordName->setText(QString{}); | ||||
clearPanel(); | clearPanel(); | ||||
ui->stackedWidget->setCurrentIndex(0); | |||||
} | } | ||||
void MainWindow::passShowHandler(const QString &p_output) | void MainWindow::passShowHandler(const QString &p_output) | ||||
{ | { | ||||
QStringList templ = Settings::isUseTemplate() ? Settings::getPassTemplate().split(QStringLiteral("\n")) : QStringList(); | QStringList templ = Settings::isUseTemplate() ? Settings::getPassTemplate().split(QStringLiteral("\n")) : QStringList(); | ||||
bool allFields = Settings::isUseTemplate() && Settings::isTemplateAllFields(); | bool allFields = Settings::isUseTemplate() && Settings::isTemplateAllFields(); | ||||
FileContent fileContent = FileContent::parse(p_output, templ, allFields); | FileContent fileContent = FileContent::parse(p_output, templ, allFields); | ||||
QString output = p_output; | QString output = p_output; | ||||
▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | |||||
void MainWindow::onConfig() | void MainWindow::onConfig() | ||||
{ | { | ||||
config(); | config(); | ||||
} | } | ||||
/** | /** | ||||
* @brief Executes when the string in the search box changes, collapses the | * @brief Executes when the string in the search box changes, collapses the | ||||
* TreeView | * TreeView | ||||
* @param arg1 | |||||
*/ | */ | ||||
void MainWindow::filterList(const QString &arg1) | void MainWindow::filterList(const QString &) | ||||
{ | { | ||||
ui->statusBar->showMessage(i18n("Looking for: %1", arg1), 1000); | |||||
ui->treeView->expandAll(); | ui->treeView->expandAll(); | ||||
clearPanel(); | clearPanel(); | ||||
ui->passwordName->setText(QString{}); | ui->passwordName->setText(QString{}); | ||||
ui->actionEdit->setEnabled(false); | ui->actionEdit->setEnabled(false); | ||||
ui->actionDelete->setEnabled(false); | ui->actionDelete->setEnabled(false); | ||||
searchTimer.start(); | searchTimer.start(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 544 Lines • Show Last 20 Lines |