diff --git a/gui/commandrunner.cpp b/gui/commandrunner.cpp index 3c460971b0..53f6ec9d2d 100644 --- a/gui/commandrunner.cpp +++ b/gui/commandrunner.cpp @@ -18,11 +18,13 @@ CommandRunner::CommandRunner(QDialog *parent) void CommandRunner::executeMinikubeCommand(QStringList args) { + m_isRunning = true; m_output = ""; QStringList userArgs = { "--user", "minikube-gui" }; args << userArgs; m_process = new QProcess(m_parent); - connect(m_process, QOverload::of(&QProcess::finished), this, &CommandRunner::executionCompleted); + connect(m_process, QOverload::of(&QProcess::finished), this, + &CommandRunner::executionCompleted); connect(m_process, &QProcess::readyReadStandardError, this, &CommandRunner::errorReady); connect(m_process, &QProcess::readyReadStandardOutput, this, &CommandRunner::outputReady); m_process->setProcessEnvironment(m_env); @@ -163,6 +165,7 @@ void CommandRunner::requestClusters() void CommandRunner::executionCompleted() { + m_isRunning = false; QString cmd = m_command; m_command = ""; QString output = m_output; @@ -212,3 +215,8 @@ void CommandRunner::minikubePath() QStringList path = { "/usr/local/bin" }; m_minikubePath = QStandardPaths::findExecutable("minikube", path); } + +bool CommandRunner::isRunning() +{ + return m_isRunning; +} diff --git a/gui/commandrunner.h b/gui/commandrunner.h index ddf8cfbaca..2d836d9f32 100644 --- a/gui/commandrunner.h +++ b/gui/commandrunner.h @@ -25,6 +25,7 @@ public: void deleteMinikube(QStringList args); void stopCommand(); void requestClusters(); + bool isRunning(); signals: void startingExecution(); @@ -53,6 +54,7 @@ private: QString m_command; QDialog *m_parent; QStringList m_args; + bool m_isRunning; }; #endif // COMMANDRUNNER_H diff --git a/gui/errormessage.cpp b/gui/errormessage.cpp index 375eb77eee..d4222092f1 100644 --- a/gui/errormessage.cpp +++ b/gui/errormessage.cpp @@ -13,7 +13,8 @@ ErrorMessage::ErrorMessage(QDialog *parent, QIcon icon) m_icon = icon; } -void ErrorMessage::error(QString errorCode, QString advice, QString message, QString url, QString issues) +void ErrorMessage::error(QString errorCode, QString advice, QString message, QString url, + QString issues) { m_dialog = new QDialog(m_parent); diff --git a/gui/errormessage.h b/gui/errormessage.h index dfab8e1db6..0ab015383c 100644 --- a/gui/errormessage.h +++ b/gui/errormessage.h @@ -14,7 +14,8 @@ class ErrorMessage : public QObject public: explicit ErrorMessage(QDialog *parent, QIcon icon); - void error(QString errorCode, QString advice, QString errorMessage, QString url, QString issues); + void error(QString errorCode, QString advice, QString errorMessage, QString url, + QString issues); QLabel *createLabel(QString title, QString text, QFormLayout *form, bool isLink); private: diff --git a/gui/operator.cpp b/gui/operator.cpp index 61b7b4918e..336573fae3 100644 --- a/gui/operator.cpp +++ b/gui/operator.cpp @@ -5,7 +5,10 @@ #include #include -Operator::Operator(AdvancedView *advancedView, BasicView *basicView, CommandRunner *commandRunner, ErrorMessage *errorMessage, ProgressWindow *progressWindow, Tray *tray, HyperKit *hyperKit, Updater *updater, QStackedWidget *stackedWidget, QDialog *parent) +Operator::Operator(AdvancedView *advancedView, BasicView *basicView, CommandRunner *commandRunner, + ErrorMessage *errorMessage, ProgressWindow *progressWindow, Tray *tray, + HyperKit *hyperKit, Updater *updater, QStackedWidget *stackedWidget, + QDialog *parent) { m_advancedView = advancedView; m_basicView = basicView; @@ -37,14 +40,16 @@ Operator::Operator(AdvancedView *advancedView, BasicView *basicView, CommandRunn connect(m_advancedView, &AdvancedView::dashboard, this, &Operator::dashboardBrowser); connect(m_advancedView, &AdvancedView::basic, this, &Operator::toBasicView); connect(m_advancedView, &AdvancedView::createCluster, this, &Operator::createCluster); - connect(m_advancedView->clusterListView, SIGNAL(clicked(QModelIndex)), this, SLOT(updateButtons())); + connect(m_advancedView->clusterListView, SIGNAL(clicked(QModelIndex)), this, + SLOT(updateButtons())); connect(m_commandRunner, &CommandRunner::startingExecution, this, &Operator::commandStarting); connect(m_commandRunner, &CommandRunner::executionEnded, this, &Operator::commandEnding); connect(m_commandRunner, &CommandRunner::output, this, &Operator::commandOutput); connect(m_commandRunner, &CommandRunner::error, this, &Operator::commandError); connect(m_commandRunner, &CommandRunner::updatedClusters, this, &Operator::clustersReceived); - connect(m_commandRunner, &CommandRunner::startCommandStarting, this, &Operator::startCommandStarting); + connect(m_commandRunner, &CommandRunner::startCommandStarting, this, + &Operator::startCommandStarting); connect(m_progressWindow, &ProgressWindow::cancelled, this, &Operator::cancelCommand); @@ -185,6 +190,8 @@ void Operator::restoreWindow() if (wasVisible) { return; } + if (m_commandRunner->isRunning()) + return; updateClusters(); } diff --git a/gui/operator.h b/gui/operator.h index eb1490c423..69239911b2 100644 --- a/gui/operator.h +++ b/gui/operator.h @@ -18,7 +18,9 @@ class Operator : public QObject Q_OBJECT public: - Operator(AdvancedView *advancedView, BasicView *basicView, CommandRunner *commandRunner, ErrorMessage *errorMessage, ProgressWindow *progressWindow, Tray *tray, HyperKit *hyperKit, Updater *updater, QStackedWidget *stackedWidget, QDialog *parent); + Operator(AdvancedView *advancedView, BasicView *basicView, CommandRunner *commandRunner, + ErrorMessage *errorMessage, ProgressWindow *progressWindow, Tray *tray, + HyperKit *hyperKit, Updater *updater, QStackedWidget *stackedWidget, QDialog *parent); public slots: void startMinikube(); diff --git a/gui/tray.cpp b/gui/tray.cpp index 30717fe562..d8c3e3d914 100644 --- a/gui/tray.cpp +++ b/gui/tray.cpp @@ -1,8 +1,8 @@ #include "tray.h" -#include -#include -#include +#include +#include +#include Tray::Tray(QIcon icon) { diff --git a/gui/updater.cpp b/gui/updater.cpp index ea18e2b279..e39a1d5278 100644 --- a/gui/updater.cpp +++ b/gui/updater.cpp @@ -13,7 +13,6 @@ #include #include - Updater::Updater(QVersionNumber version, QIcon icon) { m_version = version; @@ -22,7 +21,8 @@ Updater::Updater(QVersionNumber version, QIcon icon) static bool checkedForUpdateRecently() { - QString filePath = QStandardPaths::locate(QStandardPaths::HomeLocation, "/.minikube-gui/last_update_check"); + QString filePath = QStandardPaths::locate(QStandardPaths::HomeLocation, + "/.minikube-gui/last_update_check"); if (filePath == "") { return false; } @@ -32,14 +32,14 @@ static bool checkedForUpdateRecently() } QTextStream in(&file); QString line = in.readLine(); - QDateTime nextCheck = QDateTime::fromString(line).addSecs(60*60*24); + QDateTime nextCheck = QDateTime::fromString(line).addSecs(60 * 60 * 24); QDateTime now = QDateTime::currentDateTime(); return nextCheck > now; } static void logUpdateCheck() { - QDir dir = QDir(QDir::homePath() + "/.minikube-gui"); + QDir dir = QDir(QDir::homePath() + "/.minikube-gui"); if (!dir.exists()) { dir.mkpath("."); } diff --git a/gui/window.cpp b/gui/window.cpp index 4f54c63e44..aada74c8de 100644 --- a/gui/window.cpp +++ b/gui/window.cpp @@ -108,7 +108,8 @@ Window::Window() hyperKit = new HyperKit(*trayIconIcon); updater = new Updater(version, *trayIconIcon); - op = new Operator(advancedView, basicView, commandRunner, errorMessage, progressWindow, tray, hyperKit, updater, stackedWidget, this); + op = new Operator(advancedView, basicView, commandRunner, errorMessage, progressWindow, tray, + hyperKit, updater, stackedWidget, this); stackedWidget->addWidget(basicView->basicView); stackedWidget->addWidget(advancedView->advancedView);