feat(kded): add getAutoRotate method and rename lockAutoRotate
ClosedPublic

Authored by z3ntu on Apr 12 2020, 2:18 PM.

Details

Summary

lockAutoRotate(true) would enable the automatic rotation and
lockAutoRotate(false) would disable auto rotation which is the opposite
of what the function name would imply, so rename it to setAutoRotate.

We also need a getter for the value to display the status in the UI.
This getter checks if all applicable outputs have auto rotate enabled
and returns that value.

Test Plan

tested on Plasma Mobile

Diff Detail

Repository
R104 KScreen
Branch
autorotate
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 25153
Build 25171: arc lint + arc unit
z3ntu created this revision.Apr 12 2020, 2:18 PM
Restricted Application added a project: Plasma. · View Herald TranscriptApr 12 2020, 2:18 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
z3ntu requested review of this revision.Apr 12 2020, 2:18 PM
nicolasfella added inline comments.
kded/config.cpp
99 ↗(On Diff #79930)

That sounds like a job for std::all_of

kded/config.h
50 ↗(On Diff #79930)

const

I'm not sure about the renaming. the lock... implies that the rotation stays the way it is at the moment (what it does). But I'm fine either way.

These are normally two separate commits, one refactor and one feature addition. But since it's only a small change and Phabricator sucks let's not bitch too much about it.

@bshah: ok with the change?

kded/config.cpp
104 ↗(On Diff #79930)

Should we check if all or only one panel display are set to auto rotate. Granted I'm not aware of a device with multiple panel displays which runs KScreen but maybe you had a reason for using && here?

Just want to hear a rational if you had one. If you didn't and just picked && by random it's also fine.

z3ntu planned changes to this revision.Apr 12 2020, 2:36 PM
z3ntu added inline comments.
kded/config.cpp
99 ↗(On Diff #79930)

I wasn't aware that C++ had such fancy methods :) I'm using equivalent functions a lot in Kotlin but they are honestly much nicer to use in Kotlin than in C++.

In this case instead of the "continue" keyword I would have to return true then I guess.

104 ↗(On Diff #79930)

I thought it makes more sense to say "auto rotate is enabled when all panels have auto rotate enabled" rather than "auto rotate is enabled when at least one panel has auto rotate enabled" which is why I've chosen to do it this way.

z3ntu updated this revision to Diff 79995.Apr 13 2020, 11:07 AM
  • const function, std::all_of
z3ntu marked 3 inline comments as done.Apr 13 2020, 11:07 AM
bshah accepted this revision.Apr 13 2020, 11:19 AM

LGTM, Please wait for @romangg to approve.

I am fine with behavior change of the,

  • method rename of lock -> set/getAutoRotate
  • all panels being considered for value of autorotate.
This revision is now accepted and ready to land.Apr 13 2020, 11:19 AM
nicolasfella added inline comments.Apr 13 2020, 11:20 AM
kded/config.cpp
99
nicolasfella requested changes to this revision.Apr 13 2020, 11:21 AM
This revision now requires changes to proceed.Apr 13 2020, 11:21 AM
z3ntu updated this revision to Diff 79997.Apr 13 2020, 11:52 AM
  • extract m_data->outputs() into a variable
z3ntu marked an inline comment as done.Apr 13 2020, 11:53 AM
nicolasfella added inline comments.Apr 13 2020, 12:16 PM
kded/config.cpp
99 ↗(On Diff #79930)

const auto

romangg accepted this revision.Apr 13 2020, 12:26 PM

Add the const and push.

z3ntu updated this revision to Diff 80393.Apr 17 2020, 2:33 PM
  • const auto
z3ntu marked an inline comment as done.Apr 17 2020, 2:35 PM
This revision was not accepted when it landed; it landed in state Needs Review.Apr 17 2020, 2:39 PM
This revision was automatically updated to reflect the committed changes.