diff --git a/ZeroTierUI/ZeroTierUI.pro b/ZeroTierUI/ZeroTierUI.pro index c379bd0a0..c90ede1d6 100644 --- a/ZeroTierUI/ZeroTierUI.pro +++ b/ZeroTierUI/ZeroTierUI.pro @@ -45,7 +45,8 @@ SOURCES += main.cpp \ ../ext/lz4/lz4hc.c \ networkwidget.cpp \ installdialog.cpp \ - licensedialog.cpp + licensedialog.cpp \ + onetimedialog.cpp HEADERS += mainwindow.h \ aboutwindow.h \ @@ -98,14 +99,16 @@ HEADERS += mainwindow.h \ installdialog.h \ mac_doprivileged.h \ licensedialog.h \ - main.h + main.h \ + onetimedialog.h FORMS += mainwindow.ui \ aboutwindow.ui \ networkwidget.ui \ installdialog.ui \ licensedialog.ui \ - quickstartdialog.ui + quickstartdialog.ui \ + onetimedialog.ui RESOURCES += \ resources.qrc diff --git a/ZeroTierUI/main.h b/ZeroTierUI/main.h index 9ab950d1b..bee0e51bb 100644 --- a/ZeroTierUI/main.h +++ b/ZeroTierUI/main.h @@ -2,6 +2,7 @@ #define MAIN_H #include +#include extern QSettings *settings; diff --git a/ZeroTierUI/mainwindow.cpp b/ZeroTierUI/mainwindow.cpp index c03a95d74..d0dd73512 100644 --- a/ZeroTierUI/mainwindow.cpp +++ b/ZeroTierUI/mainwindow.cpp @@ -66,7 +66,7 @@ ZeroTier::Node::LocalClient *zeroTierClient = (ZeroTier::Node::LocalClient *)0; // Main window instance for app -static MainWindow *mainWindow = (MainWindow *)0; +QMainWindow *mainWindow = (MainWindow *)0; // Handles message from ZeroTier One service static void handleZTMessage(void *arg,unsigned long id,const char *line) diff --git a/ZeroTierUI/mainwindow.h b/ZeroTierUI/mainwindow.h index c62444282..679a727ee 100644 --- a/ZeroTierUI/mainwindow.h +++ b/ZeroTierUI/mainwindow.h @@ -51,6 +51,9 @@ class MainWindow; // Can be null if not connected, or will point to current extern ZeroTier::Node::LocalClient *zeroTierClient; +// Globally visible pointer to main app window +extern QMainWindow *mainWindow; + class MainWindow : public QMainWindow { Q_OBJECT diff --git a/ZeroTierUI/networkwidget.cpp b/ZeroTierUI/networkwidget.cpp index a99fef1ec..0fdaa5143 100644 --- a/ZeroTierUI/networkwidget.cpp +++ b/ZeroTierUI/networkwidget.cpp @@ -28,6 +28,8 @@ #include "networkwidget.h" #include "mainwindow.h" #include "ui_networkwidget.h" +#include "onetimedialog.h" +#include "main.h" #include #include @@ -43,7 +45,8 @@ NetworkWidget::NetworkWidget(QWidget *parent,const std::string &nwid) : QWidget(parent), ui(new Ui::NetworkWidget), - networkIdStr(nwid) + networkIdStr(nwid), + publicWarningShown(false) { ui->setupUi(this); ui->networkIdButton->setText(QString(nwid.c_str())); @@ -98,9 +101,15 @@ void NetworkWidget::setNetworkType(const std::string &type) ui->networkTypeLabel->setText(QString(type.c_str())); if (type == "?") ui->networkTypeLabel->setStatusTip("Waiting for configuration..."); - else if (type == "public") + else if (type == "public") { + if ((!publicWarningShown)&&(!settings->value("shown_publicWarning",false).toBool())) { + publicWarningShown = true; + OneTimeDialog *d = new OneTimeDialog(mainWindow,"shown_publicWarning","Security Notice","Security Notice:"ZT_EOL_S""ZT_EOL_S"You have joined a public network. Anyone can join these. We recommend making sure that your system's automatic software updates are enabled and turning off any shared network services that you do not want people to access."); + d->setModal(false); + d->show(); + } ui->networkTypeLabel->setStatusTip("This network can be joined by anyone in the world."); - else if (type == "private") + } else if (type == "private") ui->networkTypeLabel->setStatusTip("This network is private; only authorized peers can join."); else ui->networkTypeLabel->setStatusTip("Unknown network type."); } diff --git a/ZeroTierUI/networkwidget.h b/ZeroTierUI/networkwidget.h index 9ff1ef998..6515e17a8 100644 --- a/ZeroTierUI/networkwidget.h +++ b/ZeroTierUI/networkwidget.h @@ -62,6 +62,7 @@ private slots: private: Ui::NetworkWidget *ui; std::string networkIdStr; + bool publicWarningShown; }; #endif // NETWORK_H diff --git a/ZeroTierUI/onetimedialog.cpp b/ZeroTierUI/onetimedialog.cpp new file mode 100644 index 000000000..1c1d983b8 --- /dev/null +++ b/ZeroTierUI/onetimedialog.cpp @@ -0,0 +1,37 @@ +#include "onetimedialog.h" +#include "ui_onetimedialog.h" +#include "main.h" + +OneTimeDialog::OneTimeDialog(QWidget *parent,const char *propName,const QString &title,const QString &message) : + QDialog(parent), + ui(new Ui::OneTimeDialog) +{ + ui->setupUi(this); + + ui->label->setText(message); + this->setWindowTitle(title); + _propName = propName; + +#ifdef __WINDOWS__ + QWidgetList widgets = this->findChildren(); + foreach(QWidget *widget, widgets) { + QFont font(widget->font()); + font.setPointSizeF(font.pointSizeF() * 0.75); + widget->setFont(font); + } +#endif +} + +OneTimeDialog::~OneTimeDialog() +{ + delete ui; +} + +void OneTimeDialog::on_pushButton_clicked() +{ + if (_propName) { + settings->setValue(_propName,ui->checkBox->isChecked()); + settings->sync(); + } + this->close(); +} diff --git a/ZeroTierUI/onetimedialog.h b/ZeroTierUI/onetimedialog.h new file mode 100644 index 000000000..3e76cd054 --- /dev/null +++ b/ZeroTierUI/onetimedialog.h @@ -0,0 +1,26 @@ +#ifndef ONETIMEDIALOG_H +#define ONETIMEDIALOG_H + +#include + +namespace Ui { +class OneTimeDialog; +} + +class OneTimeDialog : public QDialog +{ + Q_OBJECT + +public: + explicit OneTimeDialog(QWidget *parent = 0,const char *propName = (const char *)0,const QString &title = QString(),const QString &message = QString()); + ~OneTimeDialog(); + +private slots: + void on_pushButton_clicked(); + +private: + Ui::OneTimeDialog *ui; + const char *_propName; +}; + +#endif // ONETIMEDIALOG_H diff --git a/ZeroTierUI/onetimedialog.ui b/ZeroTierUI/onetimedialog.ui new file mode 100644 index 000000000..227cdc38e --- /dev/null +++ b/ZeroTierUI/onetimedialog.ui @@ -0,0 +1,99 @@ + + + OneTimeDialog + + + + 0 + 0 + 496 + 197 + + + + Dialog + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + 12 + + + Qt::NoTextInteraction + + + + + + + + 12 + + + 0 + + + 12 + + + 5 + + + + + + 0 + 0 + + + + Don't Show This Message Again + + + true + + + + + + + OK + + + + + + + + + + +