feat: option to disable gallery looping

This change is sponsored by @superuser7777

Related: https://github.com/BLumia/pineapple-pictures/issues/153
This commit is contained in:
2025-06-25 20:55:42 +08:00
parent 2bee79c064
commit b566096b1f
8 changed files with 62 additions and 12 deletions

View File

@ -196,7 +196,7 @@ QModelIndex PlaylistManager::previousIndex() const
int count = totalCount();
if (count == 0) return {};
return m_model.index(m_currentIndex - 1 < 0 ? count - 1 : m_currentIndex - 1);
return m_model.index(isFirstIndex() ? count - 1 : m_currentIndex - 1);
}
QModelIndex PlaylistManager::nextIndex() const
@ -204,7 +204,7 @@ QModelIndex PlaylistManager::nextIndex() const
int count = totalCount();
if (count == 0) return {};
return m_model.index(m_currentIndex + 1 == count ? 0 : m_currentIndex + 1);
return m_model.index(isLastIndex() ? 0 : m_currentIndex + 1);
}
QModelIndex PlaylistManager::curIndex() const
@ -212,6 +212,16 @@ QModelIndex PlaylistManager::curIndex() const
return m_model.index(m_currentIndex);
}
bool PlaylistManager::isFirstIndex() const
{
return m_currentIndex == 0;
}
bool PlaylistManager::isLastIndex() const
{
return m_currentIndex + 1 == totalCount();
}
void PlaylistManager::setCurrentIndex(const QModelIndex &index)
{
if (index.isValid() && index.row() >= 0 && index.row() < totalCount()) {