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
|
2020-01-31 07:00:05 +01:00
|
|
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
2015-06-18 10:45:38 +02:00
|
|
|
**
|
|
|
|
** 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>
|
|
|
|
#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>
|
2020-10-15 17:05:21 +02:00
|
|
|
#include <QTranslator>
|
2015-09-19 21:58:32 +02:00
|
|
|
|
2016-08-08 13:44:49 +02:00
|
|
|
#include "../vmisc/def.h"
|
|
|
|
#include "../vpatterndb/vtranslatevars.h"
|
|
|
|
#include "vcommonsettings.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
|
2020-10-15 17:05:21 +02:00
|
|
|
class VCommonSettings;
|
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);
|
2020-10-15 17:05:21 +02:00
|
|
|
virtual ~VAbstractApplication() =default;
|
2015-06-18 10:45:38 +02:00
|
|
|
|
|
|
|
virtual const VTranslateVars *TrVars()=0;
|
2015-11-18 13:42:25 +01:00
|
|
|
|
2020-10-15 17:05:21 +02:00
|
|
|
QString translationsPath(const QString &locale = QString()) const;
|
2015-09-19 21:58:32 +02:00
|
|
|
|
2020-10-15 17:05:21 +02:00
|
|
|
void LoadTranslation(const QString &locale);
|
2017-09-19 15:07:48 +02:00
|
|
|
|
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>
|
2020-10-15 17:05:21 +02:00
|
|
|
QString LocaleToString(const T &value);
|
2015-06-18 19:23:24 +02:00
|
|
|
|
2020-10-15 17:05:21 +02:00
|
|
|
QUndoStack *getUndoStack() const;
|
2015-06-18 19:23:24 +02:00
|
|
|
|
2020-10-15 17:05:21 +02:00
|
|
|
virtual bool IsAppInGUIMode()const =0;
|
|
|
|
virtual bool IsPedantic() const;
|
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
|
|
|
|
|
2015-06-18 19:23:24 +02:00
|
|
|
protected:
|
2020-10-15 17:05:21 +02:00
|
|
|
QUndoStack *undoStack;
|
2015-06-18 10:45:38 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief settings pointer to settings. Help hide constructor creation settings. Make make code more readable.
|
|
|
|
*/
|
2020-10-15 17:05:21 +02:00
|
|
|
VCommonSettings *settings{nullptr};
|
2015-06-18 19:23:24 +02:00
|
|
|
|
2020-10-15 17:05:21 +02:00
|
|
|
QPointer<QTranslator> qtTranslator{nullptr};
|
|
|
|
QPointer<QTranslator> qtxmlTranslator{nullptr};
|
|
|
|
QPointer<QTranslator> qtBaseTranslator{nullptr};
|
|
|
|
QPointer<QTranslator> appTranslator{nullptr};
|
|
|
|
QPointer<QTranslator> pmsTranslator{nullptr};
|
2015-09-19 21:58:32 +02:00
|
|
|
|
|
|
|
virtual void InitTrVars()=0;
|
|
|
|
|
2019-07-01 11:47:06 +02:00
|
|
|
protected slots:
|
|
|
|
virtual void AboutToQuit()=0;
|
|
|
|
|
2015-06-25 12:42:49 +02:00
|
|
|
private:
|
|
|
|
Q_DISABLE_COPY(VAbstractApplication)
|
2018-07-25 10:26:09 +02:00
|
|
|
|
2015-09-19 21:58:32 +02:00
|
|
|
void ClearTranslation();
|
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
|