Workspace KCM Code Improvement
ClosedPublic

Authored by furkantokac on May 18 2018, 11:12 PM.

Details

Summary

Code formatting is improved. "save" function is improved by preventing unnecessary file open and file write. Functionality is same. Everything is tested, works fine.

Diff Detail

Repository
R119 Plasma Desktop
Branch
kcmworkspace-CodeFormatting
Lint
No Linters Available
Unit
No Unit Test Coverage
furkantokac created this revision.May 18 2018, 11:12 PM
Restricted Application added a project: Plasma. · View Herald TranscriptMay 18 2018, 11:12 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
furkantokac requested review of this revision.May 18 2018, 11:12 PM
furkantokac edited the summary of this revision. (Show Details)May 18 2018, 11:15 PM

While we're doing some formatting and style cleanup work, how about renaming some variables? For example m_ostateToolTip and m_ostateVisualFeedback aren't very descriptive IMHO. Maybe instead, they could be m_currentToolTipState and m_currentVisualFeedbackState.

zzag removed a reviewer: zzag.May 19 2018, 11:14 AM

Thanks, but I'm not a member of Plasma. ;-)

While we're doing some formatting and style cleanup work, how about renaming some variables? For example m_ostateToolTip and m_ostateVisualFeedback aren't very descriptive IMHO. Maybe instead, they could be m_currentToolTipState and m_currentVisualFeedbackState.

So they'll be changed as
m_toolTipCurrentState m_toolTipOriginalState etc.

zzag added a subscriber: zzag.May 19 2018, 11:34 AM

Also, about coding style. Why are you using /* for one line comments?

kcms/workspaceoptions/workspaceoptions.cpp
28–29
35–37

I think you could do something like this in the header file

class ...  {
...
    m_stateToolTip = true;
    m_stateVisualFeedback = true;
    m_stateSingleClick = true;
...
};
111–112

I would remove it. It doesn't add any useful information. I don't see any word about commets in the kdelibs coding style(I assume Plasma follows it) but as a rule of thumb: comment things that are not obvious.

For example, see https://google.github.io/styleguide/cppguide.html#Implementation_Comments

While we're doing some formatting and style cleanup work, how about renaming some variables? For example m_ostateToolTip and m_ostateVisualFeedback aren't very descriptive IMHO. Maybe instead, they could be m_currentToolTipState and m_currentVisualFeedbackState.

So they'll be changed as
m_toolTipCurrentState m_toolTipOriginalState etc.

Yep, sounds good!

State variable names are changed. Some formatting improvements.

furkantokac marked 3 inline comments as done.May 20 2018, 1:58 AM
furkantokac added inline comments.
kcms/workspaceoptions/workspaceoptions.cpp
35–37

This one is more clear imho because they are not optional initializations, they are must so we emphasize that.

111–112

Actually this is optional. Not a big issue. Makes it easier to follow. Specifically for this patch, it's okay imho.

ngraham added inline comments.May 20 2018, 3:59 AM
kcms/workspaceoptions/workspaceoptions.cpp
50–51

Why all the asterisks?

kcms/workspaceoptions/workspaceoptions.h
64–65

The inline comments are no longer needed now that the variable name is self-documenting.

davidedmundson added inline comments.
kcms/workspaceoptions/workspaceoptions.cpp
62

We want to batch our syncs to plasmarc, which the old code did better.

I wouldn't bother trying to be clever with checking if it's the original state or not here, as KConfig will do all of that for us anyway at a more correct lower level.

romangg added inline comments.May 22 2018, 9:09 AM
kcms/workspaceoptions/workspaceoptions.cpp
62

For the sync yes.

For checking state: the old code wrote always all values to the config file, with or without the user changing them at all. It might make sense to only write config values which have been explicitly changed by the user, because this would mean that we can later on change the default of values of this user which have never been explicitly changed by the user before with an update of just the KCM code.

furkantokac marked 8 inline comments as done.May 22 2018, 12:56 PM
furkantokac added inline comments.
kcms/workspaceoptions/workspaceoptions.cpp
62

Nice point. I tested the situation for the old code. When I just change single/double click option, other option files (plasmarc) are not opened. That means KConfig handles the situation. Thank you. Correction will be done now.

furkantokac updated this revision to Diff 34652.EditedMay 22 2018, 2:56 PM

resources.qrc is creator for better Qt Creator integration and explicit definition of resource files. workspaceoptions.cpp/.h are reformatted according to phab feedback. Save and load function are seperated to different functions. It is easier to manipulate now and the code is more clear. Comments are reformatted. Tested and everything works fine.

mart requested changes to this revision.May 22 2018, 3:15 PM
mart added a subscriber: mart.
mart added inline comments.
kcms/workspaceoptions/resources.qrc
1 ↗(On Diff #34652)

I don't want this kcm done differently from all the others, i want all modules using the same structure, on disk

This revision now requires changes to proceed.May 22 2018, 3:15 PM

.qrc file is cancelled.

romangg accepted this revision.May 23 2018, 2:17 PM

Looks good to me. Only commit to master branch please.

This revision was not accepted when it landed; it landed in state Needs Review.May 23 2018, 10:33 PM
This revision was automatically updated to reflect the committed changes.