Add monospaced font option for Notes field

This commit is contained in:
Jonathan White 2019-06-28 22:10:47 -04:00
parent a0d1304bfc
commit d49e74c1f4
10 changed files with 44 additions and 3 deletions

View File

@ -4,6 +4,7 @@
- CLI: Add 'flatten' option to the 'ls' command [#3276] - CLI: Add 'flatten' option to the 'ls' command [#3276]
- Rework the Entry Preview panel [#3306] - Rework the Entry Preview panel [#3306]
- Move notes to General tab on Group Preview Panel [#3336] - 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) 2.4.3 (2019-06-12)
========================= =========================

View File

@ -21,6 +21,7 @@ DarkTrayIcon=false
MinimizeToTray=false MinimizeToTray=false
MinimizeOnClose=false MinimizeOnClose=false
MinimizeOnStartup=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)" 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() SplitterState=@Invalid()
EntryListColumnSizes=@Invalid() EntryListColumnSizes=@Invalid()

View File

@ -211,6 +211,7 @@ void Config::init(const QString& fileName)
m_defaults.insert("GUI/HideUsernames", false); m_defaults.insert("GUI/HideUsernames", false);
m_defaults.insert("GUI/HidePasswords", true); m_defaults.insert("GUI/HidePasswords", true);
m_defaults.insert("GUI/AdvancedSettings", false); m_defaults.insert("GUI/AdvancedSettings", false);
m_defaults.insert("GUI/MonospaceNotes", false);
} }
Config* Config::instance() Config* Config::instance()

View File

