mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-19 23:39:42 +01:00
When there isn't enough room to display all the crumbs, collapse from the left.
This commit is contained in:
parent
aeaf569eb1
commit
c79985ad86
@ -26,6 +26,8 @@
|
||||
#include <QItemSelectionModel>
|
||||
#include <QLabel>
|
||||
#include <QPropertyAnimation>
|
||||
#include <QResizeEvent>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "utils/logger.h"
|
||||
|
||||
@ -198,12 +200,30 @@ void BreadcrumbBar::updateButtons()
|
||||
}
|
||||
m_navButtons.erase(itBegin, m_navButtons.end());
|
||||
|
||||
foreach (BreadcrumbButtonBase *button, m_navButtons)
|
||||
button->show();
|
||||
collapseButtons();
|
||||
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
void BreadcrumbBar::collapseButtons()
|
||||
{
|
||||
foreach (BreadcrumbButtonBase *button, m_navButtons) {
|
||||
button->show();
|
||||
}
|
||||
|
||||
const int desired_width = size().width();
|
||||
int current_width = sizeHint().width();
|
||||
|
||||
QLinkedList<BreadcrumbButtonBase*>::iterator it = m_navButtons.begin();
|
||||
QLinkedList<BreadcrumbButtonBase*>::const_iterator const itEnd = m_navButtons.end();
|
||||
it = m_navButtons.begin();
|
||||
while( current_width > desired_width && it != itEnd ) {
|
||||
(*it)->hide();
|
||||
++it;
|
||||
current_width = sizeHint().width();
|
||||
}
|
||||
}
|
||||
|
||||
void BreadcrumbBar::clearButtons()
|
||||
{
|
||||
foreach (BreadcrumbButtonBase *button, m_navButtons)
|
||||
@ -287,3 +307,7 @@ void BreadcrumbBar::currentChangedTriggered(QModelIndex const& index)
|
||||
m_selectionModel->setCurrentIndex( index, QItemSelectionModel::SelectCurrent);
|
||||
}
|
||||
|
||||
void BreadcrumbBar::resizeEvent ( QResizeEvent * event )
|
||||
{
|
||||
collapseButtons();
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ class QAbstractItemModel;
|
||||
class QAbstractProxyModel;
|
||||
class QHBoxLayout;
|
||||
class QItemSelectionModel;
|
||||
class QResizeEvent;
|
||||
|
||||
/**
|
||||
* \brief A breadcrumb view for a QAbstractItemModel
|
||||
@ -144,6 +145,17 @@ protected:
|
||||
*/
|
||||
void deleteButton(BreadcrumbButtonBase *button);
|
||||
|
||||
/**
|
||||
* \brief collapses crumbs when there isnt enough room for all of them
|
||||
* Starts hiding from the left until we can fit all the buttons.
|
||||
*/
|
||||
void collapseButtons();
|
||||
/**
|
||||
* \brief reimpl from QWidget
|
||||
*/
|
||||
void resizeEvent ( QResizeEvent * event );
|
||||
|
||||
|
||||
protected slots:
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user