summaryrefslogtreecommitdiffstats
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp43
1 files changed, 39 insertions, 4 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 5279610f..6e7dcffb 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -87,6 +87,12 @@ MainWindow::MainWindow(const QString &searchText, QWidget *parent)
connect(ui->treeView, &DeselectableTreeView::emptyClicked, this,
&MainWindow::deselect);
+ if (QtPassSettings::isUseMonospace()) {
+ ui->textBrowser->setFont(QFont(QStringLiteral("Monospace")));
+ }
+ if (QtPassSettings::isNoLineWrapping()) {
+ ui->textBrowser->setLineWrapMode(QTextBrowser::NoWrap);
+ }
ui->textBrowser->setOpenExternalLinks(true);
ui->textBrowser->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->textBrowser, &QWidget::customContextMenuRequested, this,
@@ -239,6 +245,19 @@ void MainWindow::config() {
d->wizard(); // does shit
if (d->exec()) {
if (d->result() == QDialog::Accepted) {
+ // Update the textBrowser font
+ if (QtPassSettings::isUseMonospace()) {
+ ui->textBrowser->setFont(QFont(QStringLiteral("Monospace")));
+ } else {
+ ui->textBrowser->setFont(QFont());
+ }
+ // Update the textBrowser line wrap mode
+ if (QtPassSettings::isNoLineWrapping()) {
+ ui->textBrowser->setLineWrapMode(QTextBrowser::NoWrap);
+ } else {
+ ui->textBrowser->setLineWrapMode(QTextBrowser::WidgetWidth);
+ }
+
if (QtPassSettings::isAlwaysOnTop()) {
Qt::WindowFlags flags = windowFlags();
this->setWindowFlags(flags | Qt::WindowStaysOnTopHint);
@@ -385,7 +404,7 @@ void MainWindow::passShowHandler(const QString &p_output) {
// show what is needed:
if (QtPassSettings::isHideContent()) {
output = "***" + tr("Content hidden") + "***";
- } else {
+ } else if (! QtPassSettings::isDisplayAsIs()) {
if (!password.isEmpty()) {
// set the password, it is hidden if needed in addToGridLayout
addToGridLayout(0, tr("Password"), password);
@@ -621,6 +640,14 @@ void MainWindow::addPassword() {
* sure.
*/
void MainWindow::onDelete() {
+ QModelIndex currentIndex = ui->treeView->currentIndex();
+ if (!currentIndex.isValid()) {
+ // This fixes https://github.com/IJHack/QtPass/issues/556
+ // Otherwise the entire password directory would be deleted if
+ // nothing is selected in the tree view.
+ return;
+ }
+
QFileInfo fileOrFolder =
model.fileInfo(proxyModel.mapToSource(ui->treeView->currentIndex()));
QString file = "";
@@ -947,6 +974,7 @@ void MainWindow::showBrowserContextMenu(const QPoint &pos) {
QPoint globalPos = ui->textBrowser->viewport()->mapToGlobal(pos);
contextMenu->exec(globalPos);
+ delete contextMenu;
}
/**
@@ -1018,7 +1046,10 @@ void MainWindow::renamePassword() {
bool ok;
QString file = getFile(ui->treeView->currentIndex(), false);
QString filePath = QFileInfo(file).path();
- QString fileName = QFileInfo(file).baseName();
+ QString fileName = QFileInfo(file).fileName();
+ if (fileName.endsWith(".gpg", Qt::CaseInsensitive))
+ fileName.chop(4);
+
QString newName =
QInputDialog::getText(this, tr("Rename file"), tr("Rename File To: "),
QLineEdit::Normal, fileName, &ok);
@@ -1095,13 +1126,17 @@ void MainWindow::addToGridLayout(int position, const QString &field,
}
// set the echo mode to password, if the field is "password"
+ const QString lineStyle = QtPassSettings::isUseMonospace()
+ ? "border-style: none; background: transparent; font-family: monospace;"
+ : "border-style: none; background: transparent;";
+
if (QtPassSettings::isHidePassword() && trimmedField == tr("Password")) {
auto *line = new QLineEdit();
line->setObjectName(trimmedField);
line->setText(trimmedValue);
line->setReadOnly(true);
- line->setStyleSheet("border-style: none ; background: transparent;");
+ line->setStyleSheet(lineStyle);
line->setContentsMargins(0, 0, 0, 0);
line->setEchoMode(QLineEdit::Password);
QPushButtonShowPassword *showButton =
@@ -1125,7 +1160,7 @@ void MainWindow::addToGridLayout(int position, const QString &field,
R"(<a href="\1">\1</a>)");
line->setText(trimmedValue);
line->setReadOnly(true);
- line->setStyleSheet("border-style: none ; background: transparent;");
+ line->setStyleSheet(lineStyle);
line->setContentsMargins(0, 0, 0, 0);
frame->layout()->addWidget(line);
}