forked from qt-creator/qt-creator
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:
@@ -1816,22 +1816,22 @@ void TextEditorWidgetPrivate::clearCurrentSuggestion()
|
||||
void TextEditorWidget::selectEncoding()
|
||||
{
|
||||
TextDocument *doc = d->m_document.data();
|
||||
CodecSelector codecSelector(this, doc);
|
||||
|
||||
switch (codecSelector.exec()) {
|
||||
case CodecSelector::Reload: {
|
||||
const CodecSelectorResult result = Core::askForCodec(Core::ICore::dialogParent(), doc);
|
||||
switch (result.action) {
|
||||
case Core::CodecSelectorResult::Reload: {
|
||||
QString errorString;
|
||||
if (!doc->reload(&errorString, codecSelector.selectedCodec())) {
|
||||
if (!doc->reload(&errorString, result.codec)) {
|
||||
QMessageBox::critical(this, Tr::tr("File Error"), errorString);
|
||||
break;
|
||||
}
|
||||
break; }
|
||||
case CodecSelector::Save:
|
||||
doc->setCodec(codecSelector.selectedCodec());
|
||||
break;
|
||||
}
|
||||
case Core::CodecSelectorResult::Save:
|
||||
doc->setCodec(result.codec);
|
||||
EditorManager::saveDocument(textDocument());
|
||||
updateTextCodecLabel();
|
||||
break;
|
||||
case CodecSelector::Cancel:
|
||||
case Core::CodecSelectorResult::Cancel:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user