MainAndSecondaryCamerasWnd.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. #include "MainAndSecondaryCamerasWnd.h"
  2. #include "ui_MainAndSecondaryCamerasWnd.h"
  3. #include <QSettings>
  4. #include <QCloseEvent>
  5. #include <QVBoxLayout>
  6. #include <QTimer>
  7. #include "CameraMaterialGroupWnd/CameraImage/CameraImageHandler.h"
  8. #include <qDebug.h>
  9. #include <QScrollBar>
  10. MainAndSecondaryCamerasWnd::MainAndSecondaryCamerasWnd(QWidget *parent)
  11. : QMainWindow(parent)
  12. , ui(new Ui::MainAndSecondaryCamerasWnd)
  13. {
  14. ui->setupUi(this);
  15. QSettings settings("YourOrganization", "YourApplication");
  16. settings.beginGroup("LastSettings");
  17. lastRightPixmap = settings.value("LastRightPixmap").value<QPixmap>();
  18. lasttextList = settings.value("LasttextList").toStringList();
  19. lastLastRightPixmap = settings.value("LastLastRightPixmap").value<QPixmap>();
  20. lastLasttextList = settings.value("LastLasttextList").toStringList();
  21. settings.endGroup();
  22. initFrom();
  23. isShow = true;
  24. }
  25. MainAndSecondaryCamerasWnd::~MainAndSecondaryCamerasWnd()
  26. {
  27. delete ui;
  28. }
  29. void MainAndSecondaryCamerasWnd::initFrom()
  30. {
  31. QTimer *timer = new QTimer(this);
  32. connect(timer, &QTimer::timeout, this, &MainAndSecondaryCamerasWnd::checkSettings);
  33. timer->start(100);
  34. ui->Leftlabel_Percentage->setAlignment(Qt::AlignCenter);
  35. ui->Rightlabel_Percentage->setAlignment(Qt::AlignCenter);
  36. initSliders();
  37. initLineEdits();
  38. initProgressBar();
  39. // 连接 QSlider 的 valueChanged 信号到 QProgressBar 的 setValue 槽
  40. connect(ui->RedLightverticalSlider_2, &QSlider::valueChanged, ui->RedLightprogressBar_2, &QProgressBar::setValue);
  41. connect(ui->BlueLightverticalSlider, &QSlider::valueChanged, ui->BlueLightprogressBar_2, &QProgressBar::setValue);
  42. connect(ui->GreenLightverticalSlider_5, &QSlider::valueChanged, ui->GreenLightprogressBar_5, &QProgressBar::setValue);
  43. connect(ui->DotLightverticalSlider_2, &QSlider::valueChanged, ui->DotLightprogressBar_2, &QProgressBar::setValue);
  44. connectSliderAndLineEdit(ui->RedLightverticalSlider_2, ui->RedLightlineEdit_2);
  45. connectSliderAndLineEdit(ui->GreenLightverticalSlider_5, ui->GreenLightlineEdit_5);
  46. connectSliderAndLineEdit(ui->BlueLightverticalSlider, ui->BlueLightlineEdit_2);
  47. connectSliderAndLineEdit(ui->DotLightverticalSlider_2, ui->DotLightlineEdit_2);
  48. connect(ui->LeftOperatewidget,&ImageWidget::sendDoubleClicksignal,this,&MainAndSecondaryCamerasWnd::handleDoubleClick);
  49. connect(ui->RightOperatewidget,&ImageWidget::sendDoubleClicksignal,this,&MainAndSecondaryCamerasWnd::handleDoubleClick);
  50. QWidget *viewport = ui->scrollArea->viewport();
  51. QWidget *container = new QWidget(viewport);
  52. QHBoxLayout *mainLayout = new QHBoxLayout(container);
  53. mainLayout->setSpacing(28);
  54. mainLayout->setMargin(0);
  55. QList<int> numbers = {1, 2, 3, 4, 5, 6, 7, 8};
  56. QList<Group*> widgets;
  57. for (int i = 0; i < numbers.size(); ++i) {
  58. int num = numbers[i];
  59. CameraImageHandler* manager = new CameraImageHandler(num);
  60. Group* widget = manager->getGroup();
  61. connect(widget,&Group::send_button_Signal,this,&MainAndSecondaryCamerasWnd::showAndHide);
  62. if (widget != nullptr) {
  63. mainLayout->addWidget(widget);
  64. widgets.append(widget);
  65. }
  66. delete manager;
  67. }
  68. // 设置控件的最小高度和最大宽度
  69. int minHeight = 162;
  70. int maxWidth = 244;
  71. int num = -28;
  72. for (Group* w : widgets) {
  73. w->setMinimumHeight(minHeight);
  74. w->setMaximumWidth(maxWidth);
  75. num = num + 272;
  76. }
  77. container->setMinimumSize(num, 162);
  78. container->setLayout(mainLayout);
  79. ui->scrollArea->setWidget(container);
  80. ui->scrollArea->resize(1062, 177);
  81. ui->LeftOperatewidget->setMouseTracking(true);
  82. ui->RightOperatewidget->setMouseTracking(true);
  83. QSettings settings2("YourOrganization", "YourApplication_lastWndType");
  84. int lastWndType = settings2.value("LastWndType").toInt();
  85. int LastGroup = settings2.value("LastGroup").toInt();
  86. lastIndex = lastWndType;
  87. lastGroupId = LastGroup;
  88. }
  89. void MainAndSecondaryCamerasWnd::initSliders() {
  90. QList<QSlider*> sliders = {
  91. ui->RedLightverticalSlider_2, ui->GreenLightverticalSlider_5,
  92. ui->BlueLightverticalSlider, ui->DotLightverticalSlider_2
  93. };
  94. QList<int> initialValues = { 22, 11, 0, 0};
  95. for (int i = 0; i < sliders.size(); ++i) {
  96. sliders[i]->setMinimum(0);
  97. sliders[i]->setMaximum(100);
  98. sliders[i]->setValue(initialValues[i]);
  99. }
  100. }
  101. void MainAndSecondaryCamerasWnd::initProgressBar(){
  102. QList<int> initialValues = {22, 11, 1, 1};
  103. QList<QProgressBar*> progressBar = {
  104. ui->RedLightprogressBar_2,ui->GreenLightprogressBar_5,
  105. ui->BlueLightprogressBar_2,ui->DotLightprogressBar_2
  106. };
  107. for (int i = 0; i < progressBar.size(); ++i) {
  108. progressBar[i]->setMinimum(0);
  109. progressBar[i]->setMaximum(100);
  110. progressBar[i]->setValue(initialValues[i]);
  111. }
  112. }
  113. void MainAndSecondaryCamerasWnd::handleDoubleClick(){
  114. QPoint globalMousePos = QCursor::pos(); // 获取当前鼠标的全局位置
  115. QPoint leftWidgetLocalPos = ui->LeftOperatewidget->mapFromGlobal(globalMousePos);
  116. QPoint rightWidgetLocalPos = ui->RightOperatewidget->mapFromGlobal(globalMousePos);
  117. if (ui->LeftOperatewidget->rect().contains(leftWidgetLocalPos)){
  118. QPixmap scaledImage = Left_currentPixmap.scaled(Left_currentPixmap.width(), Left_currentPixmap.height(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
  119. ui->LeftOperatewidget->setPixmap(scaledImage); // 这里传递缩放后的图片
  120. Left_scaleFactor = 1.0;
  121. ui->Leftlabel_Percentage->setText("100%");
  122. }
  123. if(ui->RightOperatewidget->rect().contains(rightWidgetLocalPos)){
  124. QPixmap scaledImage = Right_currentPixmap.scaled(Right_currentPixmap.width(), Right_currentPixmap.height(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
  125. ui->RightOperatewidget->setPixmap(scaledImage); // 这里传递缩放后的图片
  126. Right_scaleFactor = 1.0;
  127. ui->Rightlabel_Percentage->setText("100%");
  128. }
  129. }
  130. void MainAndSecondaryCamerasWnd::initLineEdits() {
  131. QList<QLineEdit*> lineEdits = {
  132. ui->RedLightlineEdit_2, ui->GreenLightlineEdit_5,
  133. ui->BlueLightlineEdit_2, ui->DotLightlineEdit_2
  134. };
  135. for (QLineEdit* lineEdit : lineEdits) {
  136. lineEdit->setAlignment(Qt::AlignCenter);
  137. }
  138. }
  139. void MainAndSecondaryCamerasWnd::connectSliderAndLineEdit(QSlider* slider, QLineEdit* lineEdit)
  140. {
  141. QIntValidator* validator = new QIntValidator(slider->minimum(), slider->maximum(), lineEdit);
  142. lineEdit->setValidator(validator);
  143. connect(slider, &QSlider::valueChanged, [lineEdit](int value) {
  144. lineEdit->setText(QString::number(value));
  145. });
  146. connect(lineEdit, &QLineEdit::textChanged, [slider](const QString &text) {
  147. bool ok;
  148. int value = text.toInt(&ok);
  149. if (ok && value >= slider->minimum() && value <= slider->maximum()) {
  150. slider->setValue(value);
  151. } else if (!text.isEmpty()) {
  152. int closestValue = qMin(qMax(text.toInt(&ok), slider->minimum()), slider->maximum());
  153. slider->setValue(closestValue);
  154. }
  155. });
  156. }
  157. void MainAndSecondaryCamerasWnd::checkSettings() {
  158. QSettings settings("YourCompany", "YourApplication_");
  159. int groupId = settings.value("GroupId", 0).toInt();
  160. int index = settings.value("Index", 0).toInt();
  161. if (groupId != lastGroupId || index != lastIndex) {
  162. loadSettings();
  163. lastGroupId = groupId;
  164. lastIndex = index;
  165. }
  166. }
  167. void MainAndSecondaryCamerasWnd::loadSettings()
  168. {
  169. QSettings settings("YourCompany", "YourApplication_");
  170. int groupId = settings.value("GroupId", 0).toInt();
  171. int index = settings.value("Index", 0).toInt();
  172. loadGroupSettings(groupId, index);
  173. }
  174. void MainAndSecondaryCamerasWnd::loadGroupSettings(int Id, int Index) {
  175. // isUpdatingSettings = true;
  176. QSettings settings("YourOrganization", "YourApplication");
  177. settings.beginGroup(QString::number(Id));
  178. QString imagePath1 = settings.value("ImagePath1").toString();
  179. int materialWndType = settings.value("MaterialWndType").toInt();
  180. QStringList textList = settings.value("TextList").toStringList();
  181. settings.endGroup();
  182. QString lastRightImage = settings.value("LastRightImage").toString();
  183. QSize size_left = ui->LeftOperatewidget->size();
  184. QSize size_right = ui->RightOperatewidget->size();
  185. QPixmap newPixmap;
  186. if (Index == 1) {
  187. newPixmap = QPixmap(imagePath1);
  188. clearLayout(1);
  189. if (lastIndex == 1) {
  190. clearLayout(0);
  191. } else if (lastIndex == 2) {
  192. clearLayout(0);
  193. if (lastGroupId == 1) {
  194. WaferWidget(0);
  195. } else if (lastGroupId == 2) {
  196. WaffleWidget(0);
  197. } else if (lastGroupId == 3) {
  198. MaterialBoxWidget(0);
  199. }
  200. }
  201. } else if (Index == 2) {
  202. clearLayout(1);
  203. clearLayout(0);
  204. if (materialWndType == 1) {
  205. if (lastIndex == 2) {
  206. if (lastGroupId == 1) {
  207. WaferWidget(0);
  208. } else if (lastGroupId == 2) {
  209. WaffleWidget(0);
  210. } else if (lastGroupId == 3) {
  211. MaterialBoxWidget(0);
  212. }
  213. }
  214. WaferWidget(1);
  215. } else if (materialWndType == 2) {
  216. if (lastIndex == 2) {
  217. if (lastGroupId == 1) {
  218. WaferWidget(0);
  219. } else if (lastGroupId == 2) {
  220. WaffleWidget(0);
  221. } else if (lastGroupId == 3) {
  222. MaterialBoxWidget(0);
  223. }
  224. }
  225. WaffleWidget(1);
  226. } else if (materialWndType == 3) {
  227. if (lastIndex == 2) {
  228. if (lastGroupId == 1) {
  229. WaferWidget(0);
  230. } else if (lastGroupId == 2) {
  231. WaffleWidget(0);
  232. } else if (lastGroupId == 3) {
  233. MaterialBoxWidget(0);
  234. }
  235. }
  236. MaterialBoxWidget(1);
  237. }
  238. }
  239. QSettings settings2("YourOrganization", "YourApplication_lastWndType");
  240. settings2.setValue("LastWndType", lastIndex);
  241. settings2.setValue("LastGroup", lastGroupId);
  242. QPixmap scaledPixmap_right = newPixmap.scaled(size_right, Qt::KeepAspectRatio, Qt::SmoothTransformation);
  243. ui->RightOperatewidget->setPixmap(scaledPixmap_right);
  244. QPixmap scaledPixmap_left = lastRightPixmap.scaled(size_left, Qt::KeepAspectRatio, Qt::SmoothTransformation);
  245. ui->LeftOperatewidget->setPixmap(scaledPixmap_left);
  246. // 更新当前图片的成员变量
  247. Left_currentPixmap = scaledPixmap_left;
  248. Left_scaleFactor = 1.0;
  249. Right_currentPixmap = scaledPixmap_right;
  250. Right_scaleFactor = 1.0;
  251. ui->Leftlabel_Percentage->setText("100%");
  252. ui->Rightlabel_Percentage->setText("100%");
  253. ui->LeftDataSources->clear();
  254. ui->LeftDataSources->addItems(lasttextList);
  255. ui->RightDataSources->clear();
  256. ui->RightDataSources->addItems(textList);
  257. // 保存到 QSettings
  258. settings.beginGroup("LastSettings");
  259. settings.setValue("LastRightPixmap", lastRightPixmap);
  260. settings.setValue("LasttextList", lasttextList);
  261. settings.setValue("LastLastRightPixmap", lastLastRightPixmap);
  262. settings.setValue("LastLasttextList", lastLasttextList);
  263. settings.endGroup();
  264. if (isUpdatingSettings) {
  265. lastLastRightPixmap = lastRightPixmap;
  266. lastLasttextList = lasttextList;
  267. lastRightPixmap = scaledPixmap_right;
  268. lasttextList = textList;
  269. }
  270. }
  271. void MainAndSecondaryCamerasWnd::clearLayout(int flag) {
  272. QWidget* widget = (flag == 1) ? ui->RightOperatewidget : ui->LeftOperatewidget;
  273. QLayout* layout = widget->layout();
  274. if (layout) {
  275. QLayoutItem *child;
  276. while ((child = layout->takeAt(0)) != nullptr) {
  277. if (child->widget() != nullptr) {
  278. delete child->widget(); // 删除控件
  279. }
  280. delete child; // 删除布局项
  281. }
  282. delete layout; // 删除布局本身
  283. }
  284. }
  285. // 圆晶
  286. void MainAndSecondaryCamerasWnd::WaferWidget(int flag) {
  287. // QWidget *operatewidget = ui->LeftOperatewidget;
  288. // if (flag == 1) {
  289. // operatewidget = ui->RightOperatewidget;
  290. // }
  291. // QGridLayout *layout = new QGridLayout(operatewidget);
  292. // wafer = new Wafer(1, operatewidget);
  293. // wafer->initFrom(operatewidget);
  294. // layout->setContentsMargins(0, 0, 0, 0);
  295. // layout->addWidget(wafer->globalWidget);
  296. // operatewidget->setLayout(layout);
  297. // operatewidget->setFixedSize(476, 476);
  298. }
  299. // 华夫盒
  300. void MainAndSecondaryCamerasWnd::WaffleWidget(int flag) {
  301. QWidget *operatewidget = ui->LeftOperatewidget;
  302. if (flag == 1) {
  303. operatewidget = ui->RightOperatewidget;
  304. }
  305. QVBoxLayout *layout = new QVBoxLayout(operatewidget);
  306. waffle = new Waffle(1, operatewidget);
  307. layout->setContentsMargins(0, 0, 0, 0);
  308. layout->addWidget(waffle);
  309. operatewidget->setLayout(layout);
  310. operatewidget->setFixedSize(476, 476);
  311. }
  312. // 料盒
  313. void MainAndSecondaryCamerasWnd::MaterialBoxWidget(int flag) {
  314. QWidget *operatewidget = ui->LeftOperatewidget;
  315. if (flag == 1) {
  316. operatewidget = ui->RightOperatewidget;
  317. }
  318. QVBoxLayout *layout = new QVBoxLayout(operatewidget);
  319. materialbox = new MaterialBox(1, operatewidget);
  320. layout->setContentsMargins(0, 0, 0, 0);
  321. layout->addWidget(materialbox);
  322. operatewidget->setLayout(layout);
  323. operatewidget->setFixedSize(476, 476);
  324. }
  325. void MainAndSecondaryCamerasWnd::on_LeftZoomUpButton_clicked()
  326. {
  327. Left_scaleFactor *= 1.1;
  328. int newWidth = Left_currentPixmap.width() * Left_scaleFactor;
  329. int newHeight = Left_currentPixmap.height() * Left_scaleFactor;
  330. QPixmap scaledImage = Left_currentPixmap.scaled(newWidth, newHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
  331. ui->LeftOperatewidget->setPixmap(scaledImage);
  332. double percentage = (Left_scaleFactor * 100);
  333. QString percentageStr = QString::number((int)percentage);
  334. ui->Leftlabel_Percentage->setText(QString("%1%").arg(percentageStr));
  335. }
  336. void MainAndSecondaryCamerasWnd::on_RightZoomUpButton_clicked()
  337. {
  338. Right_scaleFactor *= 1.1;
  339. int newWidth = Right_currentPixmap.width() * Right_scaleFactor;
  340. int newHeight = Right_currentPixmap.height() * Right_scaleFactor;
  341. QPixmap scaledImage = Right_currentPixmap.scaled(newWidth, newHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
  342. ui->RightOperatewidget->setPixmap(scaledImage);
  343. double percentage = (Right_scaleFactor * 100);
  344. QString percentageStr = QString::number((int)percentage);
  345. ui->Rightlabel_Percentage->setText(QString("%1%").arg(percentageStr));
  346. }
  347. void MainAndSecondaryCamerasWnd::on_LeftZoomOutButton_clicked()
  348. {
  349. double Left_newScaleFactor = Left_scaleFactor * 0.9;
  350. if (Left_newScaleFactor >= 1.0) {
  351. Left_scaleFactor = Left_newScaleFactor;
  352. } else {
  353. Left_scaleFactor = 1.0;
  354. }
  355. int newWidth = Left_currentPixmap.width() * Left_scaleFactor;
  356. int newHeight = Left_currentPixmap.height() * Left_scaleFactor;
  357. QPixmap scaledImage = Left_currentPixmap.scaled(newWidth, newHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
  358. ui->LeftOperatewidget->setPixmap(scaledImage);
  359. double percentage = (Left_scaleFactor * 100);
  360. QString percentageStr = QString::number((int)percentage);
  361. ui->Leftlabel_Percentage->setText(QString("%1%").arg(percentageStr));
  362. }
  363. void MainAndSecondaryCamerasWnd::on_RightZoomOutButton_clicked()
  364. {
  365. double Right_newScaleFactor = Right_scaleFactor * 0.9;
  366. if (Right_newScaleFactor >= 1.0) {
  367. Right_scaleFactor = Right_newScaleFactor;
  368. } else {
  369. Right_scaleFactor = 1.0;
  370. }
  371. int newWidth = Right_currentPixmap.width() * Right_scaleFactor;
  372. int newHeight = Right_currentPixmap.height() * Right_scaleFactor;
  373. QPixmap scaledImage = Right_currentPixmap.scaled(newWidth, newHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
  374. ui->RightOperatewidget->setPixmap(scaledImage);
  375. double percentage = (Right_scaleFactor * 100);
  376. QString percentageStr = QString::number((int)percentage);
  377. ui->Rightlabel_Percentage->setText(QString("%1%").arg(percentageStr));
  378. }
  379. void MainAndSecondaryCamerasWnd::wheelEvent(QWheelEvent *event)
  380. {
  381. if (ui->LeftOperatewidget->rect().contains(ui->LeftOperatewidget->mapFromGlobal(event->globalPosition().toPoint()))) {
  382. if (event->angleDelta().y() > 0) {
  383. Left_scaleFactor *= 1.1;
  384. } else {
  385. double Left_newScaleFactor = Left_scaleFactor * 0.9;
  386. if (Left_newScaleFactor >= 1.0) {
  387. Left_scaleFactor = Left_newScaleFactor;
  388. } else {
  389. Left_scaleFactor = 1.0;
  390. }
  391. }
  392. int newWidth_left = Left_currentPixmap.width() * Left_scaleFactor;
  393. int newHeight_left = Left_currentPixmap.height() * Left_scaleFactor;
  394. QPixmap scaledImage_left = Left_currentPixmap.scaled(newWidth_left, newHeight_left, Qt::KeepAspectRatio, Qt::SmoothTransformation);
  395. // ui->LeftOperatewidget->setPixmap(scaledImage_left);
  396. // ui->LeftOperatewidget->setPixmapAndPoint(scaledImage_left);
  397. double percentage_left = Left_scaleFactor * 100;
  398. QString percentageStr_left = QString::number((int)percentage_left);
  399. ui->Leftlabel_Percentage->setText(QString("%1%").arg(percentageStr_left));
  400. }
  401. if (ui->RightOperatewidget->rect().contains(ui->RightOperatewidget->mapFromGlobal(event->globalPosition().toPoint()))) {
  402. if (event->angleDelta().y() > 0) {
  403. Right_scaleFactor *= 1.1;
  404. } else {
  405. double Right_newScaleFactor = Right_scaleFactor * 0.9;
  406. if (Right_newScaleFactor >= 1.0) {
  407. Right_scaleFactor = Right_newScaleFactor;
  408. } else {
  409. Right_scaleFactor = 1.0;
  410. }
  411. }
  412. int newWidth = Right_currentPixmap.width() * Right_scaleFactor;
  413. int newHeight = Right_currentPixmap.height() * Right_scaleFactor;
  414. QPixmap scaledImage = Right_currentPixmap.scaled(newWidth, newHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
  415. // ui->RightOperatewidget->setPixmap(scaledImage);
  416. // ui->RightOperatewidget->setPixmapAndPoint(scaledImage);
  417. double percentage = Right_scaleFactor * 100;
  418. QString percentageStr = QString::number((int)percentage);
  419. ui->Rightlabel_Percentage->setText(QString("%1%").arg(percentageStr));
  420. }
  421. if (ui->scrollArea->rect().contains(ui->scrollArea->mapFromGlobal(event->globalPos()))) {
  422. // 获取 QScrollArea 的横向滚动条
  423. QScrollBar *scrollBar = ui->scrollArea->horizontalScrollBar();
  424. // 根据滚轮滚动方向改变滚动条的值
  425. if (event->angleDelta().y() > 0) {
  426. scrollBar->setValue(scrollBar->value() - 50);
  427. } else {
  428. scrollBar->setValue(scrollBar->value() + 50);
  429. }
  430. }
  431. QMainWindow::wheelEvent(event);
  432. }
  433. void MainAndSecondaryCamerasWnd::showEvent(QShowEvent *event) {
  434. isUpdatingSettings = false;
  435. QMainWindow::showEvent(event);
  436. loadSettings();
  437. isUpdatingSettings = true;
  438. }
  439. void MainAndSecondaryCamerasWnd::hideEvent(QHideEvent *event) {
  440. isUpdatingSettings = false;
  441. QMainWindow::hideEvent(event);
  442. }
  443. void MainAndSecondaryCamerasWnd::showAndHide(){
  444. if(isShow == true){
  445. isShow = false;
  446. }else{
  447. isShow = true;
  448. }
  449. QList<QLineEdit*> lineEdits = {
  450. ui->RedLightlineEdit_2, ui->GreenLightlineEdit_5,
  451. ui->BlueLightlineEdit_2, ui->DotLightlineEdit_2
  452. };
  453. QList<QSlider*> sliders = {
  454. ui->RedLightverticalSlider_2, ui->GreenLightverticalSlider_5,
  455. ui->BlueLightverticalSlider, ui->DotLightverticalSlider_2
  456. };
  457. QList<QProgressBar*> progressBar = {
  458. ui->RedLightprogressBar_2,ui->GreenLightprogressBar_5,
  459. ui->BlueLightprogressBar_2,ui->DotLightprogressBar_2
  460. };
  461. if(isShow == true){
  462. for (QLineEdit* lineEdit : lineEdits) {
  463. lineEdit->show();
  464. }
  465. for (int i = 0; i < sliders.size(); ++i) {
  466. sliders[i]->show();
  467. }
  468. for (int i = 0; i < progressBar.size(); ++i) {
  469. progressBar[i]->show();
  470. }
  471. ui->BlueLight->show();
  472. ui->RedLight->show();
  473. ui->DotLight->show();
  474. ui->GreenLight->show();
  475. ui->BlueLightlabel_2->show();
  476. ui->RedLightlabel_2->show();
  477. ui->DotLightlabel_2->show();
  478. ui->GreenLightlabel_5->show();
  479. }else{
  480. for (QLineEdit* lineEdit : lineEdits) {
  481. lineEdit->hide();
  482. }
  483. for (int i = 0; i < sliders.size(); ++i) {
  484. sliders[i]->hide();
  485. }
  486. for (int i = 0; i < progressBar.size(); ++i) {
  487. progressBar[i]->hide();
  488. }
  489. ui->BlueLight->hide();
  490. ui->RedLight->hide();
  491. ui->DotLight->hide();
  492. ui->GreenLight->hide();
  493. ui->BlueLightlabel_2->hide();
  494. ui->RedLightlabel_2->hide();
  495. ui->DotLightlabel_2->hide();
  496. ui->GreenLightlabel_5->hide();
  497. }
  498. }