[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdegraphics/gwenview
From:       Aurélien Gâteau <agateau () kde ! org>
Date:       2010-08-17 21:28:45
Message-ID: 20100817212846.04A21AC857 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1164890 by gateau:

New actions to go to first and last document

Initial patch by Ivan Wagner <wagner17@mandalore.com>

BUG:174619

 M  +5 -0      NEWS  
 M  +3 -1      app/gwenviewui.rc  
 M  +36 -4     app/mainwindow.cpp  
 M  +2 -0      app/mainwindow.h  


--- trunk/KDE/kdegraphics/gwenview/NEWS #1164889:1164890
@@ -1,3 +1,8 @@
+# 2.6.0
+## Improvements
+- New shortcuts to go to first and last image (bug #174619), original patch by
+  Ivan Wagner.
+
 # 2.5.0
 ## Improvements
 - Gwenview no longer blocks the UI when modifying or saving images.
--- trunk/KDE/kdegraphics/gwenview/app/gwenviewui.rc #1164889:1164890
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
-<kpartgui name="gwenview" version="50">
+<kpartgui name="gwenview" version="51">
 
 <MenuBar>
 	<Menu name="file" >
@@ -72,8 +72,10 @@
 		<Action name="red_eye_reduction" />
 	</Menu>
 	<Menu name="go" >
+		<Action name="go_first"/>
 		<Action name="go_previous"/>
 		<Action name="go_next"/>
+		<Action name="go_last"/>
 		<Separator/>
 		<Action name="go_up"/>
 		<Separator/>
--- trunk/KDE/kdegraphics/gwenview/app/mainwindow.cpp #1164889:1164890
@@ -171,6 +171,8 @@
 	KAction* mGoUpAction;
 	KAction* mGoToPreviousAction;
 	KAction* mGoToNextAction;
+	KAction* mGoToFirstAction;
+	KAction* mGoToLastAction;
 	KToggleAction* mToggleSideBarAction;
 	KToggleFullScreenAction* mFullScreenAction;
 	KAction* mToggleSlideShowAction;
@@ -359,7 +361,16 @@
 		mGoToNextAction->setToolTip(i18n("Go to Next Image"));
 		mGoToNextAction->setShortcut(Qt::Key_Space);
 
+		mGoToFirstAction = view->addAction("go_first",mWindow, SLOT(goToFirst()));
+		mGoToFirstAction->setText(i18nc("@action Go to first image", "First"));
+		mGoToFirstAction->setToolTip(i18n("Go to First Image"));
+		mGoToFirstAction->setShortcut(Qt::Key_Home);
 
+		mGoToLastAction = view->addAction("go_last",mWindow, SLOT(goToLast()));
+		mGoToLastAction->setText(i18nc("@action Go to last image", "Last"));
+		mGoToLastAction->setToolTip(i18n("Go to Last Image"));
+		mGoToLastAction->setShortcut(Qt::Key_End);
+
 		mGoUpAction = view->addAction(KStandardAction::Up,mWindow, SLOT(goUp()));
 
 		action = view->addAction("go_start_page",mWindow, SLOT(showStartPage()));
@@ -515,6 +526,15 @@
 		return ArchiveUtils::fileItemIsDirOrArchive(item);
 	}
 
+	void goTo(const QModelIndex& index) {
+		if (!index.isValid()) {
+			return;
+		}
+		mThumbnailView->setCurrentIndex(index);
+		mThumbnailView->scrollTo(index);
+	}
+
+
 	void goTo(int offset) {
 		QModelIndex index = currentIndex();
 		index = mDirModel->index(index.row() + offset, 0);
@@ -522,8 +542,7 @@
 			return;
 		}
 		if (!indexIsDirOrArchive(index)) {
-			mThumbnailView->setCurrentIndex(index);
-			mThumbnailView->scrollTo(index);
+			goTo(index);
 		}
 	}
 
@@ -539,10 +558,14 @@
 				break;
 			}
 		}
-		Q_ASSERT(index.isValid());
-		mThumbnailView->setCurrentIndex(index);
+		goTo(index);
 	}
 
+	void goToLastDocument() {
+		QModelIndex index = mDirModel->index(mDirModel->rowCount() - 1, 0);
+		goTo(index);
+	}
+
 	void spreadCurrentDirUrl(const KUrl& url) {
 		mContextManager->setCurrentDirUrl(url);
 		mThumbnailViewHelper->setCurrentDirUrl(url);
@@ -1151,7 +1174,14 @@
 	d->goTo(1);
 }
 
+void MainWindow::goToFirst() {
+	d->goToFirstDocument();
+}
 
+void MainWindow::goToLast() {
+	d->goToLastDocument();
+}
+
 void MainWindow::goToUrl(const KUrl& url) {
 	if (d->mCurrentPageId == ViewPageId) {
 		openDocumentUrl(url);
@@ -1172,9 +1202,11 @@
 
 	QModelIndex prevIndex = d->mDirModel->index(index.row() - 1, 0);
 	d->mGoToPreviousAction->setEnabled(prevIndex.isValid() && !d->indexIsDirOrArchive(prevIndex));
+	d->mGoToFirstAction->setEnabled(d->mGoToPreviousAction->isEnabled());
 
 	QModelIndex nextIndex = d->mDirModel->index(index.row() + 1, 0);
 	d->mGoToNextAction->setEnabled(nextIndex.isValid() && !d->indexIsDirOrArchive(nextIndex));
+	d->mGoToLastAction->setEnabled(d->mGoToNextAction->isEnabled());
 }
 
 
--- trunk/KDE/kdegraphics/gwenview/app/mainwindow.h #1164889:1164890
@@ -125,6 +125,8 @@
 
 	void goToPrevious();
 	void goToNext();
+	void goToFirst();
+	void goToLast();
 	void updatePreviousNextActions();
 
 	void reduceLevelOfDetails();
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic