Permalink
Browse files

Make sure that the AppCafe browser "app" page gets the download butto…

…n updated if there is a status change for the associated installed version of that app.
  • Loading branch information...
1 parent 430a6b5 commit f7905b5194dc1db6fcedd5f254f810203cbc8652 Ken Moore committed Feb 24, 2014
@@ -291,6 +291,10 @@ void MainUI::slotRefreshInstallTab(){
slotUpdateSelectedPBI();; //Update the info boxes
slotDisplayStats();
slotCheckSelectedItems();
+ //If the browser app page is currently visible for this app
+ if( (ui->stacked_browser->currentWidget() == ui->page_app) && ui->page_app->isVisible() ){
+ slotUpdateAppDownloadButton();
+ }
}
void MainUI::slotCheckSelectedItems(){
@@ -327,6 +331,11 @@ void MainUI::slotPBIStatusUpdate(QString pbiID){
}
}
}
+ //If the browser app page is current for this app
+ QString metaID = PBI->pbiToAppID(pbiID);
+ if( (ui->stacked_browser->currentWidget() == ui->page_app) && (cApp == metaID) && ui->page_app->isVisible() ){
+ slotUpdateAppDownloadButton();
+ }
}
void MainUI::on_tool_install_details_clicked(){
@@ -831,6 +840,7 @@ void MainUI::slotGoToApp(QString appID){
qDebug() << "Invalid App:" << appID;
return;
}
+ cApp = appID; //save this for later
//Start the search for similar apps
PBI->searchSimilar = appID;
ui->group_bapp_similar->setVisible(FALSE);
@@ -867,7 +877,8 @@ void MainUI::slotGoToApp(QString appID){
else{ ui->label_bapp_size->setText( Extras::sizeKToDisplay(data[14]) ); }
}
//Now update the download button appropriately
- QString ico;
+ slotUpdateAppDownloadButton();
+ /*QString ico;
QString working = PBI->currentAppStatus(appID);
if(!working.isEmpty()){ //app currently pending or actually doing something
ui->tool_bapp_download->setText(working);
@@ -898,6 +909,7 @@ void MainUI::slotGoToApp(QString appID){
ui->tool_bapp_download->setIcon(QIcon(ico));
}
ui->tool_bapp_download->setWhatsThis(appID); //set for slot
+ */
//Now enable/disable the shortcut buttons
ui->tool_browse_app->setVisible(TRUE);
ui->tool_browse_app->setText(data[0]);
@@ -914,6 +926,42 @@ void MainUI::slotGoToApp(QString appID){
}
+void MainUI::slotUpdateAppDownloadButton(){
+ QString ico;
+ QString working = PBI->currentAppStatus(cApp);
+ QStringList info = PBI->AppInfo(cApp, QStringList() << "latestversion" << "backupversion" << "requiresroot");
+ QString pbiID = PBI->isInstalled(cApp);
+ if(!working.isEmpty()){ //app currently pending or actually doing something
+ ui->tool_bapp_download->setText(working);
+ ui->tool_bapp_download->setIcon(QIcon(":icons/working.png"));
+ ui->tool_bapp_download->setEnabled(FALSE);
+ }else if( pbiID.isEmpty() ){ //new installation
+ ui->tool_bapp_download->setText(tr("Install Now!"));
+ ico = ":icons/app_download.png";
+ ui->tool_bapp_download->setEnabled(TRUE);
+ }else if( !PBI->upgradeAvailable(pbiID).isEmpty() ){ //Update available
+ ui->tool_bapp_download->setText(tr("Update"));
+ ico = ":icons/app_upgrade.png";
+ ui->tool_bapp_download->setEnabled(TRUE);
+ }else if(!info[1].isEmpty()){ //Downgrade available
+ ui->tool_bapp_download->setText(tr("Downgrade"));
+ ico = ":icons/app_downgrade.png";
+ ui->tool_bapp_download->setEnabled(TRUE);
+ }else{ //already installed (no downgrade available)
+ ui->tool_bapp_download->setText(tr("Installed"));
+ ui->tool_bapp_download->setIcon(QIcon(":icons/dialog-ok.png"));
+ ui->tool_bapp_download->setEnabled(FALSE);
+ }
+ //Now set the icon appropriately if it requires root permissions
+ if(!ico.isEmpty()){
+ if(info[2]=="true"){ //requires root permissions to install
+ ico.replace(".png","-root.png");
+ }
+ ui->tool_bapp_download->setIcon(QIcon(ico));
+ }
+ ui->tool_bapp_download->setWhatsThis(cApp); //set for slot
+}
+
void MainUI::slotGoToSearch(){
searchTimer->stop(); //just in case "return" was pressed to start the search
QString search = ui->line_browse_searchbar->text();
@@ -1058,7 +1106,7 @@ void MainUI::on_tool_bapp_download_clicked(){
PBI->installApp(QStringList() << appID);
ui->tool_bapp_download->setEnabled(FALSE); //make sure it cannot be clicked more than once before page refresh
//Now show the Installed tab
- ui->tabWidget->setCurrentWidget(ui->tab_installed);
+ //ui->tabWidget->setCurrentWidget(ui->tab_installed);
}
void MainUI::on_group_br_home_newapps_toggled(bool show){
@@ -94,6 +94,7 @@ private slots:
void slotGoToHome();
void slotGoToCategory(QString);
void slotGoToApp(QString);
+ void slotUpdateAppDownloadButton();
void slotGoToSearch();
void slotShowSimilarApps(QStringList);
void slotShowSearchResults(QStringList, QStringList);
@@ -119,7 +120,7 @@ private slots:
QStringList getCheckedItems();
//BROWSER TAB
QTimer *searchTimer;
- QString cCat;
+ QString cCat, cApp;
void initializeBrowserTab();
//OTHER
QLabel *statusLabel;
@@ -630,6 +630,12 @@ QStringList PBIBackend::pbiBinList(QString pbiID){
return output;
}
+QString PBIBackend::pbiToAppID(QString pbiID){
+ QString appID;
+ if( PBIHASH.contains(pbiID) ){ appID = PBIHASH[pbiID].metaID; }
+ return appID;
+}
+
// === Configuration Management ===
void PBIBackend::openConfigurationDialog(){
//temporarily disable the filesystem watcher (causes issues with repo changes)
@@ -69,14 +69,15 @@ class PBIBackend : public QObject{
QString currentAppStatus( QString appID , bool rawstatus = false);
bool isWorking(QString pbiID);
QStringList pbiBinList(QString pbiID);
+ QString pbiToAppID(QString pbiID);
//Configuration Management
void openConfigurationDialog();
//Import/Export PBI lists
bool exportPbiListToFile(QString filepath);
bool importPbiListFromFile(QString filepath);
-
+
public slots:
void startAppSearch(); //get list of apps containing the search string (SIGNAL OUTPUT ONLY)
void startSimilarSearch(); //get list of apps that are similar to the input app

0 comments on commit f7905b5

Please sign in to comment.