pqProxyGroupMenuManager.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
3 // SPDX-License-Identifier: BSD-3-Clause
4 #ifndef pqProxyGroupMenuManager_h
5 #define pqProxyGroupMenuManager_h
6 
7 #include "pqApplicationComponentsModule.h"
8 
9 #include <QMenu>
10 
11 #include "vtkParaViewDeprecation.h" // for deprecation macro
12 
13 #include <memory> // for unique_ptr
14 
15 class pqProxyCategory;
16 class pqProxyInfo;
17 class vtkPVXMLElement;
18 class vtkSMProxy;
19 
25 class PQAPPLICATIONCOMPONENTS_EXPORT pqProxyGroupMenuManager : public QObject
26 {
27  Q_OBJECT
28  typedef QObject Superclass;
29 
30 public:
39  pqProxyGroupMenuManager(QMenu* menu, const QString& resourceTagName,
40  bool supportsQuickLaunch = true, bool enableFavorites = false);
41  ~pqProxyGroupMenuManager() override;
42 
46  QMenu* menu() const { return static_cast<QMenu*>(this->parent()); }
47 
51  QWidget* widgetActionsHolder() const;
52  QMenu* getFavoritesMenu();
53 
58  void setRecentlyUsedMenuSize(unsigned int val) { this->RecentlyUsedMenuSize = val; }
59  unsigned int recentlyUsedMenuSize() const { return this->RecentlyUsedMenuSize; }
64  bool supportsQuickLaunch() const { return this->SupportsQuickLaunch; }
65  void setEnableFavorites(bool enable) { this->EnableFavorites = enable; }
66 
70  void addProxy(const QString& xmlgroup, const QString& xmlname);
71 
75  void removeProxy(const QString& xmlgroup, const QString& xmlname);
76 
80 
85  QStringList getToolbarCategories() const;
91  QString getToolbarName(pqProxyCategory* category);
95  QString categoryLabel(const QString& category);
96 
100 
104  QList<QAction*> actions() const;
109  QList<QAction*> categoryActions(const QString& category);
113  QList<QAction*> categoryActions(pqProxyCategory* category);
117  QList<QAction*> actionsInToolbars();
118 
124  void populateMenuFromCategory(QMenu* menu, pqProxyCategory* category);
125 
133  void setShowCategoriesInMenuBar(bool show);
134  bool showCategoriesInMenuBar() const;
138  QAction* getAction(pqProxyInfo* proxy);
142  void updateActionIcon(pqProxyInfo* proxy);
144 
153  void addProxyDefinitionUpdateListener(const QString& proxyGroupName);
154  void removeProxyDefinitionUpdateListener(const QString& proxyGroupName);
155 
159 
164  pqProxyCategory* getApplicationCategory();
169  pqProxyCategory* getMenuCategory();
173  pqProxyCategory* getFavoritesCategory();
178  bool isFavorites(pqProxyCategory* category);
180 
181 public Q_SLOTS: // NOLINT(readability-redundant-access-specifiers)
185 
192  void loadConfiguration(vtkPVXMLElement*);
197  void lookForNewDefinitions();
201  void removeProxyDefinitionUpdateObservers();
205  void addProxyDefinitionUpdateObservers();
207 
215  virtual void populateMenu();
216 
220  void writeCategoryToSettings();
221 
222 Q_SIGNALS:
223  void triggered(const QString& group, const QString& name);
224 
229  void menuPopulated();
230 
234  void categoriesUpdated();
235 
236 protected Q_SLOTS:
237  void triggered();
238  void quickLaunch();
239  void switchActiveServer();
240  void updateMenuStyle();
241  void updateActionsStyle();
242 
244  void populateRecentlyUsedMenu();
245 
246 protected: // NOLINT(readability-redundant-access-specifiers)
248  vtkPVXMLElement* MenuRoot = nullptr;
249  int RecentlyUsedMenuSize = 0;
250  bool EnableFavorites = false;
251 
252  void loadRecentlyUsedItems();
253  void saveRecentlyUsedItems();
254 
258  QAction* getAction(const QString& pgroup, const QString& proxyname);
259 
260 private Q_SLOTS:
265  void populateAlphabeticalMenu();
269  void populateMiscMenu();
271  void populateCategoriesMenus();
273 
274 private: // NOLINT(readability-redundant-access-specifiers)
275  Q_DISABLE_COPY(pqProxyGroupMenuManager)
276 
277 
281  QAction* createAction(pqProxyInfo* proxy);
282 
286  void runScript(const QString& code, const QString& fileName);
287 
291  QAction* createAddToFavoritesAction();
292 
296  void clearMenu();
300  void clearCategoriesMenus();
302  void populateSubCategoriesMenus(QMenu* parent, pqProxyCategory* category);
304  void populateCategoryMenu(QMenu* parent, pqProxyCategory* category);
306 
310  void loadCategorySettings();
311 
312  struct pqInternal;
313  std::unique_ptr<pqInternal> Internal;
314  bool SupportsQuickLaunch = true;
315 };
316 
317 #endif
unsigned int recentlyUsedMenuSize() const
void setRecentlyUsedMenuSize(unsigned int val)
When size>0 a recently used category will be added to the menu.
pqProxyGroupMenuManager is a menu-populator that fills up a menu with proxies defined in an XML confi...
void setEnableFavorites(bool enable)
bool supportsQuickLaunch() const
Returns true if the pqProxyGroupMenuManager has been registered with quick-launch mechanism maintaine...
Meta data structure for the User Interface, describing an item of a pqProxyCategory.
Definition: pqProxyInfo.h:33
name
proxy for a VTK object(s) on a server
Definition: vtkSMProxy.h:140
The pqProxyCategory class reads and writes XML that describes the proxies organisation into categorie...
This is used by vtkPVXMLParser to represent an XML document starting at the root element.
QMenu * menu() const
Access the menu.