From 2976ca6b21750c110a48d166202c3fdf7a0b89f2 Mon Sep 17 00:00:00 2001 From: liuwenhuan Date: Mon, 9 Nov 2026 23:18:03 +0800 Subject: [PATCH] fix: create the filter preview buttons inside their scroll area MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. takePhotoSettingAreaWidget::initButtons() created every filter preview button without a parent and called show()/setVisible(true) before adding it to the scroll layout. On X11 each call mapped a short-lived translucent top-level window while the main window was being built. 2. The first of these windows made Qt end the application's startup notification before the main window was mapped, so the window manager could not place the main window on the screen the camera was launched from (multi-screen: it always opened on the primary screen). 3. The buttons are now created with m_scrollAreaWidget as parent and are shown with it; show()/setVisible(true) are removed. Visibility in the layout does not change: a child that was not explicitly hidden is shown with its parent. Log: The camera window opens on the screen it was launched from. Influence: 1. Launch the camera from the dock or launcher on a second screen: the window opens on that screen. 2. Filter list: open and close it, select filters; previews show as before. fix: 滤镜预览按钮直接创建在滚动区域内 1. takePhotoSettingAreaWidget::initButtons() 创建滤镜预览按钮时没有父控件, 并在加入滚动布局之前调用 show()/setVisible(true)。X11 下每次调用都会在主 窗口构建期间映射一个短暂存在的透明顶层窗口。 2. 第一个这样的窗口让 Qt 在主窗口映射之前就结束了应用的启动通知,窗口管理 器因此无法把主窗口放到启动它的屏幕上(多屏时总是出现在主屏)。 3. 现在按钮以 m_scrollAreaWidget 为父控件创建,随父控件显示,去掉了 show()/setVisible(true)。按钮在布局中的可见性不变:未被显式隐藏的子控件会 随父控件一起显示。 Log: 相机窗口出现在启动它的屏幕上。 Influence: 1. 在第二块屏幕上从任务栏或启动器启动相机:窗口出现在该屏幕。 2. 滤镜列表:展开、收起、选择滤镜,预览与之前一致。 --- src/src/takephotosettingareawidget.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/src/takephotosettingareawidget.cpp b/src/src/takephotosettingareawidget.cpp index e6d425fb..0df625d3 100644 --- a/src/src/takephotosettingareawidget.cpp +++ b/src/src/takephotosettingareawidget.cpp @@ -182,11 +182,9 @@ void takePhotoSettingAreaWidget::initButtons() filterPreviewButton* filterBtn = nullptr; for (int i = 0; i < efilterType::filter_Count; i++) { - filterBtn = new filterPreviewButton(nullptr, static_cast(i)); + filterBtn = new filterPreviewButton(m_scrollAreaWidget, static_cast(i)); filterBtn->setToolTip(filterPreviewButton::filterName(static_cast(i))); filterBtn->setFocusPolicy(Qt::NoFocus); - filterBtn->show(); - filterBtn->setVisible(true); scrollLayout->addWidget(filterBtn); m_filterPreviewBtnList.push_back(filterBtn); }