From 31611141067d1876a3b1ee2d8bafd64839c476d3 Mon Sep 17 00:00:00 2001 From: Boris Barbulovski Date: Sat, 8 Feb 2014 08:50:39 +0100 Subject: SubsurfaceAbout class cleanup. Main change is that now SubsurfaceAbout doesn't have instance object, but it constructs and destructs dynamically. * Remove the static SubsurfaceAbout::instance() class member * construct/destruct about dialog on demand * Other small aboutbox cleanups. Signed-off-by: Boris Barbulovski ACK-ed-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/about.cpp | 27 ++++----------- qt-ui/about.h | 9 ++--- qt-ui/about.ui | 93 ++++++++++++++++++++++++++++++++-------------------- qt-ui/mainwindow.cpp | 6 ++-- 4 files changed, 72 insertions(+), 63 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/about.cpp b/qt-ui/about.cpp index 0a6489d93..804d73b7c 100644 --- a/qt-ui/about.cpp +++ b/qt-ui/about.cpp @@ -1,39 +1,26 @@ #include "about.h" #include "ssrf-version.h" -#include "mainwindow.h" -#include -#include -#include -#include - -SubsurfaceAbout *SubsurfaceAbout::instance() -{ - static SubsurfaceAbout *self = new SubsurfaceAbout(mainWindow()); - self->setAttribute(Qt::WA_QuitOnClose, false); - return self; -} +#include +#include SubsurfaceAbout::SubsurfaceAbout(QWidget* parent, Qt::WindowFlags f) { ui.setupUi(this); + + setWindowModality(Qt::ApplicationModal); + ui.aboutLabel->setText(tr("" \ "Subsurface %1

" \ "Multi-platform divelog software
" \ "Linus Torvalds, Dirk Hohndel, and others, 2011-2014").arg(VERSION_STRING)); - 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) +void SubsurfaceAbout::on_licenseButton_clicked() { QDesktopServices::openUrl(QUrl("http://www.gnu.org/licenses/gpl-2.0.txt")); } -void SubsurfaceAbout::websiteClicked(void) +void SubsurfaceAbout::on_websiteButton_clicked() { QDesktopServices::openUrl(QUrl("http://subsurface.hohndel.org")); } diff --git a/qt-ui/about.h b/qt-ui/about.h index 06dc30c87..0a4c8ddb5 100644 --- a/qt-ui/about.h +++ b/qt-ui/about.h @@ -9,14 +9,11 @@ class SubsurfaceAbout : public QDialog { Q_OBJECT public: - static SubsurfaceAbout* instance(); + explicit SubsurfaceAbout(QWidget* parent = 0, Qt::WindowFlags f = 0); private slots: - void licenseClicked(); - void websiteClicked(); + void on_licenseButton_clicked(); + void on_websiteButton_clicked(); private: - explicit SubsurfaceAbout(QWidget* parent = 0, Qt::WindowFlags f = 0); - QPushButton *licenseButton; - QPushButton *websiteButton; Ui::SubsurfaceAbout ui; }; diff --git a/qt-ui/about.ui b/qt-ui/about.ui index 71f0acb0f..0c1735e26 100644 --- a/qt-ui/about.ui +++ b/qt-ui/about.ui @@ -29,22 +29,7 @@ true - - - 20 - - - 30 - - - 30 - - - 30 - - - 20 - + @@ -61,7 +46,7 @@ - + Qt::RichText @@ -75,17 +60,55 @@ - - - Qt::Horizontal - - - QDialogButtonBox::Close - - - true - - + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + &License + + + + + + + &Website + + + + + + + &Close + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + @@ -94,18 +117,18 @@ - buttonBox - rejected() + closeButton + clicked() SubsurfaceAbout - close() + accept() - 227 - 437 + 290 + 411 - 227 - 224 + 340 + 409 diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 6d7123a05..73191dacf 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -503,7 +503,9 @@ void MainWindow::on_actionInputPlan_triggered() void MainWindow::on_actionAboutSubsurface_triggered() { - SubsurfaceAbout::instance()->show(); + SubsurfaceAbout dlg(this); + + dlg.exec(); } void MainWindow::on_actionUserManual_triggered() @@ -900,4 +902,4 @@ void MainWindow::on_profSAC_clicked(bool triggered) TOOLBOX_PREF_PROFILE(show_sac); } -#undef TOOLBOX_PREF_PROFILE \ No newline at end of file +#undef TOOLBOX_PREF_PROFILE -- cgit v1.2.3-70-g09d2