Implement User Selectable Code Editor Style in cppcheck-gui#1913
Implement User Selectable Code Editor Style in cppcheck-gui#1913danmar merged 1 commit intocppcheck-opensource:masterfrom scottfurry:EditStyle
Conversation
|
CI testing failed - logs indicated left over testing/debug code. Removed. |
|
CI highlighted warnings about variable naming conventions. Updated to correct code to expected style. |
danmar
left a comment
There was a problem hiding this comment.
I am eager to get this in. However I have some small nits..
| CodeEditor::~CodeEditor() | ||
| { | ||
| // NOTE: not a Qt Object - delete manually | ||
| if( mWidgetStyle ) delete mWidgetStyle; |
| else mWidgetStyle = new CodeEditorStyle(defaultStyle); | ||
| switch( rule.ruleRole ) | ||
| { | ||
| case( RuleRole::Keyword ): |
There was a problem hiding this comment.
imho the parentheses here does not help
| return !(*this == rhs); | ||
| } | ||
|
|
||
| CodeEditorStyle CodeEditorStyle::LoadSettings( QSettings *pSettings ) |
There was a problem hiding this comment.
Please use camelCase for function names.
I would prefer the name settings instead of pSettings.
| CodeEditorStyle CodeEditorStyle::LoadSettings( QSettings *pSettings ) | ||
| { | ||
| CodeEditorStyle theStyle( defaultStyleLight ); | ||
| if( pSettings) { |
There was a problem hiding this comment.
I suggest a early return here.
| const CodeEditorStyle& theStyle ) | ||
| { | ||
| if( pSettings) { | ||
| bool bDefaultLight = ( defaultStyleLight == theStyle ); |
There was a problem hiding this comment.
I prefer that the name bDefaultLight is changed to isDefaultLight
|
All changes identified above incorporated. |
|
One more... |
| @@ -0,0 +1 @@ | |||
| /home/scottfurry/FurCaT_Remote/CPPCheck/project/.vscode No newline at end of file | |||
There was a problem hiding this comment.
remove this file from the PR
There was a problem hiding this comment.
You're right. That shouldn't be there!
| case RuleRole::Symbol: | ||
| rule.format = mSymbolFormat; | ||
| break; | ||
| default: |
There was a problem hiding this comment.
hmm.. I have the feeling that it's better to remove the "default". then we'll get compiler warnings if an enum value is missing.
There was a problem hiding this comment.
Would this not raise another warning about a missing default in switch statement?
There was a problem hiding this comment.
Yes.. but I rather suppress that warning and get warnings when I forget enum constants instead.
| CodeEditorStyle theStyle( defaultStyleLight ); | ||
| if( !settings) return theStyle; | ||
|
|
||
| if( settings->childGroups().contains( SETTINGS_STYLE_GROUP )) |
There was a problem hiding this comment.
It seems you can have an early return here also.
|
|
||
| bool CodeEditorStyle::operator==( const CodeEditorStyle& rhs ) const | ||
| { | ||
| if( this->widgetFGColor != rhs.widgetFGColor ) return false; |
There was a problem hiding this comment.
could you remove "this->" in these conditions.
| } | ||
|
|
||
| void SelectColorButton::changeColor() { | ||
| QColorDialog *pDlg = new QColorDialog( mColor ); |
There was a problem hiding this comment.
As far as I know you don't need to use new/delete for QColorDialog in this method.
QColorDialog dlg(mColor);
| } | ||
|
|
||
| void SelectColorButton::setColor( const QColor& color ) { | ||
| this->mColor = color; |
| mSymbolFormat.setForeground( newStyle.symbolFGColor ); | ||
| mSymbolFormat.setBackground( newStyle.symbolBGColor ); | ||
| mSymbolFormat.setFontWeight( newStyle.symbolWeight ); | ||
| for( QVector<HighlightingRule>::iterator ruleIT = mHighlightingRules.begin(); |
There was a problem hiding this comment.
I wonder if you can't use foreach here.
There was a problem hiding this comment.
Tried that. Qt foreach macro wants to use a const variable in each iteration. That becomes a problem since contents are being altered in the call to apply the style. There is the std::foreach or std::for(auto &: <container) but IIRC that is only available >=c++11.
There was a problem hiding this comment.
ok.. please try C++11 range for if you can. We use that throughout the code in cppcheck-core so you can't build the GUI unless the compiler support that anyway.
There was a problem hiding this comment.
That's going to change a couple of things in the .pro and CMakeList.txt files. Are you okay with that?
There was a problem hiding this comment.
ok.. let's keep it like this for now.. and then somebody can try to modernize for loops later in a separate PR.
There was a problem hiding this comment.
Already had change incorporated and doing a full build for testing. Nothing jumps out in the logging messages. Expect this to be incorporated in final push. Only change was in .pro file where one line for gcc was using c++0x.
|
I really look forward to the day when the full GUI uses a configurable theme! :-) |
|
All identified changes in code made. |
Building on #1874, commit adds user controls to choose or edit style in cppcheck-gui ONLY. Commit does not address CodeEditor style usage in triage app at this time. Code Editor style can be altered from the added "Code Editor" tab in the user preferences. The user has the option to select default light, default dark, or to customize. If user leaves the style set to light or dark defaults, this will be reflected in the choices shown in the preferences dialog. User choice for Code Editor Style is saved in the cppcheck-gui preferences under the heading "EditorStyle".
danmar
left a comment
There was a problem hiding this comment.
If Travis/Appveyor finish happily I think we can merge this.
|
\o/ All checks passed! |
Styling change missed in #1913.
…-opensource#1913) Building on cppcheck-opensource#1874, commit adds user controls to choose or edit style in cppcheck-gui ONLY. Commit does not address CodeEditor style usage in triage app at this time. Code Editor style can be altered from the added "Code Editor" tab in the user preferences. The user has the option to select default light, default dark, or to customize. If user leaves the style set to light or dark defaults, this will be reflected in the choices shown in the preferences dialog. User choice for Code Editor Style is saved in the cppcheck-gui preferences under the heading "EditorStyle".
…k-opensource#1923) Styling change missed in cppcheck-opensource#1913.
Building on #1874, commit adds user controls to choose
or edit style in cppcheck-gui ONLY. Commit does not
address CodeEditor style usage in triage app at this time.
Code Editor style can be altered from the added "Code Editor"
tab in the user preferences. The user has the option to select
default light, default dark, or to customize.
If user leaves the style set to light or dark defaults, this
will be reflected in the choices shown in the preferences
dialog.
User choice for Code Editor Style is saved in the cppcheck-gui
preferences under the heading "EditorStyle".