valentina/src/app/puzzle/dialogs/vpdialogabout.cpp

151 lines
5.4 KiB
C++
Raw Normal View History

2020-04-11 11:40:02 +02:00
/************************************************************************
**
2020-05-23 13:49:38 +02:00
** @file vpdialogabout.cpp
2020-04-13 12:43:27 +02:00
** @author Ronan Le Tiec
2020-04-11 11:40:02 +02:00
** @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
** <https://gitlab.com/smart-pattern/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
2020-05-23 13:49:38 +02:00
#include "vpdialogabout.h"
2020-04-11 11:40:02 +02:00
#include "../fervor/fvupdater.h"
2023-07-25 13:02:01 +02:00
#include "../vmisc/def.h"
#include "../vmisc/projectversion.h"
#include "ui_vpdialogabout.h"
2020-04-11 11:40:02 +02:00
#include <QDate>
#include <QDesktopServices>
#include <QMessageBox>
#include <QShowEvent>
#include <QUrl>
#include <QtDebug>
2023-01-04 17:31:50 +01:00
#if !defined(BUILD_REVISION) && defined(QBS_BUILD)
#include <vcsRepoState.h>
#define BUILD_REVISION VCS_REPO_STATE_REVISION
#endif
#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
#include "../vmisc/compatibility.h"
#endif
using namespace Qt::Literals::StringLiterals;
2020-04-11 11:40:02 +02:00
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 13:49:38 +02:00
VPDialogAbout::VPDialogAbout(QWidget *parent)
2023-07-25 13:02:01 +02:00
: QDialog(parent),
m_isInitialized(false)
2020-04-11 11:40:02 +02:00
{
ui->setupUi(this);
2023-07-25 13:02:01 +02:00
// mApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
2020-04-11 11:40:02 +02:00
RetranslateUi();
2023-07-25 13:02:01 +02:00
connect(ui->pushButton_Web_Site, &QPushButton::clicked, this,
[]()
{
if (not QDesktopServices::openUrl(QUrl(QStringLiteral(VER_COMPANYDOMAIN_STR))))
{
qWarning() << tr("Cannot open your default browser");
}
});
2020-05-23 13:49:38 +02:00
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &VPDialogAbout::close);
2023-07-25 13:02:01 +02:00
connect(ui->pushButtonCheckUpdate, &QPushButton::clicked,
[]()
{
// Set feed URL before doing anything else
FvUpdater::sharedUpdater()->SetFeedURL(FvUpdater::CurrentFeedURL());
FvUpdater::sharedUpdater()->CheckForUpdatesNotSilent();
});
2020-04-11 11:40:02 +02:00
// 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);
}
//---------------------------------------------------------------------------------------------------------------------
VPDialogAbout::~VPDialogAbout() = default;
2020-04-11 11:40:02 +02:00
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 13:49:38 +02:00
void VPDialogAbout::changeEvent(QEvent *event)
2020-04-11 11:40:02 +02:00
{
if (event->type() == QEvent::LanguageChange)
{
// retranslate designer form (single inheritance approach)
ui->retranslateUi(this);
RetranslateUi();
}
// remember to call base class implementation
QDialog::changeEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 13:49:38 +02:00
void VPDialogAbout::showEvent(QShowEvent *event)
2020-04-11 11:40:02 +02:00
{
2023-07-25 13:02:01 +02:00
QDialog::showEvent(event);
if (event->spontaneous())
2020-04-11 11:40:02 +02:00
{
return;
}
2022-08-12 17:50:13 +02:00
if (m_isInitialized)
2020-04-11 11:40:02 +02:00
{
return;
}
// do your init stuff here
setMaximumSize(size());
setMinimumSize(size());
2023-07-25 13:02:01 +02:00
m_isInitialized = true; // first show windows are held
2020-04-11 11:40:02 +02:00
}
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 13:49:38 +02:00
void VPDialogAbout::FontPointSize(QWidget *w, int pointSize)
2020-04-11 11:40:02 +02:00
{
SCASSERT(w != nullptr)
QFont font = w->font();
font.setPointSize(qMax(pointSize, 1));
2020-04-11 11:40:02 +02:00
w->setFont(font);
}
//---------------------------------------------------------------------------------------------------------------------
2020-05-23 13:49:38 +02:00
void VPDialogAbout::RetranslateUi()
2020-04-11 11:40:02 +02:00
{
2023-07-25 13:01:41 +02:00
ui->label_Puzzle_Version->setText(QStringLiteral("Puzzle %1").arg(AppVersionStr()));
2022-08-12 17:50:13 +02:00
ui->labelBuildRevision->setText(tr("Build revision: %1").arg(QStringLiteral(BUILD_REVISION)));
2020-04-11 11:40:02 +02:00
ui->label_QT_Version->setText(buildCompatibilityString());
const QDate date = QLocale::c().toDate(QStringLiteral(__DATE__).simplified(), "MMM d yyyy"_L1);
2022-08-12 17:50:13 +02:00
ui->label_Puzzle_Built->setText(tr("Built on %1 at %2").arg(date.toString(), QStringLiteral(__TIME__)));
2020-04-11 11:40:02 +02:00
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."));
2022-08-12 17:50:13 +02:00
ui->pushButton_Web_Site->setText(tr("Web site : %1").arg(QStringLiteral(VER_COMPANYDOMAIN_STR)));
2020-04-11 11:40:02 +02:00
}