Add 'cancel update' button, clear status stringview

This commit is contained in:
Jaidyn Ann 2021-03-21 12:10:58 -05:00
parent 9149de6eb9
commit 956e366e24
3 changed files with 39 additions and 7 deletions

View File

@ -83,6 +83,19 @@ FeedsView::MessageReceived(BMessage* msg)
case kParseComplete: case kParseComplete:
{ {
_UpdateProgress(msg, kClearStatus); _UpdateProgress(msg, kClearStatus);
break;
}
case kProgress:
{
int32 total,current = 0;
if (msg->FindInt32("total", &total) == B_OK
&& msg->FindInt32("current", &current) == B_OK)
{
if (total == current)
fProgressLabel->SetText("");
}
break;
} }
} }
} }

View File

@ -104,11 +104,11 @@ MainWindow::_InitInterface()
// Bottom bar // Bottom bar
fStatusBar = new BStatusBar("feedProgress"); fStatusBar = new BStatusBar("feedProgress");
fUpdateNowButton = new BButton("updateNow", "Update Now", fUpdateButton = new BButton("updateNow", "", NULL);
new BMessage(kUpdateSubscribed)); fUpdateButton->SetTarget((App*)be_app);
fUpdateNowButton->SetTarget((App*)be_app); fUpdateButton->SetExplicitAlignment(
fUpdateNowButton->SetExplicitAlignment(
BAlignment(B_ALIGN_RIGHT, B_ALIGN_MIDDLE)); BAlignment(B_ALIGN_RIGHT, B_ALIGN_MIDDLE));
_SetUpdateButton(false);
// Window size // Window size
font_height fontHeight; font_height fontHeight;
@ -126,7 +126,7 @@ MainWindow::_InitInterface()
.Add(new BSeparatorView(B_HORIZONTAL)) .Add(new BSeparatorView(B_HORIZONTAL))
.AddGroup(B_HORIZONTAL) .AddGroup(B_HORIZONTAL)
.Add(fStatusBar) .Add(fStatusBar)
.Add(fUpdateNowButton) .Add(fUpdateButton)
.SetInsets(B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING, .SetInsets(B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING,
B_USE_DEFAULT_SPACING, B_USE_WINDOW_SPACING) B_USE_DEFAULT_SPACING, B_USE_WINDOW_SPACING)
.End() .End()
@ -141,6 +141,24 @@ MainWindow::_UpdateProgress(int32 total, int32 current)
fStatusBar->Reset(); fStatusBar->Reset();
fStatusBar->SetMaxValue(total); fStatusBar->SetMaxValue(total);
fStatusBar->SetTo(current); 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));
}
} }

View File

@ -1,7 +1,6 @@
#ifndef MAINWINDOW_H #ifndef MAINWINDOW_H
#define MAINWINDOW_H #define MAINWINDOW_H
#include <Window.h> #include <Window.h>
class BButton; class BButton;
@ -25,6 +24,8 @@ private:
void _UpdateProgress(int32 total, int32 current); void _UpdateProgress(int32 total, int32 current);
void _SetUpdateButton(bool cancel);
BGroupView* fBaseView; BGroupView* fBaseView;
BTabView* fTabView; BTabView* fTabView;
EntriesView* fEntriesView; EntriesView* fEntriesView;
@ -32,7 +33,7 @@ private:
UpdatesView* fUpdatesView; UpdatesView* fUpdatesView;
BStatusBar* fStatusBar; BStatusBar* fStatusBar;
BButton* fUpdateNowButton; BButton* fUpdateButton;
}; };