CodecSelector: Hide dialog class behind function

It isn't necessary to export the class (which would then best have a d-
pointer etc). Just provide a function that asks the user for a codec and
returns their decision. This makes the whole dialog an implementation
detail.

Change-Id: I7d574561cbe7f079a6d383ba65ba70f6868bbf05
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Eike Ziller
2024-01-24 09:59:52 +01:00
parent f40c18784b
commit e1da48bf86
4 changed files with 64 additions and 52 deletions

View File

@@ -311,17 +311,17 @@ Core::IDocument::OpenResult DiffEditorDocument::open(QString *errorString, const
bool DiffEditorDocument::selectEncoding()
{
Core::CodecSelector codecSelector(Core::ICore::dialogParent(), this);
switch (codecSelector.exec()) {
case Core::CodecSelector::Reload: {
setCodec(codecSelector.selectedCodec());
const CodecSelectorResult result = askForCodec(Core::ICore::dialogParent(), this);
switch (result.action) {
case CodecSelectorResult::Reload: {
setCodec(result.codec);
QString errorMessage;
return reload(&errorMessage, Core::IDocument::FlagReload, Core::IDocument::TypeContents);
}
case Core::CodecSelector::Save:
setCodec(codecSelector.selectedCodec());
case CodecSelectorResult::Save:
setCodec(result.codec);
return Core::EditorManager::saveDocument(this);
case Core::CodecSelector::Cancel:
case CodecSelectorResult::Cancel:
break;
}
return false;