|
- #include "runtime_monitor_window.h"
-
- #include "ui_runtime_monitor_window.h"
-
- #include <QCloseEvent>
- #include <QWidget>
-
- RuntimeMonitorWindow::RuntimeMonitorWindow(QWidget *parent)
- : QMainWindow(
- parent,
- Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint),
- ui_(std::make_unique<Ui::RuntimeMonitorWindow>())
- {
- ui_->setupUi(this);
- }
-
- RuntimeMonitorWindow::~RuntimeMonitorWindow() = default;
-
- void RuntimeMonitorWindow::setMonitorWidget(QWidget &widget)
- {
- widget.setParent(ui_->centralWidget);
- ui_->runtimeMonitorWindowLayout->addWidget(&widget);
- }
-
- void RuntimeMonitorWindow::showForRuntime()
- {
- application_exit_ = false;
- runtime_active_ = true;
- showMaximized();
- raise();
- activateWindow();
- }
-
- void RuntimeMonitorWindow::hideForEditing()
- {
- runtime_active_ = false;
- hide();
- }
-
- void RuntimeMonitorWindow::closeForApplicationExit()
- {
- application_exit_ = true;
- runtime_active_ = false;
- close();
- }
-
- void RuntimeMonitorWindow::closeEvent(QCloseEvent *event)
- {
- // 运行期间禁止通过系统关闭路径离开运行界面,只允许应用退出时关闭
- if (runtime_active_ && !application_exit_)
- {
- event->ignore();
- return;
- }
- QMainWindow::closeEvent(event);
- }
|