[libcalamaresui] Display a reduced amount of details
Cut the error message from down to a maximum of 8 lines so that the messagebox does not hopelessly overflow.
This commit is contained in:
parent
f0fd47eeb3
commit
4f78afe67e
@ -136,6 +136,40 @@ ViewManager::insertViewStep( int before, ViewStep* step )
|
||||
emit endInsertRows();
|
||||
}
|
||||
|
||||
/** Makes a long details message suitable for display
|
||||
*
|
||||
* @returns a (possibly shortened) version of @p text that
|
||||
* will fit sensibly in a messagebox.
|
||||
*/
|
||||
static QString
|
||||
simplifyText( const QString& text )
|
||||
{
|
||||
constexpr const int maxLines = 8;
|
||||
constexpr const int maxChars = 640;
|
||||
QString shorter = text.simplified();
|
||||
if ( shorter.count( '\n' ) >= maxLines )
|
||||
{
|
||||
int from = -1;
|
||||
for ( int i = 0; i < maxLines; ++i )
|
||||
{
|
||||
from = shorter.indexOf( '\n', from + 1 );
|
||||
if ( from < 0 )
|
||||
{
|
||||
// That's odd, we counted at least maxLines newlines before
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( from > 0 )
|
||||
{
|
||||
shorter.truncate( from );
|
||||
}
|
||||
}
|
||||
if ( shorter.length() > maxChars )
|
||||
{
|
||||
shorter.truncate( maxChars );
|
||||
}
|
||||
return shorter;
|
||||
}
|
||||
|
||||
void
|
||||
ViewManager::onInstallationFailed( const QString& message, const QString& details )
|
||||
@ -152,7 +186,7 @@ ViewManager::onInstallationFailed( const QString& message, const QString& detail
|
||||
QString text = "<p>" + message + "</p>";
|
||||
if ( !details.isEmpty() )
|
||||
{
|
||||
text += "<p>" + details + "</p>";
|
||||
text += "<p>" + simplifyText( details ) + "</p>";
|
||||
}
|
||||
if ( shouldOfferWebPaste )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user