2015-06-18 10:45:38 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vabstractapplication.h
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 18 6, 2015
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
|
|
|
** This source code is part of the Valentine project, a pattern making
|
|
|
|
** 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 QGraphicsScene;
|
|
|
|
class QTranslator;
|
|
|
|
class QUndoStack;
|
|
|
|
class QWidget;
|
2015-06-18 10:45:38 +02:00
|
|
|
class VAbstractApplication;// use in define
|
2015-06-18 19:23:24 +02:00
|
|
|
class VAbstractPattern;
|
|
|
|
class VMainGraphicsView;
|
2016-08-08 13:44:49 +02:00
|
|
|
class VTranslateVars;
|
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);
|
2015-07-03 15:36:54 +02:00
|
|
|
virtual ~VAbstractApplication() Q_DECL_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);
|
|
|
|
|
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;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
2016-11-29 18:39:40 +01:00
|
|
|
QGraphicsScene **currentScene;
|
2015-06-18 19:23:24 +02:00
|
|
|
VMainGraphicsView *sceneView;
|
|
|
|
|
|
|
|
VAbstractPattern *doc;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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
|
|
|
|
|
|
|
void ClearTranslation();
|
2016-10-30 13:34:55 +01:00
|
|
|
|
2016-10-30 15:25:14 +01:00
|
|
|
static bool SymlinkCopyDirRecursive(const QString &fromDir, const QString &toDir, bool replaceOnConflit);
|
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
|