From caed16703d3ff515748cde80da31ddfef8e436d1 Mon Sep 17 00:00:00 2001 From: Francesc Martinez Date: Sat, 9 May 2020 09:53:56 +0200 Subject: [PATCH] Adding about and sha to the config page --- GitQlient.pro | 5 ++++- src/aux_widgets/ClickableFrame.cpp | 27 ++++++++++++++++++++++++++- src/aux_widgets/ClickableFrame.h | 21 +++++++++++++++++++++ src/config/ConfigWidget.cpp | 29 +++++++++++++++++++++++++++-- src/config/ConfigWidget.h | 5 +++++ 5 files changed, 83 insertions(+), 4 deletions(-) diff --git a/GitQlient.pro b/GitQlient.pro index 2ec68586..fcd40ce9 100644 --- a/GitQlient.pro +++ b/GitQlient.pro @@ -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 diff --git a/src/aux_widgets/ClickableFrame.cpp b/src/aux_widgets/ClickableFrame.cpp index b9b30770..a1389aed 100644 --- a/src/aux_widgets/ClickableFrame.cpp +++ b/src/aux_widgets/ClickableFrame.cpp @@ -3,6 +3,7 @@ #include #include #include +#include ClickableFrame::ClickableFrame(QWidget *parent) : QFrame(parent) @@ -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); } @@ -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); +} diff --git a/src/aux_widgets/ClickableFrame.h b/src/aux_widgets/ClickableFrame.h index 3b3fe93b..24282f46 100644 --- a/src/aux_widgets/ClickableFrame.h +++ b/src/aux_widgets/ClickableFrame.h @@ -25,6 +25,8 @@ #include +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 @@ -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. @@ -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; }; diff --git a/src/config/ConfigWidget.cpp b/src/config/ConfigWidget.cpp index c173e29f..7ade8e78 100644 --- a/src/config/ConfigWidget.cpp +++ b/src/config/ConfigWidget.cpp @@ -16,13 +16,12 @@ #include #include #include +#include #include using namespace QLogger; -#include - ConfigWidget::ConfigWidget(QWidget *parent) : QFrame(parent) , mOpenRepo(new QPushButton(tr("Open existing repo"))) @@ -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")); @@ -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.

" + "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 GitHub. If you find any " + "bug or problem, please report it in the issues " + "page so I can fix it as soon as possible.

" + "If you want to integrate GitQlient into QtCreator, there I also provide a plugin that you can download from " + "here. Just make sure you pick the right " + "version and follow the instructions in the main page of the repo.

" + "GitQlient can be compiled from Qt 5.9 on.

" + "Copyright © 2019 - 2020 GitQlient (Francesc Martínez)"; + + QMessageBox::about(this, tr("About GitQlient v%1").arg(VER), aboutMsg); +} + void ConfigWidget::onRepoOpened() { mSettings->sync(); diff --git a/src/config/ConfigWidget.h b/src/config/ConfigWidget.h index 31c85767..95f39e07 100644 --- a/src/config/ConfigWidget.h +++ b/src/config/ConfigWidget.h @@ -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(); };