[Uml-devel] KDE/kdesdk/umbrello/umbrello

Emmanuel Lepage Vallee elv1313 at gmail.com
Fri Jun 24 23:26:58 UTC 2011


SVN commit 1238262 by lepagevalleeemmanuel:

Remove the old buggy zoom slider with a better statusbar widget


 M  +1 -1      CMakeLists.txt  
 D             kplayerslideraction.cpp  
 D             kplayerslideraction.h  
 M  +0 -2      umbrelloui.rc  
 M  +80 -16    uml.cpp  
 M  +15 -2     uml.h  
 A             widgets/statusbartoolbutton.cpp   [License: GPL (v2+)]
 A             widgets/statusbartoolbutton.h   [License: GPL (v2+)]


--- trunk/KDE/kdesdk/umbrello/umbrello/CMakeLists.txt #1238261:1238262
@@ -349,6 +349,7 @@
     widgets/widget_factory.cpp
     widgets/widget_utils.cpp
     widgets/widgetbase.cpp
+    widgets/statusbartoolbutton.cpp
 )
 
 set (libcontroller_SRCS
@@ -385,7 +386,6 @@
     foreignkeyconstraint.cpp
     icon_utils.cpp
     import_rose.cpp
-    kplayerslideraction.cpp
     linepath.cpp
     listpopupmenu.cpp
     main.cpp
--- trunk/KDE/kdesdk/umbrello/umbrello/umbrelloui.rc #1238261:1238262
@@ -80,7 +80,5 @@
   </Menu>
 </MenuBar>
 <ToolBar name="mainToolBar" fullWidth="true" newline="true">
-  <Action name="popup_zoom"/>
-  <Action name="zoom100"/>
 </ToolBar>
 </kpartgui>
--- trunk/KDE/kdesdk/umbrello/umbrello/uml.cpp #1238261:1238262
@@ -18,12 +18,12 @@
 #include "worktoolbar.h"
 #include "umlviewimageexporter.h"
 #include "umlviewimageexporterall.h"
-#include "kplayerslideraction.h"
 #include "docwindow.h"
 #include "optionstate.h"
 #include "cmdlineexportallviewsevent.h"
 #include "cmds.h"
 #include "umbrellosettings.h"
+#include "statusbartoolbutton.h"
 // code generation
 #include "codegenerator.h"
 #include "codegenerationpolicy.h"
@@ -64,7 +64,6 @@
 #include <kmenubar.h>
 #include <kmessagebox.h>
 #include <kstandarddirs.h>
-#include <kstatusbar.h>
 #include <ktip.h>
 #include <ktabwidget.h>
 #include <kactionmenu.h>
@@ -73,6 +72,7 @@
 #include <kapplication.h>
 #include <kdeprintdialog.h>
 #include <kundostack.h>
+#include <kstatusbar.h>
 
 // qt includes
 #include <QtCore/QPointer>
@@ -89,6 +89,8 @@
 #include <QtGui/QPrinter>
 #include <QtGui/QPrintDialog>
 #include <QtGui/QUndoView>
+#include <QtGui/QPushButton>
+#include <QtGui/QLabel>
 
 /** Static pointer, holding the last created instance. */
 UMLApp* UMLApp::s_instance;
@@ -439,11 +441,6 @@
     viewExportImage->setEnabled(false);
     viewProperties->setEnabled(false);
 
-    zoomAction = new KPlayerPopupSliderAction(this, SLOT(slotZoomSliderMoved(int)), this);
-    zoomAction->setText(i18n("&Zoom Slider"));
-    zoomAction->setIcon(Icon_Utils::SmallIcon(Icon_Utils::it_Zoom_Slider));
-    zoomAction->setShortcuts(KShortcut(Qt::Key_F9));
-    actionCollection()->addAction("popup_zoom", zoomAction);
     zoom100Action = actionCollection()->addAction("zoom100");
     zoom100Action->setIcon(Icon_Utils::SmallIcon(Icon_Utils::it_Zoom_100));
     zoom100Action->setText(i18n("Z&oom to 100%"));
@@ -535,14 +532,13 @@
 }
 
 /**
- * Connected to by the KPlayerSliderAction zoomAction, a value of between 300
+ * Connected to by the  zoomAction, a value of between 300
  * and 2200 is scaled to zoom to between 9% and 525%.
- * The min and max values of the slider are hard coded in KPlayerSliderAction for now.
+ * The min and max values of the slider are hard coded in the statusbar slider.
  */
 void UMLApp::slotZoomSliderMoved(int value)
 {
-    int zoom = (int)(value*0.01);
-    currentView()->setZoom(zoom*zoom);
+    setZoom(value);
 }
 
 /**
@@ -554,6 +550,22 @@
 }
 
 /**
+ * Decrease the zoom factor of the current diagram.
+ */
+void UMLApp::slotZoomOut()
+{
+    setZoom(currentView()->getZoom()-5);
+}
+
+/**
+ * Increase the zoom factor of the current diagram.
+ */
+void UMLApp::slotZoomIn()
+{
+    setZoom(currentView()->getZoom()+5);
+}
+
+/**
  * Set the zoom factor of the current diagram.
  *
  * @param zoom  Zoom factor in percentage.
@@ -561,6 +573,8 @@
 void UMLApp::setZoom(int zoom)
 {
     currentView()->setZoom(zoom);
+    qDebug() << "Set zoom value:" << " " << zoom;
+    m_pZoomSlider->setValue(zoom);
 }
 
 /**
@@ -572,7 +586,7 @@
 {
     QVariant var = action->data();
     if (var.canConvert<int>()) {
-        currentView()->setZoom(var.toInt());
+        setZoom(var.toInt());
     }
 }
 
@@ -632,8 +646,58 @@
  */
 void UMLApp::initStatusBar()
 {
-    statusBar()->insertPermanentItem( i18nc("init status bar", "Ready"), 1 );
     connect(m_doc, SIGNAL( sigWriteToStatusBar(const QString &) ), this, SLOT( slotStatusMsg(const QString &) ));
+    
+    m_statusBarMessage = new QLabel(i18nc("init status bar", "Ready"));
+    statusBar()->addWidget(m_statusBarMessage);
+    
+    QWidget* defaultZoomWdg = new QWidget(this);
+    QHBoxLayout* zoomLayout = new QHBoxLayout(defaultZoomWdg);
+    zoomLayout->setContentsMargins(0,0,0,0);
+    zoomLayout->setSpacing(0);
+    zoomLayout->addItem(new QSpacerItem(0, 20, QSizePolicy::Expanding, QSizePolicy::Minimum));
+    
+    
+    m_pZoomFitSBTB = new StatusBarToolButton(this);
+    m_pZoomFitSBTB->setText("Fit");
+    m_pZoomFitSBTB->setGroupPosition(StatusBarToolButton::GroupLeft);
+    zoomLayout->addWidget(m_pZoomFitSBTB);
+    m_pZoomFitSBTB->setContentsMargins(0,0,0,0);
+    m_pZoomFitSBTB->setDisabled(true);
+    
+    m_pZoomFullSBTB = new StatusBarToolButton(this);
+    m_pZoomFullSBTB->setText("100%");
+    m_pZoomFullSBTB->setGroupPosition(StatusBarToolButton::GroupRight);
+    m_pZoomFullSBTB->setContentsMargins(0,0,0,0);
+    zoomLayout->addWidget(m_pZoomFullSBTB);
+    connect(m_pZoomFullSBTB, SIGNAL( clicked() ), this, SLOT( slotZoom100() ));
+    
+    statusBar()->addPermanentWidget(defaultZoomWdg);
+    
+    m_pZoomOutPB = new QPushButton(this);
+    m_pZoomOutPB->setIcon(KIcon("zoom-out"));
+    m_pZoomOutPB->setFlat(true);
+    m_pZoomOutPB->setMaximumSize(30,30);
+    statusBar()->addPermanentWidget(m_pZoomOutPB);
+    connect(m_pZoomOutPB, SIGNAL( clicked() ), this, SLOT( slotZoomOut() ));
+    
+    m_pZoomSlider = new QSlider(Qt::Horizontal, this);
+    m_pZoomSlider->setMaximumSize(100,50);
+    m_pZoomSlider->setMinimum (20);
+    m_pZoomSlider->setMaximum (480);
+    //m_pZoomSlider->setPageStep (1000);
+    m_pZoomSlider->setValue (100);
+    m_pZoomSlider->setContentsMargins(0,0,0,0);
+    connect(m_pZoomSlider, SIGNAL( valueChanged( int ) ), this, SLOT( slotZoomSliderMoved(int) ));
+    
+    statusBar()->addPermanentWidget(m_pZoomSlider);
+    
+    m_pZoomInPB = new QPushButton(this);
+    m_pZoomInPB->setIcon(KIcon("zoom-in"));
+    m_pZoomInPB->setFlat(true);
+    m_pZoomInPB->setMaximumSize(30,30);
+    statusBar()->addPermanentWidget(m_pZoomInPB);
+    connect(m_pZoomInPB, SIGNAL( clicked() ), this, SLOT( slotZoomIn() ));
 }
 
 /**
@@ -1308,7 +1372,7 @@
 void UMLApp::slotStatusMsg(const QString &text)
 {
     // change status message permanently
-    statusBar()->changeItem( text, 1 );
+    m_statusBarMessage->setText(text);
 }
 
 /**
@@ -1316,7 +1380,7 @@
  */
 void UMLApp::resetStatusMsg()
 {
-    statusBar()->changeItem( i18nc("reset status bar", "Ready."), 1 );
+    m_statusBarMessage->setText( i18nc("reset status bar", "Ready."));
 }
 
 /**
@@ -2775,7 +2839,7 @@
  */
 QString UMLApp::statusBarMsg()
 {
-    return statusBar()->itemText(1);
+    return m_statusBarMessage->text();
 }
 
 /**
--- trunk/KDE/kdesdk/umbrello/umbrello/uml.h #1238261:1238262
@@ -31,8 +31,8 @@
 class SettingsDlg;
 class UMLViewImageExporterAll;
 class RefactoringAssistant;
-class KPlayerPopupSliderAction;
 class XhtmlGenerator;
+class StatusBarToolButton;
 
 // KDE forward declarations
 class KActionMenu;
@@ -55,6 +55,8 @@
 class QMimeData;
 class QUndoCommand;
 class QUndoView;
+class QPushButton;
+class QLabel;
 
 /**
  * The base class for UML application windows. It sets up the main
@@ -244,6 +246,8 @@
     void slotSetZoom(QAction* action);
     void slotZoomSliderMoved(int value);
     void slotZoom100();
+    void slotZoomOut();
+    void slotZoomIn();
 
     void setupZoomMenu();
 
@@ -356,7 +360,6 @@
     QAction* viewProperties;
 
     QAction* zoom100Action;
-    KPlayerPopupSliderAction* zoomAction;
 
     QAction* m_langAct[Uml::pl_Reserved];
     KAction* deleteSelectedWidget;
@@ -396,6 +399,16 @@
     UMLViewImageExporterAll* m_imageExporterAll;  ///< Used to export all the views.
 
     /**
+     * Statusbar items
+     */
+    QPushButton* m_pZoomOutPB;
+    QPushButton* m_pZoomInPB;
+    StatusBarToolButton* m_pZoomFitSBTB;
+    StatusBarToolButton* m_pZoomFullSBTB;
+    QSlider* m_pZoomSlider;
+    QLabel* m_statusBarMessage;
+
+    /**
      * The running XHTML documentation generator. Null when no generation is running.
      */
     XhtmlGenerator* m_xhtmlGenerator;




More information about the umbrello-devel mailing list