tidy signal handling

This commit is contained in:
2026-02-01 19:37:46 +08:00
parent ed2f047452
commit 7c79abc9c7
3 changed files with 1 additions and 14 deletions

View File

@@ -18,7 +18,7 @@ int main(int argc, char *argv[])
KLocalizedString::setApplicationDomain(QByteArrayLiteral("pineapple-notepad"));
KAboutData aboutData(QStringLiteral("pineapple-notepad"),
"Pineapple Notepad(迫真)",
"Pineapple Notepad",
QStringLiteral("0.1"),
"A Scintilla-based Text Editor",
KAboutLicense::Unknown,

View File

@@ -70,9 +70,6 @@ int TabWidget::openDocument(const QString &filePath)
SciEdit *editor = createEditor();
m_editors[docId] = editor;
// 临时断开信号连接避免setText触发textChanged导致文档被标记为已修改
disconnectEditorSignals(editor);
// 设置编辑器内容
QString content = m_documentManager->getDocumentContent(docId);
const QByteArray contentBytes = content.toUtf8();
@@ -243,7 +240,6 @@ bool TabWidget::closeTab(int index)
// 清理编辑器和文档
if (m_editors.contains(docId)) {
SciEdit *editor = m_editors[docId];
disconnectEditorSignals(editor);
m_editors.remove(docId);
}
@@ -435,11 +431,3 @@ void TabWidget::connectEditorSignals(SciEdit *editor)
connect(editor, &ScintillaEditBase::savePointChanged, this, &TabWidget::onEditorSavePointChanged);
}
}
void TabWidget::disconnectEditorSignals(SciEdit *editor)
{
if (editor) {
disconnect(editor, &SciEdit::textChanged, this, &TabWidget::onEditorTextChanged);
disconnect(editor, &ScintillaEditBase::savePointChanged, this, &TabWidget::onEditorSavePointChanged);
}
}

View File

@@ -54,5 +54,4 @@ private:
SciEdit *createEditor();
void updateTabTitle(int tabIndex);
void connectEditorSignals(SciEdit *editor);
void disconnectEditorSignals(SciEdit *editor);
};