Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add monospaced font option for Notes field #3321

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -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)
=========================
Expand Down
1 change: 1 addition & 0 deletions share/keepassxc.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions src/core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions src/gui/ApplicationSettingsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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",
Expand Down
7 changes: 7 additions & 0 deletions src/gui/ApplicationSettingsWidgetGeneral.ui
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,13 @@
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="monospaceNotesCheckBox">
<property name="text">
<string>Use monospaced font for Notes</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="minimizeOnCloseCheckBox">
<property name="text">
Expand Down
16 changes: 13 additions & 3 deletions src/gui/EntryPreviewWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/

#include "EntryPreviewWidget.h"
#include "Font.h"
#include "ui_EntryPreviewWidget.h"

#include <QDesktopServices>
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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());
Expand All @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions src/gui/Font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@

#include <QFontDatabase>

QFont Font::defaultFont()
{
return QFontDatabase::systemFont(QFontDatabase::GeneralFont);
}

QFont Font::fixedFont()
{
QFont fixedFont = QFontDatabase::systemFont(QFontDatabase::FixedFont);
Expand Down
1 change: 1 addition & 0 deletions src/gui/Font.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
class Font
{
public:
static QFont defaultFont();
static QFont fixedFont();

private:
Expand Down
5 changes: 5 additions & 0 deletions src/gui/entry/EditEntryWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
8 changes: 8 additions & 0 deletions src/gui/group/EditGroupWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
Expand Down