aboutsummaryrefslogtreecommitdiff
path: root/lumina-desktop/desktop-plugins
diff options
context:
space:
mode:
authorKen Moore <ken@pcbsd.org>2014-09-29 10:18:14 -0400
committerKen Moore <ken@pcbsd.org>2014-09-29 10:18:14 -0400
commitf11d2a7d2b38d751d50ecfe6349039447d80fb15 (patch)
tree92833d6338e0ff0df59634e2a0c606578c89af6d /lumina-desktop/desktop-plugins
parentMerge pull request #11 from slicer69/master (diff)
downloadlumina-f11d2a7d2b38d751d50ecfe6349039447d80fb15.tar.gz
lumina-f11d2a7d2b38d751d50ecfe6349039447d80fb15.tar.bz2
lumina-f11d2a7d2b38d751d50ecfe6349039447d80fb15.zip
A few updates to plugins:
UserButton: 1) When creating links, always create them in ~/.lumina/favorites 2) Scan both the Desktop and the favorites dir for favorite items 3) Distinguish between removing a link and deleting a file 4) Allow for setting links to directories 5) Allow removing links to directories AppLauncher desktop plugin: 1) Make sure to use the session function for launching an item (makes the mouse cursor show the loading icon). 2) Allow for pre-defining a file path for the launcher (syntax: applauncher::<path to file>)
Diffstat (limited to 'lumina-desktop/desktop-plugins')
-rw-r--r--lumina-desktop/desktop-plugins/NewDP.h3
-rw-r--r--lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp54
-rw-r--r--lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h52
3 files changed, 59 insertions, 50 deletions
diff --git a/lumina-desktop/desktop-plugins/NewDP.h b/lumina-desktop/desktop-plugins/NewDP.h
index 0e225cb9..83d035d5 100644
--- a/lumina-desktop/desktop-plugins/NewDP.h
+++ b/lumina-desktop/desktop-plugins/NewDP.h
@@ -25,7 +25,8 @@ public:
plug = new SamplePlugin(parent, plugin);
}else if(plugin.section("---",0,0)=="calendar"){
plug = new CalendarPlugin(parent, plugin);
- }else if(plugin.section("---",0,0)=="applauncher"){
+ }else if(plugin.section("---",0,0).section("::",0,0)=="applauncher"){
+ //This plugin can be pre-initialized to a file path after the "::" delimiter
plug = new AppLauncherPlugin(parent, plugin);
}else{
qWarning() << "Invalid Desktop Plugin:"<<plugin << " -- Ignored";
diff --git a/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp
new file mode 100644
index 00000000..32937ad4
--- /dev/null
+++ b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp
@@ -0,0 +1,54 @@
+#include "AppLauncherPlugin.h"
+#include "../../LSession.h"
+
+AppLauncherPlugin::AppLauncherPlugin(QWidget* parent, QString ID) : LDPlugin(parent, ID){
+ this->setLayout( new QVBoxLayout());
+ this->layout()->setContentsMargins(0,0,0,0);
+ button = new QToolButton(this);
+ button->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
+ button->setIconSize(QSize(64,64));
+ button->setAutoRaise(true);
+ this->layout()->addWidget(button);
+ connect(button, SIGNAL(clicked()), this, SLOT(buttonClicked()) );
+ watcher = new QFileSystemWatcher(this);
+ connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT( loadButton()) );
+ QTimer::singleShot(1,this, SLOT(loadButton()) );
+}
+
+void AppLauncherPlugin::loadButton(){
+ QString def = this->ID().section("::",1,50).section("---",0,0).simplified();
+ QString path = this->settings->value("applicationpath",def).toString(); //use the default if necessary
+ //qDebug() << "Default Application Launcher:" << def << path;
+ bool ok = false;
+ XDGDesktop file = LXDG::loadDesktopFile(path, ok);
+ if(path.isEmpty() || !QFile::exists(path) || !ok){
+ button->setWhatsThis("");
+ button->setIcon( LXDG::findIcon("quickopen-file","") );
+ button->setText( tr("Click to Set") );
+ if(!watcher->files().isEmpty()){ watcher->removePaths(watcher->files()); }
+ }else{
+ button->setWhatsThis(file.filePath);
+ button->setIcon( LXDG::findIcon(file.icon,"quickopen") );
+ button->setText( this->fontMetrics().elidedText(file.name, Qt::ElideRight, 64) );
+ if(!watcher->files().isEmpty()){ watcher->removePaths(watcher->files()); }
+ watcher->addPath(file.filePath); //make sure to update this shortcut if the file changes
+ }
+}
+
+void AppLauncherPlugin::buttonClicked(){
+ QString path = button->whatsThis();
+ if(path.isEmpty() || !QFile::exists(path) ){
+ //prompt for the user to select an application
+ QList<XDGDesktop> apps = LXDG::sortDesktopNames( LXDG::systemDesktopFiles() );
+ QStringList names;
+ for(int i=0; i<apps.length(); i++){ names << apps[i].name; }
+ bool ok = false;
+ QString app = QInputDialog::getItem(this, tr("Select Application"), tr("Name:"), names, 0, false, &ok);
+ if(!ok || names.indexOf(app)<0){ return; } //cancelled
+ this->settings->setValue("applicationpath", apps[ names.indexOf(app) ].filePath);
+ QTimer::singleShot(0,this, SLOT(loadButton()));
+ }else{
+ LSession::LaunchApplication("lumina-open \""+path+"\"");
+ }
+
+} \ No newline at end of file
diff --git a/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h
index 3a8e5da8..bb21b636 100644
--- a/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h
+++ b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h
@@ -24,20 +24,7 @@
class AppLauncherPlugin : public LDPlugin{
Q_OBJECT
public:
- AppLauncherPlugin(QWidget* parent, QString ID) : LDPlugin(parent, ID){
- this->setLayout( new QVBoxLayout());
- this->layout()->setContentsMargins(0,0,0,0);
- button = new QToolButton(this);
- button->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
- button->setIconSize(QSize(64,64));
- button->setAutoRaise(true);
- this->layout()->addWidget(button);
- connect(button, SIGNAL(clicked()), this, SLOT(buttonClicked()) );
- watcher = new QFileSystemWatcher(this);
- connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT( loadButton()) );
- QTimer::singleShot(1,this, SLOT(loadButton()) );
- }
-
+ AppLauncherPlugin(QWidget* parent, QString ID);
~AppLauncherPlugin(){}
private:
@@ -45,40 +32,7 @@ private:
QFileSystemWatcher *watcher;
private slots:
- void loadButton(){
- QString path = this->settings->value("applicationpath","").toString();
- bool ok = false;
- XDGDesktop file = LXDG::loadDesktopFile(path, ok);
- if(path.isEmpty() || !QFile::exists(path) || !ok){
- button->setWhatsThis("");
- button->setIcon( LXDG::findIcon("quickopen-file","") );
- button->setText( tr("Click to Set") );
- if(!watcher->files().isEmpty()){ watcher->removePaths(watcher->files()); }
- }else{
- button->setWhatsThis(file.filePath);
- button->setIcon( LXDG::findIcon(file.icon,"quickopen") );
- button->setText( this->fontMetrics().elidedText(file.name, Qt::ElideRight, 64) );
- if(!watcher->files().isEmpty()){ watcher->removePaths(watcher->files()); }
- watcher->addPath(file.filePath); //make sure to update this shortcut if the file changes
- }
- }
-
- void buttonClicked(){
- QString path = button->whatsThis();
- if(path.isEmpty() || !QFile::exists(path) ){
- //prompt for the user to select an application
- QList<XDGDesktop> apps = LXDG::sortDesktopNames( LXDG::systemDesktopFiles() );
- QStringList names;
- for(int i=0; i<apps.length(); i++){ names << apps[i].name; }
- bool ok = false;
- QString app = QInputDialog::getItem(this, tr("Select Application"), tr("Name:"), names, 0, false, &ok);
- if(!ok || names.indexOf(app)<0){ return; } //cancelled
- this->settings->setValue("applicationpath", apps[ names.indexOf(app) ].filePath);
- QTimer::singleShot(0,this, SLOT(loadButton()));
- }else{
- QProcess::startDetached("lumina-open "+path);
- }
-
- }
+ void loadButton();
+ void buttonClicked();
};
#endif
bgstack15