feature: astyle reformat option dialog

This commit is contained in:
royqh1979@gmail.com 2021-09-01 22:40:58 +08:00
parent 0f70658d32
commit 2778e9f4bd
10 changed files with 462 additions and 223 deletions

View File

@ -185,6 +185,7 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target !isEmpty(target.path): INSTALLS += target
RESOURCES += \ RESOURCES += \
codes.qrc \
colorschemes.qrc \ colorschemes.qrc \
themes/dark/dark.qrc \ themes/dark/dark.qrc \
themes/light/light.qrc \ themes/light/light.qrc \

View File

@ -573,20 +573,20 @@ Are you really want to continue?</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="editor.cpp" line="2042"/> <location filename="editor.cpp" line="2045"/>
<location filename="editor.cpp" line="2079"/> <location filename="editor.cpp" line="2082"/>
<location filename="editor.cpp" line="2130"/> <location filename="editor.cpp" line="2133"/>
<source>Ctrl+click for more info</source> <source>Ctrl+click for more info</source>
<translation>Ctrl+</translation> <translation>Ctrl+</translation>
</message> </message>
<message> <message>
<location filename="editor.cpp" line="2148"/> <location filename="editor.cpp" line="2151"/>
<location filename="editor.cpp" line="2178"/> <location filename="editor.cpp" line="2181"/>
<source>Symbol &apos;%1&apos; not found!</source> <source>Symbol &apos;%1&apos; not found!</source>
<translation>&apos;%1&apos;!</translation> <translation>&apos;%1&apos;!</translation>
</message> </message>
<message> <message>
<location filename="editor.cpp" line="2688"/> <location filename="editor.cpp" line="2691"/>
<source>Readonly</source> <source>Readonly</source>
<translation></translation> <translation></translation>
</message> </message>
@ -1319,371 +1319,371 @@ Are you really want to continue?</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="75"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="78"/>
<source>Basic</source> <source>Basic</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="81"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="84"/>
<source>Brace modifications</source> <source>Brace modifications</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="87"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="90"/>
<source>Attach braces to namespace statements</source> <source>Attach braces to namespace statements</source>
<oldsource>Attach spaces to namespace statements</oldsource> <oldsource>Attach spaces to namespace statements</oldsource>
<translation>(namespace)</translation> <translation>(namespace)</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="94"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="97"/>
<source>Attach braces to classes</source> <source>Attach braces to classes</source>
<oldsource>Attach spaces to classes</oldsource> <oldsource>Attach spaces to classes</oldsource>
<translation>(class)</translation> <translation>(class)</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="101"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="104"/>
<source>Attach braces to class inline function definitions</source> <source>Attach braces to class inline function definitions</source>
<oldsource>Attach spaces to class inline function definitions</oldsource> <oldsource>Attach spaces to class inline function definitions</oldsource>
<translation>(inline function)</translation> <translation>(inline function)</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="108"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="111"/>
<source>Attach braces to extern &quot;C&quot; statements</source> <source>Attach braces to extern &quot;C&quot; statements</source>
<oldsource>Attach spaces to extern &quot;C&quot; statements</oldsource> <oldsource>Attach spaces to extern &quot;C&quot; statements</oldsource>
<translation>extern &quot;C&quot;</translation> <translation>extern &quot;C&quot;</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="115"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="118"/>
<source>Attach the closing while of do-while to the close brace</source> <source>Attach the closing while of do-while to the close brace</source>
<translation>do-while语句的while部分与结尾花括号合并</translation> <translation>do-while语句的while部分与结尾花括号合并</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="125"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="128"/>
<source>Convert tabs to the appropriate number of spaces</source> <source>Convert tabs to the appropriate number of spaces</source>
<translation>(Tab)</translation> <translation>(Tab)</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="133"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="136"/>
<source>Indentation 1</source> <source>Indentation 1</source>
<translation>1</translation> <translation>1</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="139"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="142"/>
<source>Indent with:</source> <source>Indent with:</source>
<translation>使:</translation> <translation>使:</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="154"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="157"/>
<source>Indent using spaces</source> <source>Indent using spaces</source>
<translation>使</translation> <translation>使</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="157"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="160"/>
<source>Spaces</source> <source>Spaces</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="164"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="167"/>
<source>Indent using tabs</source> <source>Indent using tabs</source>
<translation>使</translation> <translation>使</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="167"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="170"/>
<source>Tabs</source> <source>Tabs</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="192"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="195"/>
<source>Tab Size:</source> <source>Tab Size:</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="243"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="246"/>
<source>Indent for continuation lines:</source> <source>Indent for continuation lines:</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="291"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="294"/>
<source>Minimal indent for a continuous conditional beloning to a conditional header:</source> <source>Minimal indent for a continuous conditional beloning to a conditional header:</source>
<translation>(&apos;if&apos;,&apos;while&apos;,...)</translation> <translation>(&apos;if&apos;,&apos;while&apos;,...)</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="332"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="335"/>
<source>Maximal indent spaces for a continuation line</source> <source>Maximal indent spaces for a continuation line</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="359"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="362"/>
<source>Indentation 2</source> <source>Indentation 2</source>
<translation>2</translation> <translation>2</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="365"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="368"/>
<source>Indent labels</source> <source>Indent labels</source>
<translation>(label)</translation> <translation>(label)</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="372"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="375"/>
<source>Indent class blocks</source> <source>Indent class blocks</source>
<translation>(class)</translation> <translation>(class)</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="379"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="382"/>
<source>Indent namespaces</source> <source>Indent namespaces</source>
<translation>(namespace)</translation> <translation>(namespace)</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="386"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="389"/>
<source>Indent class access modifiers</source> <source>Indent class access modifiers</source>
<translation>访(&apos;public&apos;,&apos;private&apos;...)</translation> <translation>访(&apos;public&apos;,&apos;private&apos;...)</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="393"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="396"/>
<source>Indent after parenthesis &apos;(&apos; or assignment &apos;=&apos;</source> <source>Indent after parenthesis &apos;(&apos; or assignment &apos;=&apos;</source>
<translation>&apos;(&apos;&apos;=&apos;</translation> <translation>&apos;(&apos;&apos;=&apos;</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="400"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="403"/>
<source>Indent preprocessor conditional statements</source> <source>Indent preprocessor conditional statements</source>
<translation>(&apos;#if&apos;,&apos;#else&apos;,...)</translation> <translation>(&apos;#if&apos;,&apos;#else&apos;,...)</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="407"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="410"/>
<source>Indent multi-line preprocessor #define statements</source> <source>Indent multi-line preprocessor #define statements</source>
<translation>#define语句</translation> <translation>#define语句</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="414"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="417"/>
<source>Indent line comments that start in column one</source> <source>Indent line comments that start in column one</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="421"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="424"/>
<source>Indent preprocessor blocks</source> <source>Indent preprocessor blocks</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="428"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="431"/>
<source>Indent switch blocks</source> <source>Indent switch blocks</source>
<translation>switch语句</translation> <translation>switch语句</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="435"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="438"/>
<source>Indent cases</source> <source>Indent cases</source>
<translation>case语句</translation> <translation>case语句</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="443"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="446"/>
<source>Padding 1</source> <source>Padding 1</source>
<translation>1</translation> <translation>1</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="449"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="452"/>
<source>Insert spaces around operators</source> <source>Insert spaces around operators</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="456"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="459"/>
<source>Insert spaces after commas</source> <source>Insert spaces after commas</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="463"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="466"/>
<source>Insert spaces after parenthesis headers (&apos;if&apos;,&apos;for&apos;,...)</source> <source>Insert spaces after parenthesis headers (&apos;if&apos;,&apos;for&apos;,...)</source>
<translation>(&apos;if&apos;,&apos;for&apos;...)</translation> <translation>(&apos;if&apos;,&apos;for&apos;...)</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="470"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="473"/>
<source>Insert spaces around parenthesis on the outside only</source> <source>Insert spaces around parenthesis on the outside only</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="477"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="480"/>
<source>Insert spaces around parenthesis on the inside only</source> <source>Insert spaces around parenthesis on the inside only</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="484"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="487"/>
<source>Insert empty lines arround unrelated blocks</source> <source>Insert empty lines arround unrelated blocks</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="491"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="494"/>
<source>Insert empty lines around all blocks</source> <source>Insert empty lines around all blocks</source>
<oldsource>Insert empy lines around all blocks</oldsource> <oldsource>Insert empy lines around all blocks</oldsource>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="498"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="501"/>
<source>Insert spaces around first parenthesis in a series on the out side only</source> <source>Insert spaces around first parenthesis in a series on the out side only</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="505"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="508"/>
<source>Insert spaces around parenthesis</source> <source>Insert spaces around parenthesis</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="513"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="516"/>
<source>Padding 2</source> <source>Padding 2</source>
<translation>2</translation> <translation>2</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="519"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="522"/>
<source>Remove all empty lines. It will NOT delete lines added by the padding options.</source> <source>Remove all empty lines. It will NOT delete lines added by the padding options.</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="526"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="529"/>
<source>Attach a pointer operator to its :</source> <source>Attach a pointer operator to its :</source>
<translation>(&apos;*&apos;)</translation> <translation>(&apos;*&apos;)</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="533"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="536"/>
<source>Remove all consecutive empty lines. It will NOT delete lines added by the padding options.</source> <source>Remove all consecutive empty lines. It will NOT delete lines added by the padding options.</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="540"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="543"/>
<location filename="settingsdialog/formattergeneralwidget.ui" line="550"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="553"/>
<source>type(left)</source> <source>type(left)</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="583"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="586"/>
<source>Fill empty lines with the white space of the previous lines.</source> <source>Fill empty lines with the white space of the previous lines.</source>
<translation>使</translation> <translation>使</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="573"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="576"/>
<location filename="settingsdialog/formattergeneralwidget.ui" line="600"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="603"/>
<source>middle</source> <source>middle</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="61"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="64"/>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Note for the predefined format style&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source> <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Note for the predefined format style&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation> <translation>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="590"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="593"/>
<location filename="settingsdialog/formattergeneralwidget.ui" line="610"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="613"/>
<source>name(right)</source> <source>name(right)</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="620"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="623"/>
<source>Remove unnecessary space adding around parenthesis</source> <source>Remove unnecessary space adding around parenthesis</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="627"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="630"/>
<source>Attach a reference operator to its :</source> <source>Attach a reference operator to its :</source>
<translation>(&apos;&amp;&apos;)</translation> <translation>(&apos;&amp;&apos;)</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="634"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="637"/>
<location filename="settingsdialog/formattergeneralwidget.ui" line="644"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="647"/>
<source>none</source> <source>none</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="655"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="658"/>
<source>Other 1</source> <source>Other 1</source>
<translation>1</translation> <translation>1</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="661"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="664"/>
<source>Break one line headers (&apos;if&apos;,&apos;while&apos;,&apos;else&apos;...) from the statement on the same line</source> <source>Break one line headers (&apos;if&apos;,&apos;while&apos;,&apos;else&apos;...) from the statement on the same line</source>
<translation>(&apos;if&apos;,&apos;while&apos;,&apos;else&apos;)</translation> <translation>(&apos;if&apos;,&apos;while&apos;,&apos;else&apos;)</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="668"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="671"/>
<source>Add one line braces to unbraced one line conditional statements</source> <source>Add one line braces to unbraced one line conditional statements</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="675"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="678"/>
<source>Break braces before close headers (&apos;else&apos;,&apos;catch&quot;...)</source> <source>Break braces before close headers (&apos;else&apos;,&apos;catch&quot;...)</source>
<translation>(&apos;else&apos;,&apos;catch&apos;)</translation> <translation>(&apos;else&apos;,&apos;catch&apos;)</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="682"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="685"/>
<source>Remove braces from a braced one line conditional statements</source> <source>Remove braces from a braced one line conditional statements</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="689"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="692"/>
<source>Break &apos;else if&apos; statements into two lines</source> <source>Break &apos;else if&apos; statements into two lines</source>
<translation>&apos;else if&apos;</translation> <translation>&apos;else if&apos;</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="696"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="699"/>
<source>Add braces to unbraced one line conditional statements</source> <source>Add braces to unbraced one line conditional statements</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="704"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="707"/>
<source>Other 2</source> <source>Other 2</source>
<translation>2</translation> <translation>2</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="745"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="748"/>
<source>Attach return type to the function name in its declaration</source> <source>Attach return type to the function name in its declaration</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="738"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="741"/>
<source>Break return type from the function name in its declaration</source> <source>Break return type from the function name in its declaration</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="710"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="713"/>
<source>Break return type from the function name in its definition</source> <source>Break return type from the function name in its definition</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="724"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="727"/>
<source>Attach return type to the function name in its definition</source> <source>Attach return type to the function name in its definition</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="717"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="720"/>
<source>Don&apos;t break blocks residing completely on one line</source> <source>Don&apos;t break blocks residing completely on one line</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="731"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="734"/>
<source>Don&apos;t break multimple statements residing on one line</source> <source>Don&apos;t break multimple statements residing on one line</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="753"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="756"/>
<source>Other 3</source> <source>Other 3</source>
<translation>3</translation> <translation>3</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="840"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="843"/>
<source>Place the logical conditional to the last on the previous line, when break lines</source> <source>Place the logical conditional to the last on the previous line, when break lines</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="833"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="836"/>
<source>Close ending angle brackets on template definitions</source> <source>Close ending angle brackets on template definitions</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="826"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="829"/>
<source>Remove the leading &apos;*&apos; prefix on multi-line comments and indent the comment text one line indent.</source> <source>Remove the leading &apos;*&apos; prefix on multi-line comments and indent the comment text one line indent.</source>
<translation>&apos;*&apos;</translation> <translation>&apos;*&apos;</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="774"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="777"/>
<source>Break lines exceeds</source> <source>Break lines exceeds</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.ui" line="781"/> <location filename="settingsdialog/formattergeneralwidget.ui" line="784"/>
<source>characters</source> <source>characters</source>
<translation></translation> <translation></translation>
</message> </message>
@ -1691,179 +1691,187 @@ Are you really want to continue?</source>
<context> <context>
<name>FormatterStyleModel</name> <name>FormatterStyleModel</name>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="204"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="133"/>
<source>Default</source> <source>Default</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="205"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="134"/>
<source>The opening braces will not be changed and closing braces will be broken from the preceding line.</source> <source>The opening braces will not be changed and closing braces will be broken from the preceding line.</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="210"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="139"/>
<source>Allman</source> <source>Allman</source>
<translation>Allman</translation> <translation>Allman</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="211"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="140"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="217"/>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="223"/>
<source>Broken braces.</source> <source>Broken braces.</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="216"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="145"/>
<source>Java</source> <source>Java</source>
<translation>Java</translation> <translation>Java</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="222"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="146"/>
<source>Attached braces.</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="151"/>
<source>K&amp;R</source> <source>K&amp;R</source>
<translation>Kernighan &amp; Ritchie</translation> <translation>K&amp;R</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="228"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="152"/>
<source>Linux braces.</source>
<translation type="unfinished">Linux风格花括号</translation>
</message>
<message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="157"/>
<source>Stroustrup</source> <source>Stroustrup</source>
<translation>Kernighan &amp; Ritchie</translation> <translation>Stroustrup</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="229"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="158"/>
<source>Linux braces, with broken closing headers.</source> <source>Linux braces, with broken closing headers.</source>
<translation>Linux风格花括号do-while的while</translation> <translation>Linux风格花括号do-while的while</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="234"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="163"/>
<source>Whitesmith</source> <source>Whitesmith</source>
<translation>Whitesmith</translation> <translation>Whitesmith</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="235"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="164"/>
<source>Broken, indented braces.</source> <source>Broken, indented braces.</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="237"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="166"/>
<source>Indented class blocks and switch blocks.</source> <source>Indented class blocks and switch blocks.</source>
<translation>switch代码段缩进</translation> <translation>switch代码段缩进</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="242"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="171"/>
<source>VTK</source> <source>VTK</source>
<translation>VTK</translation> <translation>VTK</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="243"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="172"/>
<source>Broken, indented braces except for the opening braces.</source> <source>Broken, indented braces except for the opening braces.</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="248"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="177"/>
<source>Ratliff</source> <source>Ratliff</source>
<translation>Ratliff</translation> <translation>Ratliff</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="249"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="178"/>
<source>Attached, indented braces.</source> <source>Attached, indented braces.</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="254"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="183"/>
<source>GNU</source> <source>GNU</source>
<translation>GNU</translation> <translation>GNU</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="255"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="184"/>
<source>Broken braces, indented blocks.</source> <source>Broken braces, indented blocks.</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="260"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="189"/>
<source>Linux</source> <source>Linux</source>
<translation>Linux</translation> <translation>Linux</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="261"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="190"/>
<source>Linux braces, minimum conditional indent is one-half indent.</source> <source>Linux braces, minimum conditional indent is one-half indent.</source>
<translation>Linux风格花括号1.5</translation> <translation>Linux风格花括号1.5</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="266"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="195"/>
<source>Horstmann</source> <source>Horstmann</source>
<translation>Horstmann</translation> <translation>Horstmann</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="267"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="196"/>
<source>Run-in braces, indented switches.</source> <source>Run-in braces, indented switches.</source>
<translation>Run-in花括号switch语句缩进</translation> <translation>Run-in花括号switch语句缩进</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="272"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="201"/>
<source>One True Brace</source> <source>One True Brace</source>
<translation>One True Brace</translation> <translation>One True Brace</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="273"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="202"/>
<source>Linux braces, add braces to all conditionals.</source> <source>Linux braces, add braces to all conditionals.</source>
<translation>Linux封号花括号</translation> <translation>Linux封号花括号</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="278"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="207"/>
<source>Google</source> <source>Google</source>
<translation>Google</translation> <translation>Google</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="279"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="208"/>
<source>Attached braces, indented class modifiers.</source> <source>Attached braces, indented class modifiers.</source>
<translation>访</translation> <translation>访</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="284"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="213"/>
<source>Mozilla</source> <source>Mozilla</source>
<translation>Mozilla</translation> <translation>Mozilla</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="285"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="214"/>
<source>Linux braces, with broken braces for structs and enums, and attached braces for namespaces.</source> <source>Linux braces, with broken braces for structs and enums, and attached braces for namespaces.</source>
<translation>Linux风格花括号 </translation> <translation>Linux风格花括号 </translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="290"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="219"/>
<source>Webkit</source> <source>Webkit</source>
<translation>Webkit</translation> <translation>Webkit</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="291"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="220"/>
<source>Linux braces, with attached closing headers.</source> <source>Linux braces, with attached closing headers.</source>
<translation>Linux风格花括号 do-while的while)</translation> <translation>Linux风格花括号 do-while的while)</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="296"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="225"/>
<source>Pico</source> <source>Pico</source>
<translation>Pico</translation> <translation>Pico</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="297"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="226"/>
<source>Run-in opening braces and attached closing braces.</source> <source>Run-in opening braces and attached closing braces.</source>
<translation>Run-in左花括号</translation> <translation>Run-in左花括号</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="299"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="228"/>
<source>Uses keep one line blocks and keep one line statements.</source> <source>Uses keep one line blocks and keep one line statements.</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="304"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="233"/>
<source>Lisp</source> <source>Lisp</source>
<translation>Lisp</translation> <translation>Lisp</translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="305"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="234"/>
<source>Attached opening braces and attached closing braces.</source> <source>Attached opening braces and attached closing braces.</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="settingsdialog/formattergeneralwidget.cpp" line="307"/> <location filename="settingsdialog/formattergeneralwidget.cpp" line="236"/>
<source>Uses keep one line statements.</source> <source>Uses keep one line statements.</source>
<translation></translation> <translation></translation>
</message> </message>
@ -2912,7 +2920,7 @@ Are you really want to continue?</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="utils.cpp" line="326"/> <location filename="utils.cpp" line="329"/>
<source>Index %1 out of range</source> <source>Index %1 out of range</source>
<translation>&quot;%1&quot;</translation> <translation>&quot;%1&quot;</translation>
</message> </message>

5
RedPandaIDE/codes.qrc Normal file
View File

@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/codes">
<file alias="formatdemo.cpp">resources/formatdemo.cpp</file>
</qresource>
</RCC>

View File

@ -2704,6 +2704,199 @@ Settings::CodeFormatter::CodeFormatter(Settings *settings):
} }
QStringList Settings::CodeFormatter::getArguments()
{
QStringList result;
switch(mBraceStyle) {
case FormatterBraceStyle::fbsDefault:
break;
case FormatterBraceStyle::fbsAllman:
result.append("--style=allman");
break;
case FormatterBraceStyle::fbsJava:
result.append("--style=java");
break;
case FormatterBraceStyle::fbsKR:
result.append("--style=kr");
break;
case FormatterBraceStyle::fbsStroustrup:
result.append("--style=stroustrup");
break;
case FormatterBraceStyle::fbsWitesmith:
result.append("--style=whitesmith");
break;
case FormatterBraceStyle::fbsVtk:
result.append("--style=vtk");
break;
case FormatterBraceStyle::fbsRatliff:
result.append("--style=ratliff");
break;
case FormatterBraceStyle::fbsGNU:
result.append("--style=gnu");
break;
case FormatterBraceStyle::fbsLinux:
result.append("--style=linux");
break;
case FormatterBraceStyle::fbsHorstmann:
result.append("--style=horstmann");
break;
case FormatterBraceStyle::fbs1TBS:
result.append("--style=1tbs");
break;
case FormatterBraceStyle::fbsGoogle:
result.append("--style=google");
break;
case FormatterBraceStyle::fbsMozilla:
result.append("--style=mozilla");
break;
case FormatterBraceStyle::fbsWebkit:
result.append("--style=webkit");
break;
case FormatterBraceStyle::fbsPico:
result.append("--style=pico");
break;
case FormatterBraceStyle::fbsLisp:
result.append("--style=lisp");
break;
};
switch(mIndentStyle) {
case FormatterIndentType::fitTab:
result.append(QString("--indent=tab=%1").arg(mTabWidth));
break;
case FormatterIndentType::fitSpace:
result.append(QString("--indent=spaces=%1").arg(mTabWidth));
break;
}
if (mAttachNamespaces)
result.append("--attach-namespaces");
if (mAttachClasses)
result.append("--attach-classes");
if (mAttachInlines)
result.append("--attach-inlines");
if (mAttachExternC)
result.append("--attach-extern-c");
if (mAttachClosingWhile)
result.append("--attach-closing-while");
if (mIndentClasses)
result.append("--indent-classes");
if (mIndentModifiers)
result.append("--indent-modifiers");
if (mIndentSwitches)
result.append("--indent-switches");
if (mIndentCases)
result.append("--indent-cases");
if (mIndentNamespaces)
result.append("--indent-namespaces");
if (mIndentAfterParens)
result.append("--indent-after-parens");
if (mIndentContinuation!=1)
result.append(QString("--indent-continuation=%1").arg(mIndentContinuation));
if (mIndentLabels)
result.append("--indent-labels");
if (mIndentPreprocBlock)
result.append("--indent-preproc-block");
if (mIndentPreprocCond)
result.append("--indent-preproc-cond");
if (mIndentPreprocDefine)
result.append("--indent-preproc-define");
if (mIndentCol1Comments)
result.append("--indent-col1-comments");
if (mMinConditionalIndent!=2)
result.append(QString("--min-conditional-indent=%1").arg(mMinConditionalIndent));
if (mMaxContinuationIndent!=40)
result.append(QString("--max-continuation-indent=%1").arg(mMaxContinuationIndent));
if (mBreakBlocks)
result.append("--break-blocks");
if (mBreakBlocksAll)
result.append("--break-blocks=all");
if (mPadOper)
result.append("--pad-oper");
if (mPadComma)
result.append("--pad-comma");
if (mPadParen)
result.append("--pad-paren");
if (mPadParenOut)
result.append("--pad-paren-out");
if (mPadFirstParenOut)
result.append("--pad-first-paren-out");
if (mPadParenIn)
result.append("--pad-paren-in");
if (mPadHeader)
result.append("--pad-header");
if (mUnpadParen)
result.append("--unpad-paren");
if (mDeleteEmptyLines)
result.append("--delete-empty-lines");
if (mDeleteMultipleEmptyLines)
result.append("--delete-multiple-empty-lines");
if (mFillEmptyLines)
result.append("--fill-empty-lines");
switch(mAlignPointerStyle) {
case FormatterOperatorAlign::foaNone:
break;
case FormatterOperatorAlign::foaType:
result.append("--align-pointer=type");
break;
case FormatterOperatorAlign::foaMiddle:
result.append("--align-pointer=middle");
break;
case FormatterOperatorAlign::foaName:
result.append("--align-pointer=name");
break;
}
switch(mAlignReferenceStyle) {
case FormatterOperatorAlign::foaNone:
break;
case FormatterOperatorAlign::foaType:
result.append("--align-reference=type");
break;
case FormatterOperatorAlign::foaMiddle:
result.append("--align-reference=middle");
break;
case FormatterOperatorAlign::foaName:
result.append("--align-reference=name");
break;
}
if (mBreakClosingBraces)
result.append("--break-closing-braces");
if (mBreakElseIf)
result.append("--break-elseifs");
if (mBreakOneLineHeaders)
result.append("--break-one-line-headers");
if (mAddBraces)
result.append("--add-braces");
if (mAddOneLineBraces)
result.append("--add-one-line-braces");
if (mRemoveBraces)
result.append("--remove-braces");
if (mBreakReturnType)
result.append("--break-return-type");
if (mBreakReturnTypeDecl)
result.append("--break-return-type-decl");
if (mAttachReturnType)
result.append("--attach-return-type");
if (mAttachReturnTypeDecl)
result.append("--attach-return-type-decl");
if (mKeepOneLineBlocks)
result.append("--keep-one-line-blocks");
if (mKeepOneLineStatements)
result.append("--keep-one-line-statements");
if (mConvertTabs)
result.append("--convert-tabs");
if (mCloseTemplates)
result.append("--close-templates");
if (mRemoveCommentPrefix)
result.append("--remove-comment-prefix");
if (mBreakMaxCodeLength) {
result.append(QString("--max-code-length=%1").arg(mMaxCodeLength));
if (mBreakAfterLogical)
result.append("--break-after-logical");
}
return result;
}
int Settings::CodeFormatter::indentStyle() const int Settings::CodeFormatter::indentStyle() const
{ {
return mIndentStyle; return mIndentStyle;

View File

@ -468,6 +468,7 @@ public:
class CodeFormatter: public _Base { class CodeFormatter: public _Base {
public: public:
explicit CodeFormatter(Settings* settings); explicit CodeFormatter(Settings* settings);
QStringList getArguments();
int braceStyle() const; int braceStyle() const;
void setBraceStyle(int newBraceStyle); void setBraceStyle(int newBraceStyle);

View File

@ -11,7 +11,8 @@ FormatterGeneralWidget::FormatterGeneralWidget(const QString& name, const QStrin
connect(ui->cbBraceStyle, QOverload<int>::of(&QComboBox::currentIndexChanged), connect(ui->cbBraceStyle, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &FormatterGeneralWidget::onBraceStyleChanged); this, &FormatterGeneralWidget::onBraceStyleChanged);
ui->editDemo->setReadOnly(true); ui->editDemo->setReadOnly(true);
ui->editDemo->lines()->setText("int test;"); connect(this, &SettingsWidget::settingsChanged,
this, &FormatterGeneralWidget::updateDemo);
} }
FormatterGeneralWidget::~FormatterGeneralWidget() FormatterGeneralWidget::~FormatterGeneralWidget()
@ -30,7 +31,13 @@ void FormatterGeneralWidget::onBraceStyleChanged()
void FormatterGeneralWidget::doLoad() void FormatterGeneralWidget::doLoad()
{ {
Settings::CodeFormatter& format = pSettings->codeFormatter(); Settings::CodeFormatter& format = pSettings->codeFormatter();
ui->cbBraceStyle->setCurrentIndex(format.braceStyle()); for (int i=0;i<mStylesModel.rowCount(QModelIndex());i++) {
PFormatterStyleItem item = mStylesModel.getStyle(i);
if (item->style == format.braceStyle()) {
ui->cbBraceStyle->setCurrentIndex(i);
break;
}
}
if (format.indentStyle() == FormatterIndentType::fitSpace) { if (format.indentStyle() == FormatterIndentType::fitSpace) {
ui->rbIndentSpaces->setChecked(true); ui->rbIndentSpaces->setChecked(true);
} else { } else {
@ -115,87 +122,13 @@ void FormatterGeneralWidget::doLoad()
ui->chkBreakMaxCodeLength->setChecked(format.breakMaxCodeLength()); ui->chkBreakMaxCodeLength->setChecked(format.breakMaxCodeLength());
ui->spinMaxCodeLength->setValue(format.maxCodeLength()); ui->spinMaxCodeLength->setValue(format.maxCodeLength());
ui->chkBreakAfterLogical->setChecked(format.breakAfterLogical()); ui->chkBreakAfterLogical->setChecked(format.breakAfterLogical());
updateDemo();
} }
void FormatterGeneralWidget::doSave() void FormatterGeneralWidget::doSave()
{ {
Settings::CodeFormatter& format = pSettings->codeFormatter(); Settings::CodeFormatter& format = pSettings->codeFormatter();
if (ui->cbBraceStyle->currentIndex()>0) updateCodeFormatter(format);
format.setBraceStyle(ui->cbBraceStyle->currentIndex());
if (ui->rbIndentSpaces) {
format.setIndentStyle(FormatterIndentType::fitSpace);
} else {
format.setIndentStyle(FormatterIndentType::fitTab);
}
format.setTabWidth(ui->spinTabSize->value());
format.setAttachNamespaces(ui->chkAttachNamespaces->isChecked());
format.setAttachClasses(ui->chkAttachClasses->isChecked());
format.setAttachInlines(ui->chkAttachInline->isChecked());
format.setAttachExternC(ui->chkAttachExternC->isChecked());
format.setAttachClosingWhile(ui->chkAttachClosingWhile->isChecked());
format.setIndentClasses(ui->chkIndentClasses->isChecked());
format.setIndentModifiers(ui->chkIndentModifiers->isChecked());
format.setIndentSwitches(ui->chkIndentSwiches->isChecked());
format.setIndentCases(ui->chkIndentCases->isChecked());
format.setIndentNamespaces(ui->chkIndentNamespaces->isChecked());
format.setIndentAfterParens(ui->chkIndentAfterParens->isChecked());
format.setIndentContinuation(ui->spinIndentContinuation->value());
format.setIndentLabels(ui->chkIndentLabels->isChecked());
format.setIndentPreprocBlock(ui->chkIndentPreprocBlock->isChecked());
format.setIndentPreprocCond(ui->chkIndentPreprocCond->isChecked());
format.setIndentPreprocDefine(ui->chkIndentPreprocDefine->isChecked());
format.setIndentCol1Comments(ui->chkIndentCol1Comments->isChecked());
format.setMinConditionalIndent(ui->spinMinConditionalIndent->value());
format.setMaxContinuationIndent(ui->spinMaxContinuationIndent->value());
format.setBreakBlocks(ui->chkBreakBlocks->isChecked());
format.setBreakBlocksAll(ui->chkBreakBlocksAll->isChecked());
format.setPadOper(ui->chkPadOper->isChecked());
format.setPadComma(ui->chkPadComma->isChecked());
format.setPadParen(ui->chkPadParen->isChecked());
format.setPadParenOut(ui->chkPadParenOut->isChecked());
format.setPadFirstParenOut(ui->chkPadFirstParenOut->isChecked());
format.setPadParenIn(ui->chkPadParenIn->isChecked());
format.setPadHeader(ui->chkPadHeader->isChecked());
format.setUnpadParen(ui->chkUnpadParen->isChecked());
format.setDeleteEmptyLines(ui->chkDeleteEmptyLines->isChecked());
format.setDeleteMultipleEmptyLines(ui->chkDeleteMultipleEmptyLines->isChecked());
format.setFillEmptyLines(ui->chkFillEmptyLines->isChecked());
if (ui->rbAlignPointNone->isChecked()) {
format.setAlignPointerStyle(FormatterOperatorAlign::foaNone);
} else if (ui->rbAlignPointType->isChecked()) {
format.setAlignPointerStyle(FormatterOperatorAlign::foaType);
} else if (ui->rbAlignPointerMiddle->isChecked()) {
format.setAlignPointerStyle(FormatterOperatorAlign::foaMiddle);
} else if (ui->rbAlignPointerName->isChecked()) {
format.setAlignPointerStyle(FormatterOperatorAlign::foaName);
}
if (ui->rbAlignReferenceNone->isChecked()) {
format.setAlignReferenceStyle(FormatterOperatorAlign::foaNone);
} else if (ui->rbAlignReferenceType->isChecked()) {
format.setAlignReferenceStyle(FormatterOperatorAlign::foaType);
} else if (ui->rbAlignReferenceMiddle->isChecked()) {
format.setAlignReferenceStyle(FormatterOperatorAlign::foaMiddle);
} else if (ui->rbAlignReferenceName->isChecked()) {
format.setAlignReferenceStyle(FormatterOperatorAlign::foaName);
}
format.setBreakClosingBraces(ui->chkBreakClosingBraces->isChecked());
format.setBreakElseIf(ui->chkBreakElseIf->isChecked());
format.setBreakOneLineHeaders(ui->chkBreakOneLineHeaders->isChecked());
format.setAddBraces(ui->chkAddBraces->isChecked());
format.setAddOneLineBraces(ui->chkAddOneLineBraces->isChecked());
format.setRemoveBraces(ui->chkRemoveBraces->isChecked());
format.setBreakReturnType(ui->chkBreakReturnType->isChecked());
format.setBreakReturnTypeDecl(ui->chkBreakReturnTypeDecl->isChecked());
format.setAttachReturnType(ui->chkAttachReturnType->isChecked());
format.setAttachReturnTypeDecl(ui->chkAttachReturnTypeDecl->isChecked());
format.setKeepOneLineBlocks(ui->chkKeepOneLineBlocks->isChecked());
format.setKeepOneLineStatements(ui->chkKeepOneLineStatements->isChecked());
format.setConvertTabs(ui->chkConvertTabs->isChecked());
format.setCloseTemplates(ui->chkCloseTemplates->isChecked());
format.setRemoveCommentPrefix(ui->chkRemoveCommentPrefix->isChecked());
format.setBreakMaxCodeLength(ui->chkBreakMaxCodeLength->isChecked());
format.setMaxCodeLength(ui->spinMaxCodeLength->value());
format.setBreakAfterLogical(ui->chkBreakAfterLogical->isChecked());
format.save(); format.save();
} }
@ -216,13 +149,13 @@ FormatterStyleModel::FormatterStyleModel(QObject *parent):QAbstractListModel(par
mStyles.append( mStyles.append(
std::make_shared<FormatterStyleItem>( std::make_shared<FormatterStyleItem>(
tr("Java"), tr("Java"),
tr("Broken braces."), tr("Attached braces."),
FormatterBraceStyle::fbsJava) FormatterBraceStyle::fbsJava)
); );
mStyles.append( mStyles.append(
std::make_shared<FormatterStyleItem>( std::make_shared<FormatterStyleItem>(
tr("K&R"), tr("K&R"),
tr("Broken braces."), tr("Linux braces."),
FormatterBraceStyle::fbsKR) FormatterBraceStyle::fbsKR)
); );
mStyles.append( mStyles.append(
@ -267,7 +200,7 @@ FormatterStyleModel::FormatterStyleModel(QObject *parent):QAbstractListModel(par
std::make_shared<FormatterStyleItem>( std::make_shared<FormatterStyleItem>(
tr("Horstmann"), tr("Horstmann"),
tr("Run-in braces, indented switches."), tr("Run-in braces, indented switches."),
FormatterBraceStyle::fbsHorstman) FormatterBraceStyle::fbsHorstmann)
); );
mStyles.append( mStyles.append(
std::make_shared<FormatterStyleItem>( std::make_shared<FormatterStyleItem>(
@ -362,3 +295,101 @@ void FormatterGeneralWidget::on_chkBreakMaxCodeLength_stateChanged(int)
ui->chkBreakAfterLogical->setEnabled(ui->chkBreakMaxCodeLength->isChecked()); ui->chkBreakAfterLogical->setEnabled(ui->chkBreakMaxCodeLength->isChecked());
} }
void FormatterGeneralWidget::updateDemo()
{
QFile file(":/codes/formatdemo.cpp");
if (!file.open(QFile::ReadOnly))
return;
QByteArray content = file.readAll();
Settings::CodeFormatter formatter(nullptr);
updateCodeFormatter(formatter);
QByteArray newContent = runAndGetOutput("astyle.exe",
pSettings->dirs().app(),
formatter.getArguments(),
content);
ui->editDemo->lines()->setText(newContent);
}
void FormatterGeneralWidget::updateCodeFormatter(Settings::CodeFormatter &format)
{
PFormatterStyleItem item = mStylesModel.getStyle(ui->cbBraceStyle->currentIndex());
if (item)
format.setBraceStyle(item->style);
if (ui->rbIndentSpaces) {
format.setIndentStyle(FormatterIndentType::fitSpace);
} else {
format.setIndentStyle(FormatterIndentType::fitTab);
}
format.setTabWidth(ui->spinTabSize->value());
format.setAttachNamespaces(ui->chkAttachNamespaces->isChecked());
format.setAttachClasses(ui->chkAttachClasses->isChecked());
format.setAttachInlines(ui->chkAttachInline->isChecked());
format.setAttachExternC(ui->chkAttachExternC->isChecked());
format.setAttachClosingWhile(ui->chkAttachClosingWhile->isChecked());
format.setIndentClasses(ui->chkIndentClasses->isChecked());
format.setIndentModifiers(ui->chkIndentModifiers->isChecked());
format.setIndentSwitches(ui->chkIndentSwiches->isChecked());
format.setIndentCases(ui->chkIndentCases->isChecked());
format.setIndentNamespaces(ui->chkIndentNamespaces->isChecked());
format.setIndentAfterParens(ui->chkIndentAfterParens->isChecked());
format.setIndentContinuation(ui->spinIndentContinuation->value());
format.setIndentLabels(ui->chkIndentLabels->isChecked());
format.setIndentPreprocBlock(ui->chkIndentPreprocBlock->isChecked());
format.setIndentPreprocCond(ui->chkIndentPreprocCond->isChecked());
format.setIndentPreprocDefine(ui->chkIndentPreprocDefine->isChecked());
format.setIndentCol1Comments(ui->chkIndentCol1Comments->isChecked());
format.setMinConditionalIndent(ui->spinMinConditionalIndent->value());
format.setMaxContinuationIndent(ui->spinMaxContinuationIndent->value());
format.setBreakBlocks(ui->chkBreakBlocks->isChecked());
format.setBreakBlocksAll(ui->chkBreakBlocksAll->isChecked());
format.setPadOper(ui->chkPadOper->isChecked());
format.setPadComma(ui->chkPadComma->isChecked());
format.setPadParen(ui->chkPadParen->isChecked());
format.setPadParenOut(ui->chkPadParenOut->isChecked());
format.setPadFirstParenOut(ui->chkPadFirstParenOut->isChecked());
format.setPadParenIn(ui->chkPadParenIn->isChecked());
format.setPadHeader(ui->chkPadHeader->isChecked());
format.setUnpadParen(ui->chkUnpadParen->isChecked());
format.setDeleteEmptyLines(ui->chkDeleteEmptyLines->isChecked());
format.setDeleteMultipleEmptyLines(ui->chkDeleteMultipleEmptyLines->isChecked());
format.setFillEmptyLines(ui->chkFillEmptyLines->isChecked());
if (ui->rbAlignPointNone->isChecked()) {
format.setAlignPointerStyle(FormatterOperatorAlign::foaNone);
} else if (ui->rbAlignPointType->isChecked()) {
format.setAlignPointerStyle(FormatterOperatorAlign::foaType);
} else if (ui->rbAlignPointerMiddle->isChecked()) {
format.setAlignPointerStyle(FormatterOperatorAlign::foaMiddle);
} else if (ui->rbAlignPointerName->isChecked()) {
format.setAlignPointerStyle(FormatterOperatorAlign::foaName);
}
if (ui->rbAlignReferenceNone->isChecked()) {
format.setAlignReferenceStyle(FormatterOperatorAlign::foaNone);
} else if (ui->rbAlignReferenceType->isChecked()) {
format.setAlignReferenceStyle(FormatterOperatorAlign::foaType);
} else if (ui->rbAlignReferenceMiddle->isChecked()) {
format.setAlignReferenceStyle(FormatterOperatorAlign::foaMiddle);
} else if (ui->rbAlignReferenceName->isChecked()) {
format.setAlignReferenceStyle(FormatterOperatorAlign::foaName);
}
format.setBreakClosingBraces(ui->chkBreakClosingBraces->isChecked());
format.setBreakElseIf(ui->chkBreakElseIf->isChecked());
format.setBreakOneLineHeaders(ui->chkBreakOneLineHeaders->isChecked());
format.setAddBraces(ui->chkAddBraces->isChecked());
format.setAddOneLineBraces(ui->chkAddOneLineBraces->isChecked());
format.setRemoveBraces(ui->chkRemoveBraces->isChecked());
format.setBreakReturnType(ui->chkBreakReturnType->isChecked());
format.setBreakReturnTypeDecl(ui->chkBreakReturnTypeDecl->isChecked());
format.setAttachReturnType(ui->chkAttachReturnType->isChecked());
format.setAttachReturnTypeDecl(ui->chkAttachReturnTypeDecl->isChecked());
format.setKeepOneLineBlocks(ui->chkKeepOneLineBlocks->isChecked());
format.setKeepOneLineStatements(ui->chkKeepOneLineStatements->isChecked());
format.setConvertTabs(ui->chkConvertTabs->isChecked());
format.setCloseTemplates(ui->chkCloseTemplates->isChecked());
format.setRemoveCommentPrefix(ui->chkRemoveCommentPrefix->isChecked());
format.setBreakMaxCodeLength(ui->chkBreakMaxCodeLength->isChecked());
format.setMaxCodeLength(ui->spinMaxCodeLength->value());
format.setBreakAfterLogical(ui->chkBreakAfterLogical->isChecked());
}

View File

@ -5,6 +5,7 @@
#include <QWidget> #include <QWidget>
#include "settingswidget.h" #include "settingswidget.h"
#include "../utils.h" #include "../utils.h"
#include "../settings.h"
namespace Ui { namespace Ui {
class FormatterGeneralWidget; class FormatterGeneralWidget;
@ -46,6 +47,10 @@ private slots:
void on_chkBreakMaxCodeLength_stateChanged(int arg1); void on_chkBreakMaxCodeLength_stateChanged(int arg1);
void updateDemo();
private:
void updateCodeFormatter(Settings::CodeFormatter& format);
private: private:
Ui::FormatterGeneralWidget *ui; Ui::FormatterGeneralWidget *ui;
FormatterStyleModel mStylesModel; FormatterStyleModel mStylesModel;

View File

@ -850,6 +850,12 @@
</item> </item>
<item> <item>
<widget class="Editor" name="editDemo"> <widget class="Editor" name="editDemo">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
@ -864,22 +870,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
<customwidgets> <customwidgets>
@ -893,7 +883,7 @@
<resources/> <resources/>
<connections/> <connections/>
<buttongroups> <buttongroups>
<buttongroup name="pointerBtnGroup"/>
<buttongroup name="referenceBtnGroup"/> <buttongroup name="referenceBtnGroup"/>
<buttongroup name="pointerBtnGroup"/>
</buttongroups> </buttongroups>
</ui> </ui>

View File

@ -92,7 +92,7 @@ bool isGreenEdition()
return gIsGreenEdition; return gIsGreenEdition;
} }
QByteArray runAndGetOutput(const QString &cmd, const QString& workingDir, const QStringList& arguments, bool inheritEnvironment) QByteArray runAndGetOutput(const QString &cmd, const QString& workingDir, const QStringList& arguments, const QByteArray &inputContent, bool inheritEnvironment)
{ {
QProcess process; QProcess process;
QByteArray result; QByteArray result;
@ -111,6 +111,9 @@ QByteArray runAndGetOutput(const QString &cmd, const QString& workingDir, const
result.append(process.readAllStandardOutput()); result.append(process.readAllStandardOutput());
}); });
process.start(cmd,arguments); process.start(cmd,arguments);
if (!inputContent.isEmpty()) {
process.write(inputContent);
}
process.closeWriteChannel(); process.closeWriteChannel();
process.waitForFinished(); process.waitForFinished();
return result; return result;

View File

@ -63,7 +63,7 @@ enum FormatterBraceStyle {
fbsRatliff, fbsRatliff,
fbsGNU, fbsGNU,
fbsLinux, fbsLinux,
fbsHorstman, fbsHorstmann,
fbs1TBS, fbs1TBS,
fbsGoogle, fbsGoogle,
fbsMozilla, fbsMozilla,
@ -111,7 +111,9 @@ const QByteArray GuessTextEncoding(const QByteArray& text);
bool isTextAllAscii(const QString& text); bool isTextAllAscii(const QString& text);
QByteArray runAndGetOutput(const QString& cmd, const QString& workingDir, const QStringList& arguments, bool inheritEnvironment = false); QByteArray runAndGetOutput(const QString& cmd, const QString& workingDir, const QStringList& arguments,
const QByteArray& inputContent = QByteArray(),
bool inheritEnvironment = false);
bool isNonPrintableAsciiChar(char ch); bool isNonPrintableAsciiChar(char ch);