diff --git a/app/generalconfigpage.ui b/app/generalconfigpage.ui --- a/app/generalconfigpage.ui +++ b/app/generalconfigpage.ui @@ -11,14 +11,14 @@ - + Background color: - + @@ -76,21 +76,21 @@ - - - - Videos: - - - Show videos + + + Wrap around after reaching the last image + + + + Qt::Vertical diff --git a/app/mainwindow.h b/app/mainwindow.h --- a/app/mainwindow.h +++ b/app/mainwindow.h @@ -126,9 +126,6 @@ void toggleMenuBar(); void toggleStatusBar(); - void showFirstDocumentReached(); - void showLastDocumentReached(); - private: struct Private; MainWindow::Private* const d; diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp --- a/app/mainwindow.cpp +++ b/app/mainwindow.cpp @@ -409,15 +409,13 @@ mGoToPreviousAction->setText(i18nc("@action Go to previous image", "Previous")); mGoToPreviousAction->setToolTip(i18nc("@info:tooltip", "Go to previous image")); actionCollection->setDefaultShortcut(mGoToPreviousAction, Qt::Key_Backspace); - installDisabledActionShortcutMonitor(mGoToPreviousAction, SLOT(showFirstDocumentReached())); mGoToNextAction = view->addAction("go_next", q, SLOT(goToNext())); mGoToNextAction->setPriority(QAction::LowPriority); mGoToNextAction->setIcon(QIcon::fromTheme("media-skip-forward")); mGoToNextAction->setText(i18nc("@action Go to next image", "Next")); mGoToNextAction->setToolTip(i18nc("@info:tooltip", "Go to next image")); actionCollection->setDefaultShortcut(mGoToNextAction, Qt::Key_Space); - installDisabledActionShortcutMonitor(mGoToNextAction, SLOT(showLastDocumentReached())); mGoToFirstAction = view->addAction("go_first", q, SLOT(goToFirst())); mGoToFirstAction->setPriority(QAction::LowPriority); @@ -1155,12 +1153,24 @@ void MainWindow::goToPrevious() { - d->goTo(-1); + QModelIndex currentIndex = d->mContextManager->selectionModel()->currentIndex(); + QModelIndex previousIndex = d->mDirModel->index(currentIndex.row() - 1, 0); + if (!previousIndex.isValid() && GwenviewConfig::wrap()) { + d->goToLastDocument(); + } else { + d->goTo(-1); + } } void MainWindow::goToNext() { - d->goTo(1); + QModelIndex currentIndex = d->mContextManager->selectionModel()->currentIndex(); + QModelIndex nextIndex = d->mDirModel->index(currentIndex.row() + 1, 0); + if (! nextIndex.isValid() && GwenviewConfig::wrap()) { + d->goToFirstDocument(); + } else { + d->goTo(1); + } } void MainWindow::goToFirst() @@ -1197,11 +1207,11 @@ int row = currentIndex.row(); QModelIndex prevIndex = d->mDirModel->index(row - 1, 0); QModelIndex nextIndex = d->mDirModel->index(row + 1, 0); - hasPrevious = prevIndex.isValid() && !d->indexIsDirOrArchive(prevIndex); - hasNext = nextIndex.isValid() && !d->indexIsDirOrArchive(nextIndex); + hasPrevious = GwenviewConfig::wrap() || (prevIndex.isValid() && !d->indexIsDirOrArchive(prevIndex)); + hasNext = GwenviewConfig::wrap() || (nextIndex.isValid() && !d->indexIsDirOrArchive(nextIndex)); } else { hasPrevious = false; - hasNext = false; + hasNext = false; } d->mGoToPreviousAction->setEnabled(hasPrevious); @@ -1577,32 +1587,4 @@ goToUrl(url); } -void MainWindow::showFirstDocumentReached() -{ - if (d->mCurrentMainPageId != ViewMainPageId) { - return; - } - HudButtonBox* dlg = new HudButtonBox; - dlg->setText(i18n("You reached the first document, what do you want to do?")); - dlg->addButton(i18n("Stay There")); - dlg->addAction(d->mGoToLastAction, i18n("Go to the Last Document")); - dlg->addAction(d->mBrowseAction, i18n("Go Back to the Document List")); - dlg->addCountDown(15000); - d->mViewMainPage->showMessageWidget(dlg, Qt::AlignCenter); -} - -void MainWindow::showLastDocumentReached() -{ - if (d->mCurrentMainPageId != ViewMainPageId) { - return; - } - HudButtonBox* dlg = new HudButtonBox; - dlg->setText(i18n("You reached the last document, what do you want to do?")); - dlg->addButton(i18n("Stay There")); - dlg->addAction(d->mGoToFirstAction, i18n("Go to the First Document")); - dlg->addAction(d->mBrowseAction, i18n("Go Back to the Document List")); - dlg->addCountDown(15000); - d->mViewMainPage->showMessageWidget(dlg, Qt::AlignCenter); -} - } // namespace diff --git a/lib/gwenviewconfig.kcfg b/lib/gwenviewconfig.kcfg --- a/lib/gwenviewconfig.kcfg +++ b/lib/gwenviewconfig.kcfg @@ -190,6 +190,10 @@ true + + + true +