Pop a BNotification on download success/failure.

Clicking the notification opens the downloaded file for succesful
downloads.
Fixes #10689.
This commit is contained in:
Adrien Destugues
2014-04-22 13:31:28 +02:00
parent 976bc77c7c
commit 567a96acc9
@@ -21,6 +21,7 @@
#include <MenuItem.h>
#include <NodeInfo.h>
#include <NodeMonitor.h>
#include <Notification.h>
#include <PopUpMenu.h>
#include <Roster.h>
#include <SpaceLayoutItem.h>
@@ -141,6 +142,11 @@ public:
return MinSize();
}
BBitmap* Bitmap()
{
return &fIconBitmap;
}
private:
BBitmap fIconBitmap;
bool fDimmedIcon;
@@ -617,6 +623,18 @@ DownloadProgressView::DownloadFinished()
fBottomButton->SetMessage(new BMessage(REMOVE_DOWNLOAD));
fBottomButton->SetEnabled(true);
fInfoView->SetText("");
fStatusBar->SetBarColor(ui_color(B_SUCCESS_COLOR));
BNotification success(B_INFORMATION_NOTIFICATION);
success.SetTitle(B_TRANSLATE("Download finished"));
success.SetContent(fPath.Leaf());
BEntry entry(fPath.Path());
entry_ref ref;
entry.GetRef(&ref);
success.SetOnClickFile(&ref);
success.SetIcon(fIconView->Bitmap());
success.Send();
}
@@ -631,6 +649,15 @@ DownloadProgressView::DownloadCanceled()
fBottomButton->SetMessage(new BMessage(REMOVE_DOWNLOAD));
fBottomButton->SetEnabled(true);
fInfoView->SetText("");
fStatusBar->SetBarColor(ui_color(B_FAILURE_COLOR));
BNotification success(B_ERROR_NOTIFICATION);
success.SetTitle(B_TRANSLATE("Download aborted"));
success.SetContent(fPath.Leaf());
// Don't make a click on the notification open the file: it is not complete
success.SetIcon(fIconView->Bitmap());
success.Send();
fPath.Unset();
}