! ConnectionDialog Constructor: If command is cmdMenu the button is supposed to have sub menu buttons. If isCheckable is true the button gets a checkbox If isChecked is true the checkbox gets a little cross If radioParent is a parent button all of it checkable children act as radio buttons. If closeOnClick is true the entire menu gets closed after command execution. */
| 27 | If closeOnClick is true the entire menu gets closed after command execution. |
| 28 | */ |
| 29 | ConnectionDialog::ConnectionDialog(IPProcessStep *from, IPProcessStep *to, IPProcessGridScene* scene, QWidget *parent) : QDialog(parent) |
| 30 | { |
| 31 | setModal(true); |
| 32 | setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint); |
| 33 | |
| 34 | setMinimumWidth(350); |
| 35 | setMaximumWidth(350); |
| 36 | |
| 37 | _mainWindow = (MainWindow*) parent; |
| 38 | |
| 39 | _layout = new QGridLayout; |
| 40 | setLayout(_layout); |
| 41 | |
| 42 | _from = from; |
| 43 | _to = to; |
| 44 | |
| 45 | _scene = scene; |
| 46 | |
| 47 | // set up GUI |
| 48 | _layout->addWidget(new QLabel("<b>Source Process</b>", this), 0, 0); |
| 49 | _layout->addWidget(new QLabel("<b>Destination Process</b>", this), 0, 2); |
| 50 | |
| 51 | setStyleSheet("QDialog {border: 1px solid rgb(53,53,53);}"); |
| 52 | |
| 53 | _groupFrom = new QButtonGroup; |
| 54 | _groupTo = new QButtonGroup; |
| 55 | |
| 56 | int rowL = 1; |
| 57 | bool isDefaultSet = false; |
| 58 | for(int i=0; i < (int)_from->process()->outputs()->size(); i++) |
| 59 | { |
| 60 | QRadioButton* btn = new QRadioButton(QString::fromStdString(_from->process()->outputs()->at(i).name), this); |
| 61 | |
| 62 | // check if output is free |
| 63 | if(_from->process()->outputs()->at(i).occupied) |
| 64 | { |
| 65 | btn->setEnabled(false); |
| 66 | } |
| 67 | else |
| 68 | { |
| 69 | // make sure one option is set as default |
| 70 | if(!isDefaultSet) |
| 71 | { |
| 72 | btn->setChecked(true); |
| 73 | isDefaultSet = true; |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | _layout->addWidget(btn, rowL++, 0); |
| 78 | _groupFrom->addButton(btn, i); |
| 79 | |
| 80 | // click event |
| 81 | connect(btn, &QPushButton::clicked, this, &ConnectionDialog::redrawConnection); |
| 82 | |
| 83 | // special styling |
| 84 | btn->setStyleSheet(QString("QRadioButton {width: 10px; spacing: -130px; text-align:right;} QRadioButton::indicator { subcontrol-origin: content; subcontrol-position: right top; }")); |
| 85 | } |
| 86 |