Commit 799ec3f8 authored by Andrea Scarpino's avatar Andrea Scarpino

Enable the ping button only when target field is empty

parent 6f2aac86
......@@ -57,12 +57,6 @@ Page {
}
}
function defaults() {
target.text = "";
useIpv6.checked = false;
errorMsg.text = "";
}
SilicaFlickable {
anchors.fill: parent
contentHeight: column.height
......@@ -72,7 +66,8 @@ Page {
text: qsTr("Ping all")
onClicked: {
defaults();
target.text = "";
errorMsg.text = "";
manager.pingAll()
}
}
......@@ -81,7 +76,6 @@ Page {
text: qsTr("Clear history")
onClicked: {
defaults();
manager.clearHistory()
}
}
......@@ -103,9 +97,12 @@ Page {
placeholderText: qsTr("An IP address or hostname")
onTextChanged: {
if (target.text.match('([a-zA-Z1-9]{1,4}:){5}[a-zA-Z1-9]{1,4}')) {
button.enabled = text.length > 0;
errorMsg.text = "";
if (text.match('([a-zA-Z1-9]{1,4}:){5}[a-zA-Z1-9]{1,4}')) {
useIpv6.checked = true;
} else if (target.text.match('([1-9]{1,3}.){3}[1-9]{1,3}')) {
} else if (text.match('([1-9]{1,3}.){3}[1-9]{1,3}')) {
useIpv6.checked = false;
}
}
......@@ -117,7 +114,7 @@ Page {
TextSwitch {
id: useIpv6
text: qsTr("IPv6")
text: qsTr("Use IPv6")
}
Label {
......@@ -135,12 +132,9 @@ Page {
id: button
text: qsTr("Ping it")
anchors.horizontalCenter: parent.horizontalCenter
enabled: false
onClicked: {
if (target.text.length !== 0) {
pingHost();
}
}
onClicked: pingHost();
}
SectionHeader {
......
......@@ -24,7 +24,6 @@
#include "hostsmanager.h"
#include <QDebug>
#include <QEventLoop>
#include <QSqlRecord>
......@@ -63,7 +62,6 @@ void HostsManager::pingAll()
}
Q_FOREACH (const QString host, pairs.keys()) {
qDebug() << host << pairs.value(host).toBool();
ping(host, pairs.value(host).toBool());
}
}
......
<?xml version="1.0" ?><!DOCTYPE TS><TS language="it" version="2.1">
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="it">
<context>
<name>CoverPage</name>
<message>
......@@ -68,39 +70,39 @@
<translation>La macchina è SPENTA!</translation>
</message>
<message>
<location filename="../qml/pages/MainPage.qml" line="72"/>
<location filename="../qml/pages/MainPage.qml" line="66"/>
<source>Ping all</source>
<translation>Manda ping a tutti</translation>
</message>
<message>
<location filename="../qml/pages/MainPage.qml" line="81"/>
<location filename="../qml/pages/MainPage.qml" line="76"/>
<source>Clear history</source>
<translation>Cancella cronologia</translation>
</message>
<message>
<location filename="../qml/pages/MainPage.qml" line="95"/>
<location filename="../qml/pages/MainPage.qml" line="89"/>
<source>Ping any host!</source>
<translation>Manda un ping!</translation>
</message>
<message>
<location filename="../qml/pages/MainPage.qml" line="103"/>
<location filename="../qml/pages/MainPage.qml" line="97"/>
<source>An IP address or hostname</source>
<translation>Un indirizzo IP o hostname</translation>
</message>
<message>
<location filename="../qml/pages/MainPage.qml" line="120"/>
<source>IPv6</source>
<translation>IPv6</translation>
<location filename="../qml/pages/MainPage.qml" line="117"/>
<source>Use IPv6</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/MainPage.qml" line="136"/>
<location filename="../qml/pages/MainPage.qml" line="133"/>
<source>Ping it</source>
<translation>Manda un ping</translation>
</message>
<message>
<location filename="../qml/pages/MainPage.qml" line="147"/>
<location filename="../qml/pages/MainPage.qml" line="141"/>
<source>History</source>
<translation>Cronologia</translation>
</message>
</context>
</TS>
\ No newline at end of file
</TS>
......@@ -70,37 +70,37 @@
<translation>Värddatorn är NERE!</translation>
</message>
<message>
<location filename="../qml/pages/MainPage.qml" line="72"/>
<location filename="../qml/pages/MainPage.qml" line="66"/>
<source>Ping all</source>
<translation>Pinga alla</translation>
</message>
<message>
<location filename="../qml/pages/MainPage.qml" line="81"/>
<location filename="../qml/pages/MainPage.qml" line="76"/>
<source>Clear history</source>
<translation>Rensa historiken</translation>
</message>
<message>
<location filename="../qml/pages/MainPage.qml" line="95"/>
<location filename="../qml/pages/MainPage.qml" line="89"/>
<source>Ping any host!</source>
<translation>Pinga en värddator!</translation>
</message>
<message>
<location filename="../qml/pages/MainPage.qml" line="103"/>
<location filename="../qml/pages/MainPage.qml" line="97"/>
<source>An IP address or hostname</source>
<translation>En IP-adress eller ett värdnamn</translation>
</message>
<message>
<location filename="../qml/pages/MainPage.qml" line="120"/>
<source>IPv6</source>
<translation>IPv6</translation>
<location filename="../qml/pages/MainPage.qml" line="117"/>
<source>Use IPv6</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/MainPage.qml" line="136"/>
<location filename="../qml/pages/MainPage.qml" line="133"/>
<source>Ping it</source>
<translation>Pinga den</translation>
</message>
<message>
<location filename="../qml/pages/MainPage.qml" line="147"/>
<location filename="../qml/pages/MainPage.qml" line="141"/>
<source>History</source>
<translation>Historik</translation>
</message>
......
......@@ -70,37 +70,37 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/MainPage.qml" line="72"/>
<location filename="../qml/pages/MainPage.qml" line="66"/>
<source>Ping all</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/MainPage.qml" line="81"/>
<location filename="../qml/pages/MainPage.qml" line="76"/>
<source>Clear history</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/MainPage.qml" line="95"/>
<location filename="../qml/pages/MainPage.qml" line="89"/>
<source>Ping any host!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/MainPage.qml" line="103"/>
<location filename="../qml/pages/MainPage.qml" line="97"/>
<source>An IP address or hostname</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/MainPage.qml" line="120"/>
<source>IPv6</source>
<location filename="../qml/pages/MainPage.qml" line="117"/>
<source>Use IPv6</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/MainPage.qml" line="136"/>
<location filename="../qml/pages/MainPage.qml" line="133"/>
<source>Ping it</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/MainPage.qml" line="147"/>
<location filename="../qml/pages/MainPage.qml" line="141"/>
<source>History</source>
<translation type="unfinished"></translation>
</message>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment