!52 Build Main App nodepad-- with QT6

Merge pull request !52 from troxyz/wip/build-with-qt6
This commit is contained in:
爬山虎 2023-02-17 09:34:05 +00:00 committed by Gitee
commit e392ef0da9
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
20 changed files with 316 additions and 233 deletions

View File

@ -5,7 +5,8 @@ set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets Concurrent Network PrintSupport XmlPatterns)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Gui Widgets Concurrent Network PrintSupport Xml Core5Compat)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Widgets Concurrent Network PrintSupport Xml Core5Compat)
# qscint
add_subdirectory(${PROJECT_SOURCE_DIR}/src/qscint)
@ -54,7 +55,17 @@ ${PROJECT_SOURCE_DIR}/src/qscint/scintilla/lexlib
${PROJECT_SOURCE_DIR}/src/qscint/scintilla/boostregex
)
target_link_libraries(${PROJECT_NAME} qscint Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Concurrent Qt5::Network Qt5::PrintSupport Qt5::XmlPatterns)
target_link_libraries(${PROJECT_NAME}
qscint
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::Concurrent
Qt${QT_VERSION_MAJOR}::Network
Qt${QT_VERSION_MAJOR}::PrintSupport
Qt${QT_VERSION_MAJOR}::Xml
Qt${QT_VERSION_MAJOR}::Core5Compat
)
# set(PROJECT_BINARY_DIR "${PROJECT_BINARY_DIR}/bin")
# set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)

View File

@ -281,7 +281,7 @@ quint32 CmpareMode::readLineFromFileWithUnicodeLe(uchar* m_fileFpr, const int fi
else if (mode == 2)
{
QString temp = lineInfo.unicodeStr;
md4.addData(temp.replace(QRegExp("\\s"), QString("")).toUtf8());
md4.addData(temp.replace(QRegularExpression("\\s"), QString("")).toUtf8());
}
};
@ -529,7 +529,7 @@ CODE_ID CmpareMode::readLineFromFile(uchar* m_fileFpr, const int fileLength, con
else if (mode == 2)
{
QString temp = lineInfo.unicodeStr;
md4.addData(temp.replace(QRegExp("\\s"), QString("")).toUtf8());
md4.addData(temp.replace(QRegularExpression("\\s"), QString("")).toUtf8());
}
};

View File

