Skip to content

Commit d5a5df7

Browse files
committed
GUI: Add About-dialog.
Replace messagebox containing about-text with dialog. About-dialog must contain copyright information.
1 parent 62741bf commit d5a5df7

4 files changed

Lines changed: 99 additions & 9 deletions

File tree

gui/aboutdialog.cpp

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Cppcheck - A tool for static C/C++ code analysis
3+
* Copyright (C) 2007-2009 Daniel Marjamäki and Cppcheck team.
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/
17+
*/
18+
#include <QDialog>
19+
#include <QVBoxLayout>
20+
#include <QHBoxLayout>
21+
#include <QLabel>
22+
#include <QPushButton>
23+
#include "aboutdialog.h"
24+
25+
AboutDialog::AboutDialog(const QString &version, QWidget *parent)
26+
: QDialog(parent)
27+
, mVersion(version)
28+
{
29+
setWindowTitle(tr("About cppcheck"));
30+
QVBoxLayout *mainLayout = new QVBoxLayout(this);
31+
QHBoxLayout *btnLayout = new QHBoxLayout(this);
32+
33+
QLabel *name = new QLabel(tr("Cppcheck - A tool for static C/C++ code analysis."));
34+
QLabel *ver = new QLabel(QString(tr("Version %1")).arg(mVersion));
35+
QLabel *copy = new QLabel(("Copyright (C) 2007-2009 Daniel Marjamäki and cppcheck team."));
36+
copy->setWordWrap(true);
37+
QLabel *gpl = new QLabel(tr("This program is licensed under the terms " \
38+
"of the GNU General Public License version 3"));
39+
gpl->setWordWrap(true);
40+
QPushButton *quit = new QPushButton(tr("Close"));
41+
42+
mainLayout->addWidget(name);
43+
mainLayout->addWidget(ver);
44+
mainLayout->addWidget(copy);
45+
mainLayout->addWidget(gpl);
46+
mainLayout->addStretch();
47+
48+
mainLayout->addLayout(btnLayout);
49+
btnLayout->addStretch();
50+
btnLayout->addWidget(quit);
51+
52+
connect(quit, SIGNAL(clicked()), this, SLOT(close()));
53+
}

gui/aboutdialog.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Cppcheck - A tool for static C/C++ code analysis
3+
* Copyright (C) 2007-2009 Daniel Marjamäki and Cppcheck team.
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/
17+
*/
18+
19+
#ifndef _ABOUT_DIALOG_H_
20+
#define _ABOUT_DIALOG_H_
21+
22+
#include <QDialog>
23+
#include <QString>
24+
25+
class QWidget;
26+
27+
/**
28+
* @brief About dialog
29+
*
30+
*/
31+
class AboutDialog : public QDialog
32+
{
33+
Q_OBJECT
34+
public:
35+
AboutDialog(const QString &version, QWidget *parent = 0);
36+
37+
private:
38+
QString mVersion;
39+
};
40+
41+
#endif // _ABOUT_DIALOG_H_

gui/gui.pro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ HEADERS += mainwindow.h \
2626
threadhandler.h \
2727
applicationlist.h \
2828
applicationdialog.h \
29+
aboutdialog.h \
2930
../src/checkautovariables.h \
3031
../src/checkdangerousfunctions.h \
3132
../src/checkheaders.h \
@@ -60,6 +61,7 @@ SOURCES += main.cpp \
6061
settingsdialog.cpp \
6162
applicationlist.cpp \
6263
applicationdialog.cpp \
64+
aboutdialog.cpp \
6365
../src/checkautovariables.cpp \
6466
../src/checkdangerousfunctions.cpp \
6567
../src/checkmemoryleak.cpp \

gui/mainwindow.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <QMenuBar>
2525
#include <QMessageBox>
2626
#include <QToolBar>
27+
#include "aboutdialog.h"
2728
#include "../src/filelister.h"
2829
#include "../src/cppcheckexecutor.h"
2930

@@ -385,15 +386,8 @@ void MainWindow::About()
385386
QString version = check.parseFromArgs(2, argv).c_str();
386387
version.replace("Cppcheck ", "");
387388

388-
QMessageBox msgBox;
389-
msgBox.setWindowTitle(tr("About..."));
390-
msgBox.setText(QString("Cppcheck - A tool for static C/C++ code analysis.\nVersion %1\n\n" \
391-
"This program is licensed under the terms\n" \
392-
"of the GNU General Public License version 3\n" \
393-
"Available online under:\n" \
394-
"http://www.gnu.org/licenses/gpl-3.0.html\n\nSee AUTHORS file for the list of developers." \
395-
).arg(version));
396-
msgBox.exec();
389+
AboutDialog *dlg = new AboutDialog(version, this);
390+
dlg->show();
397391
}
398392

399393

0 commit comments

Comments
 (0)