diff --git a/CHANGELOG b/CHANGELOG index 54330a63a..dabd69c19 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ - CLI: Add 'flatten' option to the 'ls' command [#3276] - Rework the Entry Preview panel [#3306] - Move notes to General tab on Group Preview Panel [#3336] +- Add 'Monospaced font' option to the Notes field [#3321] 2.4.3 (2019-06-12) ========================= diff --git a/share/keepassxc.ini b/share/keepassxc.ini index 69f921f4b..7117b9840 100644 --- a/share/keepassxc.ini +++ b/share/keepassxc.ini @@ -21,6 +21,7 @@ DarkTrayIcon=false MinimizeToTray=false MinimizeOnClose=false MinimizeOnStartup=false +MonospaceNotes=false MainWindowGeometry="@ByteArray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\x2(\0\0\0\xbd\0\0\x5W\0\0\x3;\0\0\x2\x30\0\0\0\xdc\0\0\x5O\0\0\x3\x33\0\0\0\0\0\0\0\0\a\x80)" SplitterState=@Invalid() EntryListColumnSizes=@Invalid() diff --git a/src/core/Config.cpp b/src/core/Config.cpp index caf41c5d9..e65926ec6 100644 --- a/src/core/Config.cpp +++ b/src/core/Config.cpp @@ -211,6 +211,7 @@ void Config::init(const QString& fileName) m_defaults.insert("GUI/HideUsernames", false); m_defaults.insert("GUI/HidePasswords", true); m_defaults.insert("GUI/AdvancedSettings", false); + m_defaults.insert("GUI/MonospaceNotes", false); } Config* Config::instance() diff --git a/src/gui/ApplicationSettingsWidget.cpp b/src/gui/ApplicationSettingsWidget.cpp index 30b0dd537..dea184a44 100644 --- a/src/gui/ApplicationSettingsWidget.cpp +++ b/src/gui/ApplicationSettingsWidget.cpp @@ -167,6 +167,7 @@ void ApplicationSettingsWidget::loadSettings() m_generalUi->previewHideCheckBox->setChecked(config()->get("GUI/HidePreviewPanel").toBool()); m_generalUi->toolbarHideCheckBox->setChecked(config()->get("GUI/HideToolbar").toBool()); m_generalUi->toolbarMovableCheckBox->setChecked(config()->get("GUI/MovableToolbar").toBool()); + m_generalUi->monospaceNotesCheckBox->setChecked(config()->get("GUI/MonospaceNotes").toBool()); m_generalUi->toolButtonStyleComboBox->clear(); m_generalUi->toolButtonStyleComboBox->addItem(tr("Icon only"), Qt::ToolButtonIconOnly); @@ -260,6 +261,7 @@ void ApplicationSettingsWidget::saveSettings() config()->set("GUI/HidePreviewPanel", m_generalUi->previewHideCheckBox->isChecked()); config()->set("GUI/HideToolbar", m_generalUi->toolbarHideCheckBox->isChecked()); config()->set("GUI/MovableToolbar", m_generalUi->toolbarMovableCheckBox->isChecked()); + config()->set("GUI/MonospaceNotes", m_generalUi->monospaceNotesCheckBox->isChecked()); int currentToolButtonStyleIndex = m_generalUi->toolButtonStyleComboBox->currentIndex(); config()->set("GUI/ToolButtonStyle", diff --git a/src/gui/ApplicationSettingsWidgetGeneral.ui b/src/gui/ApplicationSettingsWidgetGeneral.ui index ccdbee880..97f8f0fed 100644 --- a/src/gui/ApplicationSettingsWidgetGeneral.ui +++ b/src/gui/ApplicationSettingsWidgetGeneral.ui @@ -382,6 +382,13 @@ + + + + Use monospaced font for Notes + + + diff --git a/src/gui/EntryPreviewWidget.cpp b/src/gui/EntryPreviewWidget.cpp index 7ccd54474..d5c2b32b2 100644 --- a/src/gui/EntryPreviewWidget.cpp +++ b/src/gui/EntryPreviewWidget.cpp @@ -17,6 +17,7 @@ */ #include "EntryPreviewWidget.h" +#include "Font.h" #include "ui_EntryPreviewWidget.h" #include @@ -236,6 +237,12 @@ void EntryPreviewWidget::updateEntryGeneralTab() m_ui->toggleEntryNotesButton->setVisible(false); } + if (config()->get("GUI/MonospaceNotes", false).toBool()) { + m_ui->entryNotesLabel->setFont(Font::fixedFont()); + } else { + m_ui->entryNotesLabel->setFont(Font::defaultFont()); + } + m_ui->entryUrlLabel->setRawText(m_currentEntry->displayUrl()); const QString url = m_currentEntry->url(); if (!url.isEmpty()) { @@ -317,9 +324,6 @@ void EntryPreviewWidget::updateGroupGeneralTab() groupTime.expires() ? groupTime.expiryTime().toString(Qt::DefaultLocaleShortDate) : tr("Never"); m_ui->groupExpirationLabel->setText(expiresText); - const QString notes = m_currentGroup->notes(); - m_ui->groupNotesLabel->setText(notes); - if (config()->get("security/hidenotes").toBool()) { setGroupNotesVisible(false); m_ui->toggleGroupNotesButton->setVisible(!m_ui->groupNotesLabel->text().isEmpty()); @@ -328,6 +332,12 @@ void EntryPreviewWidget::updateGroupGeneralTab() setGroupNotesVisible(true); m_ui->toggleGroupNotesButton->setVisible(false); } + + if (config()->get("GUI/MonospaceNotes", false).toBool()) { + m_ui->groupNotesLabel->setFont(Font::fixedFont()); + } else { + m_ui->groupNotesLabel->setFont(Font::defaultFont()); + } } #if defined(WITH_XC_KEESHARE) diff --git a/src/gui/Font.cpp b/src/gui/Font.cpp index 3583622dd..f53daed93 100644 --- a/src/gui/Font.cpp +++ b/src/gui/Font.cpp @@ -19,6 +19,11 @@ #include +QFont Font::defaultFont() +{ + return QFontDatabase::systemFont(QFontDatabase::GeneralFont); +} + QFont Font::fixedFont() { QFont fixedFont = QFontDatabase::systemFont(QFontDatabase::FixedFont); diff --git a/src/gui/Font.h b/src/gui/Font.h index 076c42770..930d53a2e 100644 --- a/src/gui/Font.h +++ b/src/gui/Font.h @@ -23,6 +23,7 @@ class Font { public: + static QFont defaultFont(); static QFont fixedFont(); private: diff --git a/src/gui/entry/EditEntryWidget.cpp b/src/gui/entry/EditEntryWidget.cpp index 5a557d472..14520650b 100644 --- a/src/gui/entry/EditEntryWidget.cpp +++ b/src/gui/entry/EditEntryWidget.cpp @@ -726,6 +726,11 @@ void EditEntryWidget::setForms(Entry* entry, bool restore) m_mainUi->notesEdit->setReadOnly(m_history); m_mainUi->notesEdit->setVisible(!config()->get("security/hidenotes").toBool()); m_mainUi->notesHint->setVisible(config()->get("security/hidenotes").toBool()); + if (config()->get("GUI/MonospaceNotes", false).toBool()) { + m_mainUi->notesEdit->setFont(Font::fixedFont()); + } else { + m_mainUi->notesEdit->setFont(Font::defaultFont()); + } m_mainUi->togglePasswordGeneratorButton->setChecked(false); m_mainUi->togglePasswordGeneratorButton->setDisabled(m_history); m_mainUi->passwordGenerator->reset(entry->password().length()); diff --git a/src/gui/group/EditGroupWidget.cpp b/src/gui/group/EditGroupWidget.cpp index 65e03e82b..30d8fb913 100644 --- a/src/gui/group/EditGroupWidget.cpp +++ b/src/gui/group/EditGroupWidget.cpp @@ -16,8 +16,10 @@ */ #include "EditGroupWidget.h" +#include "gui/Font.h" #include "ui_EditGroupWidgetMain.h" +#include "core/Config.h" #include "core/FilePath.h" #include "core/Metadata.h" #include "gui/EditWidgetIcons.h" @@ -151,6 +153,12 @@ void EditGroupWidget::loadGroup(Group* group, bool create, const QSharedPointer< } m_mainUi->autoTypeSequenceCustomEdit->setText(group->effectiveAutoTypeSequence()); + if (config()->get("GUI/MonospaceNotes", false).toBool()) { + m_mainUi->editNotes->setFont(Font::fixedFont()); + } else { + m_mainUi->editNotes->setFont(Font::defaultFont()); + } + IconStruct iconStruct; iconStruct.uuid = m_temporaryGroup->iconUuid(); iconStruct.number = m_temporaryGroup->iconNumber();