Made a few small changes to ImageButton and ZoomButtonPanel classes.
authorPekka Nissinen <pekka.nissinen@ixonos.com>
Tue, 25 May 2010 11:18:15 +0000 (14:18 +0300)
committerPekka Nissinen <pekka.nissinen@ixonos.com>
Tue, 25 May 2010 11:18:15 +0000 (14:18 +0300)
Reviewed by: Marko Niemelä

src/src.pro
src/ui/imagebutton.cpp
src/ui/imagebutton.h
src/ui/mainwindow.cpp
src/ui/zoombuttonpanel.cpp
src/ui/zoombuttonpanel.h

index 4e5b9f0..3cdc8c3 100644 (file)
@@ -85,8 +85,7 @@ HEADERS += ui/mainwindow.h \
     ui/sidepanel.h
 QT += network \
     webkit
-
-#DEFINES += QT_NO_DEBUG_OUTPUT
+DEFINES += QT_NO_DEBUG_OUTPUT
 
 maemo5 | simulator {
     SOURCES += gps/gpspositionprivate.cpp
@@ -103,8 +102,7 @@ maemo5 | simulator {
     message([QtMobility])
     message(Make sure you have QtMobility development headers installed)
     message(install headers with: apt-get install libqtm-dev)
-}
-else {
+} else {
     SOURCES += gps/gpspositionprivatestub.cpp
     HEADERS += gps/gpspositionprivatestub.h
     message(QJson built in)
@@ -112,7 +110,6 @@ else {
     message(install headers with: sudo apt-get install libqjson-dev)
 }
 
-
 # -----------------------------------------------------------------
 # Debian packetizing additions
 # -----------------------------------------------------------------
index a94ca30..2f4dac8 100644 (file)
    USA.
 */
 
+#include <QSize>
 #include <QDebug>
 #include <QPixmap>
 #include <QPainter>
-#include <QAbstractButton>
 
 #include "imagebutton.h"
 
 ImageButton::ImageButton(QWidget *parent, QString normalIconPictureFileName,
-                     QString selectedIconPictureFileName)
+                         QString selectedIconPictureFileName)
     : QPushButton(parent),
       m_buttonMode(QIcon::Normal)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
+    // If there is a file name provided for icon image, use it as the icon for the button
     if (normalIconPictureFileName != "") {
         QPixmap iconPixmap(normalIconPictureFileName);
-        m_buttonSize = iconPixmap.size(); // Get the button size from the normal state icon picture
+        QSize buttonSize = iconPixmap.size(); // Get the button size from the normal state icon picture
         QIcon icon(iconPixmap);
 
         // If there is a picture for selected state, use it instead of a simple highlight change
         if(selectedIconPictureFileName != "")
-            icon.addFile(selectedIconPictureFileName, m_buttonSize, QIcon::Selected);
+            icon.addFile(selectedIconPictureFileName, buttonSize, QIcon::Selected);
 
         setIcon(icon);
-        setIconSize(m_buttonSize);
-        setFixedSize(m_buttonSize);
+        setIconSize(buttonSize);
+        setFixedSize(buttonSize);
     }
 }
 
 void ImageButton::setButtonIcon(const QPixmap &image)
 {
-    m_buttonSize = image.size(); // Get the button size from the normal state icon picture
+    QSize buttonSize = image.size(); // Get the button size from the normal state icon picture
     QIcon icon(image);
 
     setIcon(icon);
-    setIconSize(m_buttonSize);
-    setFixedSize(m_buttonSize);
+    setIconSize(buttonSize);
+    setFixedSize(buttonSize);
 }
 
 void ImageButton::mousePressEvent(QMouseEvent *event)
@@ -63,7 +64,7 @@ void ImageButton::mousePressEvent(QMouseEvent *event)
     qDebug() << __PRETTY_FUNCTION__;
 
     if(m_buttonMode != QIcon::Disabled) {
-        QAbstractButton::mousePressEvent(event);
+        QPushButton::mousePressEvent(event);
         setMode(QIcon::Selected);
     }
 }
@@ -73,7 +74,7 @@ void ImageButton::mouseReleaseEvent(QMouseEvent *event)
     qDebug() << __PRETTY_FUNCTION__;
 
     if(m_buttonMode != QIcon::Disabled) {
-        QAbstractButton::mouseReleaseEvent(event);
+        QPushButton::mouseReleaseEvent(event);
         setMode(QIcon::Normal);
     }
 }
index 0061fe2..de6a480 100644 (file)
@@ -23,8 +23,8 @@
 #define IMAGEBUTTON_H
 
 #include <QIcon>
-#include <QSize>
 #include <QString>
+#include <QWidget>
 #include <QPushButton>
 #include <QMouseEvent>
 #include <QPaintEvent>
