[Kst] extragear/graphics/kst/kst

Andrew Walker arwalker at sumusltd.com
Wed Aug 10 20:52:36 CEST 2005


SVN commit 445245 by arwalker:

Clean up toggleMouseMode

 M  +51 -39    kst.cpp  


--- trunk/extragear/graphics/kst/kst/kst.cpp #445244:445245
@@ -37,6 +37,7 @@
 #include <kstandarddirs.h>
 #include <kstatusbar.h>
 #include <ktabwidget.h>
+#include <ktoolbarbutton.h>
 #include <qdatetime.h>
 
 // application specific includes
@@ -168,8 +169,8 @@
 
   initActions();
   readOptions();
+  XYZoomAction->setChecked(true);
   toggleMouseMode();
-  XYZoomAction->setChecked(true);
 
   fixKMdi();
 
@@ -772,17 +773,15 @@
   LayoutAction->setToolTip(i18n("Layout mode"));
   LayoutAction->setWhatsThis(i18n("Use this mode to move, resize, and group plots."));
   
-  
   // this is the mouse mode menu
   QPopupMenu* mouseModeMenu = new QPopupMenu();
   
   XYZoomAction->plug(mouseModeMenu);
   XZoomAction->plug(mouseModeMenu);
   YZoomAction->plug(mouseModeMenu);
-  
   mouseModeMenu->insertSeparator();
-  
   LayoutAction->plug(mouseModeMenu);
+  mouseModeMenu->insertSeparator();
   _gfxLabelAction->plug(mouseModeMenu);
   _gfxRectangleAction->plug(mouseModeMenu);
   _gfxLineAction->plug(mouseModeMenu);
@@ -790,8 +789,9 @@
   _gfxArrowAction->plug(mouseModeMenu);
   _gfxEllipseAction->plug(mouseModeMenu);
 
-  toolBar()->insertButton("thumbnail", 5, mouseModeMenu, true, "blah");
-
+  toolBar()->insertButton("thumbnail", 5, mouseModeMenu, true, i18n("Select the desired mode"));
+  toggleMouseMode();
+  
   createGUI(0L);
 }
 
@@ -1693,44 +1693,56 @@
 
 
 void KstApp::toggleMouseMode() {
+  KstTopLevelView::ViewMode mode = KstTopLevelView::DisplayMode;
+  KAction* action = NULL;
+  
+  if (_gfxLineAction->isChecked()) {
+    action = _gfxLineAction;
+    mode = KstTopLevelView::GfxLineMode;
+  } else if (_gfxRectangleAction->isChecked()) {
+    action = _gfxRectangleAction;
+    mode = KstTopLevelView::GfxRectangleMode;
+  } else if (_gfxEllipseAction->isChecked()) {
+    action = _gfxEllipseAction;
+    mode = KstTopLevelView::GfxEllipseMode;
+  } else if (_gfxLabelAction->isChecked()) {
+    action = _gfxLabelAction;
+    mode = KstTopLevelView::GfxTextMode;
+  } else if (_gfxPictureAction->isChecked()) {
+    action = _gfxPictureAction;
+    mode = KstTopLevelView::GfxPictureMode;
+  } else if (_gfxArrowAction->isChecked()) {
+    action = _gfxArrowAction;
+    mode = KstTopLevelView::GfxArrowMode;
+  } else if (LayoutAction->isChecked()) {
+    action = LayoutAction;
+    mode = KstTopLevelView::LayoutMode;
+  } else if (XYZoomAction->isChecked()) {
+    action = XYZoomAction;
+    mode = KstTopLevelView::DisplayMode;
+  } else if (XZoomAction->isChecked()) {
+    action = XZoomAction;
+    mode = KstTopLevelView::DisplayMode;
+  } else if (YZoomAction->isChecked()) {
+    action = YZoomAction;
+    mode = KstTopLevelView::DisplayMode;
+  }
+  
+  if (action) {
+    KToolBarButton* button = toolBar()->getButton(5);
+    
+    if (button) {
+      button->setText(action->toolTip());
+      button->setIcon(action->icon());
+    }
+  } 
+  
   KMdiIterator<KMdiChildView*> *it = createIterator();
   if (it) {
     while (it->currentItem()) {
       KstViewWindow *pView = dynamic_cast<KstViewWindow*>(it->currentItem());
       if (pView) {
-        if (_gfxLineAction->isChecked()) {
-          pView->view()->setViewMode(KstTopLevelView::GfxLineMode);
-          toolBar()->setButtonIcon(5, "kst_gfx_line");
-        } else if (_gfxRectangleAction->isChecked()) {
-          pView->view()->setViewMode(KstTopLevelView::GfxRectangleMode);
-          toolBar()->setButtonIcon(5, "kst_gfx_rectangle");
-        } else if (_gfxEllipseAction->isChecked()) {
-          pView->view()->setViewMode(KstTopLevelView::GfxEllipseMode);
-          toolBar()->setButtonIcon(5, "kst_gfx_ellipse");
-        } else if (_gfxLabelAction->isChecked()) {
-          pView->view()->setViewMode(KstTopLevelView::GfxTextMode);
-          toolBar()->setButtonIcon(5, "text");
-        } else if (_gfxPictureAction->isChecked()) {
-          pView->view()->setViewMode(KstTopLevelView::GfxPictureMode);  
-          toolBar()->setButtonIcon(5, "kst_gfx_picture");
-        } else if (_gfxArrowAction->isChecked()) {
-          pView->view()->setViewMode(KstTopLevelView::GfxArrowMode);  
-          toolBar()->setButtonIcon(5, "kst_gfx_arrow");
-        } else if (LayoutAction->isChecked()) {
-          pView->view()->setViewMode(KstTopLevelView::LayoutMode); 
-          toolBar()->setButtonIcon(5, "kst_layoutmode"); 
-        } else if (XYZoomAction->isChecked()) {
-          pView->view()->setViewMode(KstTopLevelView::DisplayMode);  
-          toolBar()->setButtonIcon(5, "kst_zoomxy");
-        } else if (XZoomAction->isChecked()) {
-          pView->view()->setViewMode(KstTopLevelView::DisplayMode);
-          toolBar()->setButtonIcon(5, "kst_zoomx");  
-        } else if (YZoomAction->isChecked()) {
-          pView->view()->setViewMode(KstTopLevelView::DisplayMode);
-          toolBar()->setButtonIcon(5, "kst_zoomy");
-        } else {
-          pView->view()->setViewMode(KstTopLevelView::DisplayMode);  
-        }
+        pView->view()->setViewMode(mode);  
       }
       it->next();
     }


More information about the Kst mailing list