From 3ec78f4c3616a4858500a1cab0e54e32ed44760b Mon Sep 17 00:00:00 2001 From: goodl3000 <15722463+goodl3000@user.noreply.gitee.com> Date: Wed, 16 Apr 2025 13:33:06 +0000 Subject: [PATCH] !1 fix popup windows * fix popup windows --- src/widgets/attachmentpopup.cpp | 13 +++++++++++-- src/widgets/outlinepopup.cpp | 13 ++++++++----- src/widgets/tagpopup.cpp | 10 ++++++++-- src/widgets/wordcountpopup.cpp | 11 ++++++----- 4 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/widgets/attachmentpopup.cpp b/src/widgets/attachmentpopup.cpp index 4ee7bc6b..edcc15a8 100644 --- a/src/widgets/attachmentpopup.cpp +++ b/src/widgets/attachmentpopup.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include "propertydefs.h" @@ -46,7 +47,8 @@ AttachmentPopup::AttachmentPopup(QToolButton *p_btn, QWidget *p_parent) void AttachmentPopup::setupUI() { - auto mainLayout = new QVBoxLayout(this); + QWidget *widget = new QWidget{}; + auto mainLayout = new QVBoxLayout(widget); const auto &themeMgr = VNoteX::getInst().getThemeMgr(); @@ -202,7 +204,14 @@ void AttachmentPopup::setupUI() }); mainLayout->addWidget(m_viewer); - setMinimumSize(320, 384); + widget->setMinimumSize(320, 384); + + + auto act = new QWidgetAction(this); + // @act will own @p_widget. + act->setDefaultWidget(widget); + addAction(act); + } QToolButton *AttachmentPopup::createButton() diff --git a/src/widgets/outlinepopup.cpp b/src/widgets/outlinepopup.cpp index 12ffd68a..31fedbf0 100644 --- a/src/widgets/outlinepopup.cpp +++ b/src/widgets/outlinepopup.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -23,13 +24,15 @@ OutlinePopup::OutlinePopup(QToolButton *p_btn, QWidget *p_parent) void OutlinePopup::setupUI() { - auto mainLayout = new QVBoxLayout(this); - WidgetUtils::setContentsMargins(mainLayout); - m_viewer = new OutlineViewer(tr("Outline"), this); - mainLayout->addWidget(m_viewer); + m_viewer->setMinimumSize(320, 384); + + auto act = new QWidgetAction(this); + // @act will own @p_widget. + act->setDefaultWidget(m_viewer); + addAction(act); + - setMinimumSize(320, 384); } void OutlinePopup::setOutlineProvider(const QSharedPointer &p_provider) diff --git a/src/widgets/tagpopup.cpp b/src/widgets/tagpopup.cpp index 3c89f364..89d25817 100644 --- a/src/widgets/tagpopup.cpp +++ b/src/widgets/tagpopup.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -30,9 +31,14 @@ TagPopup::TagPopup(QToolButton *p_btn, QWidget *p_parent) void TagPopup::setupUI() { m_tagViewer = new TagViewer(true, this); - setCentralWidget(m_tagViewer); + //setCentralWidget(m_tagViewer); - setMinimumSize(256, 320); + m_tagViewer->setMinimumSize(256, 320); + + auto act = new QWidgetAction(this); + // @act will own @p_widget. + act->setDefaultWidget(m_tagViewer); + addAction(act); } void TagPopup::setBuffer(Buffer *p_buffer) diff --git a/src/widgets/wordcountpopup.cpp b/src/widgets/wordcountpopup.cpp index 1e075daa..e9d0b7b5 100644 --- a/src/widgets/wordcountpopup.cpp +++ b/src/widgets/wordcountpopup.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include @@ -70,11 +71,11 @@ void WordCountPopup::updateCount(const ViewWindow::WordCountInfo &p_info) void WordCountPopup::setupUI() { - QWidget *mainWidget = new QWidget(this); - setCentralWidget(mainWidget); + m_panel = new WordCountPanel(this); - auto mainLayout = new QVBoxLayout(mainWidget); - m_panel = new WordCountPanel(mainWidget); - mainLayout->addWidget(m_panel); + auto act = new QWidgetAction(this); + // @act will own @p_widget. + act->setDefaultWidget(m_panel); + addAction(act); }