Skip to content

Commit

Permalink
Also make line wrapping optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Leupold committed Feb 20, 2022
1 parent aa5e4b0 commit c384dee
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/configdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ ConfigDialog::ConfigDialog(MainWindow *parent)
ui->checkBoxHideContent->setChecked(QtPassSettings::isHideContent());
ui->checkBoxUseMonospace->setChecked(QtPassSettings::isUseMonospace());
ui->checkBoxDisplayAsIs->setChecked(QtPassSettings::isDisplayAsIs());
ui->checkBoxNoLineWrapping->setChecked(QtPassSettings::isNoLineWrapping());
ui->checkBoxAddGPGId->setChecked(QtPassSettings::isAddGPGId(true));

if (QSystemTrayIcon::isSystemTrayAvailable()) {
Expand Down Expand Up @@ -207,6 +208,7 @@ void ConfigDialog::on_accepted() {
QtPassSettings::setHideContent(ui->checkBoxHideContent->isChecked());
QtPassSettings::setUseMonospace(ui->checkBoxUseMonospace->isChecked());
QtPassSettings::setDisplayAsIs(ui->checkBoxDisplayAsIs->isChecked());
QtPassSettings::setNoLineWrapping(ui->checkBoxNoLineWrapping->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 @@ -228,6 +228,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxNoLineWrapping">
<property name="text">
<string>No line wrapping</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_9">
<property name="orientation">
Expand Down
9 changes: 9 additions & 0 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ MainWindow::MainWindow(const QString &searchText, QWidget *parent)
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,
Expand Down Expand Up @@ -248,6 +251,12 @@ void MainWindow::config() {
} 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();
Expand Down
9 changes: 9 additions & 0 deletions src/qtpasssettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,15 @@ void QtPassSettings::setDisplayAsIs(const bool &displayAsIs) {
getInstance()->setValue(SettingsConstants::displayAsIs, displayAsIs);
}

bool QtPassSettings::isNoLineWrapping(const bool &defaultValue) {
return getInstance()
->value(SettingsConstants::noLineWrapping, defaultValue)
.toBool();
}
void QtPassSettings::setNoLineWrapping(const bool &noLineWrapping) {
getInstance()->setValue(SettingsConstants::noLineWrapping, noLineWrapping);
}

bool QtPassSettings::isAddGPGId(const bool &defaultValue) {
return getInstance()
->value(SettingsConstants::addGPGId, defaultValue)
Expand Down
3 changes: 3 additions & 0 deletions src/qtpasssettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ class QtPassSettings : public QSettings {
static bool isDisplayAsIs(const bool &defaultValue = QVariant().toBool());
static void setDisplayAsIs(const bool &displayAsIs);

static bool isNoLineWrapping(const bool &defaultValue = QVariant().toBool());
static void setNoLineWrapping(const bool &noLineWrapping);

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 @@ -29,6 +29,7 @@ const QString SettingsConstants::hidePassword = "hidePassword";
const QString SettingsConstants::hideContent = "hideContent";
const QString SettingsConstants::useMonospace = "useMonospace";
const QString SettingsConstants::displayAsIs = "displayAsIs";
const QString SettingsConstants::noLineWrapping = "noLineWrapping";
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 @@ -28,6 +28,7 @@ class SettingsConstants {
const static QString hideContent;
const static QString useMonospace;
const static QString displayAsIs;
const static QString noLineWrapping;
const static QString addGPGId;
const static QString passStore;
const static QString passExecutable;
Expand Down

0 comments on commit c384dee

Please sign in to comment.