From: Jussi Laitinen Date: Wed, 1 Sep 2010 11:18:51 +0000 (+0300) Subject: Added method to disable tabs. X-Git-Tag: v2.0b-1~19^2~8 X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;h=9a32369c091eda3a8f6406386737b13c2c087436;p=situare Added method to disable tabs. --- diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index 8b0ac3c..e36f76b 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -793,7 +793,6 @@ void SituareEngine::userDataChanged(User *user, QList &friendsList) qDebug() << __PRETTY_FUNCTION__; m_ui->toggleProgressIndicator(false); - m_ui->showPanels(); emit userLocationReady(user); emit friendsLocationsReady(friendsList); diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 0d4c574..3766c2c 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -324,8 +324,10 @@ void MainWindow::buildPanels() buildRoutingPanel(); m_tabbedPanel = new TabbedPanel(this); - m_tabbedPanel->addTab(m_userInfoPanel, QIcon(":/res/images/user_info.png")); - m_tabbedPanel->addTab(m_friendsListPanel, QIcon(":/res/images/friend_list.png")); + m_situareTabsIndexes.append( + m_tabbedPanel->addTab(m_userInfoPanel, QIcon(":/res/images/user_info.png"))); + m_situareTabsIndexes.append( + m_tabbedPanel->addTab(m_friendsListPanel, QIcon(":/res/images/friend_list.png"))); m_tabbedPanel->addTab(m_routingPanel, QIcon(":/res/images/routing.png")); connect(m_mapView, SIGNAL(viewResized(QSize)), @@ -952,25 +954,6 @@ void MainWindow::showInformationBox() } } -void MainWindow::showPanels() -{ - qDebug() << __PRETTY_FUNCTION__; - -///< @todo check how this is called and can this method be removed - -// if(m_loggedIn) { -// if(!m_friendsListPanel->isVisible()) { -// m_friendsListPanel->show(); -// m_friendsListPanelSidebar->show(); -// } - -// if(!m_userPanel->isVisible()) { -// m_userPanel->show(); -// m_userPanelSidebar->show(); -// } -// } -} - void MainWindow::startLocationSearch() { qDebug() << __PRETTY_FUNCTION__; @@ -1029,17 +1012,10 @@ void MainWindow::updateItemVisibility() { qDebug() << __PRETTY_FUNCTION__; -///< @todo can this be removed? - -// if(!m_loggedIn) { -// m_friendsListPanel->closePanel(); -// m_friendsListPanel->hide(); -// m_friendsListPanelSidebar->hide(); + if (!m_loggedIn) + m_tabbedPanel->closePanel(); -// m_userPanel->closePanel(); -// m_userPanel->hide(); -// m_userPanelSidebar->hide(); -// } + m_tabbedPanel->setTabsEnabled(m_situareTabsIndexes, m_loggedIn); } const QString MainWindow::username() diff --git a/src/ui/mainwindow.h b/src/ui/mainwindow.h index 044a1c4..5111c9e 100644 --- a/src/ui/mainwindow.h +++ b/src/ui/mainwindow.h @@ -198,11 +198,6 @@ public slots: void setUsername(const QString &username); /** - * @brief Method to show panels - */ - void showPanels(); - - /** * @brief Public slot to intercept signal when old cerdentials are invalid or credentials * doesn't exist yet */ @@ -674,6 +669,7 @@ private: QLabel *m_crosshair; ///< Label for center point crosshair QLabel *m_osmLicense; ///< Label for Open Street Map license + QList m_situareTabsIndexes; ///< List of Situare tab indexes QList m_error_queue; ///< QList type error dialog queue QList m_queue; ///< QList type dialog queue diff --git a/src/ui/paneltab.cpp b/src/ui/paneltab.cpp index 19b1240..b048f51 100644 --- a/src/ui/paneltab.cpp +++ b/src/ui/paneltab.cpp @@ -111,6 +111,8 @@ void PanelTab::paintEvent(QPaintEvent *event) icon().paint(&painter, m_tabRect, Qt::AlignCenter, QIcon::Selected); else if (isChecked()) icon().paint(&painter, m_tabRect, Qt::AlignCenter, QIcon::Normal); - else + else if (!isEnabled()) icon().paint(&painter, m_tabRect, Qt::AlignCenter, QIcon::Disabled); + else + icon().paint(&painter, m_tabRect, Qt::AlignCenter, QIcon::Normal); } diff --git a/src/ui/paneltabbar.cpp b/src/ui/paneltabbar.cpp index 7b7cdd5..2560886 100644 --- a/src/ui/paneltabbar.cpp +++ b/src/ui/paneltabbar.cpp @@ -128,3 +128,10 @@ void PanelTabBar::setUpTabLayout() emit sizeChangeRequested(); } + +QButtonGroup *PanelTabBar::tabs() const +{ + qDebug() << __PRETTY_FUNCTION__; + + return m_tabButtonGroup; +} diff --git a/src/ui/paneltabbar.h b/src/ui/paneltabbar.h index 35ed793..ddf170e 100644 --- a/src/ui/paneltabbar.h +++ b/src/ui/paneltabbar.h @@ -78,6 +78,13 @@ public: */ void removeTab(int index); + /** + * @brief Returns all tabs. + * + * @return All tabs + */ + QButtonGroup *tabs() const; + private: /** * @brief Initializes and formats tab buttons layout diff --git a/src/ui/tabbedpanel.cpp b/src/ui/tabbedpanel.cpp index 50f0344..15b87da 100644 --- a/src/ui/tabbedpanel.cpp +++ b/src/ui/tabbedpanel.cpp @@ -20,6 +20,8 @@ USA. */ +#include +#include #include #include #include @@ -256,6 +258,21 @@ void TabbedPanel::setCurrentIndex(int index) } } +void TabbedPanel::setTabsEnabled(const QList &tabIndexes, bool enabled) +{ + qDebug() << __PRETTY_FUNCTION__; + + QButtonGroup *tabs = m_panelTabBar->tabs(); + + foreach (int tabIndex, tabIndexes) { + + QAbstractButton *tabButton = tabs->button(tabIndex); + + if (tabButton) + tabButton->setEnabled(enabled); + } +} + void TabbedPanel::stateChanged() { qDebug() << __PRETTY_FUNCTION__; diff --git a/src/ui/tabbedpanel.h b/src/ui/tabbedpanel.h index d3e1f16..c65dbbc 100644 --- a/src/ui/tabbedpanel.h +++ b/src/ui/tabbedpanel.h @@ -95,6 +95,14 @@ public: */ void removeTab(int index); + /** + * @brief Sets tabs enabled. + * + * @param tabIndexes tab indexes to set + * @param enabled true if should be enabled, false otherwise + */ + void setTabsEnabled(const QList &tabIndexes, bool enabled); + public slots: /** * @brief Slot that closes the panel