diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index 0614c786f..a34c55741 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -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 = "
" + message + "
"; if ( !details.isEmpty() ) { - text += "" + details + "
"; + text += "" + simplifyText( details ) + "
"; } if ( shouldOfferWebPaste ) {