Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "contextmenu.h"
- #include "m_window1.h"
- #include "m_window2.h"
- #include <QMessageBox>
- #include "figure.h"
- #include "main.h"
- contextmenu::contextmenu(QMenu *parent, Figure *fig) : QMenu(parent)
- {
- f = fig;
- menu = new QMenu(this);
- edit = new QAction(tr("Edit"),this);
- del = new QAction(tr("Delete"),this);
- connect(edit,SIGNAL(triggered()),this,SLOT(if_edit_ispressed()));
- connect(del,SIGNAL(triggered()),this,SLOT(if_del_ispressed()));
- menu->addAction(edit);
- menu->addAction(del);
- }
- void contextmenu::if_edit_ispressed(){
- M_Window1* w1 = new M_Window1(f);
- if(w1->exec() == QDialog::Accepted)
- {
- if (w1->getW() == "0" || w1->getH() == "0" || w1->getA_X() == "0" ||
- w1->getB_R() == "0" || w1->getC_R() == "0" || w1->getD_R() == "0" ||
- w1->getE_Q() == "0"){
- QMessageBox::information(0 ,"Information", "Some data is zero");
- }
- else{
- f->set_data_from_dw((w1->getW()).toInt(),
- (w1->getH()).toInt(),
- (w1->getA_X()).toInt(),
- (w1->getB_R()).toInt(),
- (w1->getC_R()).toInt(),
- (w1->getD_R()).toInt(),
- (w1->getE_Q()).toInt(),
- (w1->getF_Q()).toInt(),
- (w1->getAngle()).toInt());
- delete w1;
- }
- }
- }
- void contextmenu::if_del_ispressed(){
- mainwindow->delete_figure1();
- }
- contextmenu2::contextmenu2(QMenu *parent, Figure2 *fig) : QMenu(parent)
- {
- f1 = fig;
- menu = new QMenu(this);
- edit = new QAction(tr("Edit"),this);
- del = new QAction(tr("Delete"),this);
- connect(edit,SIGNAL(triggered()),this,SLOT(if_edit_ispressed2()));
- connect(del,SIGNAL(triggered()),this,SLOT(if_del_ispressed2()));
- menu->addAction(edit);
- menu->addAction(del);
- }
- void contextmenu2::if_edit_ispressed2(){
- M_Window2* w2 = new M_Window2(f1);
- if(w2->exec() == QDialog::Accepted){
- if (w2->getW() == "0" || w2->getH() == "0" ||
- w2->getB_X() == "0" ||
- w2->getF_Q() == "0"){
- QMessageBox::information(0 ,"Information", "Some data is zero");
- }
- else{
- f1->set_data_from_dw((w2->getW()).toInt(),
- (w2->getH()).toInt(),
- (w2->getB_X()).toInt(),
- (w2->getF_Q()).toInt(),
- (w2->getAngle()).toInt());
- delete w2;
- }
- }
- }
- void contextmenu2::if_del_ispressed2(){
- mainwindow->delete_figure2();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement