Seamly2D
Code documentation
dialogaboutseamlyme.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * *
3  * Copyright (C) 2017 Seamly, LLC *
4  * *
5  * https://github.com/fashionfreedom/seamly2d *
6  * *
7  ***************************************************************************
8  **
9  ** Seamly2D is free software: you can redistribute it and/or modify
10  ** it under the terms of the GNU General Public License as published by
11  ** the Free Software Foundation, either version 3 of the License, or
12  ** (at your option) any later version.
13  **
14  ** Seamly2D is distributed in the hope that it will be useful,
15  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  ** GNU General Public License for more details.
18  **
19  ** You should have received a copy of the GNU General Public License
20  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
21  **
22  **************************************************************************
23 
24  ************************************************************************
25  **
26  ** @file dialogaboutseamlyme.cpp
27  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
28  ** @date 12 7, 2015
29  **
30  ** @brief
31  ** @copyright
32  ** This source code is part of the Valentine project, a pattern making
33  ** program, whose allow create and modeling patterns of clothing.
34  ** Copyright (C) 2015 Seamly2D project
35  ** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
36  **
37  ** Seamly2D is free software: you can redistribute it and/or modify
38  ** it under the terms of the GNU General Public License as published by
39  ** the Free Software Foundation, either version 3 of the License, or
40  ** (at your option) any later version.
41  **
42  ** Seamly2D is distributed in the hope that it will be useful,
43  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
44  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45  ** GNU General Public License for more details.
46  **
47  ** You should have received a copy of the GNU General Public License
48  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
49  **
50  *************************************************************************/
51 
52 #include "dialogaboutseamlyme.h"
53 #include "ui_dialogaboutseamlyme.h"
54 #include "../version.h"
55 #include "../vmisc/def.h"
56 #include "../fervor/fvupdater.h"
57 
58 #include <QDate>
59 #include <QDesktopServices>
60 #include <QMessageBox>
61 #include <QShowEvent>
62 #include <QUrl>
63 #include <QtDebug>
64 
65 //---------------------------------------------------------------------------------------------------------------------
67  :QDialog(parent),
68  ui(new Ui::DialogAboutSeamlyMe),
69  isInitialized(false)
70 {
71  ui->setupUi(this);
72 
73  //mApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
74 
75  RetranslateUi();
76  connect(ui->pushButton_Web_Site, &QPushButton::clicked, this, [this]()
77  {
78  if ( QDesktopServices::openUrl(QUrl(VER_COMPANYDOMAIN_STR)) == false)
79  {
80  qWarning() << tr("Cannot open your default browser");
81  }
82  });
83  connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &DialogAboutSeamlyMe::close);
84  connect(ui->pushButtonCheckUpdate, &QPushButton::clicked, []()
85  {
86  // Set feed URL before doing anything else
87  FvUpdater::sharedUpdater()->SetFeedURL(defaultFeedURL);
88  FvUpdater::sharedUpdater()->CheckForUpdatesNotSilent();
89  });
90 
91  // By default on Windows font point size 8 points we need 11 like on Linux.
92  FontPointSize(ui->label_Legal_Stuff, 11);
93  FontPointSize(ui->label_SeamlyMe_Built, 11);
94  FontPointSize(ui->label_QT_Version, 11);
95 
96  ui->downloadProgress->hide();
97  ui->downloadProgress->setValue(0);
98  connect(FvUpdater::sharedUpdater(), SIGNAL(setProgress(int)), this, SLOT(setProgressValue(int)));
99 }
100 
101 //---------------------------------------------------------------------------------------------------------------------
103 {
104  delete ui;
105 }
106 
107 //---------------------------------------------------------------------------------------------------------------------
109 {
110  if (event->type() == QEvent::LanguageChange)
111  {
112  // retranslate designer form (single inheritance approach)
113  ui->retranslateUi(this);
114  RetranslateUi();
115  }
116 
117  // remember to call base class implementation
118  QDialog::changeEvent(event);
119 }
120 
121 //---------------------------------------------------------------------------------------------------------------------
122 void DialogAboutSeamlyMe::showEvent(QShowEvent *event)
123 {
124  QDialog::showEvent( event );
125  if ( event->spontaneous() )
126  {
127  return;
128  }
129 
130  if (isInitialized)
131  {
132  return;
133  }
134  // do your init stuff here
135 
136  setMaximumSize(size());
137  setMinimumSize(size());
138 
139  isInitialized = true;//first show windows are held
140 }
141 
142 //---------------------------------------------------------------------------------------------------------------------
143 void DialogAboutSeamlyMe::FontPointSize(QWidget *w, int pointSize)
144 {
145  SCASSERT(w != nullptr)
146 
147  QFont font = w->font();
148  font.setPointSize(pointSize);
149  w->setFont(font);
150 }
151 
152 //---------------------------------------------------------------------------------------------------------------------
154 {
155  ui->label_SeamlyMe_Version->setText(QString("SeamlyMe %1").arg(APP_VERSION_STR));
156  ui->labelBuildRevision->setText(tr("Build revision: %1").arg(BUILD_REVISION));
157  ui->label_QT_Version->setText(buildCompatibilityString());
158 
159  const QDate date = QLocale::c().toDate(QString(__DATE__).simplified(), QLatin1String("MMM d yyyy"));
160  ui->label_SeamlyMe_Built->setText(tr("Built on %1 at %2").arg(date.toString()).arg(__TIME__));
161 
162  ui->label_Legal_Stuff->setText(QApplication::translate("InternalStrings",
163  "The program is provided AS IS with NO WARRANTY OF ANY "
164  "KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY "
165  "AND FITNESS FOR A PARTICULAR PURPOSE."));
166 
167  ui->pushButton_Web_Site->setText(tr("Web site : %1").arg(VER_COMPANYDOMAIN_STR));
168 }
169 
171  if (!ui->downloadProgress->isVisible()){
172  ui->downloadProgress->show();
173  ui->pushButtonCheckUpdate->setDisabled(true);
174  }
175  ui->downloadProgress->setValue(val);
176  if (val == 100){
177  ui->downloadProgress->hide();
178  ui->downloadProgress->setValue(0);
179  ui->pushButtonCheckUpdate->setDisabled(false);
180  }
181 }
182 
void FontPointSize(QWidget *w, int pointSize)
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE
Ui::DialogAboutSeamlyMe * ui
DialogAboutSeamlyMe(QWidget *parent=nullptr)
virtual void changeEvent(QEvent *event) Q_DECL_OVERRIDE
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 translate(context, source)
Definition: vcmdexport.cpp:41