Skip to content

Commit

Permalink
Added an option to display all pass file content as-is
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Leupold committed Feb 19, 2022
1 parent 6d470ce commit aa5e4b0
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/configdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ ConfigDialog::ConfigDialog(MainWindow *parent)
ui->checkBoxHidePassword->setChecked(QtPassSettings::isHidePassword());
ui->checkBoxHideContent->setChecked(QtPassSettings::isHideContent());
ui->checkBoxUseMonospace->setChecked(QtPassSettings::isUseMonospace());
ui->checkBoxDisplayAsIs->setChecked(QtPassSettings::isDisplayAsIs());
ui->checkBoxAddGPGId->setChecked(QtPassSettings::isAddGPGId(true));

if (QSystemTrayIcon::isSystemTrayAvailable()) {
Expand Down Expand Up @@ -205,6 +206,7 @@ void ConfigDialog::on_accepted() {
QtPassSettings::setHidePassword(ui->checkBoxHidePassword->isChecked());
QtPassSettings::setHideContent(ui->checkBoxHideContent->isChecked());
QtPassSettings::setUseMonospace(ui->checkBoxUseMonospace->isChecked());
QtPassSettings::setDisplayAsIs(ui->checkBoxDisplayAsIs->isChecked());
QtPassSettings::setAddGPGId(ui->checkBoxAddGPGId->isChecked());
QtPassSettings::setUseTrayIcon(ui->checkBoxUseTrayIcon->isEnabled() &&
ui->checkBoxUseTrayIcon->isChecked());
Expand Down
7 changes: 7 additions & 0 deletions src/configdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxDisplayAsIs">
<property name="text">
<string>Display the files content as-is</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_9">
<property name="orientation">
Expand Down
2 changes: 1 addition & 1 deletion src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,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);
Expand Down
9 changes: 9 additions & 0 deletions src/qtpasssettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,15 @@ void QtPassSettings::setUseMonospace(const bool &useMonospace) {
getInstance()->setValue(SettingsConstants::useMonospace, useMonospace);
}

bool QtPassSettings::isDisplayAsIs(const bool &defaultValue) {
return getInstance()
->value(SettingsConstants::displayAsIs, defaultValue)
.toBool();
}
void QtPassSettings::setDisplayAsIs(const bool &displayAsIs) {
getInstance()->setValue(SettingsConstants::displayAsIs, displayAsIs);
}

bool QtPassSettings::isAddGPGId(const bool &defaultValue) {
return getInstance()
->value(SettingsConstants::addGPGId, defaultValue)
Expand Down
5 changes: 4 additions & 1 deletion src/qtpasssettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ class QtPassSettings : public QSettings {
static void setHideContent(const bool &hideContent);

static bool isUseMonospace(const bool &defaultValue = QVariant().toBool());
static void setUseMonospace(const bool &hideContent);
static void setUseMonospace(const bool &useMonospace);

static bool isDisplayAsIs(const bool &defaultValue = QVariant().toBool());
static void setDisplayAsIs(const bool &displayAsIs);

static bool isAddGPGId(const bool &defaultValue = QVariant().toBool());
static void setAddGPGId(const bool &addGPGId);
Expand Down
1 change: 1 addition & 0 deletions src/settingsconstants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const QString SettingsConstants::autoclearPanelSeconds =
const QString SettingsConstants::hidePassword = "hidePassword";
const QString SettingsConstants::hideContent = "hideContent";
const QString SettingsConstants::useMonospace = "useMonospace";
const QString SettingsConstants::displayAsIs = "displayAsIs";
const QString SettingsConstants::addGPGId = "addGPGId";
const QString SettingsConstants::passStore = "passStore";
const QString SettingsConstants::passExecutable = "passExecutable";
Expand Down
1 change: 1 addition & 0 deletions src/settingsconstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class SettingsConstants {
const static QString hidePassword;
const static QString hideContent;
const static QString useMonospace;
const static QString displayAsIs;
const static QString addGPGId;
const static QString passStore;
const static QString passExecutable;
Expand Down

0 comments on commit aa5e4b0

Please sign in to comment.