mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 20:13:44 +02:00
Cleanup in installer code in app.
This commit is contained in:
parent
9208c6b4e6
commit
305ed0b3c5
2 changed files with 33 additions and 33 deletions
|
@ -85,31 +85,17 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
pollServiceTimerId(0)
|
pollServiceTimerId(0)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
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__
|
mainWindow = this;
|
||||||
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
|
|
||||||
|
|
||||||
this->pollServiceTimerId = this->startTimer(1000);
|
this->pollServiceTimerId = this->startTimer(1000);
|
||||||
this->setEnabled(false); // gets enabled when updates are received
|
this->setEnabled(false); // gets enabled when updates are received
|
||||||
mainWindow = this;
|
|
||||||
this->cyclesSinceResponseFromService = 0;
|
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()
|
MainWindow::~MainWindow()
|
||||||
|
@ -132,8 +118,6 @@ void MainWindow::timerEvent(QTimerEvent *event)
|
||||||
if (!ZeroTier::Utils::readFile(ZeroTier::Node::LocalClient::authTokenDefaultUserPath().c_str(),authToken)) {
|
if (!ZeroTier::Utils::readFile(ZeroTier::Node::LocalClient::authTokenDefaultUserPath().c_str(),authToken)) {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
if (QFile::exists("/Library/Application Support/ZeroTier/One/zerotier-one")) {
|
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);
|
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");
|
QString authHelperPath(QCoreApplication::applicationDirPath() + "/../Resources/helpers/mac/ZeroTier One (Authenticate).app/Contents/MacOS/applet");
|
||||||
if (!QFile::exists(authHelperPath)) {
|
if (!QFile::exists(authHelperPath)) {
|
||||||
|
@ -143,13 +127,7 @@ void MainWindow::timerEvent(QTimerEvent *event)
|
||||||
}
|
}
|
||||||
QProcess::execute(authHelperPath,QStringList());
|
QProcess::execute(authHelperPath,QStringList());
|
||||||
} else {
|
} else {
|
||||||
// If the service is not installed, download the installer and run it
|
doInstallDialog();
|
||||||
// for the first time.
|
|
||||||
this->setEnabled(false);
|
|
||||||
InstallDialog *id = new InstallDialog(this);
|
|
||||||
id->setModal(true);
|
|
||||||
id->show();
|
|
||||||
this->setHidden(true);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#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()
|
void MainWindow::on_joinNetworkButton_clicked()
|
||||||
{
|
{
|
||||||
QString toJoin(ui->networkIdLineEdit->text());
|
QString toJoin(ui->networkIdLineEdit->text());
|
||||||
|
@ -340,3 +326,15 @@ void MainWindow::on_addressButton_clicked()
|
||||||
{
|
{
|
||||||
QApplication::clipboard()->setText(this->myAddress);
|
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
|
||||||
|
}
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QShowEvent>
|
||||||
|
#include <QTimerEvent>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -59,10 +61,7 @@ public:
|
||||||
public:
|
public:
|
||||||
ZTMessageEvent(const std::vector<std::string> &m) :
|
ZTMessageEvent(const std::vector<std::string> &m) :
|
||||||
QEvent(QEvent::User),
|
QEvent(QEvent::User),
|
||||||
ztMessage(m)
|
ztMessage(m) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<std::string> ztMessage;
|
std::vector<std::string> ztMessage;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -72,6 +71,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
virtual void timerEvent(QTimerEvent *event);
|
virtual void timerEvent(QTimerEvent *event);
|
||||||
virtual void customEvent(QEvent *event);
|
virtual void customEvent(QEvent *event);
|
||||||
|
virtual void showEvent(QShowEvent *event);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_joinNetworkButton_clicked();
|
void on_joinNetworkButton_clicked();
|
||||||
|
@ -80,6 +80,8 @@ private slots:
|
||||||
void on_addressButton_clicked();
|
void on_addressButton_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void doInstallDialog();
|
||||||
|
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
|
|
||||||
QString myAddress;
|
QString myAddress;
|
||||||
|
|
Loading…
Add table
Reference in a new issue