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:
{
_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
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));
}
}

View File

@ -1,7 +1,6 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <Window.h>
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;
};