aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core
diff options
context:
space:
mode:
Diffstat (limited to 'src-qt5/core')
-rw-r--r--src-qt5/core/lumina-desktop/desktop-plugins/LDPlugin.h58
-rw-r--r--src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp17
-rw-r--r--src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h16
3 files changed, 50 insertions, 41 deletions
diff --git a/src-qt5/core/lumina-desktop/desktop-plugins/LDPlugin.h b/src-qt5/core/lumina-desktop/desktop-plugins/LDPlugin.h
index 815ae9da..18eee1e6 100644
--- a/src-qt5/core/lumina-desktop/desktop-plugins/LDPlugin.h
+++ b/src-qt5/core/lumina-desktop/desktop-plugins/LDPlugin.h
@@ -29,7 +29,7 @@
class LDPlugin : public QFrame{
Q_OBJECT
-
+
private:
QString PLUGID, prefix;
QSettings *settings;
@@ -41,9 +41,9 @@ private:
public:
LDPlugin(QWidget *parent = 0, QString id="unknown");
-
+
~LDPlugin(){}
-
+
QString ID(){
return PLUGID;
}
@@ -51,46 +51,46 @@ public:
void setContextMenu(QMenu *cmen){ contextM = cmen; }
QMenu* contextMenu(){ return contextM; }
-
+
virtual QSize defaultPluginSize(){
//This needs to be re-implemented in the subclassed plugin
// The returned QSize is in grid points (typically 100 or 200 pixels square)
return QSize(1,1); //1x1 grid size
}
-
+
void savePluginGeometry(QRect geom){
settings->setValue(prefix+"geometry/desktopGridPoints", geom);
settings->sync();
}
-
+
QRect loadPluginGeometry(){
- return settings->value(prefix+"geometry/desktopGridPoints", QRect()).toRect();
+ return settings->value(prefix+"geometry/desktopGridPoints", QRect()).toRect();
}
-
+
void saveSetting(QString var, QVariant val){
//qDebug() << "Saving Setting:" << prefix+var+QString(" = ")+val.toString();
settings->setValue(prefix+var, val);
settings->sync();
}
-
+
QVariant readSetting(QString var, QVariant defaultval){
return settings->value(prefix+var, defaultval);
}
-
+
virtual void Cleanup(){
//This needs to be re-implemented in the subclassed plugin
//This is where any last-minute changes are performed before a plugin is removed permanently
//Note1: This is *not* called if the plugin is being temporarily closed
//Note2: All the settings for this plugin will be automatically removed after this is finished
}
-
+
void removeSettings(bool permanent = false){ //such as when a plugin is deleted
if(permanent){ Cleanup(); }
QStringList list = settings->allKeys().filter(prefix);
for(int i=0; i<list.length(); i++){ settings->remove(list[i]); }
-
+
}
-
+
void setGridGeometry(QRect grid){ settings->setValue(prefix+"geometry/gridLocation", grid); }
QRect gridGeometry(){ return settings->value(prefix+"geometry/gridLocation",QRect()).toRect(); }
@@ -106,36 +106,36 @@ public slots:
setupMenu();
}
void showPluginMenu();
-
+
signals:
void OpenDesktopMenu();
void CloseDesktopMenu();
void PluginResized();
void PluginActivated();
-
+
//Signals for communication with the desktop layout system (not generally used by hand)
void StartMoving(QString); //ID of plugin
void StartResizing(QString); //ID of plugin
void RemovePlugin(QString); //ID of plugin
void IncreaseIconSize(); // only used for desktop icons
void DecreaseIconSize(); // only used for desktop icons
-
+
private slots:
- void slotStartMove(){
- QCursor::setPos( this->mapToGlobal(QPoint(this->width()/2, this->height()/2)) );
- emit StartMoving(PLUGID);
+ void slotStartMove(){
+ QCursor::setPos( this->mapToGlobal(QPoint(this->width()/2, this->height()/2)) );
+ emit StartMoving(PLUGID);
}
-
- void slotStartResize(){
- QCursor::setPos( this->mapToGlobal(QPoint(this->width()/2, this->height()/2)) );
- emit StartResizing(PLUGID);
+
+ void slotStartResize(){
+ QCursor::setPos( this->mapToGlobal(QPoint(this->width()/2, this->height()/2)) );
+ emit StartResizing(PLUGID);
}
-
- void slotRemovePlugin(){
+
+ void slotRemovePlugin(){
removeSettings(true);
- emit RemovePlugin(PLUGID);
+ emit RemovePlugin(PLUGID);
}
-
+
protected:
void mousePressEvent(QMouseEvent *ev){
if(!dragTimer->isActive() && ev->buttons().testFlag(Qt::LeftButton) ){ dragTimer->start(); }
@@ -146,9 +146,9 @@ protected:
QWidget::mouseReleaseEvent(ev);
}
void mouseMoveEvent(QMouseEvent *ev){
- if(ev->buttons().testFlag(Qt::LeftButton)){
+ if(ev->buttons().testFlag(Qt::LeftButton)){
if(dragTimer->isActive()){ dragTimer->stop(); }
- slotStartMove();
+ slotStartMove();
}
QWidget::mouseMoveEvent(ev);
}
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 218bc098..88f535de 100644
--- a/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp
+++ b/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp
@@ -153,6 +153,8 @@ void AppLauncherPlugin::loadButton(){
tmp = this->contextMenu()->addAction( tr("Delete"), this, SLOT(fileDelete()) );
ICONS->loadIcon(tmp, "document-close");
}
+ tmp = this->contextMenu()->addAction( tr("Drag to Application"), this, SLOT(startDragNDrop()) );
+ ICONS->loadIcon(tmp, "edit-redo");
iconLoaded(iconID); //make sure the emblem is layered on top
//If the file is a symlink, put the overlay on the icon
/*if(info.isSymLink()){
@@ -240,6 +242,21 @@ void AppLauncherPlugin::iconLoaded(QString ico){
}
}
+void AppLauncherPlugin::startDragNDrop(){
+ //Start the drag event for this file
+ QDrag *drag = new QDrag(this);
+ QMimeData *md = new QMimeData;
+ md->setUrls( QList<QUrl>() << QUrl::fromLocalFile(button->whatsThis()) );
+ drag->setMimeData(md);
+ //Now perform the drag and react appropriately
+ Qt::DropAction dropAction = drag->exec(Qt::CopyAction | Qt::MoveAction);
+ if(dropAction == Qt::MoveAction){
+ // File Moved, remove it from here
+ //qDebug() << "File Moved:" << button->whatsThis();
+ //DO NOT DELETE FILES - return code often is wrong (browser drops for instance)
+ }
+}
+
void AppLauncherPlugin::actionTriggered(QAction *act){
if(act->whatsThis().isEmpty()){ return; }
QString path = button->whatsThis();
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 6cff4bf7..553fe1c5 100644
--- a/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h
+++ b/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h
@@ -53,6 +53,7 @@ private slots:
//void increaseIconSize();
//void decreaseIconSize();
//void deleteFile();
+ void startDragNDrop();
void actionTriggered(QAction *act);
void openWith();
@@ -90,18 +91,9 @@ protected:
void mouseMoveEvent(QMouseEvent *ev){
if( (ev->buttons() & Qt::LeftButton) ){
if((ev->pos() - dragstartpos).manhattanLength() > (this->width()/4) ){
- //Start the drag event for this file
- QDrag *drag = new QDrag(this);
- QMimeData *md = new QMimeData;
- md->setUrls( QList<QUrl>() << QUrl::fromLocalFile(button->whatsThis()) );
- drag->setMimeData(md);
- //Now perform the drag and react appropriately
- Qt::DropAction dropAction = drag->exec(Qt::CopyAction | Qt::MoveAction);
- if(dropAction == Qt::MoveAction){
- // File Moved, remove it from here
- //qDebug() << "File Moved:" << button->whatsThis();
- //DO NOT DELETE FILES - return code often is wrong (browser drops for instance)
- }
+ emit StartMoving(this->ID());
+ }else if(false){ //
+ startDragNDrop();
}
}else{
LDPlugin::mouseMoveEvent(ev);
bgstack15