Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYCustomPopupMenu.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012-2024> <EDF-DTG> <FRANCE>
3  * This file is part of Code_TYMPAN (R).
4  * Code_TYMPAN (R) is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * Code_TYMPAN (R) 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.
11  * See the GNU General Public License for more details.
12  * You should have received a copy of the GNU General Public License along
13  * with Code_TYMPAN (R). If not, see <https://www.gnu.org/licenses/>.
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:63