summaryrefslogtreecommitdiff
path: root/ZeroTierUI/mainwindow.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2014-01-10 16:41:44 -0800
committerAdam Ierymenko <adam.ierymenko@gmail.com>2014-01-10 16:41:44 -0800
commit305ed0b3c5e59c1ba70b221e135edcdb09499d0a (patch)
treec1692f8addc986ab00fa89361ec6ae847ca3da3d /ZeroTierUI/mainwindow.cpp
parent9208c6b4e6ea698a63676a6673bb5ff934ac14ac (diff)
downloadinfinitytier-305ed0b3c5e59c1ba70b221e135edcdb09499d0a.tar.gz
infinitytier-305ed0b3c5e59c1ba70b221e135edcdb09499d0a.zip
Cleanup in installer code in app.
Diffstat (limited to 'ZeroTierUI/mainwindow.cpp')
-rw-r--r--ZeroTierUI/mainwindow.cpp56
1 files changed, 27 insertions, 29 deletions
diff --git a/ZeroTierUI/mainwindow.cpp b/ZeroTierUI/mainwindow.cpp
index 53cfe2a2..913ced1c 100644
--- a/ZeroTierUI/mainwindow.cpp
+++ b/ZeroTierUI/mainwindow.cpp
@@ -85,31 +85,17 @@ MainWindow::MainWindow(QWidget *parent) :
pollServiceTimerId(0)
{
ui->setupUi(this);
+ if (ui->networkListWidget->verticalScrollBar())
+ ui->networkListWidget->verticalScrollBar()->setSingleStep(8);
+ QWidgetList widgets = this->findChildren<QWidget*>();
+ foreach(QWidget *widget, widgets)
+ widget->setAttribute(Qt::WA_MacShowFocusRect,false);
-#ifdef __APPLE__
- if (!QFile::exists("/Library/Application Support/ZeroTier/One/zerotier-one")) {
- // If the service is not installed, download the installer and run it
- // for the first time.
- this->setEnabled(false);
- InstallDialog *id = new InstallDialog(this);
- id->setModal(true);
- id->show();
- this->setHidden(true);
- return;
- }
-#endif
+ mainWindow = this;
this->pollServiceTimerId = this->startTimer(1000);
this->setEnabled(false); // gets enabled when updates are received
- mainWindow = this;
this->cyclesSinceResponseFromService = 0;
-
- if (ui->networkListWidget->verticalScrollBar())
- ui->networkListWidget->verticalScrollBar()->setSingleStep(8);
-
- QWidgetList widgets = this->findChildren<QWidget*>();
- foreach(QWidget* widget, widgets)
- widget->setAttribute(Qt::WA_MacShowFocusRect,false);
}
MainWindow::~MainWindow()
@@ -132,8 +118,6 @@ void MainWindow::timerEvent(QTimerEvent *event)
if (!ZeroTier::Utils::readFile(ZeroTier::Node::LocalClient::authTokenDefaultUserPath().c_str(),authToken)) {
#ifdef __APPLE__
if (QFile::exists("/Library/Application Support/ZeroTier/One/zerotier-one")) {
- // Run the little AppleScript hack that asks for admin credentials and
- // then installs the auth token file in the current user's home.
QMessageBox::information(this,"Authorization Required","You must authenticate to authorize this user to administrate ZeroTier One on this computer.\n\n(This only needs to be done once.)",QMessageBox::Ok,QMessageBox::NoButton);
QString authHelperPath(QCoreApplication::applicationDirPath() + "/../Resources/helpers/mac/ZeroTier One (Authenticate).app/Contents/MacOS/applet");
if (!QFile::exists(authHelperPath)) {
@@ -143,13 +127,7 @@ void MainWindow::timerEvent(QTimerEvent *event)
}
QProcess::execute(authHelperPath,QStringList());
} else {
- // If the service is not installed, download the installer and run it
- // for the first time.
- this->setEnabled(false);
- InstallDialog *id = new InstallDialog(this);
- id->setModal(true);
- id->show();
- this->setHidden(true);
+ doInstallDialog();
return;
}
#endif
@@ -279,6 +257,14 @@ void MainWindow::customEvent(QEvent *event)
}
}
+void MainWindow::showEvent(QShowEvent *event)
+{
+#ifdef __APPLE__
+ if (!QFile::exists("/Library/Application Support/ZeroTier/One/zerotier-one"))
+ doInstallDialog();
+#endif
+}
+
void MainWindow::on_joinNetworkButton_clicked()
{
QString toJoin(ui->networkIdLineEdit->text());
@@ -340,3 +326,15 @@ void MainWindow::on_addressButton_clicked()
{
QApplication::clipboard()->setText(this->myAddress);
}
+
+void MainWindow::doInstallDialog()
+{
+#ifdef __APPLE__
+ this->setEnabled(false);
+ this->setHidden(true);
+
+ InstallDialog *id = new InstallDialog(this);
+ id->setModal(true);
+ id->show();
+#endif
+}