diff --git a/src/FeedsView.cpp b/src/FeedsView.cpp index fa27124..a38d8b2 100644 --- a/src/FeedsView.cpp +++ b/src/FeedsView.cpp @@ -83,6 +83,19 @@ FeedsView::MessageReceived(BMessage* msg) case kParseComplete: { _UpdateProgress(msg, kClearStatus); + break; + } + case kProgress: + { + int32 total,current = 0; + + if (msg->FindInt32("total", &total) == B_OK + && msg->FindInt32("current", ¤t) == B_OK) + { + if (total == current) + fProgressLabel->SetText(""); + } + break; } } } diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index aedbc23..fcdd7e6 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -104,11 +104,11 @@ MainWindow::_InitInterface() // Bottom bar fStatusBar = new BStatusBar("feedProgress"); - fUpdateNowButton = new BButton("updateNow", "Update Now", - new BMessage(kUpdateSubscribed)); - fUpdateNowButton->SetTarget((App*)be_app); - fUpdateNowButton->SetExplicitAlignment( + fUpdateButton = new BButton("updateNow", "", NULL); + fUpdateButton->SetTarget((App*)be_app); + fUpdateButton->SetExplicitAlignment( BAlignment(B_ALIGN_RIGHT, B_ALIGN_MIDDLE)); + _SetUpdateButton(false); // Window size font_height fontHeight; @@ -126,7 +126,7 @@ MainWindow::_InitInterface() .Add(new BSeparatorView(B_HORIZONTAL)) .AddGroup(B_HORIZONTAL) .Add(fStatusBar) - .Add(fUpdateNowButton) + .Add(fUpdateButton) .SetInsets(B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_WINDOW_SPACING) .End() @@ -141,6 +141,24 @@ MainWindow::_UpdateProgress(int32 total, int32 current) fStatusBar->Reset(); fStatusBar->SetMaxValue(total); fStatusBar->SetTo(current); + + if (total == current) + _SetUpdateButton(false); + else + _SetUpdateButton(true); +} + + +void +MainWindow::_SetUpdateButton(bool cancel) +{ + if (cancel == true) { + fUpdateButton->SetLabel("Cancel"); + fUpdateButton->SetMessage(new BMessage(kClearQueue)); + } else { + fUpdateButton->SetLabel("Update Now"); + fUpdateButton->SetMessage(new BMessage(kUpdateSubscribed)); + } } diff --git a/src/MainWindow.h b/src/MainWindow.h index 20a6a1a..2113b29 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -1,7 +1,6 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H - #include class BButton; @@ -25,6 +24,8 @@ private: void _UpdateProgress(int32 total, int32 current); + void _SetUpdateButton(bool cancel); + BGroupView* fBaseView; BTabView* fTabView; EntriesView* fEntriesView; @@ -32,7 +33,7 @@ private: UpdatesView* fUpdatesView; BStatusBar* fStatusBar; - BButton* fUpdateNowButton; + BButton* fUpdateButton; };