|
@@ -192,7 +192,7 @@ int getFileNewIndexProperty(QWidget* pwidget)
|
|
return pwidget->property(Edit_File_New).toInt();
|
|
return pwidget->property(Edit_File_New).toInt();
|
|
}
|
|
}
|
|
|
|
|
|
-void setTextChangeProperty(QWidget* pwidget, bool status)
|
|
|
|
|
|
+inline void setTextChangeProperty(QWidget* pwidget, bool status)
|
|
{
|
|
{
|
|
QVariant v(status);
|
|
QVariant v(status);
|
|
pwidget->setProperty(Edit_Text_Change, v);
|
|
pwidget->setProperty(Edit_Text_Change, v);
|
|
@@ -452,6 +452,8 @@ QString watchFilePath;
|
|
|
|
|
|
QStringList CCNotePad::s_findHistroy;
|
|
QStringList CCNotePad::s_findHistroy;
|
|
|
|
|
|
|
|
+QStringList CCNotePad::s_replaceHistroy;
|
|
|
|
+
|
|
int CCNotePad::s_autoWarp = 0; //自动换行
|
|
int CCNotePad::s_autoWarp = 0; //自动换行
|
|
int CCNotePad::s_indent = 0; //自动缩进
|
|
int CCNotePad::s_indent = 0; //自动缩进
|
|
int CCNotePad::s_showblank = 0; //显示空白
|
|
int CCNotePad::s_showblank = 0; //显示空白
|
|
@@ -1501,14 +1503,7 @@ void CCNotePad::setUserDefShortcutKey(int shortcutId)
|
|
ui.actionGoline->setShortcut(keySeq);
|
|
ui.actionGoline->setShortcut(keySeq);
|
|
|
|
|
|
break;
|
|
break;
|
|
-
|
|
|
|
- case File_Compare_ID:
|
|
|
|
- break;
|
|
|
|
- case Dir_Compare_ID:
|
|
|
|
- break;
|
|
|
|
- case Bin_Compare_ID:
|
|
|
|
- break;
|
|
|
|
-
|
|
|
|
|
|
+
|
|
case Trans_code_ID:
|
|
case Trans_code_ID:
|
|
keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Trans_code);
|
|
keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Trans_code);
|
|
m_transcode->setShortcut(keySeq);
|
|
m_transcode->setShortcut(keySeq);
|
|
@@ -1781,8 +1776,10 @@ void CCNotePad::onPlugWork(bool check)
|
|
if (pMainCallBack != NULL)
|
|
if (pMainCallBack != NULL)
|
|
{
|
|
{
|
|
std::function<QsciScintilla* ()> foundCallBack = std::bind(&CCNotePad::getCurEditView, this);
|
|
std::function<QsciScintilla* ()> foundCallBack = std::bind(&CCNotePad::getCurEditView, this);
|
|
|
|
+ std::function<bool(int, void*)> pluginCallBack = std::bind(&CCNotePad::pluginInvoke, this, std::placeholders::_1, std::placeholders::_2);
|
|
|
|
+
|
|
|
|
+ pMainCallBack(this, plugPath, foundCallBack, pluginCallBack, nullptr);
|
|
|
|
|
|
- pMainCallBack(this, plugPath, foundCallBack, nullptr);
|
|
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -1805,8 +1802,9 @@ void CCNotePad::sendParaToPlugin(NDD_PROC_DATA& procData)
|
|
if (pMainCallBack != NULL)
|
|
if (pMainCallBack != NULL)
|
|
{
|
|
{
|
|
std::function<QsciScintilla* ()> foundCallBack = std::bind(&CCNotePad::getCurEditView, this);
|
|
std::function<QsciScintilla* ()> foundCallBack = std::bind(&CCNotePad::getCurEditView, this);
|
|
|
|
+ std::function<bool(int, void*)> pluginCallBack = std::bind(&CCNotePad::pluginInvoke, this, std::placeholders::_1, std::placeholders::_2);
|
|
|
|
|
|
- pMainCallBack(this, plugPath, foundCallBack, &procData);
|
|
|
|
|
|
+ pMainCallBack(this, plugPath, foundCallBack, pluginCallBack, &procData);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -2154,7 +2152,7 @@ void CCNotePad::initNotePadSqlOptions()
|
|
ScintillaEditView::s_noUseTab = (1 == NddSetting::getKeyValueFromNumSets(key1)) ? true : false;
|
|
ScintillaEditView::s_noUseTab = (1 == NddSetting::getKeyValueFromNumSets(key1)) ? true : false;
|
|
|
|
|
|
ScintillaEditView::s_bigTextSize = NddSetting::getKeyValueFromNumSets(MAX_BIG_TEXT);
|
|
ScintillaEditView::s_bigTextSize = NddSetting::getKeyValueFromNumSets(MAX_BIG_TEXT);
|
|
- if (ScintillaEditView::s_bigTextSize < 50 || ScintillaEditView::s_bigTextSize > 300)
|
|
|
|
|
|
+ if (ScintillaEditView::s_bigTextSize < 50 || ScintillaEditView::s_bigTextSize > 600)
|
|
{
|
|
{
|
|
ScintillaEditView::s_bigTextSize = 100;
|
|
ScintillaEditView::s_bigTextSize = 100;
|
|
}
|
|
}
|
|
@@ -3376,6 +3374,14 @@ void CCNotePad::slot_lexerActTrig(QAction *action)
|
|
//保存最近打开文件到数据库。文件只有在关闭时,才写入最近列表。不关闭的下次自动恢复打开
|
|
//保存最近打开文件到数据库。文件只有在关闭时,才写入最近列表。不关闭的下次自动恢复打开
|
|
void CCNotePad::saveReceneOpenFile()
|
|
void CCNotePad::saveReceneOpenFile()
|
|
{
|
|
{
|
|
|
|
+ int clearOpenfilelist = NddSetting::getKeyValueFromDelayNumSets(CLEAR_OPENFILE_ON_CLOSE);
|
|
|
|
+ //开启了关闭时清空打开历史列表
|
|
|
|
+ if (clearOpenfilelist == 1)
|
|
|
|
+ {
|
|
|
|
+ NddSetting::updataKeyValueFromDelaySets(RECENT_OPEN_FILE, "");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
QString rFile(RECENT_OPEN_FILE);
|
|
QString rFile(RECENT_OPEN_FILE);
|
|
|
|
|
|
const int maxRecord = 15;
|
|
const int maxRecord = 15;
|
|
@@ -3538,7 +3544,8 @@ void CCNotePad::setLangsDescLable(QString &langDesc)
|
|
//重新加载文件。这里有个问题,文件的序号会跳动,要解决跳动问题。
|
|
//重新加载文件。这里有个问题,文件的序号会跳动,要解决跳动问题。
|
|
//这里不能销毁当前pedit,加载编码也要保持不变。而且加载的文件一定是普通文本模式
|
|
//这里不能销毁当前pedit,加载编码也要保持不变。而且加载的文件一定是普通文本模式
|
|
//目前只在文本文件被修改后,外部自动加载的场景
|
|
//目前只在文本文件被修改后,外部自动加载的场景
|
|
-void CCNotePad::reloadEditFile(ScintillaEditView* pEdit, bool isTailfOn)
|
|
|
|
|
|
+//如果isTailfOn == true, 则从startReadSize开始读取文件,不从头读取。startReadSize=-1则还是从头,否则从startReadSize开始
|
|
|
|
+void CCNotePad::reloadEditFile(ScintillaEditView* pEdit, bool isTailfOn, qint64 startReadSize)
|
|
{
|
|
{
|
|
QString filePath = pEdit->property(Edit_View_FilePath).toString();
|
|
QString filePath = pEdit->property(Edit_View_FilePath).toString();
|
|
|
|
|
|
@@ -3553,16 +3560,35 @@ void CCNotePad::reloadEditFile(ScintillaEditView* pEdit, bool isTailfOn)
|
|
|
|
|
|
//下面这个clear会触发文本修改,要避免不必要的消息循环。先屏蔽一些信号
|
|
//下面这个clear会触发文本修改,要避免不必要的消息循环。先屏蔽一些信号
|
|
disEnableEditTextChangeSign(pEdit);
|
|
disEnableEditTextChangeSign(pEdit);
|
|
|
|
+ if (isTailfOn && startReadSize != -1)
|
|
|
|
+ {
|
|
|
|
+ //如果是tail模式,则不要直接把文档清空
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
pEdit->clear();
|
|
pEdit->clear();
|
|
|
|
+ }
|
|
pEdit->setProperty(Edit_Text_Change, QVariant(false));
|
|
pEdit->setProperty(Edit_Text_Change, QVariant(false));
|
|
setSaveButtonStatus(false);
|
|
setSaveButtonStatus(false);
|
|
|
|
|
|
- int errCode = FileManager::getInstance().loadFileDataInText(pEdit, filePath, code, lineEnd, nullptr, false, this);
|
|
|
|
|
|
+ int errCode = 0;
|
|
|
|
+
|
|
|
|
+ if (isTailfOn && startReadSize != -1)
|
|
|
|
+ {
|
|
|
|
+ //使用tailf读取尾部一部分数据;而不是全部读取
|
|
|
|
+ errCode = FileManager::getInstance().loadFileDataInTextFromOffset(pEdit, filePath, code, this, startReadSize);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ errCode = FileManager::getInstance().loadFileDataInText(pEdit, filePath, code, lineEnd, nullptr, false, this);
|
|
|
|
+ }
|
|
|
|
|
|
enableEditTextChangeSign(pEdit);
|
|
enableEditTextChangeSign(pEdit);
|
|
|
|
|
|
- if (errCode == 5)
|
|
|
|
|
|
+ if (6 == errCode)
|
|
{
|
|
{
|
|
|
|
+ //可能存在乱码,给出警告。还是以编辑模式打开
|
|
|
|
+ ui.statusBar->showMessage(tr("File %1 open success. But Exist Garbled code !"));
|
|
}
|
|
}
|
|
else if (errCode != 0)
|
|
else if (errCode != 0)
|
|
{
|
|
{
|
|
@@ -3575,17 +3601,44 @@ void CCNotePad::reloadEditFile(ScintillaEditView* pEdit, bool isTailfOn)
|
|
lineNum = pEdit->lines();
|
|
lineNum = pEdit->lines();
|
|
}
|
|
}
|
|
pEdit->execute(SCI_GOTOLINE, lineNum - 1);
|
|
pEdit->execute(SCI_GOTOLINE, lineNum - 1);
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
#ifdef Q_OS_WIN
|
|
#ifdef Q_OS_WIN
|
|
-void CCNotePad::on_roladFile(ScintillaEditView* pEdit)
|
|
|
|
|
|
+void CCNotePad::on_roladFile(ScintillaEditView* pEdit,quint64 lastSize, qint64 curSize)
|
|
{
|
|
{
|
|
pEdit->setProperty(Modify_Outside, QVariant(true));
|
|
pEdit->setProperty(Modify_Outside, QVariant(true));
|
|
- checkRoladFile(pEdit);
|
|
|
|
|
|
+ checkRoladFile(pEdit, lastSize);
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
|
|
-bool CCNotePad::checkRoladFile(ScintillaEditView* pEdit)
|
|
|
|
|
|
+void CCNotePad::doReloadTxtFile(ScintillaEditView* pEdit, bool isOnTail, qint64 startReadSize)
|
|
|
|
+{
|
|
|
|
+ //reloadEditFile 里面会关闭和新增tab,触发一系列的currentChanged
|
|
|
|
+ disconnect(ui.editTabWidget, &QTabWidget::currentChanged, this, &CCNotePad::slot_tabCurrentChanged);
|
|
|
|
+ reloadEditFile(pEdit, isOnTail, startReadSize);
|
|
|
|
+ pEdit->setProperty(Modify_Outside, QVariant(false));
|
|
|
|
+ connect(ui.editTabWidget, &QTabWidget::currentChanged, this, &CCNotePad::slot_tabCurrentChanged, Qt::UniqueConnection);
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+//初次进入文件tailf模式。把文件清空,而且只留100行文件
|
|
|
|
+void CCNotePad::firstTimeIntoTail(ScintillaEditView* pEdit, int remainLineNums)
|
|
|
|
+{
|
|
|
|
+ int lineCount = pEdit->lines();
|
|
|
|
+ int startLineNum = 0;
|
|
|
|
+ if (lineCount >= remainLineNums)
|
|
|
|
+ {
|
|
|
|
+ startLineNum = lineCount - remainLineNums;
|
|
|
|
+ }
|
|
|
|
+ int pos = pEdit->execute(SCI_POSITIONFROMLINE, startLineNum);
|
|
|
|
+ disEnableEditTextChangeSign(pEdit);
|
|
|
|
+ pEdit->clear();
|
|
|
|
+ enableEditTextChangeSign(pEdit);
|
|
|
|
+ doReloadTxtFile(pEdit, true, pos);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//startReadSize == -1 则从头开始读取。否则从startReadSize开始
|
|
|
|
+bool CCNotePad::checkRoladFile(ScintillaEditView* pEdit, qint64 startReadSize)
|
|
{
|
|
{
|
|
if (pEdit != nullptr && pEdit->property(Modify_Outside).toBool())
|
|
if (pEdit != nullptr && pEdit->property(Modify_Outside).toBool())
|
|
{
|
|
{
|
|
@@ -3597,8 +3650,6 @@ bool CCNotePad::checkRoladFile(ScintillaEditView* pEdit)
|
|
|
|
|
|
m_isInReloadFile = true;
|
|
m_isInReloadFile = true;
|
|
|
|
|
|
- QString filePath = pEdit->property(Edit_View_FilePath).toString();
|
|
|
|
-
|
|
|
|
int tailStatus = getFileTailProperty(pEdit);
|
|
int tailStatus = getFileTailProperty(pEdit);
|
|
|
|
|
|
if (tailStatus != 1)
|
|
if (tailStatus != 1)
|
|
@@ -3606,25 +3657,38 @@ bool CCNotePad::checkRoladFile(ScintillaEditView* pEdit)
|
|
QApplication::beep();
|
|
QApplication::beep();
|
|
}
|
|
}
|
|
|
|
|
|
- auto doReload = [this](ScintillaEditView* pEdit, bool isOnTail) {
|
|
|
|
- //reloadEditFile 里面会关闭和新增tab,触发一系列的currentChanged
|
|
|
|
- disconnect(ui.editTabWidget, &QTabWidget::currentChanged, this, &CCNotePad::slot_tabCurrentChanged);
|
|
|
|
- reloadEditFile(pEdit, isOnTail);
|
|
|
|
- pEdit->setProperty(Modify_Outside, QVariant(false));
|
|
|
|
- connect(ui.editTabWidget, &QTabWidget::currentChanged, this, &CCNotePad::slot_tabCurrentChanged, Qt::UniqueConnection);
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
//如果是开启了taif,则不提示,直接重新加载文件
|
|
//如果是开启了taif,则不提示,直接重新加载文件
|
|
if (tailStatus == 1)
|
|
if (tailStatus == 1)
|
|
{
|
|
{
|
|
- doReload(pEdit,true);
|
|
|
|
|
|
+ //如果是进入tailf模式,但是startReadSize == -1.则什么也不干。
|
|
|
|
+ //等监控超时后,后续走tailf差异读取模式。
|
|
|
|
+ if (startReadSize == -1)
|
|
|
|
+ {
|
|
|
|
+ //这里什么也不做。坐等超时后,走下面的逻辑
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
|
|
+ //如果文件大于3000行,则删除内容,只保留当前100行,继续tailf
|
|
|
|
+ if (pEdit->lines() < 3000)
|
|
|
|
+ {
|
|
|
|
+ doReloadTxtFile(pEdit, true, startReadSize);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ firstTimeIntoTail(pEdit,100);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ QString filePath = pEdit->property(Edit_View_FilePath).toString();
|
|
|
|
+
|
|
int ret = QMessageBox::question(this, tr("Reload"), tr("\"%1\" This file has been modified by another program. Do you want to reload it?").arg(filePath), tr("Yes[Reload]"), tr("No[Drop]"), tr("On Tailf"));
|
|
int ret = QMessageBox::question(this, tr("Reload"), tr("\"%1\" This file has been modified by another program. Do you want to reload it?").arg(filePath), tr("Yes[Reload]"), tr("No[Drop]"), tr("On Tailf"));
|
|
if(ret == 0)
|
|
if(ret == 0)
|
|
{
|
|
{
|
|
- doReload(pEdit, false);
|
|
|
|
|
|
+ doReloadTxtFile(pEdit, false, startReadSize);
|
|
}
|
|
}
|
|
else if (ret == 1)
|
|
else if (ret == 1)
|
|
{
|
|
{
|
|
@@ -3634,8 +3698,10 @@ bool CCNotePad::checkRoladFile(ScintillaEditView* pEdit)
|
|
else if (ret == 2)
|
|
else if (ret == 2)
|
|
{
|
|
{
|
|
m_tailf->setChecked(true);
|
|
m_tailf->setChecked(true);
|
|
- doReload(pEdit, true);
|
|
|
|
|
|
|
|
|
|
+ //这里也是首次开启tailf
|
|
|
|
+ //读取最后3000行的内容。进入tailf模式
|
|
|
|
+ firstTimeIntoTail(pEdit,3000);
|
|
//开启监控
|
|
//开启监控
|
|
tailfile(true,pEdit);
|
|
tailfile(true,pEdit);
|
|
}
|
|
}
|
|
@@ -3698,7 +3764,8 @@ void CCNotePad::enableEditTextChangeSign(ScintillaEditView* pEdit)
|
|
//直到保存后,再放开
|
|
//直到保存后,再放开
|
|
void CCNotePad::disEnableEditTextChangeSign(ScintillaEditView* pEdit)
|
|
void CCNotePad::disEnableEditTextChangeSign(ScintillaEditView* pEdit)
|
|
{
|
|
{
|
|
- pEdit->disconnect(SIGNAL(textChanged()));
|
|
|
|
|
|
+ //pEdit->disconnect(SIGNAL(textChanged()));
|
|
|
|
+ disconnect(pEdit, &ScintillaEditView::textChanged, this, &CCNotePad::slot_editViewMofidyChange);
|
|
}
|
|
}
|
|
|
|
|
|
//编辑框文本变化后,设置对应的变化状态
|
|
//编辑框文本变化后,设置对应的变化状态
|
|
@@ -3905,10 +3972,22 @@ void CCNotePad::tabClose(int index, bool isInQuit)
|
|
{
|
|
{
|
|
QApplication::beep();
|
|
QApplication::beep();
|
|
|
|
|
|
- int ret = QMessageBox::question(this, tr("Do you want to save changes to before closing?"), tr("If you don't save the changes you made in file %1, you'll lose them forever.").arg(filePath), tr("Yes"), tr("No"), tr("Cancel"));
|
|
|
|
-
|
|
|
|
|
|
+ QMessageBox askSave(QMessageBox::Question, tr("Do you want to save changes to before closing?"), \
|
|
|
|
+ tr("If you don't save the changes you made in file %1, you'll lose them forever.").arg(filePath), \
|
|
|
|
+ QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, this);
|
|
|
|
+ QPushButton* okButton = (QPushButton *) askSave.button(QMessageBox::Yes);
|
|
|
|
+ okButton->setText(tr("&Yes"));
|
|
|
|
+
|
|
|
|
+ okButton = (QPushButton*)askSave.button(QMessageBox::No);
|
|
|
|
+ okButton->setText(tr("&No"));
|
|
|
|
+
|
|
|
|
+ okButton = (QPushButton*)askSave.button(QMessageBox::Cancel);
|
|
|
|
+ okButton->setText(tr("&Cancel"));
|
|
|
|
+
|
|
|
|
+ int ret = askSave.exec();
|
|
|
|
+
|
|
//保存
|
|
//保存
|
|
- if (ret == 0)
|
|
|
|
|
|
+ if (ret == QMessageBox::Yes)
|
|
{
|
|
{
|
|
saveTabEdit(index);
|
|
saveTabEdit(index);
|
|
|
|
|
|
@@ -3918,7 +3997,7 @@ void CCNotePad::tabClose(int index, bool isInQuit)
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- else if (ret == 2)
|
|
|
|
|
|
+ else if (ret == QMessageBox::Cancel)
|
|
{
|
|
{
|
|
m_isQuitCancel = true;
|
|
m_isQuitCancel = true;
|
|
return;
|
|
return;
|
|
@@ -4008,7 +4087,12 @@ ScintillaEditView* CCNotePad::newTxtFile(QString name, int index, QString conten
|
|
if (!contentPath.isEmpty())
|
|
if (!contentPath.isEmpty())
|
|
{
|
|
{
|
|
int ret = FileManager::getInstance().loadFileDataInText(pEdit, contentPath, code, lineEnd, nullptr, false, this);
|
|
int ret = FileManager::getInstance().loadFileDataInText(pEdit, contentPath, code, lineEnd, nullptr, false, this);
|
|
- if (ret != 0)
|
|
|
|
|
|
+ if (6 == ret)
|
|
|
|
+ {
|
|
|
|
+ //可能存在乱码,给出警告。还是以编辑模式打开
|
|
|
|
+ ui.statusBar->showMessage(tr("File %1 open success. But Exist Garbled code !"));
|
|
|
|
+ }
|
|
|
|
+ else if (ret != 0)
|
|
{
|
|
{
|
|
ui.statusBar->showMessage(tr("Restore Last Temp File %1 Failed").arg(contentPath));
|
|
ui.statusBar->showMessage(tr("Restore Last Temp File %1 Failed").arg(contentPath));
|
|
}
|
|
}
|
|
@@ -4161,9 +4245,9 @@ bool CCNotePad::reloadTextFileWithCode(CODE_ID code)
|
|
if (docType == TXT_TYPE)
|
|
if (docType == TXT_TYPE)
|
|
{
|
|
{
|
|
int errCode = FileManager::getInstance().loadFileDataInText(pEdit, filePath, code, lineEnd, this, false,this);
|
|
int errCode = FileManager::getInstance().loadFileDataInText(pEdit, filePath, code, lineEnd, this, false,this);
|
|
- if (errCode == 5)
|
|
|
|
|
|
+ if (errCode == 6)
|
|
{
|
|
{
|
|
- //只读模式。暂时什么也不做
|
|
|
|
|
|
+ //有乱码
|
|
}
|
|
}
|
|
else if (errCode != 0)
|
|
else if (errCode != 0)
|
|
{
|
|
{
|
|
@@ -4527,11 +4611,11 @@ bool CCNotePad::openTextFile(QString filePath, bool isCheckHex, CODE_ID code)
|
|
//用户同意以二进制格式打开文件
|
|
//用户同意以二进制格式打开文件
|
|
return openHexFile(filePath);
|
|
return openHexFile(filePath);
|
|
}
|
|
}
|
|
- else if (5 == ret)
|
|
|
|
- {
|
|
|
|
- isReadOnly = true;
|
|
|
|
- //只读模式
|
|
|
|
- }
|
|
|
|
|
|
+ //else if (5 == ret)
|
|
|
|
+ //{
|
|
|
|
+ // isReadOnly = true;
|
|
|
|
+ // //只读模式
|
|
|
|
+ //}
|
|
else if (6 == ret)
|
|
else if (6 == ret)
|
|
{
|
|
{
|
|
//可能存在乱码,给出警告。还是以编辑模式打开
|
|
//可能存在乱码,给出警告。还是以编辑模式打开
|
|
@@ -5150,7 +5234,7 @@ bool CCNotePad::tryRestoreFile(QString filePath)
|
|
bool CCNotePad::openFile(QString filePath, int lineNum)
|
|
bool CCNotePad::openFile(QString filePath, int lineNum)
|
|
{
|
|
{
|
|
s_padTimes++;
|
|
s_padTimes++;
|
|
-
|
|
|
|
|
|
+ //如果是相对路径
|
|
getRegularFilePath(filePath);
|
|
getRegularFilePath(filePath);
|
|
|
|
|
|
QFileInfo fi(filePath);
|
|
QFileInfo fi(filePath);
|
|
@@ -5223,6 +5307,11 @@ void CCNotePad::slot_slectionChanged()
|
|
|
|
|
|
void CCNotePad::slot_actionOpenFile_toggle(bool /*checked*/)
|
|
void CCNotePad::slot_actionOpenFile_toggle(bool /*checked*/)
|
|
{
|
|
{
|
|
|
|
+ if (s_lastOpenDirPath.isEmpty())
|
|
|
|
+ {
|
|
|
|
+ s_lastOpenDirPath = NddSetting::getKeyValueFromDelaySets(LAST_OPEN_DIR);
|
|
|
|
+ }
|
|
|
|
+
|
|
QFileDialog fd(this,QString(), s_lastOpenDirPath);
|
|
QFileDialog fd(this,QString(), s_lastOpenDirPath);
|
|
fd.setFileMode(QFileDialog::ExistingFile);
|
|
fd.setFileMode(QFileDialog::ExistingFile);
|
|
|
|
|
|
@@ -5240,6 +5329,7 @@ void CCNotePad::slot_actionOpenFile_toggle(bool /*checked*/)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+#if 0
|
|
#ifdef _WIN32
|
|
#ifdef _WIN32
|
|
void hide_file(const QString& szFile)
|
|
void hide_file(const QString& szFile)
|
|
{
|
|
{
|
|
@@ -5251,12 +5341,13 @@ void hide_file(const QString& szFile)
|
|
#endif // !UNICODE
|
|
#endif // !UNICODE
|
|
}
|
|
}
|
|
#endif // _WIN32
|
|
#endif // _WIN32
|
|
|
|
+#endif
|
|
|
|
|
|
//bool isBakWrite:是否进行保护写,即先写swap文件,再写源文件。这样可以避免突然断电导致源文件被清空
|
|
//bool isBakWrite:是否进行保护写,即先写swap文件,再写源文件。这样可以避免突然断电导致源文件被清空
|
|
//isBakWrite 是否写保护swp文件,默认true。只有新文件时不需要,因为新文件不存在覆盖写的问题
|
|
//isBakWrite 是否写保护swp文件,默认true。只有新文件时不需要,因为新文件不存在覆盖写的问题
|
|
//isStatic 是否静默:不弹出对话框,在外部批量查找替换文件夹时使用,避免弹窗中断。默认false
|
|
//isStatic 是否静默:不弹出对话框,在外部批量查找替换文件夹时使用,避免弹窗中断。默认false
|
|
//isClearSwpFile:是否回收swp交换文件,在外部批量查找替换文件夹时使用,替换后直接删除swp文件。默认false
|
|
//isClearSwpFile:是否回收swp交换文件,在外部批量查找替换文件夹时使用,替换后直接删除swp文件。默认false
|
|
-bool CCNotePad::saveFile(QString fileName, ScintillaEditView* pEdit, bool isBakWrite, bool isStatic,bool isClearSwpFile)
|
|
|
|
|
|
+bool CCNotePad::saveFile(QString fileName, ScintillaEditView* pEdit, bool isBakWrite, bool isStatic,bool /*isClearSwpFile*/)
|
|
{
|
|
{
|
|
QFile srcfile(fileName);
|
|
QFile srcfile(fileName);
|
|
|
|
|
|
@@ -5390,7 +5481,7 @@ bool CCNotePad::saveFile(QString fileName, ScintillaEditView* pEdit, bool isBak
|
|
bool success = saveWork(swapfile, fileName, true);
|
|
bool success = saveWork(swapfile, fileName, true);
|
|
if (success)
|
|
if (success)
|
|
{
|
|
{
|
|
-#ifdef _WIN32
|
|
|
|
|
|
+#if 0 //不要这个了,windows下无条件删除
|
|
if (!isClearSwpFile)
|
|
if (!isClearSwpFile)
|
|
{
|
|
{
|
|
hide_file(swapFilePath);
|
|
hide_file(swapFilePath);
|
|
@@ -5402,10 +5493,18 @@ bool CCNotePad::saveFile(QString fileName, ScintillaEditView* pEdit, bool isBak
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+#ifdef _WIN32
|
|
|
|
+ //windows下面如果保存成功,则无条件删除swap文件,许多用户反感这个.swap文件存在
|
|
|
|
+ if (success)
|
|
|
|
+ {
|
|
|
|
+ QFile::remove(swapFilePath);
|
|
|
|
+ }
|
|
|
|
+#else
|
|
if (success && isClearSwpFile)
|
|
if (success && isClearSwpFile)
|
|
{
|
|
{
|
|
QFile::remove(swapFilePath);
|
|
QFile::remove(swapFilePath);
|
|
}
|
|
}
|
|
|
|
+#endif
|
|
|
|
|
|
}
|
|
}
|
|
return true;
|
|
return true;
|
|
@@ -6093,6 +6192,8 @@ void CCNotePad::closeFileStatic(int index, QSettings& qs)
|
|
removeWatchFilePath(filePath);
|
|
removeWatchFilePath(filePath);
|
|
pw->deleteLater();
|
|
pw->deleteLater();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
void CCNotePad::closeAllFileStatic()
|
|
void CCNotePad::closeAllFileStatic()
|
|
{
|
|
{
|
|
QString tempFileList = QString("notepad/temp/list");
|
|
QString tempFileList = QString("notepad/temp/list");
|
|
@@ -6253,8 +6354,12 @@ void CCNotePad::closeEvent(QCloseEvent * event)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //保存上次打开目录
|
|
|
|
+ if (!CCNotePad::s_lastOpenDirPath.isEmpty())
|
|
|
|
+ {
|
|
|
|
+ NddSetting::updataKeyValueFromDelaySets(LAST_OPEN_DIR, CCNotePad::s_lastOpenDirPath);
|
|
|
|
+ }
|
|
//保存大小
|
|
//保存大小
|
|
-
|
|
|
|
QByteArray curGeo = saveGeometry();
|
|
QByteArray curGeo = saveGeometry();
|
|
NddSetting::updataKeyByteArrayValue(WIN_POS, curGeo);
|
|
NddSetting::updataKeyByteArrayValue(WIN_POS, curGeo);
|
|
|
|
|
|
@@ -6626,7 +6731,11 @@ void CCNotePad::tailfile(bool isOn, ScintillaEditView* pEdit)
|
|
//这里不能直接更新,而是要发生信号出去。否则跨线程访问,可能发生错误或告警
|
|
//这里不能直接更新,而是要发生信号出去。否则跨线程访问,可能发生错误或告警
|
|
//pEdit->setProperty(Modify_Outside, QVariant(true));
|
|
//pEdit->setProperty(Modify_Outside, QVariant(true));
|
|
//checkRoladFile(pEdit);
|
|
//checkRoladFile(pEdit);
|
|
- emit this->tailFileChange(pEdit);
|
|
|
|
|
|
+ quint64 lastSize = 0;
|
|
|
|
+ quint64 curSize = 0;
|
|
|
|
+
|
|
|
|
+ fileChanges.getDiffFileSize(lastSize,curSize);
|
|
|
|
+ emit this->tailFileChange(pEdit, lastSize, curSize);
|
|
}
|
|
}
|
|
//如果退出监控。这里要注意,一定要是volidate的,否则多线程获取不到该变化
|
|
//如果退出监控。这里要注意,一定要是volidate的,否则多线程获取不到该变化
|
|
//使用了原子变量,效果是一样的,多个线程均可见
|
|
//使用了原子变量,效果是一样的,多个线程均可见
|
|
@@ -6783,15 +6892,21 @@ int CCNotePad::initFindWindow(FindTabIndex type)
|
|
QVariant history = qs.value("keys", "");
|
|
QVariant history = qs.value("keys", "");
|
|
s_findHistroy = history.toStringList();
|
|
s_findHistroy = history.toStringList();
|
|
}
|
|
}
|
|
|
|
+ if (qs.contains("replace"))
|
|
|
|
+ {
|
|
|
|
+ QVariant replaceHistory = qs.value("replace", "");
|
|
|
|
+ s_replaceHistroy = replaceHistory.toStringList();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
pFind->setFindHistory(&s_findHistroy);
|
|
pFind->setFindHistory(&s_findHistroy);
|
|
-
|
|
|
|
|
|
+ pFind->setReplaceHistory(&s_replaceHistroy);
|
|
|
|
+
|
|
pFind->setTabWidget(ui.editTabWidget);
|
|
pFind->setTabWidget(ui.editTabWidget);
|
|
|
|
|
|
if((TXT_TYPE == docType) || (BIG_TEXT_RO_TYPE == docType) || (SUPER_BIG_TEXT_RO_TYPE == docType))
|
|
if((TXT_TYPE == docType) || (BIG_TEXT_RO_TYPE == docType) || (SUPER_BIG_TEXT_RO_TYPE == docType))
|
|
{
|
|
{
|
|
- connect(pFind, &FindWin::sign_findAllInCurDoc, this, &CCNotePad::slot_showFindAllInCurDocResult);
|
|
|
|
|
|
+ //connect(pFind, &FindWin::sign_findAllInCurDoc, this, &CCNotePad::slot_showFindAllInCurDocResult);
|
|
connect(pFind, &FindWin::sign_findAllInOpenDoc, this, &CCNotePad::slot_showfindAllInOpenDocResult);
|
|
connect(pFind, &FindWin::sign_findAllInOpenDoc, this, &CCNotePad::slot_showfindAllInOpenDocResult);
|
|
connect(pFind, &FindWin::sign_replaceSaveFile, this, &CCNotePad::slot_saveFile);
|
|
connect(pFind, &FindWin::sign_replaceSaveFile, this, &CCNotePad::slot_saveFile);
|
|
connect(pFind, &FindWin::sign_clearResult, this, &CCNotePad::slot_clearFindResult);
|
|
connect(pFind, &FindWin::sign_clearResult, this, &CCNotePad::slot_clearFindResult);
|
|
@@ -6893,6 +7008,13 @@ void CCNotePad::slot_saveSearchHistory()
|
|
s_findHistroy = s_findHistroy.mid(0, 15);
|
|
s_findHistroy = s_findHistroy.mid(0, 15);
|
|
}
|
|
}
|
|
qs.setValue("keys", s_findHistroy);
|
|
qs.setValue("keys", s_findHistroy);
|
|
|
|
+
|
|
|
|
+ if (s_replaceHistroy.count() > 15)
|
|
|
|
+ {
|
|
|
|
+ s_replaceHistroy = s_replaceHistroy.mid(0, 15);
|
|
|
|
+ }
|
|
|
|
+ qs.setValue("replace", s_replaceHistroy);
|
|
|
|
+
|
|
qs.sync();
|
|
qs.sync();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -6984,8 +7106,8 @@ void CCNotePad::clearHighlightWord(QString signWord, ScintillaEditView* pEdit)
|
|
delete r;
|
|
delete r;
|
|
curMarkRecord.removeAt(i);
|
|
curMarkRecord.removeAt(i);
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
void CCNotePad::slot_clearWordHighlight()
|
|
void CCNotePad::slot_clearWordHighlight()
|
|
{
|
|
{
|
|
QWidget* pw = ui.editTabWidget->currentWidget();
|
|
QWidget* pw = ui.editTabWidget->currentWidget();
|
|
@@ -7121,7 +7243,9 @@ void CCNotePad::initFindResultDockWin()
|
|
m_dockSelectTreeWin->setAllowedAreas(Qt::LeftDockWidgetArea| Qt::RightDockWidgetArea |Qt::BottomDockWidgetArea);
|
|
m_dockSelectTreeWin->setAllowedAreas(Qt::LeftDockWidgetArea| Qt::RightDockWidgetArea |Qt::BottomDockWidgetArea);
|
|
|
|
|
|
m_pResultWin = new FindResultWin(m_dockSelectTreeWin);
|
|
m_pResultWin = new FindResultWin(m_dockSelectTreeWin);
|
|
- connect(m_pResultWin, &FindResultWin::itemDoubleClicked, this, &CCNotePad::slot_findResultItemDoubleClick);
|
|
|
|
|
|
+ //connect(m_pResultWin, &FindResultWin::itemDoubleClicked, this, &CCNotePad::slot_findResultItemDoubleClick);
|
|
|
|
+ connect(m_pResultWin, &FindResultWin::lineDoubleClicked, this, &CCNotePad::on_findResultlineDoubleClick);
|
|
|
|
+
|
|
connect(m_pResultWin, &FindResultWin::showMsg, this, [this](QString& msg) {
|
|
connect(m_pResultWin, &FindResultWin::showMsg, this, [this](QString& msg) {
|
|
ui.statusBar->showMessage(msg,5000);
|
|
ui.statusBar->showMessage(msg,5000);
|
|
});
|
|
});
|
|
@@ -7235,16 +7359,62 @@ void CCNotePad::slot_findResultItemDoubleClick(const QModelIndex &index)
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+//双击文件leve=2的节点后,显示文件并定位到文件位置中去高亮
|
|
|
|
+void CCNotePad::on_findResultlineDoubleClick(QString* pFilePath, int pos, int end)
|
|
|
|
+{
|
|
|
|
+ auto locationCurrentEdit = [this](QString filePath)->ScintillaEditView* {
|
|
|
|
+
|
|
|
|
+ getRegularFilePath(filePath);
|
|
|
|
+
|
|
|
|
+ ScintillaEditView* pEdit = dynamic_cast<ScintillaEditView*>(ui.editTabWidget->currentWidget());
|
|
|
|
+ if (pEdit != nullptr && (filePath == getFilePathProperty(pEdit)))
|
|
|
|
+ {
|
|
|
|
+ return pEdit;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //不在则遍历插值定位到
|
|
|
|
+ for (int i = 0; i < ui.editTabWidget->count(); ++i)
|
|
|
|
+ {
|
|
|
|
+ pEdit = dynamic_cast<ScintillaEditView*>(ui.editTabWidget->widget(i));
|
|
|
|
+ if (pEdit != nullptr && (filePath == getFilePathProperty(pEdit)))
|
|
|
|
+ {
|
|
|
|
+ ui.editTabWidget->setCurrentIndex(i);
|
|
|
|
+ return pEdit;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //走到这里,说明文档已经关闭,不在当前打开框中
|
|
|
|
+ //还是没有找到,则新建打开文件
|
|
|
|
+ if (openFile(filePath))
|
|
|
|
+ {
|
|
|
|
+ ScintillaEditView* pEdit = dynamic_cast<ScintillaEditView*>(ui.editTabWidget->currentWidget());
|
|
|
|
+ return pEdit;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ui.statusBar->showMessage(tr("file %1 was not exists !").arg(filePath), 5000);
|
|
|
|
+ QApplication::beep();
|
|
|
|
+ return nullptr;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ ScintillaEditView* pCurEdit = locationCurrentEdit(*pFilePath);
|
|
|
|
+ if (pCurEdit != nullptr)
|
|
|
|
+ {
|
|
|
|
+ pCurEdit->execute(SCI_SETSEL, pos, end);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#if 0
|
|
void CCNotePad::slot_showFindAllInCurDocResult(FindRecords* record)
|
|
void CCNotePad::slot_showFindAllInCurDocResult(FindRecords* record)
|
|
{
|
|
{
|
|
initFindResultDockWin();
|
|
initFindResultDockWin();
|
|
|
|
|
|
m_dockSelectTreeWin->setWindowTitle(tr("Find result - %1 hit").arg(record->records.size()));
|
|
m_dockSelectTreeWin->setWindowTitle(tr("Find result - %1 hit").arg(record->records.size()));
|
|
|
|
|
|
- m_pResultWin->appendResultsToShow(record);
|
|
|
|
|
|
+ //m_pResultWin->appendResultsToShow(record);
|
|
|
|
|
|
m_dockSelectTreeWin->show();
|
|
m_dockSelectTreeWin->show();
|
|
}
|
|
}
|
|
|
|
+#endif
|
|
|
|
|
|
void CCNotePad::slot_showfindAllInOpenDocResult(QVector<FindRecords*>* record, int hits, QString whatFind)
|
|
void CCNotePad::slot_showfindAllInOpenDocResult(QVector<FindRecords*>* record, int hits, QString whatFind)
|
|
{
|
|
{
|
|
@@ -7512,11 +7682,11 @@ void CCNotePad::transDocToEncord(CODE_ID destCode)
|
|
//等到文件保存时才执行
|
|
//等到文件保存时才执行
|
|
if (srcCode != newCode)
|
|
if (srcCode != newCode)
|
|
{
|
|
{
|
|
- QVariant editTextCode((int)newCode);
|
|
|
|
- pEdit->setProperty(Edit_Text_Code, editTextCode);
|
|
|
|
|
|
+ setCodeTypeProperty(pEdit, (int)newCode);
|
|
|
|
|
|
- QVariant textChanged(true);
|
|
|
|
- pEdit->setProperty(Edit_Text_Change, textChanged);
|
|
|
|
|
|
+ setTextChangeProperty(pEdit, true);
|
|
|
|
+
|
|
|
|
+ ui.editTabWidget->setTabIcon(ui.editTabWidget->currentIndex(), QIcon(TabNeedSave));
|
|
|
|
|
|
setSaveButtonStatus(true);
|
|
setSaveButtonStatus(true);
|
|
setSaveAllButtonStatus(true);
|
|
setSaveAllButtonStatus(true);
|
|
@@ -7911,15 +8081,15 @@ void CCNotePad::slot_aboutNdd()
|
|
QString title = tr("Notepad-- Version %1").arg(VersionStr);
|
|
QString title = tr("Notepad-- Version %1").arg(VersionStr);
|
|
pWin->setWindowTitle(title);
|
|
pWin->setWindowTitle(title);
|
|
pWin->appendText(title);
|
|
pWin->appendText(title);
|
|
-// int status = NddSetting::getKeyValueFromNumSets(SOFT_STATUS);
|
|
|
|
-// if (1 == status)
|
|
|
|
-// {
|
|
|
|
-// pWin->appendText(tr("Registered Version"));
|
|
|
|
-// }
|
|
|
|
-// else
|
|
|
|
-// {
|
|
|
|
-// pWin->appendText(tr("Free Trial"));
|
|
|
|
-// }
|
|
|
|
|
|
+ int status = NddSetting::getKeyValueFromNumSets(SOFT_STATUS);
|
|
|
|
+ if (1 == status)
|
|
|
|
+ {
|
|
|
|
+ pWin->appendText(tr("Registered Version"));
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ pWin->appendText(tr("Free Trial"));
|
|
|
|
+ }
|
|
pWin->show();
|
|
pWin->show();
|
|
registerEscKeyShort(pWin);
|
|
registerEscKeyShort(pWin);
|
|
#ifdef uos
|
|
#ifdef uos
|
|
@@ -7990,6 +8160,11 @@ void CCNotePad::dropEvent(QDropEvent* e)
|
|
e->accept();
|
|
e->accept();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void CCNotePad::dragLeaveEvent(QDragLeaveEvent* event)
|
|
|
|
+{
|
|
|
|
+ qDebug() << "drag level";
|
|
|
|
+}
|
|
|
|
+
|
|
//目前只有一个Tabwidget的双击事件。
|
|
//目前只有一个Tabwidget的双击事件。
|
|
bool CCNotePad::eventFilter(QObject * watched, QEvent * event)
|
|
bool CCNotePad::eventFilter(QObject * watched, QEvent * event)
|
|
{
|
|
{
|
|
@@ -8481,7 +8656,7 @@ bool CCNotePad::restoreDirtyExistFile(QString& filePath, QString& tempFilePath)
|
|
if (!tempFilePath.isEmpty())
|
|
if (!tempFilePath.isEmpty())
|
|
{
|
|
{
|
|
int ret = FileManager::getInstance().loadFileDataInText(pEdit, tempFilePath, code, lineEnd, nullptr, false,this);
|
|
int ret = FileManager::getInstance().loadFileDataInText(pEdit, tempFilePath, code, lineEnd, nullptr, false,this);
|
|
- if (ret != 0)
|
|
|
|
|
|
+ if ((ret != 6) && (ret != 0))
|
|
{
|
|
{
|
|
isLoadOrgin = true;
|
|
isLoadOrgin = true;
|
|
ui.statusBar->showMessage(tr("Restore Last Temp File %1 Failed").arg(tempFilePath), 5000);
|
|
ui.statusBar->showMessage(tr("Restore Last Temp File %1 Failed").arg(tempFilePath), 5000);
|
|
@@ -8511,10 +8686,14 @@ bool CCNotePad::restoreDirtyExistFile(QString& filePath, QString& tempFilePath)
|
|
//用户同意以二进制格式打开文件
|
|
//用户同意以二进制格式打开文件
|
|
return openHexFile(filePath);
|
|
return openHexFile(filePath);
|
|
}
|
|
}
|
|
- else if (5 == ret)
|
|
|
|
|
|
+ //else if (5 == ret)
|
|
|
|
+ //{
|
|
|
|
+ // isReadOnly = true;
|
|
|
|
+ // //只读模式
|
|
|
|
+ //}
|
|
|
|
+ else if (6 == ret)
|
|
{
|
|
{
|
|
- isReadOnly = true;
|
|
|
|
- //只读模式
|
|
|
|
|
|
+ //存在乱码,还是打开
|
|
}
|
|
}
|
|
else if (0 != ret)
|
|
else if (0 != ret)
|
|
{
|
|
{
|
|
@@ -9606,6 +9785,46 @@ void CCNotePad::on_quitActiveWindow()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+#if 0
|
|
|
|
+//修改主题颜色//暂时不开始,发现MAC下有不开启深色的配置
|
|
|
|
+void CCNotePad::changeAppFontColor(QColor color)
|
|
|
|
+{
|
|
|
|
+ //把存在的界面都关闭。发现如果不关闭,颜色不会更新
|
|
|
|
+
|
|
|
|
+ if (!m_pFindWin.isNull())
|
|
|
|
+ {
|
|
|
|
+ QByteArray curGeo = m_pFindWin->saveGeometry();
|
|
|
|
+ NddSetting::updataKeyByteArrayValue(FINDWINSIZE, curGeo);
|
|
|
|
+
|
|
|
|
+ m_pFindWin.data()->deleteLater();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!m_pHexGotoWin.isNull())
|
|
|
|
+ {
|
|
|
|
+ m_pHexGotoWin.data()->close();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!m_columnEditWin.isNull())
|
|
|
|
+ {
|
|
|
|
+ m_columnEditWin.data()->close();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //filelistwin还存在
|
|
|
|
+ if (!m_dockFileListWin.isNull())
|
|
|
|
+ {
|
|
|
|
+ NddSetting::updataKeyValueFromNumSets(FILELISTSHOW, 1);
|
|
|
|
+ m_dockFileListWin.data()->close();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (m_dockSelectTreeWin != nullptr)
|
|
|
|
+ {
|
|
|
|
+ m_dockSelectTreeWin->deleteLater();
|
|
|
|
+ m_dockSelectTreeWin = nullptr;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+#endif
|
|
|
|
+
|
|
void CCNotePad::on_md5hash()
|
|
void CCNotePad::on_md5hash()
|
|
{
|
|
{
|
|
Md5hash* pWin = new Md5hash(this);
|
|
Md5hash* pWin = new Md5hash(this);
|
|
@@ -9613,3 +9832,70 @@ void CCNotePad::on_md5hash()
|
|
pWin->setAttribute(Qt::WA_DeleteOnClose);
|
|
pWin->setAttribute(Qt::WA_DeleteOnClose);
|
|
pWin->show();
|
|
pWin->show();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+#ifdef NO_PLUGIN
|
|
|
|
+//插件中调用主程序的功能。
|
|
|
|
+//cmdId 执行什么动作,一定固定后,主程序不能随便修改,否则会引发兼容性问题。
|
|
|
|
+bool CCNotePad::pluginInvoke(int cmdId, void* data)
|
|
|
|
+{
|
|
|
|
+ bool ret = false;
|
|
|
|
+ switch (cmdId)
|
|
|
|
+ {
|
|
|
|
+ case 1:
|
|
|
|
+ {
|
|
|
|
+ //新建一个文件。
|
|
|
|
+ slot_actionNewFile_toggle(true);
|
|
|
|
+
|
|
|
|
+ //默认不需要。
|
|
|
|
+ if (data != nullptr)
|
|
|
|
+ {
|
|
|
|
+ QVariant* pVar = (QVariant*)data;
|
|
|
|
+ //回传回去新建文件的名称
|
|
|
|
+ ScintillaEditView* pw = getCurEditView();
|
|
|
|
+ if (pw != nullptr)
|
|
|
|
+ {
|
|
|
|
+ pVar->setValue(getFilePathProperty(pw));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ ret = true;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 2:
|
|
|
|
+ {
|
|
|
|
+ //设定当前编辑器的语言。0 js 1 json
|
|
|
|
+ int lang = *((int*)data);
|
|
|
|
+
|
|
|
|
+ LangType langs = ((lang == 0) ? L_JAVASCRIPT : L_JSON);
|
|
|
|
+
|
|
|
|
+ ScintillaEditView* pEdit = getCurEditView();
|
|
|
|
+ if (pEdit != nullptr)
|
|
|
|
+ {
|
|
|
|
+ QsciLexer* curLexer = pEdit->lexer();
|
|
|
|
+ if (curLexer == nullptr)
|
|
|
|
+ {
|
|
|
|
+ //设定为目标语法
|
|
|
|
+ QsciLexer* lexer = ScintillaEditView::createLexer(langs);
|
|
|
|
+ pEdit->setLexer(lexer);
|
|
|
|
+ }
|
|
|
|
+ else if (curLexer->lexerId() != langs)
|
|
|
|
+ {
|
|
|
|
+ pEdit->setLexer(nullptr);
|
|
|
|
+ delete curLexer;
|
|
|
|
+ curLexer = nullptr;
|
|
|
|
+
|
|
|
|
+ QsciLexer* lexer = ScintillaEditView::createLexer(langs);
|
|
|
|
+ pEdit->setLexer(lexer);
|
|
|
|
+ }
|
|
|
|
+ syncCurDocLexerToMenu(pEdit);
|
|
|
|
+ }
|
|
|
|
+ ret = true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ default:
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ return ret;
|
|
|
|
+}
|
|
|
|
+#endif
|