Changeset 6156865


Ignore:
Timestamp:
08/07/13 06:47:58 (15 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1, releng/10.0.2, releng/10.0.3, releng/10.1
Children:
de1ea77
Parents:
1030769
Message:

Setup the AppCafe? UI to refresh status updates faster

Location:
src-qt4/pc-softwaremanager
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/pc-softwaremanager/mainUI.cpp

    re46485b r6156865  
    266266    }  
    267267  } 
    268   on_tree_install_apps_itemSelectionChanged(); //Update the info boxes 
     268  slotUpdateSelectedPBI();; //Update the info boxes 
    269269  slotDisplayStats(); 
    270270} 
     
    282282      } 
    283283      if ( appID == pbiID ) { 
    284         on_tree_install_apps_itemSelectionChanged(); 
     284        slotUpdateSelectedPBI(true);; //only update status 
    285285      } 
    286286      return; // Found our match, we can return now 
     
    314314void MainUI::on_tree_install_apps_itemSelectionChanged(){ 
    315315  //When an installed PBI is clicked on 
     316  slotUpdateSelectedPBI(); 
     317} 
     318 
     319void MainUI::on_check_install_autoupdate_clicked(){ 
     320  //Get the current item 
     321  QString appID; 
     322  if(ui->tree_install_apps->topLevelItemCount() > 0){ 
     323    appID = ui->tree_install_apps->currentItem()->whatsThis(0); 
     324  } 
     325  if(appID.isEmpty()){return;} 
     326  //Now determine the current state of the checkbox 
     327  bool enabled = ui->check_install_autoupdate->isChecked(); 
     328  //Now have the backend make the change 
     329  PBI->enableAutoUpdate(appID, enabled); 
     330} 
     331 
     332void MainUI::on_tool_install_update_clicked(){ 
     333  //Get the current item 
     334  QString appID; 
     335  if(ui->tree_install_apps->topLevelItemCount() > 0){ 
     336    appID = ui->tree_install_apps->currentItem()->whatsThis(0); 
     337  } 
     338  if(appID.isEmpty()){return;} 
     339  PBI->upgradePBI(QStringList() << appID); 
     340} 
     341 
     342void MainUI::on_tool_install_remove_clicked(){ 
     343  //Get the current item 
     344  QString appID; 
     345  if(ui->tree_install_apps->topLevelItemCount() > 0){ 
     346    appID = ui->tree_install_apps->currentItem()->whatsThis(0); 
     347  } 
     348  if(appID.isEmpty()){return;} 
     349  //Verify removal 
     350  if( QMessageBox::Yes == QMessageBox::question(this,tr("Verify PBI Removal"), tr("Are you sure you wish to remove this application?")+"\n\n"+appID,QMessageBox::Yes | QMessageBox::Cancel,QMessageBox::Cancel) ){ 
     351    PBI->removePBI(QStringList() << appID); 
     352  } 
     353} 
     354 
     355void MainUI::on_tool_install_cancel_clicked(){ 
     356  //Get the current item 
     357  QString appID; 
     358  if(ui->tree_install_apps->topLevelItemCount() > 0){ 
     359    appID = ui->tree_install_apps->currentItem()->whatsThis(0); 
     360  } 
     361  if(appID.isEmpty()){return;} 
     362  PBI->cancelActions(QStringList() << appID); 
     363   
     364} 
     365 
     366// === SELECTED PBI ACTIONS === 
     367void MainUI::slotActionAddDesktop(){ 
     368  QStringList items = getCheckedItems(); 
     369  PBI->addDesktopIcons(items,FALSE); //only for current user 
     370} 
     371 
     372void MainUI::slotActionRemoveDesktop(){ 
     373  QStringList items = getCheckedItems(); 
     374  PBI->rmDesktopIcons(items,FALSE);  //Only for current user 
     375} 
     376 
     377void MainUI::slotActionAddPath(){ 
     378  QStringList items = getCheckedItems(); 
     379  PBI->addPaths(items,FALSE);  //Only for current user   
     380} 
     381 
     382void MainUI::slotActionRemovePath(){ 
     383  QStringList items = getCheckedItems(); 
     384  PBI->rmPaths(items,FALSE);  //Only for current user 
     385} 
     386 
     387void MainUI::slotActionAddPathAll(){ 
     388  QStringList items = getCheckedItems(); 
     389  PBI->addPaths(items,TRUE);  //For all users (root permissions required) 
     390} 
     391 
     392void MainUI::slotActionAddMenu(){ 
     393  QStringList items = getCheckedItems(); 
     394  PBI->addMenuIcons(items,FALSE);  //Only for current user 
     395} 
     396 
     397void MainUI::slotActionRemoveMenu(){ 
     398  QStringList items = getCheckedItems(); 
     399  PBI->rmMenuIcons(items,FALSE);  //Only for current user        
     400} 
     401 
     402void MainUI::slotActionAddMenuAll(){ 
     403  QStringList items = getCheckedItems(); 
     404  PBI->addMenuIcons(items,TRUE);  //For all users (root permissions required)    
     405} 
     406 
     407void MainUI::slotActionAddMime(){ 
     408  QStringList items = getCheckedItems(); 
     409  PBI->addMimeTypes(items,FALSE);  //Only for current user       
     410} 
     411 
     412void MainUI::slotActionRemoveMime(){ 
     413  QStringList items = getCheckedItems(); 
     414  PBI->rmMimeTypes(items,FALSE);  //Only for current user        
     415} 
     416 
     417void MainUI::slotActionAddMimeAll(){ 
     418    QStringList items = getCheckedItems(); 
     419  PBI->addMimeTypes(items,TRUE);  //For all users (root permissions required)    
     420} 
     421 
     422void MainUI::slotActionUpdate(){ 
     423  QStringList checkedID = getCheckedItems(); 
     424  if(!checkedID.isEmpty()){ 
     425    PBI->upgradePBI(checkedID);   
     426  } 
     427} 
     428 
     429void MainUI::slotActionRemove(){ 
     430  QStringList checkedID = getCheckedItems(); 
     431  if(!checkedID.isEmpty()){ 
     432    //Verify that the user really wants to remove these apps 
     433    if( QMessageBox::Yes == QMessageBox::question(this,tr("Verify PBI Removal"), tr("Are you sure you wish to remove these applications?")+"\n\n"+checkedID.join("\n"),QMessageBox::Yes | QMessageBox::Cancel,QMessageBox::Cancel) ){ 
     434      PBI->removePBI(checkedID); 
     435    } 
     436  } 
     437} 
     438 
     439void MainUI::slotActionCancel(){ 
     440  QStringList checkedID = getCheckedItems(); 
     441  if(!checkedID.isEmpty()){ 
     442    PBI->cancelActions(checkedID);   
     443  } 
     444} 
     445 
     446void MainUI::slotStartApp(QAction* act){ 
     447  qDebug() << "Starting external application:" << act->text(); 
     448  //Get the command from the action 
     449  QString desktopfile = act->whatsThis(); 
     450  QString cmd = "xdg-open "+desktopfile; 
     451  //Startup the command externally 
     452  QProcess::startDetached(cmd); 
     453} 
     454 
     455void MainUI::slotUpdateSelectedPBI(bool statusonly){ 
    316456  QString appID; 
    317457  if(ui->tree_install_apps->topLevelItemCount() > 0){ 
     
    324464    ui->group_install_info->setVisible( ui->group_install_showinfo->isChecked() );         
    325465  } 
    326  
    327   //Get the PBI info for that item 
    328   QStringList vals;  
    329   vals << "name" << "icon" << "author" << "website" << "version" << "license"; 
    330   QStringList bools; 
    331   bools << "autoupdate" << "hasdesktopicons" << "hasmenuicons" << "requiresroot"; 
    332   vals = PBI->PBIInfo(appID,vals); 
    333   bools = PBI->PBIInfo(appID,bools); 
    334   //Make sure the info lists are not empty 
    335   if(vals.isEmpty() || bools.isEmpty()){ 
    336     ui->group_install_info->setVisible(FALSE); 
    337     return;  
    338   } 
    339   //Load a default icon if none found 
    340   if(vals[1].isEmpty()){ vals[1] = defaultIcon; } 
    341   //Now set the info on the UI 
    342   bool desktopSC = (bools[1] == "true"); // XDG desktop entries available 
    343   bool menuSC= (bools[2] == "true");     // XDG menu entries available 
    344   bool autoupdate = (bools[0] == "true"); //auto-update enabled 
    345   bool rootonly = (bools[3] == "true"); //requires root 
    346   //Create the shortcuts string 
    347   QString shortcuts; 
    348     if(desktopSC && menuSC){ shortcuts = tr("Desktop/Menu"); } 
    349     else if(desktopSC){ shortcuts = tr("Desktop"); } 
    350     else if(menuSC){ shortcuts = tr("Menu"); } 
    351     else{ shortcuts = tr("None"); } 
    352   //Now display that info on the UI 
    353   ui->label_install_app->setText(vals[0]); 
    354   ui->tool_install_icon->setIcon( QIcon(vals[1]) ); 
    355   if(vals[3].isEmpty()){  
    356     ui->label_install_author->setText(vals[2]);  
    357     ui->label_install_author->setToolTip(""); 
    358   }else{  
    359     ui->label_install_author->setText("<a href="+vals[3]+">"+vals[2]+"</a>");  
    360     ui->label_install_author->setToolTip(vals[3]); //show website URL as tooltip 
    361   } 
    362   ui->label_install_license->setText(vals[5]); 
    363   ui->label_install_version->setText(vals[4]); 
    364   ui->label_install_shortcuts->setText(shortcuts); 
    365   ui->check_install_autoupdate->setChecked(autoupdate); 
     466  if(!statusonly){ 
     467    //Get the PBI info for that item 
     468    QStringList vals;  
     469    vals << "name" << "icon" << "author" << "website" << "version" << "license"; 
     470    QStringList bools; 
     471    bools << "autoupdate" << "hasdesktopicons" << "hasmenuicons" << "requiresroot"; 
     472    vals = PBI->PBIInfo(appID,vals); 
     473    bools = PBI->PBIInfo(appID,bools); 
     474    //Make sure the info lists are not empty 
     475    if(vals.isEmpty() || bools.isEmpty()){ 
     476      ui->group_install_info->setVisible(FALSE); 
     477      return;  
     478    } 
     479    //Load a default icon if none found 
     480    if(vals[1].isEmpty()){ vals[1] = defaultIcon; } 
     481    //Now set the info on the UI 
     482    bool desktopSC = (bools[1] == "true"); // XDG desktop entries available 
     483    bool menuSC= (bools[2] == "true");   // XDG menu entries available 
     484    bool autoupdate = (bools[0] == "true"); //auto-update enabled 
     485    bool rootonly = (bools[3] == "true"); //requires root 
     486    //Create the shortcuts string 
     487    QString shortcuts; 
     488      if(desktopSC && menuSC){ shortcuts = tr("Desktop/Menu"); } 
     489      else if(desktopSC){ shortcuts = tr("Desktop"); } 
     490      else if(menuSC){ shortcuts = tr("Menu"); } 
     491      else{ shortcuts = tr("None"); } 
     492    //Now display that info on the UI 
     493    ui->label_install_app->setText(vals[0]); 
     494    ui->tool_install_icon->setIcon( QIcon(vals[1]) ); 
     495    if(vals[3].isEmpty()){  
     496      ui->label_install_author->setText(vals[2]);  
     497      ui->label_install_author->setToolTip(""); 
     498    }else{  
     499      ui->label_install_author->setText("<a href="+vals[3]+">"+vals[2]+"</a>");  
     500      ui->label_install_author->setToolTip(vals[3]); //show website URL as tooltip 
     501    } 
     502    ui->label_install_license->setText(vals[5]); 
     503    ui->label_install_version->setText(vals[4]); 
     504    ui->label_install_shortcuts->setText(shortcuts); 
     505    ui->check_install_autoupdate->setChecked(autoupdate); 
    366506   
    367   //Adjust the quick action buttons as necessary 
    368   if( PBI->isWorking(appID) ){ 
    369     //Actions pending/working only show cancel button 
    370     ui->tool_install_cancel->setVisible(TRUE); 
    371     ui->tool_install_remove->setVisible(FALSE); 
    372     ui->tool_install_update->setVisible(FALSE); 
    373   }else{ 
    374     //Nothing pending 
    375     ui->tool_install_cancel->setVisible(FALSE); 
    376     if( !PBI->isInstalled(appID).isEmpty() ){  
    377       //Remove Button 
    378       ui->tool_install_remove->setVisible(TRUE); 
    379       if(rootonly){ ui->tool_install_remove->setIcon(QIcon(":icons/remove-root.png")); } 
    380       else{ ui->tool_install_remove->setIcon(QIcon(":icons/remove.png")); } 
    381       //Update 
    382       if(PBI->upgradeAvailable(appID).isEmpty()){ ui->tool_install_update->setVisible(FALSE); } 
    383       else{ 
    384         ui->tool_install_update->setVisible(TRUE);  
    385         if(rootonly){ ui->tool_install_update->setIcon(QIcon(":icons/app_upgrade_small-root.png")); } 
    386         else{ ui->tool_install_update->setIcon(QIcon(":icons/app_upgrade_small.png")); } 
    387       } 
    388     }else{  
    389       ui->tool_install_remove->setVisible(FALSE);  
    390       ui->tool_install_update->setVisible(FALSE);  
    391     }    
     507    //Adjust the quick action buttons as necessary 
     508    if( PBI->isWorking(appID) ){ 
     509      //Actions pending/working only show cancel button 
     510      ui->tool_install_cancel->setVisible(TRUE); 
     511      ui->tool_install_remove->setVisible(FALSE); 
     512      ui->tool_install_update->setVisible(FALSE); 
     513    }else{ 
     514      //Nothing pending 
     515      ui->tool_install_cancel->setVisible(FALSE); 
     516      if( !PBI->isInstalled(appID).isEmpty() ){  
     517        //Remove Button 
     518        ui->tool_install_remove->setVisible(TRUE); 
     519        if(rootonly){ ui->tool_install_remove->setIcon(QIcon(":icons/remove-root.png")); } 
     520        else{ ui->tool_install_remove->setIcon(QIcon(":icons/remove.png")); } 
     521        //Update 
     522        if(PBI->upgradeAvailable(appID).isEmpty()){ ui->tool_install_update->setVisible(FALSE); } 
     523        else{ 
     524          ui->tool_install_update->setVisible(TRUE);  
     525          if(rootonly){ ui->tool_install_update->setIcon(QIcon(":icons/app_upgrade_small-root.png")); } 
     526          else{ ui->tool_install_update->setIcon(QIcon(":icons/app_upgrade_small.png")); } 
     527        } 
     528      }else{  
     529        ui->tool_install_remove->setVisible(FALSE);  
     530        ui->tool_install_update->setVisible(FALSE);  
     531      }    
     532    } 
    392533  } 
    393534  //Update the current status indicators 
     
    423564      ui->label_install_DL->setVisible(FALSE); 
    424565  } 
    425   //Get the application binaries and set the icon to start them 
    426   QStringList bins = PBI->pbiBinList(appID); 
    427   appBinMenu->clear(); 
    428   if(bins.isEmpty()){ 
    429     ui->tool_install_icon->setAutoRaise(false); 
    430   }else{ 
    431     ui->tool_install_icon->setAutoRaise(true); 
    432     for(int i=0; i<bins.length(); i++){ 
    433       QAction *act = new QAction(this); 
     566  if(!statusonly){ 
     567    //Get the application binaries and set the icon to start them 
     568    QStringList bins = PBI->pbiBinList(appID); 
     569    appBinMenu->clear(); 
     570    if(bins.isEmpty()){ 
     571      ui->tool_install_icon->setAutoRaise(false); 
     572    }else{ 
     573      ui->tool_install_icon->setAutoRaise(true); 
     574      for(int i=0; i<bins.length(); i++){ 
     575        QAction *act = new QAction(this); 
    434576            act->setText(bins[i].section("::::",0,0)); //set name 
    435577            act->setWhatsThis(bins[i].section("::::",1,10)); //set command string 
    436       appBinMenu->addAction(act); 
    437     } 
    438   } 
    439 } 
    440  
    441 void MainUI::on_check_install_autoupdate_clicked(){ 
    442   //Get the current item 
    443   QString appID; 
    444   if(ui->tree_install_apps->topLevelItemCount() > 0){ 
    445     appID = ui->tree_install_apps->currentItem()->whatsThis(0); 
    446   } 
    447   if(appID.isEmpty()){return;} 
    448   //Now determine the current state of the checkbox 
    449   bool enabled = ui->check_install_autoupdate->isChecked(); 
    450   //Now have the backend make the change 
    451   PBI->enableAutoUpdate(appID, enabled); 
    452 } 
    453  
    454 void MainUI::on_tool_install_update_clicked(){ 
    455   //Get the current item 
    456   QString appID; 
    457   if(ui->tree_install_apps->topLevelItemCount() > 0){ 
    458     appID = ui->tree_install_apps->currentItem()->whatsThis(0); 
    459   } 
    460   if(appID.isEmpty()){return;} 
    461   PBI->upgradePBI(QStringList() << appID); 
    462 } 
    463  
    464 void MainUI::on_tool_install_remove_clicked(){ 
    465   //Get the current item 
    466   QString appID; 
    467   if(ui->tree_install_apps->topLevelItemCount() > 0){ 
    468     appID = ui->tree_install_apps->currentItem()->whatsThis(0); 
    469   } 
    470   if(appID.isEmpty()){return;} 
    471   //Verify removal 
    472   if( QMessageBox::Yes == QMessageBox::question(this,tr("Verify PBI Removal"), tr("Are you sure you wish to remove this application?")+"\n\n"+appID,QMessageBox::Yes | QMessageBox::Cancel,QMessageBox::Cancel) ){ 
    473     PBI->removePBI(QStringList() << appID); 
    474   } 
    475 } 
    476  
    477 void MainUI::on_tool_install_cancel_clicked(){ 
    478   //Get the current item 
    479   QString appID; 
    480   if(ui->tree_install_apps->topLevelItemCount() > 0){ 
    481     appID = ui->tree_install_apps->currentItem()->whatsThis(0); 
    482   } 
    483   if(appID.isEmpty()){return;} 
    484   PBI->cancelActions(QStringList() << appID); 
    485    
    486 } 
    487  
    488 // === SELECTED PBI ACTIONS === 
    489 void MainUI::slotActionAddDesktop(){ 
    490   QStringList items = getCheckedItems(); 
    491   PBI->addDesktopIcons(items,FALSE); //only for current user 
    492 } 
    493  
    494 void MainUI::slotActionRemoveDesktop(){ 
    495   QStringList items = getCheckedItems(); 
    496   PBI->rmDesktopIcons(items,FALSE);  //Only for current user 
    497 } 
    498  
    499 void MainUI::slotActionAddPath(){ 
    500   QStringList items = getCheckedItems(); 
    501   PBI->addPaths(items,FALSE);  //Only for current user   
    502 } 
    503  
    504 void MainUI::slotActionRemovePath(){ 
    505   QStringList items = getCheckedItems(); 
    506   PBI->rmPaths(items,FALSE);  //Only for current user 
    507 } 
    508  
    509 void MainUI::slotActionAddPathAll(){ 
    510   QStringList items = getCheckedItems(); 
    511   PBI->addPaths(items,TRUE);  //For all users (root permissions required) 
    512 } 
    513  
    514 void MainUI::slotActionAddMenu(){ 
    515   QStringList items = getCheckedItems(); 
    516   PBI->addMenuIcons(items,FALSE);  //Only for current user 
    517 } 
    518  
    519 void MainUI::slotActionRemoveMenu(){ 
    520   QStringList items = getCheckedItems(); 
    521   PBI->rmMenuIcons(items,FALSE);  //Only for current user        
    522 } 
    523  
    524 void MainUI::slotActionAddMenuAll(){ 
    525   QStringList items = getCheckedItems(); 
    526   PBI->addMenuIcons(items,TRUE);  //For all users (root permissions required)    
    527 } 
    528  
    529 void MainUI::slotActionAddMime(){ 
    530   QStringList items = getCheckedItems(); 
    531   PBI->addMimeTypes(items,FALSE);  //Only for current user       
    532 } 
    533  
    534 void MainUI::slotActionRemoveMime(){ 
    535   QStringList items = getCheckedItems(); 
    536   PBI->rmMimeTypes(items,FALSE);  //Only for current user        
    537 } 
    538  
    539 void MainUI::slotActionAddMimeAll(){ 
    540     QStringList items = getCheckedItems(); 
    541   PBI->addMimeTypes(items,TRUE);  //For all users (root permissions required)    
    542 } 
    543  
    544 void MainUI::slotActionUpdate(){ 
    545   QStringList checkedID = getCheckedItems(); 
    546   if(!checkedID.isEmpty()){ 
    547     PBI->upgradePBI(checkedID);   
    548   } 
    549 } 
    550  
    551 void MainUI::slotActionRemove(){ 
    552   QStringList checkedID = getCheckedItems(); 
    553   if(!checkedID.isEmpty()){ 
    554     //Verify that the user really wants to remove these apps 
    555     if( QMessageBox::Yes == QMessageBox::question(this,tr("Verify PBI Removal"), tr("Are you sure you wish to remove these applications?")+"\n\n"+checkedID.join("\n"),QMessageBox::Yes | QMessageBox::Cancel,QMessageBox::Cancel) ){ 
    556       PBI->removePBI(checkedID); 
    557     } 
    558   } 
    559 } 
    560  
    561 void MainUI::slotActionCancel(){ 
    562   QStringList checkedID = getCheckedItems(); 
    563   if(!checkedID.isEmpty()){ 
    564     PBI->cancelActions(checkedID);   
    565   } 
    566 } 
    567  
    568 void MainUI::slotStartApp(QAction* act){ 
    569   qDebug() << "Starting external application:" << act->text(); 
    570   //Get the command from the action 
    571   QString desktopfile = act->whatsThis(); 
    572   QString cmd = "xdg-open "+desktopfile; 
    573   //Startup the command externally 
    574   QProcess::startDetached(cmd); 
     578        appBinMenu->addAction(act); 
     579      } 
     580    } 
     581  } 
    575582} 
    576583 
  • src-qt4/pc-softwaremanager/mainUI.h

    re46485b r6156865  
    7979  void slotActionCancel(); 
    8080  void slotStartApp(QAction*); 
     81  void slotUpdateSelectedPBI(bool statusonly=false); 
    8182   
    8283  //BROWSER TAB 
Note: See TracChangeset for help on using the changeset viewer.