fix: dont ask when closing if file is not edited
This commit is contained in:
@ -42,6 +42,9 @@ int TabWidget::newDocument()
|
|||||||
SciEdit *editor = createEditor();
|
SciEdit *editor = createEditor();
|
||||||
m_editors[docId] = editor;
|
m_editors[docId] = editor;
|
||||||
|
|
||||||
|
// 连接信号
|
||||||
|
connectEditorSignals(editor);
|
||||||
|
|
||||||
QString title = m_documentManager->getDocumentTitle(docId);
|
QString title = m_documentManager->getDocumentTitle(docId);
|
||||||
int tabIndex = addTab(editor, title);
|
int tabIndex = addTab(editor, title);
|
||||||
|
|
||||||
@ -64,10 +67,16 @@ int TabWidget::openDocument(const QString &filePath)
|
|||||||
SciEdit *editor = createEditor();
|
SciEdit *editor = createEditor();
|
||||||
m_editors[docId] = editor;
|
m_editors[docId] = editor;
|
||||||
|
|
||||||
|
// 临时断开信号连接,避免setText触发textChanged导致文档被标记为已修改
|
||||||
|
disconnectEditorSignals(editor);
|
||||||
|
|
||||||
// 设置编辑器内容
|
// 设置编辑器内容
|
||||||
QString content = m_documentManager->getDocumentContent(docId);
|
QString content = m_documentManager->getDocumentContent(docId);
|
||||||
editor->setText(content.toUtf8().constData());
|
editor->setText(content.toUtf8().constData());
|
||||||
|
|
||||||
|
// 重新连接信号
|
||||||
|
connectEditorSignals(editor);
|
||||||
|
|
||||||
QString title = m_documentManager->getDocumentTitle(docId);
|
QString title = m_documentManager->getDocumentTitle(docId);
|
||||||
int tabIndex = addTab(editor, title);
|
int tabIndex = addTab(editor, title);
|
||||||
|
|
||||||
@ -340,7 +349,6 @@ void TabWidget::onEditorTextChanged()
|
|||||||
SciEdit *TabWidget::createEditor()
|
SciEdit *TabWidget::createEditor()
|
||||||
{
|
{
|
||||||
SciEdit *editor = new SciEdit(this);
|
SciEdit *editor = new SciEdit(this);
|
||||||
connectEditorSignals(editor);
|
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user