diff options
Diffstat (limited to 'lumina-desktop/desktop-plugins')
6 files changed, 170 insertions, 20 deletions
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/applauncher/AppLauncherPlugin.cpp b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp index dc0c7596..b3c6afcf 100644 --- a/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp +++ b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp @@ -7,18 +7,19 @@ AppLauncherPlugin::AppLauncherPlugin(QWidget* parent, QString ID) : LDPlugin(par lay->setContentsMargins(0,0,0,0); button = new QToolButton(this); button->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); - button->setIconSize(QSize(64,64)); button->setAutoRaise(true); 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()) ); - 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(); - }*/ + menu = new QMenu(this); + menu->addAction(LXDG::findIcon("zoom-in",""), tr("Increase Size"), this, SLOT(increaseIconSize())); + menu->addAction(LXDG::findIcon("zoom-out",""), tr("Decrease Size"), this, SLOT(decreaseIconSize())); + int icosize = settings->value("iconsize",64).toInt(); + button->setIconSize(QSize(icosize,icosize)); + this->setInitialSize(icosize,icosize+10+this->fontMetrics().height()); + this->setContextMenuPolicy(Qt::CustomContextMenu); + connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(openContextMenu()) ); watcher = new QFileSystemWatcher(this); connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT( loadButton()) ); QTimer::singleShot(1,this, SLOT(loadButton()) ); @@ -62,4 +63,27 @@ void AppLauncherPlugin::buttonClicked(){ LSession::LaunchApplication("lumina-open \""+path+"\""); } -}
\ No newline at end of file +} + +void AppLauncherPlugin::openContextMenu(){ + if(button->underMouse()){ + menu->popup(QCursor::pos()); + }else{ + emit OpenDesktopMenu(); + } +} + +void AppLauncherPlugin::increaseIconSize(){ + int icosize = settings->value("iconsize",64).toInt(); + icosize += 16; + button->setIconSize(QSize(icosize,icosize)); + settings->setValue("iconsize",icosize); +} + +void AppLauncherPlugin::decreaseIconSize(){ + int icosize = settings->value("iconsize",64).toInt(); + if(icosize < 20){ return; } //cannot get smaller + icosize -= 16; + button->setIconSize(QSize(icosize,icosize)); + settings->setValue("iconsize",icosize); +} diff --git a/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h index bb21b636..2c861e4d 100644 --- a/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h +++ b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h @@ -16,6 +16,8 @@ #include <QFile> #include <QFileSystemWatcher> #include <QTimer> +#include <QMenu> +#include <QCursor> #include "../LDPlugin.h" @@ -30,9 +32,15 @@ public: private: QToolButton *button; QFileSystemWatcher *watcher; + QMenu *menu; private slots: void loadButton(); void buttonClicked(); + void openContextMenu(); + + void increaseIconSize(); + void decreaseIconSize(); + }; #endif diff --git a/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp b/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp index ce20c563..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++){ @@ -54,15 +140,19 @@ void DesktopViewPlugin::updateContents(){ bool ok = false; XDGDesktop desk = LXDG::loadDesktopFile(files[i].absoluteFilePath(), ok); if(ok){ - it->setIcon( LXDG::findIcon(desk.icon,"") ); - it->setText( desk.name ); + it->setIcon( LXDG::findIcon(desk.icon,"unknown") ); + if(desk.name.isEmpty()){ + it->setText( files[i].fileName() ); + }else{ + it->setText( desk.name ); + } }else{ //Revert back to a standard file handling - it->setIcon( LXDG::findMimeIcon(files[i].suffix()) ); + it->setIcon( LXDG::findMimeIcon(files[i].fileName()) ); it->setText( files[i].fileName() ); } }else{ - it->setIcon( LXDG::findMimeIcon(files[i].suffix()) ); + it->setIcon( LXDG::findMimeIcon( files[i].fileName() ) ); it->setText( files[i].fileName() ); } list->addItem(it); 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/desktop-plugins/notepad/NotepadPlugin.cpp b/lumina-desktop/desktop-plugins/notepad/NotepadPlugin.cpp index 6d4a2b5d..dacaca60 100644 --- a/lumina-desktop/desktop-plugins/notepad/NotepadPlugin.cpp +++ b/lumina-desktop/desktop-plugins/notepad/NotepadPlugin.cpp @@ -200,10 +200,12 @@ void NotePadPlugin::updateContents(){ QString note = cnote->currentData().toString(); updating = true; LUtils::writeFile(note, edit->toPlainText().split("\n"), true); + QApplication::processEvents(); //make sure to process/discard the file changed signal before disabling the flag updating = false; } void NotePadPlugin::notesDirChanged(){ + if(updating){ return; } QString cfile = settings->value("currentFile","").toString(); QStringList notes; QDir dir(QDir::homePath()+"/Notes"); |