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
15 changes: 7 additions & 8 deletions reader/uiframe/Central.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,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));
Expand Down
1 change: 0 additions & 1 deletion reader/uiframe/CentralDocPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,6 @@ void CentralDocPage::handleShortcut(const QString &s)
}

if (m_slideWidget) {
m_slideWidget->handleKeyPressEvent(s);
return;
}

Expand Down
10 changes: 10 additions & 0 deletions reader/widgets/SlideWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
#include "MainWindow.h"
#include "DocSheet.h"
#include "SlidePlayWidget.h"
#include "Application.h"

Check warning on line 10 in reader/widgets/SlideWidget.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "Application.h" not found.
#include "ReaderImageThreadPoolManager.h"

Check warning on line 11 in reader/widgets/SlideWidget.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "ReaderImageThreadPoolManager.h" not found.
#include "Utils.h"

Check warning on line 12 in reader/widgets/SlideWidget.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "Utils.h" not found.

#include <DGuiApplicationHelper>

Check warning on line 14 in reader/widgets/SlideWidget.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DGuiApplicationHelper> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <DApplication>

Check warning on line 15 in reader/widgets/SlideWidget.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DApplication> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <DTitlebar>

#include <QDesktopWidget>
Expand All @@ -26,6 +27,7 @@
initControl();
initImageControl();
show();
QTimer::singleShot(0, this, [this](){this->setFocus();});
}

SlideWidget::~SlideWidget()
Expand Down Expand Up @@ -345,6 +347,14 @@
}
}

void SlideWidget::keyPressEvent(QKeyEvent *event)
{
QString key = Utils::getKeyshortcut(event);
handleKeyPressEvent(key);

DWidget::keyPressEvent(event);
}

void SlideWidget::onFetchImage(int index)
{
const QPixmap &pix = ReaderImageThreadPoolManager::getInstance()->getImageForDocSheet(m_docSheet, index);
Expand Down
16 changes: 9 additions & 7 deletions reader/widgets/SlideWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@ public slots:
*/
void setWidgetState(bool full);

/**
* @brief handleKeyPressEvent
* 按键处理事件
* @param sKey
*/
void handleKeyPressEvent(const QString &sKey);

/**
* @brief onImageAniFinished
* 单页幻灯片播放结束
Expand All @@ -56,6 +49,13 @@ public slots:
*/
void initControl();

/**
* @brief handleKeyPressEvent
* 按键处理事件
* @param sKey
*/
void handleKeyPressEvent(const QString &sKey);

/**
* @brief initImageControl
* 初始化图片数据
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions tests/uiframe/ut_centraldocpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,7 @@ TEST_F(TestCentralDocPage, UT_CentralDocPage_handleShortcut_004)
{
Stub s;
s.set(ADDR(ReaderImageThreadPoolManager, addgetDocImageTask), addgetDocImageTask_stub);
s.set(ADDR(SlideWidget, handleKeyPressEvent), handleKeyPressEvent_stub);
s.set(ADDR(CentralDocPage, openSlide), openSlide_stub);

QString strPath = UTSOURCEDIR;
strPath += "/files/normal.pdf";
Expand All @@ -1103,7 +1103,7 @@ TEST_F(TestCentralDocPage, UT_CentralDocPage_handleShortcut_004)
g_funcName.clear();
m_tester->handleShortcut(Dr::key_f5);

EXPECT_TRUE(g_funcName == "handleKeyPressEvent_stub");
EXPECT_TRUE(g_funcName != "openSlide_stub");

delete sheet;
delete slide;
Expand All @@ -1117,7 +1117,6 @@ TEST_F(TestCentralDocPage, UT_CentralDocPage_handleShortcut_005)
s.set(ADDR(CentralDocPage, handleBlockShutdown), handleBlockShutdown_stub);
s.set(ADDR(CentralDocPage, openSlide), openSlide_stub);
s.set(ADDR(CentralDocPage, openMagnifer), openMagnifer_stub);
s.set(ADDR(SlideWidget, handleKeyPressEvent), handleKeyPressEvent_stub);

g_funcName.clear();
m_tester->handleShortcut(Dr::key_ctrl_s);
Expand Down
11 changes: 7 additions & 4 deletions tests/widgets/ut_slidewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
#include <gtest/gtest.h>
#include <QTimer>
#include <QTest>
#include <QPropertyAnimation>

Check warning on line 19 in tests/widgets/ut_slidewidget.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QPropertyAnimation> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDBusMessage>

Check warning on line 20 in tests/widgets/ut_slidewidget.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusMessage> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDBusInterface>

Check warning on line 21 in tests/widgets/ut_slidewidget.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusInterface> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QKeyEvent>

Check warning on line 22 in tests/widgets/ut_slidewidget.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QKeyEvent> not found. Please note: Cppcheck does not need standard library headers to get proper results.

namespace {
void ReaderImageThreadPoolManager_addgetDocImageTask_stub(const ReaderImageParam_t &);
Expand Down Expand Up @@ -275,11 +276,14 @@
stub.set(ADDR(SlideWidget, onPreBtnClicked), onPreBtnClicked_stub);
stub.set(ADDR(SlideWidget, onNextBtnClicked), onNextBtnClicked_stub);

m_tester->handleKeyPressEvent(Dr::key_space);
QKeyEvent spaceEvent(QEvent::KeyPress, Qt::Key_Space, Qt::NoModifier);
m_tester->keyPressEvent(&spaceEvent);
EXPECT_TRUE(g_funcname == "setPlayStatus_stub");
m_tester->handleKeyPressEvent(Dr::key_left);
QKeyEvent leftEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier);
m_tester->keyPressEvent(&leftEvent);
EXPECT_TRUE(g_funcname == "onPreBtnClicked_stub");
m_tester->handleKeyPressEvent(Dr::key_right);
QKeyEvent rightEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier);
m_tester->keyPressEvent(&rightEvent);
EXPECT_TRUE(g_funcname == "onNextBtnClicked_stub");
}

Expand All @@ -300,4 +304,3 @@
m_tester->onUpdatePageImage(0);
EXPECT_TRUE(g_funcname == "0");
}

Loading