2007-12-01 10:47:15 +00:00
|
|
|
/*
|
2017-01-20 10:55:49 +00:00
|
|
|
Copyright 2006-2017 The QElectroTech Team
|
2007-12-01 10:47:15 +00:00
|
|
|
This file is part of QElectroTech.
|
|
|
|
|
|
|
|
QElectroTech 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 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
QElectroTech 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 QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2007-09-21 17:13:11 +00:00
|
|
|
#ifndef QET_APP_H
|
|
|
|
#define QET_APP_H
|
2016-05-27 12:59:24 +00:00
|
|
|
|
2007-09-21 17:13:11 +00:00
|
|
|
#include <QTranslator>
|
2016-05-27 12:59:24 +00:00
|
|
|
#include <QSystemTrayIcon>
|
|
|
|
#include <QPalette>
|
|
|
|
|
|
|
|
#include "qetsingleapplication.h"
|
2009-04-03 19:30:25 +00:00
|
|
|
#include "elementslocation.h"
|
2012-01-08 17:04:34 +00:00
|
|
|
#include "templatelocation.h"
|
2008-07-26 15:26:19 +00:00
|
|
|
#include "qetarguments.h"
|
2012-01-15 19:26:40 +00:00
|
|
|
|
2016-05-27 12:59:24 +00:00
|
|
|
class QSplashScreen;
|
|
|
|
class QMenu;
|
|
|
|
class QAction;
|
|
|
|
class QMainWindow;
|
|
|
|
|
2012-01-15 19:26:40 +00:00
|
|
|
#define QETAPP_COMMON_TBT_PROTOCOL "commontbt"
|
|
|
|
#define QETAPP_CUSTOM_TBT_PROTOCOL "customtbt"
|
|
|
|
|
2009-06-19 19:31:48 +00:00
|
|
|
class AboutQET;
|
2007-09-21 17:13:11 +00:00
|
|
|
class QETDiagramEditor;
|
|
|
|
class QETElementEditor;
|
2011-10-08 21:54:53 +00:00
|
|
|
class ElementsCollectionCache;
|
2010-12-20 02:45:36 +00:00
|
|
|
class TitleBlockTemplate;
|
2012-01-08 17:04:34 +00:00
|
|
|
class TitleBlockTemplatesCollection;
|
|
|
|
class TitleBlockTemplatesFilesCollection;
|
2009-04-03 19:30:25 +00:00
|
|
|
class QETProject;
|
2011-12-27 01:39:45 +00:00
|
|
|
class QETTitleBlockTemplateEditor;
|
2010-02-09 19:29:55 +00:00
|
|
|
class QTextOrientationSpinBoxWidget;
|
2008-07-30 11:51:27 +00:00
|
|
|
class RecentFiles;
|
2012-01-15 19:26:40 +00:00
|
|
|
|
2007-09-21 17:13:11 +00:00
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
This class represents the QElectroTech application.
|
2007-09-21 17:13:11 +00:00
|
|
|
*/
|
2008-07-17 19:25:57 +00:00
|
|
|
class QETApp : public QETSingleApplication {
|
2007-09-21 17:13:11 +00:00
|
|
|
Q_OBJECT
|
2012-11-09 21:09:24 +00:00
|
|
|
// constructors, destructor
|
2007-09-21 17:13:11 +00:00
|
|
|
public:
|
|
|
|
QETApp(int &, char **);
|
2017-08-05 02:10:01 +00:00
|
|
|
~QETApp() override;
|
2007-09-21 17:13:11 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
QETApp(const QETApp &);
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// methods
|
2007-09-21 17:13:11 +00:00
|
|
|
public:
|
2008-07-20 11:37:31 +00:00
|
|
|
static QETApp *instance();
|
2007-09-21 17:13:11 +00:00
|
|
|
void setLanguage(const QString &);
|
2014-01-21 19:23:44 +00:00
|
|
|
static QString langFromSetting ();
|
2012-02-20 21:20:34 +00:00
|
|
|
void switchLayout(Qt::LayoutDirection);
|
2007-10-28 01:32:57 +00:00
|
|
|
static void printHelp();
|
|
|
|
static void printVersion();
|
|
|
|
static void printLicense();
|
2007-09-21 17:13:11 +00:00
|
|
|
|
2012-02-06 21:19:58 +00:00
|
|
|
static ElementsCollectionCache *collectionCache();
|
2014-02-12 17:36:35 +00:00
|
|
|
static QStringList elementInfoKeys();
|
2017-08-06 10:18:33 +00:00
|
|
|
static QString elementTranslatedInfoKey(const QString &);
|
2017-08-16 13:52:15 +00:00
|
|
|
static QString elementInfoToVar(const QString &info);
|
2009-04-03 19:30:25 +00:00
|
|
|
|
2012-01-08 17:04:34 +00:00
|
|
|
static TitleBlockTemplatesFilesCollection *commonTitleBlockTemplatesCollection();
|
|
|
|
static TitleBlockTemplatesFilesCollection *customTitleBlockTemplatesCollection();
|
|
|
|
static QList<TitleBlockTemplatesCollection *> availableTitleBlockTemplatesCollections();
|
2012-01-15 19:26:40 +00:00
|
|
|
static TitleBlockTemplatesCollection *titleBlockTemplatesCollection(const QString &);
|
2012-01-08 17:04:34 +00:00
|
|
|
|
2008-07-17 19:25:57 +00:00
|
|
|
static QString userName();
|
2007-09-21 17:13:11 +00:00
|
|
|
static QString commonElementsDir();
|
|
|
|
static QString customElementsDir();
|
2016-02-13 12:51:56 +00:00
|
|
|
static QString commonElementsDirN();
|
|
|
|
static QString customElementsDirN();
|
2012-01-08 17:04:34 +00:00
|
|
|
static QString commonTitleBlockTemplatesDir();
|
|
|
|
static QString customTitleBlockTemplatesDir();
|
2009-04-03 19:30:25 +00:00
|
|
|
static bool registerProject(QETProject *);
|
|
|
|
static bool unregisterProject(QETProject *);
|
|
|
|
static QMap<uint, QETProject *> registeredProjects();
|
|
|
|
static QETProject *project(const uint &);
|
|
|
|
static int projectId(const QETProject *);
|
2007-09-21 17:13:11 +00:00
|
|
|
static QString configDir();
|
|
|
|
static QString languagesPath();
|
2007-10-04 20:34:29 +00:00
|
|
|
static QString realPath(const QString &);
|
|
|
|
static QString symbolicPath(const QString &);
|
2012-05-24 17:27:15 +00:00
|
|
|
static QStringList handledFileExtensions();
|
|
|
|
static QStringList handledFiles(const QList<QUrl> &);
|
2008-07-30 11:51:27 +00:00
|
|
|
static RecentFiles *projectsRecentFiles();
|
|
|
|
static RecentFiles *elementsRecentFiles();
|
2007-10-04 20:34:29 +00:00
|
|
|
#ifdef QET_ALLOW_OVERRIDE_CED_OPTION
|
2007-11-10 17:52:30 +00:00
|
|
|
public:
|
2007-10-04 20:34:29 +00:00
|
|
|
static void overrideCommonElementsDir(const QString &);
|
|
|
|
private:
|
2012-11-09 21:09:24 +00:00
|
|
|
static QString common_elements_dir; ///< Directory containing the common elements collection
|
2007-10-04 20:34:29 +00:00
|
|
|
#endif
|
2012-01-08 17:04:34 +00:00
|
|
|
#ifdef QET_ALLOW_OVERRIDE_CTBTD_OPTION
|
|
|
|
public:
|
|
|
|
static void overrideCommonTitleBlockTemplatesDir(const QString &);
|
|
|
|
private:
|
|
|
|
static QString common_tbt_dir_; ///< Directory containing the common title block templates collection
|
|
|
|
#endif
|
2007-11-10 17:52:30 +00:00
|
|
|
#ifdef QET_ALLOW_OVERRIDE_CD_OPTION
|
|
|
|
public:
|
|
|
|
static void overrideConfigDir(const QString &);
|
|
|
|
private:
|
2012-11-09 21:09:24 +00:00
|
|
|
static QString config_dir; ///< Directory containing the user configuration and the custom elements collection
|
2007-11-10 17:52:30 +00:00
|
|
|
#endif
|
2007-12-21 18:20:18 +00:00
|
|
|
public:
|
2008-08-17 21:08:31 +00:00
|
|
|
static void overrideLangDir(const QString &);
|
2012-11-09 21:09:24 +00:00
|
|
|
static QString lang_dir; ///< Directory containing localization files.
|
2011-02-08 06:53:47 +00:00
|
|
|
static QFont diagramTextsFont(qreal = -1.0);
|
2017-12-10 01:03:36 +00:00
|
|
|
static QFont diagramTextsItemFont(qreal = -1.0);
|
2009-04-03 19:30:25 +00:00
|
|
|
static QETDiagramEditor *diagramEditorForFile(const QString &);
|
2016-11-10 19:49:33 +00:00
|
|
|
static QETDiagramEditor *diagramEditorAncestorOf (const QWidget *child);
|
2009-04-03 19:30:25 +00:00
|
|
|
static QList<QETDiagramEditor *> diagramEditors();
|
|
|
|
static QList<QETElementEditor *> elementEditors();
|
|
|
|
static QList<QETElementEditor *> elementEditors(QETProject *);
|
2011-12-27 01:39:45 +00:00
|
|
|
static QList<QETTitleBlockTemplateEditor *> titleBlockTemplateEditors();
|
|
|
|
static QList<QETTitleBlockTemplateEditor *> titleBlockTemplateEditors(QETProject *);
|
2010-02-09 19:29:55 +00:00
|
|
|
static QTextOrientationSpinBoxWidget *createTextOrientationSpinBoxWidget();
|
2010-12-20 02:45:36 +00:00
|
|
|
static TitleBlockTemplate *defaultTitleBlockTemplate();
|
2007-11-10 17:52:30 +00:00
|
|
|
|
2007-10-10 17:50:26 +00:00
|
|
|
protected:
|
2008-07-17 19:25:57 +00:00
|
|
|
#ifdef Q_OS_DARWIN
|
2007-10-10 17:50:26 +00:00
|
|
|
bool event(QEvent *);
|
2008-07-17 19:25:57 +00:00
|
|
|
#endif
|
2007-09-21 17:13:11 +00:00
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// attributes
|
2007-09-21 17:13:11 +00:00
|
|
|
private:
|
|
|
|
QTranslator qtTranslator;
|
|
|
|
QTranslator qetTranslator;
|
|
|
|
QSystemTrayIcon *qsti;
|
2008-08-02 16:53:42 +00:00
|
|
|
QSplashScreen *splash_screen_;
|
2007-09-21 17:13:11 +00:00
|
|
|
QMenu *menu_systray;
|
2007-09-22 13:27:14 +00:00
|
|
|
QAction *quitter_qet;
|
2007-09-21 17:13:11 +00:00
|
|
|
QAction *reduce_appli;
|
|
|
|
QAction *restore_appli;
|
2007-09-22 13:27:14 +00:00
|
|
|
QAction *reduce_diagrams;
|
|
|
|
QAction *restore_diagrams;
|
|
|
|
QAction *reduce_elements;
|
|
|
|
QAction *restore_elements;
|
2011-12-27 01:39:45 +00:00
|
|
|
QAction *reduce_templates;
|
|
|
|
QAction *restore_templates;
|
2007-09-22 13:27:14 +00:00
|
|
|
QAction *new_diagram;
|
|
|
|
QAction *new_element;
|
2007-09-21 17:13:11 +00:00
|
|
|
QHash<QMainWindow *, QByteArray> window_geometries;
|
|
|
|
QHash<QMainWindow *, QByteArray> window_states;
|
2007-09-21 18:07:05 +00:00
|
|
|
bool every_editor_reduced;
|
2007-09-22 13:27:14 +00:00
|
|
|
bool every_diagram_reduced;
|
|
|
|
bool every_diagram_visible;
|
|
|
|
bool every_element_reduced;
|
|
|
|
bool every_element_visible;
|
2011-12-27 01:39:45 +00:00
|
|
|
bool every_template_reduced;
|
|
|
|
bool every_template_visible;
|
2007-09-22 13:27:14 +00:00
|
|
|
QSignalMapper signal_map;
|
2012-11-09 21:09:24 +00:00
|
|
|
QETArguments qet_arguments_; ///< Comand-line arguments parser
|
|
|
|
bool non_interactive_execution_; ///< Whether the application will end without any user interaction
|
|
|
|
QPalette initial_palette_; ///< System color palette
|
2009-04-03 19:30:25 +00:00
|
|
|
|
2012-01-08 17:04:34 +00:00
|
|
|
static TitleBlockTemplatesFilesCollection *common_tbt_collection_;
|
|
|
|
static TitleBlockTemplatesFilesCollection *custom_tbt_collection_;
|
2011-10-08 21:54:53 +00:00
|
|
|
static ElementsCollectionCache *collections_cache_;
|
2009-04-03 19:30:25 +00:00
|
|
|
static QMap<uint, QETProject *> registered_projects_;
|
|
|
|
static uint next_project_id;
|
2008-07-30 11:51:27 +00:00
|
|
|
static RecentFiles *projects_recent_files_;
|
|
|
|
static RecentFiles *elements_recent_files_;
|
2010-12-20 02:45:36 +00:00
|
|
|
static TitleBlockTemplate *default_titleblock_template_;
|
2009-05-24 17:46:44 +00:00
|
|
|
|
2007-09-21 17:13:11 +00:00
|
|
|
public slots:
|
|
|
|
void systray(QSystemTrayIcon::ActivationReason);
|
2007-09-22 13:27:14 +00:00
|
|
|
void reduceEveryEditor();
|
|
|
|
void restoreEveryEditor();
|
|
|
|
void reduceDiagramEditors();
|
|
|
|
void restoreDiagramEditors();
|
|
|
|
void reduceElementEditors();
|
|
|
|
void restoreElementEditors();
|
2011-12-27 01:39:45 +00:00
|
|
|
void reduceTitleBlockTemplateEditors();
|
|
|
|
void restoreTitleBlockTemplateEditors();
|
2007-09-22 13:27:14 +00:00
|
|
|
void newDiagramEditor();
|
|
|
|
void newElementEditor();
|
2007-10-04 12:19:01 +00:00
|
|
|
bool closeEveryEditor();
|
2007-09-22 13:27:14 +00:00
|
|
|
void setMainWindowVisible(QMainWindow *, bool);
|
|
|
|
void invertMainWindowVisibility(QWidget *);
|
2009-05-24 17:46:44 +00:00
|
|
|
void useSystemPalette(bool);
|
2007-10-04 12:19:01 +00:00
|
|
|
void quitQET();
|
|
|
|
void checkRemainingWindows();
|
2008-07-17 19:25:57 +00:00
|
|
|
void messageReceived(const QString &);
|
2008-07-26 15:26:19 +00:00
|
|
|
void openFiles(const QETArguments &);
|
|
|
|
void openProjectFiles(const QStringList &);
|
|
|
|
void openElementFiles(const QStringList &);
|
2010-03-28 16:27:48 +00:00
|
|
|
void openElementLocations(const QList<ElementsLocation> &);
|
2012-01-25 07:29:50 +00:00
|
|
|
void openTitleBlockTemplate(const TitleBlockTemplateLocation &, bool = false);
|
2012-01-12 07:04:09 +00:00
|
|
|
void openTitleBlockTemplate(const QString &);
|
2012-04-09 15:27:15 +00:00
|
|
|
void openTitleBlockTemplateFiles(const QStringList &);
|
2009-06-19 19:31:48 +00:00
|
|
|
void configureQET();
|
|
|
|
void aboutQET();
|
2007-09-21 17:13:11 +00:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void cleanup();
|
|
|
|
|
|
|
|
private:
|
2011-12-27 01:39:45 +00:00
|
|
|
template <class T> QList<T *> detectWindows() const;
|
|
|
|
template <class T> void setMainWindowsVisible(bool);
|
2007-09-21 18:59:43 +00:00
|
|
|
QList<QWidget *> floatingToolbarsAndDocksForMainWindow(QMainWindow *) const;
|
2008-07-19 17:34:13 +00:00
|
|
|
void parseArguments();
|
2008-08-02 16:53:42 +00:00
|
|
|
void initSplashScreen();
|
|
|
|
void setSplashScreenStep(const QString & = QString());
|
2008-07-19 17:34:13 +00:00
|
|
|
void initLanguage();
|
|
|
|
void initStyle();
|
|
|
|
void initConfiguration();
|
|
|
|
void initSystemTray();
|
2007-09-22 13:27:14 +00:00
|
|
|
void buildSystemTrayMenu();
|
2011-12-27 01:39:45 +00:00
|
|
|
void fetchWindowStats(
|
|
|
|
const QList<QETDiagramEditor *> &,
|
|
|
|
const QList<QETElementEditor *> &,
|
|
|
|
const QList<QETTitleBlockTemplateEditor *> &
|
|
|
|
);
|
|
|
|
template <class T> void addWindowsListToMenu(QMenu *, const QList<T *> &);
|
2012-01-15 19:26:40 +00:00
|
|
|
static int projectIdFromString(const QString &);
|
|
|
|
static QETProject *projectFromString(const QString &);
|
2007-09-21 17:13:11 +00:00
|
|
|
};
|
2007-10-30 14:00:11 +00:00
|
|
|
|
2007-09-21 17:13:11 +00:00
|
|
|
#endif
|