소스 검색

fix: 限制运行监控窗口系统关闭路径

main
suyu 4 주 전
부모
커밋
ab5085e42b
4개의 변경된 파일21개의 추가작업 그리고 19개의 파일을 삭제
  1. +4
    -3
      app/src/ui/runtime_monitor_window.cpp
  2. +1
    -5
      app/src/ui/runtime_monitor_window.h
  3. +0
    -9
      app/src/ui/runtime_panel_controller.cpp
  4. +16
    -2
      app/tests/main_window_tests.cpp

+ 4
- 3
app/src/ui/runtime_monitor_window.cpp 파일 보기

@@ -6,7 +6,9 @@
#include <QWidget>

RuntimeMonitorWindow::RuntimeMonitorWindow(QWidget *parent)
: QMainWindow(parent, Qt::Window),
: QMainWindow(
parent,
Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint),
ui_(std::make_unique<Ui::RuntimeMonitorWindow>())
{
ui_->setupUi(this);
@@ -44,10 +46,9 @@ void RuntimeMonitorWindow::closeForApplicationExit()

void RuntimeMonitorWindow::closeEvent(QCloseEvent *event)
{
// 运行期间关闭按钮等价于请求返回编辑态,应用退出时才真正放行关闭
// 运行期间禁止通过系统关闭路径离开运行界面,只允许应用退出时关闭
if (runtime_active_ && !application_exit_)
{
emit exitRequested();
event->ignore();
return;
}


+ 1
- 5
app/src/ui/runtime_monitor_window.h 파일 보기

@@ -37,12 +37,8 @@ public:
/** 应用退出时允许真正关闭窗口 */
void closeForApplicationExit();

signals:
/** 用户点击窗口关闭按钮后请求退出运行态 */
void exitRequested();

protected:
/** 根据当前生命周期决定关闭是隐藏还是销毁窗口 */
/** 仅在应用退出时放行窗口关闭事件 */
void closeEvent(QCloseEvent *event) override;

private:


+ 0
- 9
app/src/ui/runtime_panel_controller.cpp 파일 보기

@@ -98,15 +98,6 @@ void RuntimePanelController::configure()
runtime_exit_requester_();
}
});
QObject::connect(runtime_monitor_window_.get(),
&RuntimeMonitorWindow::exitRequested,
&parent_, [this]
{
if (runtime_exit_requester_)
{
runtime_exit_requester_();
}
});
QObject::connect(runtime_monitor_widget_->freeMonitorWidget(),
&FreeMonitorWidget::monitorAddressesChanged,
&parent_, [this]


+ 16
- 2
app/tests/main_window_tests.cpp 파일 보기

@@ -2031,12 +2031,26 @@ void testRuntimeMonitorWindowLifecycle()
require(runtime_window->isVisible() && runtime_window->isMaximized()
&& runtime_hmi->scene()->items().size() == 4,
"a later runtime session must reopen and refresh the monitor window");

const Qt::WindowFlags runtime_window_flags = runtime_window->windowFlags();
require(!(runtime_window_flags & Qt::WindowMinimizeButtonHint)
&& !(runtime_window_flags & Qt::WindowMaximizeButtonHint)
&& !(runtime_window_flags & Qt::WindowCloseButtonHint),
"runtime monitor must not expose native window control buttons");

runtime_window->close();
QApplication::processEvents();
require(mode_service.mode() == ApplicationMode::OfflineRunning,
"closing the runtime monitor window must not leave offline running mode");
require(runtime_window->isVisible(),
"closing the runtime monitor window must not hide the runtime surface");

requiredChild<QToolButton>(window, "exitRuntimeButton")->click();
QApplication::processEvents();
require(mode_service.mode() == ApplicationMode::Editing,
"closing the runtime monitor window must request editing mode");
"the runtime monitor exit button must be the editing transition");
require(!runtime_window->isVisible(),
"closing the runtime monitor window must leave no visible runtime surface");
"the runtime monitor exit button must hide the runtime surface");
}

void testApplicationExitClosesRuntimeMonitorWindow()


불러오는 중...
취소
저장