aboutsummaryrefslogtreecommitdiff
path: root/lumina-desktop/desktop-plugins/desktopview
diff options
context:
space:
mode:
authorKen Moore <ken@pcbsd.org>2014-11-03 11:41:29 -0500
committerKen Moore <ken@pcbsd.org>2014-11-03 11:41:29 -0500
commit53ce9ffd7903e59a6a215e50c39d8da194c0d42e (patch)
tree9ebaa097c957e9297f8026f6673af7df0e5fdce7 /lumina-desktop/desktop-plugins/desktopview
parentLarge quality of life update to Lumina: (diff)
downloadlumina-53ce9ffd7903e59a6a215e50c39d8da194c0d42e.tar.gz
lumina-53ce9ffd7903e59a6a215e50c39d8da194c0d42e.tar.bz2
lumina-53ce9ffd7903e59a6a215e50c39d8da194c0d42e.zip
Add a new desktop plugin: desktopview
This plugin provides an area of the screen for automatically displaying icons for anything in the ~/Desktop folder. An icon can be opened/run via a double-click of the mouse.
Diffstat (limited to 'lumina-desktop/desktop-plugins/desktopview')
-rw-r--r--lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp69
-rw-r--r--lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.h35
2 files changed, 92 insertions, 12 deletions
diff --git a/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp b/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp
new file mode 100644
index 00000000..98d132ac
--- /dev/null
+++ b/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp
@@ -0,0 +1,69 @@
+#include "DesktopViewPlugin.h"
+
+#include <QFileInfo>
+#include <QDir>
+
+#include <LuminaXDG.h>
+#include "LSession.h"
+
+
+DesktopViewPlugin::DesktopViewPlugin(QWidget* parent, QString ID) : LDPlugin(parent, ID){
+ this->setLayout( new QVBoxLayout());
+ this->layout()->setContentsMargins(0,0,0,0);
+ list = new QListWidget(this);
+ list->setUniformItemSizes(true);
+ list->setViewMode(QListView::IconMode);
+ list->setLayoutMode(QListView::Batched);
+ list->setBatchSize(10); //keep it snappy
+ list->setSpacing(2);
+ list->setSelectionBehavior(QAbstractItemView::SelectItems);
+ list->setSelectionMode(QAbstractItemView::NoSelection);
+ list->setStyleSheet( "QListWidget{ background: transparent; }" );
+ list->setIconSize(QSize(64,64));
+ list->setGridSize(QSize(80,80));
+ this->layout()->addWidget(list);
+ this->setInitialSize(200,300);
+ watcher = new QFileSystemWatcher(this);
+ watcher->addPath(QDir::homePath()+"/Desktop");
+ connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(updateContents()) );
+
+ connect(list, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(runItem(QListWidgetItem*)) );
+ QTimer::singleShot(0,this, SLOT(updateContents()) );
+}
+
+DesktopViewPlugin::~DesktopViewPlugin(){
+
+}
+
+void DesktopViewPlugin::runItem(QListWidgetItem *item){
+ LSession::LaunchApplication("lumina-open \""+item->whatsThis()+"\"");
+}
+
+void DesktopViewPlugin::updateContents(){
+ list->clear();
+ QDir dir(QDir::homePath()+"/Desktop");
+ QFileInfoList files = dir.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name | QDir::Type | QDir::DirsFirst);
+ for(int i=0; i<files.length(); i++){
+ QListWidgetItem *it = new QListWidgetItem;
+ it->setWhatsThis(files[i].absoluteFilePath());
+ if(files[i].isDir()){
+ it->setIcon( LXDG::findIcon("folder","") );
+ it->setText( files[i].fileName() );
+ }else if(files[i].suffix() == "desktop" ){
+ bool ok = false;
+ XDGDesktop desk = LXDG::loadDesktopFile(files[i].absoluteFilePath(), ok);
+ if(ok){
+ it->setIcon( LXDG::findIcon(desk.icon,"") );
+ it->setText( desk.name );
+ }else{
+ //Revert back to a standard file handling
+ it->setIcon( LXDG::findMimeIcon(files[i].suffix()) );
+ it->setText( files[i].fileName() );
+ }
+ }else{
+ it->setIcon( LXDG::findMimeIcon(files[i].suffix()) );
+ it->setText( files[i].fileName() );
+ }
+ list->addItem(it);
+ }
+} \ No newline at end of file
diff --git a/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.h b/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.h
index 9dd97423..6ec35276 100644
--- a/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.h
+++ b/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.h
@@ -4,28 +4,39 @@
// Available under the 3-clause BSD license
// See the LICENSE file for full details
//===========================================
-// This class is a quick sample desktop plugin
+// This plugin is a listing/launcher for things in the ~/Desktop folder
//===========================================
-#ifndef _LUMINA_DESKTOP_DESKTOP_VIEW_PLUGIN_CALENDAR_H
-#define _LUMINA_DESKTOP_DESKTOP_VIEW_PLUGIN_CALENDAR_H
+#ifndef _LUMINA_DESKTOP_DESKTOP_VIEW_PLUGIN_H
+#define _LUMINA_DESKTOP_DESKTOP_VIEW_PLUGIN_H
#include <QListWidget>
#include <QVBoxLayout>
+#include <QTimer>
+#include <QFileSystemWatcher>
#include "../LDPlugin.h"
-class CalendarPlugin : public LDPlugin{
+class DesktopViewPlugin : public LDPlugin{
Q_OBJECT
public:
- DesktopViewPlugin(QWidget* parent, QString ID) : LDPlugin(parent, ID){
- this->setLayout( new QVBoxLayout());
- this->layout()->setContentsMargins(0,0,0,0);
- list = new QListWidget(this);
- this->layout()->addWidget(list);
- }
-
- ~DesktopViewPlugin(){}
+ DesktopViewPlugin(QWidget* parent, QString ID);
+ ~DesktopViewPlugin();
private:
QListWidget *list;
+ QFileSystemWatcher *watcher;
+
+private slots:
+ void runItem(QListWidgetItem*);
+ void updateContents();
+
+
+public slots:
+ void LocaleChange(){
+ QTimer::singleShot(0,this, SLOT(updateContents()));
+ }
+ void ThemeChange(){
+ QTimer::singleShot(0,this, SLOT(updateContents()));
+ }
+
};
#endif
bgstack15