Skip to content

Commit

Permalink
feat: set cursor for bottom navigation
Browse files Browse the repository at this point in the history
Change-Id: I4714c6366044d43c31059a64cba9bc2c24e20f6c
  • Loading branch information
justforlxz committed Apr 10, 2018
1 parent fa4ee3e commit 555edec
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/widgets/bottomnavigation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <dimagebutton.h>
#include <QDesktopServices>
#include <QUrl>
#include <QEvent>

DWIDGET_USE_NAMESPACE

Expand Down Expand Up @@ -40,6 +41,14 @@ BottomNavigation::BottomNavigation(QWidget *parent)
":/resources/Mail.svg",
":/resources/Mail.svg");

QList<QWidget*> list;

list << sinaBtn << twitterBtn << facebook << offical << community << feedback << thank << mail;

for (QWidget *w : list) {
w->installEventFilter(this);
}

connect(sinaBtn, &DImageButton::clicked, this, &BottomNavigation::onButtonClicked);
connect(twitterBtn, &DImageButton::clicked, this, &BottomNavigation::onButtonClicked);
connect(facebook, &DImageButton::clicked, this, &BottomNavigation::onButtonClicked);
Expand Down Expand Up @@ -80,3 +89,16 @@ void BottomNavigation::onButtonClicked()

QDesktopServices::openUrl(QUrl(m_buttons[button]));
}

bool BottomNavigation::eventFilter(QObject *watched, QEvent *event)
{
if (event->type() == QEvent::Enter) {
setCursor(Qt::PointingHandCursor);
}

if (event->type() == QEvent::Leave) {
setCursor(Qt::ArrowCursor);
}

return QWidget::eventFilter(watched, event);
}
3 changes: 3 additions & 0 deletions src/widgets/bottomnavigation.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ class BottomNavigation : public QWidget
private slots:
void onButtonClicked();

protected:
bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE;

private:
QMap<QWidget*, QString> m_buttons;
};
Expand Down

0 comments on commit 555edec

Please sign in to comment.