From: David Date: Wed, 19 Mar 2014 03:55:27 +0000 (+0000) Subject: Fixed log output window. Rearranted components to increase space for the X-Git-Url: https://www.flypig.org.uk/git/?p=openvpnui.git;a=commitdiff_plain;h=c45d410d3b300c1e37398e8c6c2bd453ee3da696 Fixed log output window. Rearranted components to increase space for the log output rectangle. Moved required OpenVPN options from file to command line parameters. --- diff --git a/qml/pages/ConnectPage.qml b/qml/pages/ConnectPage.qml index 665226e..08cbdb6 100644 --- a/qml/pages/ConnectPage.qml +++ b/qml/pages/ConnectPage.qml @@ -122,7 +122,10 @@ Page { id: connect text: "Connect" enabled: true - onClicked: VpnControl.vpnConnect() + onClicked: { + VpnControl.logAppend('\n') + VpnControl.vpnConnect() + } } Button { id : disconnect @@ -131,6 +134,7 @@ Page { onClicked: VpnControl.vpnDisconnect(); } } + Label { id: statusText text: "No status" @@ -144,7 +148,7 @@ Page { BusyIndicator { id: busy running: false - size: BusyIndicatorSize.Large + size: BusyIndicatorSize.Medium anchors.verticalCenter: parent.verticalCenter } } @@ -157,25 +161,27 @@ Page { } //radius: Theme.paddingSmall anchors.horizontalCenter: parent.horizontalCenter - height: (20 * Theme.fontSizeTiny) + (2 * Theme.paddingLarge) + height: (24 * Theme.fontSizeTiny) + (2 * Theme.paddingLarge) width: parent.width - 2 * Theme.paddingLarge x: Theme.paddingLarge + //TextEdit { Label { id: logOutput textFormat: Text.PlainText width: parent.width - 2 * Theme.paddingSmall - height: parent.height - 2 * Theme.paddingSmall + height: parent.height - 0 * Theme.paddingSmall wrapMode: Text.WrapAnywhere font.pixelSize: Theme.fontSizeTiny * 0.6 font.family: "Monospace" color: Theme.highlightColor visible: true text: VpnControl.logText - maximumLineCount: Math.floor(18 / 0.6) verticalAlignment: Text.AlignBottom x: Theme.paddingSmall y: Theme.paddingSmall + //readOnly: true + clip: true } } } diff --git a/src/vpncontrol.cpp b/src/vpncontrol.cpp index 12ca3f1..3383dcc 100644 --- a/src/vpncontrol.cpp +++ b/src/vpncontrol.cpp @@ -230,6 +230,16 @@ void VPNControl::collectArguments () { arguments.clear(); addArgumentNonempty("config", configFile); + addOption("client", true); + addOption("persist-key", true); + addOption("persist-tun", true); + addOption("nobind", true); + addArgument("resolv-retry", "infinite"); + addArgument("dev", "tun"); + addArgument("verb", "3"); + addArgument("proto", "udp"); + addArgument("user", "nemo"); + addArgument("group", "nemo"); addArgumentNonempty("remote", server); addArgumentNonempty("port", QString::number(port)); addOption("comp-lzo", compressed); @@ -335,22 +345,27 @@ void VPNControl::updateConfiguration() void VPNControl::logAppend(const QString &text) { if (!text.isEmpty()) { + QString append = text; + // Ensure we end with a newline + if (!append.endsWith('\n')) { + append += '\n'; + } // How many lines to add - int newLines = text.count('\n'); + int newLines = append.count('\n'); int currentLines = logText.count('\n'); - int removeLines = currentLines + newLines - 18; - - // Remove excess lines -// while (removeLines > 0) { -// int nextLine = logText.indexOf('\n'); -// if (nextLine > 0) { -// logText = logText.right(nextLine); -// } -// removeLines--; -// } + int removeLines = currentLines + newLines - 24; + + // Remove excess lines from the top + while (removeLines > 0) { + int nextLine = logText.indexOf('\n'); + if (nextLine > 0) { + logText = logText.mid(nextLine + 1); + } + removeLines--; + } // Add new lines - logText.append(text); + logText.append(append); emit logTextChanged(logText); } }