DiagramDesigner/include/enhancedToolBar.h

46 lines
1.1 KiB
C
Raw Normal View History

2026-03-26 16:22:35 +08:00
// enhancedtoolbar.h
2026-03-23 11:06:17 +08:00
#ifndef ENHANCEDTOOLBAR_H
#define ENHANCEDTOOLBAR_H
#include <QToolBar>
#include <QMap>
2026-03-26 16:22:35 +08:00
class DraggableToolButton;
2026-03-23 11:06:17 +08:00
class EnhancedToolBar : public QToolBar
{
Q_OBJECT
public:
explicit EnhancedToolBar(QWidget *parent = nullptr);
2026-03-26 16:22:35 +08:00
// 添加工具
2026-03-23 11:06:17 +08:00
void addTool(const QString &toolType, const QString &toolName,
const QIcon &icon = QIcon());
2026-03-26 16:22:35 +08:00
// 获取当前选中的工具
2026-03-23 11:06:17 +08:00
QString currentTool() const;
2026-03-26 16:22:35 +08:00
// 设置当前工具
void setCurrentTool(const QString &toolType);
2026-03-23 11:06:17 +08:00
2026-03-26 16:22:35 +08:00
// 启用/禁用拖拽
void setDragEnabled(bool enabled);
bool dragEnabled() const;
2026-03-23 11:06:17 +08:00
signals:
void toolSelected(const QString &toolType);
2026-03-26 16:22:35 +08:00
void toolDragged(const QString &toolType, const QPoint &globalPos);
2026-03-23 11:06:17 +08:00
private slots:
2026-03-26 16:22:35 +08:00
void onToolButtonClicked();
void onToolButtonDragStarted(const QString &toolData, const QPoint &globalPos);
void startDrag(const QString &toolType, const QPoint &globalPos);
2026-03-23 11:06:17 +08:00
private:
2026-03-26 16:22:35 +08:00
QMap<QString, DraggableToolButton*> m_buttons;
2026-03-23 11:06:17 +08:00
QString m_currentTool;
2026-03-26 16:22:35 +08:00
bool m_dragEnabled = true;
2026-03-23 11:06:17 +08:00
};
2026-03-26 16:22:35 +08:00
#endif // ENHANCEDTOOLBAR_H