diff --git a/reader/uiframe/Central.cpp b/reader/uiframe/Central.cpp index 98984f159..5d3d10944 100644 --- a/reader/uiframe/Central.cpp +++ b/reader/uiframe/Central.cpp @@ -74,14 +74,13 @@ Central::Central(QWidget *parent) keyList.append(QKeySequence::Print); keyList.append(QKeySequence::Save); keyList.append(QKeySequence::Copy); - // 屏蔽右侧区域的切页快捷键,使用默认的滚动效果 - // when using slide mode, left & right keys are needed. modify by lz,at 2022.4.18 - keyList.append(QKeySequence(Qt::Key_Left)); - keyList.append(QKeySequence(Qt::Key_Right)); - - keyList.append(QKeySequence(Qt::Key_Up)); - keyList.append(QKeySequence(Qt::Key_Down)); - keyList.append(QKeySequence(Qt::Key_Space)); + //使用下面5个快捷键会屏蔽主界面对应的功能,故注释 + //keyList.append(QKeySequence(Qt::Key_Left)); + //keyList.append(QKeySequence(Qt::Key_Right)); + + //keyList.append(QKeySequence(Qt::Key_Up)); + //keyList.append(QKeySequence(Qt::Key_Down)); + //keyList.append(QKeySequence(Qt::Key_Space)); keyList.append(QKeySequence(Qt::Key_Escape)); keyList.append(QKeySequence(Qt::Key_F5)); keyList.append(QKeySequence(Qt::Key_F11)); diff --git a/reader/uiframe/CentralDocPage.cpp b/reader/uiframe/CentralDocPage.cpp index cf553f22a..3697d3083 100644 --- a/reader/uiframe/CentralDocPage.cpp +++ b/reader/uiframe/CentralDocPage.cpp @@ -731,7 +731,6 @@ void CentralDocPage::handleShortcut(const QString &s) } if (m_slideWidget) { - m_slideWidget->handleKeyPressEvent(s); return; } diff --git a/reader/widgets/SlideWidget.cpp b/reader/widgets/SlideWidget.cpp index 7bfee2e54..0603dffc6 100644 --- a/reader/widgets/SlideWidget.cpp +++ b/reader/widgets/SlideWidget.cpp @@ -9,6 +9,7 @@ #include "SlidePlayWidget.h" #include "Application.h" #include "ReaderImageThreadPoolManager.h" +#include "Utils.h" #include "ddlog.h" #include @@ -34,6 +35,7 @@ SlideWidget::SlideWidget(DocSheet *docsheet) initControl(); initImageControl(); show(); + QTimer::singleShot(0, this, [this](){this->setFocus();}); qCDebug(appLog) << "SlideWidget initialized"; } @@ -423,6 +425,14 @@ void SlideWidget::handleKeyPressEvent(const QString &sKey) // qCDebug(appLog) << "Handling key press event end"; } +void SlideWidget::keyPressEvent(QKeyEvent *event) +{ + QString key = Utils::getKeyshortcut(event); + handleKeyPressEvent(key); + + DWidget::keyPressEvent(event); +} + void SlideWidget::onFetchImage(int index) { qCDebug(appLog) << "Fetching image for page:" << index; diff --git a/reader/widgets/SlideWidget.h b/reader/widgets/SlideWidget.h index b3fc73ce8..cc283ff3e 100644 --- a/reader/widgets/SlideWidget.h +++ b/reader/widgets/SlideWidget.h @@ -36,13 +36,6 @@ public slots: */ void setWidgetState(bool full); - /** - * @brief handleKeyPressEvent - * 按键处理事件 - * @param sKey - */ - void handleKeyPressEvent(const QString &sKey); - /** * @brief onImageAniFinished * 单页幻灯片播放结束 @@ -56,6 +49,13 @@ public slots: */ void initControl(); + /** + * @brief handleKeyPressEvent + * 按键处理事件 + * @param sKey + */ + void handleKeyPressEvent(const QString &sKey); + /** * @brief initImageControl * 初始化图片数据 @@ -160,6 +160,8 @@ private slots: void wheelEvent(QWheelEvent *event) override; + void keyPressEvent(QKeyEvent *event) override; + private: int m_curPageIndex = 0; bool m_canRestart = false;