diff --git a/Valentina.pro b/Valentina.pro index 81ed324c7..d78671c57 100644 --- a/Valentina.pro +++ b/Valentina.pro @@ -53,3 +53,6 @@ unix { TEMPLATE = subdirs SUBDIRS = src + +RESOURCES += \ + src/app/puzzle/share/resources/tapeicon.qrc diff --git a/src/app/puzzle/dialogs/dialogaboutpuzzle.cpp b/src/app/puzzle/dialogs/dialogaboutpuzzle.cpp new file mode 100644 index 000000000..f4a19caa9 --- /dev/null +++ b/src/app/puzzle/dialogs/dialogaboutpuzzle.cpp @@ -0,0 +1,141 @@ +/************************************************************************ + ** + ** @file dialogaboutpuzzle.cpp + ** @author Roman Telezhynskyi + ** @date 11 4, 2020 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentina 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 "dialogaboutpuzzle.h" +#include "ui_dialogaboutpuzzle.h" +#include "../version.h" +#include "../vmisc/def.h" +#include "../fervor/fvupdater.h" + +#include +#include +#include +#include +#include +#include + +//--------------------------------------------------------------------------------------------------------------------- +DialogAboutPuzzle::DialogAboutPuzzle(QWidget *parent) + :QDialog(parent), + ui(new Ui::DialogAboutPuzzle), + isInitialized(false) +{ + ui->setupUi(this); + + //mApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); + + RetranslateUi(); + connect(ui->pushButton_Web_Site, &QPushButton::clicked, this, []() + { + if ( not QDesktopServices::openUrl(QUrl(VER_COMPANYDOMAIN_STR))) + { + qWarning() << tr("Cannot open your default browser"); + } + }); + connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &DialogAboutPuzzle::close); + connect(ui->pushButtonCheckUpdate, &QPushButton::clicked, []() + { + // Set feed URL before doing anything else + FvUpdater::sharedUpdater()->SetFeedURL(FvUpdater::CurrentFeedURL()); + FvUpdater::sharedUpdater()->CheckForUpdatesNotSilent(); + }); + + // By default on Windows font point size 8 points we need 11 like on Linux. + FontPointSize(ui->label_Legal_Stuff, 11); + FontPointSize(ui->label_Puzzle_Built, 11); + FontPointSize(ui->label_QT_Version, 11); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogAboutPuzzle::~DialogAboutPuzzle() +{ + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogAboutPuzzle::changeEvent(QEvent *event) +{ + if (event->type() == QEvent::LanguageChange) + { + // retranslate designer form (single inheritance approach) + ui->retranslateUi(this); + RetranslateUi(); + } + + // remember to call base class implementation + QDialog::changeEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogAboutPuzzle::showEvent(QShowEvent *event) +{ + QDialog::showEvent( event ); + if ( event->spontaneous() ) + { + return; + } + + if (isInitialized) + { + return; + } + // do your init stuff here + + setMaximumSize(size()); + setMinimumSize(size()); + + isInitialized = true;//first show windows are held +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogAboutPuzzle::FontPointSize(QWidget *w, int pointSize) +{ + SCASSERT(w != nullptr) + + QFont font = w->font(); + font.setPointSize(pointSize); + w->setFont(font); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogAboutPuzzle::RetranslateUi() +{ + ui->label_Puzzle_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()); + + const QDate date = QLocale::c().toDate(QString(__DATE__).simplified(), QLatin1String("MMM d yyyy")); + ui->label_Puzzle_Built->setText(tr("Built on %1 at %2").arg(date.toString(), __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)); +} diff --git a/src/app/puzzle/dialogs/dialogaboutpuzzle.h b/src/app/puzzle/dialogs/dialogaboutpuzzle.h new file mode 100644 index 000000000..0367c5ace --- /dev/null +++ b/src/app/puzzle/dialogs/dialogaboutpuzzle.h @@ -0,0 +1,61 @@ +/************************************************************************ + ** + ** @file dialogaboutpuzzle.h + ** @author Roman Telezhynskyi + ** @date 11 4, 2020 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentina 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 DIALOGABOUTPUZZLE_H +#define DIALOGABOUTPUZZLE_H + +#include + +namespace Ui +{ + class DialogAboutPuzzle; +} + +class DialogAboutPuzzle : public QDialog +{ + Q_OBJECT + +public: + explicit DialogAboutPuzzle(QWidget *parent = nullptr); + virtual ~DialogAboutPuzzle(); + +protected: + virtual void changeEvent(QEvent* event) override; + virtual void showEvent(QShowEvent *event) override; + +private: + Q_DISABLE_COPY(DialogAboutPuzzle) + Ui::DialogAboutPuzzle *ui; + bool isInitialized; + + void FontPointSize(QWidget *w, int pointSize); + + void RetranslateUi(); +}; + +#endif // DIALOGABOUTPUZZLE_H diff --git a/src/app/puzzle/dialogs/dialogaboutpuzzle.ui b/src/app/puzzle/dialogs/dialogaboutpuzzle.ui new file mode 100644 index 000000000..fdcb86428 --- /dev/null +++ b/src/app/puzzle/dialogs/dialogaboutpuzzle.ui @@ -0,0 +1,296 @@ + + + DialogAboutPuzzle + + + + 0 + 0 + 462 + 320 + + + + + 0 + 0 + + + + + 0 + 0 + + + + About Tape + + + + :/tapeicon/64x64/logo.png:/tapeicon/64x64/logo.png + + + + + + 4 + + + 0 + + + 9 + + + + + + 0 + 0 + + + + + + + :/puzzleicon/64x64/logo.png + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + + + 15 + 75 + true + + + + Puzzle version + + + Qt::AlignCenter + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + 75 + true + + + + Build revision: + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + 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 + 0 + + + + label_Tape_Built + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + label_QT_Version + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + label_Legal_Stuff + + + true + + + + + + + + + + + + + Check For Updates + + + + + + + true + + + Qt::Horizontal + + + QDialogButtonBox::Ok + + + false + + + + + + + + + + + + + diff --git a/src/app/puzzle/puzzle.pri b/src/app/puzzle/puzzle.pri index 101fff4e3..a4db72756 100644 --- a/src/app/puzzle/puzzle.pri +++ b/src/app/puzzle/puzzle.pri @@ -4,14 +4,17 @@ SOURCES += \ $$PWD/main.cpp \ $$PWD/puzzlemainwindow.cpp \ - $$PWD/puzzleapplication.cpp + $$PWD/puzzleapplication.cpp \ + $$PWD/dialogs/dialogaboutpuzzle.cpp *msvc*:SOURCES += $$PWD/stable.cpp HEADERS += \ $$PWD/puzzlemainwindow.h \ $$PWD/stable.h \ - $$PWD/puzzleapplication.h + $$PWD/puzzleapplication.h \ + $$PWD/dialogs/dialogaboutpuzzle.h FORMS += \ - $$PWD/puzzlemainwindow.ui + $$PWD/puzzlemainwindow.ui \ + $$PWD/dialogs/dialogaboutpuzzle.ui diff --git a/src/app/puzzle/puzzle.pro b/src/app/puzzle/puzzle.pro index 7463ba832..1a471e46a 100644 --- a/src/app/puzzle/puzzle.pro +++ b/src/app/puzzle/puzzle.pro @@ -333,3 +333,5 @@ CONFIG(release, debug|release){ QMAKE_POST_LINK += $$[QT_INSTALL_BINS]/macdeployqt $${OUT_PWD}/$${DESTDIR}/$${TARGET}.app } } + +FORMS += diff --git a/src/app/puzzle/puzzlemainwindow.cpp b/src/app/puzzle/puzzlemainwindow.cpp index a647d528d..560fcb1b1 100644 --- a/src/app/puzzle/puzzlemainwindow.cpp +++ b/src/app/puzzle/puzzlemainwindow.cpp @@ -27,6 +27,7 @@ *************************************************************************/ #include "puzzlemainwindow.h" #include "ui_puzzlemainwindow.h" +#include "dialogs/dialogaboutpuzzle.h" //--------------------------------------------------------------------------------------------------------------------- PuzzleMainWindow::PuzzleMainWindow(QWidget *parent) : @@ -166,12 +167,9 @@ void PuzzleMainWindow::AboutQt() //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::AboutPuzzle() { - // just for test purpuses, to be removed: - QMessageBox msgBox; - msgBox.setText("TODO PuzzleMainWindow::AboutPuzzle"); - int ret = msgBox.exec(); - - // TODO + auto *aboutDialog = new DialogAboutPuzzle(this); + aboutDialog->setAttribute(Qt::WA_DeleteOnClose, true); + aboutDialog->show(); }