diff options
author | Ken Moore <ken@pcbsd.org> | 2015-03-12 08:10:56 -0400 |
---|---|---|
committer | Ken Moore <ken@pcbsd.org> | 2015-03-12 08:10:56 -0400 |
commit | 6f2d86bca68975dc311a4838dbbb30e059d1fc1d (patch) | |
tree | 86cf376d5d63858048539e95282808d60eef57df | |
parent | Clean up some of the Lumina theme watcher usage (add a 1/2 second delay after... (diff) | |
download | lumina-6f2d86bca68975dc311a4838dbbb30e059d1fc1d.tar.gz lumina-6f2d86bca68975dc311a4838dbbb30e059d1fc1d.tar.bz2 lumina-6f2d86bca68975dc311a4838dbbb30e059d1fc1d.zip |
Update a bunch of icons in the desktop session, and also add a few abilities to the desktopview plugin:
1) Multi-item selection
2) cut/copy files to clipboard
3) delete files
4) increase/decrease icon sizes
-rw-r--r-- | lumina-desktop/LDesktop.cpp | 1 | ||||
-rw-r--r-- | lumina-desktop/desktop-plugins/LDPlugin.h | 4 | ||||
-rw-r--r-- | lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp | 98 | ||||
-rw-r--r-- | lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.h | 24 | ||||
-rw-r--r-- | lumina-desktop/lumina-desktop.pro | 2 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp | 2 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/userbutton/UserWidget.cpp | 2 |
7 files changed, 123 insertions, 10 deletions
diff --git a/lumina-desktop/LDesktop.cpp b/lumina-desktop/LDesktop.cpp index 9a045e4f..c2ef4a2a 100644 --- a/lumina-desktop/LDesktop.cpp +++ b/lumina-desktop/LDesktop.cpp @@ -287,6 +287,7 @@ void LDesktop::UpdateDesktop(){ if(DEBUG){qDebug() << " -- New Plugin:" << plugins[i];} plug = NewDP::createPlugin(plugins[i], bgDesktop); if(plug != 0){ + connect(plug, SIGNAL(OpenDesktopMenu()), this, SLOT(ShowMenu()) ); //qDebug() << " -- Show Plugin"; PLUGINS << plug; CreateDesktopPluginContainer(plug); diff --git a/lumina-desktop/desktop-plugins/LDPlugin.h b/lumina-desktop/desktop-plugins/LDPlugin.h index 0e1f6847..9660a85c 100644 --- a/lumina-desktop/desktop-plugins/LDPlugin.h +++ b/lumina-desktop/desktop-plugins/LDPlugin.h @@ -68,6 +68,10 @@ public slots: //This needs to be re-implemented in the subclassed plugin //This is where all the visuals are set if using Theme-dependant icons. } + +signals: + void OpenDesktopMenu(); + }; #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 index 018f96e8..0aa4a3de 100644 --- a/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp +++ b/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp @@ -2,6 +2,8 @@ #include <QFileInfo> #include <QDir> +#include <QClipboard> +#include <QMimeData> #include <LuminaXDG.h> #include "LSession.h" @@ -17,17 +19,31 @@ DesktopViewPlugin::DesktopViewPlugin(QWidget* parent, QString ID) : LDPlugin(par list->setBatchSize(10); //keep it snappy list->setSpacing(2); list->setSelectionBehavior(QAbstractItemView::SelectItems); - list->setSelectionMode(QAbstractItemView::NoSelection); + list->setSelectionMode(QAbstractItemView::ExtendedSelection); list->setStyleSheet( "QListWidget{ background: transparent; border: none; }" ); - list->setIconSize(QSize(64,64)); + int icosize = settings->value("IconSize",64).toInt(); + list->setIconSize(QSize(icosize,icosize)); list->setUniformItemSizes(true); + list->setContextMenuPolicy(Qt::CustomContextMenu); + + menu = new QMenu(this); + menu->addAction( LXDG::findIcon("run-build-file",""), tr("Open"), this, SLOT(runItems()) ); + menu->addSeparator(); + menu->addAction( LXDG::findIcon("edit-cut",""), tr("Cut"), this, SLOT(cutItems()) ); + menu->addAction( LXDG::findIcon("edit-copy",""), tr("Copy"), this, SLOT(copyItems()) ); + menu->addSeparator(); + menu->addAction( LXDG::findIcon("zoom-in",""), tr("Increase Icons"), this, SLOT(increaseIconSize()) ); + menu->addAction( LXDG::findIcon("zoom-out",""), tr("Decrease Icons"), this, SLOT(decreaseIconSize()) ); + menu->addSeparator(); + menu->addAction( LXDG::findIcon("edit-delete",""), tr("Delete"), this, SLOT(deleteItems()) ); this->layout()->addWidget(list); this->setInitialSize(600,600); 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*)) ); + connect(list, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(runItems()) ); + connect(list, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showMenu(const QPoint&)) ); QTimer::singleShot(0,this, SLOT(updateContents()) ); } @@ -35,13 +51,83 @@ DesktopViewPlugin::~DesktopViewPlugin(){ } -void DesktopViewPlugin::runItem(QListWidgetItem *item){ - LSession::LaunchApplication("lumina-open \""+item->whatsThis()+"\""); +void DesktopViewPlugin::runItems(){ + QList<QListWidgetItem*> sel = list->selectedItems(); + for(int i=0; i<sel.length(); i++){ + LSession::LaunchApplication("lumina-open \""+sel[i]->whatsThis()+"\""); + } +} + +void DesktopViewPlugin::copyItems(){ + QList<QListWidgetItem*> sel = list->selectedItems(); + if(sel.isEmpty()){ return; } //nothing selected + QStringList items; + //Format the data string + for(int i=0; i<sel.length(); i++){ + items << "copy::::"+sel[i]->whatsThis(); + } + //Now save that data to the global clipboard + QMimeData *dat = new QMimeData; + dat->clear(); + dat->setData("x-special/lumina-copied-files", items.join("\n").toLocal8Bit()); + QApplication::clipboard()->clear(); + QApplication::clipboard()->setMimeData(dat); +} + +void DesktopViewPlugin::cutItems(){ + QList<QListWidgetItem*> sel = list->selectedItems(); + if(sel.isEmpty()){ return; } //nothing selected + QStringList items; + //Format the data string + for(int i=0; i<sel.length(); i++){ + items << "cut::::"+sel[i]->whatsThis(); + } + //Now save that data to the global clipboard + QMimeData *dat = new QMimeData; + dat->clear(); + dat->setData("x-special/lumina-copied-files", items.join("\n").toLocal8Bit()); + QApplication::clipboard()->clear(); + QApplication::clipboard()->setMimeData(dat); +} + +void DesktopViewPlugin::deleteItems(){ + QList<QListWidgetItem*> sel = list->selectedItems(); + for(int i=0; i<sel.length(); i++){ + QFile::remove(sel[i]->whatsThis()); + } +} + +void DesktopViewPlugin::showMenu(const QPoint &pos){ + //Make sure there is an item underneath the mouse first + if(list->itemAt(pos)!=0){ + menu->popup(pos); + }else{ + //Pass the context menu request on to the desktop (emit it from the plugin) + emit OpenDesktopMenu(); + } +} + +void DesktopViewPlugin::increaseIconSize(){ + int icosize = settings->value("IconSize",64).toInt(); + icosize+=16; //go in orders of 16 pixels + list->setIconSize(QSize(icosize,icosize)); + settings->setValue("IconSize",icosize); + updateContents(); +} + +void DesktopViewPlugin::decreaseIconSize(){ + int icosize = settings->value("IconSize",64).toInt(); + if(icosize < 20){ return; } //too small to decrease more + icosize-=16; //go in orders of 16 pixels + list->setIconSize(QSize(icosize,icosize)); + settings->setValue("IconSize",icosize); + updateContents(); } void DesktopViewPlugin::updateContents(){ list->clear(); - list->setGridSize(QSize(80,70+this->fontMetrics().height())); + int icosize = settings->value("IconSize",64).toInt(); + list->setGridSize(QSize(icosize+8,icosize+4+this->fontMetrics().height())); 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++){ diff --git a/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.h b/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.h index 6ec35276..61e1caf9 100644 --- a/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.h +++ b/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.h @@ -13,6 +13,8 @@ #include <QVBoxLayout> #include <QTimer> #include <QFileSystemWatcher> +#include <QMouseEvent> + #include "../LDPlugin.h" class DesktopViewPlugin : public LDPlugin{ @@ -24,9 +26,16 @@ public: private: QListWidget *list; QFileSystemWatcher *watcher; + QMenu *menu; private slots: - void runItem(QListWidgetItem*); + void runItems(); + void copyItems(); + void cutItems(); + void deleteItems(); + void showMenu(const QPoint&); + void increaseIconSize(); + void decreaseIconSize(); void updateContents(); @@ -37,6 +46,19 @@ public slots: void ThemeChange(){ QTimer::singleShot(0,this, SLOT(updateContents())); } + +/*protected: + void mousePressEvent(QMouseEvent *ev){ + if(ev->button()==Qt::RightButton){ + qDebug() << " - got mouse event"; + //Only show the context menu if an item is under the mouse (don't block the desktop menu) + if(list->itemAt( ev->globalPos()) !=0){ + ev->accept(); + showMenu(ev->globalPos()); + } + } + } + */ }; #endif diff --git a/lumina-desktop/lumina-desktop.pro b/lumina-desktop/lumina-desktop.pro index feb49f60..dc3db9bd 100644 --- a/lumina-desktop/lumina-desktop.pro +++ b/lumina-desktop/lumina-desktop.pro @@ -1,6 +1,6 @@ QT += core gui network -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets x11extras multimedia dbus +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets x11extras multimedia TARGET = Lumina-DE isEmpty(PREFIX) { diff --git a/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp b/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp index 3b8be74f..53fdb950 100644 --- a/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp +++ b/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp @@ -101,7 +101,7 @@ void UserItemWidget::setupButton(bool disable){ }else if( !QFile::exists( QDir::homePath()+"/Desktop/"+icon->whatsThis().section("/",-1) ) && !QFile::exists( QDir::homePath()+"/.lumina/favorites/"+icon->whatsThis().section("/",-1) ) ){ //This file does not have a desktop shortcut yet -- allow the user to add it button->setWhatsThis("add"); - button->setIcon( LXDG::findIcon("favorites","") ); + button->setIcon( LXDG::findIcon("bookmark-toolbar","") ); button->setToolTip(tr("Create Shortcut")); connect(button, SIGNAL(clicked()), this, SLOT(buttonClicked()) ); }else{ diff --git a/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp b/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp index 6ca3ba19..82a06012 100644 --- a/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp +++ b/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp @@ -16,7 +16,7 @@ UserWidget::UserWidget(QWidget* parent) : QTabWidget(parent), ui(new Ui::UserWid sysapps = LSession::handle()->applicationMenu()->currentAppHash(); //get the raw info //Setup the Icons // - favorites tab - this->setTabIcon(0, rotateIcon(LXDG::findIcon("favorites","")) ); + this->setTabIcon(0, rotateIcon(LXDG::findIcon("folder-favorites","")) ); this->setTabText(0,""); // - apps tab this->setTabIcon(1, rotateIcon(LXDG::findIcon("system-run","")) ); |