Enable wordwrap in summary labels
authorMilian Wolff <mail@milianw.de>
Tue, 21 Feb 2017 08:23:13 +0000 (09:23 +0100)
committerMilian Wolff <mail@milianw.de>
Tue, 21 Feb 2017 08:42:06 +0000 (09:42 +0100)
When we encounter long debuggee command lines, we used to put them
into one line. This increased the minimal width of the mainwindow,
which could even expand beyond the screen dimensions, making parts
of the window invisible.

By enabling wordwrap, we can break the command line after every
argument. Additionally, to cope with extremely long arguments,
we add zero-width spaces after every 50 word characters, to enable
word wrap at these places.

BUG: 376741

src/analyze/gui/mainwindow.cpp
src/analyze/gui/mainwindow.ui

index 24fdc97..6bf762f 100644 (file)
@@ -175,6 +175,13 @@ void setupCallerCalle(CallerCalleeModel* model, QTreeView* view, CostDelegate* c
     QObject::connect(filterModule, &QLineEdit::textChanged, callerCalleeProxy, &TreeProxy::setModuleFilter);
     addContextMenu(view, CallerCalleeModel::LocationRole);
 }
+
+QString insertWordWrapMarkers(QString text)
+{
+    // insert zero-width spaces after every 50 word characters to enable word wrap in the middle of words
+    static const QRegularExpression pattern(QStringLiteral("(\\w{50})"));
+    return text.replace(pattern, QStringLiteral("\\1\u200B"));
+}
 }
 
 MainWindow::MainWindow(QWidget* parent)
@@ -241,13 +248,14 @@ MainWindow::MainWindow(QWidget* parent)
         const double peakTimeS = 0.001 * data.peakTime;
         {
             QTextStream stream(&textLeft);
+            const auto debuggee = insertWordWrapMarkers(data.debuggee);
             stream << "<qt><dl>"
                    << (data.fromAttached ? i18n("<dt><b>debuggee</b>:</dt><dd "
                                                 "style='font-family:monospace;'>%1 <i>(attached)</i></dd>",
-                                                data.debuggee)
+                                                debuggee)
                                          : i18n("<dt><b>debuggee</b>:</dt><dd "
                                                 "style='font-family:monospace;'>%1</dd>",
-                                                data.debuggee))
+                                                debuggee))
                    // xgettext:no-c-format
                    << i18n("<dt><b>total runtime</b>:</dt><dd>%1s</dd>", totalTimeS)
                    << i18n("<dt><b>total system memory</b>:</dt><dd>%1</dd>",
index 5c8381f..e367cb6 100644 (file)
                  <property name="text">
                   <string notr="true">summary</string>
                  </property>
+                 <property name="wordWrap">
+                  <bool>true</bool>
+                 </property>
                  <property name="textInteractionFlags">
                   <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
                  </property>
                  <property name="text">
                   <string notr="true">summary</string>
                  </property>
+                 <property name="wordWrap">
+                  <bool>true</bool>
+                 </property>
                  <property name="textInteractionFlags">
                   <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
                  </property>