Salome HOME
Update copyrights
[modules/jobmanager.git] / src / wrappers / BL_MainWindows_Qt.cxx
1 // Copyright (C) 2009-2019  CEA/DEN, EDF R&D
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 #include "BL_MainWindows_Qt.hxx"
21
22 #include <QAction>
23 #include <QMainWindow>
24 #include <QMenu>
25 #include <QMenuBar>
26
27 BL::MainWindows_Qt::MainWindows_Qt(QMainWindow * main_window)
28 {
29   DEBTRACE("Creating BL::MainWindows_Qt");
30   BL_ASSERT(main_window);
31   _main_window = main_window;
32   _menuId = 0;
33 }
34
35 BL::MainWindows_Qt::~MainWindows_Qt()
36 {
37   DEBTRACE("Destroying BL::MainWindows_Qt");
38 }
39
40 QMainWindow * 
41 BL::MainWindows_Qt::getDockParent()
42 {
43   return _main_window;
44 }
45
46 QMainWindow * 
47 BL::MainWindows_Qt::getTabParent()
48 {
49   return _main_window;
50 }
51
52 QAction* 
53 BL::MainWindows_Qt::createAction(const QString& toolTip,
54                                  const QIcon& icon,
55                                  const QString& menu,
56                                  const QString& status,
57                                  const int accel,
58                                  QObject* parent,
59                                  bool checkable,
60                                  QObject* receiver,
61                                  const char* member,
62                                  const QString& shortCut)
63 {
64   QAction * action = new QAction(icon, menu, parent);
65   action->setStatusTip(status);
66   action->setToolTip(toolTip);
67   if (receiver)
68     connect(action, SIGNAL(triggered()), receiver, member);
69   return action;
70 }
71
72 int
73 BL::MainWindows_Qt::createTopMenu(const QString & menu_name)
74 {
75   QMenu * new_menu = _main_window->menuBar()->addMenu(menu_name);
76   _menu_map[getMenuId()] = new_menu;
77   return 0;
78 }
79
80 void
81 BL::MainWindows_Qt::addActionToMenu(QAction * action, int menu_id)
82 {
83   _menu_map[menu_id]->addAction(action);
84 }