From 1a40663edebd0cdc4a0ebea6bfe4f0c95f362b02 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Fri, 9 Jun 2017 14:26:35 -0400 Subject: Clean up the loading/changing of font family/size (still need to update the font boxes to reflect the currently visible tab). --- src-qt5/desktop-utils/lumina-textedit/MainUI.cpp | 16 +++++++++++----- src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp | 3 +-- 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'src-qt5/desktop-utils') diff --git a/src-qt5/desktop-utils/lumina-textedit/MainUI.cpp b/src-qt5/desktop-utils/lumina-textedit/MainUI.cpp index 40ff2c71..e6c523ee 100644 --- a/src-qt5/desktop-utils/lumina-textedit/MainUI.cpp +++ b/src-qt5/desktop-utils/lumina-textedit/MainUI.cpp @@ -213,6 +213,9 @@ void MainUI::OpenFile(QString file){ edit->showLineNumbers(ui->actionLine_Numbers->isChecked()); edit->setLineWrapMode( ui->actionWrap_Lines->isChecked() ? QPlainTextEdit::WidgetWidth : QPlainTextEdit::NoWrap); edit->setFocusPolicy(Qt::ClickFocus); //no "tabbing" into this widget + QFont font = fontbox->currentFont(); + font.setPointSize( fontSizes->value() ); + edit->document()->setDefaultFont(font); } tabWidget->setCurrentWidget(edit); edit->LoadFile(files[i]); @@ -238,17 +241,20 @@ void MainUI::SaveFileAs(){ cur->SaveFile(true); } -void MainUI::fontChanged(const QFont &font){ +void MainUI::fontChanged(const QFont&){ + if(currentEditor()==0){ return; } //Save this font for later + QFont font = fontbox->currentFont(); + font.setPointSize( fontSizes->value() ); settings->setValue("lastfont", font.toString()); - //Now apply this font to all the open editors - //QApplication::setFont(font, "PlainTextEditor"); + currentEditor()->document()->setDefaultFont(font); } void MainUI::changeFontSize(int newFontSize){ - QFont currentFont = fontbox->currentFont(); + if(currentEditor()==0){ return; } + QFont currentFont = currentEditor()->document()->defaultFont(); currentFont.setPointSize(newFontSize); - //QApplication::setFont(currentFont, "PlainTextEditor"); + currentEditor()->document()->setDefaultFont(currentFont); } void MainUI::changeTabsLocation(QAction *act){ diff --git a/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp b/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp index 9c264fca..46ca056b 100644 --- a/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp +++ b/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp @@ -61,8 +61,7 @@ void SyntaxFile::SetupDocument(QPlainTextEdit* editor){ QString type = formatObj.value("font_type").toString(); QFont font = editor->document()->defaultFont(); // current font if(type=="monospace"){ - font = QFont("monospace"); - //font = QFontDatabase::systemFont(QFontDatabase::FixedFont); //get the default fixed-size font for the system + font.setFamily("monospace"); //Make sure we don't change other properties of the font like size } font.setStyle(QFont::StyleNormal); font.setStyleStrategy(QFont::PreferAntialias); -- cgit