KCM KWin Manage default Highlight indicator for settings not handled by KCModule
For the following KCM : * KWin Options * KWin Screen Edges * KWin Tabbox KCModule introduce an indicator to show which settings have changed from default value. Unfortunately some KCM have settings' states which are not managed automatically by the KCModule thus we have to handle it manually. see https://invent.kde.org/frameworks/kconfigwidgets/-/merge_requests/9
This commit is contained in:
parent
30b516eceb
commit
99bed106bf
9 changed files with 118 additions and 5 deletions
|
@ -39,6 +39,11 @@
|
|||
#define FOCUS_UNDER_MOUSE 4
|
||||
#define FOCUS_STRICTLY_UNDER_MOUSE 5
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr int defaultFocusPolicyIndex = CLICK_TO_FOCUS;
|
||||
}
|
||||
|
||||
KWinFocusConfigForm::KWinFocusConfigForm(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
|
@ -60,6 +65,8 @@ void KFocusConfig::initialize(KWinOptionsSettings *settings)
|
|||
addConfig(m_settings, this);
|
||||
|
||||
connect(m_ui->windowFocusPolicy, qOverload<int>(&QComboBox::currentIndexChanged), this, &KFocusConfig::focusPolicyChanged);
|
||||
connect(m_ui->windowFocusPolicy, qOverload<int>(&QComboBox::currentIndexChanged), this, &KFocusConfig::updateDefaultIndicator);
|
||||
connect(this, SIGNAL(defaultsIndicatorsVisibleChanged(bool)), this, SLOT(updateDefaultIndicator()));
|
||||
|
||||
connect(qApp, &QGuiApplication::screenAdded, this, &KFocusConfig::updateMultiScreen);
|
||||
connect(qApp, &QGuiApplication::screenRemoved, this, &KFocusConfig::updateMultiScreen);
|
||||
|
@ -75,6 +82,13 @@ void KFocusConfig::updateMultiScreen()
|
|||
m_ui->kcfg_SeparateScreenFocus->setVisible(QApplication::screens().count() > 1);
|
||||
}
|
||||
|
||||
void KFocusConfig::updateDefaultIndicator()
|
||||
{
|
||||
const bool isDefault = m_ui->windowFocusPolicy->currentIndex() == defaultFocusPolicyIndex;
|
||||
m_ui->windowFocusPolicy->setProperty("_kde_highlight_neutral", defaultsIndicatorsVisible() && !isDefault);
|
||||
m_ui->windowFocusPolicy->update();
|
||||
}
|
||||
|
||||
void KFocusConfig::focusPolicyChanged()
|
||||
{
|
||||
int selectedFocusPolicy = 0;
|
||||
|
@ -115,7 +129,7 @@ void KFocusConfig::focusPolicyChanged()
|
|||
unmanagedWidgetChangeState(changed);
|
||||
emit unmanagedWidgetStateChanged(changed);
|
||||
|
||||
const bool isDefault = focusPolicy == CLICK_TO_FOCUS;
|
||||
const bool isDefault = focusPolicy == defaultFocusPolicyIndex;
|
||||
unmanagedWidgetDefaultState(isDefault);
|
||||
emit unmanagedWidgetDefaulted(isDefault);
|
||||
|
||||
|
@ -206,7 +220,7 @@ void KFocusConfig::save(void)
|
|||
void KFocusConfig::defaults()
|
||||
{
|
||||
KCModule::defaults();
|
||||
m_ui->windowFocusPolicy->setCurrentIndex(CLICK_TO_FOCUS);
|
||||
m_ui->windowFocusPolicy->setCurrentIndex(defaultFocusPolicyIndex);
|
||||
}
|
||||
|
||||
KWinAdvancedConfigForm::KWinAdvancedConfigForm(QWidget* parent)
|
||||
|
|
|
@ -77,6 +77,7 @@ protected:
|
|||
private Q_SLOTS:
|
||||
void focusPolicyChanged();
|
||||
void updateMultiScreen();
|
||||
void updateDefaultIndicator();
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ KWinScreenEdgesConfigForm::KWinScreenEdgesConfigForm(QWidget *parent)
|
|||
connect(ui->kcfg_ElectricBorderTiling, &QCheckBox::stateChanged, this, &KWinScreenEdgesConfigForm::groupChanged);
|
||||
|
||||
connect(ui->electricBorderCornerRatioSpin, qOverload<int>(&QSpinBox::valueChanged), this, &KWinScreenEdgesConfigForm::onChanged);
|
||||
connect(ui->electricBorderCornerRatioSpin, qOverload<int>(&QSpinBox::valueChanged), this, &KWinScreenEdgesConfigForm::updateDefaultIndicators);
|
||||
}
|
||||
|
||||
KWinScreenEdgesConfigForm::~KWinScreenEdgesConfigForm()
|
||||
|
@ -53,7 +54,7 @@ double KWinScreenEdgesConfigForm::electricBorderCornerRatio() const
|
|||
|
||||
void KWinScreenEdgesConfigForm::setElectricBorderCornerRatioEnabled(bool enable)
|
||||
{
|
||||
return ui->electricBorderCornerRatioSpin->setEnabled(enable);
|
||||
ui->electricBorderCornerRatioSpin->setEnabled(enable);
|
||||
}
|
||||
|
||||
void KWinScreenEdgesConfigForm::reload()
|
||||
|
@ -68,6 +69,14 @@ void KWinScreenEdgesConfigForm::setDefaults()
|
|||
KWinScreenEdge::setDefaults();
|
||||
}
|
||||
|
||||
void KWinScreenEdgesConfigForm::setDefaultsIndicatorsVisible(bool visible)
|
||||
{
|
||||
if (m_defaultIndicatorVisible != visible) {
|
||||
m_defaultIndicatorVisible = visible;
|
||||
updateDefaultIndicators();
|
||||
}
|
||||
}
|
||||
|
||||
Monitor *KWinScreenEdgesConfigForm::monitor() const
|
||||
{
|
||||
return ui->monitor;
|
||||
|
@ -101,4 +110,10 @@ void KWinScreenEdgesConfigForm::groupChanged()
|
|||
monitorHideEdge(ElectricLeft, hide);
|
||||
}
|
||||
|
||||
void KWinScreenEdgesConfigForm::updateDefaultIndicators()
|
||||
{
|
||||
ui->electricBorderCornerRatioSpin->setProperty("_kde_highlight_neutral", m_defaultIndicatorVisible && (electricBorderCornerRatio() != m_defaultCornerRatio));
|
||||
ui->electricBorderCornerRatioSpin->update();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -41,6 +41,9 @@ public:
|
|||
void reload() override;
|
||||
void setDefaults() override;
|
||||
|
||||
public Q_SLOTS:
|
||||
void setDefaultsIndicatorsVisible(bool visible);
|
||||
|
||||
protected:
|
||||
Monitor *monitor() const override;
|
||||
bool isSaveNeeded() const override;
|
||||
|
@ -49,12 +52,15 @@ protected:
|
|||
private Q_SLOTS:
|
||||
void sanitizeCooldown();
|
||||
void groupChanged();
|
||||
void updateDefaultIndicators();
|
||||
|
||||
private:
|
||||
// electricBorderCornerRatio value between 0. and 1.
|
||||
double m_referenceCornerRatio = 0.;
|
||||
double m_defaultCornerRatio = 0.;
|
||||
|
||||
bool m_defaultIndicatorVisible = false;
|
||||
|
||||
Ui::KWinScreenEdgesConfigUI *ui;
|
||||
};
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ KWinScreenEdgesConfig::KWinScreenEdgesConfig(QWidget *parent, const QVariantList
|
|||
|
||||
monitorInit();
|
||||
|
||||
connect(this, &KWinScreenEdgesConfig::defaultsIndicatorsVisibleChanged, m_form, &KWinScreenEdgesConfigForm::setDefaultsIndicatorsVisible);
|
||||
connect(m_form, &KWinScreenEdgesConfigForm::saveNeededChanged, this, &KWinScreenEdgesConfig::unmanagedWidgetChangeState);
|
||||
connect(m_form, &KWinScreenEdgesConfigForm::defaultChanged, this, &KWinScreenEdgesConfig::unmanagedWidgetDefaultState);
|
||||
}
|
||||
|
|
|
@ -324,6 +324,54 @@ void KWinTabBoxConfigForm::setLayoutNameEnabled(bool enabled)
|
|||
ui->effectCombo->setEnabled(enabled);
|
||||
}
|
||||
|
||||
void KWinTabBoxConfigForm::setFilterScreenDefaultIndicatorVisible(bool visible)
|
||||
{
|
||||
setDefaultIndicatorVisible(ui->filterScreens, visible);
|
||||
setDefaultIndicatorVisible(ui->currentScreen, visible);
|
||||
setDefaultIndicatorVisible(ui->otherScreens, visible);
|
||||
}
|
||||
|
||||
void KWinTabBoxConfigForm::setFilterDesktopDefaultIndicatorVisible(bool visible)
|
||||
{
|
||||
setDefaultIndicatorVisible(ui->filterDesktops, visible);
|
||||
setDefaultIndicatorVisible(ui->currentDesktop, visible);
|
||||
setDefaultIndicatorVisible(ui->otherDesktops, visible);
|
||||
}
|
||||
|
||||
void KWinTabBoxConfigForm::setFilterActivitiesDefaultIndicatorVisible(bool visible)
|
||||
{
|
||||
setDefaultIndicatorVisible(ui->filterActivities, visible);
|
||||
setDefaultIndicatorVisible(ui->currentActivity, visible);
|
||||
setDefaultIndicatorVisible(ui->otherActivities, visible);
|
||||
}
|
||||
|
||||
void KWinTabBoxConfigForm::setFilterMinimizationDefaultIndicatorVisible(bool visible)
|
||||
{
|
||||
setDefaultIndicatorVisible(ui->filterMinimization, visible);
|
||||
setDefaultIndicatorVisible(ui->visibleWindows, visible);
|
||||
setDefaultIndicatorVisible(ui->hiddenWindows, visible);
|
||||
}
|
||||
|
||||
void KWinTabBoxConfigForm::setApplicationModeDefaultIndicatorVisible(bool visible)
|
||||
{
|
||||
setDefaultIndicatorVisible(ui->oneAppWindow, visible);
|
||||
}
|
||||
|
||||
void KWinTabBoxConfigForm::setShowDesktopModeDefaultIndicatorVisible(bool visible)
|
||||
{
|
||||
setDefaultIndicatorVisible(ui->showDesktop, visible);
|
||||
}
|
||||
|
||||
void KWinTabBoxConfigForm::setSwitchingModeDefaultIndicatorVisible(bool visible)
|
||||
{
|
||||
setDefaultIndicatorVisible(ui->switchingModeCombo, visible);
|
||||
}
|
||||
|
||||
void KWinTabBoxConfigForm::setLayoutNameDefaultIndicatorVisible(bool visible)
|
||||
{
|
||||
setDefaultIndicatorVisible(ui->effectCombo, visible);
|
||||
}
|
||||
|
||||
void KWinTabBoxConfigForm::tabBoxToggled(bool on)
|
||||
{
|
||||
// Highlight Windows options is availabled if no TabBox effect is selected
|
||||
|
@ -393,4 +441,10 @@ void KWinTabBoxConfigForm::shortcutChanged(const QKeySequence &seq)
|
|||
m_actionCollection->writeSettings();
|
||||
}
|
||||
|
||||
void KWinTabBoxConfigForm::setDefaultIndicatorVisible(QWidget *widget, bool visible)
|
||||
{
|
||||
widget->setProperty("_kde_highlight_neutral", visible);
|
||||
widget->update();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -85,6 +85,15 @@ public:
|
|||
void setSwitchingModeEnabled(bool enabled);
|
||||
void setLayoutNameEnabled(bool enabled);
|
||||
|
||||
void setFilterScreenDefaultIndicatorVisible(bool visible);
|
||||
void setFilterDesktopDefaultIndicatorVisible(bool visible);
|
||||
void setFilterActivitiesDefaultIndicatorVisible(bool visible);
|
||||
void setFilterMinimizationDefaultIndicatorVisible(bool visible);
|
||||
void setApplicationModeDefaultIndicatorVisible(bool visible);
|
||||
void setShowDesktopModeDefaultIndicatorVisible(bool visible);
|
||||
void setSwitchingModeDefaultIndicatorVisible(bool visible);
|
||||
void setLayoutNameDefaultIndicatorVisible(bool visible);
|
||||
|
||||
Q_SIGNALS:
|
||||
void filterScreenChanged(int value);
|
||||
void filterDesktopChanged(int value);
|
||||
|
@ -109,6 +118,8 @@ private Q_SLOTS:
|
|||
void shortcutChanged(const QKeySequence &seq);
|
||||
|
||||
private:
|
||||
void setDefaultIndicatorVisible(QWidget *widget, bool visible);
|
||||
|
||||
KActionCollection *m_actionCollection = nullptr;
|
||||
KShortcutsEditor *m_editor = nullptr;
|
||||
|
||||
|
|
|
@ -86,6 +86,7 @@ KWinTabBoxConfig::KWinTabBoxConfig(QWidget* parent, const QVariantList& args)
|
|||
addConfig(m_tabBoxConfig, m_primaryTabBoxUi);
|
||||
addConfig(m_tabBoxAlternativeConfig, m_alternativeTabBoxUi);
|
||||
|
||||
connect(this, &KWinTabBoxConfig::defaultsIndicatorsVisibleChanged, this, &KWinTabBoxConfig::updateUnmanagedState);
|
||||
createConnections(m_primaryTabBoxUi);
|
||||
createConnections(m_alternativeTabBoxUi);
|
||||
|
||||
|
@ -261,8 +262,18 @@ bool KWinTabBoxConfig::updateUnmanagedIsNeedSave(const KWinTabBoxConfigForm *for
|
|||
return isNeedSave;
|
||||
}
|
||||
|
||||
bool KWinTabBoxConfig::updateUnmanagedIsDefault(const KWinTabBoxConfigForm *form, const TabBoxSettings *config)
|
||||
bool KWinTabBoxConfig::updateUnmanagedIsDefault(KWinTabBoxConfigForm *form, const TabBoxSettings *config)
|
||||
{
|
||||
const bool visible = defaultsIndicatorsVisible();
|
||||
form->setFilterScreenDefaultIndicatorVisible(visible && form->filterScreen() != config->defaultMultiScreenModeValue());
|
||||
form->setFilterDesktopDefaultIndicatorVisible(visible && form->filterDesktop() != config->defaultDesktopModeValue());
|
||||
form->setFilterActivitiesDefaultIndicatorVisible(visible && form->filterActivities() != config->defaultActivitiesModeValue());
|
||||
form->setFilterMinimizationDefaultIndicatorVisible(visible && form->filterMinimization() != config->defaultMinimizedModeValue());
|
||||
form->setApplicationModeDefaultIndicatorVisible(visible && form->applicationMode() != config->defaultApplicationsModeValue());
|
||||
form->setShowDesktopModeDefaultIndicatorVisible(visible && form->showDesktopMode() != config->defaultShowDesktopModeValue());
|
||||
form->setSwitchingModeDefaultIndicatorVisible(visible && form->switchingMode() != config->defaultSwitchingModeValue());
|
||||
form->setLayoutNameDefaultIndicatorVisible(visible && form->layoutName() != config->defaultLayoutNameValue());
|
||||
|
||||
bool isDefault = true;
|
||||
isDefault &= form->filterScreen() == config->defaultMultiScreenModeValue();
|
||||
isDefault &= form->filterDesktop() == config->defaultDesktopModeValue();
|
||||
|
|
|
@ -53,7 +53,7 @@ private:
|
|||
void setEnabledUi(KWinTabBoxConfigForm *form, const TabBox::TabBoxSettings *config);
|
||||
void createConnections(KWinTabBoxConfigForm *form);
|
||||
bool updateUnmanagedIsNeedSave(const KWinTabBoxConfigForm *form, const TabBox::TabBoxSettings *config);
|
||||
bool updateUnmanagedIsDefault(const KWinTabBoxConfigForm *form, const TabBox::TabBoxSettings *config);
|
||||
bool updateUnmanagedIsDefault(KWinTabBoxConfigForm *form, const TabBox::TabBoxSettings *config);
|
||||
|
||||
private:
|
||||
KWinTabBoxConfigForm *m_primaryTabBoxUi = nullptr;
|
||||
|
|
Loading…
Reference in a new issue