-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrundialog.cpp
More file actions
134 lines (126 loc) · 4.19 KB
/
rundialog.cpp
File metadata and controls
134 lines (126 loc) · 4.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#include "rundialog.h"
#include "ui_rundialog.h"
runDialog::runDialog(QWidget *parent) :
QDialog(parent),labelPos(2),
ui(new Ui::runDialog)
{
ui->setupUi(this);
buildUi();
}
runDialog::~runDialog()
{
delete ui;
}
void runDialog::runClicked()
{
runDialogStorage runParameters;
runParameters.setPlayerPort(playerPortLineEdit->text().toUInt());
//cout<<"runDialog Player Port"<<runParameters.getPlayerPort();
//cout<<"runDialog Player Port"<<runParameters.getPlayerPort();
if(channelsComboBox->currentText()!="--Select Channel--")
{
unsigned int channelSplitterPort=runDialogChannels[channelsComboBox->currentIndex()-1].getSplitterPort();
runParameters.setSplitterPort(channelSplitterPort);
string channelSplitterAddress=runDialogChannels[channelsComboBox->currentIndex()-1].getSplitterAddress();
runParameters.setSplitterAddress(channelSplitterAddress);
}
#ifndef __IMS__
runParameters.setMaxChunk(maxChunkLineEdit->text().toInt());
runParameters.setTeamPort(teamPortSpinBox->text().toUInt());
runParameters.setLocalHost(localHostCheckBox->isChecked());
#endif
#ifdef __NTS__
#ifndef __monitor__
runParameters.setSourcePortStep(sourcePortLineEdit->text().toInt());
#endif
#endif
this->hide();
clearUiElements();
emit runPeer(runParameters);
}
void runDialog::clearUiElements()
{
playerPortLineEdit->clear();
channelsComboBox->clear();
#ifndef __IMS__
maxChunkLineEdit->clear();
teamPortSpinBox->clear();
localHostCheckBox->setChecked(false);
#endif
#ifdef __NTS__
#ifndef __monitor__
sourcePortLineEdit->clear();
#endif
#endif
}
void runDialog::receiveChannels(vector<addChannels> channels)
{
for(auto chnnl:channels)
{
QIcon icon;
if(chnnl.getThumbnail().isNull())
{
icon.addPixmap(QPixmap("://icons/p2psp.png"));
}
else
{
icon.addPixmap(chnnl.getThumbnail());
}
channelsComboBox->addItem(icon,QString::fromStdString(chnnl.getName()));
runDialogChannels.push_back(chnnl); //used in runClicked Method for retrieving splitter port and address
}
}
void runDialog::buildUi()
{
glayout = new QGridLayout(this);
playerPortLabel = new QLabel();
playerPortLabel->setText("Player Port");
glayout->addWidget(playerPortLabel,0,0);
playerPortLineEdit = new QLineEdit();
glayout->addWidget(playerPortLineEdit,0,1,1,3);
channelsLabel = new QLabel();
channelsLabel->setText("Channels");
glayout->addWidget(channelsLabel,1,0);
channelsComboBox=new QComboBox();
glayout->addWidget(channelsComboBox,1,1,1,3);
channelsComboBox->addItem("--Select Channel--");
#ifndef __IMS__
maxChunkLabel=new QLabel();
maxChunkLabel->setText("Max Chunk Debt");
glayout->addWidget(maxChunkLabel,labelPos,0);
maxChunkLineEdit = new QLineEdit();
glayout->addWidget(maxChunkLineEdit,labelPos,1,1,3);
labelPos++;
teamPortLabel=new QLabel();
teamPortLabel->setText("Team Port");
glayout->addWidget(teamPortLabel,labelPos,0);
teamPortSpinBox = new QSpinBox();
teamPortSpinBox->setMaximum(65536);
glayout->addWidget(teamPortSpinBox,labelPos,1,1,3);
labelPos++;
localHostLabel=new QLabel();
localHostLabel->setText("Local Host");
glayout->addWidget(localHostLabel,labelPos,0);
localHostCheckBox = new QCheckBox();
glayout->addWidget(localHostCheckBox,labelPos,1,1,3);
labelPos++;
#endif
#ifdef __NTS__
#ifndef __monitor__
sourcePortStepLabel=new QLabel();
sourcePortStepLabel->setText("Source Port Step");
glayout->addWidget(sourcePortStepLabel,labelPos,0);
sourcePortLineEdit = new QLineEdit();
glayout->addWidget(sourcePortLineEdit,labelPos,1,1,3);
labelPos++;
#endif
#endif
runPushButton = new QPushButton();
runPushButton->setText("Run");
glayout->addWidget(runPushButton,labelPos,2);
cancelPushButton = new QPushButton();
cancelPushButton->setText("Cancel");
glayout->addWidget(cancelPushButton,labelPos,3);
QObject::connect(cancelPushButton,SIGNAL(pressed()),this,SLOT(hide()));
QObject::connect(runPushButton,SIGNAL(pressed()),this,SLOT(runClicked()));
}