@ -167,6 +167,7 @@ void ApplicationSettingsWidget::loadSettings()
m_generalUi->previewHideCheckBox->setChecked(config()->get("GUI/HidePreviewPanel").toBool()); m_generalUi->previewHideCheckBox->setChecked(config()->get("GUI/HidePreviewPanel").toBool());
m_generalUi->toolbarHideCheckBox->setChecked(config()->get("GUI/HideToolbar").toBool()); m_generalUi->toolbarHideCheckBox->setChecked(config()->get("GUI/HideToolbar").toBool());
m_generalUi->toolbarMovableCheckBox->setChecked(config()->get("GUI/MovableToolbar").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->clear();
m_generalUi->toolButtonStyleComboBox->addItem(tr("Icon only"), Qt::ToolButtonIconOnly); 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/HidePreviewPanel", m_generalUi->previewHideCheckBox->isChecked());
config()->set("GUI/HideToolbar", m_generalUi->toolbarHideCheckBox->isChecked()); config()->set("GUI/HideToolbar", m_generalUi->toolbarHideCheckBox->isChecked());
config()->set("GUI/MovableToolbar", m_generalUi->toolbarMovableCheckBox->isChecked()); config()->set("GUI/MovableToolbar", m_generalUi->toolbarMovableCheckBox->isChecked());
config()->set("GUI/MonospaceNotes", m_generalUi->monospaceNotesCheckBox->isChecked());
int currentToolButtonStyleIndex = m_generalUi->toolButtonStyleComboBox->currentIndex(); int currentToolButtonStyleIndex = m_generalUi->toolButtonStyleComboBox->currentIndex();
config()->set("GUI/ToolButtonStyle", config()->set("GUI/ToolButtonStyle",

View File

@ -382,6 +382,13 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<widget class="QCheckBox" name="monospaceNotesCheckBox">
<property name="text">
<string>Use monospaced font for Notes</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QCheckBox" name="minimizeOnCloseCheckBox"> <widget class="QCheckBox" name="minimizeOnCloseCheckBox">
<property name="text"> <property name="text">

View File

@ -17,6 +17,7 @@
*/ */
#include "EntryPreviewWidget.h" #include "EntryPreviewWidget.h"
#include "Font.h"
#include "ui_EntryPreviewWidget.h" #include "ui_EntryPreviewWidget.h"
#include <QDesktopServices> #include <QDesktopServices>
@ -236,6 +237,12 @@ void EntryPreviewWidget::updateEntryGeneralTab()
m_ui->toggleEntryNotesButton->setVisible(false); 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()); m_ui->entryUrlLabel->setRawText(m_currentEntry->displayUrl());
const QString url = m_currentEntry->url(); const QString url = m_currentEntry->url();
if (!url.isEmpty()) { if (!url.isEmpty()) {
@ -317,9 +324,6 @@ void EntryPreviewWidget::updateGroupGeneralTab()
groupTime.expires() ? groupTime.expiryTime().toString(Qt::DefaultLocaleShortDate) : tr("Never"); groupTime.expires() ? groupTime.expiryTime().toString(Qt::DefaultLocaleShortDate) : tr("Never");
m_ui->groupExpirationLabel->setText(expiresText); m_ui->groupExpirationLabel->setText(expiresText);
const QString notes = m_currentGroup->notes();
m_ui->groupNotesLabel->setText(notes);
if (config()->get("security/hidenotes").toBool()) { if (config()->get("security/hidenotes").toBool()) {
setGroupNotesVisible(false); setGroupNotesVisible(false);
m_ui->toggleGroupNotesButton->setVisible(!m_ui->groupNotesLabel->text().isEmpty()); m_ui->toggleGroupNotesButton->setVisible(!m_ui->groupNotesLabel->text().isEmpty());
@ -328,6 +332,12 @@ void EntryPreviewWidget::updateGroupGeneralTab()
setGroupNotesVisible(true); setGroupNotesVisible(true);
m_ui->toggleGroupNotesButton->setVisible(false); 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) #if defined(WITH_XC_KEESHARE)

View File

@ -19,6 +19,11 @@
#include <QFontDatabase> #include <QFontDatabase>
QFont Font::defaultFont()
{
return QFontDatabase::systemFont(QFontDatabase::GeneralFont);
}
QFont Font::fixedFont() QFont Font::fixedFont()
{ {
QFont fixedFont = QFontDatabase::systemFont(QFontDatabase::FixedFont); QFont fixedFont = QFontDatabase::systemFont(QFontDatabase::FixedFont);

View File

@ -23,6 +23,7 @@
class Font class Font
{ {
public: public:
static QFont defaultFont();
static QFont fixedFont(); static QFont fixedFont();
private: private:

View File

@ -726,6 +726,11 @@ void EditEntryWidget::setForms(Entry* entry, bool restore)
m_mainUi->notesEdit->setReadOnly(m_history); m_mainUi->notesEdit->setReadOnly(m_history);
m_mainUi->notesEdit->setVisible(!config()->get("security/hidenotes").toBool()); m_mainUi->notesEdit->setVisible(!config()->get("security/hidenotes").toBool());
m_mainUi->notesHint->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->setChecked(false);
m_mainUi->togglePasswordGeneratorButton->setDisabled(m_history); m_mainUi->togglePasswordGeneratorButton->setDisabled(m_history);
m_mainUi->passwordGenerator->reset(entry->password().length()); m_mainUi->passwordGenerator->reset(entry->password().length());

View File

@ -16,8 +16,10 @@
*/ */
#include "EditGroupWidget.h" #include "EditGroupWidget.h"
#include "gui/Font.h"
#include "ui_EditGroupWidgetMain.h" #include "ui_EditGroupWidgetMain.h"
#include "core/Config.h"
#include "core/FilePath.h" #include "core/FilePath.h"
#include "core/Metadata.h" #include "core/Metadata.h"
#include "gui/EditWidgetIcons.h" #include "gui/EditWidgetIcons.h"
@ -151,6 +153,12 @@ void EditGroupWidget::loadGroup(Group* group, bool create, const QSharedPointer<
} }
m_mainUi->autoTypeSequenceCustomEdit->setText(group->effectiveAutoTypeSequence()); 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 iconStruct;
iconStruct.uuid = m_temporaryGroup->iconUuid(); iconStruct.uuid = m_temporaryGroup->iconUuid();
iconStruct.number = m_temporaryGroup->iconNumber(); iconStruct.number = m_temporaryGroup->iconNumber();