From 28665079a01d26345e1289f2eaaca3307f83ac29 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Sun, 26 Jan 2014 22:24:29 -0800 Subject: [PATCH] Windows UI appearance fixes (font issue, etc.) and fix to WinSock init on GUI client. --- ZeroTierUI/aboutwindow.cpp | 3 ++- ZeroTierUI/licensedialog.cpp | 11 +++++++++++ ZeroTierUI/main.cpp | 13 +++++++++++++ ZeroTierUI/mainwindow.cpp | 11 ++++++++++- ZeroTierUI/mainwindow.h | 1 + ZeroTierUI/mainwindow.ui | 19 +++++++++++++++++-- ZeroTierUI/networkwidget.cpp | 14 ++++++++++++++ ZeroTierUI/stylesheet.css | 5 +++++ node/Node.hpp | 4 ++++ 9 files changed, 77 insertions(+), 4 deletions(-) diff --git a/ZeroTierUI/aboutwindow.cpp b/ZeroTierUI/aboutwindow.cpp index ddac50f5f..d57de3e7b 100644 --- a/ZeroTierUI/aboutwindow.cpp +++ b/ZeroTierUI/aboutwindow.cpp @@ -29,7 +29,9 @@ #include "ui_aboutwindow.h" #include +#include +#include "../node/Constants.hpp" #include "../node/Node.hpp" AboutWindow::AboutWindow(QWidget *parent) : @@ -37,7 +39,6 @@ AboutWindow::AboutWindow(QWidget *parent) : ui(new Ui::AboutWindow) { ui->setupUi(this); - ui->aboutTextLabel->setText(QString("ZeroTier One\nVersion ")+ZeroTier::Node::versionString()+"\nQt Graphical User Interface\n\n(c)2011-2014 ZeroTier Networks LLC\n\nReleased under the terms of the GNU\nGeneral Public License v3.0, see: http://gplv3.fsf.org for terms.\n\nAuthor(s): Adam Ierymenko"); } diff --git a/ZeroTierUI/licensedialog.cpp b/ZeroTierUI/licensedialog.cpp index bda9488df..8df3cc4ce 100644 --- a/ZeroTierUI/licensedialog.cpp +++ b/ZeroTierUI/licensedialog.cpp @@ -5,11 +5,22 @@ #include "licensedialog.h" #include "ui_licensedialog.h" +#include "../node/Constants.hpp" + LicenseDialog::LicenseDialog(QWidget *parent) : QDialog(parent), ui(new Ui::LicenseDialog) { ui->setupUi(this); + +#ifdef __WINDOWS__ + QWidgetList widgets = this->findChildren(); + foreach(QWidget *widget, widgets) { + QFont font(widget->font()); + font.setPointSizeF(font.pointSizeF() * 0.75); + widget->setFont(font); + } +#endif } LicenseDialog::~LicenseDialog() diff --git a/ZeroTierUI/main.cpp b/ZeroTierUI/main.cpp index 5814849c7..612d7c83d 100644 --- a/ZeroTierUI/main.cpp +++ b/ZeroTierUI/main.cpp @@ -32,6 +32,12 @@ #include #include #include +#include + +#ifdef __WINDOWS__ +#include +#include +#endif QSettings *settings = (QSettings *)0; @@ -39,6 +45,13 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); +#ifdef __WINDOWS__ + { + WSADATA wsaData; + WSAStartup(MAKEWORD(2,2),&wsaData); + } +#endif + { QFile qss(":css/stylesheet.css"); qss.open(QFile::ReadOnly); diff --git a/ZeroTierUI/mainwindow.cpp b/ZeroTierUI/mainwindow.cpp index 4e73ccfa8..1b3f57cd5 100644 --- a/ZeroTierUI/mainwindow.cpp +++ b/ZeroTierUI/mainwindow.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include "main.h" #include "mainwindow.h" @@ -106,6 +107,15 @@ MainWindow::MainWindow(QWidget *parent) : widget->setAttribute(Qt::WA_MacShowFocusRect,false); #endif +#ifdef __WINDOWS__ + QWidgetList widgets = this->findChildren(); + foreach(QWidget *widget, widgets) { + QFont font(widget->font()); + font.setPointSizeF(font.pointSizeF() * 0.75); + widget->setFont(font); + } +#endif + ui->noNetworksLabel->setVisible(true); ui->noNetworksLabel->setText("Connecting to Service..."); ui->bottomContainerWidget->setVisible(false); @@ -206,7 +216,6 @@ void MainWindow::timerEvent(QTimerEvent *event) void MainWindow::customEvent(QEvent *event) { - QMessageBox::information(this,"event","event",QMessageBox::Ok); ZTMessageEvent *m = (ZTMessageEvent *)event; // only one custom event type so far if (m->ztMessage.size() == 0) return; diff --git a/ZeroTierUI/mainwindow.h b/ZeroTierUI/mainwindow.h index 390e822dc..92cfabf1a 100644 --- a/ZeroTierUI/mainwindow.h +++ b/ZeroTierUI/mainwindow.h @@ -39,6 +39,7 @@ #include #include +#include "../node/Constants.hpp" #include "../node/Node.hpp" #include "../node/Utils.hpp" diff --git a/ZeroTierUI/mainwindow.ui b/ZeroTierUI/mainwindow.ui index 0f686b28b..913f2683f 100644 --- a/ZeroTierUI/mainwindow.ui +++ b/ZeroTierUI/mainwindow.ui @@ -230,9 +230,14 @@ 0 0 668 - 18 + 24 + + + 12 + + Qt::LeftToRight @@ -255,7 +260,7 @@ - 12 + 10 @@ -263,11 +268,21 @@ About + + + 10 + + Exit + + + 10 + + diff --git a/ZeroTierUI/networkwidget.cpp b/ZeroTierUI/networkwidget.cpp index 8b0ec0a71..bdc18d921 100644 --- a/ZeroTierUI/networkwidget.cpp +++ b/ZeroTierUI/networkwidget.cpp @@ -36,6 +36,9 @@ #include #include #include +#include + +#include "../node/Constants.hpp" NetworkWidget::NetworkWidget(QWidget *parent,const std::string &nwid) : QWidget(parent), @@ -50,9 +53,20 @@ NetworkWidget::NetworkWidget(QWidget *parent,const std::string &nwid) : ui->ipListWidget->setMinimumHeight(lineHeight * 4); ui->ipListWidget->setMaximumHeight(lineHeight * 4); +#ifdef __APPLE__ QWidgetList widgets = this->findChildren(); foreach(QWidget* widget, widgets) widget->setAttribute(Qt::WA_MacShowFocusRect,false); +#endif + +#ifdef __WINDOWS__ + QWidgetList widgets = this->findChildren(); + foreach(QWidget *widget, widgets) { + QFont font(widget->font()); + font.setPointSizeF(font.pointSizeF() * 0.75); + widget->setFont(font); + } +#endif } NetworkWidget::~NetworkWidget() diff --git a/ZeroTierUI/stylesheet.css b/ZeroTierUI/stylesheet.css index 3a5795c5d..c8764ea25 100644 --- a/ZeroTierUI/stylesheet.css +++ b/ZeroTierUI/stylesheet.css @@ -11,6 +11,7 @@ QToolButton:focus { } QToolButton:hover { background: palette(highlight); + color: palette(highlight-text); } QToolButton:pressed { border: 1px solid #000000; @@ -75,6 +76,10 @@ QLabel.networkName { text-align: right; } +QStatusBar { + background: palette(button); +} + #joinNetworkButton { margin: 1px; padding: 0; diff --git a/node/Node.hpp b/node/Node.hpp index a6410992d..974a51b64 100644 --- a/node/Node.hpp +++ b/node/Node.hpp @@ -45,6 +45,10 @@ class Node public: /** * Client for controlling a local ZeroTier One node + * + * Windows note: be sure you call WSAStartup() before using this, + * otherwise it will be unable to open a local UDP socket to + * communicate with the service. */ class LocalClient {