aboutsummaryrefslogtreecommitdiff
path: root/lumina-desktop
diff options
context:
space:
mode:
Diffstat (limited to 'lumina-desktop')
-rw-r--r--lumina-desktop/LDesktop.cpp11
-rw-r--r--lumina-desktop/desktop-plugins/LDPlugin.h11
-rw-r--r--lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp7
-rw-r--r--lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h4
4 files changed, 29 insertions, 4 deletions
diff --git a/lumina-desktop/LDesktop.cpp b/lumina-desktop/LDesktop.cpp
index 8c2592c7..a326cbcb 100644
--- a/lumina-desktop/LDesktop.cpp
+++ b/lumina-desktop/LDesktop.cpp
@@ -555,6 +555,8 @@ void LDesktop::AlignDesktopPlugins(){
}
void LDesktop::DesktopPluginRemoved(QString ID, bool internal){
+ //NOTE: This function is only run when the plugin is deliberately removed
+ // The "internal" flag is for whether the plugin was closed by the user (external), or programmatically removed (internal)
//Close down that plugin instance (NOTE: the container might have already closed by the user)
if(DEBUG){ qDebug() << "Desktop Plugin Removed:" << ID; }
//First look for the container (just in case)
@@ -569,13 +571,18 @@ void LDesktop::DesktopPluginRemoved(QString ID, bool internal){
break;
}
}
-
+
//qDebug() << "PLUGINS:" << PLUGINS.length() << ID;
for(int i=0; i<PLUGINS.length(); i++){
if(PLUGINS[i]->ID() == ID){
//qDebug() << "- found ID";
if(DEBUG){ qDebug() << " - Deleting Desktop Plugin:" << ID; }
- PLUGINS[i]->removeSettings(); //Remove any settings associated with this plugin
+ //Special check for auto-generated desktop icons
+ if(ID.startsWith("applauncher::") && (ID.section("::",1,1).section("---",0,0).section("/",0,-1) == (QDir::homePath()+"/Desktop") ) ){
+ PLUGINS[i]->removeSettings(!internal); //Only remove the file if an external removal on an auto-generated shortcut
+ }else{
+ PLUGINS[i]->removeSettings(true); //Remove any settings associated with this plugin
+ }
delete PLUGINS.takeAt(i);
break;
}
diff --git a/lumina-desktop/desktop-plugins/LDPlugin.h b/lumina-desktop/desktop-plugins/LDPlugin.h
index d49fa40a..a77674ee 100644
--- a/lumina-desktop/desktop-plugins/LDPlugin.h
+++ b/lumina-desktop/desktop-plugins/LDPlugin.h
@@ -53,9 +53,18 @@ public:
return settings->value(prefix+var, defaultval);
}
- void removeSettings(){ //such as when a plugin is deleted
+ 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]); }
+
}
/*virtual void scalePlugin(double xscale, double yscale){
diff --git a/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp
index ea42f151..ae454511 100644
--- a/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp
+++ b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp
@@ -33,6 +33,13 @@ AppLauncherPlugin::AppLauncherPlugin(QWidget* parent, QString ID) : LDPlugin(par
QTimer::singleShot(100,this, SLOT(loadButton()) );
}
+void AppLauncherPlugin::Cleanup(){
+ //This is run only when the plugin was forcibly closed/removed
+ if(QFile::exists(button->whatsThis()) && button->whatsThis().startsWith(QDir::homePath()+"/Desktop") ){
+ deleteFile();
+ }
+}
+
void AppLauncherPlugin::loadButton(bool onchange){
QString def = this->ID().section("::",1,50).section("---",0,0).simplified();
QString path = this->readSetting("applicationpath",def).toString(); //use the default if necessary
diff --git a/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h
index 9eefebf1..796d8f04 100644
--- a/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h
+++ b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h
@@ -28,7 +28,9 @@ class AppLauncherPlugin : public LDPlugin{
public:
AppLauncherPlugin(QWidget* parent, QString ID);
~AppLauncherPlugin(){}
-
+
+ void Cleanup(); //special function for final cleanup
+
private:
QToolButton *button;
QFileSystemWatcher *watcher;
bgstack15