[rkward-cvs] SF.net SVN: rkward: [1589] trunk/rkward/rkward

tfry at users.sourceforge.net tfry at users.sourceforge.net
Thu Mar 15 19:38:27 UTC 2007


Revision: 1589
          http://svn.sourceforge.net/rkward/?rev=1589&view=rev
Author:   tfry
Date:     2007-03-15 12:38:27 -0700 (Thu, 15 Mar 2007)

Log Message:
-----------
Add window navigation actions left and right

Modified Paths:
--------------
    trunk/rkward/rkward/rkward.cpp
    trunk/rkward/rkward/rkwardui.rc
    trunk/rkward/rkward/windows/rkworkplace.cpp
    trunk/rkward/rkward/windows/rkworkplace.h
    trunk/rkward/rkward/windows/rkworkplaceview.cpp
    trunk/rkward/rkward/windows/rkworkplaceview.h

Modified: trunk/rkward/rkward/rkward.cpp
===================================================================
--- trunk/rkward/rkward/rkward.cpp	2007-03-15 19:05:18 UTC (rev 1588)
+++ trunk/rkward/rkward/rkward.cpp	2007-03-15 19:38:27 UTC (rev 1589)
@@ -114,7 +114,7 @@
 	QVBoxLayout *layout = new QVBoxLayout (dummy);
 	addWindow (dummy);
 	new RKWorkplace (dummy);
-	RKWorkplace::mainWorkplace ()->initActions (actionCollection (), "prev_window", "next_window");
+	RKWorkplace::mainWorkplace ()->initActions (actionCollection (), "prev_window", "next_window", "left_window", "right_window");
 	layout->addWidget (RKWorkplace::mainWorkplace ()->view ());
 	connect (RKWorkplace::mainWorkplace ()->view (), SIGNAL (captionChanged (const QString &)), this, SLOT (setCaption (const QString &)));
 

Modified: trunk/rkward/rkward/rkwardui.rc
===================================================================
--- trunk/rkward/rkward/rkwardui.rc	2007-03-15 19:05:18 UTC (rev 1588)
+++ trunk/rkward/rkward/rkwardui.rc	2007-03-15 19:38:27 UTC (rev 1589)
@@ -44,6 +44,9 @@
 			<Action name="prev_window"/>
 			<Action name="next_window"/>
 			<Separator/>
+			<Action name="left_window"/>
+			<Action name="right_window"/>
+			<Separator/>
 			<Action name="window_show_workspace"/>
 			<Action name="window_show_commandlog"/>
 			<Action name="window_show_pendingjobs"/>

Modified: trunk/rkward/rkward/windows/rkworkplace.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkworkplace.cpp	2007-03-15 19:05:18 UTC (rev 1588)
+++ trunk/rkward/rkward/windows/rkworkplace.cpp	2007-03-15 19:38:27 UTC (rev 1589)
@@ -63,10 +63,11 @@
 //	closeAll ();	// not needed, as the windows will autodelete themselves using QObject mechanism. Of course, closeAll () should be called *before* quitting.
 }
 
-void RKWorkplace::initActions (KActionCollection *ac, const char *prev_id, const char *next_id) {
+void RKWorkplace::initActions (KActionCollection *ac, const char *prev_id, const char *next_id, const char *left_id, const char *right_id) {
 	RK_TRACE (APP);
 
-	history->addActions (ac, prev_id, next_id);
+	history->initActions (ac, prev_id, next_id);
+	wview->initActions (ac, left_id, right_id);
 }
 
 void RKWorkplace::attachWindow (RKMDIWindow *window) {
@@ -417,7 +418,7 @@
 	RK_DO (qDebug ("Remaining windows in history: forward: %d, backward: %d", forward_list.count (), back_list.count ()), APP, DL_DEBUG);
 }
 
-void RKMDIWindowHistory::addActions (KActionCollection *ac, const char *prev_id, const char *next_id) {
+void RKMDIWindowHistory::initActions (KActionCollection *ac, const char *prev_id, const char *next_id) {
 	RK_TRACE (APP);
 
 	KShortcut prev_short ("Alt+<");
@@ -425,7 +426,7 @@
 	prev_action = new KAction (i18n ("Previous Window"), QIconSet (RKCommonFunctions::getRKWardDataDir () + "icons/window_back.png"), prev_short, this, SLOT (prev ()), ac, prev_id);
 
 	KShortcut next_short ("Alt+>");
-	next_short.append ("Alt+.");
+	next_short.append (KKey (Qt::ALT | Qt::Key_Period));
 	next_action = new KAction (i18n ("Next Window"), QIconSet (RKCommonFunctions::getRKWardDataDir () + "icons/window_forward.png"), next_short, this, SLOT (next ()), ac, next_id);
 	updateActions ();
 }

Modified: trunk/rkward/rkward/windows/rkworkplace.h
===================================================================
--- trunk/rkward/rkward/windows/rkworkplace.h	2007-03-15 19:05:18 UTC (rev 1588)
+++ trunk/rkward/rkward/windows/rkworkplace.h	2007-03-15 19:38:27 UTC (rev 1589)
@@ -41,7 +41,7 @@
 	RKMDIWindowHistory (QObject *parent);
 	~RKMDIWindowHistory ();
 
-	void addActions (KActionCollection *ac, const char *prev_id, const char *next_id);
+	void initActions (KActionCollection *ac, const char *prev_id, const char *next_id);
 	bool haveNext ();
 	bool havePrev ();
 public slots:
@@ -68,7 +68,7 @@
 @param parent: The parent widget for the workspace view (see view ()) */
 	explicit RKWorkplace (QWidget *parent);
 	~RKWorkplace ();
-	void initActions (KActionCollection *ac, const char *prev_id, const char *next_id);
+	void initActions (KActionCollection *ac, const char *prev_id, const char *next_id, const char *left_id, const char *right_id);
 
 /** @returns a pointer to the view of the workplace. Since possibly the workplace layout might change, better not rely on this pointer being valid for long */
 	RKWorkplaceView *view () { return wview; };

Modified: trunk/rkward/rkward/windows/rkworkplaceview.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkworkplaceview.cpp	2007-03-15 19:05:18 UTC (rev 1588)
+++ trunk/rkward/rkward/windows/rkworkplaceview.cpp	2007-03-15 19:38:27 UTC (rev 1589)
@@ -2,7 +2,7 @@
                           rkworkplaceview  -  description
                              -------------------
     begin                : Tue Sep 26 2006
-    copyright            : (C) 2006 by Thomas Friedrichsmeier
+    copyright            : (C) 2006, 2007 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -18,6 +18,7 @@
 #include "rkworkplaceview.h"
 
 #include <ktabbar.h>
+#include <klocale.h>
 
 #include <qwidgetstack.h>
 #include <qapplication.h>
@@ -49,6 +50,61 @@
 	RK_TRACE (APP);
 }
 
+void RKWorkplaceView::initActions (KActionCollection *ac, const char *id_left, const char *id_right) {
+	RK_TRACE (APP);
+
+	KShortcut left_short (KKey ("Ctrl+<"));
+	left_short.append (KKey (Qt::CTRL | Qt::Key_Comma));
+	action_page_left = new KAction (i18n ("Window Left"), 0, left_short, this, SLOT (pageLeft ()), ac, id_left);
+
+	KShortcut right_short (KKey ("Ctrl+>"));
+	right_short.append (KKey (Qt::CTRL | Qt::Key_Period));
+	action_page_right = new KAction (i18n ("Window Right"), 0, right_short, this, SLOT (pageRight ()), ac, id_right);
+
+	updateActions ();
+}
+
+void RKWorkplaceView::updateActions () {
+	RK_TRACE (APP);
+
+	int index = currentIndex ();
+	action_page_left->setEnabled (index > 0);
+	action_page_right->setEnabled (index < (tabs->count () - 1));
+}
+
+void RKWorkplaceView::pageLeft () {
+	RK_TRACE (APP);
+
+	int index = currentIndex ();
+	RK_ASSERT (index > 0);
+	setPageByIndex (index - 1);
+}
+
+void RKWorkplaceView::pageRight () {
+	RK_TRACE (APP);
+
+	int index = currentIndex ();
+	RK_ASSERT (index < (tabs->count () - 1));
+	setPageByIndex (index + 1);
+}
+
+int RKWorkplaceView::currentIndex () {
+	RK_TRACE (APP);
+	return (tabs->indexOf (tabs->currentTab ()));
+}
+
+void RKWorkplaceView::setPageByIndex (int index) {
+	RK_TRACE (APP);
+
+	QTab *new_tab = tabs->tabAt (index);
+	if (!new_tab) {
+		RK_ASSERT (false);
+		return;
+	}
+
+	setPage (new_tab->identifier ());
+}
+
 void RKWorkplaceView::addPage (RKMDIWindow *widget) {
 	RK_TRACE (APP);
 
@@ -80,7 +136,7 @@
 	RK_DO (if (id == -1) qDebug ("did not find page in RKWorkplaceView::removePage"), APP, DL_WARNING);
 	if (!destroyed) disconnect (widget, SIGNAL (captionChanged (RKMDIWindow *)), this, SLOT (childCaptionChanged (RKMDIWindow *)));
 
-	int oldindex = tabs->indexOf (tabs->currentTab ());	// which page will have to be activated later?
+	int oldindex = currentIndex ();	// which page will have to be activated later?
 	int oldcount = tabs->count ();
 	QTab *new_tab = tabs->tabAt (oldindex);
 	if (widget == activePage ()) {
@@ -161,6 +217,7 @@
 
 	emit (pageChanged (window));
 	setCaption (window->shortCaption ());
+	updateActions ();
 }
 
 void RKWorkplaceView::childCaptionChanged (RKMDIWindow *widget) {

Modified: trunk/rkward/rkward/windows/rkworkplaceview.h
===================================================================
--- trunk/rkward/rkward/windows/rkworkplaceview.h	2007-03-15 19:05:18 UTC (rev 1588)
+++ trunk/rkward/rkward/windows/rkworkplaceview.h	2007-03-15 19:38:27 UTC (rev 1589)
@@ -2,7 +2,7 @@
                           rkworkplaceview  -  description
                              -------------------
     begin                : Tue Sep 26 2006
-    copyright            : (C) 2006 by Thomas Friedrichsmeier
+    copyright            : (C) 2006, 2007 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -24,6 +24,8 @@
 class KTabBar;
 class QWidgetStack;
 class RKMDIWindow;
+class KAction;
+class KActionCollection;
 
 /** The widget containing all the MDI document windows. Right now it mostly acts as a QTabWidget (is not one, as unfortunately, QTabWidget always has a sunken frame), but might be extended to allow switching between different view modes */
 class RKWorkplaceView : public QWidget {
@@ -49,6 +51,8 @@
 	QString activeCaption ();
 /** reimplemented form QWidget::setCaption () to emit captionChanged () when the caption changes */
 	void setCaption (const QString &caption);
+/** initialize the window left/right actions */
+	void initActions (KActionCollection *ac, const char *id_left, const char *id_right);
 signals:
 /** a new page / window was activated
 @param widget the newly activated window */
@@ -62,7 +66,17 @@
 /** called when the caption of a window changes. Updates the tab-label, and - if appropriate - the caption of this widget */
 	void childCaptionChanged (RKMDIWindow *widget);
 	void closePage (int index);
+/** Active the page left of the current tab */
+	void pageLeft ();
+/** Active the page right of the current tab */
+	void pageRight ();
 private:
+	void updateActions ();
+/** Index of current tab (might be negative, if there are no tabs! */
+	int currentIndex ();
+	void setPageByIndex (int index);
+	KAction *action_page_left;
+	KAction *action_page_right;
 	KTabBar *tabs;
 	QWidgetStack *widgets;
 	typedef QMap<int, RKMDIWindow*> PageMap;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list