Skip to content

Commit

Permalink
Adding about and sha to the config page
Browse files Browse the repository at this point in the history
  • Loading branch information
francescmm committed May 9, 2020
1 parent 9647b9d commit caed167
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 4 deletions.
5 changes: 4 additions & 1 deletion GitQlient.pro
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ OTHER_FILES += \

VERSION = 1.1.0

GQ_SHA = $$system(git rev-parse HEAD)

DEFINES += \
VER=\\\"$$VERSION\\\"
VER=\\\"$$VERSION\\\" \
SHA_VER=\\\"$$GQ_SHA\\\"

debug {
DEFINES += DEBUG
Expand Down
27 changes: 26 additions & 1 deletion src/aux_widgets/ClickableFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <QMouseEvent>
#include <QVBoxLayout>
#include <QLabel>
#include <QStyle>

ClickableFrame::ClickableFrame(QWidget *parent)
: QFrame(parent)
Expand All @@ -16,7 +17,7 @@ ClickableFrame::ClickableFrame(const QString &text, Qt::Alignment alignment, QWi
const auto layout = new QVBoxLayout(this);
layout->setContentsMargins(2, 2, 2, 2);
layout->setSpacing(0);
layout->addWidget(new QLabel(text));
layout->addWidget(mText = new QLabel(text));
layout->setAlignment(alignment);
}

Expand All @@ -30,3 +31,27 @@ void ClickableFrame::mouseReleaseEvent(QMouseEvent *e)
if (mPressed && rect().contains(e->pos()) && e->button() == Qt::LeftButton)
emit clicked();
}

void ClickableFrame::enterEvent(QEvent *event)
{
if (mHasLinkStyles)
{
QFont f = mText->font();
f.setUnderline(true);
mText->setFont(f);
}

QFrame::enterEvent(event);
}

void ClickableFrame::leaveEvent(QEvent *event)
{
if (mHasLinkStyles)
{
QFont f = mText->font();
f.setUnderline(false);
mText->setFont(f);
}

QFrame::leaveEvent(event);
}
21 changes: 21 additions & 0 deletions src/aux_widgets/ClickableFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

#include <QFrame>

class QLabel;

/**
* @brief The ClickableFrame class is simple widget to make QLabel clickable and at the same time give the hability to
* customize its look & feel. The behaviour is so simplified that only has a @p clicked() signal to notify the user that
Expand Down Expand Up @@ -61,6 +63,11 @@ class ClickableFrame : public QFrame
*/
explicit ClickableFrame(const QString &text, Qt::Alignment alignment, QWidget *parent = nullptr);

/**
* @brief setLinkStyle Sets the text of the widget overlined when hover.
*/
void setLinkStyle() { mHasLinkStyles = true; }

protected:
/**
* @brief Detects the press event to prepare the click signal.
Expand All @@ -75,6 +82,20 @@ class ClickableFrame : public QFrame
*/
void mouseReleaseEvent(QMouseEvent *e) override;

/**
* @brief enterEvent Detects the enter event and in case the link style is enabled it applies it.
* @param event The event.
*/
void enterEvent(QEvent *event) override;

/**
* @brief leaveEvent Detects the leave event and in case the link style is enabled it removes the underline.
* @param event
*/
void leaveEvent(QEvent *event) override;

private:
bool mPressed = false;
bool mHasLinkStyles = false;
QLabel *mText = nullptr;
};
29 changes: 27 additions & 2 deletions src/config/ConfigWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@
#include <QStyle>
#include <QLabel>
#include <QApplication>
#include <QMessageBox>

#include <QLogger.h>

using namespace QLogger;

#include <QDebug>

ConfigWidget::ConfigWidget(QWidget *parent)
: QFrame(parent)
, mOpenRepo(new QPushButton(tr("Open existing repo")))
Expand Down Expand Up @@ -52,6 +51,14 @@ ConfigWidget::ConfigWidget(QWidget *parent)
repoOptionsLayout->addWidget(mCloneRepo);
repoOptionsLayout->addWidget(mInitRepo);
repoOptionsLayout->addWidget(line);

const auto sha = QString("%1").arg(SHA_VER);
const auto version
= new ClickableFrame(QString("About GitQlient v%1 ...").arg(VER), Qt::AlignLeft | Qt::AlignVCenter);
version->setLinkStyle();
connect(version, &ClickableFrame::clicked, this, &ConfigWidget::showAbout);
version->setToolTip(sha);
repoOptionsLayout->addWidget(version);
repoOptionsLayout->addStretch();

const auto usedSubtitle = new QLabel(tr("Configuration"));
Expand Down Expand Up @@ -304,6 +311,24 @@ void ConfigWidget::updateProgressDialog(QString stepDescription, int value)
mProgressDlg->repaint();
}

void ConfigWidget::showAbout()
{
const QString aboutMsg
= "GitQlient, pronounced as git+client (/gɪtˈklaɪənt/) is a multi-platform Git client. "
"With GitQlient you will be able to add commits, branches and manage all the options Git provides. <br><br>"
"Once a fork of QGit, GitQlient has followed is own path and is currently develop and maintain by Francesc M. "
"You can download the code from <a href='https://github.com/francescmm/GitQlient'>GitHub</a>. If you find any "
"bug or problem, please report it in <a href='https://github.com/francescmm/GitQlient/issues'>the issues "
"page</a> so I can fix it as soon as possible.<br><br>"
"If you want to integrate GitQlient into QtCreator, there I also provide a plugin that you can download from "
"<a href='https://github.com/francescmm/GitQlientPlugin/releases'>here</a>. Just make sure you pick the right "
"version and follow the instructions in the main page of the repo.<br><br>"
"GitQlient can be compiled from Qt 5.9 on.<br><br>"
"Copyright &copy; 2019 - 2020 GitQlient (Francesc Martínez)";

QMessageBox::about(this, tr("About GitQlient v%1").arg(VER), aboutMsg);
}

void ConfigWidget::onRepoOpened()
{
mSettings->sync();
Expand Down
5 changes: 5 additions & 0 deletions src/config/ConfigWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,9 @@ class ConfigWidget : public QFrame
\param value The numeric value.
*/
void updateProgressDialog(QString stepDescription, int value);

/**
* @brief showAbout Shows GitQlient about info.
*/
void showAbout();
};

0 comments on commit caed167

Please sign in to comment.