[KCM/Effects] Allow the user to know when the settings are set to default
ClosedPublic

Authored by meven on Dec 16 2019, 9:25 AM.

Details

Summary

It works for the effect

Test Plan

kcmshell5 kcm_kwin_effects
Change some settings, the "Restore defaults" button is enabled when the state is not the default state.
Open an effect configuration, the "Restore defaults" button is enabled when the settings are not default.

Diff Detail

Repository
R108 KWin
Branch
kcm-effects-isDefault
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 20079
Build 20097: arc lint + arc unit
meven created this revision.Dec 16 2019, 9:25 AM
Restricted Application added a project: KWin. · View Herald TranscriptDec 16 2019, 9:25 AM
Restricted Application added a subscriber: kwin. · View Herald Transcript
meven requested review of this revision.Dec 16 2019, 9:25 AM
zzag added a subscriber: zzag.Dec 16 2019, 10:19 AM
zzag added inline comments.
kcmkwin/common/effectsmodel.cpp
568

Minor thing, but could you please use std::all_of?

kcmkwin/common/effectsmodel.h
195

Make it const please.

meven updated this revision to Diff 71664.Dec 16 2019, 12:16 PM

Use std::all_of and const isDefault

meven updated this revision to Diff 71665.Dec 16 2019, 12:23 PM

Check isDefault state when loading kcm

meven marked 2 inline comments as done.Dec 16 2019, 1:16 PM
zzag added a comment.Dec 17 2019, 6:56 PM

Other than issues pointed out in inline comments, this patch looks good to me.

kcmkwin/common/effectsmodel.cpp
571

No else after a return statement.

663

God I wish we had good support for clang-format. Could you please remove whitespace between [=] and (bool defaulted)? Sorry for annoying you with whitespace issues. :/

kcmkwin/kwineffects/kcm.cpp
55

Do we actually need this connect? I assume that signal dataChanged is emitted when the model is loaded.

meven marked 3 inline comments as done.Dec 18 2019, 8:14 AM
meven added inline comments.
kcmkwin/kwineffects/kcm.cpp
55

dataChanged signal is only emitted in EffectsModel::setData

meven updated this revision to Diff 71758.Dec 18 2019, 8:17 AM
meven marked an inline comment as done.

Remove unconvenient white space, add a else to a if block

meven marked an inline comment as done.Dec 18 2019, 8:21 AM
zzag added inline comments.Dec 20 2019, 12:15 PM
kcmkwin/common/effectsmodel.cpp
571

This inline comment hasn't been addressed.

I asked you to remove a else after a return statement, i.e.

if (effect.enabledByDefaultFunction && effect.status != Status::EnabledUndeterminded) {
    return false;
}
if ((bool)effect.status != effect.enabledByDefault) {
    return false;
}
return true;
kcmkwin/kwineffects/kcm.cpp
55

Oh, you're right! You could also consider using one of QAbstractItemModel's signals instead, e.g. modelReset. Perhaps EffectsModel::loaded() should not exist in the first place.

meven marked an inline comment as done.Dec 20 2019, 12:26 PM
meven added inline comments.
kcmkwin/common/effectsmodel.cpp
571

I misunderstood what you meant, in my last change I added :

} else {
       return true;
 }

Should be good now

meven marked 2 inline comments as done.Dec 20 2019, 12:26 PM
zzag accepted this revision.Dec 20 2019, 3:10 PM
This revision is now accepted and ready to land.Dec 20 2019, 3:10 PM
This revision was automatically updated to reflect the committed changes.
ervin added inline comments.Dec 23 2019, 10:26 AM
kcmkwin/common/effectsmodel.cpp
569

I suspect this lambda would have benefited from being a single return statement (not 100% sure though)

572

Urgh! C-style cast, please don't. Should be a static_cast or something.

zzag added inline comments.Dec 23 2019, 11:08 AM
kcmkwin/common/effectsmodel.cpp
572

Agreed, using it in modern C++ code is not good but on the other hand we have (bool)effect.status != effect.enabledByDefault just right above this method. If my memory serves me well, the c-style cast is leftover from the monolithic compositing kcm. This minor issue can be addressed in another patch though...

ervin added inline comments.Dec 23 2019, 11:09 AM
kcmkwin/common/effectsmodel.cpp
572

Sure, can only be in another patch anyway, that one got merged anyway. ;-)