From ea486c90fb48769a7d56cd4aefe919417d4afbd5 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Mon, 23 Nov 2015 10:42:11 -0500 Subject: Fix up the sorting of the favorites items in the start menu. Now the applications will be sorted by display name instead of file name (case-insensitive). The favorites are still sorted by type as well (apps, dirs, files), each type sorted alphabetically. --- .../panel-plugins/systemstart/StartMenu.cpp | 32 +++++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'lumina-desktop/panel-plugins/systemstart/StartMenu.cpp') diff --git a/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp b/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp index 3c418ac5..661302dc 100644 --- a/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp +++ b/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp @@ -10,6 +10,7 @@ #include #include "../../LSession.h" +#include #include "ItemWidget.h" //#define SSAVER QString("xscreensaver-demo") @@ -250,10 +251,7 @@ void StartMenu::UpdateApps(){ ItemWidget *it = new ItemWidget(ui->scroll_apps->widget(), cats[c], "chcat::::"+cats[c] ); if(!it->gooditem){ continue; } //invalid for some reason ui->scroll_apps->widget()->layout()->addWidget(it); - //connect(it, SIGNAL(NewShortcut()), this, SLOT(UpdateFavs()) ); - //connect(it, SIGNAL(RemovedShortcut()), this, SLOT(UpdateFavs()) ); connect(it, SIGNAL(RunItem(QString)), this, SLOT(LaunchItem(QString)) ); - //connect(it, SIGNAL(toggleQuickLaunch(QString, bool)), this, SLOT(UpdateQuickLaunch(QString, bool)) ); } }else{ //Show the "go back" button @@ -303,11 +301,37 @@ void StartMenu::UpdateFavs(){ favs.sort(); //Iterate over types of favorites QStringList rest = favs; + QStringList tmp; for(int type = 0; type<3; type++){ - QStringList tmp; if(type==0){ tmp = favs.filter("::::app::::"); } //apps first else if(type==1){ tmp = favs.filter("::::dir::::"); } //dirs next else{ tmp = rest; } //everything left over + if(type==1){ + //Need to run a special routine for sorting the apps (already in the widget) + // Since each app actually might have a different name listed within the file + QLayout *lay = ui->scroll_favs->widget()->layout(); + QStringList items; + for(int i=0; icount(); i++){ + items << lay->itemAt(i)->widget()->whatsThis().toLower(); + } + + items.sort(); + //qDebug() << " - Sorted Items:" << items; + for(int i=0; icount(); j++){ + //Find this item + if(lay->itemAt(j)->widget()->whatsThis().toLower()==items[i]){ + //Found it - now move it if necessary + //qDebug() << "Found Item:" << items[i] << i << j; + lay->addItem( lay->takeAt(j) ); + break; + } + } + } + }//end of special app sorting routine + tmp.sort(); //Sort alphabetically by name (dirs/files) for(int i=0; i