From d60e27b4cfca33c1bfd5c7537a83e003f3a84d7e Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Wed, 2 May 2012 15:37:21 +0200 Subject: [PATCH] Add about dialog. --- src/CMakeLists.txt | 3 +++ src/gui/AboutDialog.cpp | 40 ++++++++++++++++++++++++++++++ src/gui/AboutDialog.h | 40 ++++++++++++++++++++++++++++++ src/gui/AboutDialog.ui | 55 +++++++++++++++++++++++++++++++++++++++++ src/gui/MainWindow.cpp | 8 ++++++ src/gui/MainWindow.h | 1 + 6 files changed, 147 insertions(+) create mode 100644 src/gui/AboutDialog.cpp create mode 100644 src/gui/AboutDialog.h create mode 100644 src/gui/AboutDialog.ui diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ef1acd911..d446d58da 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -49,6 +49,7 @@ set(keepassx_SOURCES format/KeePass2Writer.cpp format/KeePass2XmlReader.cpp format/KeePass2XmlWriter.cpp + gui/AboutDialog.cpp gui/ChangeMasterKeyWidget.cpp gui/DatabaseOpenDialog.cpp gui/DatabaseSettingsWidget.cpp @@ -82,6 +83,7 @@ set(keepassx_MOC core/EntryAttributes.h core/Group.h core/Metadata.h + gui/AboutDialog.h gui/ChangeMasterKeyWidget.h gui/DatabaseOpenDialog.h gui/DatabaseSettingsWidget.h @@ -104,6 +106,7 @@ set(keepassx_MOC ) set(keepassx_FORMS + gui/AboutDialog.ui gui/ChangeMasterKeyWidget.ui gui/DatabaseOpenDialog.ui gui/DatabaseSettingsWidget.ui diff --git a/src/gui/AboutDialog.cpp b/src/gui/AboutDialog.cpp new file mode 100644 index 000000000..b716b9939 --- /dev/null +++ b/src/gui/AboutDialog.cpp @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2012 Felix Geyer + * + * 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 2 or (at your option) + * version 3 of the License. + * + * 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 "AboutDialog.h" +#include "ui_AboutDialog.h" + +#include "config-keepassx.h" + +AboutDialog::AboutDialog(QWidget* parent) + : QDialog(parent) + , m_ui(new Ui::AboutDialog()) +{ + m_ui->setupUi(this); + m_ui->nameLabel->setText(m_ui->nameLabel->text() + " " + KEEPASSX_VERSION); + QFont nameLabelFont = m_ui->nameLabel->font(); + nameLabelFont.setBold(true); + nameLabelFont.setPointSize(nameLabelFont.pointSize() + 4); + m_ui->nameLabel->setFont(nameLabelFont); + + setAttribute(Qt::WA_DeleteOnClose); + connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(close())); +} + +AboutDialog::~AboutDialog() +{ +} diff --git a/src/gui/AboutDialog.h b/src/gui/AboutDialog.h new file mode 100644 index 000000000..369a40208 --- /dev/null +++ b/src/gui/AboutDialog.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2012 Felix Geyer + * + * 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 2 or (at your option) + * version 3 of the License. + * + * 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 . + */ + +#ifndef KEEPASSX_ABOUTDIALOG_H +#define KEEPASSX_ABOUTDIALOG_H + +#include +#include + +namespace Ui { + class AboutDialog; +} + +class AboutDialog : public QDialog +{ + Q_OBJECT + +public: + explicit AboutDialog(QWidget* parent = 0); + ~AboutDialog(); + +private: + QScopedPointer m_ui; +}; + +#endif // KEEPASSX_ABOUTDIALOG_H diff --git a/src/gui/AboutDialog.ui b/src/gui/AboutDialog.ui new file mode 100644 index 000000000..aa0f2033c --- /dev/null +++ b/src/gui/AboutDialog.ui @@ -0,0 +1,55 @@ + + + AboutDialog + + + + 0 + 0 + 392 + 208 + + + + About KeePassX + + + + + + KeePassX + + + + + + + <a href="http://www.keepassx.org/">http://www.keepassx.org/</a> + + + true + + + + + + + KeePassX is distributed under the term of the GNU General Public License (GPL) version 3 or (at your option) version 3. + + + true + + + + + + + QDialogButtonBox::Close + + + + + + + + diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index fd8efd251..990b7d916 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -23,6 +23,7 @@ #include "core/Database.h" #include "core/DataPath.h" #include "core/Metadata.h" +#include "gui/AboutDialog.h" #include "gui/DatabaseWidget.h" #include "gui/EntryView.h" @@ -69,6 +70,7 @@ MainWindow::MainWindow() connect(m_ui->actionGroupDelete, SIGNAL(triggered()), m_ui->tabWidget, SLOT(deleteGroup())); connect(m_ui->actionQuit, SIGNAL(triggered()), SLOT(close())); + connect(m_ui->actionAbout, SIGNAL(triggered()), SLOT(showAboutDialog())); } MainWindow::~MainWindow() @@ -162,6 +164,12 @@ void MainWindow::updateWindowTitle() } } +void MainWindow::showAboutDialog() +{ + AboutDialog* aboutDialog = new AboutDialog(this); + aboutDialog->show(); +} + void MainWindow::closeEvent(QCloseEvent *event) { if (!m_ui->tabWidget->closeAllDatabases()) { event->ignore(); diff --git a/src/gui/MainWindow.h b/src/gui/MainWindow.h index 784e0f955..1d9e13b52 100644 --- a/src/gui/MainWindow.h +++ b/src/gui/MainWindow.h @@ -41,6 +41,7 @@ protected: private Q_SLOTS: void setMenuActionState(DatabaseWidget::Mode mode = DatabaseWidget::None); void updateWindowTitle(); + void showAboutDialog(); private: const QScopedPointer m_ui;