Commit 83b42833 authored by Méven Car's avatar Méven Car
Browse files

[KCM/Activity] Make default button work, modernize code

Test Plan:
kcmshell5 activities
Default button states follows those of the privacy and switching tabs

Reviewers: #plasma, ervin

Reviewed By: ervin

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D26289
parent e9d1e940
......@@ -47,15 +47,26 @@ MainConfigurationWidget::MainConfigurationWidget(QWidget *parent, QVariantList a
d->tabs->insertTab(1, d->tabSwitching = new SwitchingTab(d->tabs), i18n("Switching"));
d->tabs->insertTab(2, d->tabPrivacy = new PrivacyTab(d->tabs), i18n("Privacy"));
connect(d->tabActivities, SIGNAL(changed()), this, SLOT(changed()));
connect(d->tabSwitching, SIGNAL(changed()), this, SLOT(changed()));
connect(d->tabPrivacy, SIGNAL(changed()), this, SLOT(changed()));
connect(d->tabActivities, &ActivitiesTab::changed, this, &MainConfigurationWidget::onChanged);
connect(d->tabSwitching, &SwitchingTab::changed, this, &MainConfigurationWidget::onChanged);
connect(d->tabPrivacy, &PrivacyTab::changed, this, &MainConfigurationWidget::onChanged);
}
MainConfigurationWidget::~MainConfigurationWidget()
{
}
void MainConfigurationWidget::checkDefault()
{
defaulted(d->tabSwitching->isDefault() && d->tabPrivacy->isDefault());
}
void MainConfigurationWidget::onChanged()
{
checkDefault();
markAsChanged();
}
void MainConfigurationWidget::defaults()
{
d->tabActivities->defaults();
......@@ -68,6 +79,8 @@ void MainConfigurationWidget::load()
d->tabActivities->load();
d->tabPrivacy->load();
d->tabSwitching->load();
checkDefault();
}
void MainConfigurationWidget::save()
......
......@@ -42,6 +42,12 @@ public Q_SLOTS:
void load() override;
void save() override;
private Q_SLOTS:
void onChanged();
private:
void checkDefault();
private:
D_PTR;
};
......
......@@ -116,12 +116,6 @@ PrivacyTab::PrivacyTab(QWidget *parent)
connect(d->radioRememberSpecificApplications, &QAbstractButton::toggled,
d->blacklistedApplicationsModel, &BlacklistedApplicationsModel::setEnabled);
connect(d->radioRememberSpecificApplications, &QAbstractButton::toggled,
d->viewBlacklistedApplicationsContainer, &QWidget::setEnabled);
connect(d->radioRememberSpecificApplications, &QAbstractButton::toggled,
d->checkBlacklistAllNotOnList, &QWidget::setEnabled);
connect(d->checkBlacklistAllNotOnList, &QAbstractButton::toggled, this, &PrivacyTab::changed);
defaults();
......@@ -137,6 +131,13 @@ PrivacyTab::~PrivacyTab()
{
}
bool PrivacyTab::isDefault()
{
return d->radioRememberAllApplications->isChecked() &&
d->spinKeepHistory->value() == d->pluginConfig->defaultKeepHistoryForValue() &&
d->checkBlacklistAllNotOnList->isChecked() == d->pluginConfig->defaultBlockedByDefaultValue();
}
void PrivacyTab::defaults()
{
d->blacklistedApplicationsModel->defaults();
......
......@@ -34,6 +34,8 @@ public:
explicit PrivacyTab(QWidget *parent);
~PrivacyTab() override;
bool isDefault();
public Q_SLOTS:
void defaults();
void load();
......
......@@ -39,12 +39,13 @@ public:
KActivities::Consumer activities;
void createAction(const QString &actionName, const QString &actionText,
const QList<QKeySequence> &sequence)
const QList<QKeySequence> &defaultSequence)
{
auto action = mainActionCollection->addAction(actionName);
action->setProperty("isConfigurationAction", true);
action->setText(actionText);
KGlobalAccel::self()->setShortcut(action, sequence);
KGlobalAccel::self()->setShortcut(action, defaultSequence);
KGlobalAccel::self()->setDefaultShortcut(action, defaultSequence);
}
Private()
......@@ -86,6 +87,11 @@ SwitchingTab::~SwitchingTab()
{
}
bool SwitchingTab::isDefault()
{
return !d->checkRememberVirtualDesktop->isChecked();
}
void SwitchingTab::shortcutChanged(const QKeySequence &sequence)
{
QString actionName = sender()
......
......@@ -36,6 +36,8 @@ public:
explicit SwitchingTab(QWidget *parent);
~SwitchingTab() override;
bool isDefault();
public Q_SLOTS:
void defaults();
void load();
......
......@@ -122,5 +122,38 @@
</customwidget>
</customwidgets>
<resources/>
<connections/>
<connections>
<connection>
<sender>radioRememberSpecificApplications</sender>
<signal>toggled(bool)</signal>
<receiver>viewBlacklistedApplicationsContainer</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>352</x>
<y>167</y>
</hint>
<hint type="destinationlabel">
<x>249</x>
<y>363</y>
</hint>
</hints>
</connection>
<connection>
<sender>radioRememberSpecificApplications</sender>
<signal>toggled(bool)</signal>
<receiver>checkBlacklistAllNotOnList</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>352</x>
<y>167</y>
</hint>
<hint type="destinationlabel">
<x>252</x>
<y>481</y>
</hint>
</hints>
</connection>
</connections>
</ui>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment