Seamly2D
Code documentation
dialogaboutapp.cpp
Go to the documentation of this file.
1 /************************************************************************
2  **
3  ** @file dialogaboutapp.cpp
4  ** @author Patrick Proy <patrick(at)proy.org>
5  ** @date 6 5, 2014
6  **
7  ** @brief
8  ** @copyright
9  ** This source code is part of the Valentine project, a pattern making
10  ** program, whose allow create and modeling patterns of clothing.
11  ** Copyright (C) 2013-2015 Seamly2D project
12  ** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
13  **
14  ** Seamly2D is free software: you can redistribute it and/or modify
15  ** it under the terms of the GNU General Public License as published by
16  ** the Free Software Foundation, either version 3 of the License, or
17  ** (at your option) any later version.
18  **
19  ** Seamly2D is distributed in the hope that it will be useful,
20  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
21  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  ** GNU General Public License for more details.
23  **
24  ** You should have received a copy of the GNU General Public License
25  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
26  **
27  *************************************************************************/
28 
29 #include "dialogaboutapp.h"
30 #include "ui_dialogaboutapp.h"
31 #include "../version.h"
32 #include <QDate>
33 #include <QDesktopServices>
34 #include <QMessageBox>
35 #include <QtDebug>
36 #include "../options.h"
37 #include "../core/vapplication.h"
38 #include "../fervor/fvupdater.h"
39 
40 //---------------------------------------------------------------------------------------------------------------------
42  QDialog(parent),
43  ui(new Ui::DialogAboutApp),
44  isInitialized(false)
45 {
46  ui->setupUi(this);
47 
48  qApp->Seamly2DSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
49 
50  ui->label_Seamly2D_Version->setText(QString("Seamly2D %1").arg(APP_VERSION_STR));
51  ui->labelBuildRevision->setText(QString("Build revision: %1").arg(BUILD_REVISION));
52  ui->label_QT_Version->setText(buildCompatibilityString());
53 
54  QDate date = QLocale::c().toDate(QString(__DATE__).simplified(), QLatin1String("MMM d yyyy"));
55  ui->label_Seamly2D_Built->setText(tr("Built on %1 at %2").arg(date.toString()).arg(__TIME__));
56 
57  ui->label_Legal_Stuff->setText(QApplication::translate("InternalStrings",
58  "The program is provided AS IS with NO WARRANTY OF ANY "
59  "KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY "
60  "AND FITNESS FOR A PARTICULAR PURPOSE."));
61 
62 
63  ui->pushButton_Web_Site->setText(tr("Web site : %1").arg(VER_COMPANYDOMAIN_STR));
64  connect(ui->pushButton_Web_Site, &QPushButton::clicked, this, [this]()
65  {
66  if ( QDesktopServices::openUrl(QUrl(VER_COMPANYDOMAIN_STR)) == false)
67  {
68  qWarning() << tr("Cannot open your default browser");
69  }
70  });
71 
72  connect(ui->pushButtonCheckUpdate, &QPushButton::clicked, []()
73  {
74  // Set feed URL before doing anything else
75  FvUpdater::sharedUpdater()->SetFeedURL(defaultFeedURL);
76  FvUpdater::sharedUpdater()->CheckForUpdatesNotSilent();
77  });
78 
79  // By default on Windows font point size 8 points we need 11 like on Linux.
80  FontPointSize(ui->label_Legal_Stuff, 11);
81  FontPointSize(ui->label_contrib_label, 11);
82  FontPointSize(ui->label_Seamly2D_Built, 11);
83  FontPointSize(ui->label_QT_Version, 11);
84  ui->downloadProgress->hide();
85  ui->downloadProgress->setValue(0);
86  connect(FvUpdater::sharedUpdater(), SIGNAL(setProgress(int)), this, SLOT(setProgressValue(int)));
87 }
88 
89 //---------------------------------------------------------------------------------------------------------------------
91 {
92  delete ui;
93 }
94 
95 //---------------------------------------------------------------------------------------------------------------------
96 void DialogAboutApp::showEvent(QShowEvent *event)
97 {
98  QDialog::showEvent( event );
99  if ( event->spontaneous() )
100  {
101  return;
102  }
103 
104  if (isInitialized)
105  {
106  return;
107  }
108  // do your init stuff here
109 
110  setMaximumSize(size());
111  setMinimumSize(size());
112 
113  isInitialized = true;//first show windows are held
114 }
115 
116 //---------------------------------------------------------------------------------------------------------------------
117 void DialogAboutApp::FontPointSize(QWidget *w, int pointSize)
118 {
119  SCASSERT(w != nullptr)
120 
121  QFont font = w->font();
122  font.setPointSize(pointSize);
123  w->setFont(font);
124 }
125 
127  if (!ui->downloadProgress->isVisible()){
128  ui->downloadProgress->show();
129  ui->pushButtonCheckUpdate->setDisabled(true);
130  }
131  ui->downloadProgress->setValue(val);
132  if (val == 100){
133  ui->downloadProgress->hide();
134  ui->downloadProgress->setValue(0);
135  ui->pushButtonCheckUpdate->setDisabled(false);
136  }
137 }
DialogAboutApp(QWidget *parent=nullptr)
virtual ~DialogAboutApp()
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE
Ui::DialogAboutApp * ui
void FontPointSize(QWidget *w, int pointSize)
void setProgressValue(int val)
static FvUpdater * sharedUpdater()
Definition: fvupdater.cpp:62
#define SCASSERT(cond)
Definition: def.h:317
QString buildCompatibilityString()
#define VER_COMPANYDOMAIN_STR
const QString APP_VERSION_STR
#define qApp
Definition: vapplication.h:67
#define translate(context, source)
Definition: vcmdexport.cpp:41