mirror of
https://github.com/UltimMC/Launcher.git
synced 2025-12-23 04:00:06 +00:00
Add instance view up/down keyboard navigation, fix some layout glitches (not all)
This commit is contained in:
@@ -115,6 +115,7 @@ KCategorizedView::Private::Private ( KCategorizedView *q )
|
||||
, hoveredIndex ( QModelIndex() )
|
||||
, pressedPosition ( QPoint() )
|
||||
, rubberBandRect ( QRect() )
|
||||
, constantItemWidth( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -447,7 +448,7 @@ void KCategorizedView::Private::leftToRightVisualRect ( const QModelIndex &index
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( q->uniformItemSizes() )
|
||||
if ( q->uniformItemSizes() /*|| q->uniformItemWidths()*/ )
|
||||
{
|
||||
const int relativeRow = index.row() - firstIndexRow;
|
||||
const QSize itemSize = q->sizeHintForIndex ( index );
|
||||
@@ -622,6 +623,18 @@ void KCategorizedView::setModel ( QAbstractItemModel *model )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void KCategorizedView::setUniformItemWidths(bool enable)
|
||||
{
|
||||
d->constantItemWidth = enable;
|
||||
}
|
||||
|
||||
|
||||
bool KCategorizedView::uniformItemWidths() const
|
||||
{
|
||||
return d->constantItemWidth;
|
||||
}
|
||||
|
||||
void KCategorizedView::setGridSize ( const QSize &size )
|
||||
{
|
||||
setGridSizeOwn ( size );
|
||||
@@ -1294,13 +1307,13 @@ QModelIndex KCategorizedView::moveCursor ( CursorAction cursorAction,
|
||||
}
|
||||
case MoveDown:
|
||||
{
|
||||
if ( d->hasGrid() || uniformItemSizes() )
|
||||
if ( d->hasGrid() || uniformItemSizes() || uniformItemWidths() )
|
||||
{
|
||||
const QModelIndex current = currentIndex();
|
||||
const QSize itemSize = d->hasGrid() ? gridSize()
|
||||
: sizeHintForIndex ( current );
|
||||
const Private::Block &block = d->blocks[d->categoryForIndex ( current )];
|
||||
const int maxItemsPerRow = qMax ( d->viewportWidth() / itemSize.width(), 1 );
|
||||
const int maxItemsPerRow = qMax ( ( d->viewportWidth() - spacing() ) / ( itemSize.width() + spacing() ), 1 );
|
||||
const bool canMove = current.row() + maxItemsPerRow < block.firstIndex.row() +
|
||||
block.items.count();
|
||||
|
||||
@@ -1334,13 +1347,13 @@ QModelIndex KCategorizedView::moveCursor ( CursorAction cursorAction,
|
||||
}
|
||||
case MoveUp:
|
||||
{
|
||||
if ( d->hasGrid() || uniformItemSizes() )
|
||||
if ( d->hasGrid() || uniformItemSizes() || uniformItemWidths() )
|
||||
{
|
||||
const QModelIndex current = currentIndex();
|
||||
const QSize itemSize = d->hasGrid() ? gridSize()
|
||||
: sizeHintForIndex ( current );
|
||||
const Private::Block &block = d->blocks[d->categoryForIndex ( current )];
|
||||
const int maxItemsPerRow = qMax ( d->viewportWidth() / itemSize.width(), 1 );
|
||||
const int maxItemsPerRow = qMax ( ( d->viewportWidth() - spacing() ) / ( itemSize.width() + spacing() ), 1 );
|
||||
const bool canMove = current.row() - maxItemsPerRow >= block.firstIndex.row();
|
||||
|
||||
if ( canMove )
|
||||
|
||||
Reference in New Issue
Block a user