mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-01-19 11:16:32 +00:00
UI work...
This commit is contained in:
parent
c979a695c5
commit
4d86b2f02f
@ -1,9 +1,11 @@
|
||||
#include "mainwindow.h"
|
||||
#include "aboutwindow.h"
|
||||
#include "network.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <stdexcept>
|
||||
|
||||
@ -16,6 +18,7 @@
|
||||
#include <QDebug>
|
||||
#include <QProcess>
|
||||
#include <QStringList>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
// Globally visible
|
||||
ZeroTier::Node::LocalClient *zeroTierClient = (ZeroTier::Node::LocalClient *)0;
|
||||
@ -127,11 +130,48 @@ void MainWindow::customEvent(QEvent *event)
|
||||
if (hdr.size() >= 5)
|
||||
this->myVersion = hdr[4].c_str();
|
||||
} else if (hdr[1] == "listnetworks") {
|
||||
const QObjectList &existingNetworks = ui->networksScrollAreaContentWidget->children();
|
||||
std::set<std::string> networkIds;
|
||||
|
||||
// Add/update network widgets in scroll area
|
||||
for(unsigned long i=1;i<m->ztMessage.size();++i) {
|
||||
std::vector<std::string> l(ZeroTier::Node::LocalClient::splitLine(m->ztMessage[i]));
|
||||
// 200 listnetworks <nwid> <name> <status> <type> <dev> <ips>
|
||||
if ((l.size() == 8)&&(l[2].length() == 16)) {
|
||||
networkIds.insert(l[2]);
|
||||
Network *nw = (Network *)0;
|
||||
for(QObjectList::const_iterator n(ui->networksScrollAreaContentWidget->children().begin());n!=ui->networksScrollAreaContentWidget->children().end();++n) {
|
||||
Network *n2 = (Network *)*n;
|
||||
if ((n2)&&(n2->networkId() == l[2])) {
|
||||
nw = n2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!nw) {
|
||||
nw = new Network(ui->networksScrollAreaContentWidget,l[2]);
|
||||
}
|
||||
nw->setNetworkName(l[3]);
|
||||
nw->setStatus(l[4]);
|
||||
nw->setNetworkType(l[5]);
|
||||
nw->setNetworkDeviceName(l[6]);
|
||||
nw->setIps(l[7]);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove widgets for networks no longer in the list
|
||||
for(QObjectList::const_iterator n(ui->networksScrollAreaContentWidget->children().begin());n!=ui->networksScrollAreaContentWidget->children().end();++n) {
|
||||
Network *n2 = (Network *)*n;
|
||||
if ((n2)&&(!networkIds.count(n2->networkId())))
|
||||
n2->deleteLater();
|
||||
}
|
||||
|
||||
// Update layout
|
||||
QVBoxLayout *layout = new QVBoxLayout();
|
||||
layout->setSpacing(0);
|
||||
layout->setMargin(0);
|
||||
for(QObjectList::const_iterator n(ui->networksScrollAreaContentWidget->children().begin());n!=ui->networksScrollAreaContentWidget->children().end();++n)
|
||||
layout->addWidget((QWidget *)*n);
|
||||
delete ui->networksScrollAreaContentWidget->layout();
|
||||
ui->networksScrollAreaContentWidget->setLayout(layout);
|
||||
} else if (hdr[1] == "listpeers") {
|
||||
this->numPeers = 0;
|
||||
for(unsigned long i=1;i<m->ztMessage.size();++i) {
|
||||
@ -212,6 +252,8 @@ void MainWindow::on_networkIdLineEdit_textChanged(const QString &text)
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
if (newText.size() > 16)
|
||||
newText.truncate(16);
|
||||
ui->networkIdLineEdit->setText(newText);
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,9 @@
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
@ -59,27 +62,16 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>654</width>
|
||||
<height>236</height>
|
||||
<width>656</width>
|
||||
<height>238</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -29,14 +29,14 @@ void Network::setStatus(const std::string &status)
|
||||
ui->statusLabel->setText(QString(status.c_str()));
|
||||
}
|
||||
|
||||
void Network::setNetworkName(const std::string &status)
|
||||
void Network::setNetworkName(const std::string &name)
|
||||
{
|
||||
ui->nameLabel->setText(QString(status.c_str()));
|
||||
ui->nameLabel->setText(QString(name.c_str()));
|
||||
}
|
||||
|
||||
void Network::setNetworkType(const std::string &type)
|
||||
{
|
||||
ui->networkTypeLabel->setText(QString(status.c_str()));
|
||||
ui->networkTypeLabel->setText(QString(type.c_str()));
|
||||
if (type == "?")
|
||||
ui->networkTypeLabel->setToolTip("Waiting for configuration...");
|
||||
else if (type == "public")
|
||||
@ -69,13 +69,12 @@ void Network::setIps(const std::string &commaSeparatedList)
|
||||
ips = tmp;
|
||||
|
||||
for(QStringList::iterator i(ips.begin());i!=ips.end();++i) {
|
||||
if (ui->ipListWidget->findItems(*i).size() == 0)
|
||||
if (ui->ipListWidget->findItems(*i,Qt::MatchCaseSensitive).size() == 0)
|
||||
ui->ipListWidget->addItem(*i);
|
||||
}
|
||||
|
||||
QList<QListWidgetItem *> inList(ui->ipListWidget->items());
|
||||
for(QList<QListWidgetItem *>::iterator i(inList.begin());i!=inList.end();++i) {
|
||||
QListWidgetItem *item = *i;
|
||||
for(int i=0;i<ui->ipListWidget->count();++i) {
|
||||
QListWidgetItem *item = ui->ipListWidget->item(i);
|
||||
if (!ips.contains(item->text()))
|
||||
ui->ipListWidget->removeItemWidget(item);
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ class Network : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Network(QWidget *parent = 0,const std::string &nwid);
|
||||
explicit Network(QWidget *parent = 0,const std::string &nwid = std::string());
|
||||
virtual ~Network();
|
||||
|
||||
void setStatus(const std::string &status);
|
||||
|
@ -6,12 +6,12 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>618</width>
|
||||
<height>108</height>
|
||||
<width>580</width>
|
||||
<height>267</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -19,10 +19,34 @@
|
||||
<property name="windowTitle">
|
||||
<string>Network</string>
|
||||
</property>
|
||||
<property name="widgetResizable" stdset="0">
|
||||
<bool>true</bool>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
@ -30,16 +54,22 @@
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QWidget" name="leftWidget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||
@ -81,7 +111,7 @@
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="networkIdPushButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -121,6 +151,48 @@ text-align: left;</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="nameLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>(name)</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Type:</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLabel" name="networkTypeLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>public</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
@ -179,7 +251,86 @@ text-align: left;</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="rightWidget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="font">
|
||||
<font>
|
||||
<underline>false</underline>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>IP Addresses</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="ipListWidget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Courier</family>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="showDropIndicator" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="resizeMode">
|
||||
<enum>QListView::Fixed</enum>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="leaveNetworkButtonContainerWidget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
@ -194,6 +345,9 @@ text-align: left;</string>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
@ -220,92 +374,28 @@ text-align: left;</string>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="leaveNetworkButton">
|
||||
<widget class="QToolButton" name="leaveNetworkButton">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
<underline>true</underline>
|
||||
<underline>false</underline>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">padding: 0; margin: 0;</string>
|
||||
<string notr="true">padding: 0.1em; margin:0;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Leave Network</string>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="nameLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>(name)</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Type:</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLabel" name="networkTypeLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>public</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="ipListWidget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Courier</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="showDropIndicator" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
Loading…
Reference in New Issue
Block a user