From 5c9552df87e57de2fa4be0fa68c4aea30caf71c5 Mon Sep 17 00:00:00 2001 From: Pekka Nissinen Date: Tue, 17 Aug 2010 10:16:53 +0300 Subject: [PATCH] Removed a few constants from panelcommon.h (that really weren't common at all) and moved them to appropriate places --- src/ui/friendlistpanel.cpp | 3 +++ src/ui/mainwindow.h | 1 - src/ui/panelcommon.h | 20 +------------------- src/ui/panelcontentstack.cpp | 10 ++++++---- src/ui/panelcontentstack.h | 2 +- src/ui/paneltab.cpp | 2 ++ src/ui/paneltabbar.cpp | 33 ++++++++++++++++++++------------- src/ui/paneltabbar.h | 6 ++++++ src/ui/tabbedpanel.cpp | 7 ++++++- 9 files changed, 45 insertions(+), 39 deletions(-) diff --git a/src/ui/friendlistpanel.cpp b/src/ui/friendlistpanel.cpp index 49cbae4..a1bd15e 100644 --- a/src/ui/friendlistpanel.cpp +++ b/src/ui/friendlistpanel.cpp @@ -38,6 +38,9 @@ FriendListPanel::FriendListPanel(QWidget *parent) { qDebug() << __PRETTY_FUNCTION__; + const int FRIENDPANEL_FILTER_MARGIN_LEFT = PANEL_MARGIN_LEFT + 4; + const int FRIENDPANEL_FILTER_MARGIN_RIGHT = PANEL_MARGIN_RIGHT + MAEMO5_SCROLLBAR_WIDTH + 4; + QVBoxLayout *friendListPanelLayout = new QVBoxLayout(); friendListPanelLayout->setMargin(0); friendListPanelLayout->setSpacing(0); diff --git a/src/ui/mainwindow.h b/src/ui/mainwindow.h index ab87f39..c928aea 100644 --- a/src/ui/mainwindow.h +++ b/src/ui/mainwindow.h @@ -201,7 +201,6 @@ public slots: /** * @brief Public slot to intercept signal when old cerdentials are invalid or credentials * doesn't exist yet - * */ void startLoginProcess(); diff --git a/src/ui/panelcommon.h b/src/ui/panelcommon.h index 32b22a4..ccafaa3 100644 --- a/src/ui/panelcommon.h +++ b/src/ui/panelcommon.h @@ -26,7 +26,7 @@ #include -#include "../common.h" +#include "common.h" // Dragging settings const int DRAG_INIT_TIME = 1000; ///< How long buttons must be pressed to start drag mode @@ -50,24 +50,6 @@ const int PANEL_MARGIN_RIGHT = 0; ///< Panel inner margin (r const int PANEL_MARGIN_TOP = 0; ///< Panel inner margin (top) const int PANEL_MARGIN_BOTTOM = 0; ///< Panel inner margin (bottom) -/** - * @brief Friend list filter bar margin (left) - * - * @var FRIENDPANEL_FILTER_MARGIN_LEFT - */ -///< @todo not really commom -const int FRIENDPANEL_FILTER_MARGIN_LEFT = PANEL_MARGIN_LEFT + 4; - -/** - * @brief Friend list filter bar margin (right) - * - * @var FRIENDPANEL_FILTER_MARGIN_RIGHT - */ -///< @todo not really common -const int FRIENDPANEL_FILTER_MARGIN_RIGHT = PANEL_MARGIN_RIGHT + MAEMO5_SCROLLBAR_WIDTH + 4; - -const int SHOW_ALL_BUTTON_RIGHT_MARGIN = 39; ///< Show all button right margin - const int PANEL_CLOSED_X = DEFAULT_SCREEN_WIDTH - PANEL_TAB_WIDTH - PANEL_BAR_WIDTH; ///< Horizontal position of a closed panel diff --git a/src/ui/panelcontentstack.cpp b/src/ui/panelcontentstack.cpp index d59e401..36a5057 100644 --- a/src/ui/panelcontentstack.cpp +++ b/src/ui/panelcontentstack.cpp @@ -32,12 +32,14 @@ PanelContentStack::PanelContentStack(QWidget *parent) { qDebug() << __PRETTY_FUNCTION__; + const QColor SEMI_TRANSPARENT_BLACK = QColor(0, 0, 0, 128); + resize(PANEL_WIDTH, PANEL_HEIGHT); m_menuDropShadowTile.load(":res/images/menu_bar_drop_shadow.png"); QPalette pal = palette(); - pal.setColor(QPalette::Background, QColor(0, 0, 0, 128)); + pal.setColor(QPalette::Background, SEMI_TRANSPARENT_BLACK); setPalette(pal); setAutoFillBackground(true); } @@ -49,12 +51,12 @@ void PanelContentStack::paintEvent(QPaintEvent *event) Q_UNUSED(event); QPainter painter(this); - - QRect shadowRect = QRect(0, 0, this->rect().width(), m_menuDropShadowTile.height()); + ///< @todo magic + QRect shadowRect = QRect(0, 0, rect().width(), m_menuDropShadowTile.height()); painter.drawTiledPixmap(shadowRect, m_menuDropShadowTile); } -void PanelContentStack::resizePanelContentStack(const QSize &size) +void PanelContentStack::resizeContentStack(const QSize &size) { qDebug() << __PRETTY_FUNCTION__; diff --git a/src/ui/panelcontentstack.h b/src/ui/panelcontentstack.h index fe284f5..9f93a65 100644 --- a/src/ui/panelcontentstack.h +++ b/src/ui/panelcontentstack.h @@ -63,7 +63,7 @@ public slots: * * @param size Size of the new window */ - void resizePanelContentStack(const QSize &size); + void resizeContentStack(const QSize &size); /******************************************************************************* * DATA MEMBERS diff --git a/src/ui/paneltab.cpp b/src/ui/paneltab.cpp index 12fad9b..d12bc3d 100644 --- a/src/ui/paneltab.cpp +++ b/src/ui/paneltab.cpp @@ -97,9 +97,11 @@ void PanelTab::paintEvent(QPaintEvent *event) QPainter painter(this); if (isChecked()) { + ///< @todo magic m_tabRect.setRect(0, 0, TAB_WIDTH_ACTIVE, TAB_HEIGHT); painter.drawPixmap(m_tabRect, m_tabActiveImage); } else { + ///< @todo magic m_tabRect.setRect(TAB_WIDTH_ACTIVE - TAB_WIDTH, 0, TAB_WIDTH, TAB_HEIGHT); painter.drawPixmap(m_tabRect, m_tabInactiveImage); } diff --git a/src/ui/paneltabbar.cpp b/src/ui/paneltabbar.cpp index 4decac6..e21d63f 100644 --- a/src/ui/paneltabbar.cpp +++ b/src/ui/paneltabbar.cpp @@ -26,9 +26,11 @@ #include "paneltabbar.h" +const int NO_ACTIVE_TABS = -1; + PanelTabBar::PanelTabBar(QWidget *parent) : QWidget(parent), - m_activeTab(-1) ///< @todo magic + m_activeTab(NO_ACTIVE_TABS) { qDebug() << __PRETTY_FUNCTION__; @@ -60,19 +62,10 @@ int PanelTabBar::insertTab(int index, const QIcon& icon) { qDebug() << __PRETTY_FUNCTION__; - const int TAB_BAR_TOP_SPACING = 8; - - int verticalStartPoint = TAB_BAR_TOP_SPACING; - m_tabButtonGroup->addButton(new PanelTab(this), index); m_tabButtonGroup->button(index)->setIcon(icon); - ///< @todo [BEGIN]: Purkkaa (to be removed ASAP!!!) - if (index > 0) - verticalStartPoint += 65 * index; - - m_tabButtonGroup->button(index)->move(0, verticalStartPoint); - // [END]: Purkkaa + setUpTabLayout(); return index; } @@ -84,6 +77,8 @@ void PanelTabBar::removeTab(int index) if (QAbstractButton *tab = m_tabButtonGroup->button(index)) { m_tabButtonGroup->removeButton(tab); delete tab; + + setUpTabLayout(); } } @@ -100,11 +95,23 @@ void PanelTabBar::setCurrentIndex(int index) qDebug() << __PRETTY_FUNCTION__; if (m_activeTab == index) { - ///< @todo magic - m_activeTab = -1; + m_activeTab = NO_ACTIVE_TABS; emit tabCloseRequested(index); } else { m_activeTab = index; emit currentChanged(index); } } + +void PanelTabBar::setUpTabLayout() +{ + qDebug() << __PRETTY_FUNCTION__; + + const int TAB_BUTTON_STEPPING = 65; + + QList tabList = m_tabButtonGroup->buttons(); + + for (int i = 0; i < tabList.size(); i ++) { + tabList.at(i)->move(0, i * TAB_BUTTON_STEPPING); + } +} diff --git a/src/ui/paneltabbar.h b/src/ui/paneltabbar.h index 6714abd..17da9f4 100644 --- a/src/ui/paneltabbar.h +++ b/src/ui/paneltabbar.h @@ -78,6 +78,12 @@ public: */ void removeTab(int index); +private: + /** + * @brief Initializes and formats tab buttons layout + */ + void setUpTabLayout(); + public slots: /** * @brief This slot is used to clear tab selections diff --git a/src/ui/tabbedpanel.cpp b/src/ui/tabbedpanel.cpp index 0e28947..b4ee1d6 100644 --- a/src/ui/tabbedpanel.cpp +++ b/src/ui/tabbedpanel.cpp @@ -38,11 +38,14 @@ TabbedPanel::TabbedPanel(QWidget *parent) { qDebug() << __PRETTY_FUNCTION__; + const int TAB_BAR_TOP_SPACING = 8; + resize(PANEL_BAR_TABBED_WIDTH + PANEL_WIDTH, PANEL_HEIGHT); move(PANEL_CLOSED_X, PANEL_TOP_PADDING); // --- TABS --- m_panelTabBar = new PanelTabBar(this); + m_panelTabBar->move(0, TAB_BAR_TOP_SPACING); connect(m_panelTabBar, SIGNAL(currentChanged(int)), this, SLOT(setCurrentIndex(int))); @@ -55,10 +58,12 @@ TabbedPanel::TabbedPanel(QWidget *parent) // --- BAR --- m_panelBar = new PanelBar(this); + ///< @todo magic m_panelBar->move(PANEL_TAB_WIDTH, 0); // --- PANEL CONTENT --- m_panelContentStack = new PanelContentStack(this); + ///< @todo magic m_panelContentStack->move(PANEL_TAB_WIDTH + PANEL_BAR_WIDTH, 0); // --- PANEL ANIMATION --- @@ -141,7 +146,7 @@ void TabbedPanel::resizePanel(const QSize &size) m_panelBar->resizeBar(size); - m_panelContentStack->resizePanelContentStack(size); + m_panelContentStack->resizeContentStack(size); QPoint closedPosition(size.width() - PANEL_TAB_WIDTH - PANEL_BAR_WIDTH, PANEL_TOP_PADDING); m_panelStateClosed->assignProperty(this, "pos", closedPosition); -- 1.7.9.5