From 9482acb96095a6e6c236a72f60995e43d590b75f Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Mon, 27 Oct 2014 15:03:38 -0400 Subject: Make sure to put a max length on the text in the user button items (180 pixels - auto-scale does not work unless the widget is visible). Also remove the custom stylesheet for the systemwindow (so it uses the theme). Also start working on the new desktopview plugin (not integrated yet) --- lumina-desktop/SystemWindow.ui | 3 - .../desktop-plugins/desktopview/DeskItem.cpp | 50 ------------- .../desktop-plugins/desktopview/DeskItem.h | 30 -------- .../desktopview/DesktopViewPlugin.cpp | 87 ---------------------- .../desktopview/DesktopViewPlugin.h | 46 +++++------- .../panel-plugins/userbutton/UserItemWidget.cpp | 10 +-- 6 files changed, 22 insertions(+), 204 deletions(-) delete mode 100644 lumina-desktop/desktop-plugins/desktopview/DeskItem.cpp delete mode 100644 lumina-desktop/desktop-plugins/desktopview/DeskItem.h delete mode 100644 lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp (limited to 'lumina-desktop') diff --git a/lumina-desktop/SystemWindow.ui b/lumina-desktop/SystemWindow.ui index 2b21757f..b03039f5 100644 --- a/lumina-desktop/SystemWindow.ui +++ b/lumina-desktop/SystemWindow.ui @@ -13,9 +13,6 @@ System Options - - QDialog{border-radius: 5px; background-color: rgba(240,240,240,200); border: 1px solid grey;} - 0 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 -#include -#include - -#include - -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; isetSpacing(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; iwhatsThis().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; rsetRowMinimumHeight(r,icoSize); - for(int c=0; c 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 -#include -#include -#include -#include -#include -#include - -#include +#ifndef _LUMINA_DESKTOP_DESKTOP_VIEW_PLUGIN_CALENDAR_H +#define _LUMINA_DESKTOP_DESKTOP_VIEW_PLUGIN_CALENDAR_H +#include +#include #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 ITEMS; - -private slots: - void UpdateDesktop(); - + QListWidget *list; }; -#endif \ No newline at end of file +#endif diff --git a/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp b/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp index d1e35522..7a1983d2 100644 --- a/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp +++ b/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp @@ -14,10 +14,10 @@ UserItemWidget::UserItemWidget(QWidget *parent, QString itemPath, bool isDir, bo XDGDesktop item = LXDG::loadDesktopFile(itemPath, ok); if(ok){ icon->setPixmap( LXDG::findIcon(item.icon, "preferences-system-windows-actions").pixmap(30,30) ); - name->setText( item.name ); + name->setText( this->fontMetrics().elidedText(item.name, Qt::ElideRight, 180) ); }else{ icon->setPixmap( LXDG::findIcon("unknown","").pixmap(30,30) ); - name->setText( itemPath.section("/",-1) ); + name->setText( this->fontMetrics().elidedText(itemPath.section("/",-1), Qt::ElideRight, 180) ); } }else if(isDir){ if(itemPath.endsWith("/")){ itemPath.chop(1); } @@ -26,12 +26,12 @@ UserItemWidget::UserItemWidget(QWidget *parent, QString itemPath, bool isDir, bo name->setText( tr("Go Back") ); }else{ icon->setPixmap( LXDG::findIcon("folder","").pixmap(30,30) ); - name->setText( itemPath.section("/",-1) ); + name->setText( this->fontMetrics().elidedText(itemPath.section("/",-1), Qt::ElideRight, 180) ); } }else{ if(itemPath.endsWith("/")){ itemPath.chop(1); } icon->setPixmap( LXDG::findMimeIcon(itemPath.section("/",-1).section(".",-1)).pixmap(30,30) ); - name->setText( itemPath.section("/",-1) ); + name->setText( this->fontMetrics().elidedText(itemPath.section("/",-1), Qt::ElideRight, 180) ); } linkPath = QFile::symLinkTarget(itemPath); icon->setWhatsThis(itemPath); @@ -49,7 +49,7 @@ UserItemWidget::UserItemWidget(QWidget *parent, XDGDesktop item) : QFrame(parent isShortcut = item.filePath.contains("/home/") && (item.filePath.contains("/Desktop/") || item.filePath.contains("/.lumina/favorites/") ); //Now fill it appropriately icon->setPixmap( LXDG::findIcon(item.icon,"preferences-system-windows-actions").pixmap(30,30) ); - name->setText( item.name ); + name->setText( this->fontMetrics().elidedText(item.name, Qt::ElideRight, 180) ); icon->setWhatsThis(item.filePath); //Now setup the button appropriately setupButton(); -- cgit