diff --git a/solid-device-automounter/kcm/DeviceAutomounterKCM.h b/solid-device-automounter/kcm/DeviceAutomounterKCM.h --- a/solid-device-automounter/kcm/DeviceAutomounterKCM.h +++ b/solid-device-automounter/kcm/DeviceAutomounterKCM.h @@ -26,6 +26,7 @@ #include "ui_DeviceAutomounterKCM.h" class DeviceModel; +class AutomounterSettings; class DeviceAutomounterKCM : public KCModule, public Ui::DeviceAutomounterKCM { @@ -40,16 +41,14 @@ void save() override; private slots: - void enabledChanged(); void updateForgetDeviceButton(); void forgetSelectedDevices(); private: void saveLayout(); void loadLayout(); DeviceModel *m_devices; - }; #endif diff --git a/solid-device-automounter/kcm/DeviceAutomounterKCM.cpp b/solid-device-automounter/kcm/DeviceAutomounterKCM.cpp --- a/solid-device-automounter/kcm/DeviceAutomounterKCM.cpp +++ b/solid-device-automounter/kcm/DeviceAutomounterKCM.cpp @@ -41,6 +41,7 @@ DeviceAutomounterKCM::DeviceAutomounterKCM(QWidget *parent, const QVariantList &args) : KCModule(parent, args)//DeviceAutomounterKCMFactory::componentData(), parent) + , m_devices(new DeviceModel(this)) { KAboutData *about = new KAboutData(QStringLiteral("kcm_device_automounter"), i18n("Device Automounter"), @@ -54,26 +55,21 @@ setAboutData(about); setupUi(this); - m_devices = new DeviceModel(this); + addConfig(AutomounterSettings::self(), this); + deviceView->setModel(m_devices); deviceView->header()->setSectionResizeMode(QHeaderView::ResizeToContents); deviceView->header()->setSectionResizeMode(0, QHeaderView::Stretch); auto emitChanged = [this] { - m_devices->setAutomaticMountOnLogin(automountOnLogin->isChecked()); - m_devices->setAutomaticMountOnPlugin(automountOnPlugin->isChecked()); + m_devices->setAutomaticMountOnLogin(kcfg_AutomountOnLogin->isChecked()); + m_devices->setAutomaticMountOnPlugin(kcfg_AutomountOnPlugin->isChecked()); emit markAsChanged(); }; - connect(automountOnLogin, &QCheckBox::stateChanged, this, emitChanged); - connect(automountOnPlugin, &QCheckBox::stateChanged, this, emitChanged); - connect(automountEnabled, &QCheckBox::stateChanged, this, emitChanged); - connect(automountUnknownDevices, &QCheckBox::stateChanged, this, emitChanged); connect(m_devices, &DeviceModel::dataChanged, this, emitChanged); - connect(automountEnabled, &QCheckBox::stateChanged, this, &DeviceAutomounterKCM::enabledChanged); - connect(deviceView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &DeviceAutomounterKCM::updateForgetDeviceButton); connect(forgetDevice, &QAbstractButton::clicked, this, &DeviceAutomounterKCM::forgetSelectedDevices); @@ -113,35 +109,26 @@ emit markAsChanged(); } -void DeviceAutomounterKCM::enabledChanged() -{ - automountOnLogin->setEnabled(automountEnabled->isChecked()); - automountOnPlugin->setEnabled(automountEnabled->isChecked()); - automountUnknownDevices->setEnabled(automountEnabled->isChecked()); - deviceView->setEnabled(automountEnabled->isChecked()); -} - void DeviceAutomounterKCM::load() { - automountEnabled->setChecked(AutomounterSettings::automountEnabled()); - automountUnknownDevices->setChecked(AutomounterSettings::automountUnknownDevices()); - automountOnLogin->setChecked(AutomounterSettings::automountOnLogin()); - automountOnPlugin->setChecked(AutomounterSettings::automountOnPlugin()); + KCModule::load(); + + bool automountEnabled = AutomounterSettings::self()->automountEnabled(); + + kcfg_AutomountUnknownDevices->setEnabled(automountEnabled); + kcfg_AutomountOnLogin->setEnabled(automountEnabled); + kcfg_AutomountOnPlugin->setEnabled(automountEnabled); m_devices->reload(); - enabledChanged(); loadLayout(); } void DeviceAutomounterKCM::save() { + KCModule::save(); saveLayout(); - const bool enabled = automountEnabled->isChecked(); - AutomounterSettings::setAutomountEnabled(enabled); - AutomounterSettings::setAutomountUnknownDevices(automountUnknownDevices->isChecked()); - AutomounterSettings::setAutomountOnLogin(automountOnLogin->isChecked()); - AutomounterSettings::setAutomountOnPlugin(automountOnPlugin->isChecked()); + const bool enabled = kcfg_AutomountEnabled->isChecked(); QStringList validDevices; for (int i = 0; i < m_devices->rowCount(); ++i) { diff --git a/solid-device-automounter/kcm/DeviceAutomounterKCM.ui b/solid-device-automounter/kcm/DeviceAutomounterKCM.ui --- a/solid-device-automounter/kcm/DeviceAutomounterKCM.ui +++ b/solid-device-automounter/kcm/DeviceAutomounterKCM.ui @@ -12,7 +12,7 @@ - + When this is unchecked, no device automounting of any kind will happen, regardless of anything selected in the "Device Overrides" section. @@ -40,7 +40,7 @@ - + When this is checked, only remembered devices will be automatically mounted. A device is 'remembered' if it has ever been mounted before. For instance, plugging in a USB media player to charge is not sufficient to 'remember' it - if the files are not accessed, it will not be automatically mounted the next time it is seen. Once they have been accessed, however, the device's contents will be automatically made available to the system. @@ -50,22 +50,22 @@ - + If any removable storage devices are connected to your system when you login to your desktop, their contents will automatically be made available to your system for other programs to read. - Mount all removable media at login + Automatically mount all removable media at login - + When this is checked, the contents of any storage device will automatically be made available to the system when it is plugged in or attached. - Automatically mount removable media when attached + Automatically mount all removable media when attached @@ -149,5 +149,70 @@ - + + + kcfg_AutomountEnabled + toggled(bool) + kcfg_AutomountOnLogin + setEnabled(bool) + + + 307 + 20 + + + 308 + 81 + + + + + kcfg_AutomountEnabled + toggled(bool) + kcfg_AutomountOnPlugin + setEnabled(bool) + + + 307 + 20 + + + 308 + 111 + + + + + kcfg_AutomountEnabled + toggled(bool) + kcfg_AutomountUnknownDevices + setEnabled(bool) + + + 307 + 20 + + + 308 + 51 + + + + + kcfg_AutomountEnabled + toggled(bool) + deviceView + setEnabled(bool) + + + 307 + 20 + + + 307 + 244 + + + +