More UI cleanup...

This commit is contained in:
Adam Ierymenko 2013-12-19 14:59:52 -08:00
parent 191d204674
commit f311be96a9
5 changed files with 233 additions and 99 deletions

View File

@ -56,6 +56,10 @@ MainWindow::MainWindow(QWidget *parent) :
this->setEnabled(false); // gets enabled when updates are received
mainWindow = this;
this->cyclesSinceResponseFromService = 0;
QWidgetList widgets = this->findChildren<QWidget*>();
foreach(QWidget* widget, widgets)
widget->setAttribute(Qt::WA_MacShowFocusRect,false);
}
MainWindow::~MainWindow()
@ -186,19 +190,17 @@ void MainWindow::customEvent(QEvent *event)
}
}
if (this->myAddress.size()) {
QString st(this->myAddress);
st += " (";
st += this->myStatus;
st += ", v";
st += this->myVersion;
st += ", ";
st += QString::number(this->numPeers);
st += " peers)";
while (st.size() < 45)
st += QChar::Space;
ui->statusAndAddressButton->setText(st);
}
if (this->myAddress.size())
ui->addressButton->setText(this->myAddress);
else ui->addressButton->setText("??????????");
QString st(this->myStatus);
st += ", v";
st += this->myVersion;
st += ", ";
st += QString::number(this->numPeers);
st += " direct links to peers";
ui->statusLabel->setText(st);
if (this->myStatus == "ONLINE") {
if (!this->isEnabled())
@ -266,7 +268,7 @@ void MainWindow::on_networkIdLineEdit_textChanged(const QString &text)
ui->networkIdLineEdit->setText(newText);
}
void MainWindow::on_statusAndAddressButton_clicked()
void MainWindow::on_addressButton_clicked()
{
QApplication::clipboard()->setText(this->myAddress);
}

View File

@ -46,7 +46,7 @@ private slots:
void on_joinNetworkButton_clicked();
void on_actionAbout_triggered();
void on_networkIdLineEdit_textChanged(const QString &text);
void on_statusAndAddressButton_clicked();
void on_addressButton_clicked();
private:
Ui::MainWindow *ui;

View File

