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

View file

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

View file

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

View file

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

View file

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