diff options
author | Ken Moore <ken@pcbsd.org> | 2016-09-12 10:16:09 -0400 |
---|---|---|
committer | Ken Moore <ken@pcbsd.org> | 2016-09-12 10:16:09 -0400 |
commit | ccc621aed0fe8674dacfcdab18e42559ad3218c4 (patch) | |
tree | a6e06a4c56d302300a124cfae1a5829c602292e2 /src-qt5 | |
parent | Cleanup a couple syntax highlighting rules for .rst files. (diff) | |
download | lumina-ccc621aed0fe8674dacfcdab18e42559ad3218c4.tar.gz lumina-ccc621aed0fe8674dacfcdab18e42559ad3218c4.tar.bz2 lumina-ccc621aed0fe8674dacfcdab18e42559ad3218c4.zip |
Add a font selector option to LTE, so monospaced fonts can be used as needed for particular users.
Diffstat (limited to 'src-qt5')
4 files changed, 32 insertions, 15 deletions
diff --git a/src-qt5/desktop-utils/lumina-textedit/MainUI.cpp b/src-qt5/desktop-utils/lumina-textedit/MainUI.cpp index fd0e44b8..aacb0424 100644 --- a/src-qt5/desktop-utils/lumina-textedit/MainUI.cpp +++ b/src-qt5/desktop-utils/lumina-textedit/MainUI.cpp @@ -19,11 +19,26 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ ui->setupUi(this); + fontbox = new QFontComboBox(this); + fontbox->setFocusPolicy(Qt::NoFocus); + QWidget *spacer = new QWidget(this); + spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + ui->toolBar->addWidget(spacer); + ui->toolBar->addWidget(fontbox); + //Load settings settings = new QSettings("lumina-desktop","lumina-textedit"); + if(settings->contains("lastfont")){ + QFont oldfont; + if(oldfont.fromString(settings->value("lastfont").toString() ) ){ + fontbox->setCurrentFont( oldfont ); + fontChanged(oldfont); //load it right now + } + } Custom_Syntax::SetupDefaultColors(settings); //pre-load any color settings as needed colorDLG = new ColorDialog(settings, this); this->setWindowTitle(tr("Text Editor")); ui->tabWidget->clear(); + //Add keyboard shortcuts closeFindS = new QShortcut(QKeySequence(Qt::Key_Escape), this); connect(closeFindS, SIGNAL(activated()), this, SLOT(closeFindReplace()) ); ui->groupReplace->setVisible(false); @@ -57,6 +72,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ connect(ui->line_find, SIGNAL(returnPressed()), this, SLOT(findNext()) ); connect(ui->line_replace, SIGNAL(returnPressed()), this, SLOT(replaceOne()) ); connect(colorDLG, SIGNAL(colorsChanged()), this, SLOT(UpdateHighlighting()) ); + connect(fontbox, SIGNAL(currentFontChanged(const QFont&)), this, SLOT(fontChanged(const QFont&)) ); updateIcons(); //Now load the initial size of the window QSize lastSize = settings->value("lastSize",QSize()).toSize(); @@ -171,6 +187,13 @@ void MainUI::SaveFileAs(){ cur->SaveFile(true); } +void MainUI::fontChanged(const QFont &font){ + //Save this font for later + settings->setValue("lastfont", font.toString()); + //Now apply this font to all the open editors + QApplication::setFont(font, "PlainTextEditor"); +} + void MainUI::UpdateHighlighting(QAction *act){ if(act!=0){ //Single-editor change @@ -297,19 +320,10 @@ void MainUI::replaceOne(){ PlainTextEditor *cur = currentEditor(); if(cur==0){ return; } //See if the current selection matches the find field first - bool done = false; if(cur->textCursor().selectedText()==ui->line_find->text()){ cur->insertPlainText(ui->line_replace->text()); - //done = true; - }//else{ - //Find/replace the next occurance of the string - bool found = cur->find( ui->line_find->text(), ui->tool_find_casesensitive->isChecked() ? QTextDocument::FindCaseSensitively : QTextDocument::FindFlags() ); - //if(found){ cur->insertPlainText(ui->line_replace->text()); done = true;} - //} - /*if(done){ - //Re-highlight the newly-inserted text - cur->find( ui->line_replace->text(), QTextDocument::FindCaseSensitively | QTextDocument::FindBackward); - }*/ + } + cur->find( ui->line_find->text(), ui->tool_find_casesensitive->isChecked() ? QTextDocument::FindCaseSensitively : QTextDocument::FindFlags() ); } void MainUI::replaceAll(){ diff --git a/src-qt5/desktop-utils/lumina-textedit/MainUI.h b/src-qt5/desktop-utils/lumina-textedit/MainUI.h index a090cde5..fd42428c 100644 --- a/src-qt5/desktop-utils/lumina-textedit/MainUI.h +++ b/src-qt5/desktop-utils/lumina-textedit/MainUI.h @@ -11,6 +11,7 @@ #include <QStringList> #include <QSettings> #include <QShortcut> +#include <QFontComboBox> #include "PlainTextEditor.h" #include "ColorDialog.h" @@ -32,6 +33,7 @@ public slots: private: Ui::MainUI *ui; + QFontComboBox *fontbox; ColorDialog *colorDLG; QSettings *settings; QShortcut *closeFindS; @@ -47,6 +49,7 @@ private slots: void CloseFile(); //current file only void SaveFile(); void SaveFileAs(); + void fontChanged(const QFont &font); //Other Menu Actions void UpdateHighlighting(QAction *act = 0); @@ -74,4 +77,4 @@ protected: settings->setValue("lastSize", ev->size()); } }; -#endif
\ No newline at end of file +#endif diff --git a/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp b/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp index ed3a3eac..7dcad6c3 100644 --- a/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp +++ b/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp @@ -170,7 +170,7 @@ void Custom_Syntax::loadRules(QString type){ rules << rule; rule = SyntaxRule(); //reset rule rule.format.setFontWeight( QFont::Bold ); - rule.pattern = QRegExp("^(\\s*)\\.\\.(\\s*)([a-zA-Z0-9]+)::\\s"); + rule.pattern = QRegExp("^(\\s*)\\.\\.(\\s*)([a-zA-Z0-9]+)::"); rules << rule; //Functions rule = SyntaxRule(); //reset rule diff --git a/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.h b/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.h index e4c4242c..781ff65d 100644 --- a/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.h +++ b/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.h @@ -61,14 +61,14 @@ protected: //Find the end of the current rule int end = splitrules[splitactive].endPattern.indexIn(text, start); if(end==-1){ - qDebug() << "Highlight to end of line:" << text << start; + //qDebug() << "Highlight to end of line:" << text << start; //rule did not finish - apply to all if(start>0){ setFormat(start-1, text.length()-start+1, splitrules[splitactive].format); } else{ setFormat(start, text.length()-start, splitrules[splitactive].format); } break; //stop looking for more multi-line patterns }else{ //Found end point within the same line - qDebug() << "Highlight to particular point:" << text << start << end; + //qDebug() << "Highlight to particular point:" << text << start << end; int len = end-start+splitrules[splitactive].endPattern.matchedLength(); if(start>0){ start--; len++; } //need to include the first character as well setFormat(start, len , splitrules[splitactive].format); |