From: Sami Rämö Date: Wed, 25 Aug 2010 07:45:33 +0000 (+0300) Subject: Merge branch 'new_panels_with_context_buttons' of https://vcs.maemo.org/git/situare... X-Git-Tag: v2.0b-1~44 X-Git-Url: https://vcs.maemo.org/git/?a=commitdiff_plain;h=b03cf0737bfc0d371e49bd52ccba073b23b76476;hp=6dd7b2002e600d4b2964d51a75e50a13f3b63e80;p=situare Merge branch 'new_panels_with_context_buttons' of https://vcs.maemo.org/git/situare into move_buttons_to_content_area - Also fixed the routing panel buttons --- diff --git a/doc/testing/functionality-tests.doc b/doc/testing/functionality-tests.doc index 1a5b902..0bac792 100644 Binary files a/doc/testing/functionality-tests.doc and b/doc/testing/functionality-tests.doc differ diff --git a/src/ui/friendlistpanel.cpp b/src/ui/friendlistpanel.cpp index 31fe911..d333b39 100644 --- a/src/ui/friendlistpanel.cpp +++ b/src/ui/friendlistpanel.cpp @@ -63,8 +63,8 @@ FriendListPanel::FriendListPanel(QWidget *parent) m_friendListHeaderWidget->setLayout(filterLayout); m_friendListHeaderWidget->setAutoFillBackground(true); - m_routeButton = new ImageButton(this, ":res/images/route_to_friend.png", - ":res/images/route_to_friend_s.png"); + m_routeButton = new ImageButton(":res/images/route_to_friend.png", + ":res/images/route_to_friend_s.png", "", this); m_routeButton->setDisabled(true); QPalette labelPalette = m_friendListHeaderWidget->palette(); @@ -73,8 +73,8 @@ FriendListPanel::FriendListPanel(QWidget *parent) m_friendListHeaderWidget->setPalette(labelPalette); m_friendListHeaderWidget->hide(); m_friendListLabel = new QLabel(this); - m_clearFilterButton = new ImageButton(this, ":res/images/filtered.png", - ":res/images/filtered_s.png"); + m_clearFilterButton = new ImageButton(":res/images/filtered.png", + ":res/images/filtered_s.png", "", this); m_clearFilterButton->setCheckable(true); @@ -137,8 +137,8 @@ FriendListPanel::FriendListPanel(QWidget *parent) this, SLOT(topmostWindowChanged(bool))); // CONTEXT BUTTONS - m_contextButtonList.append(m_routeButton); - m_contextButtonList.append(m_clearFilterButton); + m_contextButtonLayout->addWidget(m_routeButton, 0, 0); + m_contextButtonLayout->addWidget(m_clearFilterButton, 1, 0); } void FriendListPanel::anyPanelClosed() diff --git a/src/ui/imagebutton.cpp b/src/ui/imagebutton.cpp index 0dfd592..84fbb16 100644 --- a/src/ui/imagebutton.cpp +++ b/src/ui/imagebutton.cpp @@ -19,17 +19,16 @@ USA. */ -#include #include -#include +#include #include #include "imagebutton.h" -ImageButton::ImageButton(QWidget *parent, QString normalIconPictureFileName, - QString selectedIconPictureFileName) - : QPushButton(parent), - m_buttonMode(QIcon::Normal) +ImageButton::ImageButton(const QString &normalIconPictureFileName, + const QString &selectedIconPictureFileName, + const QString &disabledIconPictureFileName, QWidget *parent) + : QPushButton(parent) { qDebug() << __PRETTY_FUNCTION__; @@ -43,6 +42,10 @@ ImageButton::ImageButton(QWidget *parent, QString normalIconPictureFileName, if(!selectedIconPictureFileName.isEmpty()) icon.addFile(selectedIconPictureFileName, buttonSize, QIcon::Selected); + // If there is a picture for disabled state, use it instead of a simple color change + if(!disabledIconPictureFileName.isEmpty()) + icon.addFile(disabledIconPictureFileName, buttonSize, QIcon::Disabled); + initButton(buttonSize, icon); } } @@ -57,32 +60,6 @@ void ImageButton::setButtonIcon(const QPixmap &image) initButton(buttonSize, icon); } -void ImageButton::mousePressEvent(QMouseEvent *event) -{ - qDebug() << __PRETTY_FUNCTION__; - - if(m_buttonMode != QIcon::Disabled) { - QPushButton::mousePressEvent(event); - setMode(QIcon::Selected); - } else { - setDown(true); - emit pressed(); - } -} - -void ImageButton::mouseReleaseEvent(QMouseEvent *event) -{ - qDebug() << __PRETTY_FUNCTION__; - - if(m_buttonMode != QIcon::Disabled) { - QPushButton::mouseReleaseEvent(event); - setMode(QIcon::Normal); - } else { - setDown(false); - emit released(); - } -} - void ImageButton::paintEvent(QPaintEvent *event) { qDebug() << __PRETTY_FUNCTION__; @@ -90,22 +67,17 @@ void ImageButton::paintEvent(QPaintEvent *event) Q_UNUSED(event); QPainter painter(this); - icon().paint(&painter, this->rect(), NULL, m_buttonMode); -} -void ImageButton::setMode(QIcon::Mode mode) -{ - qDebug() << __PRETTY_FUNCTION__; - - m_buttonMode = mode; - update(); -} - -QIcon::Mode ImageButton::mode() -{ - qDebug() << __PRETTY_FUNCTION__; - - return m_buttonMode; + if (isEnabled()) { + if (isChecked()) + icon().paint(&painter, rect(), NULL, QIcon::Selected); + else if (isDown()) + icon().paint(&painter, rect(), NULL, QIcon::Selected); + else + icon().paint(&painter, rect(), NULL, QIcon::Normal); + } else { + icon().paint(&painter, rect(), NULL, QIcon::Disabled); + } } void ImageButton::initButton(const QSize &size, const QIcon &icon) diff --git a/src/ui/imagebutton.h b/src/ui/imagebutton.h index 5876486..224532f 100644 --- a/src/ui/imagebutton.h +++ b/src/ui/imagebutton.h @@ -22,12 +22,7 @@ #ifndef IMAGEBUTTON_H #define IMAGEBUTTON_H -#include -#include -#include #include -#include -#include /** * @brief A simple class for icon button @@ -42,32 +37,20 @@ public: /** * @brief Constructor * - * @param parent Parent * @param normalIconPictureFileName Normal state icon image file name * @param selectedIconPictureFileName Selected state icon image file name (optional) + * @param disabledIconPictureFileName Disabled state icon image file name (optional) + * @param parent Parent */ - ImageButton(QWidget *parent = 0, QString normalIconPictureFileName = "", - QString selectedIconPictureFileName = ""); + ImageButton(const QString &normalIconPictureFileName = QString(), + const QString &selectedIconPictureFileName = QString(), + const QString &disabledIconPictureFileName = QString(), QWidget *parent = 0); /******************************************************************************* * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS ******************************************************************************/ protected: /** - * @brief Event handler for mouse press events - * - * @param event Mouse event - */ - void mousePressEvent(QMouseEvent *event); - - /** - * @brief Event handler for mouse release events - * - * @param event Mouse event - */ - void mouseReleaseEvent(QMouseEvent *event); - - /** * @brief Event handler for paint events * * Paints the button and its icon @@ -86,20 +69,6 @@ public: */ void setButtonIcon(const QPixmap &image); - /** - * @brief Sets the button icon mode - * - * @param mode Button icon mode - */ - void setMode(QIcon::Mode mode); - - /** - * @brief Returns the current button icon mode - * - * @return Button icon mode - */ - QIcon::Mode mode(); - private: /** * @brief Initializes the button by setting graphics and alpha mask @@ -108,12 +77,6 @@ private: * @param icon Image icon */ void initButton(const QSize &size, const QIcon &icon); - -/******************************************************************************* - * DATA MEMBERS - ******************************************************************************/ -protected: - QIcon::Mode m_buttonMode; ///< Button mode (Normal, Selected etc...) }; #endif // IMAGEBUTTON_H diff --git a/src/ui/indicatorbutton.cpp b/src/ui/indicatorbutton.cpp index d2a5fed..81bc7b2 100644 --- a/src/ui/indicatorbutton.cpp +++ b/src/ui/indicatorbutton.cpp @@ -82,15 +82,6 @@ const QPoint& IndicatorButton::eventPosition() return m_eventPosition; } -void IndicatorButton::mouseMoveEvent(QMouseEvent *event) -{ - qDebug() << __PRETTY_FUNCTION__; - - QToolButton::mouseMoveEvent(event); - - event->ignore(); -} - void IndicatorButton::mousePressEvent(QMouseEvent *event) { qDebug() << __PRETTY_FUNCTION__; diff --git a/src/ui/indicatorbutton.h b/src/ui/indicatorbutton.h index 4397aec..743370e 100644 --- a/src/ui/indicatorbutton.h +++ b/src/ui/indicatorbutton.h @@ -57,13 +57,6 @@ public: ******************************************************************************/ protected: /** - * @brief Event handler for mouse move events - * - * @param event Mouse event - */ - void mouseMoveEvent(QMouseEvent *event); - - /** * @brief Event handler for mouse press events * * @param event Mouse event diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 18c5f85..039ba38 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -350,10 +350,8 @@ void MainWindow::buildRoutingPanel() connect(this, SIGNAL(locationDataParsed(const QList&)), m_routingPanel, SLOT(populateLocationListView(const QList&))); - connect(m_routingPanel, - SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)), - this, - SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&))); + connect(m_routingPanel, SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)), + this, SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&))); connect(m_routingPanel, SIGNAL(routeToLocation(const GeoCoordinate&)), this, SIGNAL(routeTo(const GeoCoordinate&))); diff --git a/src/ui/panelbase.cpp b/src/ui/panelbase.cpp index 1eb2175..59e6ab7 100644 --- a/src/ui/panelbase.cpp +++ b/src/ui/panelbase.cpp @@ -27,11 +27,28 @@ PanelBase::PanelBase(QWidget *parent) : QWidget(parent) { qDebug() << __PRETTY_FUNCTION__; + + const int CONTEXT_BUTTON_MARGIN_LEFT = 2; + const int CONTEXT_BUTTON_MARGIN_TOP = 10; + const int CONTEXT_BUTTON_MARGIN_RIGHT = 0; + const int CONTEXT_BUTTON_MARGIN_BOTTOM = 0; + const int CONTEXT_BUTTON_SPACING = 0; + + m_contextButtons = new QWidget; + + m_contextButtonLayout = new QGridLayout; + m_contextButtonLayout->setContentsMargins(CONTEXT_BUTTON_MARGIN_LEFT, + CONTEXT_BUTTON_MARGIN_TOP, + CONTEXT_BUTTON_MARGIN_RIGHT, + CONTEXT_BUTTON_MARGIN_BOTTOM); + m_contextButtonLayout->setSpacing(CONTEXT_BUTTON_SPACING); + + m_contextButtons->setLayout(m_contextButtonLayout); } -const QList& PanelBase::contextButtons() const +QWidget* PanelBase::contextButtons() const { qDebug() << __PRETTY_FUNCTION__; - return m_contextButtonList; + return m_contextButtons; } diff --git a/src/ui/panelbase.h b/src/ui/panelbase.h index 528dc29..272b8df 100644 --- a/src/ui/panelbase.h +++ b/src/ui/panelbase.h @@ -22,6 +22,7 @@ #ifndef PANELBASE_H #define PANELBASE_H +#include #include class ImageButton; @@ -48,11 +49,11 @@ public: ******************************************************************************/ public: /** - * @brief Get list of context buttons + * @brief Getter for the context buttons * - * @returns Reference to list of context buttons + * @returns Pointer to context buttons widget */ - const QList& contextButtons() const; + QWidget* contextButtons() const; /******************************************************************************* * SIGNALS @@ -69,6 +70,9 @@ signals: * DATA MEMBERS ******************************************************************************/ protected: - QList m_contextButtonList; ///< List of context buttons + QGridLayout *m_contextButtonLayout; ///< Layout for context buttons + +private: + QWidget *m_contextButtons; ///< Widget for context buttons }; #endif // PANELBASE_H diff --git a/src/ui/panelcontextbuttonbar.cpp b/src/ui/panelcontextbuttonbar.cpp index 11c4bbd..03dfd1e 100644 --- a/src/ui/panelcontextbuttonbar.cpp +++ b/src/ui/panelcontextbuttonbar.cpp @@ -22,14 +22,13 @@ #include #include -#include "imagebutton.h" - #include "panelcontextbuttonbar.h" const int CONTEXT_BUTTON_BAR_WIDTH = 78; PanelContextButtonBar::PanelContextButtonBar(QWidget *parent) - : QWidget(parent) + : QWidget(parent), + m_contextButtons(0) { qDebug() << __PRETTY_FUNCTION__; @@ -61,29 +60,20 @@ void PanelContextButtonBar::paintEvent(QPaintEvent *event) } -void PanelContextButtonBar::setContextButtons(const QList &contextButtonList) +void PanelContextButtonBar::setContextButtons(QWidget *contextButtons) { qDebug() << __PRETTY_FUNCTION__; - const int CONTEXT_BUTTON_HEIGHT = 74; - const int CONTEXT_BUTTON_MARGIN_LEFT = 2; - const int CONTEXT_BUTTON_MARGIN_TOP = 10; - // Hide previous buttons (if any) - for (int i = 0; i < m_contextButtonList.size(); i ++) { - m_contextButtonList.at(i)->setParent(0); - } + if (m_contextButtons) + m_contextButtons->setParent(0); - m_contextButtonList = contextButtonList; + m_contextButtons = contextButtons; - for (int i = 0; i < m_contextButtonList.size(); i ++) { - m_contextButtonList.at(i)->setParent(this); - m_contextButtonList.at(i)->setVisible(true); - m_contextButtonList.at(i)->move(CONTEXT_BUTTON_MARGIN_LEFT, - CONTEXT_BUTTON_MARGIN_TOP + (CONTEXT_BUTTON_HEIGHT * i)); - } + m_contextButtons->setParent(this); + m_contextButtons->setVisible(true); - setFixedHeight(CONTEXT_BUTTON_MARGIN_TOP + (CONTEXT_BUTTON_HEIGHT * contextButtonList.size())); + setFixedHeight(m_contextButtons->height()); emit positionChangeRequested(); } diff --git a/src/ui/panelcontextbuttonbar.h b/src/ui/panelcontextbuttonbar.h index d2528ae..7b4a4ba 100644 --- a/src/ui/panelcontextbuttonbar.h +++ b/src/ui/panelcontextbuttonbar.h @@ -24,8 +24,6 @@ #include -class ImageButton; - class PanelContextButtonBar : public QWidget { Q_OBJECT @@ -56,9 +54,9 @@ public: /** * @brief Sets the context buttons to the context button bar * - * @param contextButtonList List of context buttons + * @param contextButtons Pointer to context buttons */ - void setContextButtons(const QList &contextButtonList); + void setContextButtons(QWidget *contextButtons); /******************************************************************************* * SIGNALS @@ -73,12 +71,12 @@ signals: * DATA MEMBERS ******************************************************************************/ private: - QList m_contextButtonList; + QPixmap m_barTile; ///< Pixmap for button bar + QPixmap m_barTop; ///< Pixmap for button bar top - QPixmap m_barTile; ///< Pixmap for button bar - QPixmap m_barTop; ///< Pixmap for button bar top + QRect m_barRect; ///< Rect for the button bar - QRect m_barRect; ///< Rect for the button bar + QWidget *m_contextButtons; ///< Widget for context buttons }; #endif // PANELCONTEXTBUTTONBAR_H diff --git a/src/ui/routingpanel.cpp b/src/ui/routingpanel.cpp index 1455ff6..9662506 100644 --- a/src/ui/routingpanel.cpp +++ b/src/ui/routingpanel.cpp @@ -29,15 +29,15 @@ RoutingPanel::RoutingPanel(QWidget *parent) listViewLayout->setContentsMargins(PANEL_MARGIN_LEFT, PANEL_MARGIN_TOP, PANEL_MARGIN_RIGHT, PANEL_MARGIN_BOTTOM); - ImageButton *searchLocationButton = new ImageButton(0, ":/res/images/search.png", - ":/res/images/search_s.png"); + ImageButton *searchLocationButton = new ImageButton(":/res/images/search.png", + ":/res/images/search_s.png", + "", this); - m_contextButtonList.append(searchLocationButton); + m_contextButtonLayout->addWidget(searchLocationButton, 0, 0); - m_routeButton = new ImageButton(this, ":res/images/route_to_location.png", - ":res/images/route_to_location_s.png"); + m_routeButton = new ImageButton(":res/images/route_to_location.png", + ":res/images/route_to_location_s.png", "", this); m_routeButton->setDisabled(true); - m_routeButton->hide(); m_locationListHeaderWidget = new QWidget(); m_locationListHeaderWidget->setLayout(headerLayout); @@ -62,7 +62,6 @@ RoutingPanel::RoutingPanel(QWidget *parent) listViewLayout->addWidget(m_locationListView); listViewLayout->addWidget(m_routeWaypointListView); - routingLayout->addWidget(m_routeButton); routingLayout->addWidget(m_locationListHeaderWidget); routingLayout->addLayout(listViewLayout); @@ -84,7 +83,7 @@ RoutingPanel::RoutingPanel(QWidget *parent) this, SIGNAL(requestSearchLocation())); // CONTEXT BUTTONS - m_contextButtonList.append(m_routeButton); + m_contextButtonLayout->addWidget(m_routeButton, 1, 0); } void RoutingPanel::clearListsSelections() @@ -110,8 +109,6 @@ void RoutingPanel::populateLocationListView(const QList &locations) { qDebug() << __PRETTY_FUNCTION__; - m_routeButton->show(); - m_locationListHeaderWidget->show(); m_locationListLabel->setText(tr("Search results: %1").arg(locations.count())); @@ -153,8 +150,6 @@ void RoutingPanel::setRoute(Route &route) { qDebug() << __PRETTY_FUNCTION__; - m_routeButton->hide(); - m_locationListHeaderWidget->hide(); m_locationListView->hide(); m_routeWaypointListView->show(); diff --git a/src/ui/userinfo.cpp b/src/ui/userinfo.cpp index 102660e..d7e8f33 100644 --- a/src/ui/userinfo.cpp +++ b/src/ui/userinfo.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include #include diff --git a/src/ui/userinfopanel.cpp b/src/ui/userinfopanel.cpp index db35d46..a8ffab5 100644 --- a/src/ui/userinfopanel.cpp +++ b/src/ui/userinfopanel.cpp @@ -79,13 +79,15 @@ UserInfoPanel::UserInfoPanel(QWidget *parent) connect(this, SIGNAL(clearUpdateLocationDialogData()), m_userInfo, SLOT(clearUpdateLocationDialogData())); - ImageButton *updateFriendsButton = new ImageButton(this, ":/res/images/refresh.png", - ":/res/images/refresh_s.png"); - ImageButton *updateStatusMessageButton = new ImageButton(this, ":/res/images/send_position.png", - ":/res/images/send_position_s.png"); - - m_contextButtonList.append(updateFriendsButton); - m_contextButtonList.append(updateStatusMessageButton); + ImageButton *updateFriendsButton = new ImageButton(":/res/images/refresh.png", + ":/res/images/refresh_s.png", + "", this); + ImageButton *updateStatusMessageButton = new ImageButton(":/res/images/send_position.png", + ":/res/images/send_position_s.png", + "", this); + + m_contextButtonLayout->addWidget(updateFriendsButton, 0, 0); + m_contextButtonLayout->addWidget(updateStatusMessageButton, 1, 0); connect(updateFriendsButton, SIGNAL(clicked()), this, SIGNAL(refreshUserData())); diff --git a/src/ui/zoombutton.cpp b/src/ui/zoombutton.cpp index 74fbcc6..e5dfab9 100644 --- a/src/ui/zoombutton.cpp +++ b/src/ui/zoombutton.cpp @@ -20,15 +20,14 @@ */ #include -#include +#include #include "zoombutton.h" #include "panelcommon.h" -ZoomButton::ZoomButton(QWidget *parent, QString normalIconPictureFileName, - QString selectedIconPictureFileName) - : ImageButton(parent, normalIconPictureFileName, selectedIconPictureFileName) +ZoomButton::ZoomButton(const QString &iconPictureFileName, QWidget *parent) + : ImageButton(iconPictureFileName, "", "", parent) { qDebug() << __PRETTY_FUNCTION__; } @@ -47,9 +46,9 @@ void ZoomButton::mousePressEvent(QMouseEvent *event) { qDebug() << __PRETTY_FUNCTION__; - ImageButton::mousePressEvent(event); - m_eventPosition = mapToParent(event->pos()); + + ImageButton::mousePressEvent(event); } const QPoint& ZoomButton::eventPosition() diff --git a/src/ui/zoombutton.h b/src/ui/zoombutton.h index 773a483..6dd89e7 100644 --- a/src/ui/zoombutton.h +++ b/src/ui/zoombutton.h @@ -22,8 +22,6 @@ #ifndef ZOOMBUTTON_H #define ZOOMBUTTON_H -class QTimer; - #include "imagebutton.h" /** @@ -39,12 +37,10 @@ public: /** * @brief Constructor * + * @param iconPictureFileName Icon image file name * @param parent Parent - * @param normalIconPictureFileName Normal state Icon image file name - * @param selectedIconPictureFileName Selected state Icon image file name (optional) */ - ZoomButton(QWidget *parent = 0, QString normalIconPictureFileName = QString(), - QString selectedIconPictureFileName = QString()); + ZoomButton(const QString &iconPictureFileName = QString(), QWidget *parent = 0); /******************************************************************************* * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS diff --git a/src/ui/zoombuttonpanel.cpp b/src/ui/zoombuttonpanel.cpp index 6ff47ef..67dfba7 100644 --- a/src/ui/zoombuttonpanel.cpp +++ b/src/ui/zoombuttonpanel.cpp @@ -21,6 +21,7 @@ */ #include +#include #include #include @@ -41,8 +42,8 @@ ZoomButtonPanel::ZoomButtonPanel(QWidget *parent) { qDebug() << __PRETTY_FUNCTION__; - m_zoomInButton = new ZoomButton(this, ":/res/images/zoom_in.png"); - m_zoomOutButton = new ZoomButton(this, ":/res/images/zoom_out.png"); + m_zoomInButton = new ZoomButton(":/res/images/zoom_in.png", this); + m_zoomOutButton = new ZoomButton(":/res/images/zoom_out.png", this); m_panelLayout.setMargin(0); m_panelLayout.setSpacing(0); @@ -159,14 +160,14 @@ void ZoomButtonPanel::paintEvent(QPaintEvent *event) } } -const ZoomButton* ZoomButtonPanel::zoomInButton() +const ZoomButton* ZoomButtonPanel::zoomInButton() const { qDebug() << __PRETTY_FUNCTION__; return m_zoomInButton; } -const ZoomButton* ZoomButtonPanel::zoomOutButton() +const ZoomButton* ZoomButtonPanel::zoomOutButton() const { qDebug() << __PRETTY_FUNCTION__; @@ -177,22 +178,22 @@ void ZoomButtonPanel::disableZoomInButton() { qDebug() << __PRETTY_FUNCTION__; - m_zoomInButton->setMode(QIcon::Disabled); + m_zoomInButton->setEnabled(false); } void ZoomButtonPanel::disableZoomOutButton() { qDebug() << __PRETTY_FUNCTION__; - m_zoomOutButton->setMode(QIcon::Disabled); + m_zoomOutButton->setEnabled(false); } void ZoomButtonPanel::resetButtons() { qDebug() << __PRETTY_FUNCTION__; - m_zoomInButton->setMode(QIcon::Normal); - m_zoomOutButton->setMode(QIcon::Normal); + m_zoomInButton->setEnabled(true); + m_zoomOutButton->setEnabled(true); } void ZoomButtonPanel::setDraggable(bool mode, QPoint eventPosition) @@ -204,29 +205,24 @@ void ZoomButtonPanel::setDraggable(bool mode, QPoint eventPosition) if(mode) { emit draggingModeTriggered(); - m_zoomInMode = m_zoomInButton->mode(); - m_zoomOutMode = m_zoomOutButton->mode(); - m_zoomInButton->setMode(QIcon::Disabled); - m_zoomOutButton->setMode(QIcon::Disabled); + m_zoomInMode = m_zoomInButton->isEnabled(); + m_zoomOutMode = m_zoomOutButton->isEnabled(); + + m_zoomInButton->setEnabled(false); + m_zoomOutButton->setEnabled(false); grabMouse(); m_forceReleaseTimer->start(); m_dragPosition = eventPosition; } else { - if(m_zoomInMode == QIcon::Selected) - m_zoomInButton->setMode(QIcon::Normal); - else - m_zoomInButton->setMode(m_zoomInMode); - - if(m_zoomOutMode == QIcon::Selected) - m_zoomOutButton->setMode(QIcon::Normal); - else - m_zoomOutButton->setMode(m_zoomOutMode); + m_zoomInButton->setEnabled(m_zoomInMode); + m_zoomOutButton->setEnabled(m_zoomOutMode); releaseMouse(); m_forceReleaseTimer->stop(); + m_zoomInButton->setDown(false); m_zoomOutButton->setDown(false); } diff --git a/src/ui/zoombuttonpanel.h b/src/ui/zoombuttonpanel.h index 8165751..71fde69 100644 --- a/src/ui/zoombuttonpanel.h +++ b/src/ui/zoombuttonpanel.h @@ -90,14 +90,14 @@ public: * * @return Pointer to the zoomInButton */ - const ZoomButton* zoomInButton(); + const ZoomButton* zoomInButton() const; /** * @brief Getter for the zoom out button * * @return Pointer to the zoomOutButton */ - const ZoomButton* zoomOutButton(); + const ZoomButton* zoomOutButton() const; public slots: /** @@ -152,14 +152,13 @@ signals: ******************************************************************************/ private: bool m_isDraggable; ///< Boolean for tracking the draggability state + bool m_zoomInMode; ///< Boolean for storing zoom in button mode before dragging + bool m_zoomOutMode; ///< Boolean for storing zoom out button mode before dragging QGridLayout m_panelLayout; ///< Panel layout QPoint m_dragPosition; ///< Location from where the widget is grabbed - QIcon::Mode m_zoomInMode; ///< Store for zoom in button mode before dragging - QIcon::Mode m_zoomOutMode; ///< Store for zoom out button mode before dragging - QSize m_screenSize; ///< Store for the screen size QTimer *m_dragStartTimer; ///< Timer to init draggability of the zoom panel diff --git a/tests/ui/tabbedpanel/tabbedpanel.pro b/tests/ui/tabbedpanel/tabbedpanel.pro index 7d71204..1b298f8 100644 --- a/tests/ui/tabbedpanel/tabbedpanel.pro +++ b/tests/ui/tabbedpanel/tabbedpanel.pro @@ -5,13 +5,17 @@ SOURCES += \ testtabbedpanel.cpp \ ../../../src/ui/tabbedpanel.cpp \ ../../../src/ui/panelbar.cpp \ + ../../../src/ui/panelbase.cpp \ ../../../src/ui/panelcontentstack.cpp \ + ../../../src/ui/panelcontextbuttonbar.cpp \ ../../../src/ui/paneltab.cpp \ ../../../src/ui/paneltabbar.cpp HEADERS += \ ../../../src/ui/tabbedpanel.h \ ../../../src/ui/panelbar.h \ + ../../../src/ui/panelbase.h \ ../../../src/ui/panelcontentstack.h \ + ../../../src/ui/panelcontextbuttonbar.h \ ../../../src/ui/paneltab.h \ ../../../src/ui/paneltabbar.h \ ../../../src/ui/panelcommon.h diff --git a/tests/ui/tabbedpanel/testtabbedpanel.cpp b/tests/ui/tabbedpanel/testtabbedpanel.cpp index 63df118..1827f10 100644 --- a/tests/ui/tabbedpanel/testtabbedpanel.cpp +++ b/tests/ui/tabbedpanel/testtabbedpanel.cpp @@ -22,8 +22,8 @@ #include #include -#include +#include "ui/panelbase.h" #include "ui/tabbedpanel.h" class TestTabbedPanel : public QObject @@ -36,10 +36,10 @@ private slots: void TestTabbedPanel::testPanelToggling() { - TabbedPanel *testPanel = new TabbedPanel(); + TabbedPanel *testTabbedPanel = new TabbedPanel; - QWidget *testWidget = new QWidget(); - testPanel->addTab(testWidget, QIcon(":/res/images/user_info.png")); + PanelBase *testPanel = new PanelBase; + testTabbedPanel->addTab(testPanel, QIcon(":/res/images/user_info.png")); QSignalSpy closedSpy(testPanel, SIGNAL(panelClosed())); QSignalSpy openedSpy(testPanel, SIGNAL(panelOpened())); @@ -56,7 +56,7 @@ void TestTabbedPanel::testPanelToggling() QCOMPARE(toggleSpy.count(), 0); // Try to close the panel. As the panel is closed, no signals should be sent. - testPanel->closePanel(); + testTabbedPanel->closePanel(); QTest::qWait(1); QCOMPARE(closedSpy.count(), 0); QCOMPARE(openedSpy.count(), 0); @@ -67,7 +67,7 @@ void TestTabbedPanel::testPanelToggling() QCOMPARE(toggleSpy.count(), 0); // Now try to open the panel, only toggleState and panelOpened signals should be sent - testPanel->showPanel(testWidget); + testTabbedPanel->showPanel(testPanel); QTest::qWait(1); QCOMPARE(closedSpy.count(), 0); QCOMPARE(openedSpy.count(), 0); @@ -78,7 +78,7 @@ void TestTabbedPanel::testPanelToggling() QCOMPARE(toggleSpy.count(), 1); // Now try to open the panel again. As the panel is already open, no signals should not be sent. - testPanel->showPanel(testWidget); + testTabbedPanel->showPanel(testPanel); QTest::qWait(1); QCOMPARE(closedSpy.count(), 0); QCOMPARE(openedSpy.count(), 1); @@ -89,7 +89,7 @@ void TestTabbedPanel::testPanelToggling() QCOMPARE(toggleSpy.count(), 1); //Now try to close the panel, only toggleState and panelClosed signals should be sent - testPanel->closePanel(); + testTabbedPanel->closePanel(); QTest::qWait(1); QCOMPARE(closedSpy.count(), 0); QCOMPARE(openedSpy.count(), 1); @@ -99,8 +99,8 @@ void TestTabbedPanel::testPanelToggling() QCOMPARE(openedSpy.count(), 1); QCOMPARE(toggleSpy.count(), 2); - delete testWidget; delete testPanel; + delete testTabbedPanel; } QTEST_MAIN(TestTabbedPanel)