diff options
author | Ken Moore <ken@pcbsd.org> | 2015-04-27 15:05:03 -0400 |
---|---|---|
committer | Ken Moore <ken@pcbsd.org> | 2015-04-27 15:05:03 -0400 |
commit | ddf397d485ddb2cc391f8e0e7fe74642891d62e9 (patch) | |
tree | 727677845f062d26288e82ef2997d1b813efcee8 /lumina-desktop/panel-plugins | |
parent | Add support for system-defined default non-mime applications in the luminaDes... (diff) | |
download | lumina-ddf397d485ddb2cc391f8e0e7fe74642891d62e9.tar.gz lumina-ddf397d485ddb2cc391f8e0e7fe74642891d62e9.tar.bz2 lumina-ddf397d485ddb2cc391f8e0e7fe74642891d62e9.zip |
Setup the lumina-desktop to use the new favorites system:
1) Convert any old system to the new one on login (0.8.4-devel users will need to wait until 0.8.4-release or 0.8.5-devel - the next change to the session version).
2) Update the User Buton plugin to use the new system and streamline when it actually probes the filesystem for changes (makes it even faster)
3) Update the Desktop Bar plugin to use the new system as well.
Diffstat (limited to 'lumina-desktop/panel-plugins')
6 files changed, 155 insertions, 113 deletions
diff --git a/lumina-desktop/panel-plugins/desktopbar/LDeskBar.cpp b/lumina-desktop/panel-plugins/desktopbar/LDeskBar.cpp index e60da975..d29d4354 100644 --- a/lumina-desktop/panel-plugins/desktopbar/LDeskBar.cpp +++ b/lumina-desktop/panel-plugins/desktopbar/LDeskBar.cpp @@ -1,6 +1,6 @@ //=========================================== // Lumina-DE source code -// Copyright (c) 2012, Ken Moore +// Copyright (c) 2012-2015, Ken Moore // Available under the 3-clause BSD license // See the LICENSE file for full details //=========================================== @@ -14,17 +14,23 @@ LDeskBarPlugin::LDeskBarPlugin(QWidget *parent, QString id, bool horizontal) : L if(QFile::exists(QDir::homePath()+"/Desktop")){ desktopPath = QDir::homePath()+"/Desktop"; } else if(QFile::exists(QDir::homePath()+"/desktop")){ desktopPath = QDir::homePath()+"/desktop"; } else{ desktopPath=""; } + //Make sure the favorites directory exists + if(!QFile::exists(QDir::homePath()+"/.lumina/favorites") ){ + QDir dir; + dir.mkpath(QDir::homePath()+"/.lumina/favorites"); + } //Setup the filter lists for the different types of files - audioFilter <<"*.ogg"<<"*.mp3"<<"*.wav"<<"*.aif"<<"*.iff"<<"*.m3u"<<"*.m4a"<<"*.mid"<<"*.mpa"<<"*.ra"<<"*.wma"; + /*audioFilter <<"*.ogg"<<"*.mp3"<<"*.wav"<<"*.aif"<<"*.iff"<<"*.m3u"<<"*.m4a"<<"*.mid"<<"*.mpa"<<"*.ra"<<"*.wma"; videoFilter <<"*.3g2"<<"*.3gp"<<"*.asf"<<"*.asx"<<"*.avi"<<"*.flv"<<"*.m4v"<<"*.mov"<<"*.mp4"<<"*.mpg"<<"*.rm"<<"*.srt"<<"*.swf"<<"*.vob"<<"*.wmv"; pictureFilter <<"*.bmp"<<"*.dds"<<"*.gif"<<"*.jpg"<<"*.png"<<"*.psd"<<"*.thm"<<"*.tif"<<"*.tiff"<<"*.ai"<<"*.eps"<<"*.ps"<<"*.svg"<<"*.ico"; - docsFilter << "*.txt"<<"*.rtf"<<"*.doc"<<"*.docx"<<"*.odf"<<"*.pdf"; + docsFilter << "*.txt"<<"*.rtf"<<"*.doc"<<"*.docx"<<"*.odf"<<"*.pdf";*/ //initialize the desktop bar items initializeDesktop(); //setup the directory watcher watcher = new QFileSystemWatcher(this); if(!desktopPath.isEmpty()){ - watcher->addPath(desktopPath); + watcher->addPath(desktopPath); + watcher->addPath(QDir::homePath()+"/.lumina/favorites"); } connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(desktopChanged()) ); QTimer::singleShot(1,this, SLOT(desktopChanged()) ); //make sure to load it the first time @@ -107,7 +113,7 @@ QAction* LDeskBarPlugin::newAction(QString filepath, QString name, QIcon icon){ return act; } -void LDeskBarPlugin::updateMenu(QMenu* menu, QFileInfoList files, bool trim){ +/*void LDeskBarPlugin::updateMenu(QMenu* menu, QFileInfoList files, bool trim){ menu->clear(); //re-create the menu (since it is hidden from view) QStringList filevals; @@ -122,7 +128,7 @@ void LDeskBarPlugin::updateMenu(QMenu* menu, QFileInfoList files, bool trim){ for(int i=0; i<filevals.length(); i++){ menu->addAction( newAction( filevals[i].section("::::",1,1), filevals[i].section("::::",0,0), "") ); } -} +}*/ // ======================= // PRIVATE SLOTS @@ -135,59 +141,67 @@ void LDeskBarPlugin::ActionTriggered(QAction* act){ } void LDeskBarPlugin::desktopChanged(){ - if(!desktopPath.isEmpty()){ - QDir dir(desktopPath); - QDir favdir(QDir::homePath()+"/.lumina/favorites"); - totals = dir.entryInfoList( QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot, QDir::Name); - totals << favdir.entryInfoList( QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot, QDir::Name); - //Update all the special menus (trimming the totals list as we go) - updateMenu(dirM, QFileInfoList() << dir.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name) << favdir.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name)); - updateMenu(audioM, QFileInfoList() << dir.entryInfoList( audioFilter, QDir::Files, QDir::Name) << favdir.entryInfoList( audioFilter, QDir::Files, QDir::Name)); - updateMenu(videoM, QFileInfoList() << dir.entryInfoList( videoFilter, QDir::Files, QDir::Name) << favdir.entryInfoList( videoFilter, QDir::Files, QDir::Name) ); - updateMenu(pictureM, QFileInfoList() << dir.entryInfoList( pictureFilter, QDir::Files, QDir::Name) << favdir.entryInfoList( pictureFilter, QDir::Files, QDir::Name) ); - updateMenu(docM, QFileInfoList() << dir.entryInfoList( docsFilter, QDir::Files, QDir::Name) << favdir.entryInfoList( docsFilter, QDir::Files, QDir::Name) ); - //Now update the launchers - QFileInfoList exe = dir.entryInfoList( QStringList() << "*.desktop", QDir::Files, QDir::Name ); - exe << favdir.entryInfoList( QStringList() << "*.desktop", QDir::Files, QDir::Name ); - // - Get a complete list of apps (in alphabetical order) - QList<XDGDesktop> exeList; - for(int i=0; i<exe.length(); i++){ - totals.removeAll(exe[i]); //Remove this item from the totals - bool ok = false; - XDGDesktop df = LXDG::loadDesktopFile(exe[i].canonicalFilePath(), ok); - if(ok){ - if( LXDG::checkValidity(df) && !df.isHidden ){ exeList << df; } - } - } - exeList = LXDG::sortDesktopNames(exeList); - // - Now re-create the menu with the apps - appM->clear(); - bool listApps = true; //turn this off for the moment (make dynamic later) - if(!listApps){ - //go through the current items and remove them all - while( APPLIST.length() > 0){ - delete this->layout()->takeAt(3); //always after the 3 main menu buttons - } - } - for(int i=0; i<exeList.length(); i++){ - if(listApps){ appM->addAction( newAction(exeList[i].filePath, exeList[i].name, LXDG::findIcon(exeList[i].icon, ":/images/default-application.png")) ); } - else{ - //Create a new LTBWidget for this app - QToolButton *it = new QToolButton(this); - it->setWhatsThis(exeList[i].filePath); - it->setToolTip(exeList[i].name); - it->setIcon( LXDG::findIcon(exeList[i].icon, "") ); - it->setToolButtonStyle(Qt::ToolButtonIconOnly); - it->setAutoRaise(true); - it->setPopupMode(QToolButton::InstantPopup); - if(it->icon().isNull()){ it->setIcon( LXDG::findIcon("application-x-executable","") ); } - connect(it, SIGNAL(triggered(QAction*)), this , SLOT(ActionTriggered(QAction*)) ); - APPLIST << it; - this->layout()->addWidget(it); + QStringList newfavs = LUtils::listFavorites(); + if(lastHomeUpdate.isNull() || (QFileInfo(QDir::homePath()+"/Desktop").lastModified() > lastHomeUpdate) || newfavs!=favs ){ + favs = newfavs; + QDir homedir = QDir( QDir::homePath()+"/Desktop"); + homefiles = homedir.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot); + lastHomeUpdate = QDateTime::currentDateTime(); + QStringList favitems = favs; + //Remember for format for favorites: <name>::::[app/dir/<mimetype>]::::<full path> + for(int i=0; i<homefiles.length(); i++){ + QString type; + if(homefiles[i].isDir()){ type="dir"; } + else if(homefiles[i].fileName().endsWith(".desktop")){ type="app"; } + else{ type=LXDG::findAppMimeForFile(homefiles[i].fileName()); } + favitems << homefiles[i].fileName()+"::::"+type+"::::"+homefiles[i].absoluteFilePath(); + //qDebug() << "Desktop Item:" << favitems.last(); + } + + favitems.sort(); //sort them alphabetically + //Now add the items to the lists + appM->clear(); + dirM->clear(); + audioM->clear(); + videoM->clear(); + pictureM->clear(); + docM->clear(); + otherM->clear(); + for(int i=0; i<favitems.length(); i++){ + QString type = favitems[i].section("::::",1,1); + QString name = favitems[i].section("::::",0,0); + QString path = favitems[i].section("::::",2,50); + if(type=="app"){ + //Add it to appM + bool ok = false; + XDGDesktop df = LXDG::loadDesktopFile(path, ok); + if(ok){ + if( LXDG::checkValidity(df) && !df.isHidden ){ + appM->addAction( newAction(df.filePath, df.name, LXDG::findIcon(df.icon, ":/images/default-application.png")) ); } } - //Now update the other menu with everything else that is left - updateMenu(otherM, totals, false); + }else if(type=="dir"){ + //Add it to dirM + dirM->addAction( newAction(path, name, LXDG::findIcon("folder","")) ); + }else if(type.startsWith("audio/")){ + //Add it to audioM + audioM->addAction( newAction(path, name, LXDG::findMimeIcon(type)) ); + }else if(type.startsWith("video/")){ + //Add it to videoM + videoM->addAction( newAction(path, name, LXDG::findMimeIcon(type)) ); + }else if(type.startsWith("image/")){ + //Add it to pictureM + pictureM->addAction( newAction(path, name, LXDG::findMimeIcon(type)) ); + }else if(type.startsWith("text/")){ + //Add it to docM + docM->addAction( newAction(path, name, LXDG::findMimeIcon(type)) ); + }else{ + //Add it to otherM + otherM->addAction( newAction(path, name, LXDG::findMimeIcon(type)) ); + } + + } + //Now update the file menu as appropriate fileM->clear(); if(!audioM->isEmpty()){ fileM->addMenu(audioM); } @@ -205,12 +219,11 @@ void LDeskBarPlugin::desktopChanged(){ }else{ fileB->setMenu(fileM); } - } + } //end of check for if updates are needed + //Setup the visibility of the buttons appB->setVisible( !appM->isEmpty() ); dirB->setVisible( !dirM->isEmpty() ); fileB->setVisible( !fileM->isEmpty() ); - //Clear the totals list (since no longer in use) - totals.clear(); } diff --git a/lumina-desktop/panel-plugins/desktopbar/LDeskBar.h b/lumina-desktop/panel-plugins/desktopbar/LDeskBar.h index 1e42bd95..8e624dc2 100644 --- a/lumina-desktop/panel-plugins/desktopbar/LDeskBar.h +++ b/lumina-desktop/panel-plugins/desktopbar/LDeskBar.h @@ -43,17 +43,19 @@ private: //Special toolbuttons and menus QToolButton *appB, *fileB, *dirB; QMenu *appM, *dirM, *audioM, *videoM, *pictureM, *fileM, *otherM, *docM; - QStringList audioFilter, videoFilter, pictureFilter, docsFilter; - QFileInfoList totals; + //QStringList audioFilter, videoFilter, pictureFilter, docsFilter; + QFileInfoList homefiles; + QStringList favs; QList<QToolButton*> APPLIST; - + QDateTime lastHomeUpdate; + void initializeDesktop(); //bool readDesktopFile(QString path, QString &name, QString &iconpath); QAction* newAction(QString filepath, QString name, QString iconpath); QAction* newAction(QString filepath, QString name, QIcon icon); - void updateMenu(QMenu* menu, QFileInfoList files, bool trim = true); + //void updateMenu(QMenu* menu, QFileInfoList files, bool trim = true); private slots: diff --git a/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp b/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp index a04c6e43..5a6a9f09 100644 --- a/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp +++ b/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp @@ -1,15 +1,16 @@ //=========================================== // Lumina-DE source code -// Copyright (c) 2014, Ken Moore +// Copyright (c) 2014-2015, Ken Moore // Available under the 3-clause BSD license // See the LICENSE file for full details //=========================================== #include "UserItemWidget.h" +#include <LuminaUtils.h> -UserItemWidget::UserItemWidget(QWidget *parent, QString itemPath, bool isDir, bool goback) : QFrame(parent){ +UserItemWidget::UserItemWidget(QWidget *parent, QString itemPath, QString type, bool goback) : QFrame(parent){ createWidget(); //Now fill it appropriately - if(itemPath.endsWith(".desktop")){ + if(itemPath.endsWith(".desktop") || type=="app"){ bool ok = false; XDGDesktop item = LXDG::loadDesktopFile(itemPath, ok); if(ok){ @@ -19,7 +20,7 @@ UserItemWidget::UserItemWidget(QWidget *parent, QString itemPath, bool isDir, bo icon->setPixmap( LXDG::findIcon("unknown","").pixmap(32,32) ); name->setText( this->fontMetrics().elidedText(itemPath.section("/",-1), Qt::ElideRight, 180) ); } - }else if(isDir){ + }else if(type=="dir"){ if(itemPath.endsWith("/")){ itemPath.chop(1); } if(goback){ icon->setPixmap( LXDG::findIcon("go-previous","").pixmap(32,32) ); @@ -30,14 +31,17 @@ UserItemWidget::UserItemWidget(QWidget *parent, QString itemPath, bool isDir, bo } }else{ if(itemPath.endsWith("/")){ itemPath.chop(1); } - icon->setPixmap( LXDG::findMimeIcon(itemPath.section("/",-1)).pixmap(32,32) ); + icon->setPixmap( LXDG::findMimeIcon(type).pixmap(32,32) ); name->setText( this->fontMetrics().elidedText(itemPath.section("/",-1), Qt::ElideRight, 180) ); } - linkPath = QFile::symLinkTarget(itemPath); icon->setWhatsThis(itemPath); - if(isDir && !linkPath.isEmpty()){ isDir = false; } //not a real directory - just a sym link - isDirectory = isDir; //save this for later - isShortcut = itemPath.contains("/home/") && (itemPath.contains("/Desktop/") || itemPath.contains("/.lumina/favorites/") ); + isDirectory = (type=="dir"); //save this for later + if(LUtils::isFavorite(itemPath)){ + linkPath = itemPath; + isShortcut=true; + }else if( itemPath.section("/",0,-2)==QDir::homePath()+"/Desktop" ){ + isShortcut = true; + } //Now setup the button appropriately setupButton(goback); } @@ -45,8 +49,14 @@ UserItemWidget::UserItemWidget(QWidget *parent, QString itemPath, bool isDir, bo UserItemWidget::UserItemWidget(QWidget *parent, XDGDesktop item) : QFrame(parent){ createWidget(); isDirectory = false; - linkPath = QFile::symLinkTarget(item.filePath); - isShortcut = item.filePath.contains("/home/") && (item.filePath.contains("/Desktop/") || item.filePath.contains("/.lumina/favorites/") ); + if(LUtils::isFavorite(item.filePath)){ + linkPath = item.filePath; + isShortcut=true; + }else if( item.filePath.section("/",0,-2)==QDir::homePath()+"/Desktop" ){ + isShortcut = true; + }else{ + isShortcut = false; + } //Now fill it appropriately icon->setPixmap( LXDG::findIcon(item.icon,"preferences-system-windows-actions").pixmap(32,32) ); name->setText( this->fontMetrics().elidedText(item.name, Qt::ElideRight, 180) ); @@ -98,8 +108,8 @@ void UserItemWidget::setupButton(bool disable){ button->setToolTip(tr("Delete File")); } connect(button, SIGNAL(clicked()), this, SLOT(buttonClicked()) ); - }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 + }else if( !QFile::exists( QDir::homePath()+"/Desktop/"+icon->whatsThis().section("/",-1) ) && !LUtils::isFavorite(icon->whatsThis() ) ){ + //This file does not have a shortcut yet -- allow the user to add it button->setWhatsThis("add"); button->setIcon( LXDG::findIcon("bookmark-toolbar","") ); button->setToolTip(tr("Create Shortcut")); @@ -125,4 +135,4 @@ void UserItemWidget::ItemClicked(){ if(!linkPath.isEmpty()){ emit RunItem(linkPath); } else{ emit RunItem(icon->whatsThis()); } -}
\ No newline at end of file +} diff --git a/lumina-desktop/panel-plugins/userbutton/UserItemWidget.h b/lumina-desktop/panel-plugins/userbutton/UserItemWidget.h index 1f428ac4..a65d3e83 100644 --- a/lumina-desktop/panel-plugins/userbutton/UserItemWidget.h +++ b/lumina-desktop/panel-plugins/userbutton/UserItemWidget.h @@ -1,6 +1,6 @@ //=========================================== // Lumina-DE source code -// Copyright (c) 2014, Ken Moore +// Copyright (c) 2014-2015, Ken Moore // Available under the 3-clause BSD license // See the LICENSE file for full details //=========================================== @@ -25,7 +25,7 @@ class UserItemWidget : public QFrame{ Q_OBJECT public: - UserItemWidget(QWidget *parent=0, QString itemPath="", bool isDir=false, bool goback=false); + UserItemWidget(QWidget *parent=0, QString itemPath="", QString type="unknown", bool goback=false); UserItemWidget(QWidget *parent=0, XDGDesktop item= XDGDesktop()); ~UserItemWidget(); @@ -54,4 +54,4 @@ signals: }; -#endif
\ No newline at end of file +#endif diff --git a/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp b/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp index 52d60714..404fcc26 100644 --- a/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp +++ b/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp @@ -1,6 +1,6 @@ //=========================================== // Lumina-DE source code -// Copyright (c) 2014, Ken Moore +// Copyright (c) 2014-2015, Ken Moore // Available under the 3-clause BSD license // See the LICENSE file for full details //=========================================== @@ -85,6 +85,7 @@ UserWidget::UserWidget(QWidget* parent) : QTabWidget(parent), ui(new Ui::UserWid ui->tool_qtconfig->setVisible(false); } lastUpdate = QDateTime(); //make sure it refreshes + connect(LSession::handle()->applicationMenu(), SIGNAL(AppMenuUpdated()), this, SLOT(UpdateMenu()) ); QTimer::singleShot(10,this, SLOT(UpdateMenu())); //make sure to load this once after initialization } @@ -147,6 +148,7 @@ void UserWidget::LaunchItem(QString path, bool fix){ void UserWidget::FavChanged(){ //uncheck the current item for a moment + int oldfav = cfav; if(cfav==0){ ui->tool_fav_apps->setChecked(false); } else if(cfav==1){ ui->tool_fav_dirs->setChecked(false); } if(cfav==2){ ui->tool_fav_files->setChecked(false); } @@ -163,31 +165,53 @@ void UserWidget::FavChanged(){ ui->tool_fav_dirs->setChecked(cfav==1); ui->tool_fav_files->setChecked(cfav==2); } - updateFavItems(); + updateFavItems(oldfav!=cfav); } -void UserWidget::updateFavItems(){ - ClearScrollArea(ui->scroll_fav); - QFileInfoList items; - QDir homedir = QDir( QDir::homePath()+"/Desktop"); - QDir favdir = QDir( QDir::homePath()+"/.lumina/favorites"); - if(!favdir.exists()){ favdir.mkpath( QDir::homePath()+"/.lumina/favorites"); } +void UserWidget::updateFavItems(bool newfilter){ + QStringList newfavs = LUtils::listFavorites(); + //qDebug() << "Favorites:" << newfavs; + if(lastHomeUpdate.isNull() || (QFileInfo(QDir::homePath()+"/Desktop").lastModified() > lastHomeUpdate) || newfavs!=favs ){ + favs = newfavs; + + QDir homedir = QDir( QDir::homePath()+"/Desktop"); + homefiles = homedir.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot); + lastHomeUpdate = QDateTime::currentDateTime(); + }else if(!newfilter){ return; } //nothing new to change - stop now + QStringList favitems; + //Remember for format for favorites: <name>::::[app/dir/<mimetype>]::::<full path> if(ui->tool_fav_apps->isChecked()){ - items = homedir.entryInfoList(QStringList()<<"*.desktop", QDir::Files | QDir::NoDotAndDotDot, QDir::Name); - items << favdir.entryInfoList(QStringList()<<"*.desktop", QDir::Files | QDir::NoDotAndDotDot, QDir::Name); + favitems = favs.filter("::::app::::"); + for(int i=0; i<homefiles.length(); i++){ + if(homefiles[i].fileName().endsWith(".desktop")){ + favitems << homefiles[i].fileName()+"::::app::::"+homefiles[i].absoluteFilePath(); + } + } }else if(ui->tool_fav_dirs->isChecked()){ - items = homedir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name); - items << favdir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name); + favitems = favs.filter("::::dir::::"); + for(int i=0; i<homefiles.length(); i++){ + if(homefiles[i].isDir()){ + favitems << homefiles[i].fileName()+"::::dir::::"+homefiles[i].absoluteFilePath(); + } + } }else{ //Files - items = homedir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot, QDir::Name); - items << favdir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot, QDir::Name); - for(int i=0; i<items.length(); i++){ - if(items[i].suffix()=="desktop"){ items.removeAt(i); i--; } + for(int i=0; i<favs.length(); i++){ + QString type = favs[i].section("::::",1,1); + if(type != "app" && type !="dir"){ + favitems << favs[i]; + } + } + for(int i=0; i<homefiles.length(); i++){ + if(!homefiles[i].isDir() && !homefiles[i].fileName().endsWith(".desktop") ){ + favitems << homefiles[i].fileName()+"::::"+LXDG::findAppMimeForFile(homefiles[i].fileName())+"::::"+homefiles[i].absoluteFilePath(); + } } } - for(int i=0; i<items.length(); i++){ - UserItemWidget *it = new UserItemWidget(ui->scroll_fav->widget(), items[i].absoluteFilePath(), ui->tool_fav_dirs->isChecked()); + ClearScrollArea(ui->scroll_fav); + favitems.sort(); //sort them alphabetically + for(int i=0; i<favitems.length(); i++){ + UserItemWidget *it = new UserItemWidget(ui->scroll_fav->widget(), favitems[i].section("::::",2,50), favitems[i].section("::::",1,1) , ui->tool_fav_dirs->isChecked()); ui->scroll_fav->widget()->layout()->addWidget(it); connect(it, SIGNAL(RunItem(QString)), this, SLOT(LaunchItem(QString)) ); connect(it, SIGNAL(NewShortcut()), this, SLOT(updateFavItems()) ); @@ -195,15 +219,6 @@ void UserWidget::updateFavItems(){ } static_cast<QBoxLayout*>(ui->scroll_fav->widget()->layout())->addStretch(); - //Clean up any broken sym-links in the favorites directory - /*items = favdir.entryInfoList(QDir::System | QDir::NoDotAndDotDot, QDir::Name); - for(int i=0; i<items.length(); i++){ - if(items[i].isSymLink() && !items[i].exists()){ - //Broken sym-link - remove it - QFile::remove(items[i].absoluteFilePath()); - } - }*/ - } //Apps Tab @@ -268,8 +283,8 @@ void UserWidget::updateHome(){ for(int i=0; i<items.length(); i++){ //qDebug() << "New Home subdir:" << homedir.absoluteFilePath(items[i]); UserItemWidget *it; - if(items[i].startsWith("/")){ it = new UserItemWidget(ui->scroll_home->widget(), items[i], true, true); } - else{ it = new UserItemWidget(ui->scroll_home->widget(), homedir.absoluteFilePath(items[i]), true, false); } + if(items[i].startsWith("/")){ it = new UserItemWidget(ui->scroll_home->widget(), items[i], "dir", true); } + else{ it = new UserItemWidget(ui->scroll_home->widget(), homedir.absoluteFilePath(items[i]), "dir", false); } ui->scroll_home->widget()->layout()->addWidget(it); connect(it, SIGNAL(RunItem(QString)), this, SLOT(slotGoToDir(QString)) ); connect(it, SIGNAL(NewShortcut()), this, SLOT(updateFavItems()) ); @@ -300,4 +315,4 @@ void UserWidget::mouseMoveEvent( QMouseEvent *event){ qDebug() << " - Mouse over tab"; this->setCurrentIndex( wid->tabAt(relpos) ); } -}
\ No newline at end of file +} diff --git a/lumina-desktop/panel-plugins/userbutton/UserWidget.h b/lumina-desktop/panel-plugins/userbutton/UserWidget.h index c7af2a4d..8f5ba852 100644 --- a/lumina-desktop/panel-plugins/userbutton/UserWidget.h +++ b/lumina-desktop/panel-plugins/userbutton/UserWidget.h @@ -42,7 +42,9 @@ public slots: private: Ui::UserWidget *ui; QHash<QString, QList<XDGDesktop> > *sysapps; - QDateTime lastUpdate; + QDateTime lastUpdate, lastHomeUpdate; + QStringList favs; + QFileInfoList homefiles; int cfav; //current favorite category void ClearScrollArea(QScrollArea *area); QIcon rotateIcon(QIcon); @@ -52,7 +54,7 @@ private slots: //Favorites Tab void FavChanged(); //for ensuring radio-button-like behaviour - void updateFavItems(); + void updateFavItems(bool newfilter = true); //if false, will only update if filesystem changes //Apps Tab void updateAppCategories(); |