1 Star 0 Fork 0

小喻同学i/TouchTest

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
navigationmenu.h 2.17 KB
一键复制 编辑 原始数据 按行查看 历史
yuxj 提交于 2024-09-10 18:57 . 更新按键短按 + 长按的交互逻辑
#ifndef NAVIGATIONMENU_H
#define NAVIGATIONMENU_H
#include <QWidget>
#include <QFont>
#include <QPen>
#include <QPropertyAnimation>
#include "uicommondef.h"
#include "ikeyenbale.h"
class NavigationMenu : public QWidget, public IKeyEnable
{
Q_OBJECT
public:
Q_PROPERTY(int textOffset READ textOffset WRITE setTextOffset)
explicit NavigationMenu(QWidget *parent = nullptr);
~NavigationMenu();
void setMaxDisplaNum(int maxDisplayNum);
void setSelectIndex(int index);
int getSelectIndex() const;
MenuItemNode_S* getSelectItem();
void setNavigationInfo(const QList<MenuItemNode_S*>& lst, int selectIndex = 0);
void turnUpEvent();
void turnDownEvent();
virtual void eventTurnLeft() override;
virtual void eventTurnRight() override;
virtual void eventShortPress() override;
virtual void eventLongPress() override;
int textOffset() const;
void setTextOffset(int rect);
signals:
void sglSelectItem(MenuItemNode_S* item);
void sglExit();
private:
void calcTextDuration();
void drawItemText(QPainter* painter, MenuItemNode_S* item, QPoint basePt);
// QWidget interface
protected:
virtual void paintEvent(QPaintEvent *event) override;
virtual void mousePressEvent(QMouseEvent *event) override;
virtual void mouseReleaseEvent(QMouseEvent *event) override;
virtual void mouseMoveEvent(QMouseEvent *event) override;
private:
QPoint m_mouseStartPos;
qint64 m_pressTimeStamp = -1;
QRect m_touchRect = QRect();
private:
MenuItemNode_S* nullItem = nullptr;
int m_selectIndex = -1;
QSize m_normalSize = QSize(46, 46);
QSize m_selectSize = QSize(104, 104);
QList<MenuItemNode_S*> m_itemInfoLst;
QList<MenuItemNode_S*> m_showInfoLst;
int m_endPadding = 16;
int m_spacing = 8;
int m_iconSetp = 8;
int m_maxDisplayNum = 5; //最大显示数量
int m_fixIndex = -1; //上方固定数量
private:
QFont m_textFont;
QFont m_valueFont;
QPen m_textPen;
int m_textOffset = 0; //文本动画左侧偏移量
QPropertyAnimation* m_textAnimation = nullptr;
};
#endif // NAVIGATIONMENU_H
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/oweni/touch-test.git
git@gitee.com:oweni/touch-test.git
oweni
touch-test
TouchTest
master

搜索帮助