Skip to content

Commit

Permalink
About button support display minikube gui version
Browse files Browse the repository at this point in the history
Signed-off-by: aiyijing <[email protected]>
  • Loading branch information
aiyijing committed Jul 17, 2023
1 parent 06d1b11 commit a7b083a
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 5 deletions.
62 changes: 60 additions & 2 deletions src/basicview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ limitations under the License.
#include <QCoreApplication>
#include <QCheckBox>

BasicView::BasicView(QIcon icon)
BasicView::BasicView(QIcon icon,QVersionNumber version)
{
m_icon = icon;
m_version = version;
basicView = new QWidget();

topStatusButton = new QPushButton("Loading ...");
Expand Down Expand Up @@ -126,7 +127,7 @@ BasicView::BasicView(QIcon icon)
connect(addonsButton, &QAbstractButton::clicked, this, &BasicView::addons);
connect(advancedButton, &QAbstractButton::clicked, this, &BasicView::advanced);
connect(settingsButton, &QAbstractButton::clicked, this, &BasicView::askSettings);
connect(aboutButton, &QAbstractButton::clicked, qApp, &QApplication::aboutQt);
connect(aboutButton, &QAbstractButton::clicked, this, &BasicView::displayAbout);
connect(exitButton, &QAbstractButton::clicked, qApp, &QCoreApplication::quit);
}

Expand Down Expand Up @@ -338,3 +339,60 @@ void BasicView::minikubeNotFound()
form.addRow(&buttonBox);
dialog.exec();
}

void BasicView::displayAbout(){
QDialog aboutDialog;
aboutDialog.setWindowTitle("About Minikube GUI");
aboutDialog.setFixedSize(300, 200);
QVBoxLayout mainLayout(&aboutDialog);

// iconLayout displays minikube icon
QHBoxLayout iconLayout;
iconLayout.setAlignment(Qt::AlignCenter);

QLabel iconLabel;
iconLabel.setPixmap(m_icon.pixmap(50, 50));
iconLayout.addWidget(&iconLabel);
mainLayout.addLayout(&iconLayout);

// introLayout displays minikube gui info, home URL, and license URL
QVBoxLayout introLayout;
introLayout.setContentsMargins(10, 10, 10, 10);
introLayout.setAlignment(Qt::AlignCenter);

QLabel introLabel;
introLabel.setText("A graphical interface for minikube.");
introLayout.addWidget(&introLabel);

// hyperlinkItemLayout
QHBoxLayout hyperlinkItemLayout;
hyperlinkItemLayout.setAlignment(Qt::AlignCenter);

QLabel githubURLLabel;
githubURLLabel.setText("<a href='https://github.com/kubernetes-sigs/minikube-gui'>GitHub</a>");
githubURLLabel.setOpenExternalLinks(true);
hyperlinkItemLayout.addWidget(&githubURLLabel);

QLabel licenseURLLabel;
licenseURLLabel.setText("<a href='https://raw.githubusercontent.com/kubernetes-sigs/minikube-gui/main/LICENSE'>License</a>");
licenseURLLabel.setOpenExternalLinks(true);
hyperlinkItemLayout.addWidget(&licenseURLLabel);

introLayout.addLayout(&hyperlinkItemLayout);
mainLayout.addLayout(&introLayout);

// versionItemLayout displays minikube gui version
// TODO: display minikube binary version
QHBoxLayout versionItemLayout;
versionItemLayout.setAlignment(Qt::AlignCenter);

QLabel versionLabel("Version: " + m_version.toString());
versionLabel.setStyleSheet("QLabel { color: gray; }");
versionLabel.setAlignment(Qt::AlignCenter);
versionLabel.setTextInteractionFlags(Qt::TextSelectableByMouse);
versionItemLayout.addWidget(&versionLabel);
mainLayout.addLayout(&versionItemLayout);

aboutDialog.exec();
}

5 changes: 4 additions & 1 deletion src/basicview.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,22 @@ limitations under the License.
#include <QPushButton>
#include <QLabel>
#include <QSettings>
#include <QVersionNumber>

class BasicView : public QObject
{
Q_OBJECT

public:
explicit BasicView(QIcon icon);
explicit BasicView(QIcon icon, QVersionNumber version);
QWidget *basicView;
void update(Cluster cluster);
void updateMounts(MountList ms);
void disableButtons();
void setFont(QFont font, QWidget *wid);
void receivedSettings(Setting s);
void minikubeNotFound();
void displayAbout();
signals:
void start();
void stop();
Expand Down Expand Up @@ -74,6 +76,7 @@ class BasicView : public QObject
QPushButton *aboutButton;
QPushButton *exitButton;
QIcon m_icon;
QVersionNumber m_version;
MountList m_mountList;
Setting m_setting;
void askMount();
Expand Down
2 changes: 1 addition & 1 deletion src/constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ const QString Constants::createIcon = "\uf0fe";

const QString Constants::refreshIcon = "\uf021";
const QString Constants::settingsIcon = "\uf1de";
const QString Constants::aboutIcon = "\uf118";
const QString Constants::aboutIcon = "\uf05a";
const QString Constants::exitIcon = "\uf08b";
2 changes: 1 addition & 1 deletion src/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Window::Window()
logger = new Logger();
settings = new Settings();
commandRunner = new CommandRunner(this, logger, settings);
basicView = new BasicView(*trayIconIcon);
basicView = new BasicView(*trayIconIcon, version);
serviceView = new ServiceView(this, *trayIconIcon);
addonsView = new AddonsView(*trayIconIcon);
advancedView = new AdvancedView(*trayIconIcon);
Expand Down

0 comments on commit a7b083a

Please sign in to comment.