From 776a2deb91f7d1d72310af7dce3af454cd6f9cb8 Mon Sep 17 00:00:00 2001 From: Casey Link Date: Thu, 1 Sep 2011 00:29:05 +0000 Subject: [PATCH] Make the root icon clickable and expose a signal. --- src/libtomahawk/widgets/breadcrumbbar.cpp | 9 ++++++--- src/libtomahawk/widgets/breadcrumbbar.h | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/libtomahawk/widgets/breadcrumbbar.cpp b/src/libtomahawk/widgets/breadcrumbbar.cpp index 5a44408b9..6486ed02d 100644 --- a/src/libtomahawk/widgets/breadcrumbbar.cpp +++ b/src/libtomahawk/widgets/breadcrumbbar.cpp @@ -241,12 +241,15 @@ void BreadcrumbBar::currentIndexChanged() void BreadcrumbBar::setRootIcon(const QIcon &icon) { + m_rootIcon = icon; - QLabel *label= new QLabel(this); - label->setPixmap(icon.pixmap(16,16)); - m_layout->insertWidget(0, label); + QPushButton* button = new QPushButton(icon, "", this); + button->setFlat(true); + button->setStyleSheet( "QPushButton{ background-color: transparent; border: none; width:16px; height:16px;}" ); + m_layout->insertWidget(0, button); m_layout->insertSpacing(0,5); m_layout->insertSpacing(2,5); + connect(button, SIGNAL(clicked()), this, SIGNAL(rootClicked())); } void BreadcrumbBar::setRootText(const QString &text) diff --git a/src/libtomahawk/widgets/breadcrumbbar.h b/src/libtomahawk/widgets/breadcrumbbar.h index 999fc1ab0..d9cd6a6d5 100644 --- a/src/libtomahawk/widgets/breadcrumbbar.h +++ b/src/libtomahawk/widgets/breadcrumbbar.h @@ -129,6 +129,9 @@ public: */ void currentChangedTriggered(QModelIndex const& index); +signals: + void rootClicked(); + protected: /** * \brief append a crumb widget