Sniff URLs in descriptions and be more defensive re MSW scrolling.
This commit is contained in:
parent
f9bbaed7a1
commit
faabcc079a
|
@ -13,7 +13,7 @@
|
|||
|
||||
DIALOG_PCM_BASE::DIALOG_PCM_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
|
||||
{
|
||||
this->SetSizeHints( wxSize( 900,560 ), wxDefaultSize );
|
||||
this->SetSizeHints( wxSize( 960,560 ), wxDefaultSize );
|
||||
|
||||
wxBoxSizer* m_MainSizer;
|
||||
m_MainSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
|
|
@ -42,10 +42,10 @@
|
|||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="minimum_size">900,560</property>
|
||||
<property name="minimum_size">960,560</property>
|
||||
<property name="name">DIALOG_PCM_BASE</property>
|
||||
<property name="pos"></property>
|
||||
<property name="size">900,560</property>
|
||||
<property name="size">960,560</property>
|
||||
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
|
||||
<property name="subclass">DIALOG_SHIM; dialog_shim.h; forward_declare</property>
|
||||
<property name="title">Plugin And Content Manager</property>
|
||||
|
|
|
@ -71,7 +71,7 @@ class DIALOG_PCM_BASE : public DIALOG_SHIM
|
|||
|
||||
public:
|
||||
|
||||
DIALOG_PCM_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Plugin And Content Manager"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 900,560 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
||||
DIALOG_PCM_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Plugin And Content Manager"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 960,560 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
||||
~DIALOG_PCM_BASE();
|
||||
|
||||
};
|
||||
|
|
|
@ -75,6 +75,7 @@ PANEL_PACKAGES_VIEW::PANEL_PACKAGES_VIEW( wxWindow*
|
|||
|
||||
m_packageListWindow->SetBackgroundColour( wxStaticText::GetClassDefaultAttributes().colBg );
|
||||
m_infoScrollWindow->SetBackgroundColour( wxStaticText::GetClassDefaultAttributes().colBg );
|
||||
m_infoScrollWindow->EnableScrolling( false, true );
|
||||
|
||||
ClearData();
|
||||
}
|
||||
|
@ -141,9 +142,51 @@ void PANEL_PACKAGES_VIEW::setPackageDetails( const PACKAGE_VIEW_DATA& aPackageDa
|
|||
|
||||
details << "<h5>" + package.name + "</h5>";
|
||||
|
||||
auto format_desc =
|
||||
[]( const wxString& text ) -> wxString
|
||||
{
|
||||
wxString result;
|
||||
bool inURL = false;
|
||||
wxString url;
|
||||
|
||||
for( unsigned i = 0; i < text.length(); ++i )
|
||||
{
|
||||
wxUniChar c = text[i];
|
||||
|
||||
if( inURL )
|
||||
{
|
||||
if( c == ' ' )
|
||||
{
|
||||
result += wxString::Format( "<a href='%s'>%s</a>", url, url );
|
||||
inURL = false;
|
||||
|
||||
result += c;
|
||||
}
|
||||
else
|
||||
{
|
||||
url += c;
|
||||
}
|
||||
}
|
||||
else if( text.Mid( i, 5 ) == "http:" || text.Mid( i, 6 ) == "https:" )
|
||||
{
|
||||
url = c;
|
||||
inURL = true;
|
||||
}
|
||||
else if( c == '\n' )
|
||||
{
|
||||
result += "</p><p>";
|
||||
}
|
||||
else
|
||||
{
|
||||
result += c;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
wxString desc = package.description_full;
|
||||
desc.Replace( "\n", "</p><p>", true );
|
||||
details << "<p>" + desc + "</p>";
|
||||
details << "<p>" + format_desc( desc ) + "</p>";
|
||||
|
||||
details << "<p><b>" + _( "Metadata" ) + "</b></p>";
|
||||
details << "<ul>";
|
||||
|
@ -165,15 +208,18 @@ void PANEL_PACKAGES_VIEW::setPackageDetails( const PACKAGE_VIEW_DATA& aPackageDa
|
|||
details << "<li>" + _( "Tags: " ) + tags_str + "</li>";
|
||||
}
|
||||
|
||||
auto format_url =
|
||||
auto format_entry =
|
||||
[]( const std::pair<const std::string, wxString>& entry ) -> wxString
|
||||
{
|
||||
wxString url = entry.second;
|
||||
wxString name = entry.first;
|
||||
wxString url = EscapeHTML( entry.second );
|
||||
|
||||
if( entry.first == "email" )
|
||||
url = "mailto:" + url;
|
||||
|
||||
return "<a href='" + EscapeHTML( url ) + "'>" + EscapeHTML( url ) + "</a>";
|
||||
if( name == "email" )
|
||||
return wxString::Format( "<a href='mailto:%s'>%s</a>", url, url );
|
||||
else if( url.StartsWith( "http:" ) || url.StartsWith( "https:" ) )
|
||||
return wxString::Format( "<a href='%s'>%s</a>", url, url );
|
||||
else
|
||||
return entry.second;
|
||||
};
|
||||
|
||||
auto write_contact =
|
||||
|
@ -182,7 +228,7 @@ void PANEL_PACKAGES_VIEW::setPackageDetails( const PACKAGE_VIEW_DATA& aPackageDa
|
|||
details << "<li>" + type + ": " + contact.name + "<ul>";
|
||||
|
||||
for( const std::pair<const std::string, wxString>& entry : contact.contact )
|
||||
details << "<li>" + entry.first + ": " + format_url( entry ) + "</li>";
|
||||
details << "<li>" + entry.first + ": " + format_entry( entry ) + "</li>";
|
||||
|
||||
details << "</ul>";
|
||||
};
|
||||
|
@ -197,7 +243,7 @@ void PANEL_PACKAGES_VIEW::setPackageDetails( const PACKAGE_VIEW_DATA& aPackageDa
|
|||
details << "<li>" + _( "Resources" ) + "<ul>";
|
||||
|
||||
for( const std::pair<const std::string, wxString>& entry : package.resources )
|
||||
details << "<li>" + entry.first + wxS( ": " ) + format_url( entry ) + "</li>";
|
||||
details << "<li>" + entry.first + wxS( ": " ) + format_entry( entry ) + "</li>";
|
||||
|
||||
details << "</ul>";
|
||||
}
|
||||
|
@ -526,13 +572,13 @@ void PANEL_PACKAGES_VIEW::updatePackageList()
|
|||
void PANEL_PACKAGES_VIEW::OnSizeInfoBox( wxSizeEvent& aEvent )
|
||||
{
|
||||
wxSize infoSize = m_infoText->GetParent()->GetClientSize();
|
||||
infoSize.x -= 20; // approximation of scrollbars should they be needed
|
||||
infoSize.x -= 8;
|
||||
m_infoText->SetMinSize( infoSize );
|
||||
m_infoText->SetMaxSize( infoSize );
|
||||
m_infoText->SetSize( infoSize );
|
||||
m_infoText->Layout();
|
||||
|
||||
infoSize.y = m_infoText->GetInternalRepresentation()->GetHeight() + 20;
|
||||
infoSize.y = m_infoText->GetInternalRepresentation()->GetHeight() + 12;
|
||||
m_infoText->SetMinSize( infoSize );
|
||||
m_infoText->SetMaxSize( infoSize );
|
||||
m_infoText->SetSize( infoSize );
|
||||
|
|
|
@ -19,7 +19,7 @@ PANEL_PACKAGES_VIEW_BASE::PANEL_PACKAGES_VIEW_BASE( wxWindow* parent, wxWindowID
|
|||
m_splitter1 = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3DSASH|wxSP_LIVE_UPDATE );
|
||||
m_splitter1->SetSashGravity( 0.5 );
|
||||
m_splitter1->Connect( wxEVT_IDLE, wxIdleEventHandler( PANEL_PACKAGES_VIEW_BASE::m_splitter1OnIdle ), NULL, this );
|
||||
m_splitter1->SetMinimumPaneSize( 400 );
|
||||
m_splitter1->SetMinimumPaneSize( 420 );
|
||||
|
||||
m_panelList = new wxPanel( m_splitter1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
||||
wxBoxSizer* bPanelListSizer;
|
||||
|
@ -111,7 +111,7 @@ PANEL_PACKAGES_VIEW_BASE::PANEL_PACKAGES_VIEW_BASE( wxWindow* parent, wxWindowID
|
|||
bSizerVersionButtons->Add( m_buttonInstall, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );
|
||||
|
||||
|
||||
m_sizerVersions->Add( bSizerVersionButtons, 0, wxEXPAND|wxRIGHT, 15 );
|
||||
m_sizerVersions->Add( bSizerVersionButtons, 0, wxEXPAND|wxRIGHT, 5 );
|
||||
|
||||
|
||||
bSizerScrolledWindow->Add( m_sizerVersions, 0, wxEXPAND|wxRIGHT|wxLEFT, 3 );
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="min_pane_size">400</property>
|
||||
<property name="min_pane_size">420</property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
|
@ -584,7 +584,7 @@
|
|||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">15</property>
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND|wxRIGHT</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxBoxSizer" expanded="1">
|
||||
|
|
Loading…
Reference in New Issue