void MainUI::slotUpdateBrowserHome(){ //Load the Recommendations ui->group_br_recommend->setVisible( fillVerticalAppArea(ui->scroll_br_home_rec, PBI->getRecommendedApps(), false) ); //Load the application spotlight ui->group_br_home_spotlight->setVisible( fillVerticalAppArea(ui->scroll_br_home_spot, PBI->getHighlightedApps(), false) ); //Load the newest applications clearScrollArea(ui->scroll_br_home_newapps); QHBoxLayout *newapplayout = new QHBoxLayout; QStringList newapps = PBI->getNewApps(); QList<NGApp> apps = PBI->AppInfo(newapps); for(int i=0; i<apps.length(); i++){ //QStringList appdata = PBI->AppInfo(newapps[i],QStringList() << "name" << "icon" << "latestversion"); //if(!appdata.isEmpty()){ SmallItemWidget *item = new SmallItemWidget(apps[i].origin, apps[i].name, checkIcon(apps[i].icon, apps[i].type), apps[i].version); connect(item,SIGNAL(appClicked(QString)),this,SLOT(slotGoToApp(QString)) ); newapplayout->addWidget(item); //} } newapplayout->addStretch(); //add a spacer to the end newapplayout->setContentsMargins(0,0,0,0); newapplayout->setSpacing(0); ui->scroll_br_home_newapps->widget()->setLayout(newapplayout); //Make sure that the newapps scrollarea is the proper fit vertically (no vertical scrolling) ui->scroll_br_home_newapps->setMinimumHeight(ui->scroll_br_home_newapps->widget()->minimumSizeHint().height()); //Make sure the new apps area is invisible if no items available if(newapps.isEmpty()){ ui->group_br_home_newapps->setVisible(FALSE); } else{ ui->group_br_home_newapps->setVisible(TRUE); } //make sure the home page is visible in the browser (slotGoToHome without changing tabs) ui->stacked_browser->setCurrentWidget(ui->page_home); //Make sure the shortcut buttons are disabled ui->tool_browse_cat->setVisible(FALSE); ui->tool_browse_app->setVisible(FALSE); //Now update the category browser page (since it only needs to be done once like the home menu) //Load the Categories QStringList catlist = PBI->browserCategories(); catlist.sort(); QList<NGCat> cats = PBI->CatInfo(catlist); //all categories clearScrollArea(ui->scroll_br_cats); QVBoxLayout *catlayout = new QVBoxLayout; for(int i=0; i<cats.length(); i++){ LargeItemWidget *item = new LargeItemWidget(this,cats[i]); connect(item,SIGNAL(appClicked(QString)),this,SLOT(slotGoToCategory(QString)) ); catlayout->addWidget(item); } catlayout->addStretch(); //add a spacer to the end ui->scroll_br_cats->widget()->setLayout(catlayout); }
bool MainUI::fillVerticalAppArea( QScrollArea* area, QStringList applist, bool filter){ //clear the scroll area first clearScrollArea(area); bool ok = false; //returns whether any apps were shown after filtering //Re-create the layout QVBoxLayout *layout = new QVBoxLayout; QList<NGApp> apps = PBI->AppInfo(applist); for(int i=0; i<apps.length(); i++){ bool goodApp = false; if(apps[i].type.toLower()=="graphical"){goodApp = ui->actionGraphical_Apps->isChecked(); } else if(apps[i].type.toLower()=="text"){goodApp = ui->actionText_Apps->isChecked(); } else if(apps[i].type.toLower()=="server"){goodApp = ui->actionServer_Apps->isChecked(); } else{goodApp = ui->actionRaw_Packages->isChecked(); } if( !filter || goodApp){ LargeItemWidget *item = new LargeItemWidget(this,apps[i], checkIcon(apps[i].icon, apps[i].type) ); connect(item,SIGNAL(appClicked(QString)),this,SLOT(slotGoToApp(QString)) ); layout->addWidget(item); ok = true; } } layout->addStretch(); area->widget()->setLayout(layout); return ok; }
void StatusBar::onAppClicked(int id) { emit appClicked(id); }