From 47c5a2dc999884c3615439e92d9115ab0f0b5e4e Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sun, 12 Jul 2015 20:38:30 +0300 Subject: [PATCH] Dialog about app. --HG-- branch : feature --- src/app/tape/dialogs/dialogabouttape.cpp | 97 ++++++++++ src/app/tape/dialogs/dialogabouttape.h | 56 ++++++ src/app/tape/dialogs/dialogabouttape.ui | 236 +++++++++++++++++++++++ src/app/tape/tape.pri | 9 +- src/app/tape/tape.pro | 21 +- src/app/tape/tmainwindow.cpp | 5 +- 6 files changed, 419 insertions(+), 5 deletions(-) create mode 100644 src/app/tape/dialogs/dialogabouttape.cpp create mode 100644 src/app/tape/dialogs/dialogabouttape.h create mode 100644 src/app/tape/dialogs/dialogabouttape.ui diff --git a/src/app/tape/dialogs/dialogabouttape.cpp b/src/app/tape/dialogs/dialogabouttape.cpp new file mode 100644 index 000000000..ba7cb4f6d --- /dev/null +++ b/src/app/tape/dialogs/dialogabouttape.cpp @@ -0,0 +1,97 @@ +/************************************************************************ + ** + ** @file dialogabouttape.cpp + ** @author Roman Telezhynskyi + ** @date 12 7, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina 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. + ** + ** Valentina 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 Valentina. If not, see . + ** + *************************************************************************/ + +#include "dialogabouttape.h" +#include "ui_dialogabouttape.h" +#include "../version.h" +#include "../vmisc/def.h" + +#include +#include + +//--------------------------------------------------------------------------------------------------------------------- +DialogAboutTape::DialogAboutTape(QWidget *parent) + :QDialog(parent), + ui(new Ui::DialogAboutTape) +{ + ui->setupUi(this); + + //qApp->Settings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale(QLocale::C)); + + ui->label_Tape_Version->setText(QString("Tape %1").arg(APP_VERSION_STR)); + ui->labelBuildRevision->setText(tr("Build revision: %1").arg(BUILD_REVISION)); + ui->label_QT_Version->setText(buildCompatibilityString()); + + QDate date = QLocale(QLocale::C).toDate(QString(__DATE__).simplified(), QLatin1String("MMM d yyyy")); + ui->label_Tape_Built->setText(tr("Built on %3 at %4").arg(date.toString()).arg(__TIME__)); + + ui->label_Legal_Stuff->setText(QApplication::translate("InternalStrings", + "The program is provided AS IS with NO WARRANTY OF ANY " + "KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY " + "AND FITNESS FOR A PARTICULAR PURPOSE.")); + + + ui->pushButton_Web_Site->setText(tr("Web site : %1") + .arg(VER_COMPANYDOMAIN_STR)); + connect(ui->pushButton_Web_Site, &QPushButton::clicked, this, &DialogAboutTape::WebButtonClicked); + connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &DialogAboutTape::close); + + // By default on Windows font point size 8 points we need 11 like on Linux. + FontPointSize(ui->label_Legal_Stuff, 11); + FontPointSize(ui->label_Tape_Built, 11); + FontPointSize(ui->label_QT_Version, 11); + + adjustSize(); + setMaximumSize(size()); + setMinimumSize(size()); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogAboutTape::~DialogAboutTape() +{ + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogAboutTape::WebButtonClicked() +{ + if ( QDesktopServices::openUrl(QUrl(VER_COMPANYDOMAIN_STR)) == false) + { + QMessageBox::warning(this, tr("Warning"), tr("Cannot open your default browser")); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogAboutTape::FontPointSize(QWidget *w, int pointSize) +{ + SCASSERT(w != nullptr); + + QFont font = w->font(); + font.setPointSize(pointSize); + w->setFont(font); +} diff --git a/src/app/tape/dialogs/dialogabouttape.h b/src/app/tape/dialogs/dialogabouttape.h new file mode 100644 index 000000000..25b0222ff --- /dev/null +++ b/src/app/tape/dialogs/dialogabouttape.h @@ -0,0 +1,56 @@ +/************************************************************************ + ** + ** @file dialogabouttape.h + ** @author Roman Telezhynskyi + ** @date 12 7, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina 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. + ** + ** Valentina 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 Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef DIALOGABOUTTAPE_H +#define DIALOGABOUTTAPE_H + +#include + +namespace Ui { +class DialogAboutTape; +} + +class DialogAboutTape : public QDialog +{ + Q_OBJECT + +public: + explicit DialogAboutTape(QWidget *parent = 0); + ~DialogAboutTape(); + +private slots: + void WebButtonClicked(); + +private: + Q_DISABLE_COPY(DialogAboutTape) + Ui::DialogAboutTape *ui; + + void FontPointSize(QWidget *w, int pointSize); +}; + +#endif // DIALOGABOUTTAPE_H diff --git a/src/app/tape/dialogs/dialogabouttape.ui b/src/app/tape/dialogs/dialogabouttape.ui new file mode 100644 index 000000000..f19a4a772 --- /dev/null +++ b/src/app/tape/dialogs/dialogabouttape.ui @@ -0,0 +1,236 @@ + + + DialogAboutTape + + + + 0 + 0 + 559 + 241 + + + + + 0 + 0 + + + + Dialog + + + + + + 4 + + + 0 + + + 9 + + + + + + 0 + 0 + + + + + + + :/tapeicon/64x64/logo.png + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + + + 15 + 75 + true + + + + Tape version + + + Qt::AlignCenter + + + + + + + + 75 + true + + + + Build revision: + + + + + + + This program is part of Valentina project. + + + + + + + + + + + + 0 + 0 + 255 + + + + + + + + + 0 + 0 + 255 + + + + + + + + + 120 + 120 + 120 + + + + + + + + + true + + + + PointingHandCursor + + + pushButton_Web_Site + + + false + + + true + + + + + + + + 0 + 0 + + + + + 0 + 10 + + + + label_Tape_Built + + + + + + + + 0 + 0 + + + + + 0 + 10 + + + + label_QT_Version + + + + + + + + 0 + 0 + + + + + 0 + 10 + + + + label_Legal_Stuff + + + true + + + + + + + + + + + true + + + Qt::Horizontal + + + QDialogButtonBox::Ok + + + true + + + + + + + + + + diff --git a/src/app/tape/tape.pri b/src/app/tape/tape.pri index e466365c5..20416b462 100644 --- a/src/app/tape/tape.pri +++ b/src/app/tape/tape.pri @@ -5,12 +5,15 @@ SOURCES += \ $$PWD/main.cpp \ $$PWD/tmainwindow.cpp \ $$PWD/stable.cpp \ - $$PWD/mapplication.cpp + $$PWD/mapplication.cpp \ + dialogs/dialogabouttape.cpp HEADERS += \ $$PWD/tmainwindow.h \ $$PWD/stable.h \ - $$PWD/mapplication.h + $$PWD/mapplication.h \ + dialogs/dialogabouttape.h FORMS += \ - $$PWD/tmainwindow.ui + $$PWD/tmainwindow.ui \ + dialogs/dialogabouttape.ui diff --git a/src/app/tape/tape.pro b/src/app/tape/tape.pro index 046099a65..62644b194 100644 --- a/src/app/tape/tape.pro +++ b/src/app/tape/tape.pro @@ -98,7 +98,7 @@ CONFIG(debug, debug|release){ QMAKE_CXXFLAGS += $$GCC_DEBUG_CXXFLAGS # See common.pri for more details. } } - + DEFINES += "BUILD_REVISION=\\\"unknown\\\"" }else{ # Release mode DEFINES += V_NO_ASSERT @@ -117,6 +117,25 @@ CONFIG(debug, debug|release){ QMAKE_LFLAGS_RELEASE = } } + + macx{ + HG = /usr/local/bin/hg # Can't defeat PATH variable on Mac OS. + }else { + HG = hg # All other platforms all OK. + } + + #build revision number for using in version + unix { + HG_HESH=$$system("$${HG} log -r. --template '{node|short}'") + } else { + # Use escape character before "|" on Windows + HG_HESH=$$system($${HG} log -r. --template "{node^|short}") + } + isEmpty(HG_HESH){ + HG_HESH = "unknown" # if we can't find build revision left unknown. + } + message("Build revision:" $${HG_HESH}) + DEFINES += "BUILD_REVISION=\\\"$${HG_HESH}\\\"" # Make available build revision number in sources. } # Path to recource file. diff --git a/src/app/tape/tmainwindow.cpp b/src/app/tape/tmainwindow.cpp index 9fa498573..d52f42290 100644 --- a/src/app/tape/tmainwindow.cpp +++ b/src/app/tape/tmainwindow.cpp @@ -29,6 +29,7 @@ #include "tmainwindow.h" #include "ui_tmainwindow.h" #include "mapplication.h" +#include "dialogs/dialogabouttape.h" //--------------------------------------------------------------------------------------------------------------------- TMainWindow::TMainWindow(QWidget *parent) @@ -108,7 +109,9 @@ void TMainWindow::ShowWindow() //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::AboutApplication() { - + DialogAboutTape * aboutDialog = new DialogAboutTape(this); + aboutDialog->setAttribute(Qt::WA_DeleteOnClose, true); + aboutDialog->show(); } //---------------------------------------------------------------------------------------------------------------------