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),
|
fUserCancelRequested(false),
|
||||||
fWarningAlertCount(0)
|
fWarningAlertCount(0)
|
||||||
{
|
{
|
||||||
int32 iconSize = int(be_plain_font->Size() * 32.0 / 12.0);
|
BBitmap icon = GetIcon(32 * icon_layout_scale());
|
||||||
// At 12 point font, icon size is 32, at 24 point it is 64
|
|
||||||
BBitmap icon = GetIcon(iconSize);
|
|
||||||
fStripeView = new StripeView(icon);
|
fStripeView = new StripeView(icon);
|
||||||
|
|
||||||
fUpdateButton = new BButton(B_TRANSLATE("Update now"),
|
fUpdateButton = new BButton(B_TRANSLATE("Update now"),
|
||||||
@@ -78,7 +76,7 @@ SoftwareUpdaterWindow::SoftwareUpdaterWindow()
|
|||||||
fHeaderView->SetFont(&font,
|
fHeaderView->SetFont(&font,
|
||||||
B_FONT_FAMILY_AND_STYLE | B_FONT_SIZE | B_FONT_FLAGS);
|
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)
|
.Add(fStripeView)
|
||||||
.AddGroup(B_VERTICAL, 0)
|
.AddGroup(B_VERTICAL, 0)
|
||||||
.SetInsets(0, B_USE_WINDOW_SPACING,
|
.SetInsets(0, B_USE_WINDOW_SPACING,
|
||||||
@@ -250,6 +248,42 @@ SoftwareUpdaterWindow::MessageReceived(BMessage* message)
|
|||||||
break;
|
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:
|
default:
|
||||||
BWindow::MessageReceived(message);
|
BWindow::MessageReceived(message);
|
||||||
}
|
}
|
||||||
@@ -257,11 +291,11 @@ SoftwareUpdaterWindow::MessageReceived(BMessage* message)
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SoftwareUpdaterWindow::ConfirmUpdates(const char* text)
|
SoftwareUpdaterWindow::ConfirmUpdates()
|
||||||
{
|
{
|
||||||
Lock();
|
Lock();
|
||||||
fHeaderView->SetText(B_TRANSLATE("Updates found"));
|
fHeaderView->SetText(B_TRANSLATE("Updates found"));
|
||||||
fDetailView->SetText(text);
|
fDetailView->SetText(B_TRANSLATE("The following changes will be made:"));
|
||||||
fListView->SortItems();
|
fListView->SortItems();
|
||||||
Unlock();
|
Unlock();
|
||||||
|
|
||||||
@@ -446,6 +480,7 @@ SuperItem::SuperItem(const char* label)
|
|||||||
:
|
:
|
||||||
BListItem(),
|
BListItem(),
|
||||||
fLabel(label),
|
fLabel(label),
|
||||||
|
fShowMoreDetails(false),
|
||||||
fPackageIcon(NULL)
|
fPackageIcon(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -464,6 +499,7 @@ SuperItem::DrawItem(BView* owner, BRect item_rect, bool complete)
|
|||||||
owner->GetPreferredSize(&width, NULL);
|
owner->GetPreferredSize(&width, NULL);
|
||||||
BString label(fLabel);
|
BString label(fLabel);
|
||||||
owner->TruncateString(&label, B_TRUNCATE_END, width);
|
owner->TruncateString(&label, B_TRUNCATE_END, width);
|
||||||
|
owner->SetHighColor(ui_color(B_LIST_ITEM_TEXT_COLOR));
|
||||||
owner->SetFont(&fBoldFont);
|
owner->SetFont(&fBoldFont);
|
||||||
owner->DrawString(label.String(), BPoint(item_rect.left,
|
owner->DrawString(label.String(), BPoint(item_rect.left,
|
||||||
item_rect.bottom - fFontHeight.descent - 1));
|
item_rect.bottom - fFontHeight.descent - 1));
|
||||||
@@ -478,10 +514,25 @@ SuperItem::Update(BView *owner, const BFont *font)
|
|||||||
fBoldFont = *font;
|
fBoldFont = *font;
|
||||||
fBoldFont.SetFace(B_BOLD_FACE);
|
fBoldFont.SetFace(B_BOLD_FACE);
|
||||||
BListItem::Update(owner, &fBoldFont);
|
BListItem::Update(owner, &fBoldFont);
|
||||||
|
_SetHeights();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SuperItem::SetDetailLevel(bool showMoreDetails)
|
||||||
|
{
|
||||||
|
fShowMoreDetails = showMoreDetails;
|
||||||
|
_SetHeights();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SuperItem::_SetHeights()
|
||||||
|
{
|
||||||
// Calculate height for PackageItem
|
// Calculate height for PackageItem
|
||||||
fRegularFont.GetHeight(&fFontHeight);
|
fRegularFont.GetHeight(&fFontHeight);
|
||||||
fPackageItemHeight = 2 * (fFontHeight.ascent + fFontHeight.descent
|
int lineCount = fShowMoreDetails ? 3 : 2;
|
||||||
|
fPackageItemHeight = lineCount * (fFontHeight.ascent + fFontHeight.descent
|
||||||
+ fFontHeight.leading);
|
+ fFontHeight.leading);
|
||||||
|
|
||||||
// Calculate height for this item
|
// Calculate height for this item
|
||||||
@@ -518,26 +569,19 @@ SuperItem::_GetPackageIcon()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PackageItem::PackageItem(const char* name, const char* version,
|
PackageItem::PackageItem(const char* name, const char* simple_version,
|
||||||
const char* summary, const char* tooltip, SuperItem* super)
|
const char* detailed_version, const char* repository, const char* summary,
|
||||||
|
SuperItem* super)
|
||||||
:
|
:
|
||||||
BListItem(),
|
BListItem(),
|
||||||
fName(name),
|
fName(name),
|
||||||
fVersion(version),
|
fSimpleVersion(simple_version),
|
||||||
|
fDetailedVersion(detailed_version),
|
||||||
|
fRepository(repository),
|
||||||
fSummary(summary),
|
fSummary(summary),
|
||||||
fToolTip(NULL),
|
|
||||||
fSuperItem(super)
|
fSuperItem(super)
|
||||||
{
|
{
|
||||||
fLabelOffset = be_control_look->DefaultLabelSpacing();
|
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);
|
owner->GetPreferredSize(&width, NULL);
|
||||||
float nameWidth = width / 2.0;
|
float nameWidth = width / 2.0;
|
||||||
float offset_width = 0;
|
float offset_width = 0;
|
||||||
|
bool showMoreDetails = fSuperItem->GetDetailLevel();
|
||||||
|
|
||||||
BBitmap* icon = fSuperItem->GetIcon();
|
BBitmap* icon = fSuperItem->GetIcon();
|
||||||
if (icon != NULL && icon->IsValid()) {
|
if (icon != NULL && icon->IsValid()) {
|
||||||
@@ -562,12 +607,15 @@ PackageItem::DrawItem(BView* owner, BRect item_rect, bool complete)
|
|||||||
offset_width += iconSize + fLabelOffset;
|
offset_width += iconSize + fLabelOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
owner->SetHighColor(ui_color(B_LIST_ITEM_TEXT_COLOR));
|
||||||
// Package name
|
// Package name
|
||||||
font_height fontHeight = fSuperItem->GetFontHeight();
|
font_height fontHeight = fSuperItem->GetFontHeight();
|
||||||
BString name(fName);
|
BString name(fName);
|
||||||
owner->TruncateString(&name, B_TRUNCATE_END, nameWidth);
|
owner->TruncateString(&name, B_TRUNCATE_END, nameWidth);
|
||||||
BPoint cursor(item_rect.left + offset_width,
|
BPoint cursor(item_rect.left + offset_width,
|
||||||
item_rect.bottom - fSmallTotalHeight - fontHeight.descent - 1);
|
item_rect.bottom - fSmallTotalHeight - fontHeight.descent - 1);
|
||||||
|
if (showMoreDetails)
|
||||||
|
cursor.y -= fSmallTotalHeight + 1;
|
||||||
owner->DrawString(name.String(), cursor);
|
owner->DrawString(name.String(), cursor);
|
||||||
cursor.x += owner->StringWidth(name.String()) + fLabelOffset;
|
cursor.x += owner->StringWidth(name.String()) + fLabelOffset;
|
||||||
|
|
||||||
@@ -575,18 +623,30 @@ PackageItem::DrawItem(BView* owner, BRect item_rect, bool complete)
|
|||||||
owner->SetFont(&fSmallFont);
|
owner->SetFont(&fSmallFont);
|
||||||
owner->SetHighColor(tint_color(ui_color(B_LIST_ITEM_TEXT_COLOR), 0.7));
|
owner->SetHighColor(tint_color(ui_color(B_LIST_ITEM_TEXT_COLOR), 0.7));
|
||||||
|
|
||||||
// Version
|
// Simple version or repository
|
||||||
BString version(fVersion);
|
BString versionOrRepo;
|
||||||
owner->TruncateString(&version, B_TRUNCATE_END, width - cursor.x);
|
if (showMoreDetails)
|
||||||
owner->DrawString(version.String(), cursor);
|
versionOrRepo.SetTo(fRepository);
|
||||||
|
else
|
||||||
|
versionOrRepo.SetTo(fSimpleVersion);
|
||||||
|
owner->TruncateString(&versionOrRepo, B_TRUNCATE_END, width - cursor.x);
|
||||||
|
owner->DrawString(versionOrRepo.String(), cursor);
|
||||||
|
|
||||||
// Summary
|
// Summary
|
||||||
BString summary(fSummary);
|
BString summary(fSummary);
|
||||||
cursor.x = item_rect.left + offset_width;
|
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->TruncateString(&summary, B_TRUNCATE_END, width - cursor.x);
|
||||||
owner->DrawString(summary.String(), cursor);
|
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);
|
owner->SetFont(&fRegularFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -635,17 +695,51 @@ PackageListView::PackageListView()
|
|||||||
BOutlineListView("Package list"),
|
BOutlineListView("Package list"),
|
||||||
fSuperUpdateItem(NULL),
|
fSuperUpdateItem(NULL),
|
||||||
fSuperInstallItem(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));
|
SetExplicitMinSize(BSize(B_SIZE_UNSET, 40));
|
||||||
SetExplicitPreferredSize(BSize(B_SIZE_UNSET, 400));
|
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
|
void
|
||||||
PackageListView::FrameResized(float newWidth, float newHeight)
|
PackageListView::FrameResized(float newWidth, float newHeight)
|
||||||
{
|
{
|
||||||
BListView::FrameResized(newWidth, newHeight);
|
BOutlineListView::FrameResized(newWidth, newHeight);
|
||||||
|
|
||||||
float count = CountItems();
|
float count = CountItems();
|
||||||
for (int32 i = 0; i < count; i++) {
|
for (int32 i = 0; i < count; i++) {
|
||||||
@@ -660,25 +754,24 @@ void
|
|||||||
PackageListView::MouseDown(BPoint where)
|
PackageListView::MouseDown(BPoint where)
|
||||||
{
|
{
|
||||||
BOutlineListView::MouseDown(where);
|
BOutlineListView::MouseDown(where);
|
||||||
BToolTip* tooltip = NULL;
|
|
||||||
bool found = GetToolTipAt(where, &tooltip);
|
int32 button;
|
||||||
if (found)
|
Looper()->CurrentMessage()->FindInt32("buttons", &button);
|
||||||
ShowToolTip(tooltip);
|
if (button & B_SECONDARY_MOUSE_BUTTON) {
|
||||||
}
|
if (fShowMoreDetails) {
|
||||||
|
fDetailMenuItem->SetMarked(true);
|
||||||
|
fDetailMenuItem->Message()->what = kMsgMoreDetailsOff;
|
||||||
bool
|
} else {
|
||||||
PackageListView::GetToolTipAt(BPoint point, BToolTip** _tip)
|
fDetailMenuItem->SetMarked(false);
|
||||||
{
|
fDetailMenuItem->Message()->what = kMsgMoreDetailsOn;
|
||||||
BListItem* item = ItemAt(IndexOf(point));
|
}
|
||||||
if (item == NULL)
|
// Offset point so cursor isn't over checkmark
|
||||||
return false;
|
ConvertToScreen(&where);
|
||||||
PackageItem* pItem = dynamic_cast<PackageItem*>(item);
|
where.x -= 10;
|
||||||
if (pItem != NULL) {
|
where.y -= 10;
|
||||||
*_tip = pItem->ToolTip();
|
fMenu->Go(where, true, true, BRect(where.x - 2, where.y - 2,
|
||||||
return true;
|
where.x + 2, where.y + 2), true);
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -688,11 +781,12 @@ PackageListView::AddPackage(uint32 install_type, const char* name,
|
|||||||
const char* repository)
|
const char* repository)
|
||||||
{
|
{
|
||||||
SuperItem* super;
|
SuperItem* super;
|
||||||
BString version;
|
BString simpleVersion;
|
||||||
BString tooltip(B_TRANSLATE_COMMENT("Package:", "Tooltip text"));
|
BString detailedVersion("");
|
||||||
tooltip.Append(" ").Append(name).Append("\n")
|
BString repositoryText(B_TRANSLATE_COMMENT("from repository",
|
||||||
.Append(B_TRANSLATE_COMMENT("Repository:", "Tooltip text"))
|
"List item text"));
|
||||||
.Append(" ").Append(repository).Append("\n");
|
repositoryText.Append(" ").Append(repository);
|
||||||
|
|
||||||
switch (install_type) {
|
switch (install_type) {
|
||||||
case PACKAGE_UPDATE:
|
case PACKAGE_UPDATE:
|
||||||
{
|
{
|
||||||
@@ -703,11 +797,12 @@ PackageListView::AddPackage(uint32 install_type, const char* name,
|
|||||||
}
|
}
|
||||||
super = fSuperUpdateItem;
|
super = fSuperUpdateItem;
|
||||||
|
|
||||||
version.SetTo(new_ver);
|
simpleVersion.SetTo(new_ver);
|
||||||
tooltip.Append(B_TRANSLATE_COMMENT("Updating version",
|
detailedVersion.Append(B_TRANSLATE_COMMENT("Updating version",
|
||||||
"Tooltip text"))
|
"List item text"))
|
||||||
.Append(" ").Append(cur_ver)
|
.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);
|
.Append(" ").Append(new_ver);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -721,9 +816,9 @@ PackageListView::AddPackage(uint32 install_type, const char* name,
|
|||||||
}
|
}
|
||||||
super = fSuperInstallItem;
|
super = fSuperInstallItem;
|
||||||
|
|
||||||
version.SetTo(new_ver);
|
simpleVersion.SetTo(new_ver);
|
||||||
tooltip.Append(B_TRANSLATE_COMMENT("Installing version",
|
detailedVersion.Append(B_TRANSLATE_COMMENT("Installing version",
|
||||||
"Tooltip text"))
|
"List item text"))
|
||||||
.Append(" ").Append(new_ver);
|
.Append(" ").Append(new_ver);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -737,9 +832,9 @@ PackageListView::AddPackage(uint32 install_type, const char* name,
|
|||||||
}
|
}
|
||||||
super = fSuperUninstallItem;
|
super = fSuperUninstallItem;
|
||||||
|
|
||||||
version.SetTo("");
|
simpleVersion.SetTo("");
|
||||||
tooltip.Append(B_TRANSLATE_COMMENT("Uninstalling version",
|
detailedVersion.Append(B_TRANSLATE_COMMENT("Uninstalling version",
|
||||||
"Tooltip text"))
|
"List item text"))
|
||||||
.Append(" ").Append(cur_ver);
|
.Append(" ").Append(cur_ver);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -748,8 +843,8 @@ PackageListView::AddPackage(uint32 install_type, const char* name,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
PackageItem* item = new PackageItem(name, version.String(), summary,
|
PackageItem* item = new PackageItem(name, simpleVersion.String(),
|
||||||
tooltip.String(), super);
|
detailedVersion.String(), repositoryText.String(), summary, super);
|
||||||
AddUnder(item, super);
|
AddUnder(item, super);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -777,3 +872,41 @@ PackageListView::ItemHeight()
|
|||||||
return fSuperUninstallItem->GetPackageItemHeight();
|
return fSuperUninstallItem->GetPackageItemHeight();
|
||||||
return 0;
|
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 <Button.h>
|
||||||
#include <GroupView.h>
|
#include <GroupView.h>
|
||||||
#include <OutlineListView.h>
|
#include <OutlineListView.h>
|
||||||
|
#include <MenuItem.h>
|
||||||
#include <Point.h>
|
#include <Point.h>
|
||||||
|
#include <PopUpMenu.h>
|
||||||
#include <ScrollView.h>
|
#include <ScrollView.h>
|
||||||
#include <StatusBar.h>
|
#include <StatusBar.h>
|
||||||
#include <StringView.h>
|
#include <StringView.h>
|
||||||
#include <ToolTip.h>
|
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
#include "StripeView.h"
|
#include "StripeView.h"
|
||||||
@@ -42,13 +43,17 @@ public:
|
|||||||
{ return fPackageItemHeight; };
|
{ return fPackageItemHeight; };
|
||||||
BBitmap* GetIcon() { return fPackageIcon; };
|
BBitmap* GetIcon() { return fPackageIcon; };
|
||||||
int16 GetIconSize() { return fIconSize; };
|
int16 GetIconSize() { return fIconSize; };
|
||||||
|
void SetDetailLevel(bool showMoreDetails);
|
||||||
|
bool GetDetailLevel() { return fShowMoreDetails; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void _SetHeights();
|
||||||
void _GetPackageIcon();
|
void _GetPackageIcon();
|
||||||
|
|
||||||
BString fLabel;
|
BString fLabel;
|
||||||
BFont fRegularFont;
|
BFont fRegularFont;
|
||||||
BFont fBoldFont;
|
BFont fBoldFont;
|
||||||
|
bool fShowMoreDetails;
|
||||||
font_height fFontHeight;
|
font_height fFontHeight;
|
||||||
float fPackageItemHeight;
|
float fPackageItemHeight;
|
||||||
BBitmap* fPackageIcon;
|
BBitmap* fPackageIcon;
|
||||||
@@ -59,22 +64,22 @@ private:
|
|||||||
class PackageItem : public BListItem {
|
class PackageItem : public BListItem {
|
||||||
public:
|
public:
|
||||||
PackageItem(const char* name,
|
PackageItem(const char* name,
|
||||||
const char* version,
|
const char* simple_version,
|
||||||
|
const char* detailed_version,
|
||||||
|
const char* repository,
|
||||||
const char* summary,
|
const char* summary,
|
||||||
const char* tooltip,
|
|
||||||
SuperItem* super);
|
SuperItem* super);
|
||||||
~PackageItem();
|
|
||||||
virtual void DrawItem(BView*, BRect, bool);
|
virtual void DrawItem(BView*, BRect, bool);
|
||||||
virtual void Update(BView *owner, const BFont *font);
|
virtual void Update(BView *owner, const BFont *font);
|
||||||
void SetItemHeight(const BFont* font);
|
void SetItemHeight(const BFont* font);
|
||||||
int NameCompare(PackageItem* item);
|
int NameCompare(PackageItem* item);
|
||||||
BTextToolTip* ToolTip() { return fToolTip; };
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BString fName;
|
BString fName;
|
||||||
BString fVersion;
|
BString fSimpleVersion;
|
||||||
|
BString fDetailedVersion;
|
||||||
|
BString fRepository;
|
||||||
BString fSummary;
|
BString fSummary;
|
||||||
BTextToolTip* fToolTip;
|
|
||||||
BFont fRegularFont;
|
BFont fRegularFont;
|
||||||
BFont fSmallFont;
|
BFont fSmallFont;
|
||||||
font_height fSmallFontHeight;
|
font_height fSmallFontHeight;
|
||||||
@@ -87,6 +92,8 @@ private:
|
|||||||
class PackageListView : public BOutlineListView {
|
class PackageListView : public BOutlineListView {
|
||||||
public:
|
public:
|
||||||
PackageListView();
|
PackageListView();
|
||||||
|
void AttachedToWindow();
|
||||||
|
virtual void MessageReceived(BMessage*);
|
||||||
virtual void FrameResized(float newWidth, float newHeight);
|
virtual void FrameResized(float newWidth, float newHeight);
|
||||||
virtual void MouseDown(BPoint where);
|
virtual void MouseDown(BPoint where);
|
||||||
void AddPackage(uint32 install_type,
|
void AddPackage(uint32 install_type,
|
||||||
@@ -98,13 +105,15 @@ public:
|
|||||||
void SortItems();
|
void SortItems();
|
||||||
float ItemHeight();
|
float ItemHeight();
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual bool GetToolTipAt(BPoint point, BToolTip** _tip);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void _SetItemHeights();
|
||||||
|
|
||||||
SuperItem* fSuperUpdateItem;
|
SuperItem* fSuperUpdateItem;
|
||||||
SuperItem* fSuperInstallItem;
|
SuperItem* fSuperInstallItem;
|
||||||
SuperItem* fSuperUninstallItem;
|
SuperItem* fSuperUninstallItem;
|
||||||
|
bool fShowMoreDetails;
|
||||||
|
BPopUpMenu *fMenu;
|
||||||
|
BMenuItem *fDetailMenuItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -112,7 +121,7 @@ class SoftwareUpdaterWindow : public BWindow {
|
|||||||
public:
|
public:
|
||||||
SoftwareUpdaterWindow();
|
SoftwareUpdaterWindow();
|
||||||
void MessageReceived(BMessage* message);
|
void MessageReceived(BMessage* message);
|
||||||
bool ConfirmUpdates(const char* text);
|
bool ConfirmUpdates();
|
||||||
void UpdatesApplying(const char* header,
|
void UpdatesApplying(const char* header,
|
||||||
const char* detail);
|
const char* detail);
|
||||||
bool UserCancelRequested();
|
bool UserCancelRequested();
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
|
|
||||||
static const float kTopOffset = 10.0f;
|
static const float kTopOffset = 10.0f;
|
||||||
|
static const int kIconStripeWidth = 30;
|
||||||
|
|
||||||
|
|
||||||
StripeView::StripeView(BBitmap& icon)
|
StripeView::StripeView(BBitmap& icon)
|
||||||
@@ -23,13 +24,17 @@ StripeView::StripeView(BBitmap& icon)
|
|||||||
BView("StripeView", B_WILL_DRAW),
|
BView("StripeView", B_WILL_DRAW),
|
||||||
fIcon(icon),
|
fIcon(icon),
|
||||||
fIconSize(0.0),
|
fIconSize(0.0),
|
||||||
fWidth(0.0)
|
fPreferredWidth(0.0),
|
||||||
|
fPreferredHeight(0.0)
|
||||||
{
|
{
|
||||||
SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
|
SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
|
||||||
|
|
||||||
if (fIcon.IsValid()) {
|
if (fIcon.IsValid()) {
|
||||||
fIconSize = fIcon.Bounds().Width();
|
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);
|
FillRect(updateRect);
|
||||||
|
|
||||||
BRect stripeRect = Bounds();
|
BRect stripeRect = Bounds();
|
||||||
stripeRect.right = fIconSize;
|
int32 iconLayoutScale = icon_layout_scale();
|
||||||
|
stripeRect.right = kIconStripeWidth * iconLayoutScale;
|
||||||
SetHighColor(tint_color(ViewColor(), B_DARKEN_1_TINT));
|
SetHighColor(tint_color(ViewColor(), B_DARKEN_1_TINT));
|
||||||
FillRect(stripeRect);
|
FillRect(stripeRect);
|
||||||
|
|
||||||
SetDrawingMode(B_OP_ALPHA);
|
SetDrawingMode(B_OP_ALPHA);
|
||||||
SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
|
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
|
BSize
|
||||||
StripeView::PreferredSize()
|
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)
|
StripeView::GetPreferredSize(float* _width, float* _height)
|
||||||
{
|
{
|
||||||
if (_width != NULL)
|
if (_width != NULL)
|
||||||
*_width = fWidth;
|
*_width = fPreferredWidth;
|
||||||
|
|
||||||
if (_height != NULL)
|
if (_height != NULL)
|
||||||
*_height = fIconSize + 2 * kTopOffset;
|
*_height = fPreferredHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -76,5 +83,5 @@ BSize
|
|||||||
StripeView::MaxSize()
|
StripeView::MaxSize()
|
||||||
{
|
{
|
||||||
return BLayoutUtils::ComposeSize(ExplicitMaxSize(),
|
return BLayoutUtils::ComposeSize(ExplicitMaxSize(),
|
||||||
BSize(fWidth, B_SIZE_UNLIMITED));
|
BSize(fPreferredWidth, B_SIZE_UNLIMITED));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,8 +28,16 @@ public:
|
|||||||
private:
|
private:
|
||||||
BBitmap fIcon;
|
BBitmap fIcon;
|
||||||
float fIconSize;
|
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 */
|
#endif /* _STRIPE_VIEW_H */
|
||||||
|
|||||||
@@ -43,19 +43,25 @@ UpdateAction::Perform()
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
fUpdateManager->CheckNetworkConnection();
|
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
|
fUpdateManager->Init(BPackageManager::B_ADD_INSTALLED_REPOSITORIES
|
||||||
| BPackageManager::B_ADD_REMOTE_REPOSITORIES
|
| BPackageManager::B_ADD_REMOTE_REPOSITORIES
|
||||||
| BPackageManager::B_REFRESH_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->SetDebugLevel(1);
|
||||||
//fUpdateManager->Update(&packages, packageCount);
|
if(action == UPDATE) {
|
||||||
fUpdateManager->FullSync();
|
// 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) {
|
} catch (BFatalErrorException ex) {
|
||||||
fUpdateManager->FinalUpdate(B_TRANSLATE("Updates did not complete"),
|
fUpdateManager->FinalUpdate(B_TRANSLATE("Updates did not complete"),
|
||||||
ex.Message());
|
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
|
void
|
||||||
UpdateManager::JobFailed(BSupportKit::BJob* job)
|
UpdateManager::JobFailed(BSupportKit::BJob* job)
|
||||||
{
|
{
|
||||||
@@ -137,6 +152,7 @@ UpdateManager::HandleProblems()
|
|||||||
ProblemWindow::SolverPackageSet uninstallPackages;
|
ProblemWindow::SolverPackageSet uninstallPackages;
|
||||||
if (!fProblemWindow->Go(fSolver,installPackages, uninstallPackages))
|
if (!fProblemWindow->Go(fSolver,installPackages, uninstallPackages))
|
||||||
throw BAbortedByUserException();
|
throw BAbortedByUserException();
|
||||||
|
fProblemWindow->Hide();
|
||||||
|
|
||||||
/* int32 problemCount = fSolver->CountProblems();
|
/* int32 problemCount = fSolver->CountProblems();
|
||||||
for (int32 i = 0; i < problemCount; i++) {
|
for (int32 i = 0; i < problemCount; i++) {
|
||||||
@@ -217,32 +233,8 @@ UpdateManager::ConfirmChanges(bool fromMostSpecific)
|
|||||||
printf("Upgrade count=%" B_PRId32 ", Install count=%" B_PRId32
|
printf("Upgrade count=%" B_PRId32 ", Install count=%" B_PRId32
|
||||||
", Uninstall count=%" B_PRId32 "\n",
|
", Uninstall count=%" B_PRId32 "\n",
|
||||||
upgradeCount, installCount, uninstallCount);
|
upgradeCount, installCount, uninstallCount);
|
||||||
BString text;
|
|
||||||
if (upgradeCount == 1)
|
fChangesConfirmed = fStatusWindow->ConfirmUpdates();
|
||||||
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());
|
|
||||||
if (!fChangesConfirmed)
|
if (!fChangesConfirmed)
|
||||||
throw BAbortedByUserException();
|
throw BAbortedByUserException();
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ public:
|
|||||||
~UpdateManager();
|
~UpdateManager();
|
||||||
|
|
||||||
void CheckNetworkConnection();
|
void CheckNetworkConnection();
|
||||||
|
int32 GetUpdateType();
|
||||||
virtual void JobFailed(BSupportKit::BJob* job);
|
virtual void JobFailed(BSupportKit::BJob* job);
|
||||||
virtual void JobAborted(BSupportKit::BJob* job);
|
virtual void JobAborted(BSupportKit::BJob* job);
|
||||||
void FinalUpdate(const char* header,
|
void FinalUpdate(const char* header,
|
||||||
|
|||||||
@@ -27,6 +27,17 @@ enum {
|
|||||||
STATE_MAX
|
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
|
// Message what values
|
||||||
static const uint32 kMsgTextUpdate = 'iUPD';
|
static const uint32 kMsgTextUpdate = 'iUPD';
|
||||||
static const uint32 kMsgProgressUpdate = 'iPRO';
|
static const uint32 kMsgProgressUpdate = 'iPRO';
|
||||||
@@ -35,8 +46,11 @@ static const uint32 kMsgCancelResponse = 'iCRE';
|
|||||||
static const uint32 kMsgUpdateConfirmed = 'iCON';
|
static const uint32 kMsgUpdateConfirmed = 'iCON';
|
||||||
static const uint32 kMsgWarningDismissed = 'iWDI';
|
static const uint32 kMsgWarningDismissed = 'iWDI';
|
||||||
static const uint32 kMsgNetworkAlert = 'iNAL';
|
static const uint32 kMsgNetworkAlert = 'iNAL';
|
||||||
|
static const uint32 kMsgGetUpdateType = 'iGUP';
|
||||||
static const uint32 kMsgRegister = 'iREG';
|
static const uint32 kMsgRegister = 'iREG';
|
||||||
static const uint32 kMsgFinalQuit = 'iFIN';
|
static const uint32 kMsgFinalQuit = 'iFIN';
|
||||||
|
static const uint32 kMsgMoreDetailsOn = 'iDON';
|
||||||
|
static const uint32 kMsgMoreDetailsOff = 'iDOF';
|
||||||
|
|
||||||
// Message data keys
|
// Message data keys
|
||||||
#define kKeyHeader "key_header"
|
#define kKeyHeader "key_header"
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ ProblemWindow::ProblemWindow()
|
|||||||
:
|
:
|
||||||
BWindow(BRect(0, 0, 400, 300), B_TRANSLATE_COMMENT("Package problems",
|
BWindow(BRect(0, 0, 400, 300), B_TRANSLATE_COMMENT("Package problems",
|
||||||
"Window title"), B_TITLED_WINDOW_LOOK,
|
"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_ASYNCHRONOUS_CONTROLS | B_NOT_MINIMIZABLE | B_AUTO_UPDATE_SIZE_LIMITS,
|
||||||
B_ALL_WORKSPACES),
|
B_ALL_WORKSPACES),
|
||||||
fDoneSemaphore(-1),
|
fDoneSemaphore(-1),
|
||||||
@@ -87,9 +87,9 @@ ProblemWindow::ProblemWindow()
|
|||||||
"a solution for each:")))
|
"a solution for each:")))
|
||||||
.Add(new BScrollView(NULL, viewPort = new BViewPort(), 0, false, true))
|
.Add(new BScrollView(NULL, viewPort = new BViewPort(), 0, false, true))
|
||||||
.AddGroup(B_HORIZONTAL)
|
.AddGroup(B_HORIZONTAL)
|
||||||
|
.AddGlue()
|
||||||
.Add(fCancelButton = new BButton(B_TRANSLATE("Cancel"),
|
.Add(fCancelButton = new BButton(B_TRANSLATE("Cancel"),
|
||||||
new BMessage(B_CANCEL)))
|
new BMessage(B_CANCEL)))
|
||||||
.AddGlue()
|
|
||||||
.Add(fRetryButton = new BButton(B_TRANSLATE("Retry"),
|
.Add(fRetryButton = new BButton(B_TRANSLATE("Retry"),
|
||||||
new BMessage(kRetryMessage)))
|
new BMessage(kRetryMessage)))
|
||||||
.End();
|
.End();
|
||||||
|
|||||||
Reference in New Issue
Block a user