@ -1,4 +1,4 @@
#include "batchfindreplace.h"
#include "batchfindreplace.h"
#include "scintillaeditview.h"
#include "ccnotepad.h"
#include "progresswin.h"
@ -98,7 +98,7 @@ void BatchFindReplace::appendToFindReplaceTable(QStringList& findKeyword)
bool BatchFindReplace::tranInputKeyword(QString& findKeyWord, QStringList& outputKeyWordList)
{
//把空白字符,空格或者\t \r\n 等字符进行替换为空格
QRegExp re("\\s");
QRegularExpression re("\\s");
findKeyWord.replace(re, QString(" "));
//再进行空格分隔处理
@ -266,7 +266,9 @@ void BatchFindReplace::on_export()
if (!fileName.isEmpty())
{
QSettings setting(fileName, QSettings::IniFormat);
setting.setIniCodec("UTF-8");
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
setting->setIniCodec("UTF-8");
#endif
int rowNums = ui.findReplaceTable->rowCount();
@ -312,7 +314,9 @@ void BatchFindReplace::on_import()
QFileInfo fi(fileNameList[0]);
QSettings setting(fi.filePath(), QSettings::IniFormat);
setting.setIniCodec("UTF-8");
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
setting->setIniCodec("UTF-8");
#endif
ui.findKeywordEdit->setPlainText(setting.value("find").toStringList().join(" "));
ui.replaceKeywordEdit->setPlainText(setting.value("replace").toStringList().join(" "));

View File

@ -53,9 +53,11 @@
#include <QDateTime>
#include <QShortcut>
#ifdef Q_OS_WIN
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QXmlQuery>
#include <QXmlFormatter>
#endif
#endif
#include <QBuffer>
#include <QXmlStreamReader>
#include <QJsonObject>
@ -535,7 +537,9 @@ void initFileTypeLangMap()
//把新语言tagName,和关联ext单独存放起来ext_tag.ini。只读取一个文件就能获取所有避免遍历慢
QString extsFile = QString("notepad/userlang/ext_tag");//ext_tag是存在所有tag ext的文件
QSettings qs(QSettings::IniFormat, QSettings::UserScope, extsFile);
qs.setIniCodec("UTF-8");
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
qs->setIniCodec("UTF-8");
#endif
QStringList keys = qs.allKeys();
//LangType lexId = L_USER_TXT;
@ -4730,7 +4734,7 @@ void CCNotePad::initFileListDockWin()
}
});
m_dockFileListWin->setAttribute(Qt::WA_DeleteOnClose);
m_dockFileListWin->layout()->setMargin(0);
//m_dockFileListWin->layout()->setMargin(0);
m_dockFileListWin->layout()->setSpacing(0);
//暂时不提供关闭因为关闭后需要同步菜单的check状态
@ -5150,7 +5154,7 @@ void CCNotePad::saveTabEdit(int tabIndex)
if (pEdit != nullptr)
{
//如果是新建的文件,则弹出保存对话框,进行保存
if (pEdit->property(Edit_File_New) >= 0)
if (pEdit->property(Edit_File_New).toInt() >= 0)
{
QString filter("Text files (*.txt);;XML files (*.xml);;h files (*.h);;cpp file(*.cpp);;All types(*.*)");
QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), QString(), filter);
@ -5317,7 +5321,7 @@ void CCNotePad::slot_actionSaveAsFile_toggle(bool /*checked*/)
if (pEdit != nullptr)
{
//如果是新建的文件,则弹出保存对话框,进行保存
if (pEdit->property(Edit_File_New) >= 0)
if (pEdit->property(Edit_File_New).toInt() >= 0)
{
QString filter("Text files (*.txt);;XML files (*.xml);;h files (*.h);;cpp file(*.cpp);;All types(*.*)");
QString fileName = QFileDialog::getSaveFileName(this, tr("Save File As ..."),QString(), filter);
@ -5619,7 +5623,7 @@ void CCNotePad::saveTempFile(ScintillaEditView* pEdit,int index, QSettings& qs)
//把文件记录到qs中去
//index一定不能重复。n表示新建
//如果是新建的文件
if (pEdit->property(Edit_File_New) >= 0)
if (pEdit->property(Edit_File_New).toInt() >= 0)
{
//不再保存新建的非脏文件。因为一定是空的,意义不大
//qs.setValue(QString("%1").arg(index), QString("%1|1").arg(fileName));
@ -5639,7 +5643,7 @@ void CCNotePad::saveTempFile(ScintillaEditView* pEdit,int index, QSettings& qs)
}
//如果是新建的文件
if (pEdit->property(Edit_File_New) >= 0)
if (pEdit->property(Edit_File_New).toInt() >= 0)
{
QString qsSavePath = qs.fileName();
@ -5771,7 +5775,9 @@ void CCNotePad::closeAllFileStatic()
{
QString tempFileList = QString("notepad/temp/list");
QSettings qs(QSettings::IniFormat, QSettings::UserScope, tempFileList);
qs.setIniCodec("UTF-8");
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
qs->setIniCodec("UTF-8");
#endif
QString qsSavePath = qs.fileName();
QFileInfo fi(qsSavePath);
QDir saveDir = fi.dir();
@ -6312,7 +6318,9 @@ int CCNotePad::initFindWindow(FindTabIndex type)
//从历史查找记录文件中加载
QString searchHistory = QString("notepad/searchHistory");//历史查找记录
QSettings qs(QSettings::IniFormat, QSettings::UserScope, searchHistory);
qs.setIniCodec("UTF-8");
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
qs->setIniCodec("UTF-8");
#endif
if (qs.contains("keys"))
{
@ -6412,7 +6420,9 @@ void CCNotePad::slot_saveSearchHistory()
//从历史查找记录文件中加载
QString searchHistory = QString("notepad/searchHistory");//历史查找记录
QSettings qs(QSettings::IniFormat, QSettings::UserScope, searchHistory);
qs.setIniCodec("UTF-8");
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
qs->setIniCodec("UTF-8");
#endif
if (s_findHistroy.count() > 15)
{
@ -6639,7 +6649,7 @@ void CCNotePad::initFindResultDockWin()
m_dockSelectTreeWin = new QDockWidget(tr("Find result"), this);
connect(m_dockSelectTreeWin, &QDockWidget::dockLocationChanged, this, &CCNotePad::slot_findResultPosChangeed);
m_dockSelectTreeWin->layout()->setMargin(0);
//m_dockSelectTreeWin->layout()->setMargin(0);
m_dockSelectTreeWin->layout()->setSpacing(0);
//暂时不提供关闭因为关闭后需要同步菜单的check状态
@ -7561,7 +7571,7 @@ bool CCNotePad::nativeOpenfile(QString openFilePath)
this->activateWindow();
return true;
}
bool CCNotePad::nativeEvent(const QByteArray & eventType, void * message, long * result)
bool CCNotePad::nativeEvent(const QByteArray & eventType, void * message, qintptr * result)
{
MSG *param = static_cast<MSG *>(message);
@ -8111,7 +8121,9 @@ int CCNotePad::restoreLastFiles()
QString tempFileList = QString("notepad/temp/list");
QSettings qs(QSettings::IniFormat, QSettings::UserScope, tempFileList);
qs.setIniCodec("UTF-8");
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
qs->setIniCodec("UTF-8");
#endif
QStringList fileList = qs.allKeys();
//从小到大排序一下。这里是按照ASCII排序不得行。

View File

@ -196,7 +196,7 @@ protected:
void dropEvent(QDropEvent* e) override;
bool eventFilter(QObject *watched, QEvent *event)override;
#ifdef Q_OS_WIN
bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result) override;
bool nativeOpenfile(QString openFilePath);
#endif
#ifdef uos

View File

@ -1,4 +1,5 @@
#include "draglineedit.h"
#include "draglineedit.h"
#include <QFile>
DragLineEdit::DragLineEdit(QWidget *parent)
: QLineEdit(parent)

View File

@ -11,6 +11,7 @@
#include <QtConcurrent>
#include <QInputDialog>
#include <QDragEnterEvent>
#include <QTextCodec>
const int ITEM_CODE = Qt::UserRole + 1;

View File

@ -208,12 +208,12 @@ void FindResultWin::slot_selectAll()
//遍历下面的子节点
int i = 0;
QModelIndex childMi;
childMi = sectionItem.child(i, 0);
childMi = sectionItem.model()->index(i, 0);
while (childMi.isValid())
{
++i;
ui.resultTreeView->selectionModel()->select(childMi, QItemSelectionModel::Select);
childMi = sectionItem.child(i, 0);
childMi = sectionItem.model()->index(i, 0);
}
return i+1;
};
@ -226,12 +226,12 @@ void FindResultWin::slot_selectAll()
//遍历根节点下面每一个section
{
int i = 0;
QModelIndex section = rootItem.child(i, 0);
QModelIndex section = rootItem.model()->index(i, 0);
while (section.isValid() && !section.data(ResultItemEditor).isNull())
{
++i;
selectCount += selectSection(section);
section = firstRootItem.child(i, 0);
section = firstRootItem.model()->index(i, 0);
}
}
@ -255,12 +255,12 @@ void FindResultWin::slot_selectSection()
//遍历下面的子节点
int i = 0;
QModelIndex childMi;
childMi = sectionItem.child(i, 0);
childMi = sectionItem.model()->index(i, 0);
while (childMi.isValid())
{
++i;
ui.resultTreeView->selectionModel()->select(childMi, QItemSelectionModel::Select);
childMi = sectionItem.child(i, 0);
childMi = sectionItem.model()->index(i, 0);
}
return i+1;
};
@ -453,7 +453,7 @@ QString FindResultWin::highlightFindText(FindRecord& record)
head = QString("<font style='font-size:14px;'>%1</font>").arg(head);
src = QString("<font style='font-size:14px;background-color:#ffffbf'>%1</font>").arg(QString(utf8bytes.mid(targetStart, targetLens)).toHtmlEscaped());
tail = QString(utf8bytes.mid(tailStart));
if (tail > MAX_TAIL_LENGTH)
if (tail.size() > MAX_TAIL_LENGTH)
{
tail = (tail.mid(0, MAX_TAIL_LENGTH) + "...").toHtmlEscaped();
}
@ -488,7 +488,7 @@ QString FindResultWin::highlightFindText(FindRecord& record)
src = QString("<font style='font-size:14px;font-weight:bold;color:#ffaa00'>%1</font>").arg(QString(utf8bytes.mid(targetStart, targetLens)).toHtmlEscaped());
QString tailContens = QString(utf8bytes.mid(tailStart));
if (tailContens > MAX_TAIL_LENGTH)
if (tailContens.size() > MAX_TAIL_LENGTH)
{
tailContens = (tailContens.mid(0, MAX_TAIL_LENGTH) + "...").toHtmlEscaped();
}

View File

@ -621,8 +621,8 @@ bool readBase(const QChar * str, int * value, int base, int size)
current = str[i];
if (current >= 'A')
{
current = current.digitValue() & 0xdf;
current = current.digitValue() - ('A' - '0' - 10);
current = QChar(current.digitValue() & 0xdf);
current = QChar(current.digitValue() - ('A' - '0' - 10));
}
else if (current > '9')
return false;

View File

@ -7,6 +7,7 @@
#include <QHeaderView>
#include <QSettings>
#include <QMessageBox>
#include <QFile>
int ITEM_CHANGED = Qt::UserRole;
int ITEM_LEX_ID = Qt::UserRole + 1; //对应的语法lexer的 ID
@ -113,7 +114,9 @@ void LangExtSet::slot_save()
QString userLangFile = QString("notepad/tag_ext");
QSettings qs(QSettings::IniFormat, QSettings::UserScope, userLangFile);
qs.setIniCodec("UTF-8");
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
qs->setIniCodec("UTF-8");
#endif
for (int i = 0; i < rowNums; ++i)
{
@ -180,7 +183,9 @@ void LangExtSet::loadExtRelevanceToMagr()
{
QString userLangFile = QString("notepad/tag_ext");//自定义语言中不能有.字符,否则可能有错,后续要检查
QSettings qs(QSettings::IniFormat, QSettings::UserScope, userLangFile);
qs.setIniCodec("UTF-8");
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
qs->setIniCodec("UTF-8");
#endif
if (!QFile::exists(qs.fileName()))
{

View File

@ -30,8 +30,10 @@ bool LangStyleDefine::readLangSetFile(QString langName, bool isLoadToUI)
{
QString userLangFile = QString("notepad/userlang/%1").arg(langName);//自定义语言中不能有.字符,否则可能有错,后续要检查
QSettings qs(QSettings::IniFormat, QSettings::UserScope, userLangFile);
qs.setIniCodec("UTF-8");
qDebug() << qs.fileName();
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
qs->setIniCodec("UTF-8");
#endif
//qDebug() << qs.fileName();
if (!qs.contains("mz"))
{
@ -160,7 +162,9 @@ void LangStyleDefine::slot_save()
//把新语言tagName,和关联ext单独存放起来。后面只读取一个文件就能获取所有避免遍历慢
QString extsFile = QString("notepad/userlang/ext_tag");//ext_tag是存在所有tag ext的文件
QSettings qs(QSettings::IniFormat, QSettings::UserScope, extsFile);
qs.setIniCodec("UTF-8");
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
qs->setIniCodec("UTF-8");
#endif
QStringList extList = ui.extNameLe->text().trimmed().split(" ");
extList.append(QString::number(motherLangs)); //最后一个是mother lexer
@ -201,7 +205,9 @@ void LangStyleDefine::slot_delete()
{
QString userLangFile = QString("notepad/userlang/%1").arg(name);//自定义语言中不能有.字符,否则可能有错,后续要检查
QSettings qs(QSettings::IniFormat, QSettings::UserScope, userLangFile);
qs.setIniCodec("UTF-8");
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
qs->setIniCodec("UTF-8");
#endif
//删除userlang下面的tag.ini
QFile::remove(qs.fileName());
@ -211,7 +217,9 @@ void LangStyleDefine::slot_delete()
//把新语言在ext_tag中的关联文件记录也删除
QString extsFile = QString("notepad/userlang/ext_tag");//ext_tag是存在所有tag ext的文件
QSettings qs(QSettings::IniFormat, QSettings::UserScope, extsFile);
qs.setIniCodec("UTF-8");
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
qs->setIniCodec("UTF-8");
#endif
QStringList extList = qs.value(name).toStringList();
//更新当前ExtLexerManager::getInstance()。如果不更新,就要重启软件才能生效

View File

@ -1,4 +1,4 @@
#include "ccnotepad.h"
#include "ccnotepad.h"
#include "nddsetting.h"
#include "styleset.h"
@ -23,11 +23,20 @@
#ifdef Q_OS_WIN
#pragma comment(lib, "user32.lib")
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#if _DEBUG
#pragma comment(lib, "qmyedit_qt5d.lib")
#else
#pragma comment(lib, "qmyedit_qt5.lib")
#endif
#else
#if _DEBUG
#pragma comment(lib, "qmyedit_qt6d.lib")
#else
#pragma comment(lib, "qmyedit_qt6.lib")
#endif
#endif
#include <qt_windows.h>
const ULONG_PTR CUSTOM_TYPE = 10000;
const ULONG_PTR OPEN_NOTEPAD_TYPE = 10001;

View File

@ -50,7 +50,9 @@ void NddSetting::init()
QString qsSetPath = qs.fileName();
s_nddSet = new QSettings(QSettings::IniFormat, QSettings::UserScope, settingDir);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
s_nddSet->setIniCodec("UTF-8");
#endif
bool initOk = true;
auto initNddSet = []() {
@ -341,6 +343,8 @@ void NddSetting::winPosInit()
QString qsSetPath = qs.fileName();
s_winPosSet = new QSettings(QSettings::IniFormat, QSettings::UserScope, settingDir);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
s_winPosSet->setIniCodec("UTF-8");
#endif
}
}

View File

@ -5,7 +5,8 @@ set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets Concurrent Network PrintSupport XmlPatterns)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Gui Widgets Concurrent Network PrintSupport Xml)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Widgets Concurrent Network PrintSupport Xml)
add_definitions(-D_UNICODE -DUNICODE)
@ -31,7 +32,15 @@ ${PROJECT_SOURCE_DIR}/../../qscint/scintilla/lexlib
${PROJECT_SOURCE_DIR}/../../qscint/scintilla/boostregex
)
target_link_libraries(${PROJECT_NAME} qscint Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Concurrent Qt5::Network Qt5::PrintSupport Qt5::XmlPatterns)
target_link_libraries(${PROJECT_NAME}
qscint
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::Concurrent
Qt${QT_VERSION_MAJOR}::Network
Qt${QT_VERSION_MAJOR}::PrintSupport
Qt${QT_VERSION_MAJOR}::Xml)
# if(NOT DEFINED ${notepad--_BINARY_DIR})
# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${notepad--_BINARY_DIR}/bin/plugin)

View File

@ -5,7 +5,8 @@ set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets PrintSupport)
find_package(Qt$ NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Gui Widgets PrintSupport)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Widgets PrintSupport)
aux_source_directory(${PROJECT_SOURCE_DIR}/src SRC)
aux_source_directory(${PROJECT_SOURCE_DIR}/scintilla/lexers SRC)
@ -35,12 +36,18 @@ ${PROJECT_SOURCE_DIR}/src/Qsci
${PROJECT_SOURCE_DIR}/scintilla/src
${PROJECT_SOURCE_DIR}/scintilla/include)
target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Concurrent Qt5::Network Qt5::PrintSupport)
target_link_libraries(${PROJECT_NAME}
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::Concurrent
Qt${QT_VERSION_MAJOR}::Network
Qt${QT_VERSION_MAJOR}::PrintSupport)
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "qmyedit_qt5")
else()
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "qmyedit_qt5d")
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "qmyedit_qt${QT_VERSION_MAJOR}d")
endif()

