id: root
property alias label: titleText.text
- property alias value: valueText.text
property alias labelColor: titleText.color
property alias valueColor: valueText.color
property real labelMargin: Theme.paddingLarge
property int _duration: 200
+ property string value
+ property string placeholderText
width: parent ? parent.width : 0
height: contentItem.height
width: Math.min(implicitWidth, parent.width)
truncationMode: TruncationMode.Fade
horizontalAlignment: ((implicitWidth <= (parent.width - titleText.width)) ? Text.AlignLeft : Text.AlignRight)
+ text: (value != "" ? value : placeholderText)
}
}
}
Page {
id: page
- allowedOrientations: Orientation.All
+ //allowedOrientations: Orientation.All
property string dir: "/"
property string initialDir: ""
property bool initial: false // this is set to true if the page is initial page
Functions.cancel()
break;
case 2:
- pageStack.push(Qt.resolvedUrl("SearchPage.qml"), { dir: page.dir });
+ Functions.fileSelect("")
break;
case 3:
+ pageStack.push(Qt.resolvedUrl("SearchPage.qml"), { dir: page.dir });
+ break;
+ case 4:
fileModel.showAll = true
menuShowAll.visible = false
menuShowFiltered.visible = true
break;
- case 4:
+ case 5:
fileModel.showAll = false
menuShowFiltered.visible = false
menuShowAll.visible = true
onClicked: _selectedMenu = 1
}
MenuItem {
- text: qsTr("Search")
+ text: qsTr("Clear")
onClicked: _selectedMenu = 2
}
+ MenuItem {
+ text: qsTr("Search")
+ onClicked: _selectedMenu = 3
+ }
MenuItem {
id: menuShowAll
visible: !fileModel.showAll
text: qsTr("Show all files")
- onClicked: _selectedMenu = 3
+ onClicked: _selectedMenu = 4
}
MenuItem {
id: menuShowFiltered
visible: fileModel.showAll
text: qsTr("Show only ") + engine.extensionFilter + qsTr(" files")
- onClicked: _selectedMenu = 4
+ onClicked: _selectedMenu = 5
}
}
{ dir: fileModel.appendPath(listLabel.text) });
}
else {
- Functions.cancel()
Functions.fileSelect(fileModel.appendPath(listLabel.text))
+ //Functions.cancel()
//pageStack.push(Qt.resolvedUrl("FilePage.qml"),
// { file: fileModel.appendPath(listLabel.text) });
}
visible: true
text: qsTr("Properties")
onClicked: {
- pageStack.push(Qt.resolvedUrl("FilePage.qml"),
- { file: fileModel.fileNameAt(index) });
+ pageStack.push(Qt.resolvedUrl("FilePage.qml"), { file: fileModel.fileNameAt(index) });
}
}
}
Page {
id: page
- allowedOrientations: Orientation.All
+ //allowedOrientations: Orientation.All
property string file: "/"
FileInfo {
Page {
id: page
- allowedOrientations: Orientation.All
+ //allowedOrientations: Orientation.All
showNavigationIndicator: false // hide back indicator because it would be on top of search field
property string dir: "/"
property string currentDirectory: ""
+ onStatusChanged: {
+ if (status === PageStatus.Active) {
+ listModel.update("." + engine.extensionFilter);
+ //foundText.visible = true;
+ }
+ }
+
// this and its bg worker thread will be destroyed when page in popped from stack
SearchEngine {
id: searchEngine
VerticalScrollDecorator { flickable: fileList }
- PullDownMenu {
- MenuItem {
- text: qsTr("Settings")
- onClicked: pageStack.push(Qt.resolvedUrl("SettingsPage.qml"))
- }
- }
+// PullDownMenu {
+// MenuItem {
+// text: qsTr("Settings")
+// onClicked: pageStack.push(Qt.resolvedUrl("SettingsPage.qml"))
+// }
+// }
header: Item {
width: parent.width
}
Label {
id: foundText
- visible: false
+ visible: true
anchors.left: parent.left
anchors.leftMargin: searchField.textLeftMargin
anchors.top: searchField.bottom
pageStack.push(Qt.resolvedUrl("DirectoryPage.qml"),
{ dir: model.fullname });
else
- pageStack.push(Qt.resolvedUrl("FilePage.qml"),
- { file: model.fullname });
+ Functions.fileSelect(model.fullname)
+// pageStack.push(Qt.resolvedUrl("FilePage.qml"),
+// { file: model.fullname });
}
// delete file after remorse time
onClicked: Functions.goToFolder(model.absoluteDir)
}
MenuItem {
- text: qsTr("Cut")
- onClicked: engine.cutFiles([ model.fullname ]);
- }
- MenuItem {
- text: qsTr("Copy")
- onClicked: engine.copyFiles([ model.fullname ]);
- }
- MenuItem {
- text: qsTr("Delete")
- onClicked: deleteFile(model.fullname);
+ text: qsTr("Properties")
+ onClicked: {
+ pageStack.push(Qt.resolvedUrl("FilePage.qml"), { file: model.fullname });
+ }
}
+// MenuItem {
+// text: qsTr("Cut")
+// onClicked: engine.cutFiles([ model.fullname ]);
+// }
+// MenuItem {
+// text: qsTr("Copy")
+// onClicked: engine.copyFiles([ model.fullname ]);
+// }
+// MenuItem {
+// text: qsTr("Delete")
+// onClicked: deleteFile(model.fullname);
+// }
}
}
}
ValueButtonAlignRight {
id: caCertFilename
label: "CA cert"
- value: "Select"
+ value: VpnControl.caCertFile
+ placeholderText: "Select"
width: parent.width
onClicked: {
_fileDialogue = 1
ValueButtonAlignRight {
id: clientCertFilename
- value: "Select"
+ value: ((VpnControl.clientCertFile === "") ? "Select" : VpnControl.clientCertFile)
label: "Client cert"
width: parent.width
onClicked: {
ValueButtonAlignRight {
id: clientKeyFilename
- value: "Select"
+ value: ((VpnControl.clientKeyFile === "") ? "Select" : VpnControl.clientKeyFile)
label: "Client key"
width: parent.width
onClicked: {
ValueButtonAlignRight {
id: tlsKeyFilename
- value: "Select"
+ value: ((VpnControl.tlsKeyFile === "") ? "Select" : VpnControl.tlsKeyFile)
label: "TLS key"
width: parent.width
enabled: configureTLS.checked
VpnControl.setUseTLS(configureTLS.checked)
VpnControl.setTlsDirection(configureTLSdirection.currentIndex)
VpnControl.updateConfiguration()
+ VpnControl.setCaCertFile(caCertFilename.value)
+ VpnControl.setClientCertFile(clientCertFilename.value)
+ VpnControl.setClientKeyFile(clientKeyFilename.value)
+ VpnControl.setTlsKeyFile(tlsKeyFilename.value)
}
-
}
-
-
-
-
-
visible: true
text: VpnControl.logText
maximumLineCount: Math.floor(18 / 0.6)
+ verticalAlignment: Text.AlignBottom
x: Theme.paddingSmall
y: Theme.paddingSmall
}
compressed = settings.value("compressed", true).toBool();
useTLS = settings.value("useTLS", true).toBool();
tlsDirection = settings.value("tlsDirection", 1).toInt();
+ caCertFile = settings.value("caCertFile", "").toString();
+ clientCertFile = settings.value("clientCertFile", "").toString();;
+ clientKeyFile = settings.value("clientKeyFile", "").toString();;
+ tlsKeyFile = settings.value("tlsKeyFile", "").toString();;
+
settings.setValue("showAll", false);
}
}
}
+QString VPNControl::getCaCertFile () const
+{
+ return caCertFile;
+}
+
+void VPNControl::setCaCertFile(const QString &value)
+{
+ if (value != caCertFile) {
+ caCertFile = value;
+ settingsSetValue("caCertFile", value);
+ emit caCertFileChanged(caCertFile);
+ }
+}
+
+void VPNControl::setClientCertFile(const QString &value)
+{
+ if (value != clientCertFile) {
+ clientCertFile = value;
+ settingsSetValue("clientCertFile", value);
+ emit clientCertFileChanged(clientCertFile);
+ }
+}
+
+void VPNControl::setClientKeyFile(const QString &value)
+{
+ if (value != clientKeyFile) {
+ clientKeyFile = value;
+ settingsSetValue("clientKeyFile", value);
+ emit clientKeyFileChanged(clientKeyFile);
+ }
+}
+
+void VPNControl::setTlsKeyFile(const QString &value)
+{
+ if (value != tlsKeyFile) {
+ tlsKeyFile = value;
+ settingsSetValue("tlsKeyFile", value);
+ emit tlsKeyFileChanged(tlsKeyFile);
+ }
+}
+
+QString VPNControl::getClientCertFile () const
+{
+ return clientCertFile;
+}
+
+QString VPNControl::getClientKeyFile () const
+{
+ return clientKeyFile;
+}
+
+QString VPNControl::getTlsKeyFile () const
+{
+ return tlsKeyFile;
+}
+
QString VPNControl::getLogText() const
{
return logText;
void VPNControl::setLogText(const QString &value)
{
logText = value;
- emit logTextChanged(value);
+ emit logTextChanged(logText);
}
void VPNControl::settingsSetValue (QString key, QString value) {
void VPNControl::collectArguments () {
arguments.clear();
- addArgument("config", "/home/nemo/Documents/Configure/OpenVPN/config.ovpn");
- addArgument("remote", server);
- addArgument("port", QString::number(port));
+ addArgumentNonempty("config", "/home/nemo/Documents/Configure/OpenVPN/config.ovpn");
+ addArgumentNonempty("remote", server);
+ addArgumentNonempty("port", QString::number(port));
addOption("comp-lzo", compressed);
- if (useTLS) {
- addArgument("tls-auth", "/home/nemo/Documents/Configure/OpenVPN/ta.key");
+ if ((useTLS) && (!tlsKeyFile.isEmpty())) {
+ addArgument("tls-auth", tlsKeyFile);
addValue(QString::number(tlsDirection));
}
- addArgument("ca", "/home/nemo/Documents/Configure/OpenVPN/ca.crt");
- addArgument("cert", "/home/nemo/Documents/Configure/OpenVPN/Jolla.crt");
- addArgument("key", "/home/nemo/Documents/Configure/OpenVPN/Jolla.key");
+ addArgumentNonempty("ca", caCertFile);
+ addArgumentNonempty("cert", clientCertFile);
+ addArgumentNonempty("key", clientKeyFile);
}
void VPNControl::addArgument (QString key, QString value) {
argument = "--" + key;
arguments.append(argument);
- if (value != "") {
+ if (!value.isEmpty()) {
+ arguments.append(value);
+ }
+}
+
+void VPNControl::addArgumentNonempty (QString key, QString value) {
+ QString argument;
+
+ if (!value.isEmpty()) {
+ argument = "--" + key;
+ arguments.append(argument);
arguments.append(value);
}
}
int removeLines = currentLines + newLines - 18;
// Remove excess lines
- while (removeLines > 0) {
- int nextLine = logText.lastIndexOf('\n');
- if (nextLine > 0) {
- logText = logText.left(nextLine);
- }
- removeLines--;
- }
+// while (removeLines > 0) {
+// int nextLine = logText.indexOf('\n');
+// if (nextLine > 0) {
+// logText = logText.right(nextLine);
+// }
+// removeLines--;
+// }
// Add new lines
- logText.prepend(text);
+ logText.append(text);
emit logTextChanged(logText);
}
}
+
Q_PROPERTY (bool compressed READ getCompressed WRITE setCompressed NOTIFY compressedChanged)
Q_PROPERTY (bool useTLS READ getUseTLS WRITE setUseTLS NOTIFY useTLSChanged)
Q_PROPERTY (int tlsDirection READ getTlsDirection WRITE setTlsDirection NOTIFY tlsDirectionChanged)
+ Q_PROPERTY (QString caCertFile READ getCaCertFile WRITE setCaCertFile NOTIFY caCertFileChanged)
+ Q_PROPERTY (QString clientCertFile READ getClientCertFile WRITE setClientCertFile NOTIFY clientCertFileChanged)
+ Q_PROPERTY (QString clientKeyFile READ getClientKeyFile WRITE setClientKeyFile NOTIFY clientKeyFileChanged)
+ Q_PROPERTY (QString tlsKeyFile READ getTlsKeyFile WRITE setTlsKeyFile NOTIFY tlsKeyFileChanged)
Q_PROPERTY (QString logText READ getLogText WRITE setLogText NOTIFY logTextChanged)
QProcess * vpnProcess;
VPNSTATUS vpnStatus;
QStringList arguments;
+ QString logText;
// Configuration options
QString server;
bool compressed;
bool useTLS;
int tlsDirection;
- QString logText;
+ QString caCertFile;
+ QString clientCertFile;
+ QString clientKeyFile;
+ QString tlsKeyFile;
void collectArguments ();
void setStatus (VPNSTATUS newStatus);
void addArgument (QString key, QString value);
void addArgument (QString key);
+ void addArgumentNonempty (QString key, QString value);
void addOption (QString key, bool add);
void addValue (QString key);
void settingsSetValue (QString key, QString value);
bool getCompressed() const;
bool getUseTLS() const;
int getTlsDirection() const;
+ QString getCaCertFile () const;
+ QString getClientCertFile () const;
+ QString getClientKeyFile () const;
+ QString getTlsKeyFile () const;
+
QString getLogText() const;
signals:
void statusChanged(int status);
- void serverChanged(QString server);
+ void serverChanged(QString &server);
void portChanged(unsigned int port);
void compressedChanged(bool compressed);
void useTLSChanged(bool useTLS);
- void tlsDirectionChanged (int direction);
- void logTextChanged (QString logText);
+ void tlsDirectionChanged(int direction);
+ void caCertFileChanged(QString &caCertFile);
+ void clientCertFileChanged(QString &clientCertFile);
+ void clientKeyFileChanged(QString &clientKeyFile);
+ void tlsKeyFileChanged(QString &tlsKeyFile);
+
+ void logTextChanged (QString &logText);
public slots:
void vpnConnect ();
void setCompressed(bool value);
void setUseTLS(bool value);
void setTlsDirection(int value);
+ void setCaCertFile(const QString &value);
+ void setClientCertFile(const QString &value);
+ void setClientKeyFile(const QString &value);
+ void setTlsKeyFile(const QString &value);
+
void setLogText(const QString &value);
void logAppend(const QString &text);
};