Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions reader/browser/SheetBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2121,11 +2121,14 @@ void SheetBrowser::hideFindWidget()
qCDebug(appLog) << "hideFindWidget";
if (!m_findWidget.isNull()) {
m_findWidget->hide();
m_findWidget->deleteLater();
m_findWidget = nullptr;
}
}

bool SheetBrowser::isFindWidgetVisible() const
{
return !m_findWidget.isNull() && m_findWidget->isVisible();
}

void SheetBrowser::handleSearchStart()
{
qCDebug(appLog) << "SheetBrowser::handleSearchStart() - Handling search start";
Expand Down
8 changes: 7 additions & 1 deletion reader/browser/SheetBrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,16 @@ class SheetBrowser : public Dtk::Widget::DGraphicsView

/**
* @brief hideFindWidget
* 隐藏并销毁搜索框,切换标签页时调用,防止搜索串档
* 隐藏搜索框(不销毁),切换标签页时调用,防止搜索串档
*/
void hideFindWidget();

/**
* @brief isFindWidgetVisible
* 返回搜索框是否可见
*/
bool isFindWidgetVisible() const;

/**
* @brief jumpToNextSearchResult
* 跳到下一个搜索条目中
Expand Down
4 changes: 2 additions & 2 deletions reader/uiframe/CentralDocPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,9 @@ void CentralDocPage::onTabChanged(DocSheet *sheet)
// 离开当前 sheet 前,保存其阅读状态
QPointer<DocSheet> prevSheet = qobject_cast<DocSheet *>(m_stackedLayout->currentWidget());
if (prevSheet && prevSheet != sheet && prevSheet->opened()) {
// 关闭前一个 sheet 的搜索框,防止切换标签后搜索串档
prevSheet->closeFindWidget();
// 先保存前一个 sheet 的阅读状态(含搜索框可见性),再关闭搜索框
prevSheet->saveCurrentViewState();
prevSheet->closeFindWidget();
}

m_stackedLayout->setCurrentWidget(sheet);
Expand Down
7 changes: 7 additions & 0 deletions reader/uiframe/DocSheet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1911,6 +1911,8 @@ void DocSheet::saveCurrentViewState()
// 保存滚动位置
if (m_browser) {
m_operation.scrollPosition = m_browser->getScrollPosition();
// 保存搜索框可见性
m_operation.findWidgetVisible = m_browser->isFindWidgetVisible();
}
// 保存侧边栏宽度和展开状态
if (m_sidebar && m_sidebar->isVisible()) {
Expand Down Expand Up @@ -1948,6 +1950,11 @@ void DocSheet::restoreSavedViewState()
beginRestoreGuard(false);
}
}

// 恢复搜索框可见性
if (m_browser && m_operation.findWidgetVisible) {
m_browser->handlePrepareSearch();
}
}

void DocSheet::beginRestoreGuard(bool notifyTip)
Expand Down
2 changes: 2 additions & 0 deletions reader/uiframe/DocSheet.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ struct SheetOperation {
bool sidebarWidthChanged = false;
// 滚动位置(纵向偏移比例 0.0~1.0)
float scrollPosition = 0.0f;
// 搜索框可见性
bool findWidgetVisible = false;
// 目录树展开节点标题路径列表(如 ["1.概述", "1.概述/1.1 背景"])
QStringList expandedSections;
};
Expand Down
Loading