mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-11 00:24:12 +02:00
When there isn't enough room to display all the crumbs, collapse from the left.
This commit is contained in:
@@ -26,6 +26,8 @@
|
|||||||
#include <QItemSelectionModel>
|
#include <QItemSelectionModel>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
|
#include <QResizeEvent>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
|
|
||||||
@@ -198,12 +200,30 @@ void BreadcrumbBar::updateButtons()
|
|||||||
}
|
}
|
||||||
m_navButtons.erase(itBegin, m_navButtons.end());
|
m_navButtons.erase(itBegin, m_navButtons.end());
|
||||||
|
|
||||||
foreach (BreadcrumbButtonBase *button, m_navButtons)
|
collapseButtons();
|
||||||
button->show();
|
|
||||||
|
|
||||||
adjustSize();
|
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()
|
void BreadcrumbBar::clearButtons()
|
||||||
{
|
{
|
||||||
foreach (BreadcrumbButtonBase *button, m_navButtons)
|
foreach (BreadcrumbButtonBase *button, m_navButtons)
|
||||||
@@ -287,3 +307,7 @@ void BreadcrumbBar::currentChangedTriggered(QModelIndex const& index)
|
|||||||
m_selectionModel->setCurrentIndex( index, QItemSelectionModel::SelectCurrent);
|
m_selectionModel->setCurrentIndex( index, QItemSelectionModel::SelectCurrent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BreadcrumbBar::resizeEvent ( QResizeEvent * event )
|
||||||
|
{
|
||||||
|
collapseButtons();
|
||||||
|
}
|
||||||
|
@@ -34,6 +34,7 @@ class QAbstractItemModel;
|
|||||||
class QAbstractProxyModel;
|
class QAbstractProxyModel;
|
||||||
class QHBoxLayout;
|
class QHBoxLayout;
|
||||||
class QItemSelectionModel;
|
class QItemSelectionModel;
|
||||||
|
class QResizeEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief A breadcrumb view for a QAbstractItemModel
|
* \brief A breadcrumb view for a QAbstractItemModel
|
||||||
@@ -144,6 +145,17 @@ protected:
|
|||||||
*/
|
*/
|
||||||
void deleteButton(BreadcrumbButtonBase *button);
|
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:
|
protected slots:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user