diff options
author | Boris Barbulovski <bbarbulovski@gmail.com> | 2014-02-08 08:50:39 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-02-08 08:00:27 -0800 |
commit | 31611141067d1876a3b1ee2d8bafd64839c476d3 (patch) | |
tree | 51dfb36d2518cc774c5010ef1bbdee05e17c5786 | |
parent | 39a11d70923940f45b5e1493dabfa934ec2a79c6 (diff) | |
download | subsurface-31611141067d1876a3b1ee2d8bafd64839c476d3.tar.gz |
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 <bbarbulovski@gmail.com>
ACK-ed-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | qt-ui/about.cpp | 27 | ||||
-rw-r--r-- | qt-ui/about.h | 9 | ||||
-rw-r--r-- | qt-ui/about.ui | 93 | ||||
-rw-r--r-- | qt-ui/mainwindow.cpp | 6 |
4 files changed, 72 insertions, 63 deletions
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 <QDebug> -#include <QDialogButtonBox> -#include <QNetworkReply> -#include <qdesktopservices.h> - -SubsurfaceAbout *SubsurfaceAbout::instance() -{ - static SubsurfaceAbout *self = new SubsurfaceAbout(mainWindow()); - self->setAttribute(Qt::WA_QuitOnClose, false); - return self; -} +#include <QDesktopServices> +#include <QUrl> SubsurfaceAbout::SubsurfaceAbout(QWidget* parent, Qt::WindowFlags f) { ui.setupUi(this); + + setWindowModality(Qt::ApplicationModal); + ui.aboutLabel->setText(tr("<span style='font-size: 18pt; font-weight: bold;'>" \ "Subsurface %1 </span><br><br>" \ "Multi-platform divelog software<br>" \ "<span style='font-size: 8pt'>Linus Torvalds, Dirk Hohndel, and others, 2011-2014</span>").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 @@ <property name="modal"> <bool>true</bool> </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <property name="spacing"> - <number>20</number> - </property> - <property name="leftMargin"> - <number>30</number> - </property> - <property name="topMargin"> - <number>30</number> - </property> - <property name="rightMargin"> - <number>30</number> - </property> - <property name="bottomMargin"> - <number>20</number> - </property> + <layout class="QVBoxLayout" name="verticalLayout" stretch="0,1,0"> <item> <widget class="QLabel" name="subsurfaceIcon"> <property name="text"> @@ -61,7 +46,7 @@ <item> <widget class="QLabel" name="aboutLabel"> <property name="text"> - <string></string> + <string/> </property> <property name="textFormat"> <enum>Qt::RichText</enum> @@ -75,17 +60,55 @@ </widget> </item> <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Close</set> - </property> - <property name="centerButtons"> - <bool>true</bool> - </property> - </widget> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="licenseButton"> + <property name="text"> + <string>&License</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="websiteButton"> + <property name="text"> + <string>&Website</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="closeButton"> + <property name="text"> + <string>&Close</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> </item> </layout> </widget> @@ -94,18 +117,18 @@ </resources> <connections> <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> + <sender>closeButton</sender> + <signal>clicked()</signal> <receiver>SubsurfaceAbout</receiver> - <slot>close()</slot> + <slot>accept()</slot> <hints> <hint type="sourcelabel"> - <x>227</x> - <y>437</y> + <x>290</x> + <y>411</y> </hint> <hint type="destinationlabel"> - <x>227</x> - <y>224</y> + <x>340</x> + <y>409</y> </hint> </hints> </connection> 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 |