From ab92d95baff6b3db56e14419da2279013aedbcb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=88=AC=E5=B1=B1=E8=99=8E?= Date: Sun, 12 Feb 2023 21:52:31 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E4=BF=AE=E6=94=B9=E7=BC=96?= =?UTF-8?q?=E7=A0=81=E4=B8=BAutf8-bom?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/CmpareMode.cpp | 2 +- src/CmpareMode.h | 2 +- src/Sorters.h | 2 +- src/aboutndd.cpp | 2 +- src/aboutndd.h | 2 +- src/batchfindreplace.cpp | 20 +- src/batchfindreplace.h | 2 +- src/bigfilemessage.cpp | 2 +- src/bigfilemessage.h | 2 +- src/cceditor/ccnotepad.cpp | 2 +- src/cceditor/ccnotepad.h | 2 +- src/cceditor/filemanager.cpp | 2 +- src/cceditor/filemanager.h | 38 +- src/columnedit.cpp | 10 +- src/columnedit.h | 2 +- src/common.cpp | 2 +- src/common.h | 2 +- src/ctipwin.cpp | 2 +- src/ctipwin.h | 2 +- src/doctypelistview.h | 2 +- src/draglineedit.cpp | 6 +- src/draglineedit.h | 8 +- src/extLexermanager.cpp | 16 +- src/extlexermanager.h | 10 +- src/filecmprulewin.cpp | 2 +- src/filecmprulewin.h | 2 +- src/filelistview.cpp | 12 +- src/filelistview.h | 2 +- src/findcmpwin.cpp | 2 +- src/findcmpwin.h | 2 +- src/findresultwin.cpp | 2 +- src/findresultwin.h | 2 +- src/findwin.cpp | 2 +- src/findwin.h | 2 +- src/gotolinewin.cpp | 2 +- src/gotolinewin.h | 2 +- src/hexcmprangewin.cpp | 6 +- src/hexcmprangewin.h | 2 +- src/hexfilegoto.cpp | 4 +- src/hexfilegoto.h | 2 +- src/hexrulewin.cpp | 2 +- src/hexrulewin.h | 2 +- src/include/pluginGl.h | 16 +- src/langextset.cpp | 22 +- src/langextset.h | 2 +- src/langstyledefine.cpp | 2 +- src/langstyledefine.h | 2 +- src/mytreeview.cpp | 2 +- src/mytreeview.h | 2 +- src/nddsetting.cpp | 70 ++-- src/nddsetting.h | 34 +- src/ndstyleditemdelegate.cpp | 14 +- src/ndstyleditemdelegate.h | 2 +- src/plugin.cpp | 2 +- src/plugin.h | 2 +- src/plugin/helloworld/helloworld.vcxproj | 182 --------- .../helloworld/helloworld.vcxproj.filters | 69 ---- src/plugin/helloworld/helloworldexport.cpp | 2 +- src/plugin/helloworld/qttestclass.cpp | 2 +- src/plugin/helloworld/qttestclass.h | 2 +- src/plugin/test/test.cpp | 2 +- src/pluginGl.h | 16 +- src/pluginmgr.cpp | 2 +- src/pluginmgr.h | 2 +- .../Python/config-tests/cfgtest_Qsci.cpp | 2 +- src/qscint/scintilla/include/Scintilla.h | 2 +- src/qscint/scintilla/lexers/LexAVS.cpp | 2 +- src/qscint/scintilla/src/Catalogue.cpp | 2 +- src/qscint/src/Qsci/qsciglobal.h | 1 + src/qscint/src/Qsci/qscilexerasm.h | 2 +- src/qscint/src/Qsci/qscilexerglobal.h | 2 +- src/qscint/src/Qsci/qscilexerr.h | 2 +- src/qscint/src/Qsci/qscilexervb.h | 2 +- src/qscint/src/qscilexerasm.cpp | 2 +- src/qscint/src/qscilexerglobal.cpp | 2 +- src/qscint/src/qscilexerr.cpp | 2 +- src/qscint/src/qscilexervb.cpp | 2 +- src/qtlangset.cpp | 344 +++++++++--------- src/qtlangset.h | 2 +- src/rcglobal.h | 2 +- src/renamewin.cpp | 2 +- src/renamewin.h | 2 +- src/rgba_icons.h | 2 +- src/scintillaeditview.cpp | 2 +- src/scintillaeditview.h | 2 +- src/scintillahexeditview.cpp | 2 +- src/scintillahexeditview.h | 2 +- src/shortcutkeyeditwin.cpp | 6 +- src/shortcutkeyeditwin.h | 2 +- src/shortcutkeymgr.cpp | 28 +- src/shortcutkeymgr.h | 4 +- src/styleset.cpp | 28 +- src/styleset.h | 6 +- src/texteditsetwin.h | 2 +- src/userlexdef.cpp | 16 +- src/userlexdef.h | 2 +- 96 files changed, 438 insertions(+), 688 deletions(-) delete mode 100755 src/plugin/helloworld/helloworld.vcxproj delete mode 100755 src/plugin/helloworld/helloworld.vcxproj.filters diff --git a/src/CmpareMode.cpp b/src/CmpareMode.cpp index ae8a250..f0618bd 100755 --- a/src/CmpareMode.cpp +++ b/src/CmpareMode.cpp @@ -1,4 +1,4 @@ -#include "CmpareMode.h" +#include "CmpareMode.h" #include "Encode.h" #include "rcglobal.h" diff --git a/src/CmpareMode.h b/src/CmpareMode.h index d150c0d..a92736b 100755 --- a/src/CmpareMode.h +++ b/src/CmpareMode.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include #include diff --git a/src/Sorters.h b/src/Sorters.h index 0ad3e9d..4f3e567 100755 --- a/src/Sorters.h +++ b/src/Sorters.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include #include diff --git a/src/aboutndd.cpp b/src/aboutndd.cpp index 0c1392f..eb86931 100644 --- a/src/aboutndd.cpp +++ b/src/aboutndd.cpp @@ -1,4 +1,4 @@ -#include "aboutndd.h" +#include "aboutndd.h" AboutNdd::AboutNdd(QWidget *parent) : QWidget(parent) diff --git a/src/aboutndd.h b/src/aboutndd.h index 2e23f65..8ce15e8 100755 --- a/src/aboutndd.h +++ b/src/aboutndd.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include "ui_aboutndd.h" diff --git a/src/batchfindreplace.cpp b/src/batchfindreplace.cpp index 0a49e15..9dabbfc 100755 --- a/src/batchfindreplace.cpp +++ b/src/batchfindreplace.cpp @@ -1,4 +1,4 @@ -#include "batchfindreplace.h" +#include "batchfindreplace.h" #include "scintillaeditview.h" #include "ccnotepad.h" #include "progresswin.h" @@ -31,7 +31,7 @@ void BatchFindReplace::setTabWidget(QTabWidget* editTabWidget) m_editTabWidget = editTabWidget; } -//Զǰڵ״̬˱仯Ҫ϶Ϊ״β +//自动调整当前窗口的状态,如果发生了变化,则需要认定为是首次查找 QWidget* BatchFindReplace::autoAdjustCurrentEditWin() { QWidget* pw = m_editTabWidget->currentWidget(); @@ -53,7 +53,7 @@ void BatchFindReplace::appendToFindTable(QString findKeyword) ui.findReplaceTable->setItem(rNum, 1, new QTableWidgetItem()); } -//ﲻ׷ӣDz룬ӦItemѾڡ򲻲 +//这里不能追加,而是插入,即对应的Item必须已经存在。否则不插入 void BatchFindReplace::insertToReplaceTable(int row, QString replaceKeyword) { QTableWidgetItem* item = ui.findReplaceTable->item(row, 1); @@ -97,11 +97,11 @@ void BatchFindReplace::appendToFindReplaceTable(QStringList& findKeyword) bool BatchFindReplace::tranInputKeyword(QString& findKeyWord, QStringList& outputKeyWordList) { - //ѿհַո\t \r\n ַ滻Ϊո + //把空白字符,空格或者\t \r\n 等字符进行替换为空格 QRegExp re("\\s"); findKeyWord.replace(re, QString(" ")); - //ٽпոָ + //再进行空格分隔处理 outputKeyWordList = findKeyWord.split(" "); if (outputKeyWordList.size() > 20000) @@ -110,7 +110,7 @@ bool BatchFindReplace::tranInputKeyword(QString& findKeyWord, QStringList& outpu return false; } - //ɾÿһյԪ + //删除每一个空的元素 for (int i = outputKeyWordList.size() - 1; i >= 0; --i) { if (outputKeyWordList[i].trimmed().isEmpty()) @@ -166,7 +166,7 @@ void BatchFindReplace::on_freshBtClick() } } -//ҹ +//进行批量查找工作 void BatchFindReplace::on_findBtClick() { if (m_mainNotepad != nullptr && m_mainNotepad) @@ -213,7 +213,7 @@ void BatchFindReplace::on_findBtClick() } } -//滻 +//进行批量替换工作 void BatchFindReplace::on_replaceBtClick() { if (m_mainNotepad != nullptr && m_mainNotepad) @@ -306,9 +306,9 @@ void BatchFindReplace::on_import() QFileDialog fd(this, QString(), CCNotePad::s_lastOpenDirPath); fd.setFileMode(QFileDialog::ExistingFile); - if (fd.exec() == QDialog::Accepted) //ɹִ + if (fd.exec() == QDialog::Accepted) //如果成功的执行 { - QStringList fileNameList = fd.selectedFiles(); //ļб + QStringList fileNameList = fd.selectedFiles(); //返回文件列表的名称 QFileInfo fi(fileNameList[0]); QSettings setting(fi.filePath(), QSettings::IniFormat); diff --git a/src/batchfindreplace.h b/src/batchfindreplace.h index 7ae86f9..fdef375 100755 --- a/src/batchfindreplace.h +++ b/src/batchfindreplace.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include diff --git a/src/bigfilemessage.cpp b/src/bigfilemessage.cpp index 247d876..c3c699b 100755 --- a/src/bigfilemessage.cpp +++ b/src/bigfilemessage.cpp @@ -1,4 +1,4 @@ -#include "bigfilemessage.h" +#include "bigfilemessage.h" BigFileMessage::BigFileMessage(QWidget *parent) : QDialog(parent), m_result(-1) diff --git a/src/bigfilemessage.h b/src/bigfilemessage.h index a66a162..97e1b1f 100755 --- a/src/bigfilemessage.h +++ b/src/bigfilemessage.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "ccnotepad.h" #include diff --git a/src/cceditor/ccnotepad.cpp b/src/cceditor/ccnotepad.cpp index ed766b2..18d491f 100755 --- a/src/cceditor/ccnotepad.cpp +++ b/src/cceditor/ccnotepad.cpp @@ -1,4 +1,4 @@ -#include +#include #include "ccnotepad.h" #include "filemanager.h" #include "Encode.h" diff --git a/src/cceditor/ccnotepad.h b/src/cceditor/ccnotepad.h index 0b63a5c..84ab6e6 100755 --- a/src/cceditor/ccnotepad.h +++ b/src/cceditor/ccnotepad.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include diff --git a/src/cceditor/filemanager.cpp b/src/cceditor/filemanager.cpp index 96383cc..cd0b0e0 100755 --- a/src/cceditor/filemanager.cpp +++ b/src/cceditor/filemanager.cpp @@ -1,4 +1,4 @@ -#include "filemanager.h" +#include "filemanager.h" #include "scintillaeditview.h" #include "scintillahexeditview.h" #include "CmpareMode.h" diff --git a/src/cceditor/filemanager.h b/src/cceditor/filemanager.h index 565f9aa..fe5dc97 100755 --- a/src/cceditor/filemanager.h +++ b/src/cceditor/filemanager.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "common.h" #include "rcglobal.h" @@ -11,7 +11,7 @@ class ScintillaEditView; class ScintillaHexEditView; -//С100kļһȫȡ +//小于100k的文件一次性全部读取完毕 const int LITTLE_FILE_MAX = 1024000; enum ERROR_TYPE { @@ -29,16 +29,16 @@ struct NewFileIdMgr { } }; -//ļϢ +//管理二进制文件的信息 struct HexFileMgr { QString filePath; QFile* file; qint64 fileOffset; qint64 fileSize; - qint16 lineSize;//ÿζȡУĬΪ64Уû16ַ + qint16 lineSize;//每次读取多少行,默认为64行,没行16个字符 char* contentBuf; int contentRealSize; - bool onetimeRead; //Ƿһȫȡڴ档СڵLITTLE_FILE_MAXIJŻȫȡ + bool onetimeRead; //是否一次性全部读取到内存。小于等于LITTLE_FILE_MAX的才会全部读取 HexFileMgr() :file(nullptr), fileOffset(0), lineSize(64), fileSize(0), contentBuf(nullptr), contentRealSize(0),onetimeRead(false) { @@ -62,17 +62,17 @@ private: HexFileMgr(const HexFileMgr&) = delete; }; -//ıļϢ +//管理大文本文件的信息 struct TextFileMgr { QString filePath; QFile* file; qint64 fileOffset; qint64 fileSize; - qint16 lineSize;//ÿζȡУĬÿζȡ1024С󲻳1Mݡ + qint16 lineSize;//每次读取多少行,默认每次读取1024行。但是最大不超过1M的内容。 char* contentBuf; int contentRealSize; int loadWithCode; - int lineEndType;//βͣwin linux mac + int lineEndType;//行尾类型,win linux mac TextFileMgr() :file(nullptr), fileOffset(0), lineSize(64), fileSize(0), contentBuf(nullptr), contentRealSize(0), loadWithCode(CODE_ID::UNKOWN),lineEndType(RC_LINE_FORM::UNKNOWN_LINE) { @@ -98,23 +98,23 @@ private: }; struct BlockIndex { - qint64 fileOffset;//Ŀʼַ - quint32 fileSize;//ĴС - quint32 lineNumStart;//кŵĿʼֵ - quint32 lineNum;//е + qint64 fileOffset;//块的开始地址 + quint32 fileSize;//块的大小 + quint32 lineNumStart;//块中行号的开始值 + quint32 lineNum;//块中的行数量 }; -//ıļ,Ա༭Ϣ +//管理大文本文件,可以编辑的信息 struct BigTextEditFileMgr { QString filePath; QFile* file; - uchar* filePtr;//ʹõļӳķʽ - quint32 m_curBlockIndex; //ǰչʾеĿ - int loadWithCode; //ԺֱؽļĬUTF8 - int lineEndType;//βͣwin linux mac - static const qint16 BLOCK_SIZE = 1;//СλMʼ4MֿԽԽ࣬ôһжλеλԽ + uchar* filePtr;//使用的是文件映射的方式打开 + quint32 m_curBlockIndex; //当前展示中的块索引序号 + int loadWithCode; //以何种编码来加载解析文件。默认UTF8 + int lineEndType;//行尾类型,win linux mac + static const qint16 BLOCK_SIZE = 1;//块大小,单位M。开始是4M,发现块越大,行越多,那么在一块中定位行的位置越慢 - QVector blocks;//ÿһļʱҪ + QVector blocks;//每一块的索引。打开文件的时候,需要建立该索引 BigTextEditFileMgr():filePtr(nullptr), file(nullptr), m_curBlockIndex(0), loadWithCode(CODE_ID::UNKOWN), lineEndType(RC_LINE_FORM::UNKNOWN_LINE) { diff --git a/src/columnedit.cpp b/src/columnedit.cpp index 3fae34a..d607042 100755 --- a/src/columnedit.cpp +++ b/src/columnedit.cpp @@ -1,4 +1,4 @@ -#include "columnedit.h" +#include "columnedit.h" #include "scintillaeditview.h" ColumnEdit::ColumnEdit(QWidget *parent) @@ -54,7 +54,7 @@ void ColumnEdit::slot_bigChar(bool isCheck) ui.capital->setEnabled(isCheck); } -//Զǰڵ״̬ +//自动调整当前窗口的状态 QWidget* ColumnEdit::autoAdjustCurrentEditWin() { QWidget* pw = m_editTabWidget->currentWidget(); @@ -93,7 +93,7 @@ void ColumnEdit::slot_ok() QString prefix = ui.prefix->text(); bool isCapital = ui.capital->isChecked(); - //Dzıģʽ + //是插入文本模式 if (ui.textGroupBox->isChecked()) { @@ -138,7 +138,7 @@ void ColumnEdit::slot_ok() } else { - //ҪӸʾ + //这里要加个提示 QApplication::beep(); return; } @@ -209,7 +209,7 @@ void ColumnEdit::slot_ok() lineText.chrg.cpMin = static_cast(lineBegin); lineText.chrg.cpMax = static_cast(lineEnd); lineText.lpstrText = lineData.data(); - //ȡԭʼе + //获取原始行的内容 pEdit->SendScintilla(SCI_GETTEXTRANGE, 0, &lineText); if (lineEndCol < cursorCol) diff --git a/src/columnedit.h b/src/columnedit.h index d650e47..7263253 100755 --- a/src/columnedit.h +++ b/src/columnedit.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include diff --git a/src/common.cpp b/src/common.cpp index d5f43ab..0bab036 100755 --- a/src/common.cpp +++ b/src/common.cpp @@ -1,4 +1,4 @@ -#include "common.h" +#include "common.h" int nbDigitsFromNbLines(size_t nbLines) diff --git a/src/common.h b/src/common.h index 7e61704..a09b19b 100755 --- a/src/common.h +++ b/src/common.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include diff --git a/src/ctipwin.cpp b/src/ctipwin.cpp index f894ad8..d972901 100755 --- a/src/ctipwin.cpp +++ b/src/ctipwin.cpp @@ -1,4 +1,4 @@ -#include "ctipwin.h" +#include "ctipwin.h" #include diff --git a/src/ctipwin.h b/src/ctipwin.h index c5a3cb5..db85e10 100755 --- a/src/ctipwin.h +++ b/src/ctipwin.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include "ui_ctipwin.h" diff --git a/src/doctypelistview.h b/src/doctypelistview.h index 93fb877..874069b 100755 --- a/src/doctypelistview.h +++ b/src/doctypelistview.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include diff --git a/src/draglineedit.cpp b/src/draglineedit.cpp index c21f3de..a5e35ba 100755 --- a/src/draglineedit.cpp +++ b/src/draglineedit.cpp @@ -1,4 +1,4 @@ -#include "draglineedit.h" +#include "draglineedit.h" DragLineEdit::DragLineEdit(QWidget *parent) : QLineEdit(parent) @@ -12,9 +12,9 @@ DragLineEdit::~DragLineEdit() void DragLineEdit::dragEnterEvent(QDragEnterEvent* event) { - if (event->mimeData()->hasFormat("text/uri-list")) //ֻܴıļ + if (event->mimeData()->hasFormat("text/uri-list")) //只能打开文本文件 { - event->accept(); //ڲϷŶ + event->accept(); //可以在这个窗口部件上拖放对象 } else { diff --git a/src/draglineedit.h b/src/draglineedit.h index f37172c..4965c2a 100755 --- a/src/draglineedit.h +++ b/src/draglineedit.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include @@ -16,10 +16,10 @@ public: protected: - ///< ϶ļ + ///< 拖动文件到窗口 触发 void dragEnterEvent(QDragEnterEvent* event) override; - ///< ϶ļƶļ + ///< 拖动文件到窗口移动文件 触发 void dragMoveEvent(QDragMoveEvent* event) override; - ///< ϶ļͷļ + ///< 拖动文件到窗口释放文件触发 void dropEvent(QDropEvent* event) override; }; diff --git a/src/extLexermanager.cpp b/src/extLexermanager.cpp index af9d2a1..56618e2 100755 --- a/src/extLexermanager.cpp +++ b/src/extLexermanager.cpp @@ -1,7 +1,7 @@ -#include "extlexermanager.h" +#include "extlexermanager.h" -//רûԶExt ʷLexerࡣ -//һļext׺ٸ֪ʹʲôlexer﷨ +//专门用来管理用户自定义的Ext 和 词法Lexer关联的类。 +//给出一个文件的ext后缀,快速告知该使用什么lexer进行语法高亮 ExtLexerManager* ExtLexerManager::s_instance = nullptr; @@ -42,9 +42,9 @@ void ExtLexerManager::remove(QString ext) } -//ext:ļĺ׺ langTagName:Եtag -//lexerId ﷨idûԶ壬ȻL_USER_TXT,L_USER_CPP,L_USER_HTML,L_USER_JS,L_USER_XML, L_USER_INI еһ -//langTagName:ֻû£ҪtagNameΪûlexertagnameǹ̶ġ +//ext:文件的后缀名 langTagName:语言的tag名称 +//lexerId 语法的id,如果是用户自定义,则必然是L_USER_TXT,L_USER_CPP,L_USER_HTML,L_USER_JS,L_USER_XML, L_USER_INI 中的一个。 +//langTagName:只有在用户定义语言下,才需要tagName。因为非用户定义的lexer,其tagname是固定的。 void ExtLexerManager::addNewExtType(QString ext, LangType lexerId, QString langTagName) { LexerInfo value(lexerId, langTagName); @@ -61,7 +61,7 @@ bool ExtLexerManager::getLexerTypeByExt(QString ext, LexerInfo& lexer) return false; } -//гtagйļ׺б +//列出tag语言下面的所有关联的文件后缀列表 void ExtLexerManager::getExtlistByLangTag(QString tag, QStringList& extList) { for (QMap::iterator it = m_extToLexerIdMap.begin(); it != m_extToLexerIdMap.end(); ++it) @@ -75,7 +75,7 @@ void ExtLexerManager::getExtlistByLangTag(QString tag, QStringList& extList) } } -//гtagйļ׺б +//列出tag语言下面的所有关联的文件后缀列表 void ExtLexerManager::getExtlistByLangTag(QMap& extLangMap) { for (QMap::iterator it = m_extToLexerIdMap.begin(); it != m_extToLexerIdMap.end(); ++it) diff --git a/src/extlexermanager.h b/src/extlexermanager.h index cc59df6..6dc3427 100755 --- a/src/extlexermanager.h +++ b/src/extlexermanager.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include @@ -26,8 +26,8 @@ enum LangType { #endif struct LexerInfo{ - LangType lexerId; //L_USER_DEFINEʾĸ - QString tagName; //tagơ + LangType lexerId; //如果是L_USER_DEFINE,则表示母版的类型 + QString tagName; //语言tag名称。 bool isUserDefineLangs() { return (lexerId > L_USER_DEFINE); @@ -55,10 +55,10 @@ public: bool getLexerTypeByExt(QString ext, LexerInfo& lexer); - //гtagйļ׺б + //列出tag语言下面的所有关联的文件后缀列表 void getExtlistByLangTag(QString tag, QStringList& extList); - //гйļ׺б + //列出所有语言下面的所有关联的文件后缀列表 void getExtlistByLangTag(QMap& extLangMap); diff --git a/src/filecmprulewin.cpp b/src/filecmprulewin.cpp index ecf631c..c6c76b6 100755 --- a/src/filecmprulewin.cpp +++ b/src/filecmprulewin.cpp @@ -1,4 +1,4 @@ -#include "filecmprulewin.h" +#include "filecmprulewin.h" FileCmpRuleWin::FileCmpRuleWin(int mode, bool blankMath, int equalRato,QWidget *parent) : QWidget(parent) diff --git a/src/filecmprulewin.h b/src/filecmprulewin.h index bc569e6..44cd701 100755 --- a/src/filecmprulewin.h +++ b/src/filecmprulewin.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include "ui_filecmprulewin.h" diff --git a/src/filelistview.cpp b/src/filelistview.cpp index d6663e5..ce9ea39 100755 --- a/src/filelistview.cpp +++ b/src/filelistview.cpp @@ -1,11 +1,11 @@ -#include "filelistview.h" +#include "filelistview.h" #include "rcglobal.h" #include "ccnotepad.h" #include #include -//ʾļԺ󣬰ļڸб +//当显示文件多了以后,把所有文件列在该列表中 FileListView::FileListView(QWidget *parent) : QWidget(parent), m_pNotepad(nullptr) @@ -14,7 +14,7 @@ FileListView::FileListView(QWidget *parent) connect(ui.filelistWidget, &QListWidget::itemDoubleClicked, this, &FileListView::itemDoubleClicked); - setContextMenuPolicy(Qt::CustomContextMenu); //öֵ + setContextMenuPolicy(Qt::CustomContextMenu); //设置枚举值 connect(this, &QListWidget::customContextMenuRequested, this, &FileListView::slot_ShowPopMenu); } @@ -29,7 +29,7 @@ void FileListView::setNotepadWin(QWidget* pNotepad) m_pNotepad = pNotepad; } -//Ҽ˵ +//右键菜单 void FileListView::slot_ShowPopMenu(const QPoint& pos) { QListWidgetItem* curItem = ui.filelistWidget->itemAt(pos); @@ -53,11 +53,11 @@ void FileListView::slot_ShowPopMenu(const QPoint& pos) { pNotePad->closeFileByEditWidget(m_fileEditMap.value(curItem->text()).pEditWidget); } - //עﲻҪɾm_fileEditMapԪأΪcloseFileByEditWidgetá + //注意这里不需要在删除m_fileEditMap元素,因为closeFileByEditWidget里面会调用。 } }); - //ûƱʾǶitemڶӦļֻռλ + //没有名称表示是对齐的item,不存在对应的文件,只是占位 if (curItem->text().isEmpty()) { actionAdd->setEnabled(false); diff --git a/src/filelistview.h b/src/filelistview.h index 32c2a49..d36719f 100755 --- a/src/filelistview.h +++ b/src/filelistview.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include diff --git a/src/findcmpwin.cpp b/src/findcmpwin.cpp index 93186d1..67b7329 100755 --- a/src/findcmpwin.cpp +++ b/src/findcmpwin.cpp @@ -1,4 +1,4 @@ -#include "findcmpwin.h" +#include "findcmpwin.h" #include "qscidisplaywindow.h" #include #include diff --git a/src/findcmpwin.h b/src/findcmpwin.h index 4f53fca..8ea9438 100755 --- a/src/findcmpwin.h +++ b/src/findcmpwin.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include diff --git a/src/findresultwin.cpp b/src/findresultwin.cpp index 75af255..228cba6 100755 --- a/src/findresultwin.cpp +++ b/src/findresultwin.cpp @@ -1,4 +1,4 @@ -#include "findresultwin.h" +#include "findresultwin.h" #include "findwin.h" #include "common.h" #include "styleset.h" diff --git a/src/findresultwin.h b/src/findresultwin.h index 408c101..73b8f79 100755 --- a/src/findresultwin.h +++ b/src/findresultwin.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include diff --git a/src/findwin.cpp b/src/findwin.cpp index 14aad6c..55d97f6 100755 --- a/src/findwin.cpp +++ b/src/findwin.cpp @@ -1,4 +1,4 @@ -#include "findwin.h" +#include "findwin.h" #include "scintillaeditview.h" #include "ccnotepad.h" #include "progresswin.h" diff --git a/src/findwin.h b/src/findwin.h index 6eebf1f..7bb76ea 100755 --- a/src/findwin.h +++ b/src/findwin.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include diff --git a/src/gotolinewin.cpp b/src/gotolinewin.cpp index f57c113..520c87a 100755 --- a/src/gotolinewin.cpp +++ b/src/gotolinewin.cpp @@ -1,4 +1,4 @@ -#include "gotolinewin.h" +#include "gotolinewin.h" GoToLineWin::GoToLineWin(QWidget *parent) : QWidget(parent) diff --git a/src/gotolinewin.h b/src/gotolinewin.h index bb1417b..9c782ed 100755 --- a/src/gotolinewin.h +++ b/src/gotolinewin.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include "ui_gotolinewin.h" diff --git a/src/hexcmprangewin.cpp b/src/hexcmprangewin.cpp index 20cd7d6..d72ca57 100755 --- a/src/hexcmprangewin.cpp +++ b/src/hexcmprangewin.cpp @@ -1,4 +1,4 @@ -#include "hexcmprangewin.h" +#include "hexcmprangewin.h" #include #include @@ -23,7 +23,7 @@ void HexCmpRangeWin::slot_ok() close(); } -//ͨߵֵͬұߡұ߲ͬߣû +//通过左边的值同步右边。右边不同步左边,加速用户输入 void HexCmpRangeWin::slot_asyncStartPos(const QString& text) { ui.rightStartPos->setText(text); @@ -35,7 +35,7 @@ void HexCmpRangeWin::slot_asyncLenPos(const QString& text) } -//ȡ򲻷κЧΧֵ;ֵҲ +//如果取消,则不返回任何有效范围值;错误值也是 const int MAX_CMP_LENS = 1024 * 1024 * 10; void HexCmpRangeWin::getRange(bool & isCancel, qint64 & leftStartPos, int & leftCmpLen, qint64 & rightStartPos, int & rightCmpLen) diff --git a/src/hexcmprangewin.h b/src/hexcmprangewin.h index ef1ded4..7cf213e 100755 --- a/src/hexcmprangewin.h +++ b/src/hexcmprangewin.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include "ui_hexcmprangewin.h" diff --git a/src/hexfilegoto.cpp b/src/hexfilegoto.cpp index 29b7639..d3cc790 100755 --- a/src/hexfilegoto.cpp +++ b/src/hexfilegoto.cpp @@ -1,4 +1,4 @@ -#include "hexfilegoto.h" +#include "hexfilegoto.h" HexFileGoto::HexFileGoto(QWidget *parent) : QWidget(parent) @@ -13,7 +13,7 @@ HexFileGoto::~HexFileGoto() { } -//ʾΪ +//显示为 void HexFileGoto::slot_showDecInfo(const QString &text) { bool ok; diff --git a/src/hexfilegoto.h b/src/hexfilegoto.h index d34f29c..ab3c2cb 100755 --- a/src/hexfilegoto.h +++ b/src/hexfilegoto.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include "ui_hexfilegoto.h" diff --git a/src/hexrulewin.cpp b/src/hexrulewin.cpp index 85caa65..50d09bf 100755 --- a/src/hexrulewin.cpp +++ b/src/hexrulewin.cpp @@ -1,4 +1,4 @@ -#include "hexrulewin.h" +#include "hexrulewin.h" HexRuleWin::HexRuleWin(int mode, int highlight, QWidget *parent): QWidget(parent), m_mode(mode), m_isHighlightBackgroud(highlight) { diff --git a/src/hexrulewin.h b/src/hexrulewin.h index 8aa7f13..4701f5a 100755 --- a/src/hexrulewin.h +++ b/src/hexrulewin.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include "ui_hexrulewin.h" diff --git a/src/include/pluginGl.h b/src/include/pluginGl.h index 005c35b..8250d25 100755 --- a/src/include/pluginGl.h +++ b/src/include/pluginGl.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include @@ -16,13 +16,13 @@ struct ndd_proc_data { - QString m_strPlugName; // ѡ - QString m_strFilePath; //lib ȫ·ѡڲù,򴫵 - QString m_strComment; //˵ - QString m_version; //汾롣ѡ - QString m_auther;//ơѡ - int m_menuType;//˵͡0ʹö˵ 1˵ - QMenu* m_rootMenu;//m_menuType = 1˵ĵֵַnullptr + QString m_strPlugName; //插件名称 必选 + QString m_strFilePath; //lib 插件的全局路径。必选。插件内部不用管,主程序传递下来 + QString m_strComment; //插件说明 + QString m_version; //版本号码。可选 + QString m_auther;//作者名称。可选 + int m_menuType;//菜单类型。0:不使用二级菜单 1:创建二级菜单 + QMenu* m_rootMenu;//如果m_menuType = 1,给出二级根菜单的地址。其他值nullptr ndd_proc_data(): m_rootMenu(nullptr), m_menuType(0) { diff --git a/src/langextset.cpp b/src/langextset.cpp index 3db6f03..a1db834 100755 --- a/src/langextset.cpp +++ b/src/langextset.cpp @@ -1,4 +1,4 @@ -#include "langextset.h" +#include "langextset.h" #include "scintillaeditview.h" #include "extlexermanager.h" #include "ccnotepad.h" @@ -9,8 +9,8 @@ #include int ITEM_CHANGED = Qt::UserRole; -int ITEM_LEX_ID = Qt::UserRole + 1; //Ӧ﷨lexer ID -int ITEM_LEX_EXT_OLD_VALUE = Qt::UserRole + 2; //Ӧ﷨EXTļľֵ +int ITEM_LEX_ID = Qt::UserRole + 1; //对应的语法lexer的 ID +int ITEM_LEX_EXT_OLD_VALUE = Qt::UserRole + 2; //对应的语法关联EXT文件的旧值 LangExtSet::LangExtSet(QWidget *parent) : QMainWindow(parent), m_isChanged(false) @@ -62,7 +62,7 @@ void LangExtSet::initLangName() QTableWidgetItem* item1 = new QTableWidgetItem(extList.join(',')); item1->setData(ITEM_CHANGED, QVariant(false)); - //Ѿֵ޸ĺԱʵʱ޸ڴеĸĶ + //把旧值记起来,后面修改后对比实时修改内存中的改动 item1->setData(ITEM_LEX_EXT_OLD_VALUE, QVariant(extList)); ui.langTableWidget->setItem(langId, 1, item1); @@ -141,12 +141,12 @@ void LangExtSet::slot_save() QString langLexerTag = QString("%1_lexId").arg(langTag); qs.setValue(langLexerTag, lexId); - //ǸļǸڴ棬ʵʱЧ + //上面是更新文件,下面是更新内存,让实时生效 QStringList oldExtList = item->data(ITEM_LEX_EXT_OLD_VALUE).toStringList(); updataExtLexerManager(langTag, lexId, oldExtList, extList); - //ֵΪܲرʱٴ޸ + //更新新值。因为可能不关闭时再次修改 item->setData(ITEM_LEX_EXT_OLD_VALUE, QVariant(extList)); } } @@ -156,15 +156,15 @@ void LangExtSet::slot_save() ui.statusBar->showMessage(tr("Save Finished !"), 10000); } -//ExtLexerManagertagֵ +//更新ExtLexerManager中tag关联的值 void LangExtSet::updataExtLexerManager(QString tag, int lexId, QStringList & oldExtList, QStringList & newExtList) { - //Ѿɵֱɾ + //把旧的直接删除 for (int i = 0; i < oldExtList.size(); ++i) { ExtLexerManager::getInstance()->remove(oldExtList.at(i)); } - //µ¼һ + //把新的重新加入一遍 for (int i = 0; i < newExtList.size(); ++i) { FileExtLexer v; @@ -175,10 +175,10 @@ void LangExtSet::updataExtLexerManager(QString tag, int lexId, QStringList & old } } -//ļĹ׺﷨ +//加载文件的关联后缀到语法中 void LangExtSet::loadExtRelevanceToMagr() { - QString userLangFile = QString("notepad/tag_ext");//Զв.ַдҪ + QString userLangFile = QString("notepad/tag_ext");//自定义语言中不能有.字符,否则可能有错,后续要检查 QSettings qs(QSettings::IniFormat, QSettings::UserScope, userLangFile); qs.setIniCodec("UTF-8"); diff --git a/src/langextset.h b/src/langextset.h index e6ef42b..f20bdd8 100755 --- a/src/langextset.h +++ b/src/langextset.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include "ui_langextset.h" diff --git a/src/langstyledefine.cpp b/src/langstyledefine.cpp index 2df3a4f..3945159 100755 --- a/src/langstyledefine.cpp +++ b/src/langstyledefine.cpp @@ -1,4 +1,4 @@ -#include "langstyledefine.h" +#include "langstyledefine.h" #include "userlexdef.h" #include "extlexermanager.h" diff --git a/src/langstyledefine.h b/src/langstyledefine.h index fdbda84..24438d3 100755 --- a/src/langstyledefine.h +++ b/src/langstyledefine.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include "ui_langstyledefine.h" diff --git a/src/mytreeview.cpp b/src/mytreeview.cpp index 2410c9e..4e28b13 100755 --- a/src/mytreeview.cpp +++ b/src/mytreeview.cpp @@ -1,4 +1,4 @@ -#include "mytreeview.h" +#include "mytreeview.h" MyTreeView::MyTreeView(QWidget *parent) : QTreeView(parent) diff --git a/src/mytreeview.h b/src/mytreeview.h index 75ecccf..aeb9b70 100755 --- a/src/mytreeview.h +++ b/src/mytreeview.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include diff --git a/src/nddsetting.cpp b/src/nddsetting.cpp index 24fd83d..9fdc03d 100755 --- a/src/nddsetting.cpp +++ b/src/nddsetting.cpp @@ -1,4 +1,4 @@ -#include "nddsetting.h" +#include "nddsetting.h" #include #include #include @@ -7,8 +7,8 @@ #include #include -static short version_num = 29; //1.22.0 29 -//ļǷڡʼʧܣ򲻴 +static short version_num = 29; //1.22.0 是29 +//配置文件是否存在。如果初始化失败,则不存在 bool NddSetting::s_isExistDb = false; int NddSetting::s_reference = 0; bool NddSetting::s_isContentChanged = false; @@ -17,10 +17,10 @@ QSettings* NddSetting::s_nddSet = nullptr; QSettings* NddSetting::s_winPosSet = nullptr; -//keyڣkey-valueڣtrue +//如果key不存在,则新增key-value。存在:返回true bool NddSetting::checkNoExistAdd(QString key, QVariant& value) { - //ÿ¼ֶκҪһ£ + //每次新加字段后,这里要检查一下,不存在则新增 if (!s_nddSet->contains(key)) { s_nddSet->setValue(key, value); @@ -34,13 +34,13 @@ bool NddSetting::checkNoExistAdd(QString key, QVariant& value) return true; } -//20220402һǰݿ̴߳ģòҪ߳еá -//Ϊ̷߳ʺͶ̳߳ͻ⡣ļĶд߳н +//20220402这里隐含了一个前置条件:数据库句柄是在主线程创建的,最好不要在子线程中调用。 +//避免因为跨线程访问和多线程冲突访问引发的闪退问题。所以最好配置文件的读写都在主线程中进行 void NddSetting::init() { ++s_reference; - //Ѿʼˣֱӷ + //如果已经初始化过了,则直接返回 if (s_isExistDb) { return; @@ -56,42 +56,42 @@ void NddSetting::init() auto initNddSet = []() { QString key = "signdate"; //QString date = QDate::currentDate().toString(QString("yyyy/M/d")); - //дʱ䣬һУᷢ - //ֱдһȥʱ䣬õһУҪǩ + //不写今天的时间,否则第一次运行,无条件不会发送心跳。 + //直接写一个过去的时间,让第一次运行,总是要签到 addKeyValueToSets(key, "2022/2/20"); QString str; - //tabijȣĬΪ4 + //tab的长度,默认为4 addKeyValueToNumSets("tablens", 4); - //space replace tabո滻tabĬ0, 1Ϊtrue,0Ϊfalse + //space replace tab空格替换tab,默认0, 1为true,0为false addKeyValueToNumSets("tabnouse", 0); addKeyValueToSets("mac", "0"); addKeyValueToNumSets("padtimes", 0); addKeyValueToNumSets("serverip", 0); - //Ƿͬ + //是否高亮不同处背景 addKeyValueToNumSets("hexhigh", 1); addKeyValueToNumSets(VERSION, version_num); - //Ƥid + //皮肤id addKeyValueToNumSets(SKIN_KEY, 0); - //index 0:Զѡ 1: 2 Ӣ + //语言index 0:自动选择 1:中文 2 英文 addKeyValueToNumSets(LANGS_KEY, 0); - //Զ + //开启自动换行 addKeyValueToNumSets(AUTOWARP_KEY, 0); - //Զ + //开启自动缩进 addKeyValueToNumSets(INDENT_KEY, 0); - //ʾհ + //显示空白 addKeyValueToNumSets(SHOWSPACE_KEY, 0); - //ıļޡĬ100M.(50-300) + //最大文本文件的门限。默认100M.(50-300) addKeyValueToNumSets(MAX_BIG_TEXT, 100); addKeyValueToSets(SOFT_KEY, "0"); @@ -107,22 +107,22 @@ void NddSetting::init() addKeyValueToNumSets(FILELISTPOS, Qt::LeftDockWidgetArea); - //Ĭ0ʾ + //默认0不显示 addKeyValueToNumSets(FILELISTSHOW, 0); - //Ĭʾ + //默认显示工具栏 addKeyValueToNumSets(TOOLBARSHOW, 1); - //ҳĬϲѡԴķѶ + //打开网页,默认不勾选,资源耗费多 addKeyValueToNumSets(SHOWWEBADDR, 0); - //ҽĬС + //查找结果框的默认字体大小 addKeyValueToNumSets(FIND_RESULT_FONT_SIZE, 14); }; if (!s_nddSet->contains(VERSION)) { - //߳ʼ + //不存在走初始化流程 initNddSet(); s_isContentChanged = true; } @@ -133,7 +133,7 @@ void NddSetting::init() QVariant v(VERSION); if (checkNoExistAdd(VERSION, v)) { - //ڣҰ汾,ҪߺԶ + //如果存在,而且版本是最新,不需要走后面自动检查流程了 int curVersion = s_nddSet->value(VERSION).toInt(); if (curVersion == version_num) { @@ -141,12 +141,12 @@ void NddSetting::init() } else if (curVersion < version_num) { - //°汾 + //更新版本到最新 updataKeyValueFromNumSets(VERSION, version_num); } } } - //ÿ¼ֶκҪһ£ + //每次新加字段后,这里要检查一下,不存在则新增 { QVariant v(1); checkNoExistAdd(SKIN_KEY, v); @@ -237,7 +237,7 @@ void NddSetting::init() -//дһܵĻȡõĽӿڣԺÿֶζҪдһдӿ +//写一个总的获取配置的接口,避免以后每个字段都需要写一个读写接口 QString NddSetting::getKeyValueFromSets(QString key) { return s_nddSet->value(key,"").toString(); @@ -250,7 +250,7 @@ bool NddSetting::updataKeyValueFromSets(QString key, QString value) return true; } -//дһܵĻȡõĽӿڣԺÿֶζҪдһдӿ +//写一个总的获取配置的接口,避免以后每个字段都需要写一个读写接口 QByteArray NddSetting::getKeyByteArrayValue(QString key) { return s_nddSet->value(key, "").toByteArray(); @@ -262,14 +262,14 @@ void NddSetting::updataKeyByteArrayValue(QString key, QByteArray& value) s_isContentChanged = true; } -//һμһ¼ڳʼ +//第一次加一条记录,用于初始化 void NddSetting::addKeyValueToSets(QString key, QString value) { s_nddSet->setValue(key, QVariant(value)); } -//дһܵĻȡõĽӿڣԺÿֶζҪдһдӿ.0Ĭֵⲿò0ʼֵ +//写一个总的获取配置的接口,避免以后每个字段都需要写一个读写接口.0做默认值,外部最好不用0做初始化值 int NddSetting::getKeyValueFromNumSets(const QString key) { QVariant v = s_nddSet->value(key, QVariant(0)); @@ -283,7 +283,7 @@ bool NddSetting::updataKeyValueFromNumSets(const QString key, int value) } -//һμһ¼ڳʼ +//第一次加一条记录,用于初始化 void NddSetting::addKeyValueToNumSets(QString key, int value) { s_nddSet->setValue(key, QVariant(value)); @@ -300,7 +300,7 @@ void NddSetting::close() { s_isExistDb = false; - //һı + //做一次真正的保存 if (s_isContentChanged) { s_nddSet->sync(); @@ -309,7 +309,7 @@ void NddSetting::close() s_isContentChanged = false; } - //ﱣһӴڵλáųпӴڻڣѾ˳ⲻ + //在这里保存一下子窗口的位置。不排除有可能子窗口还在,主窗口已经退出的情况,不过问题不大。 if (s_winPosSet != nullptr) { s_winPosSet->sync(); @@ -319,7 +319,7 @@ void NddSetting::close() } } -//Ӵڵλãһwinpos.iniļУʱҪȡɱʱٶ +//子窗口的位置,单独放在一个winpos.ini文件中,而且启动程序时,不需要读取,可避免启动时拖慢速度 QByteArray NddSetting::getWinPos(QString key) { winPosInit(); diff --git a/src/nddsetting.h b/src/nddsetting.h index 2fc34d8..28ec0ff 100755 --- a/src/nddsetting.h +++ b/src/nddsetting.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include @@ -10,24 +10,24 @@ static QString SHOWSPACE_KEY = "blank"; static QString MAX_BIG_TEXT = "maxtsize"; static QString SOFT_STATUS = "rstatus"; static QString SOFT_KEY = "rkey"; -static QString RESTORE_CLOSE_FILE = "restore"; //ָرʱ򿪵ļ -static QString PRO_DIR = "prodir";//ļ· -//static QString RESTORE_SIZE = "rsize";//رʱĴС -static QString WIN_POS = "pos";//رǵĴС -static QString ICON_SIZE = "iconsize";//ͼС -static QString ZOOMVALUE = "zoom"; //Ŵ -static QString VERSION = "version";//ǰ汾 -static QString FINDRESULTPOS = "findpos";//Ҵλ -static QString FILELISTPOS = "filepos";//ļбλ -static QString FILELISTSHOW = "showfilelist"; //ļбǷʾ -static QString TOOLBARSHOW = "showbar"; //Ƿʾ -static QString FINDWINSIZE = "findwinsize";//ҿĴС150%Ŵʱáÿֶ -static QString SHOWWEBADDR = "showweb";//webַ˫ҳ -static QString FIND_RESULT_FONT_SIZE = "frfs";//ҽĬСĬΪ14 +static QString RESTORE_CLOSE_FILE = "restore"; //恢复关闭时打开的文件 +static QString PRO_DIR = "prodir";//放置配置文件的路径 +//static QString RESTORE_SIZE = "rsize";//保存关闭时的大小 +static QString WIN_POS = "pos";//保存关闭是的大小 +static QString ICON_SIZE = "iconsize";//图标大小 +static QString ZOOMVALUE = "zoom"; //放大倍数 +static QString VERSION = "version";//当前版本 +static QString FINDRESULTPOS = "findpos";//查找窗口悬浮的位置 +static QString FILELISTPOS = "filepos";//文件列表悬浮框的位置 +static QString FILELISTSHOW = "showfilelist"; //文件列表框是否显示 +static QString TOOLBARSHOW = "showbar"; //是否显示工具栏 +static QString FINDWINSIZE = "findwinsize";//保存查找框的大小。150%放大时界面永久。保留避免每次手动调整 +static QString SHOWWEBADDR = "showweb";//高亮web地址,双击网页打开 +static QString FIND_RESULT_FONT_SIZE = "frfs";//查找结果的默认字体大小,默认为14 -//winpos.iniеkeyⵥļ̫ٶ -static QString BATCH_FIND_REPLACE_POS = "bfpos";//滻ڵĴС +//下面这个是winpos.ini中的key,避免单个文件太大,拖慢启动速度 +static QString BATCH_FIND_REPLACE_POS = "bfpos";//批量查找替换窗口的大小 class NddSetting { diff --git a/src/ndstyleditemdelegate.cpp b/src/ndstyleditemdelegate.cpp index 9ee86d0..28cb689 100755 --- a/src/ndstyleditemdelegate.cpp +++ b/src/ndstyleditemdelegate.cpp @@ -1,4 +1,4 @@ -#include "ndstyleditemdelegate.h" +#include "ndstyleditemdelegate.h" #include #include #include @@ -21,7 +21,7 @@ void NdStyledItemDelegate::setFontSize(int size) } -//ʹָ֧ıʽ +//重载使可以支持富文本格式的文字 void NdStyledItemDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const { QStyleOptionViewItem viewOption(option); @@ -29,13 +29,13 @@ void NdStyledItemDelegate::paint(QPainter * painter, const QStyleOptionViewItem if (option.state.testFlag(QStyle::State_HasFocus)) viewOption.state = viewOption.state ^ QStyle::State_HasFocus; - // ... ʡ - // ʾıΪգʹĬʽ + // ... 省略 + // 设置显示文本为空,使用默认样式 QStyle *pStyle = viewOption.widget ? viewOption.widget->style() : QApplication::style(); QTextDocument doc; - //ⲿ޸Сڲиı޸Ļơ + //外部修改了字体大小后,内部进行富文本的修改绘制。 if (m_defaultFontSize != 14) { viewOption.text.replace("font-size:14px",QString("font-size:%1px").arg(m_defaultFontSize)); @@ -51,9 +51,9 @@ void NdStyledItemDelegate::paint(QPainter * painter, const QStyleOptionViewItem QRect textRect = pStyle->subElementRect(QStyle::SE_ItemViewItemText, &viewOption); painter->save(); - // 任ϽΪԭ + // 坐标变换,将左上角设置为原点 painter->translate(textRect.topLeft()); - // HTML + // 设置HTML绘制区域 painter->setClipRect(textRect.translated(-textRect.topLeft())); doc.documentLayout()->draw(painter, paintContext); diff --git a/src/ndstyleditemdelegate.h b/src/ndstyleditemdelegate.h index c9b29da..d1708d2 100755 --- a/src/ndstyleditemdelegate.h +++ b/src/ndstyleditemdelegate.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include diff --git a/src/plugin.cpp b/src/plugin.cpp index 4427e29..774c005 100755 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -1,4 +1,4 @@ -#include "plugin.h" +#include "plugin.h" #include #include #include diff --git a/src/plugin.h b/src/plugin.h index 57e920e..c2731be 100755 --- a/src/plugin.h +++ b/src/plugin.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "pluginGl.h" #include class QMenu; diff --git a/src/plugin/helloworld/helloworld.vcxproj b/src/plugin/helloworld/helloworld.vcxproj deleted file mode 100755 index 1735f0a..0000000 --- a/src/plugin/helloworld/helloworld.vcxproj +++ /dev/null @@ -1,182 +0,0 @@ - - - - - Release - x64 - - - Debug - x64 - - - - {06EED29A-D357-39F4-B1B8-25129EBC2852} - helloworld - QtVS_v304 - 10.0.19041.0 - 10.0.19041.0 - $(MSBuildProjectDirectory)\QtMsBuild - - - v141 - ..\..\x64\Debug\plugin\ - false - NotSet - DynamicLibrary - release\ - helloworld - - - v141 - ..\..\x64\Debug\plugin\ - false - NotSet - DynamicLibrary - debug\ - helloworld - - - - - - - - - - ..\..\x64\Debug\plugin\debug\helloworldtrue..\..\x64\Debug\plugin\release\helloworldtruefalse5.12.10_msvc2017_64core;gui;widgets5.12.10_msvc2017_64core;gui;widgets - - - - GeneratedFiles\$(ConfigurationName);GeneratedFiles;.;..\..\include;..\..\qscint\src;..\..\qscint\src\Qsci;release;/include;%(AdditionalIncludeDirectories) - -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 %(AdditionalOptions) - release\ - false - None - 4577;4467;%(DisableSpecificWarnings) - Sync - release\ - MaxSpeed - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;QT_NO_DEBUG;NDEBUG;%(PreprocessorDefinitions) - false - - MultiThreadedDLL - true - true - Level3 - true - - qmyedit_qt5d.lib;%(AdditionalDependencies) - ..\..\x64\Debug;%(AdditionalLibraryDirectories) - true - false - true - true - false - $(OutDir)\helloworld.dll - true - Windows - true - - - Unsigned - None - 0 - - - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;QT_NO_DEBUG;QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB;%(PreprocessorDefinitions) - - msvc./$(Configuration)/moc_predefs.hMoc'ing %(Identity)...output$(Configuration)moc_%(Filename).cppUic'ing %(Identity)...$(ProjectDir)ui_%(Filename).h - - - GeneratedFiles\$(ConfigurationName);GeneratedFiles;.;..\..\include;..\..\qscint\src;..\..\qscint\src\Qsci;debug;/include;%(AdditionalIncludeDirectories) - -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 %(AdditionalOptions) - debug\ - false - ProgramDatabase - 4577;4467;%(DisableSpecificWarnings) - Sync - debug\ - Disabled - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;%(PreprocessorDefinitions) - false - MultiThreadedDebugDLL - true - true - Level3 - true - - qmyedit_qt5d.lib;%(AdditionalDependencies) - ..\..\x64\Debug;%(AdditionalLibraryDirectories) - true - true - true - true - $(OutDir)\helloworld.dll - true - Windows - true - - - Unsigned - None - 0 - - - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB;_DEBUG;%(PreprocessorDefinitions) - - msvc./$(Configuration)/moc_predefs.hMoc'ing %(Identity)...output$(Configuration)moc_%(Filename).cppUic'ing %(Identity)...$(ProjectDir)ui_%(Filename).h - - - - - - - - - - - - - - - - - - - - Document - true - $(QTDIR)\mkspecs\features\data\dummy.cpp;%(AdditionalInputs) - cl -Bx"$(QTDIR)\bin\qmake.exe" -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -Zi -MDd -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -E $(QTDIR)\mkspecs\features\data\dummy.cpp 2>NUL >debug\moc_predefs.h - Generate moc_predefs.h - debug\moc_predefs.h;%(Outputs) - - - Document - $(QTDIR)\mkspecs\features\data\dummy.cpp;%(AdditionalInputs) - cl -Bx"$(QTDIR)\bin\qmake.exe" -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -O2 -MD -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -E $(QTDIR)\mkspecs\features\data\dummy.cpp 2>NUL >release\moc_predefs.h - Generate moc_predefs.h - release\moc_predefs.h;%(Outputs) - true - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/plugin/helloworld/helloworld.vcxproj.filters b/src/plugin/helloworld/helloworld.vcxproj.filters deleted file mode 100755 index 820a103..0000000 --- a/src/plugin/helloworld/helloworld.vcxproj.filters +++ /dev/null @@ -1,69 +0,0 @@ - - - - - {99349809-55BA-4b9d-BF79-8FDBB0286EB3} - ui - false - - - {99349809-55BA-4b9d-BF79-8FDBB0286EB3} - ui - false - - - {71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11} - cpp;c;cxx;moc;h;def;odl;idl;res; - - - {71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11} - cpp;c;cxx;moc;h;def;odl;idl;res; - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - - Generated Files - - - Generated Files - - - - - - - - Form Files - - - \ No newline at end of file diff --git a/src/plugin/helloworld/helloworldexport.cpp b/src/plugin/helloworld/helloworldexport.cpp index 28bc0ff..bd635e5 100755 --- a/src/plugin/helloworld/helloworldexport.cpp +++ b/src/plugin/helloworld/helloworldexport.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/src/plugin/helloworld/qttestclass.cpp b/src/plugin/helloworld/qttestclass.cpp index f602623..392898a 100755 --- a/src/plugin/helloworld/qttestclass.cpp +++ b/src/plugin/helloworld/qttestclass.cpp @@ -1,4 +1,4 @@ -#include "qttestclass.h" +#include "qttestclass.h" #include QtTestClass::QtTestClass(QWidget *parent, QsciScintilla* pEdit) diff --git a/src/plugin/helloworld/qttestclass.h b/src/plugin/helloworld/qttestclass.h index f1e921e..75a0a41 100755 --- a/src/plugin/helloworld/qttestclass.h +++ b/src/plugin/helloworld/qttestclass.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include "ui_qttestclass.h" diff --git a/src/plugin/test/test.cpp b/src/plugin/test/test.cpp index 667928c..d6be711 100755 --- a/src/plugin/test/test.cpp +++ b/src/plugin/test/test.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/src/pluginGl.h b/src/pluginGl.h index a7ef5d5..6b576a6 100755 --- a/src/pluginGl.h +++ b/src/pluginGl.h @@ -1,16 +1,16 @@ -#pragma once +#pragma once #include #include struct ndd_proc_data { - QString m_strPlugName; // ѡд - QString m_strFilePath; //lib ȫ·ѡڲд,򴫵 - QString m_strComment; //˵д - QString m_version; //汾롣ѡд - QString m_auther;//ơѡд - int m_menuType;//˵͡0ʹö˵ 1˵д - QMenu* m_rootMenu;//m_menuType = 1˵ĵֵַnullptr ڲд򴫵 + QString m_strPlugName; //插件名称 必选。插件里面需填写 + QString m_strFilePath; //lib 插件的全局路径。必选。插件内部不用填写,主程序传递下来 + QString m_strComment; //插件说明;插件里面需填写 + QString m_version; //版本号码。可选;插件里面需填写 + QString m_auther;//作者名称。可选;插件里面需填写 + int m_menuType;//菜单类型。0:不使用二级菜单 1:创建二级菜单;插件里面需填写 + QMenu* m_rootMenu;//如果m_menuType = 1,给出二级根菜单的地址。其他值nullptr 插件内部不用填写,主程序传递下来 ndd_proc_data(): m_rootMenu(nullptr), m_menuType(0) { diff --git a/src/pluginmgr.cpp b/src/pluginmgr.cpp index 6ba10e1..3944c6c 100755 --- a/src/pluginmgr.cpp +++ b/src/pluginmgr.cpp @@ -1,4 +1,4 @@ -#include "pluginmgr.h" +#include "pluginmgr.h" #include "rcglobal.h" diff --git a/src/pluginmgr.h b/src/pluginmgr.h index 996d333..c521c31 100755 --- a/src/pluginmgr.h +++ b/src/pluginmgr.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include "ui_pluginmgr.h" diff --git a/src/qscint/Python/config-tests/cfgtest_Qsci.cpp b/src/qscint/Python/config-tests/cfgtest_Qsci.cpp index 8bc054e..e66092f 100755 --- a/src/qscint/Python/config-tests/cfgtest_Qsci.cpp +++ b/src/qscint/Python/config-tests/cfgtest_Qsci.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/src/qscint/scintilla/include/Scintilla.h b/src/qscint/scintilla/include/Scintilla.h index eff3878..c7ca77b 100755 --- a/src/qscint/scintilla/include/Scintilla.h +++ b/src/qscint/scintilla/include/Scintilla.h @@ -1,4 +1,4 @@ -/* Scintilla source code edit control */ +/* Scintilla source code edit control */ /** @file Scintilla.h ** Interface to the edit control. **/ diff --git a/src/qscint/scintilla/lexers/LexAVS.cpp b/src/qscint/scintilla/lexers/LexAVS.cpp index 2092ba5..761f010 100755 --- a/src/qscint/scintilla/lexers/LexAVS.cpp +++ b/src/qscint/scintilla/lexers/LexAVS.cpp @@ -1,4 +1,4 @@ -// Scintilla source code edit control +// Scintilla source code edit control /** @file LexAVS.cxx ** Lexer for AviSynth. **/ diff --git a/src/qscint/scintilla/src/Catalogue.cpp b/src/qscint/scintilla/src/Catalogue.cpp index 20e90d8..dc744d7 100755 --- a/src/qscint/scintilla/src/Catalogue.cpp +++ b/src/qscint/scintilla/src/Catalogue.cpp @@ -1,4 +1,4 @@ -// Scintilla source code edit control +// Scintilla source code edit control /** @file Catalogue.cxx ** Lexer infrastructure. ** Contains a list of LexerModules which can be searched to find a module appropriate for a diff --git a/src/qscint/src/Qsci/qsciglobal.h b/src/qscint/src/Qsci/qsciglobal.h index 61e48d5..89e404b 100755 --- a/src/qscint/src/Qsci/qsciglobal.h +++ b/src/qscint/src/Qsci/qsciglobal.h @@ -37,6 +37,7 @@ // Define QSCINTILLA_MAKE_DLL to create a QScintilla shared library, or // define QSCINTILLA_DLL to link against a QScintilla shared library, or define // neither to either build or link against a static QScintilla library. +#define QSCINTILLA_DLL #if defined(QSCINTILLA_DLL) #define QSCINTILLA_EXPORT Q_DECL_IMPORT diff --git a/src/qscint/src/Qsci/qscilexerasm.h b/src/qscint/src/Qsci/qscilexerasm.h index 4ab60c9..935591e 100755 --- a/src/qscint/src/Qsci/qscilexerasm.h +++ b/src/qscint/src/Qsci/qscilexerasm.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once // This defines the interface to the QsciLexerAsm class. // // Copyright (c) 2021 Riverbank Computing Limited diff --git a/src/qscint/src/Qsci/qscilexerglobal.h b/src/qscint/src/Qsci/qscilexerglobal.h index 1d16681..d2e8912 100755 --- a/src/qscint/src/Qsci/qscilexerglobal.h +++ b/src/qscint/src/Qsci/qscilexerglobal.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include #include diff --git a/src/qscint/src/Qsci/qscilexerr.h b/src/qscint/src/Qsci/qscilexerr.h index b3a7cf8..e0b225f 100755 --- a/src/qscint/src/Qsci/qscilexerr.h +++ b/src/qscint/src/Qsci/qscilexerr.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #pragma once // This defines the interface to the QsciLexerR class. // diff --git a/src/qscint/src/Qsci/qscilexervb.h b/src/qscint/src/Qsci/qscilexervb.h index 11d2420..fc125ef 100755 --- a/src/qscint/src/Qsci/qscilexervb.h +++ b/src/qscint/src/Qsci/qscilexervb.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #pragma once #include diff --git a/src/qscint/src/qscilexerasm.cpp b/src/qscint/src/qscilexerasm.cpp index fdb2851..019cd84 100755 --- a/src/qscint/src/qscilexerasm.cpp +++ b/src/qscint/src/qscilexerasm.cpp @@ -1,4 +1,4 @@ -// This module implements the QsciLexerAsm class. +// This module implements the QsciLexerAsm class. // // Copyright (c) 2021 Riverbank Computing Limited // diff --git a/src/qscint/src/qscilexerglobal.cpp b/src/qscint/src/qscilexerglobal.cpp index 0ac42e3..1c5d92b 100755 --- a/src/qscint/src/qscilexerglobal.cpp +++ b/src/qscint/src/qscilexerglobal.cpp @@ -1,4 +1,4 @@ -#include "Qsci/qscilexerglobal.h" +#include "Qsci/qscilexerglobal.h" #include "Qsci/qsciscintilla.h" #include "Scintilla.h" #include "SciLexer.h" diff --git a/src/qscint/src/qscilexerr.cpp b/src/qscint/src/qscilexerr.cpp index 1de7014..90d3f0b 100755 --- a/src/qscint/src/qscilexerr.cpp +++ b/src/qscint/src/qscilexerr.cpp @@ -1,4 +1,4 @@ - + #include "Qsci/qsciLexerr.h" #include diff --git a/src/qscint/src/qscilexervb.cpp b/src/qscint/src/qscilexervb.cpp index d537335..6157e07 100755 --- a/src/qscint/src/qscilexervb.cpp +++ b/src/qscint/src/qscilexervb.cpp @@ -1,4 +1,4 @@ -#include "Qsci/qscilexervb.h" +#include "Qsci/qscilexervb.h" QsciLexerVB::QsciLexerVB(QObject *parent) : QsciLexer(parent) diff --git a/src/qtlangset.cpp b/src/qtlangset.cpp index 533623a..7262853 100755 --- a/src/qtlangset.cpp +++ b/src/qtlangset.cpp @@ -1,4 +1,4 @@ -#include "qtlangset.h" +#include "qtlangset.h" #include "scintillaeditview.h" #include "nddsetting.h" #include "rcglobal.h" @@ -42,7 +42,7 @@ QtLangSet::~QtLangSet() } -//ͬʱȹرչۺѭʹ +//在同步字体时,务必先关闭关联槽函数,避免循环触发。务必配对使用 void QtLangSet::enableFontChangeSensitive(bool isSensitive) { if (isSensitive) @@ -65,8 +65,8 @@ void QtLangSet::enableFontChangeSensitive(bool isSensitive) void QtLangSet::startSignSlot() { - //ʼʹõQListWidget::currentItemChangedźţǷָźŴĪĴơ - //QT5.12bugԻitemClickedź + //开始本来使用的是QListWidget::currentItemChanged信号,但是发现该信号存在莫名其妙的触发机制。 + //估计是QT5.12的bug。所以换成itemClicked信号 connect(ui.langListWidget, &QListWidget::itemClicked, this, &QtLangSet::slot_itemSelect); connect(ui.langListWidget, &QListWidget::currentRowChanged, this, &QtLangSet::slot_langListCurRowChanged); @@ -83,12 +83,12 @@ void QtLangSet::startSignSlot() connect(ui.fontComboBox, &QFontComboBox::currentFontChanged, this, &QtLangSet::slot_fontChange); } -//óʼʱѡǰ༭ +//让初始化时选择当前编辑器的语言 void QtLangSet::selectInitLangTag(QString initLangTag) { - //һαԳʼlexidʾʵΪʼlist󣬻ԶѵһΪǰ - //ﻹ⣬qt5.12.4bugƵ:ûѡQListWidgetԶѡһ + //第一次必须以初始化lexid显示。这样做实在是因为初始化list启动后,会自动把第一个设置为当前。 + //这里还是有问题,是qt5.12.4的bug机制导致:如果没有选择QListWidget,会总是自动选择第一个 if (!initLangTag.isEmpty()) { QList destItems = ui.langListWidget->findItems(initLangTag,Qt::MatchExactly); @@ -121,7 +121,7 @@ void QtLangSet::selectInitLangTag(QString initLangTag) void QtLangSet::slot_fontBoldChange(int state) { - //ʱ÷ + //即时设置风格 if (m_selectLexer != nullptr) { if (m_curStyleData.font.bold() != ((state == Qt::Unchecked) ? false : true)) @@ -139,19 +139,19 @@ void QtLangSet::slot_fontBoldChange(int state) } else if (ui.useGlobalFont->isVisible() && !ui.useGbFontBold->isChecked()) { - //ȫʽһʽ + //保存全局样式第一条样式本身 saveLangeSet(m_selectLexer); } else if (!ui.useGlobalFont->isVisible()) { - //ȫַǵһʽ޸ĵǰȫС - //ȫʽķǵһ + //全局非第一个样式,修改当前全局字体大小 + //全局样式的非第一个 StyleSet::setGlobalFont(m_selectStyleId, m_curStyleData.font); - //ȫʽһʽ + //保存全局样式第一条样式本身 saveLangeSet(m_selectLexer); - //ȫֵʽ֪ͨǰеı༭ȥ޸DZȫʽ + //这里就是全局的样式。通知当前所有的编辑框,去修改他们本身的全局样式 CCNotePad* pMainNote = dynamic_cast(parent()); if (pMainNote != nullptr) { @@ -169,7 +169,7 @@ void QtLangSet::slot_fontBoldChange(int state) void QtLangSet::slot_fontItalicChange(int state) { - //ʱ÷ + //即时设置风格 if (m_selectLexer != nullptr) { if (m_curStyleData.font.italic() != ((state == Qt::Unchecked) ? false : true)) @@ -186,17 +186,17 @@ void QtLangSet::slot_fontItalicChange(int state) } else if (ui.useGlobalFont->isVisible() && !ui.useGbFontItalic->isChecked()) { - //ȫʽһʽ + //保存全局样式第一条样式本身 saveLangeSet(m_selectLexer); } else if (!ui.useGlobalFont->isVisible()) { - //ȫַǵһʽ޸ĵǰȫС - //ȫʽķǵһ + //全局非第一个样式,修改当前全局字体大小 + //全局样式的非第一个 StyleSet::setGlobalFont(m_selectStyleId, m_curStyleData.font); saveLangeSet(m_selectLexer); - //ȫֵʽ֪ͨǰеı༭ȥ޸DZȫʽ + //这里就是全局的样式。通知当前所有的编辑框,去修改他们本身的全局样式 CCNotePad* pMainNote = dynamic_cast(parent()); if (pMainNote != nullptr) { @@ -214,7 +214,7 @@ void QtLangSet::slot_fontItalicChange(int state) void QtLangSet::slot_fontUnderlineChange(int state) { - //ʱ÷ + //即时设置风格 if (m_selectLexer != nullptr) { if (m_curStyleData.font.underline() != ((state == Qt::Unchecked) ? false : true)) @@ -231,17 +231,17 @@ void QtLangSet::slot_fontUnderlineChange(int state) } else if (ui.useGlobalFont->isVisible() && !ui.useGbFontUnderline->isChecked()) { - //ȫʽһʽ + //保存全局样式第一条样式本身 saveLangeSet(m_selectLexer); } else if (!ui.useGlobalFont->isVisible()) { - //ȫַǵһʽ޸ĵǰȫС - //ȫʽķǵһ + //全局非第一个样式,修改当前全局字体大小 + //全局样式的非第一个 StyleSet::setGlobalFont(m_selectStyleId, m_curStyleData.font); saveLangeSet(m_selectLexer); - //ȫֵʽ֪ͨǰеı༭ȥ޸DZȫʽ + //这里就是全局的样式。通知当前所有的编辑框,去修改他们本身的全局样式 CCNotePad* pMainNote = dynamic_cast(parent()); if (pMainNote != nullptr) { @@ -257,13 +257,13 @@ void QtLangSet::slot_fontUnderlineChange(int state) } } -//һqtdebugסslot_fontSizeChangeᵼ²۴2Σסreleaseģʽֱܣᴥ2 +//发现一个qt现象:在debug断住该slot_fontSizeChange函数,会导致槽触发2次;不断住或者release模式直接跑,不会触发2次 void QtLangSet::slot_fontSizeChange(int v) { - //ʱ÷ + //即时设置风格 if (m_selectLexer != nullptr) { - //ȫ޸ģԵз + //全局修改,把所有语言的所有风格都设置 if (m_isGlobelItem) { if (m_curStyleData.font.pointSize() != v) @@ -273,7 +273,7 @@ void QtLangSet::slot_fontSizeChange(int v) m_isStyleChange = true; m_selectLexer->setFont(m_curStyleData.font, m_selectStyleId); - //ȫֵһʽ޸﷨ʽ + //全局第一个样式,修改所有语法样式 if (ui.useGlobalFont->isVisible() && ui.useGbFontSize->isChecked()) { slot_useAlobalFontSize(true); @@ -281,17 +281,17 @@ void QtLangSet::slot_fontSizeChange(int v) } else if (ui.useGlobalFont->isVisible() && !ui.useGbFontSize->isChecked()) { - //ȫʽһʽ + //保存全局样式第一条样式本身 saveLangeSet(m_selectLexer); } else if (!ui.useGlobalFont->isVisible()) { - //ȫַǵһʽ޸ĵǰȫС - //ȫʽķǵһ + //全局非第一个样式,修改当前全局字体大小 + //全局样式的非第一个 StyleSet::setGlobalFont(m_selectStyleId, m_curStyleData.font); saveLangeSet(m_selectLexer); - //ȫֵʽ֪ͨǰеı༭ȥ޸DZȫʽ + //这里就是全局的样式。通知当前所有的编辑框,去修改他们本身的全局样式 CCNotePad* pMainNote = dynamic_cast(parent()); if (pMainNote != nullptr) { @@ -325,7 +325,7 @@ void QtLangSet::slot_fontSizeChange(int v) m_curStyleData.font.setPointSize(v); m_selectLexer->setFont(m_curStyleData.font, m_selectStyleId); m_isStyleChange = true; - //ʱ÷ + //即时设置风格 if (m_selectLexer != nullptr) { int row = ui.styleListWidget->count(); @@ -337,7 +337,7 @@ void QtLangSet::slot_fontSizeChange(int v) item = ui.styleListWidget->item(i); int styleId = item->data(Qt::UserRole).toInt(); - //С޸Ϊһ + //所有字体大小修改为一致 QFont f = m_selectLexer->font(styleId); f.setPointSize(v); m_selectLexer->setFont(f, styleId); @@ -360,7 +360,7 @@ void QtLangSet::getCurUseLexerTags(QVector& tag) } } -//ʹȫ趨Է +//使用全局设置设定所有语言风格 void QtLangSet::updateAllLangeStyleWithGlobal(GLOBAL_STYLE_SET flag) { QFont oldfont; @@ -369,8 +369,8 @@ void QtLangSet::updateAllLangeStyleWithGlobal(GLOBAL_STYLE_SET flag) for (int index = 0; index <= L_TXT; ++index) { - //GLOBAL棬ΪGLOBAL﷨ʽȫֵԷ - //ȫ޸ĵȫСȫҲ޸һ¡ȴСȫ岻һ + //GLOBAL本身不保存,因为GLOBAL不是语法样式,而是全局的属性风格 + //如果全局修改的是全局字体或字体大小,全局也修改一下。避免括弧等大小和全局字体不一样大。 if (index == L_GLOBAL) { if (flag != GLOBAL_FONT_SIZE && flag != GLOBAL_FONT) @@ -387,7 +387,7 @@ void QtLangSet::updateAllLangeStyleWithGlobal(GLOBAL_STYLE_SET flag) { case GLOBAL_FONT: { - //ȫ޸е﷨Ӧʽ + //非全局修改所有的语法对应样式 if (index != L_GLOBAL) { for (int i = 0; i <= 255; ++i) @@ -402,7 +402,7 @@ void QtLangSet::updateAllLangeStyleWithGlobal(GLOBAL_STYLE_SET flag) } else { - //ȫ޸ + //是全局属性修改字体 QsciLexerGlobal* pGlobalLexer = dynamic_cast(pLexer); if (pGlobalLexer != nullptr) { @@ -420,7 +420,7 @@ void QtLangSet::updateAllLangeStyleWithGlobal(GLOBAL_STYLE_SET flag) break; case GLOBAL_FONT_SIZE: { - //ȫ޸е﷨Ӧʽ + //非全局修改所有的语法对应样式 if (index != L_GLOBAL) { for (int i = 0; i <= 255; ++i) @@ -435,7 +435,7 @@ void QtLangSet::updateAllLangeStyleWithGlobal(GLOBAL_STYLE_SET flag) } else { - //ȫ + //是全局 QsciLexerGlobal* pGlobalLexer = dynamic_cast(pLexer); if (pGlobalLexer != nullptr) { @@ -498,7 +498,7 @@ void QtLangSet::updateAllLangeStyleWithGlobal(GLOBAL_STYLE_SET flag) case GLOBAL_BK_COLOR: { pLexer->setPaper(m_curStyleData.paper, -1); - //ĬֽɫQPaletteһ¡Ҫһ + //默认纸背景色会和QPalette保持一致。单独需要单独设置一下 pLexer->setDefaultPaper(m_curStyleData.paper); } break; @@ -511,8 +511,8 @@ void QtLangSet::updateAllLangeStyleWithGlobal(GLOBAL_STYLE_SET flag) delete pLexer; } - //ȫֱ仯ˣѵǰȫֽˢһ - //УҪѵǰĵȫַһ£ȫֲЧ + //如果全局变化了,把当前全局界面刷新一下 + //还有,还需要把当前打开文档的全局风格设置一下,否则全局不生效 if (isGlobalChange) { m_previousSysLangItem = nullptr; @@ -520,7 +520,7 @@ void QtLangSet::updateAllLangeStyleWithGlobal(GLOBAL_STYLE_SET flag) StyleSet::reloadGolbalStyleFromSetFile(); - //ȫֵʽ֪ͨǰеı༭ȥ޸DZȫʽ + //这里就是全局的样式。通知当前所有的编辑框,去修改他们本身的全局样式 CCNotePad* pMainNote = dynamic_cast(parent()); if (pMainNote != nullptr) { @@ -533,12 +533,12 @@ void QtLangSet::updateAllLangeStyleWithGlobal(GLOBAL_STYLE_SET flag) } } -//ָԵijʼárestoreOriginLangOneStyleƣȸ +//恢复所有语言的初始配置。与restoreOriginLangOneStyle类似,但是粒度更大 void QtLangSet::restoreOriginLangAllStyle() { QsciLexer *pLexer = nullptr; - //һãǰ޸档⵱ǰĸոãֱ + //一旦重置,当前修改无条件不保存。否则避免当前的刚刚重置,又被保存 m_isStyleChange = false; for (int index = 0; index <= L_TXT; ++index) @@ -550,7 +550,7 @@ void QtLangSet::restoreOriginLangAllStyle() continue; } - //Զãֱȫɾ + //如果存在自定义的配置,直接全部删除掉 QString cfgPath = QString("notepad/userstyle/%1/%2").arg(StyleSet::getCurrentStyle()).arg(pLexer->lexerTag()); QSettings qs(QSettings::IniFormat, QSettings::UserScope, cfgPath); @@ -562,7 +562,7 @@ void QtLangSet::restoreOriginLangAllStyle() delete pLexer; pLexer = nullptr; - //ȫֵģѵǰڴеȫַҲһ + //如果是全局的,把当前内存中的全局风格也更新一下 if (index == L_GLOBAL) { StyleSet::loadGolbalStyle(); @@ -570,7 +570,7 @@ void QtLangSet::restoreOriginLangAllStyle() } } -//ֻrestoreOriginLangOneStyleе +//只在restoreOriginLangOneStyle中调用 static void restoreLangFontFgColorToDarkStyle(QsciLexer *pLexer, int i) { //if (QtLangSet::s_darkColorMap.contains(pLexer->color(i).name())) @@ -579,11 +579,11 @@ static void restoreLangFontFgColorToDarkStyle(QsciLexer *pLexer, int i) //} } -//ֻrestoreOriginLangOneStyleе +//只在restoreOriginLangOneStyle中调用 static void restoreLangPaperColorToDarkStyle(QsciLexer *pLexer, int i) { - //עɫvoid StyleSet::setBlackStyle()бһ - //Ҳɰɫ + //注意下面这个颜色和void StyleSet::setBlackStyle()中保持一致 + //背景也变成暗黑色 if (StyleSet::foldbgColor != pLexer->paper(i)) { pLexer->setPaper(StyleSet::foldbgColor, i); @@ -591,7 +591,7 @@ static void restoreLangPaperColorToDarkStyle(QsciLexer *pLexer, int i) } } -//ָԵijʼ,ָֻGLOBAL_STYLE_SETָķ +//恢复所有语言的初始配置,只恢复GLOBAL_STYLE_SET指定的风格 void QtLangSet::restoreOriginLangOneStyle(GLOBAL_STYLE_SET flag) { @@ -676,7 +676,7 @@ void QtLangSet::restoreOriginLangOneStyle(GLOBAL_STYLE_SET flag) } } -//Ԥȫ޸Чѵǰе﷨嶼޸һ +//预览全局修改字体效果。把当前所有的语法,风格字体都修改一遍 void QtLangSet::previewAllGoblalChange() { QVector tags; @@ -688,10 +688,10 @@ void QtLangSet::previewAllGoblalChange() emit viewLexerChange(tags.at(i)); } - //ﻹһ - //ﻹ⣬Ҫѵǰĵȫַһ£ȫֲЧ + //这里还差一步 + //这里还有问题,还需要把当前打开文档的全局风格设置一下,否则全局不生效 - //ȫֵʽ֪ͨǰеı༭ȥ޸DZȫʽ + //这里就是全局的样式。通知当前所有的编辑框,去修改他们本身的全局样式 CCNotePad* pMainNote = dynamic_cast(parent()); if (pMainNote != nullptr) { @@ -704,10 +704,10 @@ void QtLangSet::previewAllGoblalChange() void QtLangSet::slot_fontChange(const QFont &font) { - //ʱ÷ + //即时设置风格 if (m_selectLexer != nullptr) { - //ȫ޸ + //全局修改 if (m_isGlobelItem) { if (m_curStyleData.font != font) @@ -716,7 +716,7 @@ void QtLangSet::slot_fontChange(const QFont &font) m_selectLexer->setFont(m_curStyleData.font, m_selectStyleId); m_isStyleChange = true; - //޸ + //修改所有字体 if (ui.useGlobalFont->isVisible() && ui.useGbFont->isChecked()) { slot_useAlobalFont(true); @@ -724,18 +724,18 @@ void QtLangSet::slot_fontChange(const QFont &font) } else if (ui.useGlobalFont->isVisible() && !ui.useGbFont->isChecked()) { - //ȫʽһʽ + //保存全局样式第一条样式本身 saveLangeSet(m_selectLexer); } else if(!ui.useGlobalFont->isVisible()) { - //ȫʽķǵһ + //全局样式的非第一个 StyleSet::setGlobalFont(m_selectStyleId, m_curStyleData.font); - //ȫʽһʽ + //保存全局样式第一条样式本身 saveLangeSet(m_selectLexer); - //ȫֵʽ֪ͨǰеı༭ȥ޸DZȫʽ + //这里就是全局的样式。通知当前所有的编辑框,去修改他们本身的全局样式 CCNotePad* pMainNote = dynamic_cast(parent()); if (pMainNote != nullptr) { @@ -747,7 +747,7 @@ void QtLangSet::slot_fontChange(const QFont &font) else { #if 0 - //ͳһ޸壬Сͷ񱣴治 + //统一修改字体,大小和风格保存不变 QFont oldf = m_curStyleData.font; m_curStyleData.font = font; m_curStyleData.font.setBold(oldf.bold()); @@ -755,7 +755,7 @@ void QtLangSet::slot_fontChange(const QFont &font) m_curStyleData.font.setUnderline(oldf.underline()); m_isStyleChange = true; - //ʱ÷ + //即时设置风格 if (m_selectLexer != nullptr) { int row = ui.styleListWidget->count(); @@ -768,7 +768,7 @@ void QtLangSet::slot_fontChange(const QFont &font) int styleId = item->data(Qt::UserRole).toInt(); QFont f = m_selectLexer->font(styleId); - //ͳһãǷСϵһ + //新字体的名统一设置,但是风格字体大小保存老的一致 QFont newFont = m_curStyleData.font; newFont.setBold(f.bold()); newFont.setItalic(f.italic()); @@ -811,20 +811,20 @@ void QtLangSet::initLangList() } } - //ǶӵģӳִСǵѡѡУǵһasp + //怀疑这个是队列链接的,会延迟执行。故总是导致选择的选不中,而是第一个语言asp。 ui.langListWidget->sortItems(Qt::AscendingOrder); - //ֶ޸ĵһΪġ + //手动修改第一个名称为中文。 if (ui.langListWidget->item(0)->text() == QString("AllGlobal")) { ui.langListWidget->item(0)->setText(tr("AllGlobal")); } } -//isLoadToUIǷʾǰUI +//isLoadToUI是否加载显示到当前UI界面 bool QtLangSet::readLangSetFile(QString langName,QString &keyword, QString &motherLang, QString & extTypes) { - QString userLangFile = QString("notepad/userlang/%1").arg(langName);//Զв.ַдҪ + QString userLangFile = QString("notepad/userlang/%1").arg(langName);//自定义语言中不能有.字符,否则可能有错,后续要检查 QSettings qs(QSettings::IniFormat, QSettings::UserScope, userLangFile); qs.setIniCodec("UTF-8"); //qDebug() << qs.fileName(); @@ -834,11 +834,11 @@ bool QtLangSet::readLangSetFile(QString langName,QString &keyword, QString &moth return false; } - //ԶԸʽ + //自定义语言格式。 //mz:ndd //name:xxx - //mother:xxx none/cpp/html - //ext:xx xx xx ļ׺ + //mother:xxx none/cpp/html 就三种 + //ext:xx xx xx 文件关联后缀名 //keword:xxx keyword = qs.value("keyword").toString(); extTypes = qs.value("ext").toString(); @@ -847,20 +847,20 @@ bool QtLangSet::readLangSetFile(QString langName,QString &keyword, QString &moth return true; } -//ʼûԶ +//初始化用户自定义的语言配置 void QtLangSet::initUserDefineLangList() { QString userLangDirPath = getUserLangDirPath(); - //ļ + //遍历文件夹 QDir dir_file(userLangDirPath); QFileInfoList list_file = dir_file.entryInfoList(QDir::Files | QDir::NoDotAndDotDot | QDir::NoSymLinks, QDir::Name); for (int i = 0; i < list_file.size(); ++i) - { //ǰĿ¼ļӵtreewidget + { //将当前目录中所有文件添加到treewidget中 QFileInfo fileInfo = list_file.at(i); - //ļexttagӳļý + //这个文件是ext和tag的映射文件,不做配置解析 if (fileInfo.baseName() == "ext_tag") { continue; @@ -872,9 +872,9 @@ void QtLangSet::initUserDefineLangList() } -//лǰԡ -//QListWidget::currentItemChangedźqt5.12.10ӦǴbug,ĪҪһcurrentItemChangedźųµһθѡǡ -//itemClickedź +//切换当前语言。 +//QListWidget::currentItemChanged这个信号qt5.12.10中应该是存在bug,总是莫名其妙的要发一次currentItemChanged信号出来。导致第一次该选的项被覆盖。 +//换成itemClicked信号 void QtLangSet::slot_itemSelect(QListWidgetItem *item) { if (item == nullptr) @@ -883,7 +883,7 @@ void QtLangSet::slot_itemSelect(QListWidgetItem *item) } //qDebug() << item->text() << (previous ? previous->text() : 0); - //ǰⷢ˱仯Ҫ߸£ֹлûʱ + //如果前后主题发生了变化,则依旧要走更新,防止主题切换后没及时更新 if (m_previousSysLangItem == item && (m_lastThemesId == m_themesId)) { return; @@ -896,11 +896,11 @@ void QtLangSet::slot_itemSelect(QListWidgetItem *item) ui.userLangListWidget->setCurrentItem(nullptr); - //ǰһѾ޸ĵġѯûǷ񱣴 + //保存前一个已经修改的。询问用户是否保存 if (m_isStyleChange && m_previousSysLangItem != nullptr && m_selectLexer !=nullptr) { - //ֻеǰǷȫ֣ҪʾûǷҪ֡ - //ȫֵIJҪʾΪѾȫˡ + //只有当前是非全局,才需要提示用户是否要保持。 + //全局的不需要提示,因为已经无条件全部保存过了。 if (!m_isGlobelItem) { if (QMessageBox::Yes == QMessageBox::question(this, tr("Save Change"), tr("%1 style configuration has been modified. Do you want to save it?").arg(m_previousSysLangItem->text()))) @@ -925,7 +925,7 @@ void QtLangSet::slot_itemSelect(QListWidgetItem *item) int lexId = item->data(Qt::UserRole).toInt(); - //ȫֵҪԴʱûκη + //全局的这个要单独对待,暂时没有任何风格。 if (lexId == L_GLOBAL) { m_isGlobelItem = true; @@ -948,7 +948,7 @@ void QtLangSet::slot_itemSelect(QListWidgetItem *item) ui.keywordTe->setPlainText(keyword); ui.motherLangCb->setCurrentIndex(0); - //ùļ + //设置关联文件项 QString langName = item->text(); QStringList extList; ExtLexerManager::getInstance()->getExtlistByLangTag(langName, extList); @@ -968,7 +968,7 @@ void QtLangSet::slot_itemSelect(QListWidgetItem *item) m_previousSysLangItem = item; - //ԶʾһĽ + //自动显示第一条的结果 QListWidgetItem *itemtemp = ui.styleListWidget->item(0); if (itemtemp != nullptr) { @@ -988,7 +988,7 @@ void QtLangSet::slot_langListCurRowChanged(int row) slot_itemSelect(current); } -//ĸģԣԷʾ +//根据母亲模块语言,把属性风格显示出来 void QtLangSet::displayUserMotherLangsStyle(QString langTagName, UserLangMother motherLang) { QsciLexer *pLexer = nullptr; @@ -1010,7 +1010,7 @@ void QtLangSet::displayUserMotherLangsStyle(QString langTagName, UserLangMother if (nullptr != pLexer) { - //һҪԵΪlexertag + //这里一定要以新语言的名称作为lexer的tag。 //pLexer->setLexerTag(langTagName); pLexer->setIsUserDefineKeywords(true); @@ -1033,7 +1033,7 @@ void QtLangSet::displayUserMotherLangsStyle(QString langTagName, UserLangMother } } - //ԶʾһĽ + //自动显示第一条的结果 QListWidgetItem *itemtemp = ui.styleListWidget->item(0); if (itemtemp != nullptr) { @@ -1046,7 +1046,7 @@ void QtLangSet::displayUserMotherLangsStyle(QString langTagName, UserLangMother } -//ǰûԶԵitemtodo:ʱûǰһ޸ı棬Ҫûÿ޸ĺԼsaveܲᱣ +//点击当前用户自定义语言的语言item。todo:暂时没有做前一个的修改保存,需要用户每次修改后自己点击save,否则可能不会保存 void QtLangSet::slot_userLangItemSelect(QListWidgetItem *item) { if (item == nullptr) @@ -1054,7 +1054,7 @@ void QtLangSet::slot_userLangItemSelect(QListWidgetItem *item) return; } - //϶ȫ + //肯定不能是全局设置了 if(m_isGlobelItem || (ui.stackedWidget->currentIndex() == 1)) { m_isGlobelItem = false; @@ -1086,7 +1086,7 @@ void QtLangSet::slot_userLangItemSelect(QListWidgetItem *item) ui.motherLangCb->setCurrentText(motherLang); ui.extFileType->setText(extTypes); - //ĸģԣԷʾ + //根据母亲模块语言,把属性风格显示出来 displayUserMotherLangsStyle(langName, (UserLangMother)(LangType::L_USER_TXT + ui.motherLangCb->currentIndex())); } else @@ -1096,7 +1096,7 @@ void QtLangSet::slot_userLangItemSelect(QListWidgetItem *item) } -//ȡǰuiϵ +//获取当前ui上的字体 void QtLangSet::getCurUiFont(QFont& font) { font = ui.fontComboBox->currentFont(); @@ -1111,7 +1111,7 @@ void QtLangSet::closeEvent(QCloseEvent * e) saveCurLangSettings(); } -//itemĶӦʾڽ +//把item的对应风格显示在界面上 void QtLangSet::syncShowStyleItemToUI(QListWidgetItem *item) { if (item != nullptr && m_selectLexer != nullptr) @@ -1156,7 +1156,7 @@ void QtLangSet::syncShowStyleItemToUI(QListWidgetItem *item) setStyleShow(sd.font, sd.color, sd.paper); m_isStyleChange = false; - //ȫ֣Ѳ޸ĵȫʽҵûѡ + //如果是全局,则把不能修改的全局样式灰掉,避免干扰用户的选择 if (m_isGlobelItem) { QsciLexerGlobal* pGlobalLexer = dynamic_cast(m_selectLexer); @@ -1191,7 +1191,7 @@ void QtLangSet::syncShowStyleItemToUI(QListWidgetItem *item) } } } -//ǰķitem +//点击当前的风格item void QtLangSet::slot_styleItemSelect(QListWidgetItem *current) { qDebug() << "slot_styleItemSelect"; @@ -1217,7 +1217,7 @@ void QtLangSet::slot_styleItemSelect(QListWidgetItem *current) } -//ʹüл +//使用键盘上下切换 void QtLangSet::slot_styleListCurRowChanged(int row) { qDebug() << "slot_curRowChanged"; @@ -1242,7 +1242,7 @@ void QtLangSet::fillBackgroundColor(QColor &bkColor) void QtLangSet::setStyleShow(QFont& font, QColor& fcColor, QColor &bkColor) { - //޸ᴥۺִУȹرһź + //修改字体会触发槽函数执行,务必先关闭一下信号 enableFontChangeSensitive(false); ui.fontComboBox->setCurrentFont(font); @@ -1259,7 +1259,7 @@ void QtLangSet::setStyleShow(QFont& font, QColor& fcColor, QColor &bkColor) } -//ȡضԵãStyleId-1ȡǰ⣬ָStyleId +//读取特定语言的设置;StyleId-1则读取当前主题,否则指定的StyleId主题 bool QtLangSet::readLangSettings(QsciLexer *lexer, QString tag, int StyleId) { QString cfgPath = QString("notepad/userstyle/%1/%2").arg((StyleId == -1) ? StyleSet::getCurrentStyle() : StyleSet::getStyleName(StyleId)).arg(tag); @@ -1269,7 +1269,7 @@ bool QtLangSet::readLangSettings(QsciLexer *lexer, QString tag, int StyleId) { return lexer->readSettings(qs); } - else//ӦüӸ߼걸ıûжȡûãӦôӱ׼Ŀȥԭʼ + else//这里应该加个逻辑完备的保护。如果没有读取到用户配置,则应该从标准目标去读原始配置 { return readLangOriginSettings(lexer, tag, StyleId, true); } @@ -1277,17 +1277,17 @@ bool QtLangSet::readLangSettings(QsciLexer *lexer, QString tag, int StyleId) return false; } -//ȡضԵԭʼʽãStyleId-1ȡǰ⣬ָStyleId -//force:ȡ +//读取特定语言的原始样式设置;StyleId-1则读取当前主题,否则指定的StyleId主题 +//force:无条件读取 bool QtLangSet::readLangOriginSettings(QsciLexer* lexer, QString tag, int StyleId, bool force) { - //ĬⲻҪȡڴѾ + //默认主题不需要读取,内存中已经存在 if (StyleId == 0 && !force) { return true; } - //ĬƤ·ͬĿ¼themesĿ¼ + //默认皮肤路径放在软件的同级目录下面的themes目录 QString cfgPath = QString("%1/themes/%2/%3.ini").arg(QCoreApplication::applicationDirPath()).arg((StyleId == -1)?StyleSet::getCurrentStyle(): StyleSet::getStyleName(StyleId)).arg(tag); QSettings qs(cfgPath, QSettings::IniFormat); if (QFile::exists(qs.fileName())) @@ -1298,7 +1298,7 @@ bool QtLangSet::readLangOriginSettings(QsciLexer* lexer, QString tag, int StyleI } -//һԵá +//保存一种语言的配置。 void QtLangSet::saveLangeSet(QsciLexer *lexer, int StyleId) { if (lexer != nullptr) @@ -1313,7 +1313,7 @@ void QtLangSet::saveLangeSet(QsciLexer *lexer, int StyleId) } } -//浱ǰѡԵ +//保存当前选定语言的配置 bool QtLangSet::saveCurLangSettings() { if (m_isStyleChange && m_selectLexer != nullptr) @@ -1337,13 +1337,13 @@ bool QtLangSet::isUseGlobalBgColor() return ui.useGlobalColor->isVisible() && ui.useGbBc->isChecked(); } -//޸ǰɫ +//修改前景色 void QtLangSet::slot_changeFgColor() { QColor color = QColorDialog::getColor(m_curStyleData.color, this, tr("Style Foreground Color")); if (color.isValid()) { - //ȫ޸ + //全局修改 if (m_isGlobelItem) { if (m_curStyleData.color != color) @@ -1352,24 +1352,24 @@ void QtLangSet::slot_changeFgColor() fillForegroundColor(color); m_isStyleChange = true; - //ʱ÷ + //即时设置风格 if (m_selectLexer != nullptr) { - //ʱһQsciLexerGlobal + //此时一定是QsciLexerGlobal m_selectLexer->setColor(color, m_selectStyleId); } - //ֻڵһȫʽʱisUseGlobalFgColorΪtrueԵз + //只有在第一个全局样式时,isUseGlobalFgColor下面才为true。把所有语言的所有风格都设置 if (isUseGlobalFgColor()) { slot_useAlobalFgColor(true); } else if(!ui.useGlobalColor->isVisible()) { - //ȫʽķǵһ + //全局样式的非第一个 StyleSet::setGlobalFgColor(m_selectStyleId, color); - //ȫֵʽ֪ͨǰеı༭ȥ޸DZȫʽ + //这里就是全局的样式。通知当前所有的编辑框,去修改他们本身的全局样式 CCNotePad* pMainNote = dynamic_cast(parent()); if (pMainNote != nullptr) { @@ -1383,14 +1383,14 @@ void QtLangSet::slot_changeFgColor() } else { - //ǰǰɫǷ仯 + //当前前景色是否变化 if (m_curStyleData.color != color) { m_curStyleData.color = color; fillForegroundColor(color); m_isStyleChange = true; - //ʱ÷ + //即时设置风格 if (m_selectLexer != nullptr) { m_selectLexer->setColor(color, m_selectStyleId); @@ -1401,14 +1401,14 @@ void QtLangSet::slot_changeFgColor() } /*else if (!ui.modiryAllColor->isChecked()) { - ǰǰɫǷ仯 + 当前前景色是否变化 if (m_curStyleData.color != color) { m_curStyleData.color = color; fillForegroundColor(color); m_isStyleChange = true; - ʱ÷ + 即时设置风格 if (m_selectLexer != nullptr) { m_selectLexer->setColor(color, m_selectStyleId); @@ -1419,13 +1419,13 @@ void QtLangSet::slot_changeFgColor() }*/ /*else { - ȫɫ޸ - ǰǰɫǷ仯 + 全部风格颜色修改 + 当前前景色是否变化 m_curStyleData.color = color; fillForegroundColor(color); m_isStyleChange = true; - ʱ÷ + 即时设置风格 if (m_selectLexer != nullptr) { m_selectLexer->setColor(color, -1); @@ -1438,13 +1438,13 @@ void QtLangSet::slot_changeFgColor() } -//޸ıɫ +//修改背景色 void QtLangSet::slot_changeBkColor() { QColor color = QColorDialog::getColor(m_curStyleData.paper, this, tr("Style Background Color")); if (color.isValid()) { - //ȫ޸ģԵз + //全局修改,把所有语言的所有风格都设置 if (m_isGlobelItem) { if (m_curStyleData.paper != color) @@ -1453,7 +1453,7 @@ void QtLangSet::slot_changeBkColor() fillBackgroundColor(color); m_isStyleChange = true; - //ʱ÷ + //即时设置风格 if (m_selectLexer != nullptr) { m_selectLexer->setPaper(color, m_selectStyleId); @@ -1467,7 +1467,7 @@ void QtLangSet::slot_changeBkColor() { StyleSet::setGlobalBgColor(m_selectStyleId, color); - //ȫֵʽ֪ͨǰеı༭ȥ޸DZȫʽ + //这里就是全局的样式。通知当前所有的编辑框,去修改他们本身的全局样式 CCNotePad* pMainNote = dynamic_cast(parent()); if (pMainNote != nullptr) { @@ -1480,14 +1480,14 @@ void QtLangSet::slot_changeBkColor() } // else if (!ui.modiryAllColor->isChecked()) // { - // //ǰǰɫǷ仯 + // //当前前景色是否变化 // if (m_curStyleData.paper != color) // { // m_curStyleData.paper = color; // fillBackgroundColor(color); // m_isStyleChange = true; - // //ʱ÷ + // //即时设置风格 // if (m_selectLexer != nullptr) // { // m_selectLexer->setPaper(color, m_selectStyleId); @@ -1497,13 +1497,13 @@ void QtLangSet::slot_changeBkColor() //} else { - //ȫɫ޸ - //ǰǰɫǷ仯 + //全部风格颜色修改 + //当前前景色是否变化 m_curStyleData.paper = color; fillBackgroundColor(color); m_isStyleChange = true; - //ʱ÷ + //即时设置风格 if (m_selectLexer != nullptr) { m_selectLexer->setPaper(color, -1); @@ -1521,7 +1521,7 @@ void QtLangSet::slot_saveClick() saveCurLangSettings(); } -//ָʼ +//恢复初始化设置 void QtLangSet::slot_reset() { if (m_selectLexer != nullptr) @@ -1533,10 +1533,10 @@ void QtLangSet::slot_reset() return; } - //һãǰ޸档⵱ǰĸոãֱ + //一旦重置,当前修改无条件不保存。否则避免当前的刚刚重置,又被保存 m_isStyleChange = false; - //ԶãҲɾ + //如果存在自定义的配置,也删除掉 QString cfgPath = QString("notepad/userstyle/%1/%2").arg(StyleSet::getCurrentStyle()).arg(m_selectLexer->lexerTag()); QSettings qs(QSettings::IniFormat, QSettings::UserScope, cfgPath); @@ -1545,15 +1545,15 @@ void QtLangSet::slot_reset() QFile::remove(qs.fileName()); } - //һҪȱ棬ΪselectInitLangTagܻ仯 + //一定要先保存,因为selectInitLangTag后可能会变化 int row = ui.styleListWidget->currentRow(); - //ǿslot_itemSelectĽл + //强行让slot_itemSelect里面的进行切换 m_previousSysLangItem = nullptr; selectInitLangTag(m_selectLexer->lexerTag()); - //ֶˢUI + //手动刷新UI QListWidgetItem* styleItem = ui.styleListWidget->item(row); m_selectStyleId = -1; @@ -1566,7 +1566,7 @@ void QtLangSet::slot_reset() { if (ui.useGlobalFont->isVisible()) { - //ȫãԶ + //如果是全局重置,则把所有语言都重置 if (QMessageBox::Yes != QMessageBox::question(this, tr("Reset All Style"), tr("Are you sure to reset All language sytle"))) { return; @@ -1575,7 +1575,7 @@ void QtLangSet::slot_reset() previewAllGoblalChange(); - //ֶˢUIȫĿǰֻһȫ + //手动刷新UI。全局目前只有一行全局设置 if (m_selectLexer != nullptr) { @@ -1592,11 +1592,11 @@ void QtLangSet::slot_reset() } else { - //ȫʽ - //һãǰ޸档⵱ǰĸոãֱ + //重置所有全局样式 + //一旦重置,当前修改无条件不保存。否则避免当前的刚刚重置,又被保存 m_isStyleChange = false; - //ԶãҲɾ + //如果存在自定义的配置,也删除掉 QString cfgPath = QString("notepad/userstyle/%1/%2").arg(StyleSet::getCurrentStyle()).arg(m_selectLexer->lexerTag()); QSettings qs(QSettings::IniFormat, QSettings::UserScope, cfgPath); @@ -1605,24 +1605,24 @@ void QtLangSet::slot_reset() QFile::remove(qs.fileName()); } - //һҪȱ棬ΪselectInitLangTagܻ仯 + //一定要先保存,因为selectInitLangTag后可能会变化 int row = ui.styleListWidget->currentRow(); - //ǿslot_itemSelectĽл + //强行让slot_itemSelect里面的进行切换 m_previousSysLangItem = nullptr; - //дALLglobalIJҲ + //这里必须写ALLglobal,否则中文查找不到 selectInitLangTag(tr("AllGlobal")); - //ֶˢUI + //手动刷新UI QListWidgetItem* styleItem = ui.styleListWidget->item(row); m_selectStyleId = -1; syncShowStyleItemToUI(styleItem); - //´ӼһδȫʽΪǰ汣ѾɾˣԼصǴġ + //重新从加载一次纯净的全局样式。因为前面保存的已经删了,所以加载的是纯净的。 StyleSet::loadGolbalStyle(); updateThemes(); @@ -1733,8 +1733,8 @@ void QtLangSet::slot_useAlobalFontItalic(bool check) -//ĬԷIJɫ滻Ϊɫ۵ɫ -//ǿԴԶԵġ +//把默认语言风格的部分颜色,替换为暗色下显眼的颜色 +//这个函数是可以处理自定义语言的。 //void QtLangSet::setLangFontFgColorToDarkStyle(LangType langId, QString tag) //{ // QColor blackColor(Qt::black); @@ -1744,7 +1744,7 @@ void QtLangSet::slot_useAlobalFontItalic(bool check) // QColor lightColor1(0xffaa00); // // -// //C++ע͵Ĭɫ +// //C++注释的默认颜色,不显眼 // QColor blackColor2(0x007f00); // QColor lightColor2(0x009000); // @@ -1755,7 +1755,7 @@ void QtLangSet::slot_useAlobalFontItalic(bool check) // QColor blackColor4(0x8000ff); // QColor lightColor4(0xffaa00); // -// עɫvoid StyleSet::setBlackStyle()бһ +// 注意下面这个颜色和void StyleSet::setBlackStyle()中保持一致 // QColor bkPaperColor(0, 0, 0); // // QsciLexer *pLexer = ScintillaEditView::createLexer(langId, tag); @@ -1791,24 +1791,24 @@ void QtLangSet::slot_useAlobalFontItalic(bool check) // pLexer->setColor(QtLangSet::s_darkColorMap.value(pLexer->color(i).name()), i); // } // -// Ҳɰɫ +// 背景也变成暗黑色 // if (StyleSet::foldbgColor != pLexer->paper(i)) // { // pLexer->setPaper(StyleSet::foldbgColor, i); // } // } // } -// ĬֽɫQPaletteһ¡Ϊɫɫ䱳QPaletteһҪһ +// 默认纸背景色会和QPalette保持一致。但是因为黑色特色,其背景和QPalette不一样,所有需要单独设置一下 // pLexer->setDefaultPaper(StyleSet::foldbgColor); // saveLangeSet(pLexer); // delete pLexer; // } // } -//Ѱɫϵ治׿ɫ滻һ¡ĬзģĬϷɫϵġ -//ѷ0x000000壬0xdedede -//0x0000ffɫ0xffff00 -//ûдԶԡ +//把暗色系下面不容易看清的颜色给替换一下。默认是有风格的,但是默认风格是亮色系的。 +//把凡是0x000000的字体,变成0xdedede +//凡是0x0000ff的颜色,变成0xffff00 +//这个函数没有处理自定义语言。 //void QtLangSet::setAllLangFontFgColorToDarkStyle() //{ // initDarkColorMap(); @@ -1820,14 +1820,14 @@ void QtLangSet::slot_useAlobalFontItalic(bool check) //} -//Ĭģ崴һûԷļ +//从默认主题模板创建一份用户的语言风格文件 void QtLangSet::createOneLangStyleFromThemes(int styleId, LangType langId, QString tag) { if (langId == L_GLOBAL) { qDebug("global call"); } - //ָԭʼģжȡһ + //指定从原始模板的主题中读取一份数据 QsciLexer* pLexer = ScintillaEditView::createLexer(langId, tag, true, styleId); if (nullptr != pLexer) { @@ -1836,7 +1836,7 @@ void QtLangSet::createOneLangStyleFromThemes(int styleId, LangType langId, QStri } } -//ԭʼģУһûļ +//从原始主题模板中,创建一份用户主题文件 void QtLangSet::createUserStyleFormThemes(int styleId) { for (int index = 0; index <= L_TXT; ++index) @@ -1845,7 +1845,7 @@ void QtLangSet::createUserStyleFormThemes(int styleId) } } -//鵱ǰǷѾڰɫ +//检查当前是否已经存在暗黑色语言配置 //bool QtLangSet::isExistDarkLangSetings() //{ // QString cfgPath = QString("notepad/userstyle/black/AllGlobal"); @@ -1853,7 +1853,7 @@ void QtLangSet::createUserStyleFormThemes(int styleId) // return QFile::exists(qs.fileName()); //} -//鵱ǰǷѾ +//检查当前是否已经存在主题配置 bool QtLangSet::isExistThemesSetings(int styleId) { QString cfgPath = QString("notepad/userstyle/%1/AllGlobal").arg(StyleSet::getStyleName(styleId)); @@ -1861,10 +1861,10 @@ bool QtLangSet::isExistThemesSetings(int styleId) return QFile::exists(qs.fileName()); } -//ǰⷢ仯 +//当前主题发生变化 void QtLangSet::on_themesChange(int styleIndex) { - //һʱֹʼûгʼ⣬ʼһisExistThemesSetings + //第一次启动时,防止初始情况没有初始化主题,故检测一下isExistThemesSetings if (m_themesId == styleIndex && isExistThemesSetings(styleIndex)) { return; @@ -1873,12 +1873,12 @@ void QtLangSet::on_themesChange(int styleIndex) m_themesId = styleIndex; - //иϣҪQsciLexerĵǰ⡣ֻĬϸķ - //Ĭ⣬ʼȫĬʽ + //这个有个耦合:先要设置QsciLexer的当前主题。只有默认主题才有详细独立的风格。 + //非默认主题,其初始风格全是默认样式。 QsciLexer::setCurThemes(m_themesId); - //ãģ濽һݳ + //如果不存在主题设置,则从模板里面拷贝一份出来 if (!isExistThemesSetings(styleIndex)) { createUserStyleFormThemes(styleIndex); @@ -1888,15 +1888,15 @@ void QtLangSet::on_themesChange(int styleIndex) NddSetting::updataKeyValueFromNumSets(SKIN_KEY, m_themesId); - //Ҫʱлǰ⣬Ԥɫ + //这里就要及时切换当前主题,预览颜色 updateThemes(); - //һҪõǰ༭﷨ + //下一步就是要更好当前编辑器的语法设置 previewAllGoblalChange(); int row = ui.langListWidget->currentRow(); - //ֶˢUI + //手动刷新UI QListWidgetItem* styleItem = ui.langListWidget->item(row); slot_itemSelect(styleItem); @@ -1906,7 +1906,7 @@ void QtLangSet::on_themesChange(int styleIndex) ui.statusBar->showMessage(tr("themes changed finished ..."), 5000); } -//µǰ༭ʽ +//更新当前编辑框中主题的样式 void QtLangSet::updateThemes() { CCNotePad* pMainNote = dynamic_cast(parent()); @@ -1916,7 +1916,7 @@ void QtLangSet::updateThemes() } } -//һʾȫֵİťûҲ +//增加一个快捷显示全局的按钮,避免用户经常找不到 void QtLangSet::on_showGlobalItem() { if (ui.langListWidget->currentRow() != 0) diff --git a/src/qtlangset.h b/src/qtlangset.h index 614733a..8e14b2e 100755 --- a/src/qtlangset.h +++ b/src/qtlangset.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include diff --git a/src/rcglobal.h b/src/rcglobal.h index 62a86d0..50a4d4c 100755 --- a/src/rcglobal.h +++ b/src/rcglobal.h @@ -15,7 +15,7 @@ static const char* VersionStr = "v1.22.2"; #endif // TEST_PRE -//#define NO_PLUGIN 1 +#define NO_PLUGIN 1 #define CMP_CODE_NOEQUAL diff --git a/src/renamewin.cpp b/src/renamewin.cpp index 6a0f18f..e0ff6bd 100755 --- a/src/renamewin.cpp +++ b/src/renamewin.cpp @@ -1,4 +1,4 @@ -#include "renamewin.h" +#include "renamewin.h" #include "progresswin.h" #include diff --git a/src/renamewin.h b/src/renamewin.h index ab69266..cb141ee 100755 --- a/src/renamewin.h +++ b/src/renamewin.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include "ui_renamewin.h" diff --git a/src/rgba_icons.h b/src/rgba_icons.h index bcd47f4..9c2a598 100755 --- a/src/rgba_icons.h +++ b/src/rgba_icons.h @@ -1,4 +1,4 @@ -// This file is part of Notepad-- project +// This file is part of Notepad-- project // Copyright (C)2023 zuowei.yin // This program is free software: you can redistribute it and/or modify diff --git a/src/scintillaeditview.cpp b/src/scintillaeditview.cpp index f3413a6..29fcd7c 100755 --- a/src/scintillaeditview.cpp +++ b/src/scintillaeditview.cpp @@ -1,4 +1,4 @@ -#include "scintillaeditview.h" +#include "scintillaeditview.h" #include "common.h" #include "rgba_icons.h" diff --git a/src/scintillaeditview.h b/src/scintillaeditview.h index db44317..1e6a8a4 100755 --- a/src/scintillaeditview.h +++ b/src/scintillaeditview.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include #include diff --git a/src/scintillahexeditview.cpp b/src/scintillahexeditview.cpp index 94526ae..ca35a0a 100755 --- a/src/scintillahexeditview.cpp +++ b/src/scintillahexeditview.cpp @@ -1,4 +1,4 @@ -#include "scintillahexeditview.h" +#include "scintillahexeditview.h" #include "styleset.h" #include "ccnotepad.h" diff --git a/src/scintillahexeditview.h b/src/scintillahexeditview.h index fc824ca..26b6c3f 100755 --- a/src/scintillahexeditview.h +++ b/src/scintillahexeditview.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include diff --git a/src/shortcutkeyeditwin.cpp b/src/shortcutkeyeditwin.cpp index 7e253d3..dd22277 100755 --- a/src/shortcutkeyeditwin.cpp +++ b/src/shortcutkeyeditwin.cpp @@ -1,4 +1,4 @@ -#include "shortcutkeyeditwin.h" +#include "shortcutkeyeditwin.h" #include @@ -27,7 +27,7 @@ QKeySequence ShortcutKeyEditWin::getNewKeySeq() return m_newKeys; } -//ȷ޸ģȼһ¡ĸ +//确认修改,先检查一下。最多四个键 void ShortcutKeyEditWin::slot_ok() { QKeySequence keys = ui.keySequenceEdit->keySequence(); @@ -41,7 +41,7 @@ void ShortcutKeyEditWin::slot_ok() done(1); } -//ɾΪ +//删除为空 void ShortcutKeyEditWin::on_delete() { done(2); diff --git a/src/shortcutkeyeditwin.h b/src/shortcutkeyeditwin.h index 2c95de9..fc0e01d 100755 --- a/src/shortcutkeyeditwin.h +++ b/src/shortcutkeyeditwin.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include "ui_shortcutkeyeditwin.h" diff --git a/src/shortcutkeymgr.cpp b/src/shortcutkeymgr.cpp index 3a2507a..7432644 100755 --- a/src/shortcutkeymgr.cpp +++ b/src/shortcutkeymgr.cpp @@ -1,4 +1,4 @@ -#include "shortcutkeymgr.h" +#include "shortcutkeymgr.h" #include "shortcutkeyeditwin.h" #include "ccnotepad.h" @@ -13,12 +13,12 @@ QMap* ShortcutKeyMgr::s_shortcutKeysMap = nullptr; //QMap * qScintShortcutKeyValueMap = nullptr; struct ShortcutKeySt { - QString iniTag;//Iniļе - QString name;//ʾڱе - //QString keyDesc;//qkeysequence + QString iniTag;//保存在Ini文件中的名称 + QString name;//显示在表格中的名称 + //QString keyDesc;//qkeysequence的描述 QKeySequence key; - bool canModify;//ܷ޸ + bool canModify;//能否修改 ShortcutKeySt() = default; ShortcutKeySt(QString name_, QString iniTag_, bool canMofidy=true) :name(name_), iniTag(iniTag_), canModify(canMofidy) @@ -119,12 +119,12 @@ void ShortcutKeyMgr::initShortcutKeysMap() s_shortcutKeysMap->insert(shortCutTable.at(i).iniTag, i); } - //ļжȡû޸Ĺñ + //从文件中读取用户修改过的配置表。 loadUserDefSet(); } } -//ȵinitShortcutKeysMap() +//务必先调用initShortcutKeysMap() QKeySequence ShortcutKeyMgr::getUserDefShortcutKey(QString iniTag) { if (s_shortcutKeysMap->contains(iniTag)) @@ -134,7 +134,7 @@ QKeySequence ShortcutKeyMgr::getUserDefShortcutKey(QString iniTag) return QKeySequence(); } -//ûiniмؿݼ +//从用户ini配置中加载快捷键配置 void ShortcutKeyMgr::loadUserDefSet() { QString userDefFile = QString("notepad/shortcuttab"); @@ -159,7 +159,7 @@ void ShortcutKeyMgr::loadUserDefSet() } } -//޸ļеĿݼ塣inittag inikey, keySeqStr inivalueڴҲ޸ +//修改配置文件中的快捷键定义。inittag ini的key, keySeqStr ini的value。内存也修改了 bool ShortcutKeyMgr::ModifyShortCutKey(QString initTag, QString keySeqStr) { QString userDefFile = QString("notepad/shortcuttab"); @@ -210,7 +210,7 @@ void ShortcutKeyMgr::initNddShortcutTable() } } -//ʼqscintڲĿݼĿǰⲿֲ޸ġ +//初始化qscint内部的快捷键。目前这部分不能修改。 void ShortcutKeyMgr::initQscintShortcutTable() { QsciScintilla* pNote = new QsciScintilla(nullptr); @@ -273,7 +273,7 @@ int ShortcutKeyMgr::isKeySeqExist(int row, QString keySeq, int &type) } return -1; } -//˫޸IJۺ +//双击修改槽函数 void ShortcutKeyMgr::slot_edit(QTableWidgetItem* item) { int row = item->row(); @@ -289,14 +289,14 @@ void ShortcutKeyMgr::slot_edit(QTableWidgetItem* item) pWin->setCurKeyDesc(shortCutTable.at(row).key.toString()); int ret = pWin->exec(); - if (1 == ret) //ȷ + if (1 == ret) //确定 { QKeySequence newKeySeq = pWin->getNewKeySeq(); QTableWidgetItem* item = ui.tableWidget->item(row, 1); if (item != nullptr) { - //ǷͻͻáԤ + //检查是否冲突,如果冲突,则不设置。先预留 int conflictType = 0; int existId = isKeySeqExist(row, newKeySeq.toString(), conflictType); if (-1 == existId) @@ -329,7 +329,7 @@ void ShortcutKeyMgr::slot_edit(QTableWidgetItem* item) } } } - else if (2 == ret)//ɾ + else if (2 == ret)//删除 { QKeySequence newKeySeq(QKeySequence::UnknownKey); diff --git a/src/shortcutkeymgr.h b/src/shortcutkeymgr.h index f7c4e34..e4bebf3 100755 --- a/src/shortcutkeymgr.h +++ b/src/shortcutkeymgr.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include "ui_shortcutkeymgr.h" @@ -38,7 +38,7 @@ enum Shortcut_Key_ID { Format_Json_ID, - Shortcut_End_ID,// + Shortcut_End_ID,//总是在最底下 }; static const char* New_File = "newfile"; diff --git a/src/styleset.cpp b/src/styleset.cpp index d4162c8..c1eca51 100755 --- a/src/styleset.cpp +++ b/src/styleset.cpp @@ -1,4 +1,4 @@ -#include "styleset.h" +#include "styleset.h" #include "ccnotepad.h" #include #include @@ -70,7 +70,7 @@ void StyleSet::setCommonStyle(QColor foldfgColor_, QColor foldbgColor_, QColor m foldbgColor = foldbgColor_; marginsBackgroundColor = marginsBackgroundColor_; - QFile file(":/qss/lightbluestyle.qss"); //qssļ·:/lightblue.qss + QFile file(":/qss/lightbluestyle.qss"); //qss文件路径:/lightblue.qss QString styleSheet; if (file.open(QIODevice::Text | QIODevice::ReadOnly)) { @@ -128,7 +128,7 @@ void StyleSet::setSkin(int id) } } -//¼Globalȫַ +//重新加载Global全局风格 void StyleSet::reloadGolbalStyleFromSetFile() { loadGolbalStyle(); @@ -140,7 +140,7 @@ void StyleSet::loadGolbalStyle() QsciLexerGlobal* pGlobalLexer = dynamic_cast(pLexer); if (pGlobalLexer != nullptr) { - //ȡɫȻ롣ScintillaEditViewֱЩOne_Stype_Infoֵ + //获取其属性颜色,然后填入。后续在ScintillaEditView中直接设置这些One_Stype_Info的属性值 One_Stype_Info* pAddr = &s_global_style->global_style; for (int i = 0; i <= URL_HOVERRED; ++i) @@ -158,7 +158,7 @@ QString StyleSet::getCurrentStyle() return getStyleName(m_curStyleId); } -//Ƿɫϵ +//是否深色风格系列 bool StyleSet::isCurrentDeepStyle() { switch (m_curStyleId) @@ -217,7 +217,7 @@ void StyleSet::setDefaultStyle() marginsBackgroundColor = QColor(0xf0f0f0); bookmarkBkColor = QColor(0xececec); - QFile file(":/qss/mystyle.qss"); //qssļ·:/lightblue.qss + QFile file(":/qss/mystyle.qss"); //qss文件路径:/lightblue.qss QString styleSheet; if (file.open(QIODevice::Text | QIODevice::ReadOnly)) { @@ -246,7 +246,7 @@ void StyleSet::setThinBlueStyle() setCommonStyle(QColor(0xd7, 0xe3, 0xf4, 100), QColor(0xd7e3f4), QColor(0xd5e1f1), "#D7E3F4"); } -//ֽ +//纸黄 void StyleSet::setThinYellowStyle() { //m_curStyleId = THIN_YELLOW_SE; @@ -254,7 +254,7 @@ void StyleSet::setThinYellowStyle() setCommonStyle(QColor(0xf9, 0xf0, 0xe1, 100), QColor(0xf9f0e1), QColor(0xf7f0e0), "#F9F0E1"); } -//ֽ +//宣纸黄 void StyleSet::setRiceYellowStyle() { //m_curStyleId = RICE_YELLOW_SE; @@ -262,7 +262,7 @@ void StyleSet::setRiceYellowStyle() setCommonStyle(QColor(0xf6, 0xf3, 0xea, 100), QColor(0xf6f3ea), QColor(0xf4f1e9), "#F6F3EA"); } -//ɫ +//银色 void StyleSet::setSilverStyle() { //m_curStyleId = SILVER_SE; @@ -270,7 +270,7 @@ void StyleSet::setSilverStyle() setCommonStyle(QColor(0xe9, 0xe8, 0xe4, 100), QColor(0xe9e8e4), QColor(0xe7e6e2), "#E9E8E4"); } -//̸ɫ#FFF0F5 +//谈紫色#FFF0F5 void StyleSet::setLavenderBlushStyle() { //m_curStyleId = LAVENDER_SE; @@ -293,14 +293,14 @@ void StyleSet::setBlackStyle() foldfgColor = QColor(0,0, 0); foldbgColor = QColor(32, 32, 40); - //עⰵģʽǵĴڱɫfoldbgColor˱༭ıɫ - //ģʽ屳ȫǺɫ686868 + //注意暗黑模式是单独的窗口背景颜色。上面的foldbgColor决定了编辑器的背景颜色。 + //暗黑模式窗体背景不完全是黑色,而是686868 QColor blackPaletteColor(68,68,68); marginsBackgroundColor = QColor(57, 58, 60); bookmarkBkColor = QColor(53,54,56); - QFile file(":/qss/black.qss"); //qssļ·:/lightblue.qss + QFile file(":/qss/black.qss"); //qss文件路径:/lightblue.qss QString styleSheet; if (file.open(QIODevice::Text | QIODevice::ReadOnly)) { @@ -325,7 +325,7 @@ void StyleSet::setBlackStyle() marginsBackgroundColor = QColor(57, 58, 60); bookmarkBkColor = QColor(53, 54, 56); - QFile file(":/qss/myblack.qss"); //qssļ·:/lightblue.qss + QFile file(":/qss/myblack.qss"); //qss文件路径:/lightblue.qss QString styleSheet; if (file.open(QIODevice::Text | QIODevice::ReadOnly)) { diff --git a/src/styleset.h b/src/styleset.h index 564b0a0..1a90813 100755 --- a/src/styleset.h +++ b/src/styleset.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include @@ -30,7 +30,7 @@ struct One_Stype_Info { int styleId; QColor fgColor; QColor bgColor; - QFont font; //fontУ1壬СЩԣŴСû壬дСʹСʾ + QFont font; //这个font代表两个含有,1是字体,而是字体大小。有些属性,比如括号大小,他们没有字体,但是有大小,则使用字体大小来表示 One_Stype_Info() :styleId(-1) { } @@ -40,7 +40,7 @@ struct One_Stype_Info { }; -//ǰȫַԣеʽ޸ģ޸ṹ壬Ȼطٸ޸ĺĽṹ壬ͬ +//当前的全局风格属性,所有的样式修改,都是先修改这个结构体,然后其余地方再根据这个修改后的结构体,来进行同步更新 struct GLOBAL_STYLE_OPS { One_Stype_Info global_style; One_Stype_Info default_style; diff --git a/src/texteditsetwin.h b/src/texteditsetwin.h index 093331d..df3263d 100755 --- a/src/texteditsetwin.h +++ b/src/texteditsetwin.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include "ui_texteditsetwin.h" diff --git a/src/userlexdef.cpp b/src/userlexdef.cpp index 6b8c7d2..a1983a6 100755 --- a/src/userlexdef.cpp +++ b/src/userlexdef.cpp @@ -1,4 +1,4 @@ -#include "userlexdef.h" +#include "userlexdef.h" #include "rcglobal.h" #include @@ -12,14 +12,14 @@ UserLexDef::~UserLexDef() } -//Լһ׶ȡͱõĽӿ +//自己定义一套读取和保存配置的接口 bool UserLexDef::readUserSettings(QString langTagName) { - //ԶԸʽ + //自定义语言格式。 //mz:ndd //name:xxx - //mother:xxx none/cpp/html + //mother:xxx none/cpp/html 就三种 //keword:xxx QString userLangFile = QString("notepad/userlang/%1").arg(langTagName); @@ -28,7 +28,7 @@ bool UserLexDef::readUserSettings(QString langTagName) if (!qs.contains(QString("mz"))) { - //MzΪNddļ + //必须包含Mz为Ndd的键,否则错误 return false; } if (qs.value("mz").toString() != QString("ndd")) @@ -84,11 +84,11 @@ void UserLexDef::setMotherLang(UserLangMother words) bool UserLexDef::writeUserSettings(QString langTagName) { - //ԶԸʽ + //自定义语言格式。 //mz:ndd //name:xxx - //mother:xxx none/cpp/html - //ext:xx xx xx ļ׺ + //mother:xxx none/cpp/html 就三种 + //ext:xx xx xx 文件关联后缀名 //keyword:xxx QString userLangFile = QString("notepad/userlang/%1").arg(langTagName); diff --git a/src/userlexdef.h b/src/userlexdef.h index a93b17a..7944c66 100755 --- a/src/userlexdef.h +++ b/src/userlexdef.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include "rcglobal.h"