@ -20,19 +20,19 @@
<widget class="QWidget" name="centralWidget">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>6</number>
<number>0</number>
</property>
<property name="leftMargin">
<number>6</number>
<number>0</number>
</property>
<property name="topMargin">
<number>6</number>
<number>0</number>
</property>
<property name="rightMargin">
<number>6</number>
<number>0</number>
</property>
<property name="bottomMargin">
<number>6</number>
<number>0</number>
</property>
<item>
<widget class="QListWidget" name="networkListWidget">
@ -42,7 +42,9 @@
<property name="styleSheet">
<string notr="true">QListWidget#networkListWidget::Item {
background-color: rgba(0,0,0,10);
}s</string>
padding: 0;
margin: 0 0.15em 0.15em 0.15em;
}</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
@ -59,11 +61,8 @@
<property name="selectionMode">
<enum>QAbstractItemView::NoSelection</enum>
</property>
<property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
<property name="spacing">
<number>5</number>
<number>0</number>
</property>
<property name="uniformItemSizes">
<bool>true</bool>
@ -72,15 +71,9 @@
</item>
<item>
<widget class="QWidget" name="bottomContainerWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>5</number>
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
@ -95,7 +88,7 @@
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="statusAndAddressButton">
<widget class="QPushButton" name="addressButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -106,28 +99,36 @@
<font>
<family>Courier</family>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="toolTip">
<string>Click to copy your address to clipboard.</string>
<property name="statusTip">
<string>Your 10-digit ZeroTier address; click to copy to clipboard.</string>
</property>
<property name="styleSheet">
<string notr="true">QPushButton {
border: 0;
text-align: left;
padding: 0 5px 0 5px;
background-color: transparent;
}
QPushButton:focus {
background-color: rgba(0,0,0,25);
background-color: rgba(0,0,0,15);
}
QPushButton:hover {
background-color: rgba(0,0,0,25);
background-color: rgba(0,0,0,15);
}
</string>
QPushButton:pressed {
background-color: rgba(0,0,0,75);
}
s</string>
</property>
<property name="text">
<string>0000000000 (OFFLINE, v0.0.0, 0 peers) </string>
<string>##########</string>
</property>
<property name="flat">
<bool>true</bool>
@ -135,37 +136,105 @@ QPushButton:hover {
</widget>
</item>
<item>
<widget class="QLineEdit" name="networkIdLineEdit">
<widget class="QLabel" name="statusLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="statusTip">
<string>Your network connection status.</string>
</property>
<property name="styleSheet">
<string notr="true">padding: 0 0.75em 0 0.75em;</string>
</property>
<property name="text">
<string>STATUS, etc.</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="networkIdLineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Courier</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="toolTip">
<string>Enter Hexadecimal Network ID</string>
<property name="statusTip">
<string>Enter a hexadecimal network ID to join a network.</string>
</property>
<property name="maxLength">
<number>16</number>
</property>
<property name="frame">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>(Numeric ID of Network to Join)</string>
<string>################</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="joinNetworkButton">
<property name="toolTip">
<string>Join Network</string>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Courier</family>
<pointsize>16</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="statusTip">
<string>Join this network.</string>
</property>
<property name="styleSheet">
<string notr="true">QPushButton {
padding: 0 0.8em 0 0.8em;
margin: 0;
border: 0;
background: transparent;
}
QPushButton:focus {
background-color: rgba(0,0,0,25);
}
QPushButton:hover {
background-color: rgba(0,0,0,25);
}
QPushButton:pressed {
background-color: rgba(0,0,0,75);
}
</string>
</property>
<property name="text">
<string>Join</string>
<string notr="true">+</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
@ -202,6 +271,13 @@ QPushButton:hover {
<addaction name="menuFile"/>
<addaction name="menuHelp"/>
</widget>
<widget class="QStatusBar" name="statusBar">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
</widget>
<action name="actionAbout">
<property name="text">
<string>About</string>

View File

@ -17,10 +17,15 @@ NetworkWidget::NetworkWidget(QWidget *parent,const std::string &nwid) :
{
ui->setupUi(this);
ui->networkIdPushButton->setText(QString(nwid.c_str()));
QFontMetrics fm(ui->ipListWidget->font());
int lineHeight = ui->ipListWidget->spacing() + fm.height();
ui->ipListWidget->setMinimumHeight(lineHeight * 3);
ui->ipListWidget->setMaximumHeight(lineHeight * 3);
ui->ipListWidget->setMinimumHeight(lineHeight * 4);
ui->ipListWidget->setMaximumHeight(lineHeight * 4);
QWidgetList widgets = this->findChildren<QWidget*>();
foreach(QWidget* widget, widgets)
widget->setAttribute(Qt::WA_MacShowFocusRect,false);
}
NetworkWidget::~NetworkWidget()
@ -38,19 +43,23 @@ void NetworkWidget::setStatus(const std::string &status,const std::string &age)
void NetworkWidget::setNetworkName(const std::string &name)
{
ui->nameLabel->setText(QString(name.c_str()));
if (name == "?") {
ui->nameLabel->setText((QString("( ")+this->networkId().c_str())+" )");
} else {
ui->nameLabel->setText(QString(name.c_str()));
}
}
void NetworkWidget::setNetworkType(const std::string &type)
{
ui->networkTypeLabel->setText(QString(type.c_str()));
if (type == "?")
ui->networkTypeLabel->setToolTip("Waiting for configuration...");
ui->networkTypeLabel->setStatusTip("Waiting for configuration...");
else if (type == "public")
ui->networkTypeLabel->setToolTip("This network can be joined by anyone.");
ui->networkTypeLabel->setStatusTip("This network can be joined by anyone in the world.");
else if (type == "private")
ui->networkTypeLabel->setToolTip("This network is private, only authorized peers can join.");
else ui->networkTypeLabel->setToolTip(QString());
ui->networkTypeLabel->setStatusTip("This network is private; only authorized peers can join.");
else ui->networkTypeLabel->setStatusTip("Unknown network type.");
}
void NetworkWidget::setNetworkDeviceName(const std::string &dev)

View File

@ -22,25 +22,28 @@
<property name="class" stdset="0">
<string>NetworkWidget</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
<number>0</number>
</property>
<property name="leftMargin">
<number>6</number>
<number>0</number>
</property>
<property name="topMargin">
<number>6</number>
<number>0</number>
</property>
<property name="rightMargin">
<number>6</number>
<number>0</number>
</property>
<property name="bottomMargin">
<number>6</number>
<number>0</number>
</property>
<item>
<widget class="QWidget" name="leftWidget" native="true">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>2</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
@ -63,13 +66,13 @@
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
<pointsize>16</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgba(0,0,0,25);
padding: 0.25em;
margin: 0;</string>
<property name="statusTip">
<string>This network's short name.</string>
</property>
<property name="text">
<string>networkname</string>
@ -133,14 +136,21 @@ margin: 0;</string>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="networkIdPushButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Courier</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="toolTip">
<string>Click to copy network ID to clipboard.</string>
<property name="statusTip">
<string>Hexadecimal network ID; click to copy to clipboard.</string>
</property>
<property name="styleSheet">
<string notr="true">QPushButton {
@ -152,11 +162,15 @@ margin: 0;</string>
}
QPushButton:focus {
background-color: rgba(0,0,0,25);
background-color: rgba(0,0,0,15);
}
QPushButton:hover {
background-color: rgba(0,0,0,25);
background-color: rgba(0,0,0,15);
}
QPushButton:pressed {
background-color: rgba(0,0,0,75);
}
</string>
</property>
@ -186,6 +200,9 @@ QPushButton:hover {
<bold>true</bold>
</font>
</property>
<property name="statusTip">
<string>What kind of network? Public or private?</string>
</property>
<property name="text">
<string>?</string>
</property>
@ -242,6 +259,9 @@ QPushButton:hover {
<bold>true</bold>
</font>
</property>
<property name="statusTip">
<string>Status of this network.</string>
</property>
<property name="text">
<string>?</string>
</property>
@ -263,6 +283,9 @@ QPushButton:hover {
<pointsize>8</pointsize>
</font>
</property>
<property name="statusTip">
<string>How recently did this network refresh its settings?</string>
</property>
<property name="text">
<string>(configuration is 0 seconds old)</string>
</property>
@ -305,6 +328,9 @@ QPushButton:hover {
<bold>true</bold>
</font>
</property>
<property name="statusTip">
<string>The name of the network device on your system.</string>
</property>
<property name="text">
<string>?</string>
</property>
@ -329,10 +355,7 @@ QPushButton:hover {
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>3</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetNoConstraint</enum>
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
@ -348,11 +371,21 @@ QPushButton:hover {
</property>
<item>
<widget class="QLabel" name="label_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
<underline>false</underline>
</font>
</property>
<property name="styleSheet">
<string notr="true">padding: 0.1em 0 0.1em 0;</string>
</property>
<property name="text">
<string>IP Address Assignments</string>
</property>
@ -363,12 +396,6 @@ QPushButton:hover {
</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>
@ -381,16 +408,16 @@ QPushButton:hover {
<pointsize>12</pointsize>
</font>
</property>
<property name="toolTip">
<string>Double-click IP to copy to clipboard.</string>
<property name="statusTip">
<string>Double-click an IP to copy it to the clipboard.</string>
</property>
<property name="styleSheet">
<string notr="true">QListWidget {
background-color: rgba(0,0,0,10);
background-color: rgba(0,0,0,5);
}
QListWidget:hover {
background-color: rgba(0,0,0,25);
background-color: rgba(0,0,0,15);
}
</string>
</property>
@ -415,19 +442,7 @@ QListWidget:hover {
</widget>
</item>
<item>
<widget class="QWidget" name="leaveNetworkButtonContainerWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<widget class="QWidget" name="leaveButtonContainerWidget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>0</number>
@ -452,22 +467,55 @@ QListWidget:hover {
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
<height>1</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="leaveNetworkButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
<underline>false</underline>
<pointsize>12</pointsize>
</font>
</property>
<property name="statusTip">
<string>Leave this network.</string>
</property>
<property name="styleSheet">
<string notr="true">QPushButton {
border: 0;
padding: 0.25em;
margin: 0;
text-align: right;
background-color: transparent;
}
QPushButton:focus {
background-color: rgba(0,0,0,25);
}
QPushButton:hover {
background-color: rgba(0,0,0,25);
}
QPushButton:pressed {
background-color: rgba(0,0,0,75);
}
</string>
</property>
<property name="text">
<string>Leave Network</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
@ -480,7 +528,6 @@ QListWidget:hover {
</widget>
<tabstops>
<tabstop>ipListWidget</tabstop>
<tabstop>leaveNetworkButton</tabstop>
</tabstops>
<resources/>
<connections/>