SoftwareUpdater improvements
*Bug fix- list item colors use Appearance settings *Problem Solver window buttons right aligned, window now app modal *The main window's stripe and icon now use the same scaling as BAlert *A pop-up menu displays an option to view more details (replaces the tooltips) *New prompt at application start to choose between doing an Update or a Full Sync. Also lays the ground work for implimenting silent check-only feature.
This commit is contained in:
@@ -45,9 +45,7 @@ SoftwareUpdaterWindow::SoftwareUpdaterWindow()
|
||||
fUserCancelRequested(false),
|
||||
fWarningAlertCount(0)
|
||||
{
|
||||
int32 iconSize = int(be_plain_font->Size() * 32.0 / 12.0);
|
||||
// At 12 point font, icon size is 32, at 24 point it is 64
|
||||
BBitmap icon = GetIcon(iconSize);
|
||||
BBitmap icon = GetIcon(32 * icon_layout_scale());
|
||||
fStripeView = new StripeView(icon);
|
||||
|
||||
fUpdateButton = new BButton(B_TRANSLATE("Update now"),
|
||||
@@ -78,7 +76,7 @@ SoftwareUpdaterWindow::SoftwareUpdaterWindow()
|
||||
fHeaderView->SetFont(&font,
|
||||
B_FONT_FAMILY_AND_STYLE | B_FONT_SIZE | B_FONT_FLAGS);
|
||||
|
||||
BLayoutBuilder::Group<>(this, B_HORIZONTAL, 0)
|
||||
BLayoutBuilder::Group<>(this, B_HORIZONTAL, B_USE_ITEM_SPACING)
|
||||
.Add(fStripeView)
|
||||
.AddGroup(B_VERTICAL, 0)
|
||||
.SetInsets(0, B_USE_WINDOW_SPACING,
|
||||
@@ -250,6 +248,42 @@ SoftwareUpdaterWindow::MessageReceived(BMessage* message)
|
||||
break;
|
||||
}
|
||||
|
||||
case kMsgGetUpdateType:
|
||||
{
|
||||
BString text(
|
||||
B_TRANSLATE("Please choose from these update options:\n\n"
|
||||
"Update:\n"
|
||||
" Updates all installed packages.\n"
|
||||
"Full sync:\n"
|
||||
" Synchronizes the installed packages with the repositories."
|
||||
));
|
||||
BAlert* alert = new BAlert("update_type",
|
||||
text,
|
||||
B_TRANSLATE_COMMENT("Cancel", "Alert button label"),
|
||||
B_TRANSLATE_COMMENT("Full sync","Alert button label"),
|
||||
B_TRANSLATE_COMMENT("Update","Alert button label"),
|
||||
B_WIDTH_AS_USUAL, B_INFO_ALERT);
|
||||
int32 result = alert->Go();
|
||||
int32 action = INVALID_SELECTION;
|
||||
switch(result) {
|
||||
case 0:
|
||||
action = CANCEL_UPDATE;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
action = FULLSYNC;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
action = UPDATE;
|
||||
break;
|
||||
}
|
||||
BMessage reply;
|
||||
reply.AddInt32(kKeyAlertResult, action);
|
||||
message->SendReply(&reply);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
BWindow::MessageReceived(message);
|
||||
}
|
||||
@@ -257,11 +291,11 @@ SoftwareUpdaterWindow::MessageReceived(BMessage* message)
|
||||
|
||||
|
||||
bool
|
||||
SoftwareUpdaterWindow::ConfirmUpdates(const char* text)
|
||||
SoftwareUpdaterWindow::ConfirmUpdates()
|
||||
{
|
||||
Lock();
|
||||
fHeaderView->SetText(B_TRANSLATE("Updates found"));
|
||||
fDetailView->SetText(text);
|
||||
fDetailView->SetText(B_TRANSLATE("The following changes will be made:"));
|
||||
fListView->SortItems();
|
||||
Unlock();
|
||||
|
||||
@@ -446,6 +480,7 @@ SuperItem::SuperItem(const char* label)
|
||||
:
|
||||
BListItem(),
|
||||
fLabel(label),
|
||||
fShowMoreDetails(false),
|
||||
fPackageIcon(NULL)
|
||||
{
|
||||
}
|
||||
@@ -464,6 +499,7 @@ SuperItem::DrawItem(BView* owner, BRect item_rect, bool complete)
|
||||
owner->GetPreferredSize(&width, NULL);
|
||||
BString label(fLabel);
|
||||
owner->TruncateString(&label, B_TRUNCATE_END, width);
|
||||
owner->SetHighColor(ui_color(B_LIST_ITEM_TEXT_COLOR));
|
||||
owner->SetFont(&fBoldFont);
|
||||
owner->DrawString(label.String(), BPoint(item_rect.left,
|
||||
item_rect.bottom - fFontHeight.descent - 1));
|
||||
@@ -478,10 +514,25 @@ SuperItem::Update(BView *owner, const BFont *font)
|
||||
fBoldFont = *font;
|
||||
fBoldFont.SetFace(B_BOLD_FACE);
|
||||
BListItem::Update(owner, &fBoldFont);
|
||||
|
||||
_SetHeights();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SuperItem::SetDetailLevel(bool showMoreDetails)
|
||||
{
|
||||
fShowMoreDetails = showMoreDetails;
|
||||
_SetHeights();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SuperItem::_SetHeights()
|
||||
{
|
||||
// Calculate height for PackageItem
|
||||
fRegularFont.GetHeight(&fFontHeight);
|
||||
fPackageItemHeight = 2 * (fFontHeight.ascent + fFontHeight.descent
|
||||
int lineCount = fShowMoreDetails ? 3 : 2;
|
||||
fPackageItemHeight = lineCount * (fFontHeight.ascent + fFontHeight.descent
|
||||
+ fFontHeight.leading);
|
||||
|
||||
// Calculate height for this item
|
||||
@@ -518,26 +569,19 @@ SuperItem::_GetPackageIcon()
|
||||
}
|
||||
|
||||
|
||||
PackageItem::PackageItem(const char* name, const char* version,
|
||||
const char* summary, const char* tooltip, SuperItem* super)
|
||||
PackageItem::PackageItem(const char* name, const char* simple_version,
|
||||
const char* detailed_version, const char* repository, const char* summary,
|
||||
SuperItem* super)
|
||||
:
|
||||
BListItem(),
|
||||
fName(name),
|
||||
fVersion(version),
|
||||
fSimpleVersion(simple_version),
|
||||
fDetailedVersion(detailed_version),
|
||||
fRepository(repository),
|
||||
fSummary(summary),
|
||||
fToolTip(NULL),
|
||||
fSuperItem(super)
|
||||
{
|
||||
fLabelOffset = be_control_look->DefaultLabelSpacing();
|
||||
if (tooltip != NULL)
|
||||
fToolTip = new BTextToolTip(tooltip);
|
||||
}
|
||||
|
||||
|
||||
PackageItem::~PackageItem()
|
||||
{
|
||||
if (fToolTip != NULL)
|
||||
fToolTip->ReleaseReference();
|
||||
}
|
||||
|
||||
|
||||
@@ -548,6 +592,7 @@ PackageItem::DrawItem(BView* owner, BRect item_rect, bool complete)
|
||||
owner->GetPreferredSize(&width, NULL);
|
||||
float nameWidth = width / 2.0;
|
||||
float offset_width = 0;
|
||||
bool showMoreDetails = fSuperItem->GetDetailLevel();
|
||||
|
||||
BBitmap* icon = fSuperItem->GetIcon();
|
||||
if (icon != NULL && icon->IsValid()) {
|
||||
@@ -562,12 +607,15 @@ PackageItem::DrawItem(BView* owner, BRect item_rect, bool complete)
|
||||
offset_width += iconSize + fLabelOffset;
|
||||
}
|
||||
|
||||
owner->SetHighColor(ui_color(B_LIST_ITEM_TEXT_COLOR));
|
||||
// Package name
|
||||
font_height fontHeight = fSuperItem->GetFontHeight();
|
||||
BString name(fName);
|
||||
owner->TruncateString(&name, B_TRUNCATE_END, nameWidth);
|
||||
BPoint cursor(item_rect.left + offset_width,
|
||||
item_rect.bottom - fSmallTotalHeight - fontHeight.descent - 1);
|
||||
if (showMoreDetails)
|
||||
cursor.y -= fSmallTotalHeight + 1;
|
||||
owner->DrawString(name.String(), cursor);
|
||||
cursor.x += owner->StringWidth(name.String()) + fLabelOffset;
|
||||
|
||||
@@ -575,18 +623,30 @@ PackageItem::DrawItem(BView* owner, BRect item_rect, bool complete)
|
||||
owner->SetFont(&fSmallFont);
|
||||
owner->SetHighColor(tint_color(ui_color(B_LIST_ITEM_TEXT_COLOR), 0.7));
|
||||
|
||||
// Version
|
||||
BString version(fVersion);
|
||||
owner->TruncateString(&version, B_TRUNCATE_END, width - cursor.x);
|
||||
owner->DrawString(version.String(), cursor);
|
||||
// Simple version or repository
|
||||
BString versionOrRepo;
|
||||
if (showMoreDetails)
|
||||
versionOrRepo.SetTo(fRepository);
|
||||
else
|
||||
versionOrRepo.SetTo(fSimpleVersion);
|
||||
owner->TruncateString(&versionOrRepo, B_TRUNCATE_END, width - cursor.x);
|
||||
owner->DrawString(versionOrRepo.String(), cursor);
|
||||
|
||||
// Summary
|
||||
BString summary(fSummary);
|
||||
cursor.x = item_rect.left + offset_width;
|
||||
cursor.y = item_rect.bottom - fontHeight.descent;
|
||||
cursor.y += fSmallTotalHeight;
|
||||
owner->TruncateString(&summary, B_TRUNCATE_END, width - cursor.x);
|
||||
owner->DrawString(summary.String(), cursor);
|
||||
|
||||
// Detailed version
|
||||
if (showMoreDetails) {
|
||||
BString version(fDetailedVersion);
|
||||
cursor.y += fSmallTotalHeight;
|
||||
owner->TruncateString(&version, B_TRUNCATE_END, width - cursor.x);
|
||||
owner->DrawString(version.String(), cursor);
|
||||
}
|
||||
|
||||
owner->SetFont(&fRegularFont);
|
||||
}
|
||||
|
||||
@@ -635,17 +695,51 @@ PackageListView::PackageListView()
|
||||
BOutlineListView("Package list"),
|
||||
fSuperUpdateItem(NULL),
|
||||
fSuperInstallItem(NULL),
|
||||
fSuperUninstallItem(NULL)
|
||||
fSuperUninstallItem(NULL),
|
||||
fShowMoreDetails(false)
|
||||
{
|
||||
fMenu = new BPopUpMenu(B_EMPTY_STRING, false, false);
|
||||
fDetailMenuItem = new BMenuItem("Show more details", new BMessage());
|
||||
fMenu->AddItem(fDetailMenuItem);
|
||||
|
||||
SetExplicitMinSize(BSize(B_SIZE_UNSET, 40));
|
||||
SetExplicitPreferredSize(BSize(B_SIZE_UNSET, 400));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PackageListView::AttachedToWindow()
|
||||
{
|
||||
BOutlineListView::AttachedToWindow();
|
||||
fDetailMenuItem->SetTarget(this);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PackageListView::MessageReceived(BMessage* message)
|
||||
{
|
||||
switch(message->what)
|
||||
{
|
||||
case kMsgMoreDetailsOff:
|
||||
case kMsgMoreDetailsOn:
|
||||
{
|
||||
fShowMoreDetails = message->what == kMsgMoreDetailsOn;
|
||||
_SetItemHeights();
|
||||
InvalidateLayout();
|
||||
ResizeToPreferred();
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
BOutlineListView::MessageReceived(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PackageListView::FrameResized(float newWidth, float newHeight)
|
||||
{
|
||||
BListView::FrameResized(newWidth, newHeight);
|
||||
BOutlineListView::FrameResized(newWidth, newHeight);
|
||||
|
||||
float count = CountItems();
|
||||
for (int32 i = 0; i < count; i++) {
|
||||
@@ -660,25 +754,24 @@ void
|
||||
PackageListView::MouseDown(BPoint where)
|
||||
{
|
||||
BOutlineListView::MouseDown(where);
|
||||
BToolTip* tooltip = NULL;
|
||||
bool found = GetToolTipAt(where, &tooltip);
|
||||
if (found)
|
||||
ShowToolTip(tooltip);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PackageListView::GetToolTipAt(BPoint point, BToolTip** _tip)
|
||||
{
|
||||
BListItem* item = ItemAt(IndexOf(point));
|
||||
if (item == NULL)
|
||||
return false;
|
||||
PackageItem* pItem = dynamic_cast<PackageItem*>(item);
|
||||
if (pItem != NULL) {
|
||||
*_tip = pItem->ToolTip();
|
||||
return true;
|
||||
|
||||
int32 button;
|
||||
Looper()->CurrentMessage()->FindInt32("buttons", &button);
|
||||
if (button & B_SECONDARY_MOUSE_BUTTON) {
|
||||
if (fShowMoreDetails) {
|
||||
fDetailMenuItem->SetMarked(true);
|
||||
fDetailMenuItem->Message()->what = kMsgMoreDetailsOff;
|
||||
} else {
|
||||
fDetailMenuItem->SetMarked(false);
|
||||
fDetailMenuItem->Message()->what = kMsgMoreDetailsOn;
|
||||
}
|
||||
// Offset point so cursor isn't over checkmark
|
||||
ConvertToScreen(&where);
|
||||
where.x -= 10;
|
||||
where.y -= 10;
|
||||
fMenu->Go(where, true, true, BRect(where.x - 2, where.y - 2,
|
||||
where.x + 2, where.y + 2), true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -688,11 +781,12 @@ PackageListView::AddPackage(uint32 install_type, const char* name,
|
||||
const char* repository)
|
||||
{
|
||||
SuperItem* super;
|
||||
BString version;
|
||||
BString tooltip(B_TRANSLATE_COMMENT("Package:", "Tooltip text"));
|
||||
tooltip.Append(" ").Append(name).Append("\n")
|
||||
.Append(B_TRANSLATE_COMMENT("Repository:", "Tooltip text"))
|
||||
.Append(" ").Append(repository).Append("\n");
|
||||
BString simpleVersion;
|
||||
BString detailedVersion("");
|
||||
BString repositoryText(B_TRANSLATE_COMMENT("from repository",
|
||||
"List item text"));
|
||||
repositoryText.Append(" ").Append(repository);
|
||||
|
||||
switch (install_type) {
|
||||
case PACKAGE_UPDATE:
|
||||
{
|
||||
@@ -703,11 +797,12 @@ PackageListView::AddPackage(uint32 install_type, const char* name,
|
||||
}
|
||||
super = fSuperUpdateItem;
|
||||
|
||||
version.SetTo(new_ver);
|
||||
tooltip.Append(B_TRANSLATE_COMMENT("Updating version",
|
||||
"Tooltip text"))
|
||||
simpleVersion.SetTo(new_ver);
|
||||
detailedVersion.Append(B_TRANSLATE_COMMENT("Updating version",
|
||||
"List item text"))
|
||||
.Append(" ").Append(cur_ver)
|
||||
.Append(" ").Append(B_TRANSLATE_COMMENT("to", "Tooltip text"))
|
||||
.Append(" ").Append(B_TRANSLATE_COMMENT("to",
|
||||
"List item text"))
|
||||
.Append(" ").Append(new_ver);
|
||||
break;
|
||||
}
|
||||
@@ -721,9 +816,9 @@ PackageListView::AddPackage(uint32 install_type, const char* name,
|
||||
}
|
||||
super = fSuperInstallItem;
|
||||
|
||||
version.SetTo(new_ver);
|
||||
tooltip.Append(B_TRANSLATE_COMMENT("Installing version",
|
||||
"Tooltip text"))
|
||||
simpleVersion.SetTo(new_ver);
|
||||
detailedVersion.Append(B_TRANSLATE_COMMENT("Installing version",
|
||||
"List item text"))
|
||||
.Append(" ").Append(new_ver);
|
||||
break;
|
||||
}
|
||||
@@ -737,9 +832,9 @@ PackageListView::AddPackage(uint32 install_type, const char* name,
|
||||
}
|
||||
super = fSuperUninstallItem;
|
||||
|
||||
version.SetTo("");
|
||||
tooltip.Append(B_TRANSLATE_COMMENT("Uninstalling version",
|
||||
"Tooltip text"))
|
||||
simpleVersion.SetTo("");
|
||||
detailedVersion.Append(B_TRANSLATE_COMMENT("Uninstalling version",
|
||||
"List item text"))
|
||||
.Append(" ").Append(cur_ver);
|
||||
break;
|
||||
}
|
||||
@@ -748,8 +843,8 @@ PackageListView::AddPackage(uint32 install_type, const char* name,
|
||||
return;
|
||||
|
||||
}
|
||||
PackageItem* item = new PackageItem(name, version.String(), summary,
|
||||
tooltip.String(), super);
|
||||
PackageItem* item = new PackageItem(name, simpleVersion.String(),
|
||||
detailedVersion.String(), repositoryText.String(), summary, super);
|
||||
AddUnder(item, super);
|
||||
}
|
||||
|
||||
@@ -777,3 +872,41 @@ PackageListView::ItemHeight()
|
||||
return fSuperUninstallItem->GetPackageItemHeight();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PackageListView::_SetItemHeights()
|
||||
{
|
||||
int32 itemCount = 0;
|
||||
float itemHeight = 0;
|
||||
BListItem* item = NULL;
|
||||
if (fSuperUpdateItem != NULL) {
|
||||
fSuperUpdateItem->SetDetailLevel(fShowMoreDetails);
|
||||
itemHeight = fSuperUpdateItem->GetPackageItemHeight();
|
||||
itemCount = CountItemsUnder(fSuperUpdateItem, true);
|
||||
for (int32 i = 0; i < itemCount; i++) {
|
||||
item = ItemUnderAt(fSuperUpdateItem, true, i);
|
||||
item->SetHeight(itemHeight);
|
||||
}
|
||||
}
|
||||
if (fSuperInstallItem != NULL) {
|
||||
fSuperInstallItem->SetDetailLevel(fShowMoreDetails);
|
||||
itemHeight = fSuperInstallItem->GetPackageItemHeight();
|
||||
itemCount = CountItemsUnder(fSuperInstallItem, true);
|
||||
for (int32 i = 0; i < itemCount; i++) {
|
||||
item = ItemUnderAt(fSuperInstallItem, true, i);
|
||||
item->SetHeight(itemHeight);
|
||||
}
|
||||
|
||||
}
|
||||
if (fSuperUninstallItem != NULL) {
|
||||
fSuperUninstallItem->SetDetailLevel(fShowMoreDetails);
|
||||
itemHeight = fSuperUninstallItem->GetPackageItemHeight();
|
||||
itemCount = CountItemsUnder(fSuperUninstallItem, true);
|
||||
for (int32 i = 0; i < itemCount; i++) {
|
||||
item = ItemUnderAt(fSuperUninstallItem, true, i);
|
||||
item->SetHeight(itemHeight);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,11 +13,12 @@
|
||||
#include <Button.h>
|
||||
#include <GroupView.h>
|
||||
#include <OutlineListView.h>
|
||||
#include <MenuItem.h>
|
||||
#include <Point.h>
|
||||
#include <PopUpMenu.h>
|
||||
#include <ScrollView.h>
|
||||
#include <StatusBar.h>
|
||||
#include <StringView.h>
|
||||
#include <ToolTip.h>
|
||||
#include <Window.h>
|
||||
|
||||
#include "StripeView.h"
|
||||
@@ -42,13 +43,17 @@ public:
|
||||
{ return fPackageItemHeight; };
|
||||
BBitmap* GetIcon() { return fPackageIcon; };
|
||||
int16 GetIconSize() { return fIconSize; };
|
||||
void SetDetailLevel(bool showMoreDetails);
|
||||
bool GetDetailLevel() { return fShowMoreDetails; };
|
||||
|
||||
private:
|
||||
void _SetHeights();
|
||||
void _GetPackageIcon();
|
||||
|
||||
BString fLabel;
|
||||
BFont fRegularFont;
|
||||
BFont fBoldFont;
|
||||
bool fShowMoreDetails;
|
||||
font_height fFontHeight;
|
||||
float fPackageItemHeight;
|
||||
BBitmap* fPackageIcon;
|
||||
@@ -59,22 +64,22 @@ private:
|
||||
class PackageItem : public BListItem {
|
||||
public:
|
||||
PackageItem(const char* name,
|
||||
const char* version,
|
||||
const char* simple_version,
|
||||
const char* detailed_version,
|
||||
const char* repository,
|
||||
const char* summary,
|
||||
const char* tooltip,
|
||||
SuperItem* super);
|
||||
~PackageItem();
|
||||
virtual void DrawItem(BView*, BRect, bool);
|
||||
virtual void Update(BView *owner, const BFont *font);
|
||||
void SetItemHeight(const BFont* font);
|
||||
int NameCompare(PackageItem* item);
|
||||
BTextToolTip* ToolTip() { return fToolTip; };
|
||||
|
||||
private:
|
||||
BString fName;
|
||||
BString fVersion;
|
||||
BString fSimpleVersion;
|
||||
BString fDetailedVersion;
|
||||
BString fRepository;
|
||||
BString fSummary;
|
||||
BTextToolTip* fToolTip;
|
||||
BFont fRegularFont;
|
||||
BFont fSmallFont;
|
||||
font_height fSmallFontHeight;
|
||||
@@ -87,6 +92,8 @@ private:
|
||||
class PackageListView : public BOutlineListView {
|
||||
public:
|
||||
PackageListView();
|
||||
void AttachedToWindow();
|
||||
virtual void MessageReceived(BMessage*);
|
||||
virtual void FrameResized(float newWidth, float newHeight);
|
||||
virtual void MouseDown(BPoint where);
|
||||
void AddPackage(uint32 install_type,
|
||||
@@ -98,13 +105,15 @@ public:
|
||||
void SortItems();
|
||||
float ItemHeight();
|
||||
|
||||
protected:
|
||||
virtual bool GetToolTipAt(BPoint point, BToolTip** _tip);
|
||||
|
||||
private:
|
||||
void _SetItemHeights();
|
||||
|
||||
SuperItem* fSuperUpdateItem;
|
||||
SuperItem* fSuperInstallItem;
|
||||
SuperItem* fSuperUninstallItem;
|
||||
bool fShowMoreDetails;
|
||||
BPopUpMenu *fMenu;
|
||||
BMenuItem *fDetailMenuItem;
|
||||
};
|
||||
|
||||
|
||||
@@ -112,7 +121,7 @@ class SoftwareUpdaterWindow : public BWindow {
|
||||
public:
|
||||
SoftwareUpdaterWindow();
|
||||
void MessageReceived(BMessage* message);
|
||||
bool ConfirmUpdates(const char* text);
|
||||
bool ConfirmUpdates();
|
||||
void UpdatesApplying(const char* header,
|
||||
const char* detail);
|
||||
bool UserCancelRequested();
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
|
||||
static const float kTopOffset = 10.0f;
|
||||
static const int kIconStripeWidth = 30;
|
||||
|
||||
|
||||
StripeView::StripeView(BBitmap& icon)
|
||||
@@ -23,13 +24,17 @@ StripeView::StripeView(BBitmap& icon)
|
||||
BView("StripeView", B_WILL_DRAW),
|
||||
fIcon(icon),
|
||||
fIconSize(0.0),
|
||||
fWidth(0.0)
|
||||
fPreferredWidth(0.0),
|
||||
fPreferredHeight(0.0)
|
||||
{
|
||||
SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
|
||||
|
||||
if (fIcon.IsValid()) {
|
||||
fIconSize = fIcon.Bounds().Width();
|
||||
fWidth = 2 * fIconSize + 2.0f;
|
||||
// Use the same scaling as a BAlert
|
||||
int32 scale = icon_layout_scale();
|
||||
fPreferredWidth = 18 * scale + fIcon.Bounds().Width();
|
||||
fPreferredHeight = 6 * scale + fIcon.Bounds().Height();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,20 +49,22 @@ StripeView::Draw(BRect updateRect)
|
||||
FillRect(updateRect);
|
||||
|
||||
BRect stripeRect = Bounds();
|
||||
stripeRect.right = fIconSize;
|
||||
int32 iconLayoutScale = icon_layout_scale();
|
||||
stripeRect.right = kIconStripeWidth * iconLayoutScale;
|
||||
SetHighColor(tint_color(ViewColor(), B_DARKEN_1_TINT));
|
||||
FillRect(stripeRect);
|
||||
|
||||
SetDrawingMode(B_OP_ALPHA);
|
||||
SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
|
||||
DrawBitmapAsync(&fIcon, BPoint(fIconSize / 2.0f, kTopOffset));
|
||||
DrawBitmapAsync(&fIcon, BPoint(stripeRect.right - (fIconSize / 2.0),
|
||||
6 * iconLayoutScale));
|
||||
}
|
||||
|
||||
|
||||
BSize
|
||||
StripeView::PreferredSize()
|
||||
{
|
||||
return BSize(fWidth, B_SIZE_UNSET);
|
||||
return BSize(fPreferredWidth, B_SIZE_UNSET);
|
||||
}
|
||||
|
||||
|
||||
@@ -65,10 +72,10 @@ void
|
||||
StripeView::GetPreferredSize(float* _width, float* _height)
|
||||
{
|
||||
if (_width != NULL)
|
||||
*_width = fWidth;
|
||||
*_width = fPreferredWidth;
|
||||
|
||||
if (_height != NULL)
|
||||
*_height = fIconSize + 2 * kTopOffset;
|
||||
*_height = fPreferredHeight;
|
||||
}
|
||||
|
||||
|
||||
@@ -76,5 +83,5 @@ BSize
|
||||
StripeView::MaxSize()
|
||||
{
|
||||
return BLayoutUtils::ComposeSize(ExplicitMaxSize(),
|
||||
BSize(fWidth, B_SIZE_UNLIMITED));
|
||||
BSize(fPreferredWidth, B_SIZE_UNLIMITED));
|
||||
}
|
||||
|
||||
@@ -28,8 +28,16 @@ public:
|
||||
private:
|
||||
BBitmap fIcon;
|
||||
float fIconSize;
|
||||
float fWidth;
|
||||
float fPreferredWidth;
|
||||
float fPreferredHeight;
|
||||
};
|
||||
|
||||
|
||||
static inline int32
|
||||
icon_layout_scale()
|
||||
{
|
||||
return max_c(1, ((int32)be_plain_font->Size() + 15) / 16);
|
||||
}
|
||||
|
||||
|
||||
#endif /* _STRIPE_VIEW_H */
|
||||
|
||||
@@ -43,19 +43,25 @@ UpdateAction::Perform()
|
||||
{
|
||||
try {
|
||||
fUpdateManager->CheckNetworkConnection();
|
||||
int32 action = fUpdateManager->GetUpdateType();
|
||||
if (action == CANCEL_UPDATE)
|
||||
throw BAbortedByUserException();
|
||||
else if (action <= INVALID_SELECTION || action >= UPDATE_TYPE_END)
|
||||
throw BException("Invalid update type, cannot continue with updates");
|
||||
|
||||
fUpdateManager->Init(BPackageManager::B_ADD_INSTALLED_REPOSITORIES
|
||||
| BPackageManager::B_ADD_REMOTE_REPOSITORIES
|
||||
| BPackageManager::B_REFRESH_REPOSITORIES);
|
||||
|
||||
// These values indicate that all updates should be installed
|
||||
//int packageCount = 0;
|
||||
//const char* const packages = "";
|
||||
|
||||
// perform the update
|
||||
|
||||
// fUpdateManager->SetDebugLevel(1);
|
||||
//fUpdateManager->Update(&packages, packageCount);
|
||||
fUpdateManager->FullSync();
|
||||
if(action == UPDATE) {
|
||||
// These values indicate that all updates should be installed
|
||||
int packageCount = 0;
|
||||
const char* const packages = "";
|
||||
fUpdateManager->Update(&packages, packageCount);
|
||||
} else if (action == FULLSYNC)
|
||||
fUpdateManager->FullSync();
|
||||
|
||||
} catch (BFatalErrorException ex) {
|
||||
fUpdateManager->FinalUpdate(B_TRANSLATE("Updates did not complete"),
|
||||
ex.Message());
|
||||
|
||||
@@ -102,6 +102,21 @@ UpdateManager::CheckNetworkConnection()
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
UpdateManager::GetUpdateType()
|
||||
{
|
||||
int32 action = USER_SELECTION_NEEDED;
|
||||
BMessenger messenger(fStatusWindow);
|
||||
if (messenger.IsValid()) {
|
||||
BMessage message(kMsgGetUpdateType);
|
||||
BMessage reply;
|
||||
messenger.SendMessage(&message, &reply);
|
||||
reply.FindInt32(kKeyAlertResult, &action);
|
||||
}
|
||||
return action;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
UpdateManager::JobFailed(BSupportKit::BJob* job)
|
||||
{
|
||||
@@ -137,6 +152,7 @@ UpdateManager::HandleProblems()
|
||||
ProblemWindow::SolverPackageSet uninstallPackages;
|
||||
if (!fProblemWindow->Go(fSolver,installPackages, uninstallPackages))
|
||||
throw BAbortedByUserException();
|
||||
fProblemWindow->Hide();
|
||||
|
||||
/* int32 problemCount = fSolver->CountProblems();
|
||||
for (int32 i = 0; i < problemCount; i++) {
|
||||
@@ -217,32 +233,8 @@ UpdateManager::ConfirmChanges(bool fromMostSpecific)
|
||||
printf("Upgrade count=%" B_PRId32 ", Install count=%" B_PRId32
|
||||
", Uninstall count=%" B_PRId32 "\n",
|
||||
upgradeCount, installCount, uninstallCount);
|
||||
BString text;
|
||||
if (upgradeCount == 1)
|
||||
text.SetTo(B_TRANSLATE_COMMENT("There is 1 update "
|
||||
"%dependancies%available.",
|
||||
"Do not translate %dependancies%"));
|
||||
else
|
||||
text.SetTo(B_TRANSLATE_COMMENT("There are %count% updates "
|
||||
"%dependancies%available.",
|
||||
"Do not translate %count% or %dependancies%"));
|
||||
BString countString;
|
||||
countString << upgradeCount;
|
||||
text.ReplaceFirst("%count%", countString);
|
||||
BString dependancies("");
|
||||
if (installCount) {
|
||||
dependancies.SetTo("(");
|
||||
dependancies.Append(B_TRANSLATE("with")).Append(" ");
|
||||
if (installCount == 1)
|
||||
dependancies.Append(B_TRANSLATE("1 new dependancy"));
|
||||
else {
|
||||
dependancies << installCount;
|
||||
dependancies.Append(" ").Append(B_TRANSLATE("new dependancies"));
|
||||
}
|
||||
dependancies.Append(") ");
|
||||
}
|
||||
text.ReplaceFirst("%dependancies%", dependancies);
|
||||
fChangesConfirmed = fStatusWindow->ConfirmUpdates(text.String());
|
||||
|
||||
fChangesConfirmed = fStatusWindow->ConfirmUpdates();
|
||||
if (!fChangesConfirmed)
|
||||
throw BAbortedByUserException();
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ public:
|
||||
~UpdateManager();
|
||||
|
||||
void CheckNetworkConnection();
|
||||
int32 GetUpdateType();
|
||||
virtual void JobFailed(BSupportKit::BJob* job);
|
||||
virtual void JobAborted(BSupportKit::BJob* job);
|
||||
void FinalUpdate(const char* header,
|
||||
|
||||
@@ -27,6 +27,17 @@ enum {
|
||||
STATE_MAX
|
||||
};
|
||||
|
||||
enum update_type {
|
||||
USER_SELECTION_NEEDED = 0,
|
||||
INVALID_SELECTION,
|
||||
CANCEL_UPDATE,
|
||||
UPDATE,
|
||||
UPDATE_CHECK_ONLY,
|
||||
FULLSYNC,
|
||||
FULLSYNC_CHECK_ONLY,
|
||||
UPDATE_TYPE_END
|
||||
} ;
|
||||
|
||||
// Message what values
|
||||
static const uint32 kMsgTextUpdate = 'iUPD';
|
||||
static const uint32 kMsgProgressUpdate = 'iPRO';
|
||||
@@ -35,8 +46,11 @@ static const uint32 kMsgCancelResponse = 'iCRE';
|
||||
static const uint32 kMsgUpdateConfirmed = 'iCON';
|
||||
static const uint32 kMsgWarningDismissed = 'iWDI';
|
||||
static const uint32 kMsgNetworkAlert = 'iNAL';
|
||||
static const uint32 kMsgGetUpdateType = 'iGUP';
|
||||
static const uint32 kMsgRegister = 'iREG';
|
||||
static const uint32 kMsgFinalQuit = 'iFIN';
|
||||
static const uint32 kMsgMoreDetailsOn = 'iDON';
|
||||
static const uint32 kMsgMoreDetailsOff = 'iDOF';
|
||||
|
||||
// Message data keys
|
||||
#define kKeyHeader "key_header"
|
||||
|
||||
@@ -59,7 +59,7 @@ ProblemWindow::ProblemWindow()
|
||||
:
|
||||
BWindow(BRect(0, 0, 400, 300), B_TRANSLATE_COMMENT("Package problems",
|
||||
"Window title"), B_TITLED_WINDOW_LOOK,
|
||||
B_NORMAL_WINDOW_FEEL,
|
||||
B_MODAL_APP_WINDOW_FEEL,
|
||||
B_ASYNCHRONOUS_CONTROLS | B_NOT_MINIMIZABLE | B_AUTO_UPDATE_SIZE_LIMITS,
|
||||
B_ALL_WORKSPACES),
|
||||
fDoneSemaphore(-1),
|
||||
@@ -87,9 +87,9 @@ ProblemWindow::ProblemWindow()
|
||||
"a solution for each:")))
|
||||
.Add(new BScrollView(NULL, viewPort = new BViewPort(), 0, false, true))
|
||||
.AddGroup(B_HORIZONTAL)
|
||||
.AddGlue()
|
||||
.Add(fCancelButton = new BButton(B_TRANSLATE("Cancel"),
|
||||
new BMessage(B_CANCEL)))
|
||||
.AddGlue()
|
||||
.Add(fRetryButton = new BButton(B_TRANSLATE("Retry"),
|
||||
new BMessage(kRetryMessage)))
|
||||
.End();
|
||||
|
||||
Reference in New Issue
Block a user