Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make buttons blue when clickable and gray when not clickable #66

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,6 @@ compile_commands.json
*creator.user*

.DS_Store

# Vscode configurations
.vscode
2 changes: 2 additions & 0 deletions minikube.pro
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ HEADERS = src/window.h \
src/fonts.h \
src/hyperkit.h \
src/logger.h \
src/minikubebutton.h \
src/mount.h \
src/operator.h \
src/paths.h \
Expand All @@ -31,6 +32,7 @@ SOURCES = src/main.cpp \
src/fonts.cpp \
src/hyperkit.cpp \
src/logger.cpp \
src/minikubebutton.cpp \
src/operator.cpp \
src/paths.cpp \
src/progresswindow.cpp \
Expand Down
20 changes: 10 additions & 10 deletions src/advancedview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ AdvancedView::AdvancedView(QIcon icon)
clusterListView->horizontalHeader()->setSectionResizeMode(6, QHeaderView::ResizeToContents);
setSelectedClusterName("default");

startButton = new QPushButton(tr("Start"));
stopButton = new QPushButton(tr("Stop"));
pauseButton = new QPushButton(tr("Pause"));
deleteButton = new QPushButton(tr("Delete"));
refreshButton = new QPushButton(tr("Refresh"));
createButton = new QPushButton(tr("Create"));
dockerEnvButton = new QPushButton("docker-env");
sshButton = new QPushButton("SSH");
dashboardButton = new QPushButton(tr("Dashboard"));
basicButton = new QPushButton(tr("Basic View"));
startButton = new MinikubeButton(tr("Start"));
stopButton = new MinikubeButton(tr("Stop"));
pauseButton = new MinikubeButton(tr("Pause"));
deleteButton = new MinikubeButton(tr("Delete"));
refreshButton = new MinikubeButton(tr("Refresh"));
createButton = new MinikubeButton(tr("Create"));
dockerEnvButton = new MinikubeButton("docker-env");
sshButton = new MinikubeButton("SSH");
dashboardButton = new MinikubeButton(tr("Dashboard"));
basicButton = new MinikubeButton(tr("Basic View"));

disableButtons();

Expand Down
21 changes: 11 additions & 10 deletions src/advancedview.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ limitations under the License.
#define ADVANCEDVIEW_H

#include "cluster.h"
#include "minikubebutton.h"

#include <QLabel>
#include <QPushButton>
Expand Down Expand Up @@ -58,16 +59,16 @@ public slots:
void askName();
void askCustom();

QPushButton *startButton;
QPushButton *stopButton;
QPushButton *pauseButton;
QPushButton *deleteButton;
QPushButton *refreshButton;
QPushButton *dockerEnvButton;
QPushButton *sshButton;
QPushButton *dashboardButton;
QPushButton *basicButton;
QPushButton *createButton;
MinikubeButton *startButton;
MinikubeButton *stopButton;
MinikubeButton *pauseButton;
MinikubeButton *deleteButton;
MinikubeButton *refreshButton;
MinikubeButton *dockerEnvButton;
MinikubeButton *sshButton;
MinikubeButton *dashboardButton;
MinikubeButton *basicButton;
MinikubeButton *createButton;
QLabel *loading;
ClusterModel *m_clusterModel;

Expand Down
35 changes: 17 additions & 18 deletions src/basicview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,23 @@ BasicView::BasicView(QIcon icon)
QVBoxLayout *topBar = new QVBoxLayout;
topBar->addWidget(topStatusButton);

startButton = new QPushButton(Constants::startIcon);
stopButton = new QPushButton(Constants::stopIcon);
pauseButton = new QPushButton(Constants::pauseIcon);
deleteButton = new QPushButton(Constants::deleteIcon);

dockerEnvButton = new QPushButton("docker-env");
serviceButton = new QPushButton("service");
mountButton = new QPushButton(tr("mount"));
tunnelButton = new QPushButton(tr("tunnel"));
sshButton = new QPushButton("SSH");
dashboardButton = new QPushButton(tr("dashboard"));
addonsButton = new QPushButton(tr("addons"));
advancedButton = new QPushButton(tr("cluster list"));

refreshButton = new QPushButton(Constants::refreshIcon);
settingsButton = new QPushButton(Constants::settingsIcon);
aboutButton = new QPushButton(Constants::aboutIcon);
exitButton = new QPushButton(Constants::exitIcon);
startButton = new MinikubeButton(Constants::startIcon);
stopButton = new MinikubeButton(Constants::stopIcon);
pauseButton = new MinikubeButton(Constants::pauseIcon);
deleteButton = new MinikubeButton(Constants::deleteIcon);