@@ -43,8 +43,8 @@ public:
      * @brief Constructor
      *
      * @param parent Parent
-     * @param normalIconPictureFileName Normal state Icon image file name
-     * @param selectedIconPictureFileName Selected state Icon image file name (optional)
+     * @param normalIconPictureFileName Normal state icon image file name
+     * @param selectedIconPictureFileName Selected state icon image file name (optional)
      */
     ImageButton(QWidget *parent = 0, QString normalIconPictureFileName = "",
                 QString selectedIconPictureFileName = "");
@@ -103,9 +103,8 @@ public:
 /*******************************************************************************
  * DATA MEMBERS
  ******************************************************************************/
-private:
+protected:
     QIcon::Mode m_buttonMode; ///< Button mode (Normal, Selected etc...)
-    QSize m_buttonSize; ///< Button size
 };
 
 #endif // IMAGEBUTTON_H
index 565af75..a70fbc0 100644 (file)
@@ -223,10 +223,10 @@ void MainWindow::buildZoomButtonPanel()
     m_zoomButtonPanel = new ZoomButtonPanel(this, ZOOM_BUTTON_PANEL_POSITION_X,
                                             ZOOM_BUTTON_PANEL_POSITION_Y);
 
-    connect(m_zoomButtonPanel->m_zoomInButton, SIGNAL(clicked()),
+    connect(m_zoomButtonPanel->zoomInButton(), SIGNAL(clicked()),
             this, SIGNAL(zoomIn()));
 
-    connect(m_zoomButtonPanel->m_zoomOutButton, SIGNAL(clicked()),
+    connect(m_zoomButtonPanel->zoomOutButton(), SIGNAL(clicked()),
             this, SIGNAL(zoomOut()));
 
     connect(this, SIGNAL(zoomLevelChanged(int)),
index 94d04c0..6c22b20 100644 (file)
 
 ZoomButtonPanel::ZoomButtonPanel(QWidget *parent, int x, int y)
     : QWidget(parent),
-      m_zoomInButton(0),
-      m_zoomOutButton(0),
       m_panelLayout(this),
-      m_x(x),
-      m_y(y)
+      m_zoomInButton(0),
+      m_zoomOutButton(0)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
@@ -46,7 +44,21 @@ ZoomButtonPanel::ZoomButtonPanel(QWidget *parent, int x, int y)
     m_panelLayout.addWidget(m_zoomInButton, 0, 0);
     m_panelLayout.addWidget(m_zoomOutButton, 1, 0);
 
-    move(m_x, m_y);
+    move(x, y);
+}
+
+const ImageButton* ZoomButtonPanel::zoomInButton()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    return m_zoomInButton;
+}
+
+const ImageButton* ZoomButtonPanel::zoomOutButton()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    return m_zoomOutButton;
 }
 
 void ZoomButtonPanel::disableZoomInButton()
index 0349676..f1f20a2 100644 (file)
@@ -23,7 +23,6 @@
 #define ZOOMBUTTONPANEL_H
 
 #include <QWidget>
-#include <QPaintEvent>
 #include <QGridLayout>
 #include <QGraphicsItem>
 
@@ -51,33 +50,44 @@ public:
 /*******************************************************************************
  * MEMBER FUNCTIONS AND SLOTS
  ******************************************************************************/
+public:
+    /**
+    * @brief Getter for the zoom in button
+    *
+    * @return Pointer to the zoomInButton
+    */
+    const ImageButton* zoomInButton();
+
+    /**
+    * @brief Getter for the zoom out button
+    *
+    * @return Pointer to the zoomOutButton
+    */
+    const ImageButton* zoomOutButton();
+
 public slots:
     /**
-     * @brief Disables the Zoom In button
+     * @brief Disables the zoom in button
      */
     void disableZoomInButton();
 
     /**
-     * @brief Disables the Zoom Out button
+     * @brief Disables the zoom out button
      */
     void disableZoomOutButton();
 
     /**
-     * @brief Reset Zoom button states to normal
+     * @brief Reset zoom button states to normal
      */
     void resetButtons();
 
 /*******************************************************************************
  * DATA MEMBERS
  ******************************************************************************/
-public:
-    ImageButton *m_zoomInButton;     ///< Button for zoom in
-    ImageButton *m_zoomOutButton;    ///< Button for zoom out
-
 private:
-    QGridLayout m_panelLayout;  ///< Panel layout
-    int m_x;                    ///< Panel x coordinate
-    int m_y;                    ///< Panel y coordinate
+    QGridLayout m_panelLayout;      ///< Panel layout
+    ImageButton *m_zoomInButton;    ///< Button for zoom in
+    ImageButton *m_zoomOutButton;   ///< Button for zoom out
 };
 
 #endif // ZOOMBUTTONPANEL_H