Added support for using email address style named URLs ("... <...>") for
package licenses and URLs. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34723 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
5674af6f76
commit
613cdfa696
@ -566,20 +566,28 @@ AboutView::AddCopyrightEntry(const char *name, const char *text,
|
||||
if (i > 0)
|
||||
fCreditsView->Insert(", ");
|
||||
|
||||
BString licenseName;
|
||||
BString licenseURL;
|
||||
parse_named_url(license, licenseName, licenseURL);
|
||||
|
||||
BPath licensePath;
|
||||
if (_GetLicensePath(license, licensePath) == B_OK) {
|
||||
fCreditsView->InsertHyperText(license,
|
||||
if (_GetLicensePath(licenseURL, licensePath) == B_OK) {
|
||||
fCreditsView->InsertHyperText(licenseName,
|
||||
new OpenFileAction(licensePath.Path()));
|
||||
} else
|
||||
fCreditsView->Insert(license);
|
||||
fCreditsView->Insert(licenseName);
|
||||
}
|
||||
|
||||
fCreditsView->Insert("\n");
|
||||
}
|
||||
|
||||
if (url) {
|
||||
BString urlName;
|
||||
BString urlAddress;
|
||||
parse_named_url(url, urlName, urlAddress);
|
||||
|
||||
fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kLinkBlue);
|
||||
fCreditsView->InsertHyperText(url, new URLAction(url));
|
||||
fCreditsView->InsertHyperText(urlName, new URLAction(urlAddress));
|
||||
fCreditsView->Insert("\n");
|
||||
}
|
||||
fCreditsView->Insert("\n");
|
||||
|
@ -45,6 +45,26 @@ trim_string(const char* string, size_t len)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
parse_named_url(const BString& namedURL, BString& name, BString& url)
|
||||
{
|
||||
int32 urlStart = namedURL.FindFirst('<');
|
||||
int32 urlEnd = namedURL.FindLast('>');
|
||||
if (urlStart < 0 || urlEnd < 0 || urlStart + 1 >= urlEnd) {
|
||||
name = namedURL;
|
||||
url = namedURL;
|
||||
return;
|
||||
}
|
||||
|
||||
url.SetTo(namedURL.String() + urlStart + 1, urlEnd - urlStart - 1);
|
||||
|
||||
if (urlStart > 0)
|
||||
name = trim_string(namedURL, urlStart);
|
||||
else
|
||||
name = url;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - StringVector
|
||||
|
||||
|
||||
|
@ -21,6 +21,8 @@ BString trim_string(const char* string, size_t len);
|
||||
// Removes leading and trailing white space and replaces all sequences
|
||||
// of white space by a single space.
|
||||
|
||||
void parse_named_url(const BString& namedURL, BString& name, BString& url);
|
||||
|
||||
|
||||
class StringVector {
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user