ukui-menu/0019-32.patch
peijiankang 3eb98cb553 add patch from openkylin
(cherry picked from commit 49080eb14485c039ea6bdf00f09cff10c0c98c9f)
2023-05-25 10:20:45 +08:00

151 lines
5.8 KiB
Diff

From: lixueman <lixueman@kylinos.cn>
Date: Thu, 24 Nov 2022 01:44:13 +0000
Subject: =?utf-8?b?ITMyIOS/ruWkjeWFqOWxj+S9jee9rumXrumimO+8jOWinuWKoOaLlg==?=
=?utf-8?b?5ou95Zu65a6a5Yiw5Lu75Yqh5qCP5Yqf6IO9IE1lcmdlIHB1bGwgcmVxdWVzdCAh?=
=?utf-8?b?MzIgZnJvbSBsaXh1ZW1hbi9vcGVua3lsaW4veWFuZ3R6ZQ==?=
---
src/UserInterface/ListView/klistview.cpp | 5 +++--
src/UserInterface/ListView/klistview.h | 1 +
src/UserInterface/ListView/listview.cpp | 31 +++++++++++++++++++++++++++++++
src/UserInterface/ListView/listview.h | 3 ++-
src/UserInterface/mainwindow.cpp | 4 ++--
5 files changed, 39 insertions(+), 5 deletions(-)
diff --git a/src/UserInterface/ListView/klistview.cpp b/src/UserInterface/ListView/klistview.cpp
index 91fbe08..28c83c2 100755
--- a/src/UserInterface/ListView/klistview.cpp
+++ b/src/UserInterface/ListView/klistview.cpp
@@ -92,8 +92,9 @@ void KListView::mouseMoveEvent(QMouseEvent *e)
void KListView::mousePressEvent(QMouseEvent *event)
{
- if ((this->indexAt(event->pos()).isValid()) && event->button() == Qt::LeftButton) {
- m_pressApp = m_listmodel->data(this->indexAt(event->pos()), Qt::DisplayRole);
+ m_pressPos = event->pos();
+ if ((this->indexAt(m_pressPos).isValid()) && event->button() == Qt::LeftButton) {
+ m_pressApp = m_listmodel->data(this->indexAt(m_pressPos), Qt::DisplayRole);
}
return QListView::mousePressEvent(event);
}
diff --git a/src/UserInterface/ListView/klistview.h b/src/UserInterface/ListView/klistview.h
index 503997b..2ac6f3d 100755
--- a/src/UserInterface/ListView/klistview.h
+++ b/src/UserInterface/ListView/klistview.h
@@ -36,6 +36,7 @@ public:
int module = 0;
double m_transparency;
QVariant m_pressApp;
+ QPoint m_pressPos;
UkuiMenuInterface *m_ukuiMenuInterface = nullptr;
protected:
void paintEvent(QPaintEvent *e);
diff --git a/src/UserInterface/ListView/listview.cpp b/src/UserInterface/ListView/listview.cpp
index 89be87b..a9a9ed2 100755
--- a/src/UserInterface/ListView/listview.cpp
+++ b/src/UserInterface/ListView/listview.cpp
@@ -18,9 +18,11 @@
#include "listview.h"
#include "function_button_widget.h"
#include "utility.h"
+#include "thumbnail.h"
#include <QDebug>
#include <QDesktopServices>
#include <QtConcurrent/QtConcurrent>
+#include <QDrag>
ListView::ListView(QWidget *parent/*, int width, int height, int module*/):
KListView(parent)
@@ -29,6 +31,7 @@ ListView::ListView(QWidget *parent/*, int width, int height, int module*/):
this->h = 540;
this->module = 1;
initWidget();
+ setDragEnabled(true);
setAttribute(Qt::WA_AcceptTouchEvents);
m_listmodel = new QStandardItemModel(this);
this->setModel(m_listmodel);
@@ -70,6 +73,34 @@ void ListView::initWidget()
connect(this, &ListView::clicked, this, &ListView::onClicked);
}
+void ListView::mouseMoveEvent(QMouseEvent *e)
+{
+ if (e->buttons() & Qt::LeftButton) {
+ if ((e->pos() - m_pressPos).manhattanLength() >= QApplication::startDragDistance()) {
+ myDebug() << "进入拖拽事件";
+ QString desktopfp = m_pressApp.value<QStringList>().at(0);
+ QMimeData *mimeData = new QMimeData;
+ ThumbNail *dragImage = new ThumbNail;
+ QDrag *drag = new QDrag(this);
+ QList<QUrl> desktopUrlList;
+ desktopUrlList.append(QUrl(desktopfp));
+ myDebug() << desktopUrlList;
+ mimeData->setUrls(desktopUrlList);
+ //设置拖拽时的缩略图
+ dragImage->setupthumbnail(desktopfp);
+ QPixmap pixmap = dragImage->grab();
+ pixmap = pixmap.scaled(QSize(32, 32), Qt::KeepAspectRatio);
+ myDebug() << mimeData;
+ drag->setMimeData(mimeData);
+ drag->setPixmap(pixmap);
+ drag->setHotSpot(QPoint(pixmap.width(), pixmap.height()));
+ drag->exec(Qt::MoveAction);
+ delete dragImage;
+ dragImage = nullptr;
+ }
+ }
+}
+
void ListView::addData(QVector<QStringList> data, int module)
{
this->module = module;
diff --git a/src/UserInterface/ListView/listview.h b/src/UserInterface/ListView/listview.h
index f9125e8..cfcfbf8 100755
--- a/src/UserInterface/ListView/listview.h
+++ b/src/UserInterface/ListView/listview.h
@@ -50,13 +50,14 @@ protected:
void paintEvent(QPaintEvent *e) override;
void keyPressEvent(QKeyEvent *e);
bool event(QEvent *e);
+ void mouseMoveEvent(QMouseEvent *e);
+
private:
int w = 0;
int h = 0;
int m_preRowCount;
bool m_scrollbarState = true;
-
private Q_SLOTS:
void onClicked(QModelIndex index);//点击item
// void rightClickedSlot(const QPoint &pos);//右键菜单
diff --git a/src/UserInterface/mainwindow.cpp b/src/UserInterface/mainwindow.cpp
index feb225a..18f538b 100755
--- a/src/UserInterface/mainwindow.cpp
+++ b/src/UserInterface/mainwindow.cpp
@@ -770,7 +770,6 @@ void MainWindow::minAnimationFinished()
m_viewWidget->setFocus();
// m_collectPushButton->clicked(true);
on_collectPushButton_clicked();
-
QTimer::singleShot(200, [ = ]() {
m_animationPage->hide();
});
@@ -791,6 +790,7 @@ void MainWindow::maxAnimationFinished()
setMaxWindowPos();
m_fullWindow->activateWindow();
+
QTimer::singleShot(200, [ = ]() {
m_animationPage->hide();
});
@@ -1370,7 +1370,7 @@ void MainWindow::setMinWindowPos()
void MainWindow::setMaxWindowPos()
{
if (g_platform.startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) {
- kdk::WindowManager::setGeometry(m_fullWindow->windowHandle(), QRect(0, 0, Style::m_availableScreenWidth, Style::m_availableScreenHeight));
+ kdk::WindowManager::setGeometry(m_fullWindow->windowHandle(), QRect(Style::m_primaryScreenX, Style::m_primaryScreenY, Style::m_availableScreenWidth, Style::m_availableScreenHeight));
}
}