viewer: clean up some font related functions
This commit is contained in:
@@ -40,7 +40,6 @@ ViewerTextEditor::ViewerTextEditor(double scale, QWidget *parent) :
|
||||
super(parent),
|
||||
transparent_clone_(nullptr),
|
||||
block_update_toolbar_signal_(false),
|
||||
listen_to_focus_events_(false),
|
||||
forced_default_(false)
|
||||
{
|
||||
// Ensure default text color is white
|
||||
@@ -208,10 +207,7 @@ void ViewerTextEditor::SetFamily(const QString &s)
|
||||
ViewerTextEditorToolBar *toolbar = static_cast<ViewerTextEditorToolBar *>(sender());
|
||||
|
||||
QTextCharFormat f;
|
||||
f.setFontFamily(s);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
|
||||
f.setFontFamilies({s});
|
||||
#endif
|
||||
|
||||
ApplyStyle(&f, s, toolbar->GetFontStyleName());
|
||||
|
||||
@@ -271,9 +267,8 @@ void ViewerTextEditor::ApplyStyle(QTextCharFormat *format, const QString &family
|
||||
{
|
||||
// NOTE: Windows appears to require setting weight and italic manually, while macOS and Linux are
|
||||
// perfectly fine with just the style name
|
||||
QFontDatabase fd;
|
||||
format->setFontWeight(fd.weight(family, style));
|
||||
format->setFontItalic(fd.italic(family, style));
|
||||
format->setFontWeight(QFontDatabase::weight(family, style));
|
||||
format->setFontItalic(QFontDatabase::italic(family, style));
|
||||
|
||||
format->setFontStyleName(style);
|
||||
}
|
||||
@@ -541,7 +536,7 @@ void ViewerTextEditorToolBar::UpdateFontStyleList(const QString &family)
|
||||
|
||||
style_combo_->blockSignals(true);
|
||||
style_combo_->clear();
|
||||
QStringList l = QFontDatabase().styles(family);
|
||||
QStringList l = QFontDatabase::styles(family);
|
||||
foreach (const QString &style, l) {
|
||||
style_combo_->addItem(style);
|
||||
}
|
||||
|
||||
@@ -151,8 +151,6 @@ public:
|
||||
|
||||
void ConnectToolBar(ViewerTextEditorToolBar *toolbar);
|
||||
|
||||
void SetListenToFocusEvents(bool e) { listen_to_focus_events_ = e; }
|
||||
|
||||
void Paint(QPainter *p, Qt::Alignment valign);
|
||||
|
||||
virtual void dragEnterEvent(QDragEnterEvent *e) override { return QTextEdit::dragEnterEvent(e); }
|
||||
@@ -178,8 +176,6 @@ private:
|
||||
|
||||
bool block_update_toolbar_signal_;
|
||||
|
||||
bool listen_to_focus_events_;
|
||||
|
||||
bool forced_default_;
|
||||
QTextCharFormat default_fmt_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user