添加模型分割
This commit is contained in:
32
client/gui/widgets/LongPressSwitchToolButton.h
Normal file
32
client/gui/widgets/LongPressSwitchToolButton.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include <QToolButton>
|
||||
|
||||
class QMouseEvent;
|
||||
class QTimer;
|
||||
|
||||
/**
|
||||
* 可复用的工具栏按钮:短按行为与普通 QToolButton 一致;
|
||||
* 左键按住超过设定时间(默认 450ms)且仍未松开时发出 longPressTriggered(),
|
||||
* 用于在「同一工具钮」上切换子模式(类似 Photoshop 长按切换同类工具)。
|
||||
*/
|
||||
class LongPressSwitchToolButton final : public QToolButton {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LongPressSwitchToolButton(QWidget* parent = nullptr);
|
||||
|
||||
void setLongPressInterval(int ms);
|
||||
int longPressInterval() const { return m_intervalMs; }
|
||||
|
||||
signals:
|
||||
void longPressTriggered();
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent* event) override;
|
||||
void mouseReleaseEvent(QMouseEvent* event) override;
|
||||
|
||||
private:
|
||||
QTimer* m_timer = nullptr;
|
||||
int m_intervalMs = 450;
|
||||
bool m_longPressEmittedForThisPress = false;
|
||||
};
|
||||
Reference in New Issue
Block a user