综合平台编程器项目的远程存储
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

57 lines
1.2 KiB

  1. #include "runtime_monitor_window.h"
  2. #include "ui_runtime_monitor_window.h"
  3. #include <QCloseEvent>
  4. #include <QWidget>
  5. RuntimeMonitorWindow::RuntimeMonitorWindow(QWidget *parent)
  6. : QMainWindow(
  7. parent,
  8. Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint),
  9. ui_(std::make_unique<Ui::RuntimeMonitorWindow>())
  10. {
  11. ui_->setupUi(this);
  12. }
  13. RuntimeMonitorWindow::~RuntimeMonitorWindow() = default;
  14. void RuntimeMonitorWindow::setMonitorWidget(QWidget &widget)
  15. {
  16. widget.setParent(ui_->centralWidget);
  17. ui_->runtimeMonitorWindowLayout->addWidget(&widget);
  18. }
  19. void RuntimeMonitorWindow::showForRuntime()
  20. {
  21. application_exit_ = false;
  22. runtime_active_ = true;
  23. showMaximized();
  24. raise();
  25. activateWindow();
  26. }
  27. void RuntimeMonitorWindow::hideForEditing()
  28. {
  29. runtime_active_ = false;
  30. hide();
  31. }
  32. void RuntimeMonitorWindow::closeForApplicationExit()
  33. {
  34. application_exit_ = true;
  35. runtime_active_ = false;
  36. close();
  37. }
  38. void RuntimeMonitorWindow::closeEvent(QCloseEvent *event)
  39. {
  40. // 运行期间禁止通过系统关闭路径离开运行界面,只允许应用退出时关闭
  41. if (runtime_active_ && !application_exit_)
  42. {
  43. event->ignore();
  44. return;
  45. }
  46. QMainWindow::closeEvent(event);
  47. }