HaikuDepot: Changelog & Contents Tabs
Disable the changelog tab in the case that a package has no changelog. Also disable the contents tab and do not attempt to load the package contents in the case where a package is not installed on the host. Resolves #15299 Change-Id: Id17daf46aba6709f35438db2ee30f3485fc251ea Reviewed-on: https://review.haiku-os.org/c/haiku/+/2749 Reviewed-by: humdinger <[email protected]> Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
05bd53615a
commit
8c6ebdec76
@@ -605,7 +605,7 @@ Model::PopulatePackage(const PackageInfoRef& package, uint32 flags)
|
||||
fPopulatedPackages.Add(package);
|
||||
}
|
||||
|
||||
if ((flags & POPULATE_CHANGELOG) != 0) {
|
||||
if ((flags & POPULATE_CHANGELOG) != 0 && package->HasChangelog()) {
|
||||
_PopulatePackageChangelog(package);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright 2013-2014, Stephan Aßmus <[email protected]>.
|
||||
* Copyright 2013, Rene Gollent <[email protected]>.
|
||||
* Copyright 2016-2019, Andrew Lindesay <[email protected]>.
|
||||
* Copyright 2016-2020, Andrew Lindesay <[email protected]>.
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@@ -471,6 +471,7 @@ PackageInfo::PackageInfo()
|
||||
fPublisher(),
|
||||
fShortDescription(),
|
||||
fFullDescription(),
|
||||
fHasChangelog(false),
|
||||
fChangelog(),
|
||||
fUserRatings(),
|
||||
fCachedRatingSummary(),
|
||||
@@ -501,6 +502,7 @@ PackageInfo::PackageInfo(const BPackageInfo& info)
|
||||
fPublisher(),
|
||||
fShortDescription(info.Summary()),
|
||||
fFullDescription(info.Description()),
|
||||
fHasChangelog(false),
|
||||
fChangelog(),
|
||||
fUserRatings(),
|
||||
fCachedRatingSummary(),
|
||||
@@ -547,6 +549,7 @@ PackageInfo::PackageInfo(const BString& name,
|
||||
fPublisher(publisher),
|
||||
fShortDescription(shortDescription),
|
||||
fFullDescription(fullDescription),
|
||||
fHasChangelog(false),
|
||||
fChangelog(),
|
||||
fCategories(),
|
||||
fUserRatings(),
|
||||
@@ -578,6 +581,7 @@ PackageInfo::PackageInfo(const PackageInfo& other)
|
||||
fPublisher(other.fPublisher),
|
||||
fShortDescription(other.fShortDescription),
|
||||
fFullDescription(other.fFullDescription),
|
||||
fHasChangelog(other.fHasChangelog),
|
||||
fChangelog(other.fChangelog),
|
||||
fCategories(other.fCategories),
|
||||
fUserRatings(other.fUserRatings),
|
||||
@@ -611,6 +615,7 @@ PackageInfo::operator=(const PackageInfo& other)
|
||||
fPublisher = other.fPublisher;
|
||||
fShortDescription = other.fShortDescription;
|
||||
fFullDescription = other.fFullDescription;
|
||||
fHasChangelog = other.fHasChangelog;
|
||||
fChangelog = other.fChangelog;
|
||||
fCategories = other.fCategories;
|
||||
fUserRatings = other.fUserRatings;
|
||||
@@ -642,6 +647,7 @@ PackageInfo::operator==(const PackageInfo& other) const
|
||||
&& fPublisher == other.fPublisher
|
||||
&& fShortDescription == other.fShortDescription
|
||||
&& fFullDescription == other.fFullDescription
|
||||
&& fHasChangelog == other.fHasChangelog
|
||||
&& fChangelog == other.fChangelog
|
||||
&& fCategories == other.fCategories
|
||||
&& fUserRatings == other.fUserRatings
|
||||
@@ -714,6 +720,13 @@ PackageInfo::SetIcon(const BitmapRef& icon)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PackageInfo::SetHasChangelog(bool value)
|
||||
{
|
||||
fHasChangelog = value;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PackageInfo::SetChangelog(const BString& changelog)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2013-2014, Stephan Aßmus <superstippi@gmx.de>.
|
||||
* Copyright 2016-2019, Andrew Lindesay <apl@lindesay.co.nz>.
|
||||
* Copyright 2016-2020, Andrew Lindesay <apl@lindesay.co.nz>.
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef PACKAGE_INFO_H
|
||||
@@ -286,6 +286,10 @@ public:
|
||||
void SetIcon(const BitmapRef& icon);
|
||||
const BitmapRef& Icon() const
|
||||
{ return fIcon; }
|
||||
|
||||
void SetHasChangelog(bool value);
|
||||
bool HasChangelog() const
|
||||
{ return fHasChangelog; }
|
||||
void SetChangelog(const BString& changelog);
|
||||
const BString& Changelog() const
|
||||
{ return fChangelog; }
|
||||
@@ -380,6 +384,7 @@ private:
|
||||
PublisherInfo fPublisher;
|
||||
BString fShortDescription;
|
||||
BString fFullDescription;
|
||||
bool fHasChangelog;
|
||||
BString fChangelog;
|
||||
CategoryList fCategories;
|
||||
UserRatingList fUserRatings;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2019, Andrew Lindesay <apl@lindesay.co.nz>.
|
||||
* Copyright 2017-2020, Andrew Lindesay <apl@lindesay.co.nz>.
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@@ -159,6 +159,8 @@ PackageFillingPkgListener::ConsumePackage(const PackageInfoRef& package,
|
||||
|
||||
package->SetRatingSummary(summary);
|
||||
|
||||
package->SetHasChangelog(pkg->HasChangelog());
|
||||
|
||||
if (!pkg->ProminenceOrderingIsNull())
|
||||
package->SetProminence(pkg->ProminenceOrdering());
|
||||
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
"derivedRating": {
|
||||
"type": "number"
|
||||
},
|
||||
"hasChangelog": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"pkgScreenshots": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
|
||||
@@ -5,68 +5,71 @@
|
||||
"javaType": "org.haiku.haikudepotserver.reference.model.dumpexport.DumpExportReference",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"naturalLanguages": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"javaType": "org.haiku.haikudepotserver.reference.model.dumpexport.DumpExportReferenceNaturalLanguage",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"isPopular": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"pkgCategories": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"javaType": "org.haiku.haikudepotserver.reference.model.dumpexport.DumpExportReferencePkgCategory",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"userRatingStabilities": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"javaType": "org.haiku.haikudepotserver.reference.model.dumpexport.DumpExportReferenceUserRatingStability",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"countries": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"javaType": "org.haiku.haikudepotserver.reference.model.dumpexport.DumpExportReferenceCountry",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"naturalLanguages": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"javaType": "org.haiku.haikudepotserver.reference.model.dumpexport.DumpExportReferenceNaturalLanguage",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"isPopular": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"pkgCategories": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"javaType": "org.haiku.haikudepotserver.reference.model.dumpexport.DumpExportReferencePkgCategory",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"userRatingStabilities": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"javaType": "org.haiku.haikudepotserver.reference.model.dumpexport.DumpExportReferenceUserRatingStability",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"ordering": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"countries": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"javaType": "org.haiku.haikudepotserver.reference.model.dumpexport.DumpExportReferenceCountry",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright 2015, TigerKid001.
|
||||
* Copyright 2020, Andrew Lindesay <apl@lindesay.co.nz>
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@@ -293,9 +294,6 @@ PackageContentsView::SetPackage(const PackageInfoRef& package)
|
||||
return;
|
||||
}
|
||||
|
||||
// printf("PackageContentsView::SetPackage(%s)\n",
|
||||
// package.Get() != NULL ? package->Name().String() : "NULL");
|
||||
|
||||
Clear();
|
||||
|
||||
{
|
||||
@@ -303,7 +301,12 @@ PackageContentsView::SetPackage(const PackageInfoRef& package)
|
||||
fPackage = package;
|
||||
fLastPackageState = package.Get() != NULL ? package->State() : NONE;
|
||||
}
|
||||
release_sem_etc(fContentPopulatorSem, 1, 0);
|
||||
|
||||
// if the package is not installed then there is no point in attempting to
|
||||
// populate data for it.
|
||||
|
||||
if (package.Get() != NULL && package->State() == ACTIVATED)
|
||||
release_sem_etc(fContentPopulatorSem, 1, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -349,7 +352,7 @@ PackageContentsView::_ContentPopulatorThread(void* arg)
|
||||
}
|
||||
|
||||
if (package.Get() != NULL) {
|
||||
if (!view->_PopuplatePackageContens(*package.Get())) {
|
||||
if (!view->_PopulatePackageContents(*package.Get())) {
|
||||
if (view->LockLooperWithTimeout(1000000) == B_OK) {
|
||||
view->fContentListView->AddItem(
|
||||
new BStringItem(B_TRANSLATE("<Package contents not "
|
||||
@@ -365,7 +368,7 @@ PackageContentsView::_ContentPopulatorThread(void* arg)
|
||||
|
||||
|
||||
bool
|
||||
PackageContentsView::_PopuplatePackageContens(const PackageInfo& package)
|
||||
PackageContentsView::_PopulatePackageContents(const PackageInfo& package)
|
||||
{
|
||||
BPath packagePath;
|
||||
|
||||
@@ -386,7 +389,7 @@ PackageContentsView::_PopuplatePackageContens(const PackageInfo& package)
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
printf("PackageContentsView::_PopuplatePackageContens(): "
|
||||
printf("PackageContentsView::_PopulatePackageContents(): "
|
||||
"unknown install location");
|
||||
return false;
|
||||
}
|
||||
@@ -400,7 +403,7 @@ PackageContentsView::_PopuplatePackageContens(const PackageInfo& package)
|
||||
|
||||
status_t status = reader.Init(packagePath.Path());
|
||||
if (status != B_OK) {
|
||||
printf("PackageContentsView::_PopuplatePackageContens(): "
|
||||
printf("PackageContentsView::_PopulatePackageContents(): "
|
||||
"failed to init BPackageReader(%s): %s\n",
|
||||
packagePath.Path(), strerror(status));
|
||||
return false;
|
||||
@@ -411,7 +414,7 @@ PackageContentsView::_PopuplatePackageContens(const PackageInfo& package)
|
||||
fPackageLock, fPackage);
|
||||
status = reader.ParseContent(&contentHandler);
|
||||
if (status != B_OK) {
|
||||
printf("PackageContentsView::_PopuplatePackageContens(): "
|
||||
printf("PackageContentsView::_PopulatePackageContents(): "
|
||||
"failed parse package contents: %s\n", strerror(status));
|
||||
// NOTE: Do not return false, since it taken to mean this
|
||||
// is a remote package, but is it not, we simply want to stop
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright 2015, TigerKid001.
|
||||
* Copyright 2020, Andrew Lindesay <apl@lindesay.co.nz>
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef PACKAGE_CONTENTS_VIEW_H
|
||||
@@ -27,7 +28,7 @@ public:
|
||||
private:
|
||||
void _InitContentPopulator();
|
||||
static int32 _ContentPopulatorThread(void* arg);
|
||||
bool _PopuplatePackageContens(
|
||||
bool _PopulatePackageContents(
|
||||
const PackageInfo& package);
|
||||
int32 _InstallLocation(
|
||||
const PackageInfo& package) const;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2013-2014, Stephan Aßmus <superstippi@gmx.de>.
|
||||
* Copyright 2018-2019, Andrew Lindesay <apl@lindesay.co.nz>.
|
||||
* Copyright 2018-2020, Andrew Lindesay <apl@lindesay.co.nz>.
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@@ -54,6 +54,14 @@
|
||||
#define B_TRANSLATION_CONTEXT "PackageInfoView"
|
||||
|
||||
|
||||
enum {
|
||||
TAB_ABOUT = 0,
|
||||
TAB_RATINGS = 1,
|
||||
TAB_CHANGELOG = 2,
|
||||
TAB_CONTENTS = 3
|
||||
};
|
||||
|
||||
|
||||
static const float kContentTint = (B_NO_TINT + B_LIGHTEN_1_TINT) / 2.0f;
|
||||
|
||||
|
||||
@@ -1222,12 +1230,12 @@ public:
|
||||
AddTab(fChangelogView);
|
||||
AddTab(fContentsView);
|
||||
|
||||
TabAt(0)->SetLabel(B_TRANSLATE("About"));
|
||||
TabAt(1)->SetLabel(B_TRANSLATE("Ratings"));
|
||||
TabAt(2)->SetLabel(B_TRANSLATE("Changelog"));
|
||||
TabAt(3)->SetLabel(B_TRANSLATE("Contents"));
|
||||
TabAt(TAB_ABOUT)->SetLabel(B_TRANSLATE("About"));
|
||||
TabAt(TAB_RATINGS)->SetLabel(B_TRANSLATE("Ratings"));
|
||||
TabAt(TAB_CHANGELOG)->SetLabel(B_TRANSLATE("Changelog"));
|
||||
TabAt(TAB_CONTENTS)->SetLabel(B_TRANSLATE("Contents"));
|
||||
|
||||
Select(0);
|
||||
Select(TAB_ABOUT);
|
||||
}
|
||||
|
||||
virtual ~PagesView()
|
||||
@@ -1238,7 +1246,15 @@ public:
|
||||
void SetPackage(const PackageInfoRef& package, bool switchToDefaultTab)
|
||||
{
|
||||
if (switchToDefaultTab)
|
||||
Select(0);
|
||||
Select(TAB_ABOUT);
|
||||
|
||||
TabAt(TAB_CHANGELOG)->SetEnabled(
|
||||
package.Get() != NULL && package->HasChangelog());
|
||||
TabAt(TAB_CONTENTS)->SetEnabled(
|
||||
package.Get() != NULL && package->State() == ACTIVATED);
|
||||
Invalidate(TabFrame(TAB_CHANGELOG));
|
||||
Invalidate(TabFrame(TAB_CONTENTS));
|
||||
|
||||
fAboutView->SetPackage(*package.Get());
|
||||
fUserRatingsView->SetPackage(*package.Get());
|
||||
fChangelogView->SetPackage(*package.Get());
|
||||
|
||||
Reference in New Issue
Block a user