Changeset View
Changeset View
Standalone View
Standalone View
app/mainwindow.cpp
Show First 20 Lines • Show All 403 Lines • ▼ Show 20 Line(s) | 354 | { | |||
---|---|---|---|---|---|
404 | leaveFullScreenAction->setText(i18nc("@action", "Leave Fullscreen Mode")); | 404 | leaveFullScreenAction->setText(i18nc("@action", "Leave Fullscreen Mode")); | ||
405 | 405 | | |||
406 | mGoToPreviousAction = view->addAction("go_previous", q, SLOT(goToPrevious())); | 406 | mGoToPreviousAction = view->addAction("go_previous", q, SLOT(goToPrevious())); | ||
407 | mGoToPreviousAction->setPriority(QAction::LowPriority); | 407 | mGoToPreviousAction->setPriority(QAction::LowPriority); | ||
408 | mGoToPreviousAction->setIcon(QIcon::fromTheme("media-skip-backward")); | 408 | mGoToPreviousAction->setIcon(QIcon::fromTheme("media-skip-backward")); | ||
409 | mGoToPreviousAction->setText(i18nc("@action Go to previous image", "Previous")); | 409 | mGoToPreviousAction->setText(i18nc("@action Go to previous image", "Previous")); | ||
410 | mGoToPreviousAction->setToolTip(i18nc("@info:tooltip", "Go to previous image")); | 410 | mGoToPreviousAction->setToolTip(i18nc("@info:tooltip", "Go to previous image")); | ||
411 | actionCollection->setDefaultShortcut(mGoToPreviousAction, Qt::Key_Backspace); | 411 | actionCollection->setDefaultShortcut(mGoToPreviousAction, Qt::Key_Backspace); | ||
412 | installDisabledActionShortcutMonitor(mGoToPreviousAction, SLOT(showFirstDocumentReached())); | | |||
413 | 412 | | |||
414 | mGoToNextAction = view->addAction("go_next", q, SLOT(goToNext())); | 413 | mGoToNextAction = view->addAction("go_next", q, SLOT(goToNext())); | ||
415 | mGoToNextAction->setPriority(QAction::LowPriority); | 414 | mGoToNextAction->setPriority(QAction::LowPriority); | ||
416 | mGoToNextAction->setIcon(QIcon::fromTheme("media-skip-forward")); | 415 | mGoToNextAction->setIcon(QIcon::fromTheme("media-skip-forward")); | ||
417 | mGoToNextAction->setText(i18nc("@action Go to next image", "Next")); | 416 | mGoToNextAction->setText(i18nc("@action Go to next image", "Next")); | ||
418 | mGoToNextAction->setToolTip(i18nc("@info:tooltip", "Go to next image")); | 417 | mGoToNextAction->setToolTip(i18nc("@info:tooltip", "Go to next image")); | ||
419 | actionCollection->setDefaultShortcut(mGoToNextAction, Qt::Key_Space); | 418 | actionCollection->setDefaultShortcut(mGoToNextAction, Qt::Key_Space); | ||
420 | installDisabledActionShortcutMonitor(mGoToNextAction, SLOT(showLastDocumentReached())); | | |||
421 | 419 | | |||
422 | mGoToFirstAction = view->addAction("go_first", q, SLOT(goToFirst())); | 420 | mGoToFirstAction = view->addAction("go_first", q, SLOT(goToFirst())); | ||
423 | mGoToFirstAction->setPriority(QAction::LowPriority); | 421 | mGoToFirstAction->setPriority(QAction::LowPriority); | ||
424 | mGoToFirstAction->setText(i18nc("@action Go to first image", "First")); | 422 | mGoToFirstAction->setText(i18nc("@action Go to first image", "First")); | ||
425 | mGoToFirstAction->setToolTip(i18nc("@info:tooltip", "Go to first image")); | 423 | mGoToFirstAction->setToolTip(i18nc("@info:tooltip", "Go to first image")); | ||
426 | actionCollection->setDefaultShortcut(mGoToFirstAction, Qt::Key_Home); | 424 | actionCollection->setDefaultShortcut(mGoToFirstAction, Qt::Key_Home); | ||
427 | 425 | | |||
428 | mGoToLastAction = view->addAction("go_last", q, SLOT(goToLast())); | 426 | mGoToLastAction = view->addAction("go_last", q, SLOT(goToLast())); | ||
▲ Show 20 Lines • Show All 721 Lines • ▼ Show 20 Line(s) | 1147 | if (d->mContextManager->selectionModel()->hasSelection()) { | |||
1150 | updatePreviousNextActions(); | 1148 | updatePreviousNextActions(); | ||
1151 | } | 1149 | } | ||
1152 | d->mThumbnailView->scrollToSelectedIndex(); | 1150 | d->mThumbnailView->scrollToSelectedIndex(); | ||
1153 | d->mViewMainPage->thumbnailBar()->scrollToSelectedIndex(); | 1151 | d->mViewMainPage->thumbnailBar()->scrollToSelectedIndex(); | ||
1154 | } | 1152 | } | ||
1155 | 1153 | | |||
1156 | void MainWindow::goToPrevious() | 1154 | void MainWindow::goToPrevious() | ||
1157 | { | 1155 | { | ||
1156 | QModelIndex currentIndex = d->mContextManager->selectionModel()->currentIndex(); | ||||
1157 | QModelIndex previousIndex = d->mDirModel->index(currentIndex.row() - 1, 0); | ||||
1158 | if (!previousIndex.isValid() && GwenviewConfig::wrap()) { | ||||
1159 | d->goToLastDocument(); | ||||
1160 | } else { | ||||
1158 | d->goTo(-1); | 1161 | d->goTo(-1); | ||
1159 | } | 1162 | } | ||
1163 | } | ||||
1160 | 1164 | | |||
1161 | void MainWindow::goToNext() | 1165 | void MainWindow::goToNext() | ||
1162 | { | 1166 | { | ||
1167 | QModelIndex currentIndex = d->mContextManager->selectionModel()->currentIndex(); | ||||
1168 | QModelIndex nextIndex = d->mDirModel->index(currentIndex.row() + 1, 0); | ||||
1169 | if (! nextIndex.isValid() && GwenviewConfig::wrap()) { | ||||
1170 | d->goToFirstDocument(); | ||||
1171 | } else { | ||||
1163 | d->goTo(1); | 1172 | d->goTo(1); | ||
1164 | } | 1173 | } | ||
1174 | } | ||||
1165 | 1175 | | |||
1166 | void MainWindow::goToFirst() | 1176 | void MainWindow::goToFirst() | ||
1167 | { | 1177 | { | ||
1168 | d->goToFirstDocument(); | 1178 | d->goToFirstDocument(); | ||
1169 | } | 1179 | } | ||
1170 | 1180 | | |||
1171 | void MainWindow::goToLast() | 1181 | void MainWindow::goToLast() | ||
1172 | { | 1182 | { | ||
Show All 19 Lines | |||||
1192 | { | 1202 | { | ||
1193 | bool hasPrevious; | 1203 | bool hasPrevious; | ||
1194 | bool hasNext; | 1204 | bool hasNext; | ||
1195 | QModelIndex currentIndex = d->mContextManager->selectionModel()->currentIndex(); | 1205 | QModelIndex currentIndex = d->mContextManager->selectionModel()->currentIndex(); | ||
1196 | if (currentIndex.isValid() && !d->indexIsDirOrArchive(currentIndex)) { | 1206 | if (currentIndex.isValid() && !d->indexIsDirOrArchive(currentIndex)) { | ||
1197 | int row = currentIndex.row(); | 1207 | int row = currentIndex.row(); | ||
1198 | QModelIndex prevIndex = d->mDirModel->index(row - 1, 0); | 1208 | QModelIndex prevIndex = d->mDirModel->index(row - 1, 0); | ||
1199 | QModelIndex nextIndex = d->mDirModel->index(row + 1, 0); | 1209 | QModelIndex nextIndex = d->mDirModel->index(row + 1, 0); | ||
1200 | hasPrevious = prevIndex.isValid() && !d->indexIsDirOrArchive(prevIndex); | 1210 | hasPrevious = GwenviewConfig::wrap() || (prevIndex.isValid() && !d->indexIsDirOrArchive(prevIndex)); | ||
1201 | hasNext = nextIndex.isValid() && !d->indexIsDirOrArchive(nextIndex); | 1211 | hasNext = GwenviewConfig::wrap() || (nextIndex.isValid() && !d->indexIsDirOrArchive(nextIndex)); | ||
1202 | } else { | 1212 | } else { | ||
1203 | hasPrevious = false; | 1213 | hasPrevious = false; | ||
1204 | hasNext = false; | 1214 | hasNext = false; | ||
1205 | } | 1215 | } | ||
1206 | 1216 | | |||
1207 | d->mGoToPreviousAction->setEnabled(hasPrevious); | 1217 | d->mGoToPreviousAction->setEnabled(hasPrevious); | ||
1208 | d->mGoToNextAction->setEnabled(hasNext); | 1218 | d->mGoToNextAction->setEnabled(hasNext); | ||
1209 | d->mGoToFirstAction->setEnabled(hasPrevious); | 1219 | d->mGoToFirstAction->setEnabled(hasPrevious); | ||
1210 | d->mGoToLastAction->setEnabled(hasNext); | 1220 | d->mGoToLastAction->setEnabled(hasNext); | ||
1211 | } | 1221 | } | ||
1212 | 1222 | | |||
▲ Show 20 Lines • Show All 359 Lines • ▼ Show 20 Line(s) | 1572 | { | |||
1572 | QUrl url = group.readEntry(SESSION_URL_KEY, QUrl()); | 1582 | QUrl url = group.readEntry(SESSION_URL_KEY, QUrl()); | ||
1573 | if (!url.isValid()) { | 1583 | if (!url.isValid()) { | ||
1574 | qWarning() << "Invalid url!"; | 1584 | qWarning() << "Invalid url!"; | ||
1575 | return; | 1585 | return; | ||
1576 | } | 1586 | } | ||
1577 | goToUrl(url); | 1587 | goToUrl(url); | ||
1578 | } | 1588 | } | ||
1579 | 1589 | | |||
1580 | void MainWindow::showFirstDocumentReached() | | |||
1581 | { | | |||
1582 | if (d->mCurrentMainPageId != ViewMainPageId) { | | |||
1583 | return; | | |||
1584 | } | | |||
1585 | HudButtonBox* dlg = new HudButtonBox; | | |||
1586 | dlg->setText(i18n("You reached the first document, what do you want to do?")); | | |||
1587 | dlg->addButton(i18n("Stay There")); | | |||
1588 | dlg->addAction(d->mGoToLastAction, i18n("Go to the Last Document")); | | |||
1589 | dlg->addAction(d->mBrowseAction, i18n("Go Back to the Document List")); | | |||
1590 | dlg->addCountDown(15000); | | |||
1591 | d->mViewMainPage->showMessageWidget(dlg, Qt::AlignCenter); | | |||
1592 | } | | |||
1593 | | ||||
1594 | void MainWindow::showLastDocumentReached() | | |||
1595 | { | | |||
1596 | if (d->mCurrentMainPageId != ViewMainPageId) { | | |||
1597 | return; | | |||
1598 | } | | |||
1599 | HudButtonBox* dlg = new HudButtonBox; | | |||
1600 | dlg->setText(i18n("You reached the last document, what do you want to do?")); | | |||
1601 | dlg->addButton(i18n("Stay There")); | | |||
1602 | dlg->addAction(d->mGoToFirstAction, i18n("Go to the First Document")); | | |||
1603 | dlg->addAction(d->mBrowseAction, i18n("Go Back to the Document List")); | | |||
1604 | dlg->addCountDown(15000); | | |||
1605 | d->mViewMainPage->showMessageWidget(dlg, Qt::AlignCenter); | | |||
1606 | } | | |||
1607 | | ||||
1608 | } // namespace | 1590 | } // namespace |