GUI: Add About-dialog.

Replace messagebox containing about-text with dialog. About-dialog must contain copyright information.
This commit is contained in:
Kimmo Varis 2009-06-04 15:35:41 +03:00
parent 62741bfd4a
commit d5a5df7fe6
4 changed files with 99 additions and 9 deletions

53
gui/aboutdialog.cpp Normal file
View File

@ -0,0 +1,53 @@
/*
* Cppcheck - A tool for static C/C++ code analysis
* Copyright (C) 2007-2009 Daniel Marjamäki and Cppcheck team.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/
*/
#include <QDialog>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QPushButton>
#include "aboutdialog.h"
AboutDialog::AboutDialog(const QString &version, QWidget *parent)
: QDialog(parent)
, mVersion(version)
{
setWindowTitle(tr("About cppcheck"));
QVBoxLayout *mainLayout = new QVBoxLayout(this);
QHBoxLayout *btnLayout = new QHBoxLayout(this);
QLabel *name = new QLabel(tr("Cppcheck - A tool for static C/C++ code analysis."));
QLabel *ver = new QLabel(QString(tr("Version %1")).arg(mVersion));
QLabel *copy = new QLabel(("Copyright (C) 2007-2009 Daniel Marjamäki and cppcheck team."));
copy->setWordWrap(true);
QLabel *gpl = new QLabel(tr("This program is licensed under the terms " \
"of the GNU General Public License version 3"));
gpl->setWordWrap(true);
QPushButton *quit = new QPushButton(tr("Close"));
mainLayout->addWidget(name);
mainLayout->addWidget(ver);
mainLayout->addWidget(copy);
mainLayout->addWidget(gpl);
mainLayout->addStretch();
mainLayout->addLayout(btnLayout);
btnLayout->addStretch();
btnLayout->addWidget(quit);
connect(quit, SIGNAL(clicked()), this, SLOT(close()));
}

41
gui/aboutdialog.h Normal file
View File

@ -0,0 +1,41 @@
/*
* Cppcheck - A tool for static C/C++ code analysis
* Copyright (C) 2007-2009 Daniel Marjamäki and Cppcheck team.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/
*/
#ifndef _ABOUT_DIALOG_H_
#define _ABOUT_DIALOG_H_
#include <QDialog>
#include <QString>
class QWidget;
/**
* @brief About dialog
*
*/
class AboutDialog : public QDialog
{
Q_OBJECT
public:
AboutDialog(const QString &version, QWidget *parent = 0);
private:
QString mVersion;
};
#endif // _ABOUT_DIALOG_H_

View File

@ -26,6 +26,7 @@ HEADERS += mainwindow.h \
threadhandler.h \ threadhandler.h \
applicationlist.h \ applicationlist.h \
applicationdialog.h \ applicationdialog.h \
aboutdialog.h \
../src/checkautovariables.h \ ../src/checkautovariables.h \
../src/checkdangerousfunctions.h \ ../src/checkdangerousfunctions.h \
../src/checkheaders.h \ ../src/checkheaders.h \
@ -60,6 +61,7 @@ SOURCES += main.cpp \
settingsdialog.cpp \ settingsdialog.cpp \
applicationlist.cpp \ applicationlist.cpp \
applicationdialog.cpp \ applicationdialog.cpp \
aboutdialog.cpp \
../src/checkautovariables.cpp \ ../src/checkautovariables.cpp \
../src/checkdangerousfunctions.cpp \ ../src/checkdangerousfunctions.cpp \
../src/checkmemoryleak.cpp \ ../src/checkmemoryleak.cpp \

View File

@ -24,6 +24,7 @@
#include <QMenuBar> #include <QMenuBar>
#include <QMessageBox> #include <QMessageBox>
#include <QToolBar> #include <QToolBar>
#include "aboutdialog.h"
#include "../src/filelister.h" #include "../src/filelister.h"
#include "../src/cppcheckexecutor.h" #include "../src/cppcheckexecutor.h"
@ -385,15 +386,8 @@ void MainWindow::About()
QString version = check.parseFromArgs(2, argv).c_str(); QString version = check.parseFromArgs(2, argv).c_str();
version.replace("Cppcheck ", ""); version.replace("Cppcheck ", "");
QMessageBox msgBox; AboutDialog *dlg = new AboutDialog(version, this);
msgBox.setWindowTitle(tr("About...")); dlg->show();
msgBox.setText(QString("Cppcheck - A tool for static C/C++ code analysis.\nVersion %1\n\n" \
"This program is licensed under the terms\n" \
"of the GNU General Public License version 3\n" \
"Available online under:\n" \
"http://www.gnu.org/licenses/gpl-3.0.html\n\nSee AUTHORS file for the list of developers." \
).arg(version));
msgBox.exec();
} }