Group.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. #include "Group.h"
  2. #include "ui_Group.h"
  3. #include <QMouseEvent>
  4. #include <QSettings>
  5. #include <QVBoxLayout>
  6. #include <QLabel>
  7. #include <QTimer>
  8. #include "QDir"
  9. // 静态变量初始化
  10. Group* Group::m_pCurrentlySelectedGroup = nullptr;
  11. Group* Group::m_pPreviouslySelectedBlueGroup = nullptr;
  12. Group* Group::m_pLastClickedGroup = nullptr;
  13. int Group::m_stnLastClickedIndex = 0;
  14. int Group::m_stnLastSavedIndex = 1;
  15. Group::Group(int groupId,const CameraInfo& cameraInfo, ns_module::CViewInterface *cViewInterface,QList<QPair<QString, QString>> fileList,QWidget* parent)
  16. //Group::Group(const CameraInfo& cameraInfo, QWidget* parent)
  17. : QWidget(parent), ui(new Ui::Group), m_nCurrentGroupId(groupId)
  18. {
  19. ui->setupUi(this);
  20. m_stnCurrentComboBoxIndex = 0;
  21. m_pCViewInterface = cViewInterface;
  22. m_nGroupId = m_nCurrentGroupId;
  23. //初始化目录名称
  24. for (const auto& pair : fileList) {
  25. ui->DatacomboBox->addItem(pair.first, pair.second);
  26. }
  27. ui->DatacomboBox->setCurrentIndex(m_stnCurrentComboBoxIndex);
  28. ui->GroupButton->setStyleSheet(
  29. "QPushButton:hover {"
  30. " background-color: #45a049;"
  31. "}"
  32. "QPushButton:pressed {"
  33. " background-color: #3e8e41;"
  34. "}"
  35. );
  36. ui->Imagewidget_left->setProperty("groupId", groupId);
  37. ui->Imagewidget_right->setProperty("groupId", groupId);
  38. ui->rightBackground->setStyleSheet("");
  39. ui->leftBackground->setStyleSheet("");
  40. if (cameraInfo.eType == 1)
  41. {
  42. //m_pWafer = new Wafer(0, ui->Imagewidget_right);
  43. //if (m_pCViewInterface != nullptr)
  44. //{
  45. // std::vector<ns_mat::WAFER_MATRIX_POINT_INFO_STRUCT> veWafer;
  46. // m_pCViewInterface->GetViewMatrix()->GetWaferAllPointInfo(veWafer);
  47. // m_pWafer->UpdataVal(veWafer);
  48. //}
  49. //else
  50. //{
  51. // m_pWafer->UpdataGenerateTestData();
  52. //}
  53. //WaferWidget();
  54. }
  55. else if (cameraInfo.eType == 2)
  56. {
  57. m_pWaffle = new Waffle(0, ui->Imagewidget_right);
  58. if (m_pCViewInterface != nullptr)
  59. {
  60. std::vector<ns_mat::WAFFLE_MATRIX_POINT_STRUCT> veWaffle;
  61. m_pCViewInterface->GetViewMatrix()->GetWafflePackAllPointInfo(veWaffle);
  62. m_pWaffle->UpdataVal(veWaffle);
  63. }
  64. else
  65. {
  66. m_pWaffle->UpdataGenerateTestData();
  67. }
  68. WaffleWidget();
  69. }
  70. else if (cameraInfo.eType == 3)
  71. {
  72. m_pMaterialbox = new MaterialBox(0, ui->Imagewidget_right);
  73. if (m_pCViewInterface != nullptr)
  74. {
  75. std::vector<ns_module::MATERIAL_BOX_STRUCT> veMaterial;
  76. m_pCViewInterface->GetViewMatrix()->GetMaterialBoxAllPointInfo(veMaterial);
  77. m_pMaterialbox->UpdataVal(veMaterial);
  78. }
  79. else
  80. {
  81. m_pMaterialbox->UpdataGenerateTestData();
  82. }
  83. MaterialBoxWidget();
  84. }
  85. else if (cameraInfo.eType == 4)
  86. {
  87. m_pBond = new Bond(ui->Imagewidget_right);
  88. if (m_pCViewInterface != nullptr)
  89. {
  90. std::vector<ns_mat::POINT_INFO_STRUCT> stPointInfo;
  91. m_pCViewInterface->GetViewMatrix()->GetBondAllPointInfo(stPointInfo);
  92. m_pBond->UpdataVal(stPointInfo);
  93. }
  94. else
  95. {
  96. m_pBond->UpdataGenerateTestData();
  97. }
  98. BondWidget();
  99. }
  100. saveGroupSettings(groupId, cameraInfo.eType);
  101. connect(ui->GroupButton, &QPushButton::clicked, this, &Group::onclickbutton);
  102. connect(ui->DatacomboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
  103. this, &Group::on_DatacomboBox_currentIndexChanged);
  104. initForm();
  105. connect(this, &Group::SendGroupSelectedSignals, this, &Group::GetGroupSelectedSlots);
  106. }
  107. Group::~Group()
  108. {
  109. delete ui;
  110. }
  111. void Group::initForm()
  112. {
  113. ui->Imagewidget_left->installEventFilter(this);
  114. ui->Imagewidget_right->installEventFilter(this);
  115. // MainWnd *mainWindow = new MainWnd();
  116. // connect(mainWindow,&MainWnd::styleChanged,this,&Group::Changedstyle);
  117. QTimer *timer = new QTimer(this);
  118. connect(timer, &QTimer::timeout, this, &Group::Changedstyle);
  119. timer->start(100);
  120. }
  121. void Group::Changedstyle()
  122. {
  123. QSettings settings("YourCompany", "YourApplication_style");
  124. int flag = settings.value("Flag_Style").toInt();
  125. if (flag == 0) {
  126. ui->DatacomboBox->setStyleSheet("background-color: #FFFFFF;");
  127. } else {
  128. ui->DatacomboBox->setStyleSheet("background-color: #4C4FA6;");
  129. }
  130. }
  131. bool Group::eventFilter(QObject *obj, QEvent *event)
  132. {
  133. if (event->type() == QEvent::MouseButtonDblClick)
  134. {
  135. QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
  136. if (mouseEvent->button() == Qt::LeftButton)
  137. {
  138. int index = 0;
  139. if (obj == this->ui->Imagewidget_left)
  140. {
  141. index = 1;
  142. //setEnableControls(true);
  143. }
  144. else if (obj == this->ui->Imagewidget_right)
  145. {
  146. index = 2;
  147. //setEnableControls(false);
  148. }
  149. if (index == 0) {
  150. return QWidget::eventFilter(obj, event);
  151. }
  152. //获取当前点击的group
  153. int groupId = obj->property("groupId").toInt();
  154. QSettings lastSettings("YourCompany", "YourApplication_");
  155. int lastGroupId = lastSettings.value("GroupId", 0).toInt();
  156. int lastIndex = lastSettings.value("Index", 0).toInt();
  157. //对比判断点击是否当前的最新小窗口
  158. if ((lastGroupId == groupId) && (lastIndex == index)) {
  159. return QWidget::eventFilter(obj, event);
  160. }
  161. // 保存索引并调用检查函数
  162. QSettings settings("YourCompany", "YourApplication_");
  163. settings.setValue("GroupId", groupId);
  164. settings.setValue("Index", index);
  165. //改变小窗口边框颜色
  166. check_selected(index);
  167. //发送信号
  168. emit SetCurrentSelectSig(groupId, index);
  169. emit SendGroupSelectedSignals(this, index);
  170. emit sendUpdateGroupState(groupId, index);
  171. return true;
  172. }
  173. }
  174. return QWidget::eventFilter(obj, event);
  175. }
  176. void Group::check_selected(int index)
  177. {
  178. if (index == 1)
  179. {
  180. ui->leftBackground->setStyleSheet("border: 2px solid red;");
  181. }
  182. else if (index == 2)
  183. {
  184. ui->rightBackground->setStyleSheet("border: 2px solid red;");
  185. }
  186. }
  187. void Group::saveGroupSettings(int Id, int materialWndType)
  188. {
  189. QSettings settings("YourOrganization", "YourApplication");
  190. settings.beginGroup(QString::number(Id));
  191. //settings.setValue("ImagePath1", imagePath1);
  192. settings.setValue("MaterialWndType", materialWndType);
  193. //settings.setValue("TextList", textList);
  194. settings.endGroup();
  195. }
  196. void Group::WaferWidget()
  197. {
  198. //QVBoxLayout *layout2 = new QVBoxLayout(ui->Imagewidget_right);
  199. //m_pWafer->paintInitFrom(ui->Imagewidget_right);
  200. //QLabel* pixmapLabel = new QLabel();
  201. //pixmapLabel->setPixmap(m_pWafer->getGlobalPixmap());
  202. //ui->Imagewidget_right->setLayout(layout2);
  203. //ui->Imagewidget_right->setFixedSize(110, 110);
  204. //layout2->setContentsMargins(0, 0, 0, 0);
  205. //layout2->addWidget(pixmapLabel);
  206. }
  207. void Group::setWafer(Wafer* wafer) {
  208. m_pWafer = wafer;
  209. }
  210. void Group::setWaferWidget(QPixmap pixmap)
  211. {
  212. QVBoxLayout* layout2 = new QVBoxLayout(ui->Imagewidget_right);
  213. m_pWafer->paintInitFrom(ui->Imagewidget_right);
  214. int width, height;
  215. width = ui->Imagewidget_right->width();
  216. height = ui->Imagewidget_right->height();
  217. QSize targetSize(width, height);
  218. // 不保持比例,直接拉伸到指定尺寸
  219. QPixmap scaledPixmap = pixmap.scaled(
  220. targetSize,
  221. Qt::IgnoreAspectRatio,
  222. Qt::SmoothTransformation
  223. );
  224. QLabel* pixmapLabel = new QLabel();
  225. pixmapLabel->setPixmap(scaledPixmap);
  226. ui->Imagewidget_right->setLayout(layout2);
  227. ui->Imagewidget_right->setFixedSize(110, 110);
  228. layout2->setContentsMargins(0, 0, 0, 0);
  229. layout2->addWidget(pixmapLabel);
  230. }
  231. void Group::setBondWidget(QPixmap pixmap) {
  232. QVBoxLayout* layout2 = new QVBoxLayout(ui->Imagewidget_right);
  233. m_pBond->paintInitFrom(ui->Imagewidget_right);
  234. int width, height;
  235. width = ui->Imagewidget_right->width();
  236. height = ui->Imagewidget_right->height();
  237. QSize targetSize(width, height);
  238. // 不保持比例,直接拉伸到指定尺寸
  239. QPixmap scaledPixmap = pixmap.scaled(
  240. targetSize,
  241. Qt::IgnoreAspectRatio,
  242. Qt::SmoothTransformation
  243. );
  244. QLabel* pixmapLabel = new QLabel();
  245. pixmapLabel->setPixmap(scaledPixmap);
  246. ui->Imagewidget_right->setLayout(layout2);
  247. ui->Imagewidget_right->setFixedSize(110, 110);
  248. layout2->setContentsMargins(0, 0, 0, 0);
  249. layout2->addWidget(pixmapLabel);
  250. }
  251. void Group::setWaffleWidget(QPixmap pixmap) {
  252. QVBoxLayout* layout2 = new QVBoxLayout(ui->Imagewidget_right);
  253. m_pWaffle->paintInitFrom(ui->Imagewidget_right);
  254. int width, height;
  255. width = ui->Imagewidget_right->width();
  256. height = ui->Imagewidget_right->height();
  257. QSize targetSize(width, height);
  258. // 不保持比例,直接拉伸到指定尺寸
  259. QPixmap scaledPixmap = pixmap.scaled(
  260. targetSize,
  261. Qt::IgnoreAspectRatio,
  262. Qt::SmoothTransformation
  263. );
  264. QLabel* pixmapLabel = new QLabel();
  265. pixmapLabel->setPixmap(scaledPixmap);
  266. ui->Imagewidget_right->setLayout(layout2);
  267. ui->Imagewidget_right->setFixedSize(110, 110);
  268. layout2->setContentsMargins(0, 0, 0, 0);
  269. layout2->addWidget(pixmapLabel);
  270. }
  271. void Group::setMaterialBox(MaterialBox* materialBox) {
  272. m_pMaterialbox = materialBox;
  273. }
  274. void Group::SetCameaInfo(CameraInfo cameaInfo)
  275. {
  276. m_cameaInfo = cameaInfo;
  277. }
  278. void Group::WaffleWidget()
  279. {
  280. //QVBoxLayout *layout2 = new QVBoxLayout(ui->Imagewidget_right);
  281. //m_pWaffle->paintInitFrom(ui->Imagewidget_right);
  282. //QLabel* pixmapLabel = new QLabel();
  283. //pixmapLabel->setPixmap(m_pWaffle->getGlobalPixmap());
  284. //ui->Imagewidget_right->setLayout(layout2);
  285. //ui->Imagewidget_right->setFixedSize(110, 110);
  286. //layout2->setContentsMargins(0, 0, 0, 0);
  287. //layout2->addWidget(pixmapLabel);
  288. }
  289. void Group::MaterialBoxWidget()
  290. {
  291. QVBoxLayout* layout2 = new QVBoxLayout(ui->Imagewidget_right);
  292. m_pMaterialbox->paintInitFrom(ui->Imagewidget_right);
  293. QLabel* pixmapLabel = new QLabel();
  294. pixmapLabel->setPixmap(m_pMaterialbox->getGlobalPixmap());
  295. ui->Imagewidget_right->setLayout(layout2);
  296. ui->Imagewidget_right->setFixedSize(110, 110);
  297. layout2->setContentsMargins(0, 0, 0, 0);
  298. layout2->addWidget(pixmapLabel);
  299. }
  300. void Group::BondWidget()
  301. {
  302. //QVBoxLayout* layout2 = new QVBoxLayout(ui->Imagewidget_right);
  303. //m_pBond->paintInitFrom(ui->Imagewidget_right);
  304. //QLabel* pixmapLabel = new QLabel();
  305. //pixmapLabel->setPixmap(m_pBond->getGlobalPixmap());
  306. //ui->Imagewidget_right->setLayout(layout2);
  307. //ui->Imagewidget_right->setFixedSize(110, 110);
  308. //layout2->setContentsMargins(0, 0, 0, 0);
  309. //layout2->addWidget(pixmapLabel);
  310. }
  311. void Group::onclickbutton(){
  312. QSettings settings("YourCompany", "YourApplication_Button");
  313. settings.setValue("GroupId_button", m_nCurrentGroupId);
  314. emit send_button_Signal();
  315. }
  316. void Group::setDatacomboBox(int index){
  317. ui->DatacomboBox->setCurrentIndex(index);
  318. }
  319. void Group::on_DatacomboBox_currentIndexChanged(int comboxIndex){
  320. send_ComboBox_singal(m_nCurrentGroupId,comboxIndex);
  321. }
  322. void Group::UpDataImageShowSlots(const QPixmap& imageData)
  323. {
  324. QSize size_left = ui->Imagewidget_left->size();
  325. QPixmap scaledPixmap = imageData.scaled(size_left, Qt::KeepAspectRatio, Qt::SmoothTransformation);
  326. ui->Imagewidget_left->setPixmap(scaledPixmap);
  327. emit SetUpDataImageShowSig(imageData);
  328. }
  329. void Group::showEvent(QShowEvent *event) {
  330. QWidget::showEvent(event);
  331. loadBorderSettings();
  332. }
  333. void Group::hideEvent(QHideEvent *event) {
  334. QWidget::hideEvent(event);
  335. saveBorderSettings(); // 保存边框颜色信息
  336. }
  337. void Group::saveBorderSettings()
  338. {
  339. QSettings settings("YourOrganization", "YourApplication");
  340. settings.beginGroup(QString::number(m_nCurrentGroupId));
  341. QString leftStyle = ui->leftBackground->styleSheet();
  342. QString rightStyle = ui->rightBackground->styleSheet();
  343. if (leftStyle.contains("blue", Qt::CaseInsensitive)) {
  344. leftStyle = ""; // 清除样式
  345. // 记录该边框信息
  346. recordBorderInfo(m_nCurrentGroupId, "Left");
  347. }
  348. if (rightStyle.contains("blue", Qt::CaseInsensitive)) {
  349. rightStyle = ""; // 清除样式
  350. // 记录该边框信息
  351. recordBorderInfo(m_nCurrentGroupId, "Right");
  352. }
  353. settings.setValue("LeftBorderStyle", leftStyle);
  354. settings.setValue("RightBorderStyle", rightStyle);
  355. settings.setValue("LastClickedIndex", m_stnLastClickedIndex);
  356. settings.setValue("LastSavedIndex", m_stnLastSavedIndex);
  357. if (m_pCurrentlySelectedGroup == this) {
  358. settings.setValue("IsCurrentlySelected", true);
  359. }
  360. else {
  361. settings.setValue("IsCurrentlySelected", false);
  362. }
  363. settings.endGroup();
  364. }
  365. void Group::recordBorderInfo(int groupId, const QString& side)
  366. {
  367. QSettings settings("YourOrganization", "YourApplication");
  368. settings.beginGroup("ModifiedBorders");
  369. QString key = QString("%1_%2").arg(groupId).arg(side);
  370. settings.setValue(key, true);
  371. settings.endGroup();
  372. }
  373. void Group::loadBorderSettings()
  374. {
  375. QSettings settings("YourOrganization", "YourApplication");
  376. settings.beginGroup(QString::number(m_nCurrentGroupId));
  377. QString leftStyle = settings.value("LeftBorderStyle", "").toString();
  378. QString rightStyle = settings.value("RightBorderStyle", "").toString();
  379. m_stnLastClickedIndex = settings.value("LastClickedIndex", 0).toInt();
  380. m_stnLastSavedIndex = settings.value("LastSavedIndex", 1).toInt();
  381. bool isCurrentlySelected = settings.value("IsCurrentlySelected", false).toBool();
  382. QSettings settings2("OrganizationName__", "ApplicationName__");
  383. int Index = settings2.value("lastIndex", 1).toInt();
  384. if (Index == 2) {
  385. QSettings borderInfoSettings("YourOrganization", "YourApplication");
  386. borderInfoSettings.beginGroup("ModifiedBorders");
  387. QString leftKey = QString("%1_Left").arg(m_nCurrentGroupId);
  388. QString rightKey = QString("%1_Right").arg(m_nCurrentGroupId);
  389. // 检查左边框是否需要还原
  390. if (borderInfoSettings.contains(leftKey)) {
  391. leftStyle = getBlueBorderStyle();
  392. borderInfoSettings.remove(leftKey); // 移除记录,避免下次重复处理
  393. qDebug() << "Left border of group" << m_nCurrentGroupId << "restored to blue.";
  394. m_pPreviouslySelectedBlueGroup = this;
  395. // lastClickedGroup =this;
  396. }
  397. // 检查右边框是否需要还原
  398. if (borderInfoSettings.contains(rightKey)) {
  399. rightStyle = getBlueBorderStyle();
  400. borderInfoSettings.remove(rightKey);
  401. qDebug() << "Right border of group" << m_nCurrentGroupId << "restored to blue.";
  402. m_pPreviouslySelectedBlueGroup = this;
  403. // lastClickedGroup =this;
  404. }
  405. borderInfoSettings.endGroup();
  406. }
  407. //ui->leftBackground->setStyleSheet(leftStyle);
  408. //ui->rightBackground->setStyleSheet(rightStyle);
  409. if (isCurrentlySelected) {
  410. m_pCurrentlySelectedGroup = this;
  411. m_pLastClickedGroup = this;
  412. if (leftStyle.contains("red")) {
  413. m_stnLastClickedIndex = 1;
  414. qDebug() << "Left border of group" << m_nCurrentGroupId << "is red.";
  415. }
  416. else if (rightStyle.contains("red")) {
  417. m_stnLastClickedIndex = 2;
  418. qDebug() << "Right border of group" << m_nCurrentGroupId << "is red.";
  419. }
  420. }
  421. settings.endGroup();
  422. }
  423. QString Group::getBlueBorderStyle()
  424. {
  425. static const QString blueBorderStyle = "border: 2px solid blue;";
  426. return blueBorderStyle;
  427. }
  428. QString Group::getRedBorderStyle()
  429. {
  430. static const QString blueBorderStyle = "";
  431. return blueBorderStyle;
  432. }
  433. void Group::GetGroupSelectedSlots(Group* group, int index) {
  434. QSettings settings("OrganizationName__", "ApplicationName__");
  435. int currentLastSavedIndex = settings.value("lastIndex", 1).toInt();
  436. // 检查是否是同一个组的同一个索引被点击
  437. if (m_pLastClickedGroup == group && m_stnLastClickedIndex == index) {
  438. // 如果是同一个组的同一个索引被点击,则不更新边框
  439. return;
  440. }
  441. // 清除当前红色边框
  442. if (m_pCurrentlySelectedGroup != nullptr) {
  443. m_pCurrentlySelectedGroup->ui->leftBackground->setStyleSheet("");
  444. m_pCurrentlySelectedGroup->ui->rightBackground->setStyleSheet("");
  445. }
  446. // 清除当前蓝色边框
  447. if (m_pPreviouslySelectedBlueGroup != nullptr) {
  448. m_pPreviouslySelectedBlueGroup->ui->leftBackground->setStyleSheet("");
  449. m_pPreviouslySelectedBlueGroup->ui->rightBackground->setStyleSheet("");
  450. }
  451. if (currentLastSavedIndex == 1 || currentLastSavedIndex == 3) {
  452. // 仅当前选中设为红色,蓝色边框清空
  453. m_pPreviouslySelectedBlueGroup = nullptr;
  454. }
  455. else if (currentLastSavedIndex == 2) {
  456. // 当前选中设为红色,上一个选中设为蓝色
  457. if (m_pLastClickedGroup != nullptr) {
  458. QString blueBorderStyle = "border: 2px solid blue;";
  459. // 即使是同一个实例,只要索引不同就设置蓝色边框
  460. if (m_pLastClickedGroup == group && m_stnLastClickedIndex != index) {
  461. if (m_stnLastClickedIndex == 1) {
  462. m_pLastClickedGroup->ui->leftBackground->setStyleSheet(blueBorderStyle);
  463. }
  464. else if (m_stnLastClickedIndex == 2) {
  465. m_pLastClickedGroup->ui->rightBackground->setStyleSheet(blueBorderStyle);
  466. }
  467. m_pPreviouslySelectedBlueGroup = m_pLastClickedGroup;
  468. }
  469. else if (m_pLastClickedGroup != group) {
  470. if (m_stnLastClickedIndex == 1) {
  471. m_pLastClickedGroup->ui->leftBackground->setStyleSheet(blueBorderStyle);
  472. }
  473. else if (m_stnLastClickedIndex == 2) {
  474. m_pLastClickedGroup->ui->rightBackground->setStyleSheet(blueBorderStyle);
  475. }
  476. m_pPreviouslySelectedBlueGroup = m_pLastClickedGroup;
  477. }
  478. }
  479. }
  480. // 更新当前选中的 Group 实例
  481. m_pCurrentlySelectedGroup = group;
  482. // 将当前选中的边框设为红色
  483. group->check_selected(index);
  484. // 更新上一次点击的记录
  485. m_pLastClickedGroup = group;
  486. m_stnLastClickedIndex = index;
  487. }
  488. void Group::setEnableControls(bool enable) {
  489. ui->GroupButton->setEnabled(enable);
  490. ui->DatacomboBox->setEnabled(enable);
  491. if (enable == true) {
  492. ui->GroupButton->setStyleSheet(
  493. "QPushButton:hover {"
  494. " background-color: #45a049;"
  495. "}"
  496. "QPushButton:pressed {"
  497. " background-color: #3e8e41;"
  498. "}"
  499. );
  500. }
  501. else {
  502. ui->GroupButton->setStyleSheet("background-color: lightgray;");
  503. }
  504. }
  505. int Group::getCurrentComboBoxIndex(){
  506. return ui->DatacomboBox->currentIndex();
  507. }
  508. void Group::setCurrentCombox(const int index){
  509. m_stnCurrentComboBoxIndex = index;
  510. if(m_stnCurrentComboBoxIndex != 0){
  511. QString imagePath = ui->DatacomboBox->itemData(index).toString();
  512. QPixmap pixmap(imagePath);
  513. QSize size_left = ui->Imagewidget_left->size();
  514. QPixmap scaledPixmap = pixmap.scaled(size_left, Qt::KeepAspectRatio, Qt::SmoothTransformation);
  515. ui->Imagewidget_left->setPixmap(scaledPixmap);
  516. }
  517. }
  518. void Group::initBorderStyle(int index,int color) {
  519. if (index == 2) {
  520. if(color == 0){
  521. ui->rightBackground->setStyleSheet("border: 2px solid blue;");
  522. m_pPreviouslySelectedBlueGroup = this;
  523. }
  524. else {
  525. ui->rightBackground->setStyleSheet("border: 2px solid red;");
  526. m_pCurrentlySelectedGroup = this;
  527. m_pLastClickedGroup = this;
  528. }
  529. }
  530. else {
  531. if (color == 0) {
  532. ui->leftBackground->setStyleSheet("border: 2px solid blue;");
  533. m_pPreviouslySelectedBlueGroup = this;
  534. }
  535. else {
  536. ui->leftBackground->setStyleSheet("border: 2px solid red;");
  537. m_pCurrentlySelectedGroup = this;
  538. m_pLastClickedGroup = this;
  539. }
  540. }
  541. }