MainWnd.cpp 23 KB

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