aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp
diff options
context:
space:
mode:
authorWeblate <noreply@weblate.org>2016-09-23 23:45:20 +0000
committerWeblate <noreply@weblate.org>2016-09-23 23:45:20 +0000
commitcb2aab6a2437990cb10b0c980ad4f9091098b6b6 (patch)
treef55a78353fc8a8ef2e27b8a4f47fa6a2e7eb0c65 /src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp
parentTranslated using Weblate (lumina_FM@ca (generated)) (diff)
parentMerge remote-tracking branch 'origin/master' (diff)
downloadlumina-cb2aab6a2437990cb10b0c980ad4f9091098b6b6.tar.gz
lumina-cb2aab6a2437990cb10b0c980ad4f9091098b6b6.tar.bz2
lumina-cb2aab6a2437990cb10b0c980ad4f9091098b6b6.zip
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp')
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp62
1 files changed, 44 insertions, 18 deletions
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp
index ae61760b..bfac46c0 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp
+++ b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp
@@ -155,22 +155,45 @@ void StartMenu::UpdateQuickLaunch(QString path, bool keep){
// ==========================
// PRIVATE FUNCTIONS
// ==========================
-void StartMenu::deleteChildren(QObject *obj){
-for(int i=0; i<obj->children().count(); i++){ obj->children().at(i)->deleteLater(); }
-}
+/*void StartMenu::deleteChildren(QWidget *obj){
+ if(obj->layout()==0){
+ for(int i=0; i<obj->children().count(); i++){
+ obj->children().at(i)->deleteLater();
+ }
+ }else{
+
+ }
+}*/
void StartMenu::ClearScrollArea(QScrollArea *area){
- QWidget *old = area->takeWidget();
- deleteChildren(old); //make sure we *fully* delete these items to save memory
- old->deleteLater();
- area->setWidget( new QWidget() ); //create a new widget in the scroll area
- area->widget()->setContentsMargins(0,0,0,0);
- QVBoxLayout *layout = new QVBoxLayout;
+ //QWidget *old = area->takeWidget();
+ //qDebug() << "Clear Scroll Area:";
+ //if(old->layout()!=0){ qDebug() << " - Number of items in layout:" << old->layout()->count(); }
+ //qDebug() << " - Number of Children:" << old->children().count();
+ //deleteChildren(old); //make sure we *fully* delete these items to save memory
+ //old->deleteLater();
+ if(area == ui->scroll_favs){
+ area->takeWidget()->deleteLater();
+ }
+ if(area->widget()==0){
+ area->setWidget( new QWidget(area) ); //create a new widget in the scroll area
+ }
+ if(area->widget()->layout()==0){
+ QVBoxLayout *layout = new QVBoxLayout(area->widget());
layout->setSpacing(2);
layout->setContentsMargins(3,1,3,1);
layout->setDirection(QBoxLayout::TopToBottom);
layout->setAlignment(Qt::AlignTop);
+ area->widget()->setContentsMargins(0,0,0,0);
area->widget()->setLayout(layout);
+ }
+ //Now clear the items in the layout
+ while( area->widget()->layout()->count() >0 ){
+ QLayoutItem *it = area->widget()->layout()->takeAt(0);
+ //Need to delete both the widget and the layout item
+ if(it->widget()!=0){ it->widget()->deleteLater(); }
+ delete it;
+ }
}
void StartMenu::SortScrollArea(QScrollArea *area){
@@ -303,8 +326,8 @@ void StartMenu::ChangeCategory(QString cat){
//Listing Update routines
void StartMenu::UpdateApps(){
ClearScrollArea(ui->scroll_apps);
- //Now assemble the apps list (note: this normally happens in the background - not when it is visible/open)
- //qDebug() << "Update Apps:" << CCat << ui->check_apps_showcats->checkState();
+ //Now assemble the apps list
+ //qDebug() << "Update Apps:";// << CCat << ui->check_apps_showcats->checkState();
if(ui->check_apps_showcats->checkState() == Qt::PartiallyChecked){
//qDebug() << " - Partially Checked";
//Show a single page of apps, but still divided up by categories
@@ -322,7 +345,7 @@ void StartMenu::UpdateApps(){
//Now add all the apps for this category
for(int i=0; i<apps.length(); i++){
ItemWidget *it = new ItemWidget(ui->scroll_apps->widget(), apps[i] );
- if(!it->gooditem){ continue; } //invalid for some reason
+ if(!it->gooditem){ qDebug() << "Invalid Item:"; it->deleteLater(); 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()) );
@@ -341,7 +364,7 @@ void StartMenu::UpdateApps(){
cats.removeAll("All"); //This is not a "real" category
for(int c=0; c<cats.length(); c++){
ItemWidget *it = new ItemWidget(ui->scroll_apps->widget(), cats[c], "chcat::::"+cats[c] );
- if(!it->gooditem){ continue; } //invalid for some reason
+ if(!it->gooditem){ qDebug() << "Invalid Item:";it->deleteLater(); continue; } //invalid for some reason
ui->scroll_apps->widget()->layout()->addWidget(it);
connect(it, SIGNAL(RunItem(QString)), this, SLOT(LaunchItem(QString)) );
}
@@ -357,7 +380,7 @@ void StartMenu::UpdateApps(){
for(int i=0; i<apps.length(); i++){
//qDebug() << " - App:" << apps[i].name;
ItemWidget *it = new ItemWidget(ui->scroll_apps->widget(), apps[i] );
- if(!it->gooditem){ continue; } //invalid for some reason
+ if(!it->gooditem){ qDebug() << "Invalid Item:"; it->deleteLater(); 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()) );
@@ -372,9 +395,9 @@ void StartMenu::UpdateApps(){
QList<XDGDesktop*> apps = LSession::handle()->applicationMenu()->currentAppHash()->value("All");
CCat.clear();
//Now add all the apps for this category
- for(int i=0; i<apps.length(); i++){
+ for(int i=0; i<apps.length(); i++){
ItemWidget *it = new ItemWidget(ui->scroll_apps->widget(), apps[i] );
- if(!it->gooditem){ continue; } //invalid for some reason
+ if(!it->gooditem){ it->deleteLater(); 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()) );
@@ -401,10 +424,11 @@ void StartMenu::UpdateFavs(){
else if(type==1){ tmp = favs.filter("::::dir::::"); } //dirs next
else{ tmp = rest; } //everything left over
if(type==1){
+ SortScrollArea(ui->scroll_favs);
//Need to run a special routine for sorting the apps (already in the widget)
//qDebug() << "Sort App Widgets...";
// Since each app actually might have a different name listed within the file
- QLayout *lay = ui->scroll_favs->widget()->layout();
+ /*QLayout *lay = ui->scroll_favs->widget()->layout();
QStringList items;
for(int i=0; i<lay->count(); i++){
items << lay->itemAt(i)->widget()->whatsThis().toLower();
@@ -424,7 +448,8 @@ void StartMenu::UpdateFavs(){
break;
}
}
- }
+ }*/
+
}//end of special app sorting routine
tmp.sort(); //Sort alphabetically by name (dirs/files)
for(int i=0; i<tmp.length(); i++){
@@ -447,6 +472,7 @@ void StartMenu::UpdateFavs(){
}
//QApplication::processEvents();
} //end loop over types
+ ui->scroll_favs->update();
//qDebug() << "End updateFavs";
}
bgstack15