diff --git a/kf5/src/smbshareplugin.cpp b/kf5/src/smbshareplugin.cpp index c3ad936..5a03f13 100644 --- a/kf5/src/smbshareplugin.cpp +++ b/kf5/src/smbshareplugin.cpp @@ -150,8 +150,14 @@ SmbSharePlugin::SmbSharePlugin(QObject *parent, const QVariantList &args) // Load existing share info loadCurrentShare(); - // Initial UI state - onShareToggled(m_shareCheckBox->isChecked()); + // Initial UI state — apply enabled/disabled without marking dirty + m_nameEdit->setEnabled(m_shareCheckBox->isChecked()); + m_guestCheckBox->setEnabled(m_shareCheckBox->isChecked()); + m_usersWidget->setEnabled(m_shareCheckBox->isChecked()); + + // Reset dirty after all initial setup so opening the dialog doesn't + // trigger applyChanges() on this or other plugins. + setDirty(false); // Add the page as a tab properties->addPage(m_page, i18n("Share")); @@ -228,9 +234,15 @@ void SmbSharePlugin::loadCurrentShare() const int colonPos = entry.lastIndexOf(QLatin1Char(':')); if (colonPos < 0) continue; - const QString name = entry.left(colonPos); + QString name = entry.left(colonPos); const QString perm = entry.mid(colonPos + 1); + // Strip Samba domain/authority prefix, e.g. "DEBIANTERMINAL\duffy" + // or "Unix User\filiz" -> "duffy" / "filiz". + const int backslashPos = name.lastIndexOf(QLatin1Char('\\')); + if (backslashPos >= 0) + name = name.mid(backslashPos + 1); + for (auto &up : m_userPerms) { if (up.username.compare(name, Qt::CaseInsensitive) == 0) { up.combo->setCurrentIndex(indexForAcl(perm)); diff --git a/kf6/src/smbshareplugin.cpp b/kf6/src/smbshareplugin.cpp index c3ad936..5a03f13 100644 --- a/kf6/src/smbshareplugin.cpp +++ b/kf6/src/smbshareplugin.cpp @@ -150,8 +150,14 @@ SmbSharePlugin::SmbSharePlugin(QObject *parent, const QVariantList &args) // Load existing share info loadCurrentShare(); - // Initial UI state - onShareToggled(m_shareCheckBox->isChecked()); + // Initial UI state — apply enabled/disabled without marking dirty + m_nameEdit->setEnabled(m_shareCheckBox->isChecked()); + m_guestCheckBox->setEnabled(m_shareCheckBox->isChecked()); + m_usersWidget->setEnabled(m_shareCheckBox->isChecked()); + + // Reset dirty after all initial setup so opening the dialog doesn't + // trigger applyChanges() on this or other plugins. + setDirty(false); // Add the page as a tab properties->addPage(m_page, i18n("Share")); @@ -228,9 +234,15 @@ void SmbSharePlugin::loadCurrentShare() const int colonPos = entry.lastIndexOf(QLatin1Char(':')); if (colonPos < 0) continue; - const QString name = entry.left(colonPos); + QString name = entry.left(colonPos); const QString perm = entry.mid(colonPos + 1); + // Strip Samba domain/authority prefix, e.g. "DEBIANTERMINAL\duffy" + // or "Unix User\filiz" -> "duffy" / "filiz". + const int backslashPos = name.lastIndexOf(QLatin1Char('\\')); + if (backslashPos >= 0) + name = name.mid(backslashPos + 1); + for (auto &up : m_userPerms) { if (up.username.compare(name, Qt::CaseInsensitive) == 0) { up.combo->setCurrentIndex(indexForAcl(perm));