From 448cdf42edabb6675ddb38c7c67c1a62a12a0af2 Mon Sep 17 00:00:00 2001 From: ZhangTingan Date: Wed, 17 Dec 2025 17:26:37 +0800 Subject: [PATCH] Fix: Add file type check for highlight action to match remove highlight behavior Log: as title Bug: https://pms.uniontech.com/bug-view-343677.html --- reader/browser/BrowserMenu.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/reader/browser/BrowserMenu.cpp b/reader/browser/BrowserMenu.cpp index a28d916f..17fd66c5 100644 --- a/reader/browser/BrowserMenu.cpp +++ b/reader/browser/BrowserMenu.cpp @@ -57,15 +57,17 @@ void BrowserMenu::initActions(DocSheet *sheet, int index, SheetMenuType_e type, } this->addSeparator(); - QAction *highAct = createAction(tr("Highlight"), type != DOC_MENU_SELECT_TEXT ? "ChangeAnnotationColor" : "AddTextHighlight"); - if (type == DOC_MENU_ANNO_HIGHLIGHT) { - qCDebug(appLog) << "BrowserMenu::initActions() - Disabling highlight action for annotation highlight"; - highAct->setDisabled(true); - } + if (sheet->fileType() == Dr::FileType::PDF || sheet->fileType() == Dr::FileType::DOCX) { + QAction *highAct = createAction(tr("Highlight"), type != DOC_MENU_SELECT_TEXT ? "ChangeAnnotationColor" : "AddTextHighlight"); + if (type == DOC_MENU_ANNO_HIGHLIGHT) { + qCDebug(appLog) << "BrowserMenu::initActions() - Disabling highlight action for annotation highlight"; + highAct->setDisabled(true); + } - m_pColorWidgetAction = new ColorWidgetAction(this); - connect(m_pColorWidgetAction, SIGNAL(sigBtnGroupClicked()), this, SLOT(onSetHighLight())); - this->addAction(m_pColorWidgetAction); + m_pColorWidgetAction = new ColorWidgetAction(this); + connect(m_pColorWidgetAction, SIGNAL(sigBtnGroupClicked()), this, SLOT(onSetHighLight())); + this->addAction(m_pColorWidgetAction); + } if (sheet->fileType() == Dr::FileType::PDF || sheet->fileType() == Dr::FileType::DOCX) { qCDebug(appLog) << "BrowserMenu::initActions() - Adding PDF/DOCX highlight actions";