Version: 9.15.0
LightApp_ModuleAction.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2025 CEA, EDF, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 // File : LightApp_ModuleAction.h
21 // Author : Sergey TELKOV, Vadim SANDLER
22 //
23 #ifndef LIGHTAPP_MODULEACTION_H
24 #define LIGHTAPP_MODULEACTION_H
25 
26 #include "LightApp.h"
27 
28 #include <QtxAction.h>
29 
30 #ifdef WIN32
31 #pragma warning ( disable:4251 )
32 #endif
33 
34 class QtxComboBox;
35 class QtxResourceMgr;
36 class QSignalMapper;
37 
39 {
40  Q_OBJECT
41 
42 private:
43  class ActionSet;
44  class ComboAction;
45  class ActivateEvent;
46 
47 public:
48  typedef enum { Buttons = 0x01,
49  List = 0x02,
50  AddRemove = 0x04,
51  All = Buttons | List | AddRemove
52  } Mode;
53 
54 public:
56  virtual ~LightApp_ModuleAction();
57 
58  int count() const;
59  QStringList modules() const;
60 
61  QIcon moduleIcon( const QString& ) const;
62  void setModuleIcon( const QString&, const QIcon& );
63 
64  QAction* moduleAction( const QString& ) const;
65 
66  void insertModule( const QString&, const QIcon&, const int = -1 );
67  void insertModule( const QString&, const QIcon&, bool, const int = -1 );
68  void removeModule( const QString& );
69  void insertExtension(const QString&);
70  void removeExtension(const QString&);
71  void updateExtActions();
72 
73  QString activeModule() const;
74 
75  void setMode( const Mode& );
76  void setModeEnabled( const Mode&, bool );
77  bool isModeEnabled( const Mode& ) const;
78 
79 public slots:
80  void setActiveModule( const QString& );
81 
82 
83 protected:
84  virtual void addedTo( QWidget* );
85  virtual void removedFrom( QWidget* );
86 
87  virtual bool event( QEvent* );
88 
89 signals:
90  void moduleActivated( const QString& );
91  void adding();
92  void removing( const QString& );
93  void showExtInfo();
94 
95 private:
96  void update();
97  void update( QtxComboBox* );
98 
99  QAction* active() const;
100  void activate( int, bool = true );
101 
102 private slots:
103  void onChanged();
104  void onTriggered( int );
105  void onComboActivated( int );
106 
107 private:
114  int myMode;
115  QSignalMapper* myMapper;
116 };
117 
119 {
120  Q_OBJECT
121 
122 public:
123  ComboAction( QObject* parent );
124 
126 
127 signals:
128  void activatedId( int );
129 
130 protected:
131  virtual QWidget* createWidget( QWidget* );
132 };
133 
134 #endif // LIGHTAPP_MODULEACTION_H
#define LIGHTAPP_EXPORT
Definition: LightApp.h:36
Internal class to represent list of modules buttons.
Definition: LightApp_ModuleAction.cxx:49
Internal class to represent custom event for transfer the activation item id.
Definition: LightApp_ModuleAction.cxx:196
Internal class to represent combo box with the list of modules in the toolbar.
Definition: LightApp_ModuleAction.h:119
virtual QWidget * createWidget(QWidget *)
Create combo box widget by request from the toolbar.
Definition: LightApp_ModuleAction.cxx:171
QList< QtxComboBox * > widgets() const
Get list of associated widgets.
Definition: LightApp_ModuleAction.cxx:154
ComboAction(QObject *parent)
Constructor.
Definition: LightApp_ModuleAction.cxx:144
void activatedId(int)
Emitted when the combo box item is activated.
An action, representing the list of modules to be inserted to the toolbar.
Definition: LightApp_ModuleAction.h:39
QSignalMapper * myMapper
Definition: LightApp_ModuleAction.h:115
int myMode
Definition: LightApp_ModuleAction.h:114
QtxAction * myInfo
Definition: LightApp_ModuleAction.h:111
QtxAction * myAdd
Definition: LightApp_ModuleAction.h:109
ComboAction * myCombo
Definition: LightApp_ModuleAction.h:108
QtxAction * myRemove
Definition: LightApp_ModuleAction.h:110
QAction * mySeparator
Definition: LightApp_ModuleAction.h:113
ActionSet * mySet
Definition: LightApp_ModuleAction.h:112
void removing(const QString &)
void moduleActivated(const QString &)
Emitted when the module is activated.
For more information see QT documentation.
Definition: SUIT_Application.h:42
Generic action class.
Definition: QtxAction.h:39
virtual void addedTo(QWidget *)
Called when the action is added to the widget.
Definition: QtxAction.cxx:286
virtual void removedFrom(QWidget *)
Called when the action is removed from the widget.
Definition: QtxAction.cxx:299
Enhanced version of Qt combo box class.
Definition: QtxComboBox.h:39
Application resources manager.
Definition: QtxResourceMgr.h:53