dockerEnvButton = new MinikubeButton("docker-env");
serviceButton = new MinikubeButton("service");
mountButton = new MinikubeButton(tr("mount"));
tunnelButton = new MinikubeButton(tr("tunnel"));
sshButton = new MinikubeButton("SSH");
dashboardButton = new MinikubeButton(tr("dashboard"));
addonsButton = new MinikubeButton(tr("addons"));
advancedButton = new MinikubeButton(tr("cluster list"));
refreshButton = new MinikubeButton(Constants::refreshIcon);
settingsButton = new MinikubeButton(Constants::settingsIcon);
aboutButton = new MinikubeButton(Constants::aboutIcon);
exitButton = new MinikubeButton(Constants::exitIcon);

// all the buttons that have icon needs to be set here
Fonts::setFontAwesome(startButton);
Expand Down
33 changes: 17 additions & 16 deletions src/basicview.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ limitations under the License.
#include "cluster.h"
#include "mount.h"
#include "setting.h"
#include "minikubebutton.h"

#include <QPushButton>
#include <QLabel>
Expand Down Expand Up @@ -57,22 +58,22 @@ class BasicView : public QObject

private:
QPushButton *topStatusButton;
QPushButton *startButton;
QPushButton *stopButton;
QPushButton *pauseButton;
QPushButton *deleteButton;
QPushButton *refreshButton;
QPushButton *dockerEnvButton;
QPushButton *serviceButton;
QPushButton *mountButton;
QPushButton *tunnelButton;
QPushButton *sshButton;
QPushButton *dashboardButton;
QPushButton *addonsButton;
QPushButton *advancedButton;
QPushButton *settingsButton;
QPushButton *aboutButton;
QPushButton *exitButton;
MinikubeButton *startButton;
MinikubeButton *stopButton;
MinikubeButton *pauseButton;
MinikubeButton *deleteButton;
MinikubeButton *refreshButton;
MinikubeButton *dockerEnvButton;
MinikubeButton *serviceButton;
MinikubeButton *mountButton;
MinikubeButton *tunnelButton;
MinikubeButton *sshButton;
MinikubeButton *dashboardButton;
MinikubeButton *addonsButton;
MinikubeButton *advancedButton;
MinikubeButton *settingsButton;
MinikubeButton *aboutButton;
MinikubeButton *exitButton;
QIcon m_icon;
MountList m_mountList;
Setting m_setting;
Expand Down
43 changes: 43 additions & 0 deletions src/minikubebutton.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include "minikubebutton.h"

MinikubeButton::MinikubeButton(QWidget *parent) : QPushButton(parent)
{
// By default a button is enabled when instantiated
setStyleSheet(enabledStyleSheet);
}

MinikubeButton::MinikubeButton(const QString &text, QWidget *parent) : QPushButton(text, parent)
{
setStyleSheet(enabledStyleSheet);
}

MinikubeButton::MinikubeButton(const QIcon &icon, const QString &text, QWidget *parent)
: QPushButton(icon, text, parent)
{
setStyleSheet(enabledStyleSheet);
}

void MinikubeButton::setEnabled(bool enabled)
{
QPushButton::setEnabled(enabled);
setStyleSheet(enabled ? enabledStyleSheet : diabledStyleSheet);
}

bool MinikubeButton::event(QEvent *event)
{
switch (event->type()) {
case QEvent::HoverEnter:
if (isEnabled()) {
setStyleSheet(enabledHoverStyleSheet);
}
break;
case QEvent::HoverLeave:
if (isEnabled()) {
setStyleSheet(enabledStyleSheet);
}

default:
break;
}
return QPushButton::event(event);
}
24 changes: 24 additions & 0 deletions src/minikubebutton.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef MINIKUBEBUTTON_H
#define MINIKUBEBUTTON_H
#include <QPushButton>
#include <QEvent>
class MinikubeButton : public QPushButton
{
public:
explicit MinikubeButton(QWidget *parent = nullptr);
explicit MinikubeButton(const QString &text, QWidget *parent = nullptr);
MinikubeButton(const QIcon &icon, const QString &text, QWidget *parent = nullptr);

void setEnabled(bool enabled);

virtual bool event(QEvent *event) override;

private:
const QString enabledStyleSheet = "";
const QString enabledHoverStyleSheet = "background-color:rgb(105,192,255,50)";

const QString diabledStyleSheet =
"background-color:rgb(191,191,191,50);color:rgb(140,140,140);";
};

#endif // MINIKUBEBUTTON_H
Loading