QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
qetapp.h
Go to the documentation of this file.
1/*
2 Copyright 2006-2024 The QElectroTech Team
3 This file is part of QElectroTech.
4
5 QElectroTech is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 2 of the License, or
8 (at your option) any later version.
9
10 QElectroTech is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef QET_APP_H
19#define QET_APP_H
20
22#include "qetarguments.h"
24
25#include <QByteArray>
26#include <QPalette>
27#include <QSystemTrayIcon>
28#include <QTranslator>
29
30class QSplashScreen;
31class QMenu;
32class QAction;
33class QMainWindow;
34
35#define QETAPP_COMMON_TBT_PROTOCOL "commontbt"
36#define QETAPP_COMPANY_TBT_PROTOCOL "companytbt"
37#define QETAPP_CUSTOM_TBT_PROTOCOL "customtbt"
38
39class AboutQET;
46class QETProject;
49class RecentFiles;
50
55class QETApp : public QObject
56{
57 Q_OBJECT
58 // constructors, destructor
59 public:
60 QETApp();
61 ~QETApp() override;
62
63 private:
64 QETApp(const QETApp &);
65
66 // methods
67 public:
68 static QETApp *instance();
69 void setLanguage(const QString &);
70 static QString langFromSetting ();
71 void switchLayout(Qt::LayoutDirection);
72 static void printHelp();
73 static void printVersion();
74 static void printLicense();
75
77
81 static QList<TitleBlockTemplatesCollection *> availableTitleBlockTemplatesCollections();
83
84 static QString commonElementsDir();
85 static QString companyElementsDir();
86 static QString customElementsDir();
87 static QString commonElementsDirN();
88 static QString companyElementsDirN();
89 static QString customElementsDirN();
90 static void resetCollectionsPath();
91 static QString commonTitleBlockTemplatesDir();
92 static QString companyTitleBlockTemplatesDir();
93 static QString customTitleBlockTemplatesDir();
94 static bool registerProject(QETProject *);
95 static bool unregisterProject(QETProject *);
96 static QMap<uint, QETProject *> registeredProjects();
97 static QETProject *project(const uint &);
98 static int projectId(const QETProject *);
99 static QString configDir();
100 static QString languagesPath();
101 static QString realPath(const QString &);
102 static QString symbolicPath(const QString &);
103 static QStringList handledFileExtensions();
104 static QStringList handledFiles(const QList<QUrl> &);
107
108#ifdef QET_ALLOW_OVERRIDE_CED_OPTION
109 public:
110 static void overrideCommonElementsDir(const QString &);
111 private:
116 static QString m_overrided_common_elements_dir;
117#endif
118
119#ifdef QET_ALLOW_OVERRIDE_CTBTD_OPTION
120 public:
121 static void overrideCommonTitleBlockTemplatesDir(const QString &);
122 private:
128 static QString common_tbt_dir_;
129#endif
130
131#ifdef QET_ALLOW_OVERRIDE_CD_OPTION
132 public:
133 static void overrideConfigDir(const QString &);
134 private:
140 static QString config_dir;
141#endif
142
143 public:
144 static void overrideLangDir(const QString &);
149 static QString lang_dir;
150 static QFont diagramTextsFont(qreal = -1.0);
151 static QFont diagramTextsItemFont(qreal = -1.0);
152 static QFont dynamicTextsItemFont(qreal = -1.0);
153 static QFont indiTextsItemFont (qreal = -1.0);
154 static QETDiagramEditor *diagramEditorForFile(const QString &);
155 static QETDiagramEditor *diagramEditorAncestorOf (const QWidget *child);
156 static QList<QETDiagramEditor *> diagramEditors();
158 static QList<QETElementEditor *> elementEditors();
159 static QList<QETElementEditor *> elementEditors(QETProject *);
160 static QList<QETTitleBlockTemplateEditor *> titleBlockTemplateEditors();
161 static QList<QETTitleBlockTemplateEditor *> titleBlockTemplateEditors(QETProject *);
164
165 protected:
166
167#ifdef Q_OS_DARWIN
168 bool eventFiltrer(QObject *object, QEvent *);
169#endif
170
171 // attributes
172 private:
174 QTranslator qtTranslator;
175 QTranslator qetTranslator;
176 QSystemTrayIcon *m_qsti;
177 QSplashScreen *m_splash_screen;
179 QAction *quitter_qet;
180 QAction *reduce_appli;
188 QAction *new_diagram;
189 QAction *new_element;
190 QHash<QMainWindow *, QByteArray> window_geometries;
191 QHash<QMainWindow *, QByteArray> window_states;
199 QSignalMapper signal_map;
208
213 static QMap<uint, QETProject *> registered_projects_;
214 static uint next_project_id;
218
219 static QString m_common_element_dir;
221
222 static QString m_company_element_dir;
224
225 static QString m_custom_element_dir;
227
229 static QString m_user_custom_tbt_dir;
230
231
232 public slots:
233 void systray(QSystemTrayIcon::ActivationReason);
234 void reduceEveryEditor();
235 void restoreEveryEditor();
242 void newDiagramEditor();
243 void newElementEditor();
244 bool closeEveryEditor();
245 void setMainWindowVisible(QMainWindow *, bool);
246 void invertMainWindowVisibility(QWidget *);
247 void useSystemPalette(bool);
248 void quitQET();
250 void openFiles(const QETArguments &);
251 void openProjectFiles(const QStringList &);
252 void openElementFiles(const QStringList &);
253 void openElementLocations(const QList<ElementsLocation> &);
254 void openTitleBlockTemplate(const TitleBlockTemplateLocation &, bool = false);
255 void openTitleBlockTemplate(const QString &);
256 void openTitleBlockTemplateFiles(const QStringList &);
257 void configureQET();
258 void aboutQET();
259 void receiveMessage(int instanceId, QByteArray message);
260
261 private:
262 template <class T> QList<T *> detectWindows() const;
263 template <class T> void setMainWindowsVisible(bool);
264 QList<QWidget *> floatingToolbarsAndDocksForMainWindow(QMainWindow *) const;
265 void parseArguments();
266 void initSplashScreen();
267 void setSplashScreenStep(const QString & = QString());
268 void initLanguage();
269 void initStyle();
270 void initConfiguration();
271 void initSystemTray();
272 void buildSystemTrayMenu();
273 void checkBackupFiles();
274 void fetchWindowStats(
275 const QList<QETDiagramEditor *> &,
276 const QList<QETElementEditor *> &,
277 const QList<QETTitleBlockTemplateEditor *> &
278 );
279 template <class T> void addWindowsListToMenu(QMenu *, const QList<T *> &);
280 static int projectIdFromString(const QString &);
281 static QETProject *projectFromString(const QString &);
282};
283
284#endif
Definition elementscollectioncache.h:32
The QETApp class This class represents the QElectroTech application.
Definition qetapp.h:56
bool every_template_reduced
Definition qetapp.h:197
static TitleBlockTemplatesFilesCollection * customTitleBlockTemplatesCollection()
QETApp::customTitleBlockTemplatesCollection.
Definition qetapp.cpp:471
void configureQET()
QETApp::configureQET Allows the user to configure QET by launching an appropriate dialog.
Definition qetapp.cpp:1827
void newElementEditor()
QETApp::newElementEditor launches a new element editor.
Definition qetapp.cpp:410
static QString customElementsDir()
QETApp::customElementsDir.
Definition qetapp.cpp:596
QAction * reduce_diagrams
Definition qetapp.h:182
static QString m_custom_element_dir
Definition qetapp.h:225
bool every_template_visible
Definition qetapp.h:198
static RecentFiles * elementsRecentFiles()
QETApp::elementsRecentFiles.
Definition qetapp.cpp:1473
void openProjectFiles(const QStringList &)
QETApp::openProjectFiles Opens a list of files. Files are opened in the first visible schematic edito...
Definition qetapp.cpp:1623
void initStyle()
QETApp::initStyle Setup the gui style.
Definition qetapp.cpp:2017
static QString configDir()
QETApp::configDir Return the QET configuration folder, i.e. the path to the folder in which QET will ...
Definition qetapp.cpp:839
QAction * quitter_qet
Definition qetapp.h:179
QMenu * menu_systray
Definition qetapp.h:178
static bool m_company_element_dir_is_set
Definition qetapp.h:223
static QFont diagramTextsFont(qreal=-1.0)
QETApp::diagramTextsFont The font to use By default the font is "sans Serif" and size 9.
Definition qetapp.cpp:1160
bool every_element_reduced
Definition qetapp.h:195
void setLanguage(const QString &)
QETApp::setLanguage Change the language used by the application.
Definition qetapp.cpp:195
static RecentFiles * m_projects_recent_files
Definition qetapp.h:215
void openFiles(const QETArguments &)
QETApp::openFiles Open files passed as arguments.
Definition qetapp.cpp:1602
static QString m_user_custom_tbt_dir
Definition qetapp.h:229
void reduceEveryEditor()
QETApp::reduceEveryEditor Minimizes all application windows in the systray.
Definition qetapp.cpp:315
static TitleBlockTemplate * default_titleblock_template_
Definition qetapp.h:217
QTranslator qtTranslator
Definition qetapp.h:174
void invertMainWindowVisibility(QWidget *)
QETApp::invertMainWindowVisibility Display a window (schema editors / element editors) if this is hid...
Definition qetapp.cpp:1516
static RecentFiles * m_elements_recent_files
Definition qetapp.h:216
QAction * new_element
Definition qetapp.h:189
static bool registerProject(QETProject *)
QETApp::registerProject.
Definition qetapp.cpp:2491
void restoreElementEditors()
QETApp::restoreElementEditors Restore all element editors in the systray.
Definition qetapp.cpp:372
void initConfiguration()
QETApp::initConfiguration Reads and takes into account the configuration of the application....
Definition qetapp.cpp:2040
QAction * reduce_templates
Definition qetapp.h:186
QSplashScreen * m_splash_screen
Definition qetapp.h:177
static QETApp * instance()
QETApp::instance.
Definition qetapp.cpp:182
QList< QWidget * > floatingToolbarsAndDocksForMainWindow(QMainWindow *) const
QETApp::floatingToolbarsAndDocksForMainWindow.
Definition qetapp.cpp:1878
void restoreDiagramEditors()
QETApp::restoreDiagramEditors Restore all schema editors in the systray.
Definition qetapp.cpp:351
void openTitleBlockTemplateFiles(const QStringList &)
QETApp::openTitleBlockTemplateFiles Open provided title block template files. If a title block templa...
Definition qetapp.cpp:1786
static QString realPath(const QString &)
QETApp::realPath Allows you to know the absolute path of the * .elmt file corresponding to a symbolic...
Definition qetapp.cpp:877
void checkBackupFiles()
QETApp::checkBackupFiles Check for backup files. If backup was found, open a dialog and ask user what...
Definition qetapp.cpp:2275
static TitleBlockTemplatesFilesCollection * companyTitleBlockTemplatesCollection()
QETApp::companyTitleBlockTemplatesCollection.
Definition qetapp.cpp:450
void setMainWindowVisible(QMainWindow *, bool)
QETApp::setMainWindowVisible Show or hide a window (schema editors / element editors)
Definition qetapp.cpp:1488
QETApp(const QETApp &)
void reduceTitleBlockTemplateEditors()
QETApp::reduceTitleBlockTemplateEditors Reduce all known template editors.
Definition qetapp.cpp:381
void addWindowsListToMenu(QMenu *, const QList< T * > &)
Definition qetapp.cpp:2155
QSignalMapper signal_map
Definition qetapp.h:199
void useSystemPalette(bool)
QETApp::useSystemPalette Change the application palette.
Definition qetapp.cpp:1530
static bool m_common_element_dir_is_set
Definition qetapp.h:220
static QString companyElementsDirN()
QETApp::companyElementsDirN like QString QETApp::companyElementsDir but without "/" at the end.
Definition qetapp.cpp:682
static QString m_user_company_tbt_dir
Definition qetapp.h:228
bool every_element_visible
Definition qetapp.h:196
static bool m_custom_element_dir_is_set
Definition qetapp.h:226
QAction * restore_templates
Definition qetapp.h:187
static QString commonElementsDir()
QETApp::commonElementsDir.
Definition qetapp.cpp:533
static QStringList handledFiles(const QList< QUrl > &)
QETApp::handledFiles.
Definition qetapp.cpp:961
static int projectId(const QETProject *)
QETApp::projectId.
Definition qetapp.cpp:2556
QAction * restore_appli
Definition qetapp.h:181
static TitleBlockTemplatesFilesCollection * m_custom_tbt_collection
Definition qetapp.h:211
static QETProject * project(const uint &)
QETApp::project.
Definition qetapp.cpp:2539
~QETApp() override
QETApp::~QETApp.
Definition qetapp.cpp:153
QAction * restore_diagrams
Definition qetapp.h:183
void receiveMessage(int instanceId, QByteArray message)
QETApp::receiveMessage openFiles from message.
Definition qetapp.cpp:1418
bool every_editor_reduced
Definition qetapp.h:192
static TitleBlockTemplatesFilesCollection * m_common_tbt_collection
Definition qetapp.h:209
static TitleBlockTemplate * defaultTitleBlockTemplate()
QETApp::defaultTitleBlockTemplate.
Definition qetapp.cpp:1369
static int projectIdFromString(const QString &)
QETApp::projectIdFromString.
Definition qetapp.cpp:2174
void buildSystemTrayMenu()
QETApp::buildSystemTrayMenu builds the icon menu in the systray.
Definition qetapp.cpp:2218
static QString languagesPath()
QETApp::languagesPath.
Definition qetapp.cpp:1094
static QString companyElementsDir()
QETApp::companyElementsDir.
Definition qetapp.cpp:633
static void printLicense()
QETApp::printLicense Display license on standard output.
Definition qetapp.cpp:2465
static QList< QETTitleBlockTemplateEditor * > titleBlockTemplateEditors()
QETApp::titleBlockTemplateEditors.
Definition qetapp.cpp:1304
void setMainWindowsVisible(bool)
Definition qetapp.cpp:1452
static QETApp * m_qetapp
Definition qetapp.h:173
QHash< QMainWindow *, QByteArray > window_states
Definition qetapp.h:191
static QETDiagramEditor * diagramEditorForFile(const QString &)
QETApp::diagramEditorForFile.
Definition qetapp.cpp:987
static QString commonTitleBlockTemplatesDir()
QETApp::commonTitleBlockTemplatesDir.
Definition qetapp.cpp:728
void newDiagramEditor()
QETApp::newDiagramEditor launches a new schema editor.
Definition qetapp.cpp:400
void systray(QSystemTrayIcon::ActivationReason)
QETApp::systray Manages QSystemTrayIcon related events.
Definition qetapp.cpp:280
bool non_interactive_execution_
non_interactive_execution_ Whether the application will end without any user interaction
Definition qetapp.h:206
void setSplashScreenStep(const QString &=QString())
QETApp::setSplashScreenStep Changes the text of the splash screen and takes events into account....
Definition qetapp.cpp:1994
static QList< QETElementEditor * > elementEditors()
QETApp::elementEditors.
Definition qetapp.cpp:1295
static QETDiagramEditor * diagramEditorAncestorOf(const QWidget *child)
QETApp::diagramEditorAncestorOf.
Definition qetapp.cpp:1008
static uint next_project_id
Definition qetapp.h:214
void restoreEveryEditor()
QETApp::restoreEveryEditor Restores all application windows in the systray.
Definition qetapp.cpp:328
static QString lang_dir
lang_dir Directory containing localization files.
Definition qetapp.h:149
static QList< TitleBlockTemplatesCollection * > availableTitleBlockTemplatesCollections()
QETApp::availableTitleBlockTemplatesCollections.
Definition qetapp.cpp:491
static TitleBlockTemplatesFilesCollection * m_company_tbt_collection
Definition qetapp.h:210
static QString commonElementsDirN()
QETApp::commonElementsDirN like QString QETApp::commonElementsDir but without "/" at the end.
Definition qetapp.cpp:670
void openTitleBlockTemplate(const TitleBlockTemplateLocation &, bool=false)
QETApp::openTitleBlockTemplate Launch a new title block template editor to edit the given template.
Definition qetapp.cpp:1760
void parseArguments()
QETApp::parseArguments Parse the following arguments:
Definition qetapp.cpp:1919
static QTextOrientationSpinBoxWidget * createTextOrientationSpinBoxWidget()
QETApp::createTextOrientationSpinBoxWidget Instantiates a QTextOrientationSpinBoxWidget and configure...
Definition qetapp.cpp:1346
static QString customTitleBlockTemplatesDir()
QETApp::customTitleBlockTemplatesDir.
Definition qetapp.cpp:791
static QString customElementsDirN()
QETApp::customElementsDirN like QString QETApp::customElementsDir but without "/" at the end.
Definition qetapp.cpp:694
void initLanguage()
QETApp::initLanguage Determine and apply the language to use for the application.
Definition qetapp.cpp:2008
static QFont indiTextsItemFont(qreal=-1.0)
QETApp::indiTextsItemFont The default font to use for independent text item.
Definition qetapp.cpp:1243
static QList< QETDiagramEditor * > diagramEditors()
QETApp::diagramEditors.
Definition qetapp.cpp:1264
QAction * new_diagram
Definition qetapp.h:188
static ElementsCollectionCache * collectionCache()
QETApp::collectionCache.
Definition qetapp.cpp:419
void restoreTitleBlockTemplateEditors()
QETApp::restoreTitleBlockTemplateEditors Restore all known template editors.
Definition qetapp.cpp:390
QHash< QMainWindow *, QByteArray > window_geometries
Definition qetapp.h:190
QAction * reduce_elements
Definition qetapp.h:184
void quitQET()
QETApp::quitQET Request the closing of all windows; if the user accepts them, the application quits.
Definition qetapp.cpp:1554
void reduceElementEditors()
QETApp::reduceElementEditors Minimize all element editors in systray.
Definition qetapp.cpp:362
void openElementLocations(const QList< ElementsLocation > &)
QETApp::openElementLocations Open the elements whose location is passed in parameter....
Definition qetapp.cpp:1720
QList< T * > detectWindows() const
Definition qetapp.cpp:1436
static bool unregisterProject(QETProject *)
QETApp::unregisterProject Cancel the recording of the project project.
Definition qetapp.cpp:2518
void aboutQET()
QETApp::aboutQET Open the dialog about qet.
Definition qetapp.cpp:1860
static QString companyTitleBlockTemplatesDir()
QETApp::companyTitleBlockTemplatesDir.
Definition qetapp.cpp:758
bool every_diagram_visible
Definition qetapp.h:194
void reduceDiagramEditors()
QETApp::reduceDiagramEditors Minimize all schema editors in the systray.
Definition qetapp.cpp:341
static void printHelp()
QETApp::printHelp Display help and usage on standard output.
Definition qetapp.cpp:2425
static QFont dynamicTextsItemFont(qreal=-1.0)
QETApp::dynamicTextsFont the default font of dynamic element text item.
Definition qetapp.cpp:1219
static QFont diagramTextsItemFont(qreal=-1.0)
QETApp::diagramTextsItemFont the font for to use in independent text item.
Definition qetapp.cpp:1186
void initSplashScreen()
QETApp::initSplashScreen Initializes the splash screen if and only if the execution is interactive....
Definition qetapp.cpp:1975
bool closeEveryEditor()
QETApp::closeEveryEditor Close all editors.
Definition qetapp.cpp:1135
static TitleBlockTemplatesCollection * titleBlockTemplatesCollection(const QString &)
QETApp::titleBlockTemplatesCollection.
Definition qetapp.cpp:512
void checkRemainingWindows()
QETApp::checkRemainingWindows Check if there are any windows (hidden or not) and exit if there are no...
Definition qetapp.cpp:1571
QAction * reduce_appli
Definition qetapp.h:180
QAction * restore_elements
Definition qetapp.h:185
static RecentFiles * projectsRecentFiles()
QETApp::projectsRecentFiles.
Definition qetapp.cpp:1463
QTranslator qetTranslator
Definition qetapp.h:175
static QStringList handledFileExtensions()
QETApp::handledFileExtensions.
Definition qetapp.cpp:945
bool every_diagram_reduced
Definition qetapp.h:193
void switchLayout(Qt::LayoutDirection)
Definition qetapp.cpp:268
static QMap< uint, QETProject * > registeredProjects()
QETApp::registeredProjects.
Definition qetapp.cpp:2475
static QString langFromSetting()
QETApp::langFromSetting.
Definition qetapp.cpp:251
static QETProject * projectFromString(const QString &)
QETApp::projectFromString.
Definition qetapp.cpp:2207
static ElementsCollectionCache * collections_cache_
Definition qetapp.h:212
QSystemTrayIcon * m_qsti
Definition qetapp.h:176
static QETDiagramEditor * diagramEditor(QETProject *project)
QETApp::diagramEditor.
Definition qetapp.cpp:1274
QPalette initial_palette_
System color palette.
Definition qetapp.h:207
void initSystemTray()
QETApp::initSystemTray Build the icon in the systray and its menu.
Definition qetapp.cpp:2084
void fetchWindowStats(const QList< QETDiagramEditor * > &, const QList< QETElementEditor * > &, const QList< QETTitleBlockTemplateEditor * > &)
QETApp::fetchWindowStats Updates the booleans concerning the state of the windows.
Definition qetapp.cpp:2365
QETArguments qet_arguments_
Command-line arguments parser.
Definition qetapp.h:200
static void resetCollectionsPath()
QETApp::resetCollectionsPath Reset the path of the user and common element collection and also the us...
Definition qetapp.cpp:707
void openElementFiles(const QStringList &)
QETApp::openElementFiles Open the elements files passed in parameter. If an element is already open,...
Definition qetapp.cpp:1669
static QMap< uint, QETProject * > registered_projects_
Definition qetapp.h:213
static void overrideLangDir(const QString &)
QETApp::overrideLangDir Redefines the path of the folder containing the language files.
Definition qetapp.cpp:1081
static QString symbolicPath(const QString &)
QETApp::symbolicPath Build the symbolic path (of the type custom: // tools_pervers / sado_maso / cont...
Definition qetapp.cpp:915
static TitleBlockTemplatesFilesCollection * commonTitleBlockTemplatesCollection()
QETApp::commonTitleBlockTemplatesCollection.
Definition qetapp.cpp:429
static QString m_company_element_dir
Definition qetapp.h:222
QETApp()
QETApp::QETApp.
Definition qetapp.cpp:98
static void printVersion()
QETApp::printVersion Print version to standard output.
Definition qetapp.cpp:2455
static QString m_common_element_dir
Definition qetapp.h:219
Definition qetarguments.h:26
Definition qetdiagrameditor.h:55
Definition qetelementeditor.h:39
Definition qetproject.h:62
Definition qettemplateeditor.h:38
Definition qtextorientationspinboxwidget.h:27
Definition recentfiles.h:26
The TitleBlockTemplate class This class represents an title block template for an electric diagram....
Definition titleblocktemplate.h:37
Definition templatelocation.h:29
Definition templatescollection.h:35
Definition templatescollection.h:125