00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <mxcpcCameraSelector.h>
00021 #include <mxcpcIPEdit.h>
00022
00023 #include <QVBoxLayout>
00024 #include <QHBoxLayout>
00025 #include <QLabel>
00026 #include <QSpinBox>
00027 #include <QComboBox>
00028 #include <QCheckBox>
00029 #include <QFrame>
00030
00031
00032
00033 mxcpcCameraSelector::mxcpcCameraSelector(QWidget *parent)
00034 : QWidget(parent) {
00035
00036 mxcpcIPEdit *ip_edit;
00037 QVBoxLayout *layout;
00038 QHBoxLayout *layout2;
00039 QLabel *label;
00040 QSpinBox *spin_box;
00041 QComboBox *combo_box;
00042 QCheckBox *checkbox;
00043 QFrame *frame;
00044
00045 layout = new QVBoxLayout(this);
00046 layout->setMargin(0);
00047
00048
00049 combo_box = new QComboBox(this);
00050 layout->addWidget(combo_box, 0, Qt::AlignHCenter);
00051 combo_box->setSizePolicy(QSizePolicy(QSizePolicy::Fixed,
00052 QSizePolicy::Fixed));
00053
00054
00055 combo_box->addItem(QString("Specify Manually"));
00056
00057 frame = new QFrame(this);
00058 layout->addWidget(frame);
00059 frame->setFrameStyle(QFrame::HLine | QFrame::Sunken);
00060
00061 CameraIPEdit = ip_edit = new mxcpcIPEdit(this);
00062 layout->addWidget(ip_edit);
00063
00064 layout2 = new QHBoxLayout();
00065 layout->addLayout(layout2);
00066
00067 label = new QLabel(QString("Camera Port:"), this);
00068 layout2->addWidget(label);
00069 CameraPortSpinBox = spin_box = new QSpinBox(this);
00070 layout2->addWidget(spin_box);
00071 spin_box->setMinimum(0);
00072 spin_box->setMaximum(65536);
00073 spin_box->setValue(80);
00074 spin_box->setSizePolicy(QSizePolicy(QSizePolicy::Fixed,
00075 QSizePolicy::Fixed));
00076
00077 frame = new QFrame(this);
00078 layout->addWidget(frame);
00079 frame->setFrameStyle(QFrame::HLine | QFrame::Sunken);
00080
00081 ProxyCheckBox
00082 = checkbox
00083 = new QCheckBox(QString("Access this Camera through Proxy Server"),
00084 this);
00085 layout->addWidget(checkbox);
00086 checkbox->setChecked(false);
00087 QObject::connect(checkbox, SIGNAL(stateChanged(int)),
00088 this, SLOT(processProxyCheckBoxStateChanged(int)));
00089
00090 ProxyIPEdit = ip_edit = new mxcpcIPEdit(this);
00091 layout->addWidget(ip_edit);
00092 ip_edit->setIPAddress(mxcpcIPAddress(192, 168, 1, 254));
00093 ip_edit->setEnabled(false);
00094
00095 layout2 = new QHBoxLayout();
00096 layout->addLayout(layout2);
00097
00098 label = new QLabel(QString("Proxy Port:"), this);
00099 layout2->addWidget(label);
00100 ProxyPortSpinBox = spin_box = new QSpinBox(this);
00101 layout2->addWidget(spin_box);
00102 spin_box->setMinimum(0);
00103 spin_box->setMaximum(65536);
00104 spin_box->setValue(8080);
00105 spin_box->setSizePolicy(QSizePolicy(QSizePolicy::Fixed,
00106 QSizePolicy::Fixed));
00107 spin_box->setEnabled(false);
00108 }
00109
00110
00111
00112 mxcpcIPAddress mxcpcCameraSelector::cameraIP(void) {
00113
00114 return(CameraIPEdit->getIPAddress());
00115 }
00116
00117
00118 int mxcpcCameraSelector::cameraPort(void) {
00119
00120 return(CameraPortSpinBox->value());
00121 }
00122
00123
00124 mxcpcProxyConfiguration mxcpcCameraSelector::cameraProxyConfiguration(void) {
00125
00126 if(ProxyCheckBox->checkState() == Qt::Checked) {
00127 return(mxcpcProxyConfiguration(ProxyIPEdit->getIPAddress(),
00128 ProxyPortSpinBox->value()));
00129 }
00130 else {
00131 return(mxcpcProxyConfiguration());
00132 }
00133 }
00134
00135
00136 void mxcpcCameraSelector::processProxyCheckBoxStateChanged(int state) {
00137
00138 ProxyIPEdit->blockSignals(true);
00139 ProxyPortSpinBox->blockSignals(true);
00140
00141 if(state == Qt::Checked) {
00142 ProxyIPEdit->setEnabled(true);
00143 ProxyPortSpinBox->setEnabled(true);
00144 }
00145 else {
00146 ProxyIPEdit->setEnabled(false);
00147 ProxyPortSpinBox->setEnabled(false);
00148 }
00149
00150 ProxyIPEdit->blockSignals(false);
00151 ProxyPortSpinBox->blockSignals(false);
00152 }
00153