Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYCustomPopupMenu.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012> <EDF-R&D> <FRANCE>
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  * See the GNU General Public License for more details.
11  * You should have received a copy of the GNU General Public License along
12  * with this program; if not, write to the Free Software Foundation, Inc.,
13  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
14  */
15 
23 #include "TYCustomPopupMenu.h"
24 
25 #include <QMdiArea>
26 
27 TYCustomPopupMenu::TYCustomPopupMenu(QWidget* parent) : QMenu(parent)
28 {
29  QObject::connect(this, &QMenu::aboutToShow, this, &TYCustomPopupMenu::onAboutToShow);
30 }
31 
32 TYCustomPopupMenu::TYCustomPopupMenu(const QString& title, QWidget* parent) : QMenu(title, parent)
33 {
34  QObject::connect(this, &QMenu::aboutToShow, this, &TYCustomPopupMenu::onAboutToShow);
35 }
36 
38 {
39  setVisible(true);
40 }
41 
43 {
44  QPoint point = pos();
45  QPoint point2;
46 
47  if (visible)
48  {
49  int w = getTYMainWnd()->getWorkspace()->width();
50  int h = getTYMainWnd()->getWorkspace()->height();
51  point2 = getTYMainWnd()->getWorkspace()->mapFromGlobal(point);
52  if ((point2.x() >= 0) && (point2.y() >= 0) && (point2.x() <= w) && (point2.y() <= h))
53  {
54  return;
55  }
56  QMenu::setVisible(visible);
57  }
58  else
59  {
60  QMenu::setVisible(visible);
61  }
62 }
TYMainWindow * getTYMainWnd()
Retourne le pointeur sur la fenetre principale.
pour l'application Tympan (fichier header)
Definit un popup menu, necessaire pour maitriser l'ouverture automtique apres un createPopupMenu (fic...
Fenetre principale de l'application Tympan (fichier header)
TYCustomPopupMenu(QWidget *parent=0)
Constructeur.
virtual void setVisible(bool visible)
QMdiArea * getWorkspace()
Definition: TYMainWindow.h:66