aboutsummaryrefslogtreecommitdiff
path: root/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp
diff options
context:
space:
mode:
authorChristopher Roy Bratusek <nano@jpberlin.de>2014-11-03 21:14:37 +0100
committerChristopher Roy Bratusek <nano@jpberlin.de>2014-11-03 21:14:37 +0100
commit0d1cd6623f7804828d4b2dbb568449a49f728cc2 (patch)
treedd85de54d59ffe29d0f62942c0c9e3cf3d4a9616 /lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp
parentdebian/changelog (diff)
parentAdd a new desktop plugin: desktopview (diff)
downloadlumina-0d1cd6623f7804828d4b2dbb568449a49f728cc2.tar.gz
lumina-0d1cd6623f7804828d4b2dbb568449a49f728cc2.tar.bz2
lumina-0d1cd6623f7804828d4b2dbb568449a49f728cc2.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp')
-rw-r--r--lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp69
1 files changed, 69 insertions, 0 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
bgstack15