aboutsummaryrefslogtreecommitdiff
path: root/lumina-desktop/panel-plugins/userbutton
diff options
context:
space:
mode:
Diffstat (limited to 'lumina-desktop/panel-plugins/userbutton')
-rw-r--r--lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp23
-rw-r--r--lumina-desktop/panel-plugins/userbutton/UserWidget.cpp14
2 files changed, 22 insertions, 15 deletions
diff --git a/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp b/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp
index ad1c2fd6..4a274cdf 100644
--- a/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp
+++ b/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp
@@ -10,6 +10,8 @@
UserItemWidget::UserItemWidget(QWidget *parent, QString itemPath, QString type, bool goback) : QFrame(parent){
createWidget();
//Now fill it appropriately
+ bool inHome = type.endsWith("-home"); //internal code
+ if(inHome){ type = type.remove("-home"); }
if(itemPath.endsWith(".desktop") || type=="app"){
bool ok = false;
XDGDesktop item = LXDG::loadDesktopFile(itemPath, ok);
@@ -39,8 +41,10 @@ UserItemWidget::UserItemWidget(QWidget *parent, QString itemPath, QString type,
if(LUtils::isFavorite(itemPath)){
linkPath = itemPath;
isShortcut=true;
- }else if( itemPath.section("/",0,-2)==QDir::homePath()+"/Desktop" ){
+ }else if( inHome ){//|| itemPath.section("/",0,-2)==QDir::homePath()+"/Desktop" ){
isShortcut = true;
+ }else{
+ isShortcut = false;
}
//Now setup the button appropriately
setupButton(goback);
@@ -95,20 +99,21 @@ void UserItemWidget::createWidget(){
}
void UserItemWidget::setupButton(bool disable){
+ if(isDirectory){ qDebug() << "Directory Entry:" << isShortcut << linkPath << icon->whatsThis(); }
+
if(disable){
button->setVisible(false);
- }else if( !isDirectory && isShortcut ){
- //This is a current desktop shortcut -- allow the user to remove it
- button->setWhatsThis("remove");
- if(!linkPath.isEmpty()){
+ }else if(isShortcut && !linkPath.isEmpty()){ //Favorite Item - can always remove this
+ button->setWhatsThis("remove");
button->setIcon( LXDG::findIcon("list-remove","") );
button->setToolTip(tr("Remove Shortcut"));
- }else{
+ connect(button, SIGNAL(clicked()), this, SLOT(buttonClicked()) );
+ }else if(isShortcut && !isDirectory){ //Physical File - can remove
+ button->setWhatsThis("remove");
button->setIcon( LXDG::findIcon("user-trash","") );
button->setToolTip(tr("Delete File"));
- }
- connect(button, SIGNAL(clicked()), this, SLOT(buttonClicked()) );
- }else if( !QFile::exists( QDir::homePath()+"/Desktop/"+icon->whatsThis().section("/",-1) ) && !LUtils::isFavorite(icon->whatsThis() ) ){
+ connect(button, SIGNAL(clicked()), this, SLOT(buttonClicked()) );
+ }else if(!isShortcut){// 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","") );
diff --git a/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp b/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp
index 9c002109..d1173ee1 100644
--- a/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp
+++ b/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp
@@ -186,14 +186,14 @@ void UserWidget::updateFavItems(bool newfilter){
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();
+ favitems << homefiles[i].fileName()+"::::app-home::::"+homefiles[i].absoluteFilePath();
}
}
}else if(ui->tool_fav_dirs->isChecked()){
favitems = favs.filter("::::dir::::");
for(int i=0; i<homefiles.length(); i++){
if(homefiles[i].isDir()){
- favitems << homefiles[i].fileName()+"::::dir::::"+homefiles[i].absoluteFilePath();
+ favitems << homefiles[i].fileName()+"::::dir-home::::"+homefiles[i].absoluteFilePath();
}
}
}else{
@@ -206,14 +206,14 @@ void UserWidget::updateFavItems(bool newfilter){
}
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();
+ favitems << homefiles[i].fileName()+"::::"+LXDG::findAppMimeForFile(homefiles[i].fileName())+"-home::::"+homefiles[i].absoluteFilePath();
}
}
}
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());
+ UserItemWidget *it = new UserItemWidget(ui->scroll_fav->widget(), favitems[i].section("::::",2,50), favitems[i].section("::::",1,1) );
ui->scroll_fav->widget()->layout()->addWidget(it);
connect(it, SIGNAL(RunItem(QString)), this, SLOT(LaunchItem(QString)) );
connect(it, SIGNAL(NewShortcut()), this, SLOT(updateFavItems()) );
@@ -282,11 +282,13 @@ void UserWidget::updateHome(){
}
ui->label_home_dir->setToolTip(ui->label_home_dir->whatsThis());
items << homedir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
+ QString type = "dir";
+ if(homedir.absolutePath() == QDir::homePath()+"/Desktop"){ type.append("-home"); }//internal code
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], "dir", true); }
- else{ it = new UserItemWidget(ui->scroll_home->widget(), homedir.absoluteFilePath(items[i]), "dir", false); }
+ if(items[i].startsWith("/")){ it = new UserItemWidget(ui->scroll_home->widget(), items[i], type, true); }
+ else{ it = new UserItemWidget(ui->scroll_home->widget(), homedir.absoluteFilePath(items[i]), type, false); }
ui->scroll_home->widget()->layout()->addWidget(it);
connect(it, SIGNAL(RunItem(QString)), this, SLOT(slotGoToDir(QString)) );
connect(it, SIGNAL(NewShortcut()), this, SLOT(updateFavItems()) );
bgstack15