+
+void VPNControl::logAppend(const QString &text)
+{
+ if (!text.isEmpty()) {
+ // How many lines to add
+ int newLines = text.count('\n');
+ int currentLines = logText.count('\n');
+ int removeLines = currentLines + newLines - 18;
+
+ // Remove excess lines
+ while (removeLines > 0) {
+ int nextLine = logText.lastIndexOf('\n');
+ if (nextLine > 0) {
+ logText = logText.left(nextLine);
+ }
+ removeLines--;
+ }
+
+ // Add new lines
+ logText.prepend(text);
+ emit logTextChanged(logText);
+ }
+}