aboutsummaryrefslogtreecommitdiff
path: root/lumina-desktop/desktop-plugins/desktopview
diff options
context:
space:
mode:
Diffstat (limited to 'lumina-desktop/desktop-plugins/desktopview')
-rw-r--r--lumina-desktop/desktop-plugins/desktopview/DeskItem.cpp50
-rw-r--r--lumina-desktop/desktop-plugins/desktopview/DeskItem.h30
-rw-r--r--lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp87
-rw-r--r--lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.h46
4 files changed, 17 insertions, 196 deletions
diff --git a/lumina-desktop/desktop-plugins/desktopview/DeskItem.cpp b/lumina-desktop/desktop-plugins/desktopview/DeskItem.cpp
deleted file mode 100644
index 21b1d1f6..00000000
--- a/lumina-desktop/desktop-plugins/desktopview/DeskItem.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-//===========================================
-// Lumina-DE source code
-// Copyright (c) 2014, Ken Moore
-// Available under the 3-clause BSD license
-// See the LICENSE file for full details
-//===========================================
-#include "DeskItem.h"
-
-DeskItem::DeskItem(QWidget *parent, QString itempath, int ssize) : QToolButton(parent){
- this->setFixedSize(ssize, ssize);
- this->setWhatsThis(itempath);
- this->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
- this->setAutoRaise(true);
- int txtheight = this->fontMetrics().height() *2;
- this->setIconSize( QSize(ssize-txtheight, ssize-txtheight));
- connect(this, SIGNAL(clicked()), this, SLOT(RunItem()) );
- updateItem();
-}
-
-DeskItem::~DeskItem(){
-
-}
-
-void DeskItem::updateItem(){
- QFileInfo info(this->whatsThis());
- QIcon ico;
- QString txt;
- if(info.isDir()){
- ico = LXDG::findIcon("folder","");
- txt = info.fileName();
- }else if(info.suffix()=="desktop"){
- bool ok = false;
- XDGDesktop dsk = LXDG::loadDesktopFile(this->whatsThis(), ok);
- if(ok){
- ico = LXDG::findIcon( dsk.icon );
- txt = dsk.name;
- }else{
- ico = LXDG::findIcon("","");
- txt = info.fileName();
- }
- }else{
- ico = LXDG::findIcon("application-x-zerosize","");
- txt = info.fileName();
- }
- this->setIcon(ico);
- //Trim the text size to fit
- txt = this->fontMetrics().elidedText(txt, Qt::ElideRight ,this->width() - 4);
- this->setText(txt);
-
-} \ No newline at end of file
diff --git a/lumina-desktop/desktop-plugins/desktopview/DeskItem.h b/lumina-desktop/desktop-plugins/desktopview/DeskItem.h
deleted file mode 100644
index c578d692..00000000
--- a/lumina-desktop/desktop-plugins/desktopview/DeskItem.h
+++ /dev/null
@@ -1,30 +0,0 @@
-//===========================================
-// Lumina-DE source code
-// Copyright (c) 2014, Ken Moore
-// Available under the 3-clause BSD license
-// See the LICENSE file for full details
-//===========================================
-#ifndef _LUMINA_DESKTOP_DESKTOP_ITEM_H
-#define _LUMINA_DESKTOP_DESKTOP_ITEM_H
-
-#include <QToolButton>
-#include <QProcess>
-#include <QString>
-
-#include <LuminaXDG.h>
-
-class DeskItem : public QToolButton{
- Q_OBJECT
-public:
- DeskItem(QWidget *parent, QString itempath, int ssize);
- ~DeskItem();
-
- void updateItem();
-
-private slots:
- void RunItem(){
- QProcess::startDetached("lumina-open "+this->whatsThis());
- }
-};
-
-#endif \ No newline at end of file
diff --git a/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp b/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp
deleted file mode 100644
index 4c70d19f..00000000
--- a/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-//===========================================
-// Lumina-DE source code
-// Copyright (c) 2014, Ken Moore
-// Available under the 3-clause BSD license
-// See the LICENSE file for full details
-//===========================================
-#include "DesktopViewPlugin.h"
-
-DesktopViewPlugin::DesktopViewPlugin(QWidget *parent) : LDPlugin(parent, "desktopview"){
- watcher = new QFileSystemWatcher(this);
- deskDir = QDir::homePath();
- if(QFile::exists(deskDir+"/Desktop") ){
- deskDir = deskDir+"/Desktop";
- }else if(QFile::exists(deskDir+"/desktop") ){
- deskDir = deskDir+"/desktop";
- }
- watcher->addPath(deskDir);
- icoSize = 0; //temporary placeholder
- spacing = 0; //temporary placeholder
- ITEMS.clear();
- layout = new QGridLayout(this);
- layout->setContentsMargins(1,1,1,1);
- this->setLayout(layout);
-
- //Connect the signals/slots
- connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(UpdateDesktop()) );
- connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(UpdateDesktop()) );
-
- //Now launch the update mechanisms in a new thread
- QTimer::singleShot(10, this, SLOT(UpdateDesktop()) );
-}
-
-DesktopViewPlugin::~DesktopViewPlugin(){
-
-}
-
-void DesktopViewPlugin::UpdateDesktop(){
- //Calculate available rows/columns
- int oldSize = icoSize;
- icoSize = 64; //64x64 default icons for now (make dynamic later)
- int oldspacing = spacing;
- spacing = 4; // 4 pixel space between items (make dynamic later);
- if(icoSize != oldSize || spacing != oldspacing){
- //Re-create all the items with the proper size
- for(int i=0; i<ITEMS.length(); i++){
- delete ITEMS.takeAt(i); //delete the widget
- i--;
- }
- }
- layout->setSpacing(spacing);
-
- int rmax = (this->height()-2)/(icoSize+spacing);
- int cmax = (this->width()-2)/(icoSize+spacing);
- //Now get the current items in the folder
- QDir dir(deskDir);
- QStringList items = dir.entryList( QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot, QDir::Type | QDir::LocaleAware | QDir::DirsFirst);
- //iterate over all current items
- for(int i=0; i<ITEMS.length(); i++){
- int index = items.indexOf( ITEMS[i]->whatsThis().section("/",-1) );
- if( index == -1 ){
- //item no longer exists - remove it
- delete ITEMS.takeAt(i);
- i--;
- }else{
- //Item still exists - remove it from the "new" list
- ITEMS[i]->updateItem();
- items.removeAt(index);
- }
- }
- //Now iterate over the spaces in the widget and create items as necessary
- for(int r=0; r<rmax; r++){
- layout->setRowMinimumHeight(r,icoSize);
- for(int c=0; c<cmax && items.length() > 0; c++){
- if(r==0){ layout->setColumnMinimumWidth(c,icoSize); }
- if(layout->itemAtPosition(r,c)==0 && items.length() > 0){
- //Empty spot, put the first new item here
- DeskItem *it = new DeskItem(this, deskDir+"/"+items[0], icoSize);
- items.removeAt(0);
- layout->addWidget(it, r,c);
- ITEMS << it;
- }
- }
- }
- if(layout->itemAtPosition(rmax,cmax)==0){
- layout->addWidget(new QWidget(this), rmax, cmax); //put an empty widget here as a placeholder
- }
-} \ 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 9702e6e4..9dd97423 100644
--- a/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.h
+++ b/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.h
@@ -4,40 +4,28 @@
// Available under the 3-clause BSD license
// See the LICENSE file for full details
//===========================================
-// This class is the interface to load all the different desktop plugins
+// This class is a quick sample desktop plugin
//===========================================
-#ifndef _LUMINA_DESKTOP_VIEW_PLUGIN_H
-#define _LUMINA_DESKTOP_VIEW_PLUGIN_H
-
-#include <QDir>
-#include <QFile>
-#include <QFileSystemWatcher>
-#include <QGridLayout>
-#include <QStringList>
-#include <QList>
-#include <QTimer>
-
-#include <LuminaXDG.h>
+#ifndef _LUMINA_DESKTOP_DESKTOP_VIEW_PLUGIN_CALENDAR_H
+#define _LUMINA_DESKTOP_DESKTOP_VIEW_PLUGIN_CALENDAR_H
+#include <QListWidget>
+#include <QVBoxLayout>
#include "../LDPlugin.h"
-#include "DeskItem.h"
-
-class DesktopViewPlugin : public LDPlugin{
+class CalendarPlugin : public LDPlugin{
Q_OBJECT
public:
- DesktopViewPlugin(QWidget *parent = 0);
- ~DesktopViewPlugin();
-
+ 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(){}
+
private:
- QString deskDir;
- QFileSystemWatcher *watcher;
- QGridLayout *layout;
- int icoSize, spacing;
- QList<DeskItem*> ITEMS;
-
-private slots:
- void UpdateDesktop();
-
+ QListWidget *list;
};
-#endif \ No newline at end of file
+#endif
bgstack15