2323#include < QMenu>
2424#include < QDirIterator>
2525#include < QMenuBar>
26+ #include < QMessageBox>
2627#include " ../src/filelister.h"
27-
28+ # include " ../src/cppcheckexecutor.h "
2829
2930MainWindow::MainWindow () :
30- mSettings(tr(" CppCheck " ), tr(" CppCheck -GUI" )),
31+ mSettings(tr(" Cppcheck " ), tr(" Cppcheck -GUI" )),
3132 mActionExit(tr(" E&xit" ), this),
3233 mActionCheckFiles(tr(" &Check files(s)" ), this),
3334 mActionClearResults(tr(" Clear &results" ), this),
3435 mActionReCheck(tr(" Recheck files" ), this),
3536 mActionCheckDirectory(tr(" Check &directory" ), this),
3637 mActionSettings(tr(" &Settings" ), this),
37- mActionShowAll(tr(" Show &more errors " ), this),
38+ mActionShowAll(tr(" show possible false positives " ), this),
3839 mActionShowSecurity(tr(" Show &security errors" ), this),
3940 mActionShowStyle(tr(" Show s&tyle errors" ), this),
4041 mActionShowUnused(tr(" Show errors on &unused functions" ), this),
4142 mActionShowErrors(tr(" Show &common errors" ), this),
4243 mActionShowCheckAll(tr(" Check all" ), this),
4344 mActionShowUncheckAll(tr(" Uncheck all" ), this),
45+ mActionAbout(tr(" About" ), this),
4446 mResults(mSettings , mApplications )
4547{
4648 QMenu *menu = menuBar ()->addMenu (tr (" &File" ));
@@ -69,6 +71,9 @@ MainWindow::MainWindow() :
6971 QMenu *menuprogram = menuBar ()->addMenu (tr (" &Program" ));
7072 menuprogram->addAction (&mActionSettings );
7173
74+ QMenu *menuHelp = menuBar ()->addMenu (tr (" &Help" ));
75+ menuHelp->addAction (&mActionAbout );
76+
7277 setCentralWidget (&mResults );
7378
7479
@@ -87,10 +92,13 @@ MainWindow::MainWindow() :
8792 connect (&mActionShowUncheckAll , SIGNAL (triggered ()), this , SLOT (UncheckAll ()));
8893
8994 connect (&mActionReCheck , SIGNAL (triggered ()), this , SLOT (ReCheck ()));
95+
96+ connect (&mActionAbout , SIGNAL (triggered ()), this , SLOT (About ()));
97+
9098 connect (&mThread , SIGNAL (Done ()), this , SLOT (CheckDone ()));
9199 LoadSettings ();
92100 mThread .Initialize (&mResults );
93- setWindowTitle (tr (" CppCheck " ));
101+ setWindowTitle (tr (" Cppcheck " ));
94102}
95103
96104MainWindow::~MainWindow ()
@@ -161,7 +169,7 @@ void MainWindow::DoCheckFiles(QFileDialog::FileMode mode)
161169 mThread .SetFiles (RemoveUnacceptedFiles (fileNames));
162170 mSettings .setValue (tr (" Check path" ), dialog.directory ().absolutePath ());
163171 EnableCheckButtons (false );
164- mThread .Check (GetCppCheckSettings (), false );
172+ mThread .Check (GetCppcheckSettings (), false );
165173 }
166174}
167175
@@ -175,7 +183,7 @@ void MainWindow::CheckDirectory()
175183 DoCheckFiles (QFileDialog::DirectoryOnly);
176184}
177185
178- Settings MainWindow::GetCppCheckSettings ()
186+ Settings MainWindow::GetCppcheckSettings ()
179187{
180188 Settings result;
181189 result._debug = false ;
@@ -188,6 +196,11 @@ Settings MainWindow::GetCppCheckSettings()
188196 result._unusedFunctions = true ;
189197 result._security = true ;
190198 result._jobs = mSettings .value (tr (" Check threads" ), 1 ).toInt ();
199+
200+ if (result._jobs <= 0 ) {
201+ result._jobs = 1 ;
202+ }
203+
191204 return result;
192205}
193206
@@ -248,7 +261,7 @@ void MainWindow::ReCheck()
248261{
249262 ClearResults ();
250263 EnableCheckButtons (false );
251- mThread .Check (GetCppCheckSettings (), true );
264+ mThread .Check (GetCppcheckSettings (), true );
252265}
253266
254267void MainWindow::ClearResults ()
@@ -316,3 +329,23 @@ void MainWindow::ToggleAllChecked(bool checked)
316329 mActionShowErrors .setChecked (checked);
317330 ShowErrors (checked);
318331}
332+
333+ void MainWindow::About ()
334+ {
335+ // TODO make a "GetVersionNumber" function to core cppcheck
336+ CppCheckExecutor exec;
337+ CppCheck check (exec);
338+ const char *argv[] = {" " ," --version" };
339+ QString version = check.parseFromArgs (2 , argv).c_str ();
340+ version.replace (" Cppcheck " ," " );
341+
342+ QMessageBox msgBox;
343+ msgBox.setWindowTitle (tr (" About..." ));
344+ msgBox.setText (QString (" Cppcheck - A tool for static C/C++ code analysis.\n Version %1\n\n " \
345+ " This program is licensed under the terms\n " \
346+ " of the GNU General Public License version 3\n " \
347+ " Available online under:\n " \
348+ " http://www.gnu.org/licenses/gpl-3.0.html\n\n See AUTHORS file for the list of developers." \
349+ ).arg (version));
350+ msgBox.exec ();
351+ }
0 commit comments