From f3b04a88dffcda6cbe10be81d5c9613e0ab00c37 Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" Date: Mon, 24 Jun 2013 14:36:38 +0300 Subject: Add an 'About' dialog for the Qt UI The dialog is similar to the one in the GTK version Signed-off-by: Lubomir I. Ivanov Signed-off-by: Dirk Hohndel --- qt-ui/about.cpp | 39 ++++++++++++++ qt-ui/about.h | 26 ++++++++++ qt-ui/about.ui | 142 +++++++++++++++++++++++++++++++++++++++++++++++++++ qt-ui/mainwindow.cpp | 3 +- 4 files changed, 209 insertions(+), 1 deletion(-) create mode 100644 qt-ui/about.cpp create mode 100644 qt-ui/about.h create mode 100644 qt-ui/about.ui (limited to 'qt-ui') diff --git a/qt-ui/about.cpp b/qt-ui/about.cpp new file mode 100644 index 000000000..18b54b956 --- /dev/null +++ b/qt-ui/about.cpp @@ -0,0 +1,39 @@ +#include "about.h" +#include "ui_about.h" +#include "../version.h" +#include +#include +#include +#include + +SubsurfaceAbout *SubsurfaceAbout::instance() +{ + static SubsurfaceAbout *self = new SubsurfaceAbout(); + return self; +} + +SubsurfaceAbout::SubsurfaceAbout(QWidget* parent, Qt::WindowFlags f) +: ui( new Ui::SubsurfaceAbout()) +{ + ui->setupUi(this); + ui->aboutLabel->setText(tr("" \ + "Subsurface " VERSION_STRING "

" \ + "Multi-platform divelog software in C
" \ + "Linus Torvalds, Dirk Hohndel, and others, 2011, 2012, 2013")); + licenseButton = new QPushButton(tr("&License")); + websiteButton = new QPushButton(tr("&Website")); + ui->buttonBox->addButton(licenseButton, QDialogButtonBox::ActionRole); + ui->buttonBox->addButton(websiteButton, QDialogButtonBox::ActionRole); + connect(licenseButton, SIGNAL(clicked(bool)), this, SLOT(licenseClicked())); + connect(websiteButton, SIGNAL(clicked(bool)), this, SLOT(websiteClicked())); +} + +void SubsurfaceAbout::licenseClicked(void) +{ + QDesktopServices::openUrl(QUrl("http://www.gnu.org/licenses/gpl-2.0.txt")); +} + +void SubsurfaceAbout::websiteClicked(void) +{ + QDesktopServices::openUrl(QUrl("http://subsurface.hohndel.org")); +} diff --git a/qt-ui/about.h b/qt-ui/about.h new file mode 100644 index 000000000..6636b0e33 --- /dev/null +++ b/qt-ui/about.h @@ -0,0 +1,26 @@ +#ifndef ABOUT_H +#define ABOUT_H + +#include +#include + +namespace Ui { + class SubsurfaceAbout; +} + +class SubsurfaceAbout : public QDialog { + Q_OBJECT + +public: + static SubsurfaceAbout* instance(); +private slots: + void licenseClicked(); + void websiteClicked(); +private: + explicit SubsurfaceAbout(QWidget* parent = 0, Qt::WindowFlags f = 0); + QPushButton *licenseButton; + QPushButton *websiteButton; + Ui::SubsurfaceAbout *ui; +}; + +#endif diff --git a/qt-ui/about.ui b/qt-ui/about.ui new file mode 100644 index 000000000..e03bb3ec0 --- /dev/null +++ b/qt-ui/about.ui @@ -0,0 +1,142 @@ + + + SubsurfaceAbout + + + Qt::WindowModal + + + + 0 + 0 + 456 + 450 + + + + + 0 + 0 + + + + About Subsurface + + + + :/subsurface-icon:/subsurface-icon + + + true + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + + + :/subsurface-icon + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::RichText + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + true + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + + + + buttonBox + rejected() + SubsurfaceAbout + close() + + + 227 + 437 + + + 227 + 224 + + + + + diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index b61f962c4..fc454ab2f 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -33,6 +33,7 @@ #include "divecomputermanagementdialog.h" #include "simplewidgets.h" #include "diveplanner.h" +#include "about.h" static MainWindow* instance = 0; @@ -335,7 +336,7 @@ void MainWindow::on_actionInputPlan_triggered() void MainWindow::on_actionAboutSubsurface_triggered() { - qDebug("actionAboutSubsurface"); + SubsurfaceAbout::instance()->show(); } void MainWindow::on_actionUserManual_triggered() -- cgit v1.2.3-70-g09d2