ImagingTools Core SDK
CThumbnailDecoratorGuiComp.h
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ImtCore-Commercial
2#pragma once
3
4
5// Qt includes
6#include <QtCore/QMap>
7#include <QtCore/QTimer>
8#include <QtCore/QProcess>
9#include <QtWidgets/QListView>
10#include <QtWidgets/QMenu>
11#include <QtGui/QStandardItemModel>
12#include <QtGui/QStandardItem>
13
14// ACF includes
15#include <imod/CMultiModelDispatcherBase.h>
16#include <ilog/IMessageConsumer.h>
17#include <iqtgui/TDesignerGuiCompBase.h>
18#include <ibase/ICommandsProvider.h>
19#include <iprm/ISelectionParam.h>
20#include <iqtgui/CHierarchicalCommand.h>
21#include <iqtgui/TRestorableGuiWrap.h>
22#include <iqtgui/IDialog.h>
23#include <imeas/INumericValue.h>
24#include <iauth/ILogin.h>
25#include <iauth/IRightsProvider.h>
26
27// ImtCore includes
28#include <imtgui/IWidgetProvider.h>
29#include <imtgui/IPageNavigationController.h>
30#include <imtgui/CThumbPageItemGuiDelegate.h>
31#include <GeneratedFiles/imtgui/ui_CThumbnailDecoratorGuiComp.h>
32
33
34class QToolBar;
35
36namespace imtbase
37{
38 class CCollectionInfo;
39}
40
41
42namespace imtgui
43{
44
45
46class CThumbnailDecoratorGuiCompAttr:
47 public iqtgui::TRestorableGuiWrap<iqtgui::TDesignerGuiCompBase<Ui::CThumbnailDecoratorGuiComp>>
48{
49public:
50 typedef iqtgui::TRestorableGuiWrap<
51 iqtgui::TDesignerGuiCompBase<Ui::CThumbnailDecoratorGuiComp>> BaseClass;
52
53 I_BEGIN_BASE_COMPONENT(CThumbnailDecoratorGuiCompAttr);
54 I_ASSIGN(m_horizontalItemsViewAttrPtr, "HorizontalItemsView", "Count of visual items in horizontal row", false, 1);
55 I_ASSIGN(m_verticalItemsViewAttrPtr, "VerticalItemsView", "Count of visual items in vertical column", false, 1);
56 I_ASSIGN(m_horizontalSpacingAttrPtr, "HorizontalSpacing", "Horizontal spacing of items on view", false, 15);
57 I_ASSIGN(m_verticalSpacingAttrPtr, "VerticalSpacing", "Vertical spacing of items on view", false, 15);
58 I_ASSIGN(m_horizontalFrameMarginAttrPtr, "HorizontalFrameMargin", "Horizontal (left&right) side margin of thumbnail frame", false, 15);
59 I_ASSIGN(m_verticalFrameMarginAttrPtr, "VerticalFrameMargin", "Vertical (top&bottom) side margin of thumbnail frame", false, 15);
60 I_ASSIGN(m_maximumFrameWidthAttrPtr, "MaximumFrameWidth", "Maximum width of thumbnail frame", false, 320);
61 I_ASSIGN(m_maximumFrameHeightAttrPtr, "MaximumFrameHeight", "Maximum height of thumbnail frame", false, 240);
62 I_ASSIGN(m_autoLogoutMinutesAttrPtr, "AutoLogoutMinutes", "Time intervall for the automatic logout", false, 60);
63 I_ASSIGN(m_defaultPageIndexAttrPtr, "DefaultPageIndex", "Index of the default (start) page", false, -1);
64 I_ASSIGN(m_welcomeTextAttrPtr, "WelcomeText", "Welcome text on the start page", true, "Welcome");
65 I_ASSIGN(m_closeRightIdAttrPtr, "CloseRightId", "ID of the user right to close the application", false, "Close");
66 I_ASSIGN_MULTI_0(m_disablePageListViewIndexesAttrPtr, "DisablePageListViewIndexes", "List of page indexes where the page list view is not shown", false);
67 I_ASSIGN(m_showPageTitlesAttrPtr, "ShowPageTitles", "Show title of the current page in the main tool bar", true, true);
68 I_ASSIGN(m_loginGuiCompPtr, "LoginGui", "Login gui", false, "StandardLoginGui");
69 I_END_COMPONENT;
70
71protected:
72 I_ATTR(int, m_horizontalItemsViewAttrPtr);
73 I_ATTR(int, m_verticalItemsViewAttrPtr);
74 I_ATTR(int, m_horizontalSpacingAttrPtr);
75 I_ATTR(int, m_verticalSpacingAttrPtr);
76 I_ATTR(int, m_horizontalFrameMarginAttrPtr);
77 I_ATTR(int, m_verticalFrameMarginAttrPtr);
78 I_ATTR(int, m_maximumFrameWidthAttrPtr);
79 I_ATTR(int, m_maximumFrameHeightAttrPtr);
80 I_ATTR(int, m_autoLogoutMinutesAttrPtr);
81 I_ATTR(int, m_defaultPageIndexAttrPtr);
82 I_TEXTATTR(m_welcomeTextAttrPtr);
83 I_ATTR(QByteArray, m_closeRightIdAttrPtr);
84 I_MULTIATTR(int, m_disablePageListViewIndexesAttrPtr);
85 I_ATTR(bool, m_showPageTitlesAttrPtr);
86 I_REF(iqtgui::IGuiObject, m_loginGuiCompPtr);
87};
88
89
90class CThumbnailDecoratorGuiCompAttr2: public CThumbnailDecoratorGuiCompAttr
91{
92public:
93 typedef CThumbnailDecoratorGuiCompAttr BaseClass;
94
95 I_BEGIN_BASE_COMPONENT(CThumbnailDecoratorGuiCompAttr2);
96 I_ASSIGN(m_hideMenuPanelOnHomePageAttrPtr, "HideMenuPanelOnHomePage", "Hide menu panel when home page is active", true, true);
97 I_ASSIGN(m_hideCommandButtonAttrPtr, "HideCommandButton", "Hide command button", true, true);
98 I_ASSIGN(m_hideHomeButtonAttrPtr, "HideHomeButton", "Hide home button", true, false);
99 I_ASSIGN(m_accountMenuCompPtr, "AccountMenu", "Menu for logged account", false, "AccountMenu");
100 I_ASSIGN(m_viewPageNavigationAttrPtr, "ViewPageNavigation", "View page navigation", true, true);
101 I_ASSIGN(m_quitDialogIgnoredAttrPtr, "QuitDialogIgnored", "If true, exit application without dialog", true, false);
102 I_ASSIGN(m_additionalCommandsProviderCompPtr, "AdditionalCommands", "Additional tool commands showed on the right side of the main tool bar", false, "AdditionalCommands");
103 I_ASSIGN_TO(m_additionalCommandsProviderModelCompPtr, m_additionalCommandsProviderCompPtr, false);
104 I_ASSIGN_MULTI_0(m_additionalCommandIdsAttrPtr, "AdditionalCommandIds", "Additional command IDs", false);
105 I_ASSIGN_MULTI_0(m_additionalCommandActivatorsCompPtr, "AdditionalCommandActivators", "Additional command activators that allow the display of commands", false);
106 I_ASSIGN(m_rightsCommandsCompPtr, "RightsCommands", "Additional tool commands showed on the right side of the login button", false, "RightsCommands");
107 I_ASSIGN(m_fullscreenCommandCompPtr, "FullscreenCommand", "Tool command to switch an application to full screen mode", false, "FullscreenCommand");
108 I_ASSIGN(m_appLogoPathAttrPtr, "AppLogoPath", "Path to the application logo in resources", true, "");
109 I_END_COMPONENT;
110
111protected:
112 I_ATTR(bool, m_hideMenuPanelOnHomePageAttrPtr);
113 I_ATTR(bool, m_hideHomeButtonAttrPtr);
114 I_ATTR(bool, m_hideCommandButtonAttrPtr);
115 I_REF(iqtgui::IGuiObject, m_accountMenuCompPtr);
116 I_ATTR(bool, m_viewPageNavigationAttrPtr);
117 I_ATTR(bool, m_quitDialogIgnoredAttrPtr);
118 I_REF(ibase::ICommandsProvider, m_additionalCommandsProviderCompPtr);
119 I_REF(imod::IModel, m_additionalCommandsProviderModelCompPtr);
120 I_MULTIATTR(QByteArray, m_additionalCommandIdsAttrPtr);
121 I_MULTIREF(iprm::IEnableableParam, m_additionalCommandActivatorsCompPtr);
122 I_REF(ibase::ICommandsProvider, m_rightsCommandsCompPtr);
123 I_REF(ibase::ICommandsProvider, m_fullscreenCommandCompPtr);
124 I_ATTR(QString, m_appLogoPathAttrPtr);
125};
126
127
128class CThumbnailDecoratorGuiComp:
129 public CThumbnailDecoratorGuiCompAttr2,
130 public virtual ibase::ICommandsProvider,
131 virtual public IWidgetProvider
132{
133 Q_OBJECT
134
135public:
136 typedef CThumbnailDecoratorGuiCompAttr2 BaseClass;
137
138 I_BEGIN_COMPONENT(CThumbnailDecoratorGuiComp);
139 I_REGISTER_INTERFACE(ibase::ICommandsProvider);
140 I_REGISTER_INTERFACE(IWidgetProvider);
141 I_ASSIGN(m_menuPanelVisibilityCompPtr, "MenuPanelVisibility", "Menu panel visibility status", false, "MenuPanelVisibility");
142 I_ASSIGN(m_pagesWidgetCompPtr, "PageUiContainer", "UI component containing all application pages", true, "PageUiContainer");
143 I_ASSIGN(m_pagesCompPtr, "PageModel", "Data model describing the used pages", true, "PageModel");
144 I_ASSIGN_TO(m_pagesModelCompPtr, m_pagesCompPtr, true);
145 I_ASSIGN(m_commandsProviderCompPtr, "Commands", "Provider of the commands showed in the main tool bar", false, "Commands");
146 I_ASSIGN_TO(m_commandsProviderModelCompPtr, m_commandsProviderCompPtr, false);
147 I_ASSIGN(m_loginCompPtr, "Login", "Login logic component", false, "Login");
148 I_ASSIGN_TO(m_loginModelCompPtr, m_loginCompPtr, false);
149 I_ASSIGN(m_rightsCompPtr, "Rights", "User rights for the application", false, "Rights");
150 I_ASSIGN_TO(m_rightsModelCompPtr, m_rightsCompPtr, false);
151 I_ASSIGN(m_autoLogoutMinutesCompPtr, "AutoLogoutTime", "Parameter to control automatical logout interval. Setting of this parameter overrides 'AutoLogoutMinutes' value", false, "AutoLogoutTime");
152 I_ASSIGN(m_leftMenuPanelGuiCompPtr, "LeftMenuPanel", "Left menu panel", false, "LeftMenuPanel");
153 I_ASSIGN(m_pageNavigationControllerCompPtr, "NavigationController", "Page navigation controller", false, "NavigationController");
154 I_ASSIGN(m_dashboardGuiCompPtr, "Dashboard", "Dashboard UI", false, "Dashboard");
155 I_ASSIGN(m_preferencesDialogCompPtr, "PreferencesDialog", "Preferences dialog", false, "Preferences");
156 I_END_COMPONENT;
157
158 enum
159 {
160 LOGIN_PAGE_INDEX,
161 HOME_PAGE_INDEX,
162 PAGE_CONTAINER_INDEX
163 };
164
165 enum LoginMode
166 {
170 LM_STRONG,
171
175 LM_DEFAULT
176 };
177
178 enum UserAction
179 {
180 UA_APPLICATION_EXIT = 0,
181 UA_LOGIN_CONTROL_ENABLED,
182 UA_LOGIN_ENABLED,
183 UA_HOME_ENABLED,
184 };
185
186 CThumbnailDecoratorGuiComp();
187
188 // reimplemented (imtgui::IWidgetProvider)
189 virtual const imtbase::ICollectionInfo* GetWidgetList() const override;
190 virtual QWidget* GetWidgetPtr(const QByteArray& widgetId) const override;
191
192 // reimplemented (ibase::ICommandsProvider)
193 virtual const ibase::IHierarchicalCommand* GetCommands() const override;
194
195 // reimplemented (QObject)
196 virtual bool eventFilter(QObject* watched, QEvent* event) override;
197
198protected:
199 // reimplemented (iqtgui::TRestorableGuiWrap)
200 virtual void OnRestoreSettings(const QSettings& settings) override;
201 virtual void OnSaveSettings(QSettings& settings) const override;
202
203 // reimplemented (iqtgui::CGuiComponentBase)
204 virtual void OnGuiCreated() override;
205 virtual void OnGuiDestroyed() override;
206 virtual void OnGuiRetranslate() override;
207 virtual void OnTryClose(bool* ignoredPtr = nullptr) override;
208 virtual void OnGuiDesignChanged();
209
210 // reimplemented (icomp::CComponentBase)
211 virtual void OnComponentCreated() override;
212 virtual void OnComponentDestroyed() override;
213
214private Q_SLOTS:
215 void on_PageList_clicked(const QModelIndex& index);
216 void on_ExitButton_clicked();
217 void on_SubPages_itemSelectionChanged();
218 void on_HomeButton_clicked();
219 void on_LoginControlButton_clicked();
220 void on_LoginCancelButton_clicked();
221 void on_CommandsMenuButton_clicked();
222 void OnAutoLogoutTimer();
223 void OnCheckIsFullScreenTimer();
224 void on_BackPageButton_clicked();
225 void on_NextPageButton_clicked();
226 void on_DashboardButton_clicked();
227 void on_PreferencesButton_clicked();
228 void UpdateCommands();
229
230Q_SIGNALS:
231 void EmitUpdateCommands();
232
233private:
234 void ShowLoginPage();
235 void ShowHomePage();
236 void SwitchToPage(int index);
237 void UpdateLoginButtonsState();
238 void CreatePages(const iprm::ISelectionParam* selectionPtr);
239 void CreateMenu(const iprm::ISelectionParam* selectionPtr, QTreeWidgetItem* parentItemPtr);
240 void UpdatePageState();
241 void UpdateAdditionalCommandsEnabled();
242 LoginMode GetLoginMode();
243 int GetAutoLogoutTime() const;
244 void ProcessLogout();
245 bool IsUserActionAllowed(UserAction action);
246 void ExitApplication();
247 bool IsHomePageEnabled() const;
248 const ibase::IHierarchicalCommand* FindCommand(const ibase::IHierarchicalCommand* commandPtr, const QByteArray& commandId) const;
249
255 void GetMenuLayout(const int count);
256 void SetLayoutProperties(const int count);
257 void UpdateSettings(const int count);
258 void UpdateSpacing();
259 void UpdateMargins();
260 void UpdateMaxSize();
261 void UpdateMinSize();
262 void UpdateAdditionalCommands();
263 int SetupCommandsMenu(const iqtgui::CHierarchicalCommand& command, QMenu& result, int& prevGroupId);
264 void UpdateMenuVisibility();
265private:
266 struct ItemInfo
267 {
268 ItemInfo()
269 :selectionPtr(nullptr),
270 pageIndex(-1)
271 {
272 }
273
274 iprm::ISelectionParam* selectionPtr;
275 int pageIndex;
276 };
277
278 typedef QMap<QStandardItem*, ItemInfo> ItemInfoMap;
279 ItemInfoMap m_itemInfoMap;
280
281 typedef QMap<QTreeWidgetItem*, ItemInfo> MenuItemInfoMap;
282 MenuItemInfoMap m_subPageItemMap;
283
284
285 class CommandsObserver: public imod::CMultiModelDispatcherBase
286 {
287 public:
288 typedef imod::CMultiModelDispatcherBase BaseClass;
289
290 explicit CommandsObserver(CThumbnailDecoratorGuiComp& parent);
291
292 // reimplemented (imod::CMultiModelDispatcherBase)
293 virtual void OnModelChanged(int modelId, const istd::IChangeable::ChangeSet& changeSet) override;
294
295 private:
296 CThumbnailDecoratorGuiComp& m_parent;
297 };
298
299 class AdditionalCommandsObserver: public imod::CMultiModelDispatcherBase
300 {
301 public:
302 typedef imod::CMultiModelDispatcherBase BaseClass;
303
304 explicit AdditionalCommandsObserver(CThumbnailDecoratorGuiComp& parent);
305
306 // reimplemented (imod::CMultiModelDispatcherBase)
307 virtual void OnModelChanged(int modelId, const istd::IChangeable::ChangeSet& changeSet) override;
308
309 private:
310 CThumbnailDecoratorGuiComp& m_parent;
311 };
312
313
314 class PageModelObserver: public imod::CMultiModelDispatcherBase
315 {
316 public:
317 explicit PageModelObserver(CThumbnailDecoratorGuiComp& parent);
318
319 // reimplemented (imod::CMultiModelDispatcherBase)
320 virtual void OnModelChanged(int modelId, const istd::IChangeable::ChangeSet& changeSet) override;
321
322 private:
323 CThumbnailDecoratorGuiComp& m_parent;
324 };
325
326
327 class LoginObserver: public imod::CMultiModelDispatcherBase
328 {
329 public:
330 explicit LoginObserver(CThumbnailDecoratorGuiComp& parent);
331
332 // reimplemented (imod::CMultiModelDispatcherBase)
333 virtual void OnModelChanged(int modelId, const istd::IChangeable::ChangeSet& changeSet) override;
334
335 private:
336 CThumbnailDecoratorGuiComp& m_parent;
337 };
338
339
340 class PageVisualStatusObserver: public imod::CMultiModelDispatcherBase
341 {
342 public:
343 explicit PageVisualStatusObserver(CThumbnailDecoratorGuiComp& parent);
344
345 // reimplemented (imod::CMultiModelDispatcherBase)
346 virtual void OnModelChanged(int modelId, const istd::IChangeable::ChangeSet& changeSet) override;
347
348 private:
349 CThumbnailDecoratorGuiComp& m_parent;
350 };
351
352
353 class AdditionalCommendActivatorsObserver: public imod::CMultiModelDispatcherBase
354 {
355 public:
356 explicit AdditionalCommendActivatorsObserver(CThumbnailDecoratorGuiComp& parent);
357
358 // reimplemented (imod::CMultiModelDispatcherBase)
359 virtual void OnModelChanged(int modelId, const istd::IChangeable::ChangeSet& changeSet) override;
360
361 private:
362 CThumbnailDecoratorGuiComp& m_parent;
363 };
364
365
366 CommandsObserver m_commandsObserver;
367 AdditionalCommandsObserver m_additionalCommandsObserver;
368 PageModelObserver m_pageModelObserver;
369 LoginObserver m_loginObserver;
370 PageVisualStatusObserver m_pageVisualStatusObserver;
371 AdditionalCommendActivatorsObserver m_additionalCommandActivatorsObserver;
372
373 QStandardItemModel m_menuItemModel;
374 imtbase::CCollectionInfo* m_widgetList;
375
376 // commands
377 iqtgui::CHierarchicalCommand m_rootCommands;
378 iqtgui::CHierarchicalCommand m_commands;
379 int m_columnsCount;
380 int m_rowsCount;
381 int m_horizontalSpacing;
382 int m_verticalSpacing;
383 int m_horizontalFrameMargin;
384 int m_verticalFrameMargin;
385 int m_maxWidth;
386 int m_maxHeight;
387 QSize m_minItemSize;
388 imtgui::CThumbPageItemGuiDelegate* m_itemDelegate;
389
390 I_REF(iprm::IEnableableParam, m_menuPanelVisibilityCompPtr);
391 I_REF(iqtgui::IGuiObject, m_pagesWidgetCompPtr);
392 I_REF(iprm::ISelectionParam, m_pagesCompPtr);
393 I_REF(imod::IModel, m_pagesModelCompPtr);
394 I_REF(ibase::ICommandsProvider, m_commandsProviderCompPtr);
395 I_REF(imod::IModel, m_commandsProviderModelCompPtr);
396 I_REF(iauth::ILogin, m_loginCompPtr);
397 I_REF(imod::IModel, m_loginModelCompPtr);
398 I_REF(iauth::IRightsProvider, m_rightsCompPtr);
399 I_REF(imod::IModel, m_rightsModelCompPtr);
400 I_REF(imeas::INumericValue, m_autoLogoutMinutesCompPtr);
401 I_REF(iqtgui::IGuiObject, m_leftMenuPanelGuiCompPtr);
402 I_REF(imtgui::IPageNavigationController, m_pageNavigationControllerCompPtr);
403 I_REF(iqtgui::IGuiObject, m_dashboardGuiCompPtr);
404 I_REF(iqtgui::IDialog, m_preferencesDialogCompPtr);
405
406 QToolBar* m_mainToolBar;
407 QToolBar* m_additionalCommandsToolBar;
408 QToolBar* m_rightsCommandsToolBar;
409 QToolBar* m_fullscreenCommandToolBar;
410 QTimer m_autoLogoutTimer;
411 QTimer m_checkIsFullScreenTimer;
412
413 QMenu m_commandsMenu;
414
415 istd::TDelPtr<QProcess> m_keyboardProcessPtr;
416 QString m_winKeyboardPath;
417
418 int m_lastPageIndexForLoggedUser;
419 bool m_isExitProcess;
420
421 QSet<int> m_supportedEvents;
422};
423
424
425} // namespace imtgui
426
427
428