refactor: move fixed font to styleUtils, use this where fixed fonts are used
This commit is contained in:
parent
6bbf5338ef
commit
8d1b33b9f1
3 changed files with 21 additions and 21 deletions
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <QDir>
|
||||
#include <QFileInfoList>
|
||||
#include <QFontDatabase>
|
||||
#include <QIcon>
|
||||
#include <QPalette>
|
||||
#include <QStyleHints>
|
||||
|
|
@ -49,3 +50,18 @@ inline void updateIconTheme()
|
|||
QIcon::setFallbackSearchPaths({QStringLiteral(":/icons/%1").arg(themeName)});
|
||||
}
|
||||
} // namespace deskflow::gui
|
||||
|
||||
inline QFont fixedFont()
|
||||
{
|
||||
#if defined(Q_OS_WIN)
|
||||
QFont f({"Hack", "Liberation Mono", "Monospace", "Andale Mono"});
|
||||
f.setStyleHint(QFont::Monospace);
|
||||
#else
|
||||
QFont f = QFontDatabase::systemFont(QFontDatabase::FixedFont);
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
f.setPointSize(12);
|
||||
#endif
|
||||
return f;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
|
||||
#include <gui/StyleUtils.h>
|
||||
#include <net/SecureUtils.h>
|
||||
|
||||
FingerprintPreview::FingerprintPreview(
|
||||
|
|
@ -59,16 +60,13 @@ QLayout *FingerprintPreview::sha256Layout(const Fingerprint &fingerprint, const
|
|||
m_lblHash->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
|
||||
m_lblHash->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||
m_lblHash->setVisible(hashMode);
|
||||
m_lblHash->setFont(fixedFont());
|
||||
|
||||
m_lblArt = new QLabel(deskflow::generateFingerprintArt(fingerprint.data), this);
|
||||
m_lblArt->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
|
||||
m_lblArt->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||
m_lblArt->setVisible(!hashMode);
|
||||
|
||||
f = font();
|
||||
f.setFamilies({"Hack", "Liberation Mono", "Monospace", "Andale Mono"});
|
||||
f.setStyleHint(QFont::Monospace);
|
||||
m_lblArt->setFont(f);
|
||||
m_lblArt->setFont(fixedFont());
|
||||
|
||||
auto sha256Layout = new QVBoxLayout();
|
||||
sha256Layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@
|
|||
*/
|
||||
|
||||
#include "LogWidget.h"
|
||||
#include "common/PlatformInfo.h"
|
||||
|
||||
#include <gui/Logger.h>
|
||||
#include <gui/StyleUtils.h>
|
||||
|
||||
#include <QPlainTextEdit>
|
||||
#include <QScrollBar>
|
||||
|
|
@ -18,21 +18,7 @@ LogWidget::LogWidget(QWidget *parent) : QWidget{parent}, m_textLog{new QPlainTex
|
|||
m_textLog->setReadOnly(true);
|
||||
m_textLog->setMaximumBlockCount(10000);
|
||||
m_textLog->setLineWrapMode(QPlainTextEdit::NoWrap);
|
||||
|
||||
// setup the log font
|
||||
if (deskflow::platform::isWindows()) {
|
||||
QFont f = font();
|
||||
f.setFamilies({"Hack", "Liberation Mono", "Monospace", "Andale Mono"});
|
||||
f.setStyleHint(QFont::Monospace);
|
||||
m_textLog->setFont(f);
|
||||
} else {
|
||||
m_textLog->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
|
||||
if (deskflow::platform::isMac()) {
|
||||
auto f = m_textLog->font();
|
||||
f.setPixelSize(12);
|
||||
m_textLog->setFont(f);
|
||||
}
|
||||
}
|
||||
m_textLog->setFont(fixedFont());
|
||||
|
||||
auto layout = new QVBoxLayout;
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
|
|
|||
Loading…
Reference in a new issue