Advertisement
spvnst

Untitled

Oct 12th, 2021
1,487
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "contextmenu.h"
  2. #include "m_window1.h"
  3. #include "m_window2.h"
  4. #include <QMessageBox>
  5. #include "figure.h"
  6. #include "main.h"
  7. contextmenu::contextmenu(QMenu *parent, Figure *fig) : QMenu(parent)
  8. {
  9.     f = fig;
  10.  
  11.     menu = new QMenu(this);
  12.     edit = new QAction(tr("Edit"),this);
  13.     del = new QAction(tr("Delete"),this);
  14.  
  15.     connect(edit,SIGNAL(triggered()),this,SLOT(if_edit_ispressed()));
  16.     connect(del,SIGNAL(triggered()),this,SLOT(if_del_ispressed()));
  17.  
  18.  
  19.     menu->addAction(edit);
  20.     menu->addAction(del);
  21.  
  22.  
  23. }
  24. void contextmenu::if_edit_ispressed(){
  25.     M_Window1* w1 = new M_Window1(f);
  26.     if(w1->exec() == QDialog::Accepted)
  27.     {
  28.         if (w1->getW() == "0" || w1->getH() == "0" || w1->getA_X() == "0" ||
  29.             w1->getB_R() == "0" || w1->getC_R() == "0" || w1->getD_R() == "0" ||
  30.                 w1->getE_Q() == "0"){
  31.             QMessageBox::information(0 ,"Information", "Some data is zero");
  32.         }
  33.  
  34.          else{
  35.                f->set_data_from_dw((w1->getW()).toInt(),
  36.                         (w1->getH()).toInt(),
  37.                         (w1->getA_X()).toInt(),
  38.                         (w1->getB_R()).toInt(),
  39.                         (w1->getC_R()).toInt(),
  40.                         (w1->getD_R()).toInt(),
  41.                         (w1->getE_Q()).toInt(),
  42.                         (w1->getF_Q()).toInt(),
  43.                         (w1->getAngle()).toInt());
  44.  
  45.     delete w1;
  46.             }
  47.    }
  48. }
  49.  
  50.  
  51. void contextmenu::if_del_ispressed(){
  52.  mainwindow->delete_figure1();
  53.  
  54. }
  55.  
  56.  
  57. contextmenu2::contextmenu2(QMenu *parent, Figure2 *fig) : QMenu(parent)
  58. {
  59.     f1 = fig;
  60.  
  61.     menu = new QMenu(this);
  62.     edit = new QAction(tr("Edit"),this);
  63.     del = new QAction(tr("Delete"),this);
  64.  
  65.     connect(edit,SIGNAL(triggered()),this,SLOT(if_edit_ispressed2()));
  66.     connect(del,SIGNAL(triggered()),this,SLOT(if_del_ispressed2()));
  67.  
  68.  
  69.     menu->addAction(edit);
  70.     menu->addAction(del);
  71.  
  72.  
  73.  
  74. }
  75. void contextmenu2::if_edit_ispressed2(){
  76.     M_Window2* w2 = new M_Window2(f1);
  77.     if(w2->exec() == QDialog::Accepted){
  78.         if (w2->getW() == "0" || w2->getH() == "0" ||
  79.             w2->getB_X() == "0" ||
  80.                 w2->getF_Q() == "0"){
  81.             QMessageBox::information(0 ,"Information", "Some data is zero");
  82.         }
  83.          else{
  84.                f1->set_data_from_dw((w2->getW()).toInt(),
  85.                                    (w2->getH()).toInt(),
  86.                                    (w2->getB_X()).toInt(),
  87.                                    (w2->getF_Q()).toInt(),
  88.                                    (w2->getAngle()).toInt());
  89.     delete w2;
  90.             }
  91.    }
  92. }
  93.  
  94.  
  95. void contextmenu2::if_del_ispressed2(){
  96.    mainwindow->delete_figure2();
  97. }
  98.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement