Merge pull request #14049 from spowelljr/singleClickOpen
GUI: Clicking the tray icon opens GUIpull/14071/head
commit
98060bc396
|
@ -186,7 +186,6 @@ void Window::createAdvancedView()
|
||||||
connect(deleteButton, &QAbstractButton::clicked, this, &Window::deleteMinikube);
|
connect(deleteButton, &QAbstractButton::clicked, this, &Window::deleteMinikube);
|
||||||
connect(refreshButton, &QAbstractButton::clicked, this, &Window::updateClustersTable);
|
connect(refreshButton, &QAbstractButton::clicked, this, &Window::updateClustersTable);
|
||||||
connect(createButton, &QAbstractButton::clicked, this, &Window::initMachine);
|
connect(createButton, &QAbstractButton::clicked, this, &Window::initMachine);
|
||||||
connect(trayIcon, &QSystemTrayIcon::messageClicked, this, &Window::messageClicked);
|
|
||||||
|
|
||||||
clusterGroupBox->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
|
clusterGroupBox->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
|
||||||
stackedWidget->addWidget(clusterGroupBox);
|
stackedWidget->addWidget(clusterGroupBox);
|
||||||
|
@ -257,12 +256,35 @@ void Window::updateStatus(Cluster cluster)
|
||||||
statusAction->setText("Status: " + status);
|
statusAction->setText("Status: " + status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Window::iconActivated(QSystemTrayIcon::ActivationReason reason)
|
||||||
|
{
|
||||||
|
switch (reason) {
|
||||||
|
case QSystemTrayIcon::Trigger:
|
||||||
|
case QSystemTrayIcon::DoubleClick:
|
||||||
|
Window::restoreWindow();
|
||||||
|
break;
|
||||||
|
default:;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Window::restoreWindow()
|
void Window::restoreWindow()
|
||||||
{
|
{
|
||||||
|
bool wasVisible = isVisible();
|
||||||
QWidget::showNormal();
|
QWidget::showNormal();
|
||||||
|
activateWindow();
|
||||||
|
if (wasVisible) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// without this delay window doesn't render until updateClusters() completes
|
||||||
|
delay();
|
||||||
updateClustersTable();
|
updateClustersTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Window::delay()
|
||||||
|
{
|
||||||
|
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
|
||||||
|
}
|
||||||
|
|
||||||
static QString minikubePath()
|
static QString minikubePath()
|
||||||
{
|
{
|
||||||
QString program = QStandardPaths::findExecutable("minikube");
|
QString program = QStandardPaths::findExecutable("minikube");
|
||||||
|
@ -290,6 +312,8 @@ void Window::createTrayIcon()
|
||||||
trayIcon = new QSystemTrayIcon(this);
|
trayIcon = new QSystemTrayIcon(this);
|
||||||
trayIcon->setContextMenu(trayIconMenu);
|
trayIcon->setContextMenu(trayIconMenu);
|
||||||
trayIcon->setIcon(*trayIconIcon);
|
trayIcon->setIcon(*trayIconIcon);
|
||||||
|
|
||||||
|
connect(trayIcon, &QSystemTrayIcon::activated, this, &Window::iconActivated);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::startMinikube(QStringList moreArgs)
|
void Window::startMinikube(QStringList moreArgs)
|
||||||
|
@ -341,11 +365,37 @@ void Window::deleteMinikube()
|
||||||
|
|
||||||
void Window::updateClustersTable()
|
void Window::updateClustersTable()
|
||||||
{
|
{
|
||||||
|
showLoading();
|
||||||
QString cluster = selectedClusterName();
|
QString cluster = selectedClusterName();
|
||||||
updateClusterList();
|
updateClusterList();
|
||||||
clusterModel->setClusters(clusterList);
|
clusterModel->setClusters(clusterList);
|
||||||
setSelectedClusterName(cluster);
|
setSelectedClusterName(cluster);
|
||||||
updateButtons();
|
updateButtons();
|
||||||
|
loading->setHidden(true);
|
||||||
|
clusterListView->setEnabled(true);
|
||||||
|
hideLoading();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Window::showLoading()
|
||||||
|
{
|
||||||
|
clusterListView->setEnabled(false);
|
||||||
|
loading->setHidden(false);
|
||||||
|
loading->raise();
|
||||||
|
int width = getCenter(loading->width(), clusterListView->width());
|
||||||
|
int height = getCenter(loading->height(), clusterListView->height());
|
||||||
|
loading->move(width, height);
|
||||||
|
delay();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Window::hideLoading()
|
||||||
|
{
|
||||||
|
loading->setHidden(true);
|
||||||
|
clusterListView->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
int Window::getCenter(int widgetSize, int parentSize)
|
||||||
|
{
|
||||||
|
return parentSize / 2 - widgetSize / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::updateClusterList()
|
void Window::updateClusterList()
|
||||||
|
@ -505,6 +555,13 @@ void Window::createClusterGroupBox()
|
||||||
clusterLayout->addWidget(clusterListView);
|
clusterLayout->addWidget(clusterListView);
|
||||||
clusterLayout->addLayout(bottomButtonLayout);
|
clusterLayout->addLayout(bottomButtonLayout);
|
||||||
clusterGroupBox->setLayout(clusterLayout);
|
clusterGroupBox->setLayout(clusterLayout);
|
||||||
|
|
||||||
|
QFont *loadingFont = new QFont();
|
||||||
|
loadingFont->setPointSize(30);
|
||||||
|
loading = new QLabel("Loading...");
|
||||||
|
loading->setFont(*loadingFont);
|
||||||
|
loading->setParent(clusterListView);
|
||||||
|
loading->setHidden(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::updateButtons()
|
void Window::updateButtons()
|
||||||
|
|
|
@ -104,6 +104,7 @@ private:
|
||||||
void createActions();
|
void createActions();
|
||||||
void updateStatus(Cluster cluster);
|
void updateStatus(Cluster cluster);
|
||||||
void updateTrayActions(Cluster cluster);
|
void updateTrayActions(Cluster cluster);
|
||||||
|
void iconActivated(QSystemTrayIcon::ActivationReason reason);
|
||||||
QAction *minimizeAction;
|
QAction *minimizeAction;
|
||||||
QAction *restoreAction;
|
QAction *restoreAction;
|
||||||
QAction *quitAction;
|
QAction *quitAction;
|
||||||
|
@ -148,9 +149,12 @@ private:
|
||||||
Cluster selectedCluster();
|
Cluster selectedCluster();
|
||||||
void updateClusterList();
|
void updateClusterList();
|
||||||
void updateClustersTable();
|
void updateClustersTable();
|
||||||
|
void showLoading();
|
||||||
|
void hideLoading();
|
||||||
ClusterModel *clusterModel;
|
ClusterModel *clusterModel;
|
||||||
QTableView *clusterListView;
|
QTableView *clusterListView;
|
||||||
ClusterList clusterList;
|
ClusterList clusterList;
|
||||||
|
QLabel *loading;
|
||||||
|
|
||||||
// Create cluster
|
// Create cluster
|
||||||
void askCustom();
|
void askCustom();
|
||||||
|
@ -187,6 +191,8 @@ private:
|
||||||
QProcessEnvironment setMacEnv();
|
QProcessEnvironment setMacEnv();
|
||||||
QStackedWidget *stackedWidget;
|
QStackedWidget *stackedWidget;
|
||||||
bool isBasicView;
|
bool isBasicView;
|
||||||
|
void delay();
|
||||||
|
int getCenter(int widgetSize, int parentSize);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QT_NO_SYSTEMTRAYICON
|
#endif // QT_NO_SYSTEMTRAYICON
|
||||||
|
|
Loading…
Reference in New Issue