aboutsummaryrefslogtreecommitdiff
path: root/src-qt5
diff options
context:
space:
mode:
Diffstat (limited to 'src-qt5')
-rw-r--r--src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp16
-rw-r--r--src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h21
2 files changed, 37 insertions, 0 deletions
diff --git a/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp b/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp
index 0bf087c1..837e3268 100644
--- a/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp
+++ b/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp
@@ -47,6 +47,7 @@ void AppLauncherPlugin::loadButton(){
bool ok = info.canonicalPath().startsWith("/net/");
if(!ok){ ok = QFile::exists(path); } //do it this way to ensure the file existance check never runs for /net/ files
if(!ok){ emit RemovePlugin(this->ID()); return;}
+ this->setAcceptDrops( info.isDir() );
icosize = this->height()-4 - 2.2*button->fontMetrics().height();
button->setFixedSize( this->width()-4, this->height()-4);
button->setIconSize( QSize(icosize,icosize) );
@@ -316,3 +317,18 @@ void AppLauncherPlugin::renameFinished(int result){
qDebug() << " - SUCCESS";
}
}
+
+void AppLauncherPlugin::fileDrop(bool copy, QList<QUrl> urls){
+ for(int i=0; i<urls.length(); i++){
+ QString oldpath = urls[i].toLocalFile();
+ if(!QFile::exists(oldpath)){ continue; } //not a local file?
+ QString filename = oldpath.section("/",-1);
+ if(copy){
+ qDebug() << "Copying File:" << oldpath << "->" << button->whatsThis()+"/"+filename;
+ QFile::copy(oldpath, button->whatsThis()+"/"+filename);
+ }else{
+ qDebug() << "Moving File:" << oldpath << "->" << button->whatsThis()+"/"+filename;
+ QFile::rename(oldpath, button->whatsThis()+"/"+filename);
+ }
+ }
+}
diff --git a/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h b/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h
index 833a2a48..6cff4bf7 100644
--- a/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h
+++ b/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h
@@ -20,6 +20,7 @@
#include <QCursor>
#include <QDrag>
#include <QMimeData>
+#include <QtConcurrent>
#include "../LDPlugin.h"
@@ -62,6 +63,8 @@ private slots:
void fileRename();
void renameFinished(int result);
+ void fileDrop(bool copy, QList<QUrl> urls);
+
public slots:
void LocaleChange(){
loadButton(); //force reload
@@ -103,7 +106,25 @@ protected:
}else{
LDPlugin::mouseMoveEvent(ev);
}
+ }
+ void dragEnterEvent(QDragEnterEvent *ev){
+ if(ev->mimeData()->hasUrls() && this->acceptDrops()){ ev->acceptProposedAction(); }
+ }
+
+ void dropEvent(QDropEvent *ev){
+ QList<QUrl> urls = ev->mimeData()->urls();
+ bool ok = !urls.isEmpty() && this->acceptDrops();
+ if(ok){
+ if(ev->proposedAction() == Qt::MoveAction){
+ ev->setDropAction(Qt::MoveAction);
+ QtConcurrent::run(this, &AppLauncherPlugin::fileDrop, false, urls);
+ }else if(ev->proposedAction() == Qt::CopyAction){
+ ev->setDropAction(Qt::CopyAction);
+ QtConcurrent::run(this, &AppLauncherPlugin::fileDrop, true, urls);
+ }else{ ok = false; }
+ }
+ if(ok){ ev->acceptProposedAction(); }
}
};
#endif
bgstack15