MCPcopy Create free account
hub / github.com/KDE/kdevelop / rememberDefaultChoice

Method rememberDefaultChoice

plugins/openwith/openwithplugin.cpp:403–422  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

401}
402
403void OpenWithPlugin::rememberDefaultChoice(const FileOpener& opener, const QString& name)
404{
405 if (m_defaultOpener.isValid() && opener == m_defaultOpener) {
406 return;
407 }
408
409 const auto setDefault = KMessageBox::questionTwoActions(
410 qApp->activeWindow(),
411 i18nc("%1: mime type name, %2: app/part name", "Do you want to open all '%1' files by default with %2?",
412 m_mimeType, name),
413 i18nc("@title:window", "Set as Default?"),
414 KGuiItem(i18nc("@action:button", "Set as Default"), QStringLiteral("dialog-ok")),
415 KGuiItem(i18nc("@action:button", "Do Not Set"), QStringLiteral("dialog-cancel")),
416 QStringLiteral("OpenWith-%1").arg(m_mimeType));
417
418 if (setDefault == KMessageBox::PrimaryAction) {
419 m_defaultOpener = opener;
420 defaultsConfig().writeEntry(m_mimeType, m_defaultOpener.toConfigEntryValue());
421 }
422}
423
424QMimeType OpenWithPlugin::updateMimeTypeForUrls()
425{

Callers

nothing calls this directly

Calls 4

defaultsConfigFunction · 0.85
writeEntryMethod · 0.80
toConfigEntryValueMethod · 0.80
isValidMethod · 0.45

Tested by

no test coverage detected