View File

@ -1,4 +1,4 @@
// This module implements the QsciLexer class.
// This module implements the QsciLexer class.
//
// Copyright (c) 2021 Riverbank Computing Limited <info@riverbankcomputing.com>
//
@ -907,7 +907,9 @@ const char* QsciLexer::getUserDefineKeywords()
QString userLangFile = QString("notepad/userlang/%1").arg(m_tagName);//自定义语言中不能有.字符,否则可能有错,后续要检查
QSettings qs(QSettings::IniFormat, QSettings::UserScope, userLangFile);
qs.setIniCodec("UTF-8");
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
qs->setIniCodec("UTF-8");
#endif
if (!qs.contains("mz"))
{

View File

@ -826,7 +826,9 @@ bool QtLangSet::readLangSetFile(QString langName,QString &keyword, QString &moth
{
QString userLangFile = QString("notepad/userlang/%1").arg(langName);//自定义语言中不能有.字符,否则可能有错,后续要检查
QSettings qs(QSettings::IniFormat, QSettings::UserScope, userLangFile);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
qs.setIniCodec("UTF-8");
#endif
//qDebug() << qs.fileName();
if (!qs.contains("mz"))

View File

@ -3308,7 +3308,7 @@ bool isUrlQueryDelimiter(QChar const c)
void scanToUrlEnd(QString & text, int textLen, int start, int* distance)
{
int p = start;
QChar q = 0;
QChar q{0};
enum { sHostAndPath, sQuery, sQueryAfterDelimiter, sQueryQuotes, sQueryAfterQuotes, sFragment } s = sHostAndPath;
while (p < textLen)
{

View File

@ -139,7 +139,9 @@ void ShortcutKeyMgr::loadUserDefSet()
{
QString userDefFile = QString("notepad/shortcuttab");
QSettings qs(QSettings::IniFormat, QSettings::UserScope, userDefFile);
qs.setIniCodec("UTF-8");
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
qs->setIniCodec("UTF-8");
#endif
QStringList keys = qs.allKeys();
@ -164,7 +166,9 @@ bool ShortcutKeyMgr::ModifyShortCutKey(QString initTag, QString keySeqStr)
{
QString userDefFile = QString("notepad/shortcuttab");
QSettings qs(QSettings::IniFormat, QSettings::UserScope, userDefFile);
qs.setIniCodec("UTF-8");
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
qs->setIniCodec("UTF-8");
#endif
if (s_shortcutKeysMap->contains(initTag))
{

View File

@ -24,7 +24,9 @@ bool UserLexDef::readUserSettings(QString langTagName)
QString userLangFile = QString("notepad/userlang/%1").arg(langTagName);
QSettings qs(QSettings::IniFormat, QSettings::UserScope, userLangFile);
qs.setIniCodec("UTF-8");
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
qs->setIniCodec("UTF-8");
#endif
if (!qs.contains(QString("mz")))
{
@ -93,7 +95,9 @@ bool UserLexDef::writeUserSettings(QString langTagName)
QString userLangFile = QString("notepad/userlang/%1").arg(langTagName);
QSettings qs(QSettings::IniFormat, QSettings::UserScope, userLangFile);
qs.setIniCodec("UTF-8");
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
qs->setIniCodec("UTF-8");
#endif
qs.clear();
qs.setValue("mz", langTagName);