✨ feat(UI模块): 添加是否响应拖拽设置
This commit is contained in:
parent
1897e73ada
commit
0b1df76404
|
@ -142,6 +142,11 @@ FileView::ItemSelectMode FileView::getItemMode() const
|
|||
return m_itemMode;
|
||||
}
|
||||
|
||||
void FileView::setAllowDrag(bool isAllowDrag)
|
||||
{
|
||||
m_isAllowDrag = isAllowDrag;
|
||||
}
|
||||
|
||||
void FileView::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (!indexAt(event->pos()).isValid()) {
|
||||
|
@ -181,7 +186,7 @@ void FileView::keyPressEvent(QKeyEvent *event)
|
|||
|
||||
void FileView::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
if (event->mimeData()->hasUrls() && m_itemMode == ItemSelectMode::Default) {
|
||||
if (m_isAllowDrag && m_itemMode == ItemSelectMode::Default && event->mimeData()->hasUrls()) {
|
||||
event->accept();
|
||||
} else {
|
||||
event->ignore();
|
||||
|
|
|
@ -34,6 +34,7 @@ public:
|
|||
PublicAttributes::Theme getTheme() const;
|
||||
void setItemMode(FileView::ItemSelectMode mode);
|
||||
FileView::ItemSelectMode getItemMode() const;
|
||||
void setAllowDrag(bool isAllowDrag);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
|
@ -72,6 +73,7 @@ private:
|
|||
QListView::ViewMode m_viewModel = QListView::IconMode; // 当前视图模式
|
||||
PublicAttributes::Theme m_theme = PublicAttributes::Theme::Light; // 当前主题
|
||||
FileView::ItemSelectMode m_itemMode = FileView::ItemSelectMode::Default; // 当前item视图模式
|
||||
bool m_isAllowDrag = true;
|
||||
};
|
||||
|
||||
#endif // FILEVIEW_H
|
||||
|
|
Loading…
Reference in New Issue