MainWnd.cpp 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  1. #include "MainWnd.h"
  2. #include "ui_MainWnd.h"
  3. #include "Login.h"
  4. #include <QMouseEvent>
  5. #include <qDebug>
  6. #include "OriginalWnd/OriginalWnd.h"
  7. MainWnd::MainWnd(QWidget *parent)
  8. : QMainWindow(parent)
  9. , ui(new Ui::MainWnd)
  10. ,initialIconSet(false)
  11. {
  12. ui->setupUi(this);
  13. // // 初始化 OriginalWnd
  14. m_originalWnd = new OriginalWnd(this);
  15. // // 将 OriginalWnd 添加到 stackedWidget_UI
  16. ui->stackedWidget_UI->addWidget(m_originalWnd);
  17. bool buttonConnected = connect(ui->tabHomeBtn, &QPushButton::clicked,
  18. this, &MainWnd::on_tabHomeBtn_clicked);
  19. qDebug() << "Connected tabHomeBtn clicked to on_tabHomeBtn_clicked:" << buttonConnected;
  20. connect(ui->tabProductionBtn, &QPushButton::clicked,
  21. this, &MainWnd::on_tabProductionBtn_clicked);
  22. connect(ui->tabDiagnosisBtn, &QPushButton::clicked,
  23. this, &MainWnd::on_tabDiagnosisBtn_clicked);
  24. connect(ui->tabDispositionBtn, &QPushButton::clicked,
  25. this, &MainWnd::on_tabDispositionBtn_clicked);
  26. connect(ui->tabModuleBtn, &QPushButton::clicked,
  27. this, &MainWnd::on_tabModuleBtn_clicked);
  28. connect(ui->tabSystemBtn, &QPushButton::clicked,
  29. this, &MainWnd::on_tabSystemBtn_clicked);
  30. connect(ui->tabProgramBtn, &QPushButton::clicked,
  31. this, &MainWnd::on_tabProgramBtn_clicked);
  32. // 设置 OriginalWnd 为当前页面
  33. ui->stackedWidget_UI->setCurrentWidget(m_originalWnd);
  34. qDebug() << "OriginalWnd 已设置为 stackedWidget 的当前页面";
  35. initForm();
  36. }
  37. MainWnd::~MainWnd()
  38. {
  39. delete ui;
  40. }
  41. void MainWnd::on_tabProductionBtn_clicked()
  42. {
  43. m_originalWnd->switchToProductionConfig();
  44. ui->stackedWidget_UI->setCurrentWidget(m_originalWnd);
  45. }
  46. void MainWnd::on_tabHomeBtn_clicked()
  47. {
  48. m_originalWnd->switchToHomeConfig();
  49. ui->stackedWidget_UI->setCurrentWidget(m_originalWnd);
  50. }
  51. void MainWnd::on_tabProgramBtn_clicked()
  52. {
  53. m_originalWnd->switchToProgramConfig();
  54. ui->stackedWidget_UI->setCurrentWidget(m_originalWnd);
  55. }
  56. void MainWnd::on_tabModuleBtn_clicked()
  57. {
  58. m_originalWnd->switchToModuleConfig();
  59. ui->stackedWidget_UI->setCurrentWidget(m_originalWnd);
  60. }
  61. void MainWnd::on_tabDispositionBtn_clicked()
  62. {
  63. m_originalWnd->switchToDispositionConfig();
  64. ui->stackedWidget_UI->setCurrentWidget(m_originalWnd);
  65. }
  66. void MainWnd::on_tabDiagnosisBtn_clicked()
  67. {
  68. m_originalWnd->switchToDiagnosisConfig();
  69. ui->stackedWidget_UI->setCurrentWidget(m_originalWnd);
  70. }
  71. void MainWnd::on_tabSystemBtn_clicked()
  72. {
  73. m_originalWnd->switchToSystemConfig();
  74. ui->stackedWidget_UI->setCurrentWidget(m_originalWnd);
  75. }
  76. void MainWnd::initForm()
  77. {
  78. // 隐藏原生标题栏
  79. setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog);
  80. // 窗口背景透明
  81. setAttribute(Qt::WA_TranslucentBackground, true);
  82. QPixmap pixmap(":/images/light/logo1.png");
  83. QPixmap scaledPixmap = pixmap.scaled(90, 49, Qt::KeepAspectRatio);
  84. ui->label_logo->setPixmap(scaledPixmap);
  85. Login *login = new Login;
  86. ui->stackedWidget_UI->addWidget(login);
  87. ui->stackedWidget_UI->setCurrentIndex(ui->stackedWidget_UI->indexOf(login));
  88. //登录监听
  89. ui->label_logo->installEventFilter(this);
  90. ui->stackedWidget_UI->installEventFilter(this);
  91. //安装监听事件,点击左侧按钮图标变化
  92. ui->tabHomeBtn->installEventFilter(this);
  93. ui->tabProductionBtn->installEventFilter(this);
  94. ui->tabProgramBtn->installEventFilter(this);
  95. ui->tabMessageBtn->installEventFilter(this);
  96. ui->tabModuleBtn->installEventFilter(this);
  97. ui->tabDispositionBtn->installEventFilter(this);
  98. ui->tabDiagnosisBtn->installEventFilter(this);
  99. ui->tabSystemBtn->installEventFilter(this);
  100. ui->tabHelpBtn->installEventFilter(this);
  101. QMouseEvent* pressEvent = new QMouseEvent(QEvent::MouseButtonPress,
  102. ui->tabHomeBtn->pos(),
  103. Qt::LeftButton,
  104. Qt::LeftButton,
  105. Qt::NoModifier);
  106. QApplication::sendEvent(ui->tabHomeBtn, pressEvent);
  107. delete pressEvent;
  108. }
  109. bool MainWnd::eventFilter(QObject *obj, QEvent *event)
  110. {
  111. if (obj == this->ui->stackedWidget_UI)
  112. {
  113. onCurrentWidgetChanged();
  114. }
  115. if (obj == this->ui->label_logo)
  116. {
  117. //判断事件类型是否为鼠标事件
  118. if (event->type() == QEvent::MouseButtonPress)
  119. {
  120. //转换为鼠标事件
  121. QMouseEvent* mouseenevt = static_cast<QMouseEvent*>(event);
  122. //判断鼠标左键点击
  123. if (mouseenevt->button() == Qt::LeftButton)
  124. {
  125. Login *login = new Login;
  126. ui->stackedWidget_UI->addWidget(login);
  127. ui->stackedWidget_UI->setCurrentIndex(ui->stackedWidget_UI->indexOf(login));
  128. return true;
  129. }
  130. }
  131. }
  132. switch(event->type())
  133. {
  134. case QEvent::MouseButtonPress:
  135. {
  136. if(obj == ui->tabHomeBtn && ui->tabHomeBtn->isEnabled())
  137. {
  138. ui->tabHomeBtn->setIcon(QIcon(":/images/deep/home.png"));
  139. ui->tabHomeBtn->setChecked(true);
  140. if(ui->tabProductionBtn->isChecked() == false)
  141. {
  142. ui->tabProductionBtn->setIcon(QIcon(":/images/light/Productionn assistance.png"));
  143. }
  144. if(ui->tabProgramBtn->isChecked() == false)
  145. {
  146. ui->tabProgramBtn->setIcon(QIcon(":/images/light/Program.png"));
  147. }
  148. if(ui->tabMessageBtn->isChecked() == false)
  149. {
  150. ui->tabMessageBtn->setIcon(QIcon(":/images/light/Message.png"));
  151. }
  152. if(ui->tabModuleBtn->isChecked() == false)
  153. {
  154. ui->tabModuleBtn->setIcon(QIcon(":/images/light/Module.png"));
  155. }
  156. if(ui->tabDispositionBtn->isChecked() == false)
  157. {
  158. ui->tabDispositionBtn->setIcon(QIcon(":/images/light/Disposition.png"));
  159. }
  160. if(ui->tabDiagnosisBtn->isChecked() == false)
  161. {
  162. ui->tabDiagnosisBtn->setIcon(QIcon(":/images/light/Diagnosis.png"));
  163. }
  164. if(ui->tabSystemBtn->isChecked() == false)
  165. {
  166. ui->tabSystemBtn->setIcon(QIcon(":/images/light/System.png"));
  167. }
  168. if(ui->tabHelpBtn->isChecked() == false)
  169. {
  170. ui->tabHelpBtn->setIcon(QIcon(":/images/light/Help.png"));
  171. }
  172. }
  173. if(obj == ui->tabProductionBtn && ui->tabProductionBtn->isEnabled())
  174. {
  175. ui->tabProductionBtn->setIcon(QIcon(":/images/deep/Productionn assistance.png"));
  176. ui->tabProductionBtn->setChecked(true);
  177. if(ui->tabHomeBtn->isChecked() == false)
  178. {
  179. ui->tabHomeBtn->setIcon(QIcon(":/images/light/home.png"));
  180. }
  181. if(ui->tabProgramBtn->isChecked() == false)
  182. {
  183. ui->tabProgramBtn->setIcon(QIcon(":/images/light/Program.png"));
  184. }
  185. if(ui->tabMessageBtn->isChecked() == false)
  186. {
  187. ui->tabMessageBtn->setIcon(QIcon(":/images/light/Message.png"));
  188. }
  189. if(ui->tabModuleBtn->isChecked() == false)
  190. {
  191. ui->tabModuleBtn->setIcon(QIcon(":/images/light/Module.png"));
  192. }
  193. if(ui->tabDispositionBtn->isChecked() == false)
  194. {
  195. ui->tabDispositionBtn->setIcon(QIcon(":/images/light/Disposition.png"));
  196. }
  197. if(ui->tabDiagnosisBtn->isChecked() == false)
  198. {
  199. ui->tabDiagnosisBtn->setIcon(QIcon(":/images/light/Diagnosis.png"));
  200. }
  201. if(ui->tabSystemBtn->isChecked() == false)
  202. {
  203. ui->tabSystemBtn->setIcon(QIcon(":/images/light/System.png"));
  204. }
  205. if(ui->tabHelpBtn->isChecked() == false)
  206. {
  207. ui->tabHelpBtn->setIcon(QIcon(":/images/light/Help.png"));
  208. }
  209. }
  210. if(obj == ui->tabProgramBtn && ui->tabProgramBtn->isEnabled())
  211. {
  212. ui->tabProgramBtn->setIcon(QIcon(":/images/deep/Program.png"));
  213. ui->tabProgramBtn->setChecked(true);
  214. if(ui->tabHomeBtn->isChecked() == false)
  215. {
  216. ui->tabHomeBtn->setIcon(QIcon(":/images/light/home.png"));
  217. }
  218. if(ui->tabProductionBtn->isChecked() == false)
  219. {
  220. ui->tabProductionBtn->setIcon(QIcon(":/images/light/Productionn assistance.png"));
  221. }
  222. if(ui->tabMessageBtn->isChecked() == false)
  223. {
  224. ui->tabMessageBtn->setIcon(QIcon(":/images/light/Message.png"));
  225. }
  226. if(ui->tabModuleBtn->isChecked() == false)
  227. {
  228. ui->tabModuleBtn->setIcon(QIcon(":/images/light/Module.png"));
  229. }
  230. if(ui->tabDispositionBtn->isChecked() == false)
  231. {
  232. ui->tabDispositionBtn->setIcon(QIcon(":/images/light/Disposition.png"));
  233. }
  234. if(ui->tabDiagnosisBtn->isChecked() == false)
  235. {
  236. ui->tabDiagnosisBtn->setIcon(QIcon(":/images/light/Diagnosis.png"));
  237. }
  238. if(ui->tabSystemBtn->isChecked() == false)
  239. {
  240. ui->tabSystemBtn->setIcon(QIcon(":/images/light/System.png"));
  241. }
  242. if(ui->tabHelpBtn->isChecked() == false)
  243. {
  244. ui->tabHelpBtn->setIcon(QIcon(":/images/light/Help.png"));
  245. }
  246. }
  247. if(obj == ui->tabMessageBtn && ui->tabMessageBtn->isEnabled())
  248. {
  249. ui->tabMessageBtn->setIcon(QIcon(":/images/deep/Message.png"));
  250. ui->tabMessageBtn->setChecked(true);
  251. if(ui->tabHomeBtn->isChecked() == false)
  252. {
  253. ui->tabHomeBtn->setIcon(QIcon(":/images/light/home.png"));
  254. }
  255. if(ui->tabProductionBtn->isChecked() == false)
  256. {
  257. ui->tabProductionBtn->setIcon(QIcon(":/images/light/Productionn assistance.png"));
  258. }
  259. if(ui->tabProgramBtn->isChecked() == false)
  260. {
  261. ui->tabProgramBtn->setIcon(QIcon(":/images/light/Program.png"));
  262. }
  263. if(ui->tabModuleBtn->isChecked() == false)
  264. {
  265. ui->tabModuleBtn->setIcon(QIcon(":/images/light/Module.png"));
  266. }
  267. if(ui->tabDispositionBtn->isChecked() == false)
  268. {
  269. ui->tabDispositionBtn->setIcon(QIcon(":/images/light/Disposition.png"));
  270. }
  271. if(ui->tabDiagnosisBtn->isChecked() == false)
  272. {
  273. ui->tabDiagnosisBtn->setIcon(QIcon(":/images/light/Diagnosis.png"));
  274. }
  275. if(ui->tabSystemBtn->isChecked() == false)
  276. {
  277. ui->tabSystemBtn->setIcon(QIcon(":/images/light/System.png"));
  278. }
  279. if(ui->tabHelpBtn->isChecked() == false)
  280. {
  281. ui->tabHelpBtn->setIcon(QIcon(":/images/light/Help.png"));
  282. }
  283. }
  284. if(obj == ui->tabModuleBtn && ui->tabModuleBtn->isEnabled())
  285. {
  286. ui->tabModuleBtn->setIcon(QIcon(":/images/deep/Module.png"));
  287. ui->tabModuleBtn->setChecked(true);
  288. if(ui->tabHomeBtn->isChecked() == false)
  289. {
  290. ui->tabHomeBtn->setIcon(QIcon(":/images/light/home.png"));
  291. }
  292. if(ui->tabProductionBtn->isChecked() == false)
  293. {
  294. ui->tabProductionBtn->setIcon(QIcon(":/images/light/Productionn assistance.png"));
  295. }
  296. if(ui->tabProgramBtn->isChecked() == false)
  297. {
  298. ui->tabProgramBtn->setIcon(QIcon(":/images/light/Program.png"));
  299. }
  300. if(ui->tabMessageBtn->isChecked() == false)
  301. {
  302. ui->tabMessageBtn->setIcon(QIcon(":/images/light/Message.png"));
  303. }
  304. if(ui->tabDispositionBtn->isChecked() == false)
  305. {
  306. ui->tabDispositionBtn->setIcon(QIcon(":/images/light/Disposition.png"));
  307. }
  308. if(ui->tabDiagnosisBtn->isChecked() == false)
  309. {
  310. ui->tabDiagnosisBtn->setIcon(QIcon(":/images/light/Diagnosis.png"));
  311. }
  312. if(ui->tabSystemBtn->isChecked() == false)
  313. {
  314. ui->tabSystemBtn->setIcon(QIcon(":/images/light/System.png"));
  315. }
  316. if(ui->tabHelpBtn->isChecked() == false)
  317. {
  318. ui->tabHelpBtn->setIcon(QIcon(":/images/light/Help.png"));
  319. }
  320. }
  321. if(obj == ui->tabDispositionBtn && ui->tabDispositionBtn->isEnabled())
  322. {
  323. ui->tabDispositionBtn->setIcon(QIcon(":/images/deep/Disposition.png"));
  324. ui->tabDispositionBtn->setChecked(true);
  325. if(ui->tabHomeBtn->isChecked() == false)
  326. {
  327. ui->tabHomeBtn->setIcon(QIcon(":/images/light/home.png"));
  328. }
  329. if(ui->tabProductionBtn->isChecked() == false)
  330. {
  331. ui->tabProductionBtn->setIcon(QIcon(":/images/light/Productionn assistance.png"));
  332. }
  333. if(ui->tabProgramBtn->isChecked() == false)
  334. {
  335. ui->tabProgramBtn->setIcon(QIcon(":/images/light/Program.png"));
  336. }
  337. if(ui->tabMessageBtn->isChecked() == false)
  338. {
  339. ui->tabMessageBtn->setIcon(QIcon(":/images/light/Message.png"));
  340. }
  341. if(ui->tabModuleBtn->isChecked() == false)
  342. {
  343. ui->tabModuleBtn->setIcon(QIcon(":/images/light/Module.png"));
  344. }
  345. if(ui->tabDiagnosisBtn->isChecked() == false)
  346. {
  347. ui->tabDiagnosisBtn->setIcon(QIcon(":/images/light/Diagnosis.png"));
  348. }
  349. if(ui->tabSystemBtn->isChecked() == false)
  350. {
  351. ui->tabSystemBtn->setIcon(QIcon(":/images/light/System.png"));
  352. }
  353. if(ui->tabHelpBtn->isChecked() == false)
  354. {
  355. ui->tabHelpBtn->setIcon(QIcon(":/images/light/Help.png"));
  356. }
  357. }
  358. if(obj == ui->tabDiagnosisBtn && ui->tabDiagnosisBtn->isEnabled())
  359. {
  360. ui->tabDiagnosisBtn->setIcon(QIcon(":/images/deep/Diagnosis.png"));
  361. ui->tabDiagnosisBtn->setChecked(true);
  362. if(ui->tabHomeBtn->isChecked() == false)
  363. {
  364. ui->tabHomeBtn->setIcon(QIcon(":/images/light/home.png"));
  365. }
  366. if(ui->tabProductionBtn->isChecked() == false)
  367. {
  368. ui->tabProductionBtn->setIcon(QIcon(":/images/light/Productionn assistance.png"));
  369. }
  370. if(ui->tabProgramBtn->isChecked() == false)
  371. {
  372. ui->tabProgramBtn->setIcon(QIcon(":/images/light/Program.png"));
  373. }
  374. if(ui->tabMessageBtn->isChecked() == false)
  375. {
  376. ui->tabMessageBtn->setIcon(QIcon(":/images/light/Message.png"));
  377. }
  378. if(ui->tabModuleBtn->isChecked() == false)
  379. {
  380. ui->tabModuleBtn->setIcon(QIcon(":/images/light/Module.png"));
  381. }
  382. if(ui->tabDispositionBtn->isChecked() == false)
  383. {
  384. ui->tabDispositionBtn->setIcon(QIcon(":/images/light/Disposition.png"));
  385. }
  386. if(ui->tabSystemBtn->isChecked() == false)
  387. {
  388. ui->tabSystemBtn->setIcon(QIcon(":/images/light/System.png"));
  389. }
  390. if(ui->tabHelpBtn->isChecked() == false)
  391. {
  392. ui->tabHelpBtn->setIcon(QIcon(":/images/light/Help.png"));
  393. }
  394. }
  395. if(obj == ui->tabSystemBtn && ui->tabSystemBtn->isEnabled())
  396. {
  397. ui->tabSystemBtn->setIcon(QIcon(":/images/deep/System.png"));
  398. ui->tabSystemBtn->setChecked(true);
  399. if(ui->tabHomeBtn->isChecked() == false)
  400. {
  401. ui->tabHomeBtn->setIcon(QIcon(":/images/light/home.png"));
  402. }
  403. if(ui->tabProductionBtn->isChecked() == false)
  404. {
  405. ui->tabProductionBtn->setIcon(QIcon(":/images/light/Productionn assistance.png"));
  406. }
  407. if(ui->tabProgramBtn->isChecked() == false)
  408. {
  409. ui->tabProgramBtn->setIcon(QIcon(":/images/light/Program.png"));
  410. }
  411. if(ui->tabMessageBtn->isChecked() == false)
  412. {
  413. ui->tabMessageBtn->setIcon(QIcon(":/images/light/Message.png"));
  414. }
  415. if(ui->tabModuleBtn->isChecked() == false)
  416. {
  417. ui->tabModuleBtn->setIcon(QIcon(":/images/light/Module.png"));
  418. }
  419. if(ui->tabDispositionBtn->isChecked() == false)
  420. {
  421. ui->tabDispositionBtn->setIcon(QIcon(":/images/light/Disposition.png"));
  422. }
  423. if(ui->tabDiagnosisBtn->isChecked() == false)
  424. {
  425. ui->tabDiagnosisBtn->setIcon(QIcon(":/images/light/Diagnosis.png"));
  426. }
  427. if(ui->tabHelpBtn->isChecked() == false)
  428. {
  429. ui->tabHelpBtn->setIcon(QIcon(":/images/light/Help.png"));
  430. }
  431. }
  432. if(obj == ui->tabHelpBtn && ui->tabHelpBtn->isEnabled())
  433. {
  434. ui->tabHelpBtn->setIcon(QIcon(":/images/deep/Help.png"));
  435. ui->tabHelpBtn->setChecked(true);
  436. if(ui->tabHomeBtn->isChecked() == false)
  437. {
  438. ui->tabHomeBtn->setIcon(QIcon(":/images/light/home.png"));
  439. }
  440. if(ui->tabProductionBtn->isChecked() == false)
  441. {
  442. ui->tabProductionBtn->setIcon(QIcon(":/images/light/Productionn assistance.png"));
  443. }
  444. if(ui->tabProgramBtn->isChecked() == false)
  445. {
  446. ui->tabProgramBtn->setIcon(QIcon(":/images/light/Program.png"));
  447. }
  448. if(ui->tabMessageBtn->isChecked() == false)
  449. {
  450. ui->tabMessageBtn->setIcon(QIcon(":/images/light/Message.png"));
  451. }
  452. if(ui->tabModuleBtn->isChecked() == false)
  453. {
  454. ui->tabModuleBtn->setIcon(QIcon(":/images/light/Module.png"));
  455. }
  456. if(ui->tabDispositionBtn->isChecked() == false)
  457. {
  458. ui->tabDispositionBtn->setIcon(QIcon(":/images/light/Disposition.png"));
  459. }
  460. if(ui->tabDiagnosisBtn->isChecked() == false)
  461. {
  462. ui->tabDiagnosisBtn->setIcon(QIcon(":/images/light/Diagnosis.png"));
  463. }
  464. if(ui->tabSystemBtn->isChecked() == false)
  465. {
  466. ui->tabSystemBtn->setIcon(QIcon(":/images/light/System.png"));
  467. }
  468. }
  469. break;
  470. }
  471. case QEvent::HoverEnter:
  472. {
  473. if(obj == ui->tabHomeBtn && ui->tabHomeBtn->isEnabled())
  474. {
  475. ui->tabHomeBtn->setIcon(QIcon(":/images/deep/home.png"));
  476. }
  477. if(obj == ui->tabProductionBtn && ui->tabProductionBtn->isEnabled())
  478. {
  479. ui->tabProductionBtn->setIcon(QIcon(":/images/deep/Productionn assistance.png"));
  480. }
  481. if(obj == ui->tabProgramBtn && ui->tabProgramBtn->isEnabled())
  482. {
  483. ui->tabProgramBtn->setIcon(QIcon(":/images/deep/Program.png"));
  484. }
  485. if(obj == ui->tabMessageBtn && ui->tabMessageBtn->isEnabled())
  486. {
  487. ui->tabMessageBtn->setIcon(QIcon(":/images/deep/Message.png"));
  488. }
  489. if(obj == ui->tabModuleBtn && ui->tabModuleBtn->isEnabled())
  490. {
  491. ui->tabModuleBtn->setIcon(QIcon(":/images/deep/Module.png"));
  492. }
  493. if(obj == ui->tabDispositionBtn && ui->tabDispositionBtn->isEnabled())
  494. {
  495. ui->tabDispositionBtn->setIcon(QIcon(":/images/deep/Disposition.png"));
  496. }
  497. if(obj == ui->tabDiagnosisBtn && ui->tabDiagnosisBtn->isEnabled())
  498. {
  499. ui->tabDiagnosisBtn->setIcon(QIcon(":/images/deep/Diagnosis.png"));
  500. }
  501. if(obj == ui->tabSystemBtn && ui->tabSystemBtn->isEnabled())
  502. {
  503. ui->tabSystemBtn->setIcon(QIcon(":/images/deep/System.png"));
  504. }
  505. if(obj == ui->tabHelpBtn && ui->tabHelpBtn->isEnabled())
  506. {
  507. ui->tabHelpBtn->setIcon(QIcon(":/images/deep/Help.png"));
  508. }
  509. break;
  510. }
  511. case QEvent::HoverLeave:
  512. {
  513. if(obj == ui->tabHomeBtn && ui->tabHomeBtn->isChecked() == false)
  514. {
  515. ui->tabHomeBtn->setIcon(QIcon(":/images/light/home.png"));
  516. ui->tabHomeBtn->setChecked(false);
  517. }
  518. if(obj == ui->tabProductionBtn && ui->tabProductionBtn->isChecked() == false)
  519. {
  520. ui->tabProductionBtn->setIcon(QIcon(":/images/light/Productionn assistance.png"));
  521. ui->tabProductionBtn->setChecked(false);
  522. }
  523. if(obj == ui->tabProgramBtn && ui->tabProgramBtn->isChecked() == false)
  524. {
  525. ui->tabProgramBtn->setIcon(QIcon(":/images/light/Program.png"));
  526. ui->tabProgramBtn->setChecked(false);
  527. }
  528. if(obj == ui->tabMessageBtn && ui->tabMessageBtn->isChecked() == false)
  529. {
  530. ui->tabMessageBtn->setIcon(QIcon(":/images/light/Message.png"));
  531. ui->tabMessageBtn->setChecked(false);
  532. }
  533. if(obj == ui->tabModuleBtn && ui->tabModuleBtn->isChecked() == false)
  534. {
  535. ui->tabModuleBtn->setIcon(QIcon(":/images/light/Module.png"));
  536. ui->tabModuleBtn->setChecked(false);
  537. }
  538. if(obj == ui->tabDispositionBtn && ui->tabDispositionBtn->isChecked() == false)
  539. {
  540. ui->tabDispositionBtn->setIcon(QIcon(":/images/light/Disposition.png"));
  541. ui->tabDispositionBtn->setChecked(false);
  542. }
  543. if(obj == ui->tabDiagnosisBtn && ui->tabDiagnosisBtn->isChecked() == false)
  544. {
  545. ui->tabDiagnosisBtn->setIcon(QIcon(":/images/light/Diagnosis.png"));
  546. ui->tabDiagnosisBtn->setChecked(false);
  547. }
  548. if(obj == ui->tabSystemBtn && ui->tabSystemBtn->isChecked() == false)
  549. {
  550. ui->tabSystemBtn->setIcon(QIcon(":/images/light/System.png"));
  551. ui->tabSystemBtn->setChecked(false);
  552. }
  553. if(obj == ui->tabHelpBtn && ui->tabHelpBtn->isChecked() == false)
  554. {
  555. ui->tabHelpBtn->setIcon(QIcon(":/images/light/Help.png"));
  556. ui->tabHelpBtn->setChecked(false);
  557. }
  558. }
  559. default:
  560. break;
  561. }
  562. return QWidget::eventFilter(obj, event);
  563. }
  564. void MainWnd::onCurrentWidgetChanged() {
  565. QWidget *currentWidget = ui->stackedWidget_UI->currentWidget();
  566. if (currentWidget) {
  567. QString currentWidgetName = currentWidget->objectName();
  568. if (currentWidgetName == "Login") {
  569. QString styleSheet = "QToolButton:disabled { color: #808080; background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #F8FBFF, stop: 1 #E7ECF3); }"; // 设置禁用状态下的文本颜色为灰色
  570. ui->tabHomeBtn->setDisabled(true);
  571. ui->tabHomeBtn->setIcon(QIcon(":/images/light/home.png"));
  572. ui->tabHomeBtn->setStyleSheet(styleSheet);
  573. ui->tabProductionBtn->setDisabled(true);
  574. ui->tabProductionBtn->setStyleSheet(styleSheet);
  575. ui->tabProgramBtn->setDisabled(true);
  576. ui->tabProgramBtn->setStyleSheet(styleSheet);
  577. ui->tabMessageBtn->setDisabled(true);
  578. ui->tabMessageBtn->setStyleSheet(styleSheet);
  579. ui->tabModuleBtn->setDisabled(true);
  580. ui->tabModuleBtn->setStyleSheet(styleSheet);
  581. ui->tabDispositionBtn->setDisabled(true);
  582. ui->tabDispositionBtn->setStyleSheet(styleSheet);
  583. ui->tabDiagnosisBtn->setDisabled(true);
  584. ui->tabDiagnosisBtn->setStyleSheet(styleSheet);
  585. ui->tabSystemBtn->setDisabled(true);
  586. ui->tabSystemBtn->setStyleSheet(styleSheet);
  587. ui->tabHelpBtn->setDisabled(true);
  588. ui->tabHelpBtn->setStyleSheet(styleSheet);
  589. } else {
  590. ui->tabHomeBtn->setDisabled(false);
  591. if (!initialIconSet) {
  592. ui->tabHomeBtn->setIcon(QIcon(":/images/deep/home.png"));
  593. initialIconSet = true;
  594. }
  595. ui->tabProductionBtn->setDisabled(false);
  596. ui->tabProgramBtn->setDisabled(false);
  597. ui->tabMessageBtn->setDisabled(false);
  598. ui->tabModuleBtn->setDisabled(false);
  599. ui->tabDispositionBtn->setDisabled(false);
  600. ui->tabDiagnosisBtn->setDisabled(false);
  601. ui->tabSystemBtn->setDisabled(false);
  602. ui->tabHelpBtn->setDisabled(false);
  603. }
  604. }
  605. }
  606. void MainWnd::on_pushButton_clicked()
  607. {
  608. qApp->quit();
  609. }