2015-06-18 10:45:38 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vabstractapplication.h
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 18 6, 2015
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2015-06-18 10:45:38 +02:00
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2015 Valentina project
|
|
|
|
** <https://bitbucket.org/dismine/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/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#ifndef VABSTRACTAPPLICATION_H
|
|
|
|
#define VABSTRACTAPPLICATION_H
|
|
|
|
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <qcompilerdetection.h>
|
2015-06-18 10:45:38 +02:00
|
|
|
#include <QApplication>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QCoreApplication>
|
2015-06-18 19:23:24 +02:00
|
|
|
#include <QGraphicsScene>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QLocale>
|
|
|
|
#include <QMetaObject>
|
|
|
|
#include <QObject>
|
2015-09-19 21:58:32 +02:00
|
|
|
#include <QPointer>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QString>
|
|
|
|
#include <QtGlobal>
|
2015-09-19 21:58:32 +02:00
|
|
|
|
2016-08-08 13:44:49 +02:00
|
|
|
#include "../vmisc/def.h"
|
|
|
|
#include "../vpatterndb/vtranslatevars.h"
|
2015-06-18 10:45:38 +02:00
|
|
|
#include "def.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
#include "vcommonsettings.h"
|
2015-09-14 13:53:49 +02:00
|
|
|
#include "vlockguard.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
#include "vsettings.h"
|
2015-06-18 10:45:38 +02:00
|
|
|
|
2016-08-08 13:44:49 +02:00
|
|
|
class QUndoStack;
|
2015-06-18 10:45:38 +02:00
|
|
|
class VAbstractApplication;// use in define
|
2017-04-01 18:53:28 +02:00
|
|
|
class VAbstractPattern;
|
2015-06-18 19:23:24 +02:00
|
|
|
class VMainGraphicsView;
|
2015-06-18 10:45:38 +02:00
|
|
|
|
|
|
|
#if defined(qApp)
|
|
|
|
#undef qApp
|
|
|
|
#endif
|
|
|
|
#define qApp (static_cast<VAbstractApplication*>(QCoreApplication::instance()))
|
|
|
|
|
|
|
|
class VAbstractApplication : public QApplication
|
|
|
|
{
|
2015-10-11 11:06:14 +02:00
|
|
|
Q_OBJECT
|
2015-06-18 10:45:38 +02:00
|
|
|
public:
|
|
|
|
VAbstractApplication(int &argc, char ** argv);
|
2018-06-26 14:53:48 +02:00
|
|
|
virtual ~VAbstractApplication() override;
|
2015-06-18 10:45:38 +02:00
|
|
|
|
|
|
|
virtual const VTranslateVars *TrVars()=0;
|
2015-11-18 13:42:25 +01:00
|
|
|
|
|
|
|
QString translationsPath(const QString &locale = QString()) const;
|
2015-09-19 21:58:32 +02:00
|
|
|
|
|
|
|
void LoadTranslation(const QString &locale);
|
2015-06-18 10:45:38 +02:00
|
|
|
|
2015-06-18 19:23:24 +02:00
|
|
|
Unit patternUnit() const;
|
|
|
|
const Unit *patternUnitP() const;
|
|
|
|
void setPatternUnit(const Unit &patternUnit);
|
|
|
|
|
2015-06-18 10:45:38 +02:00
|
|
|
MeasurementsType patternType() const;
|
|
|
|
void setPatternType(const MeasurementsType &patternType);
|
|
|
|
|
2017-09-19 15:07:48 +02:00
|
|
|
QString GetCustomerName() const;
|
|
|
|
void SetCustomerName(const QString &name);
|
|
|
|
|
2015-07-24 14:06:53 +02:00
|
|
|
virtual void OpenSettings()=0;
|
|
|
|
VCommonSettings *Settings();
|
2015-06-18 10:45:38 +02:00
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
QString LocaleToString(const T &value);
|
|
|
|
|
2015-06-18 19:23:24 +02:00
|
|
|
QGraphicsScene *getCurrentScene() const;
|
2016-11-29 18:39:40 +01:00
|
|
|
void setCurrentScene(QGraphicsScene **value);
|
2015-06-18 19:23:24 +02:00
|
|
|
|
|
|
|
VMainGraphicsView *getSceneView() const;
|
|
|
|
void setSceneView(VMainGraphicsView *value);
|
|
|
|
|
|
|
|
double toPixel(double val) const;
|
|
|
|
double fromPixel(double pix) const;
|
|
|
|
|
|
|
|
void setCurrentDocument(VAbstractPattern *doc);
|
|
|
|
VAbstractPattern *getCurrentDocument()const;
|
|
|
|
|
|
|
|
bool getOpeningPattern() const;
|
|
|
|
void setOpeningPattern();
|
|
|
|
|
|
|
|
QWidget *getMainWindow() const;
|
|
|
|
void setMainWindow(QWidget *value);
|
|
|
|
|
|
|
|
QUndoStack *getUndoStack() const;
|
|
|
|
|
2015-12-22 19:12:09 +01:00
|
|
|
virtual bool IsAppInGUIMode()const =0;
|
2018-07-13 15:18:04 +02:00
|
|
|
virtual bool IsPedantic() const;
|
2015-12-22 19:12:09 +01:00
|
|
|
|
2018-06-19 08:18:38 +02:00
|
|
|
QString GetPatternPath() const;
|
|
|
|
void SetPatternPath(const QString &value);
|
2017-08-14 14:11:14 +02:00
|
|
|
|
2017-12-10 12:17:04 +01:00
|
|
|
#if defined(Q_OS_WIN)
|
|
|
|
static void WinAttachConsole();
|
|
|
|
#endif
|
|
|
|
|
2018-05-25 16:54:21 +02:00
|
|
|
static QString ClearMessage(QString msg);
|
|
|
|
|
2018-07-18 19:18:30 +02:00
|
|
|
QMap<int, QString> GetUserMaterials() const;
|
|
|
|
void SetUserMaterials(const QMap<int, QString> &userMaterials);
|
|
|
|
|
2018-07-25 10:26:09 +02:00
|
|
|
const Draw &GetDrawMode() const;
|
|
|
|
void SetDrawMode(const Draw &value);
|
|
|
|
|
2015-06-18 19:23:24 +02:00
|
|
|
protected:
|
|
|
|
QUndoStack *undoStack;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief mainWindow pointer to main window. Usefull if need create modal dialog. Without pointer to main window
|
|
|
|
* modality doesn't work.
|
|
|
|
*/
|
|
|
|
QWidget *mainWindow;
|
2015-06-18 10:45:38 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief settings pointer to settings. Help hide constructor creation settings. Make make code more readable.
|
|
|
|
*/
|
2015-07-24 14:06:53 +02:00
|
|
|
VCommonSettings *settings;
|
2015-06-18 19:23:24 +02:00
|
|
|
|
2015-09-19 21:58:32 +02:00
|
|
|
QPointer<QTranslator> qtTranslator;
|
|
|
|
QPointer<QTranslator> qtxmlTranslator;
|
2015-11-17 15:27:51 +01:00
|
|
|
QPointer<QTranslator> qtBaseTranslator;
|
2015-09-19 21:58:32 +02:00
|
|
|
QPointer<QTranslator> appTranslator;
|
|
|
|
QPointer<QTranslator> pmsTranslator;
|
|
|
|
|
|
|
|
virtual void InitTrVars()=0;
|
|
|
|
|
2015-06-25 12:42:49 +02:00
|
|
|
private:
|
|
|
|
Q_DISABLE_COPY(VAbstractApplication)
|
|
|
|
Unit _patternUnit;
|
|
|
|
MeasurementsType _patternType;
|
2017-08-14 14:11:14 +02:00
|
|
|
QString patternFilePath;
|
2015-06-25 12:42:49 +02:00
|
|
|
|
2016-11-29 18:39:40 +01:00
|
|
|
QGraphicsScene **currentScene;
|
2015-06-18 19:23:24 +02:00
|
|
|
VMainGraphicsView *sceneView;
|
|
|
|
|
|
|
|
VAbstractPattern *doc;
|
2017-09-19 15:07:48 +02:00
|
|
|
QString m_customerName;
|
2015-06-18 19:23:24 +02:00
|
|
|
|
2018-07-18 19:18:30 +02:00
|
|
|
QMap<int, QString> m_userMaterials;
|
|
|
|
|
2015-06-18 19:23:24 +02:00
|
|
|
/**
|
|
|
|
* @brief openingPattern true when we opening pattern. If something will be wrong in formula this help understand if
|
|
|
|
* we can allow user use Undo option.
|
|
|
|
*/
|
|
|
|
bool openingPattern;
|
2015-09-19 21:58:32 +02:00
|
|
|
|
2018-07-25 10:26:09 +02:00
|
|
|
/** @brief mode keep current draw mode. */
|
|
|
|
Draw mode;
|
|
|
|
|
2015-09-19 21:58:32 +02:00
|
|
|
void ClearTranslation();
|
2015-06-18 10:45:38 +02:00
|
|
|
};
|
|
|
|
|
2017-09-19 15:07:48 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline QString VAbstractApplication::GetCustomerName() const
|
|
|
|
{
|
|
|
|
return m_customerName;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline void VAbstractApplication::SetCustomerName(const QString &name)
|
|
|
|
{
|
|
|
|
m_customerName = name;
|
|
|
|
}
|
|
|
|
|
2017-08-14 14:11:14 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2018-06-19 08:18:38 +02:00
|
|
|
inline QString VAbstractApplication::GetPatternPath() const
|
2017-08-14 14:11:14 +02:00
|
|
|
{
|
|
|
|
return patternFilePath;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2018-06-19 08:18:38 +02:00
|
|
|
inline void VAbstractApplication::SetPatternPath(const QString &value)
|
2017-08-14 14:11:14 +02:00
|
|
|
{
|
|
|
|
patternFilePath = value;
|
|
|
|
}
|
|
|
|
|
2018-07-18 19:18:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline QMap<int, QString> VAbstractApplication::GetUserMaterials() const
|
|
|
|
{
|
|
|
|
return m_userMaterials;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline void VAbstractApplication::SetUserMaterials(const QMap<int, QString> &userMaterials)
|
|
|
|
{
|
|
|
|
m_userMaterials = userMaterials;
|
|
|
|
}
|
|
|
|
|
2015-06-18 10:45:38 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
template <typename T>
|
2015-07-03 16:03:19 +02:00
|
|
|
inline QString VAbstractApplication::LocaleToString(const T &value)
|
2015-06-18 10:45:38 +02:00
|
|
|
{
|
|
|
|
QLocale loc;
|
2017-01-03 09:46:28 +01:00
|
|
|
qApp->Settings()->GetOsSeparator() ? loc = QLocale() : loc = QLocale::c();
|
2015-06-18 10:45:38 +02:00
|
|
|
return loc.toString(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // VABSTRACTAPPLICATION_H
|