Skip to content

Commit

Permalink
Merge pull request #16 from kubernetes-sigs/createIcon
Browse files Browse the repository at this point in the history
add create Icon when there is no cluster running
  • Loading branch information
medyagh authored Jan 25, 2023
2 parents c538a2f + 841b5e4 commit b54fc1c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 11 deletions.
20 changes: 14 additions & 6 deletions src/basicview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ BasicView::BasicView()
{
basicView = new QWidget();

topStatus = new QLabel("nil");
topStatus = new QLabel("Loading ...");
QVBoxLayout *topBar = new QVBoxLayout;
topStatus->setAlignment(Qt::AlignCenter);

Expand Down Expand Up @@ -99,8 +99,12 @@ static QString getPauseLabel(bool isPaused)
return Constants::pauseIcon;
}

static QString getStartLabel(bool isRunning, bool isPaused)
static QString getStartLabel(bool exists, bool isRunning, bool isPaused)
{
if (!exists) {
return Constants::createIcon;
}

if (isRunning || isPaused) {
return Constants::reloadIcon;
}
Expand All @@ -115,12 +119,16 @@ static QString getPauseToolTip(bool isPaused)
return "Pause Kubernetes cluster";
}

static QString getStartToolTip(bool isRunning, bool isPaused)
static QString getStartToolTip(bool exists, bool isRunning, bool isPaused)
{
if (!exists) {
return "Create a new cluster";
}

if (isRunning || isPaused) {
return "Restart (reconfigure) an already running cluster";
}
return "Start the default cluster";
return "Start the cluster";
}

void BasicView::update(Cluster cluster)
Expand All @@ -145,8 +153,8 @@ void BasicView::update(Cluster cluster)
#endif
pauseButton->setText(getPauseLabel(isPaused));
pauseButton->setToolTip(getPauseToolTip(isPaused));
startButton->setText(getStartLabel(isRunning, isPaused));
startButton->setToolTip(getStartToolTip(isRunning, isPaused));
startButton->setText(getStartLabel(exists, isRunning, isPaused));
startButton->setToolTip(getStartToolTip(exists, isRunning, isPaused));
}

void BasicView::disableButtons()
Expand Down
2 changes: 1 addition & 1 deletion src/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Cluster
Cluster() : Cluster("") { }
Cluster(const QString &name)
: m_name(name),
m_status(""),
m_status("No Existing Cluster"),
m_driver(""),
m_container_runtime(""),
m_k8s_version(""),
Expand Down
1 change: 1 addition & 0 deletions src/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Constants
inline static const QString unPauseIcon = "\uf04b";
inline static const QString deleteIcon = "\uf1f8";
inline static const QString reloadIcon = "\uf021";
inline static const QString createIcon = "\uf0fe";
};

#endif // CONSTANTS_H
12 changes: 9 additions & 3 deletions src/fonts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ limitations under the License.
#include <QDebug>
#include <QFontDatabase>
#include <QToolTip>
#include <QPalette>

QFont Fonts::fontAwesome;

void Fonts::initFonts()
{
loadFontAwesome();
setToolTipFont();
setToolTipStyle();
}

void Fonts::loadFontAwesome()
Expand All @@ -36,11 +37,16 @@ void Fonts::loadFontAwesome()
fontAwesome.setPixelSize(20);
}

void Fonts::setToolTipFont()
void Fonts::setToolTipStyle()
{
QFont tooltipFont = QToolTip::font();
tooltipFont.setPointSize(20);
tooltipFont.setPointSize(18);
QToolTip::setFont(tooltipFont);
QPalette palette;
palette.setColor(QPalette::ToolTipText, Qt::black);
palette.setColor(QPalette::ToolTipBase, Qt::lightGray);
QToolTip::setPalette(palette);

}

void Fonts::setFontAwesome(QWidget *wid)
Expand Down
2 changes: 1 addition & 1 deletion src/fonts.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Fonts

private:
static void loadFontAwesome();
static void setToolTipFont();
static void setToolTipStyle();
static QFont fontAwesome;
};

Expand Down

0 comments on commit b54fc1c

Please sign in to comment.