Seamly2D
Code documentation
vapplication.h
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 vapplication.h
27  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
28  ** @date November 15, 2013
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) 2013-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 #ifndef VAPPLICATION_H
53 #define VAPPLICATION_H
54 
55 #include "../vmisc/vabstractapplication.h"
56 #include "../options.h"
57 #include "../vwidgets/vmaingraphicsview.h"
58 #include "../vpatterndb/vtranslatevars.h"
59 #include "vsettings.h"
60 #include "vcmdexport.h"
61 
62 class VApplication;// use in define
63 
64 #if defined(qApp)
65 #undef qApp
66 #endif
67 #define qApp (static_cast<VApplication*>(VAbstractApplication::instance()))
68 
69 /**
70  * @brief The VApplication class reimplamentation QApplication class.
71  */
73 {
74  Q_OBJECT
75 public:
76 
77  VApplication(int &argc, char ** argv);
78  virtual ~VApplication() Q_DECL_OVERRIDE;
79  static void NewSeamly2D(const QString &fileName = QString());
80  virtual bool notify(QObject * receiver, QEvent * event) Q_DECL_OVERRIDE;
81 
82  void InitOptions();
83 
84  QString SeamlyMeFilePath() const;
85 
86  QTimer *getAutoSaveTimer() const;
87  void setAutoSaveTimer(QTimer *value);
88 
89  static QStringList LabelLanguages();
90 
91  void StartLogging();
92  QTextStream *LogFile();
93 
94  virtual const VTranslateVars *TrVars() Q_DECL_OVERRIDE;
95 
96 #if defined(Q_OS_WIN) && defined(Q_CC_GNU)
97  static void DrMingw();
98  void CollectReports() const;
99 #endif // defined(Q_OS_WIN) && defined(Q_CC_GNU)
100  bool static IsGUIMode();
101  virtual bool IsAppInGUIMode() const Q_DECL_OVERRIDE;
102 
103  virtual void OpenSettings() Q_DECL_OVERRIDE;
105 
106 protected:
107  virtual void InitTrVars() Q_DECL_OVERRIDE;
108  virtual bool event(QEvent *e) Q_DECL_OVERRIDE;
109 
110 private slots:
111 #if defined(Q_OS_WIN) && defined(Q_CC_GNU)
112  void CleanGist() const;
113 #endif // defined(Q_OS_WIN) && defined(Q_CC_GNU)
114 
115 private:
116  Q_DISABLE_COPY(VApplication)
118  QTimer *autoSaveTimer;
119 
120  std::shared_ptr<VLockGuard<QFile>> lockLog;
121  std::shared_ptr<QTextStream> out;
122 
123 #if defined(Q_OS_WIN) && defined(Q_CC_GNU)
124  static const QString GistFileName;
125 
126  void CollectReport(const QString &reportName) const;
127  void SendReport(const QString &reportName) const;
128  QString ReadFileForSending(QFile &file)const;
129  void ClearOldReports()const;
130  void GatherLogs()const;
131 #endif // defined(Q_OS_WIN) && defined(Q_CC_GNU)
132 
133  QString LogDirPath()const;
134  QString LogPath()const;
135  bool CreateLogDir()const;
136  void BeginLogging();
137  void ClearOldLogs()const;
138 
139 public:
140  //moved to the end of class so merge should go
141  const VCommandLinePtr CommandLine() const;
142 };
143 
144 //---------------------------------------------------------------------------------------------------------------------
145 inline QTimer *VApplication::getAutoSaveTimer() const
146 {
147  return autoSaveTimer;
148 }
149 
150 //---------------------------------------------------------------------------------------------------------------------
151 inline void VApplication::setAutoSaveTimer(QTimer *value)
152 {
153  autoSaveTimer = value;
154 }
155 //---------------------------------------------------------------------------------------------------------------------
156 
157 
158 #endif // VAPPLICATION_H
The VApplication class reimplamentation QApplication class.
Definition: vapplication.h:73
QString SeamlyMeFilePath() const
QTimer * getAutoSaveTimer() const
Definition: vapplication.h:145
virtual void OpenSettings() Q_DECL_OVERRIDE
OpenSettings get acsses to application settings.
static bool IsGUIMode()
QTimer * autoSaveTimer
Definition: vapplication.h:118
std::shared_ptr< QTextStream > out
Definition: vapplication.h:121
QString LogDirPath() const
VSettings * Seamly2DSettings()
void InitOptions()
static void NewSeamly2D(const QString &fileName=QString())
NewSeamly2D start Seamly2D in new process, send path to pattern file in argument.
virtual bool notify(QObject *receiver, QEvent *event) Q_DECL_OVERRIDE
notify Reimplemented from QApplication::notify().
virtual ~VApplication() Q_DECL_OVERRIDE
virtual bool IsAppInGUIMode() const Q_DECL_OVERRIDE
IsAppInGUIMode little hack that allow to have access to application state from VAbstractApplication c...
std::shared_ptr< VLockGuard< QFile > > lockLog
Definition: vapplication.h:120
virtual bool event(QEvent *e) Q_DECL_OVERRIDE
void ClearOldLogs() const
void setAutoSaveTimer(QTimer *value)
Definition: vapplication.h:151
void BeginLogging()
VApplication(int &argc, char **argv)
VApplication constructor.
QTextStream * LogFile()
void StartLogging()
QString LogPath() const
bool CreateLogDir() const
virtual void InitTrVars() Q_DECL_OVERRIDE
const VCommandLinePtr CommandLine() const
static QStringList LabelLanguages()
virtual const VTranslateVars * TrVars() Q_DECL_OVERRIDE
VTranslateVars * trVars
Definition: vapplication.h:117
std::shared_ptr< VCommandLine > VCommandLinePtr
Definition: vcmdexport.h:41