From d5a5df7fe6021b89963aefeba4dea3e915b9e77d Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Thu, 4 Jun 2009 15:35:41 +0300 Subject: [PATCH] GUI: Add About-dialog. Replace messagebox containing about-text with dialog. About-dialog must contain copyright information. --- gui/aboutdialog.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++++ gui/aboutdialog.h | 41 +++++++++++++++++++++++++++++++++++ gui/gui.pro | 2 ++ gui/mainwindow.cpp | 12 +++------- 4 files changed, 99 insertions(+), 9 deletions(-) create mode 100644 gui/aboutdialog.cpp create mode 100644 gui/aboutdialog.h diff --git a/gui/aboutdialog.cpp b/gui/aboutdialog.cpp new file mode 100644 index 000000000..a899cde16 --- /dev/null +++ b/gui/aboutdialog.cpp @@ -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 +#include +#include +#include +#include +#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())); +} diff --git a/gui/aboutdialog.h b/gui/aboutdialog.h new file mode 100644 index 000000000..4c714ffe7 --- /dev/null +++ b/gui/aboutdialog.h @@ -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 +#include + +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_ diff --git a/gui/gui.pro b/gui/gui.pro index 83ed71f56..cb59b0804 100644 --- a/gui/gui.pro +++ b/gui/gui.pro @@ -26,6 +26,7 @@ HEADERS += mainwindow.h \ threadhandler.h \ applicationlist.h \ applicationdialog.h \ + aboutdialog.h \ ../src/checkautovariables.h \ ../src/checkdangerousfunctions.h \ ../src/checkheaders.h \ @@ -60,6 +61,7 @@ SOURCES += main.cpp \ settingsdialog.cpp \ applicationlist.cpp \ applicationdialog.cpp \ + aboutdialog.cpp \ ../src/checkautovariables.cpp \ ../src/checkdangerousfunctions.cpp \ ../src/checkmemoryleak.cpp \ diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index b17e70121..b7f04b269 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -24,6 +24,7 @@ #include #include #include +#include "aboutdialog.h" #include "../src/filelister.h" #include "../src/cppcheckexecutor.h" @@ -385,15 +386,8 @@ void MainWindow::About() QString version = check.parseFromArgs(2, argv).c_str(); version.replace("Cppcheck ", ""); - QMessageBox msgBox; - msgBox.setWindowTitle(tr("About...")); - 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(); + AboutDialog *dlg = new AboutDialog(version, this); + dlg->show(); }