2020-02-16 18:18:39 +01:00
|
|
|
/************************************************************************
|
|
|
|
**
|
2020-05-23 14:10:05 +02:00
|
|
|
** @file vpapplication.h
|
2020-02-16 18:18:39 +01:00
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 16 2, 2020
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
|
|
|
** This source code is part of the Valentina project, a pattern making
|
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2020 Valentina project
|
|
|
|
** <https://gitlab.com/smart-pattern/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/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
2020-05-23 14:10:05 +02:00
|
|
|
#ifndef VPAPPLICATION_H
|
|
|
|
#define VPAPPLICATION_H
|
2020-02-16 18:18:39 +01:00
|
|
|
|
|
|
|
#include "../vmisc/def.h"
|
2020-05-23 15:44:44 +02:00
|
|
|
#include "vpsettings.h"
|
2020-02-16 18:18:39 +01:00
|
|
|
#include "../vmisc/vabstractapplication.h"
|
2020-05-23 14:43:57 +02:00
|
|
|
#include "vpcommandline.h"
|
2020-04-12 22:28:36 +02:00
|
|
|
|
2021-08-21 15:13:56 +02:00
|
|
|
template <typename T> class QWeakPointer;
|
2020-05-23 14:17:20 +02:00
|
|
|
class VPMainWindow;
|
2020-02-16 18:18:39 +01:00
|
|
|
class QLocalServer;
|
2021-08-21 15:13:56 +02:00
|
|
|
class DialogPuzzlePreferences;
|
2020-02-16 18:18:39 +01:00
|
|
|
|
|
|
|
enum class SocketConnection : bool {Client = false, Server = true};
|
|
|
|
|
2020-05-23 14:10:05 +02:00
|
|
|
class VPApplication : public VAbstractApplication
|
2020-02-16 18:18:39 +01:00
|
|
|
{
|
2022-08-03 13:41:19 +02:00
|
|
|
Q_OBJECT // NOLINT
|
2020-02-16 18:18:39 +01:00
|
|
|
public:
|
2020-05-23 14:10:05 +02:00
|
|
|
VPApplication(int &argc, char **argv);
|
2022-08-03 13:41:19 +02:00
|
|
|
~VPApplication() override;
|
2020-02-16 18:18:39 +01:00
|
|
|
|
2022-08-03 13:41:19 +02:00
|
|
|
auto notify(QObject * receiver, QEvent * event) -> bool override;
|
2020-02-16 18:18:39 +01:00
|
|
|
|
2022-08-03 13:41:19 +02:00
|
|
|
auto IsAppInGUIMode() const -> bool override;
|
|
|
|
auto MainWindow() -> VPMainWindow *;
|
|
|
|
auto MainWindows() -> QList<VPMainWindow*>;
|
|
|
|
auto NewMainWindow() -> VPMainWindow *;
|
|
|
|
auto NewMainWindow(const VPCommandLinePtr &cmd) -> VPMainWindow *;
|
2020-02-16 18:18:39 +01:00
|
|
|
|
|
|
|
void InitOptions();
|
|
|
|
|
2022-08-03 13:41:19 +02:00
|
|
|
auto TrVars() -> const VTranslateVars * override;
|
2020-02-16 18:18:39 +01:00
|
|
|
|
2022-08-03 13:41:19 +02:00
|
|
|
void OpenSettings() override;
|
|
|
|
auto PuzzleSettings() -> VPSettings *;
|
2020-02-16 18:18:39 +01:00
|
|
|
void ActivateDarkMode();
|
|
|
|
|
|
|
|
void ParseCommandLine(const SocketConnection &connection, const QStringList &arguments);
|
2020-05-23 14:43:57 +02:00
|
|
|
void ProcessArguments(const VPCommandLinePtr &cmd);
|
2021-05-20 16:10:43 +02:00
|
|
|
|
2022-08-03 13:41:19 +02:00
|
|
|
static auto CommandLine() -> VPCommandLinePtr;
|
|
|
|
static auto VApp() -> VPApplication *;
|
2021-08-21 15:13:56 +02:00
|
|
|
|
|
|
|
auto PreferencesDialog() const -> QSharedPointer<DialogPuzzlePreferences>;
|
|
|
|
void SetPreferencesDialog(const QSharedPointer<DialogPuzzlePreferences> &newPreferencesDialog);
|
|
|
|
|
2020-02-16 18:18:39 +01:00
|
|
|
public slots:
|
|
|
|
void ProcessCMD();
|
|
|
|
|
|
|
|
protected:
|
2022-08-03 13:41:19 +02:00
|
|
|
void InitTrVars() override;
|
|
|
|
auto event(QEvent *e) -> bool override;
|
2020-02-16 18:18:39 +01:00
|
|
|
|
|
|
|
protected slots:
|
2022-08-03 13:41:19 +02:00
|
|
|
void AboutToQuit() override;
|
2020-02-16 18:18:39 +01:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void NewLocalSocketConnection();
|
|
|
|
|
|
|
|
private:
|
2022-08-08 14:25:14 +02:00
|
|
|
// cppcheck-suppress unknownMacro
|
2022-08-03 13:41:19 +02:00
|
|
|
Q_DISABLE_COPY_MOVE(VPApplication) //NOLINT
|
|
|
|
QList<QPointer<VPMainWindow> > m_mainWindows{};
|
|
|
|
QLocalServer *m_localServer{nullptr};
|
2021-08-21 15:13:56 +02:00
|
|
|
QWeakPointer<DialogPuzzlePreferences> m_preferencesDialog{};
|
2020-02-16 18:18:39 +01:00
|
|
|
|
|
|
|
void Clean();
|
2022-08-03 13:41:19 +02:00
|
|
|
|
|
|
|
void StartLocalServer(const QString &serverName);
|
|
|
|
|
2022-08-08 15:14:46 +02:00
|
|
|
auto StartWithFiles(const VPCommandLinePtr &cmd, const QStringList &rawLayouts) -> bool;
|
|
|
|
auto SingleStart(const VPCommandLinePtr &cmd, const QStringList &rawLayouts) -> bool;
|
2020-02-16 18:18:39 +01:00
|
|
|
};
|
|
|
|
|
2020-05-23 14:10:05 +02:00
|
|
|
#endif // VPAPPLICATION_H
|