diff options
-rw-r--r-- | lumina-config/LPlugins.cpp | 7 | ||||
-rw-r--r-- | lumina-config/mainUI.cpp | 4 | ||||
-rw-r--r-- | lumina-desktop/desktop-plugins/LDPlugin.h | 11 | ||||
-rw-r--r-- | lumina-desktop/desktop-plugins/NewDP.h | 3 | ||||
-rw-r--r-- | lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp | 5 | ||||
-rw-r--r-- | lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp | 69 | ||||
-rw-r--r-- | lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.h | 35 | ||||
-rw-r--r-- | lumina-desktop/lumina-desktop.pro | 11 |
8 files changed, 122 insertions, 23 deletions
diff --git a/lumina-config/LPlugins.cpp b/lumina-config/LPlugins.cpp index 918cc629..ae936b7b 100644 --- a/lumina-config/LPlugins.cpp +++ b/lumina-config/LPlugins.cpp @@ -133,6 +133,13 @@ void LPlugins::LoadDesktopPlugins(){ info.ID = "applauncher"; info.icon = "quickopen"; DESKTOP.insert(info.ID, info); + //Desktop View Plugin + info = LPI(); //clear it + info.name = QObject::tr("Desktop Icons View"); + info.description = QObject::tr("Area for automatically showing desktop icons"); + info.ID = "desktopview"; + info.icon = "preferences-desktop-icons"; + DESKTOP.insert(info.ID, info); } void LPlugins::LoadMenuPlugins(){ diff --git a/lumina-config/mainUI.cpp b/lumina-config/mainUI.cpp index 88a52a2b..edd1483e 100644 --- a/lumina-config/mainUI.cpp +++ b/lumina-config/mainUI.cpp @@ -39,8 +39,8 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){ QTimer::singleShot(10, this, SLOT(loadCurrentSettings()) ); //Disable the incomplete pages/items at the moment - ui->check_session_playloginaudio->setVisible(false); - ui->check_session_playlogoutaudio->setVisible(false); + //ui->check_session_playloginaudio->setVisible(false); + //ui->check_session_playlogoutaudio->setVisible(false); } MainUI::~MainUI(){ diff --git a/lumina-desktop/desktop-plugins/LDPlugin.h b/lumina-desktop/desktop-plugins/LDPlugin.h index e8a1f5f3..d71bde0a 100644 --- a/lumina-desktop/desktop-plugins/LDPlugin.h +++ b/lumina-desktop/desktop-plugins/LDPlugin.h @@ -45,6 +45,17 @@ public: return PLUGID; } + void setInitialSize(int width, int height){ + //Note: Only run this in the plugin initization routine: + // if the plugin is completely new (first time used), it will be this size + if(settings->allKeys().isEmpty()){ + //Brand new plugin: set initial size + settings->setValue("location/width",width); + settings->setValue("location/height",height); + settings->sync(); + } + } + public slots: virtual void LocaleChange(){ //This needs to be re-implemented in the subclassed plugin diff --git a/lumina-desktop/desktop-plugins/NewDP.h b/lumina-desktop/desktop-plugins/NewDP.h index 83d035d5..daf9802c 100644 --- a/lumina-desktop/desktop-plugins/NewDP.h +++ b/lumina-desktop/desktop-plugins/NewDP.h @@ -16,6 +16,7 @@ #include "SamplePlugin.h" #include "calendar/CalendarPlugin.h" #include "applauncher/AppLauncherPlugin.h" +#include "desktopview/DesktopViewPlugin.h" class NewDP{ public: @@ -28,6 +29,8 @@ public: }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 if(plugin.section("---",0,0)=="desktopview"){ + plug = new DesktopViewPlugin(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 index 9ed9e735..dc0c7596 100644 --- a/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp +++ b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp @@ -12,12 +12,13 @@ AppLauncherPlugin::AppLauncherPlugin(QWidget* parent, QString ID) : LDPlugin(par button->setText("..."); //Need to set something here so that initial sizing works properly lay->addWidget(button, 0, Qt::AlignCenter); connect(button, SIGNAL(clicked()), this, SLOT(buttonClicked()) ); - if(this->settings->allKeys().isEmpty()){ + this->setInitialSize(64,66+this->fontMetrics().height()); + /*if(this->settings->allKeys().isEmpty()){ //Brand new plugin: set initial size this->settings->setValue("location/width",64); this->settings->setValue("location/height",66+this->fontMetrics().height()); this->settings->sync(); - } + }*/ watcher = new QFileSystemWatcher(this); connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT( loadButton()) ); QTimer::singleShot(1,this, SLOT(loadButton()) ); 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 diff --git a/lumina-desktop/lumina-desktop.pro b/lumina-desktop/lumina-desktop.pro index f2cb7cb2..479a3e3c 100644 --- a/lumina-desktop/lumina-desktop.pro +++ b/lumina-desktop/lumina-desktop.pro @@ -40,10 +40,8 @@ SOURCES += main.cpp \ panel-plugins/desktopswitcher/LDesktopSwitcher.cpp \ panel-plugins/systemdashboard/LSysDashboard.cpp \ panel-plugins/systemdashboard/SysMenuQuick.cpp \ - desktop-plugins/applauncher/AppLauncherPlugin.cpp -# desktop-plugins/desktopview/DesktopViewPlugin.cpp \ -# desktop-plugins/desktopview/DeskItem.cpp - + desktop-plugins/applauncher/AppLauncherPlugin.cpp \ + desktop-plugins/desktopview/DesktopViewPlugin.cpp HEADERS += Globals.h \ @@ -77,9 +75,8 @@ HEADERS += Globals.h \ panel-plugins/systemdashboard/SysMenuQuick.h \ desktop-plugins/SamplePlugin.h \ desktop-plugins/calendar/CalendarPlugin.h \ - desktop-plugins/applauncher/AppLauncherPlugin.h -# desktop-plugins/desktopview/DesktopViewPlugin.h \ -# desktop-plugins/desktopview/DeskItem.h + desktop-plugins/applauncher/AppLauncherPlugin.h \ + desktop-plugins/desktopview/DesktopViewPlugin.h FORMS += SystemWindow.ui \ panel-plugins/userbutton/UserWidget.ui \ |