void StatusBarBattery::setBatteryLevelText(int percent) { if(!Settings::LunaSettings()->tabletUi || !m_showBatteryText) return; char text[5]; if(percent >= 0 && percent <= 100) { sprintf(text, "%d%%", percent); } else{ sprintf(text, " ? "); } QFontMetrics fontMetrics(*m_font); m_batteryText = QString(text); QRect textBounds = fontMetrics.boundingRect(m_batteryText); if((m_textWidth != textBounds.width()) || (m_textHeight != textBounds.height())) { m_textWidth = textBounds.width(); m_textHeight = textBounds.height(); int width = m_textWidth + m_imgWidth; int height = m_imgHeight; prepareGeometryChange(); m_bounds = QRectF(-width/2, -height/2, width, height); Q_EMIT signalBoundingRectChanged(); } update(); }
void StatusBarItemGroup::layoutLeft() { int width=0; int currLeft; QRect rect; if(m_hasArrow && m_arrowPix && !m_arrowPix->isNull() && (m_arrowAnimProg > 0.0)) { width = m_arrowPix->width() + ARROW_SPACING; } if(m_separatorPix && !m_separatorPix->isNull()) { width += m_separatorPix->width(); // + ITEM_SPACING; } for(int x = 0; x < m_items.size(); x++) { StatusBarItem* item = m_items.at(x); if(item) { width += item->boundingRect().width() + ITEM_SPACING; } } rect = QRect(0, -m_height/2, width, m_height); currLeft = 0; for(int x = 0; x < m_items.size(); x++) { StatusBarItem* item = m_items.at(x); if(item) { StatusBarItem::Alignment align = item->alignment(); if(x > 0) currLeft += ITEM_SPACING; if(align == AlignLeft) { item->setPos(currLeft, 0); } else if(align == AlignRight) { item->setPos(currLeft + item->boundingRect().width(), 0); } else { item->setPos(currLeft + item->boundingRect().width()/2, 0); } currLeft += item->boundingRect().width(); } } if(rect != m_bounds) { prepareGeometryChange(); m_bounds = rect; Q_EMIT signalBoundingRectChanged(); } update(); }
void StatusBarItemGroup::addItem(StatusBarItem* item) { if(!item) return; item->setParentItem(this); m_items.append(item); connect(item,SIGNAL(signalBoundingRectChanged()), this, SLOT(slotChildBoundingRectChanged())); layout(); }
void StatusBarItemGroup::layoutCenter() { int width=0; int currRight; QRect rect; if(m_hasArrow && m_arrowPix && !m_arrowPix->isNull() && (m_arrowAnimProg > 0.0)) { width = m_arrowPix->width() + 2.0 * ARROW_SPACING; } for(int x = 0; x < m_items.size(); x++) { QGraphicsObject* item = m_items.at(x); if(item) { width += item->boundingRect().width() + ITEM_SPACING; } } rect = QRect(-width/2, -m_height/2, width, m_height); currRight = width/2; if(m_hasArrow && m_arrowPix && !m_arrowPix->isNull() && (m_arrowAnimProg > 0.0)) { currRight -=m_arrowPix->width() + 2.0 * ARROW_SPACING; } for(int x = 0; x < m_items.size(); x++) { StatusBarItem* item = m_items.at(x); if(item) { StatusBarItem::Alignment align = item->alignment(); if(align == AlignRight) { item->setPos(currRight, 0); } else if(align == AlignLeft) { item->setPos(currRight - item->boundingRect().width(), 0); } else { item->setPos(currRight - item->boundingRect().width()/2, 0); } currRight -= item->boundingRect().width() + ITEM_SPACING; } } if(rect != m_bounds) { prepareGeometryChange(); m_bounds = rect; Q_EMIT signalBoundingRectChanged(); } update(); }
void StatusBarClock::setDisplayDate(bool date) { m_displayDate = date; m_clockTimer->stop(); // Calculate the max width if(!m_displayDate) { setTimeText("00:00", false); m_clockTimer->start (1000); } else { setTimeText("00/00/00", false); m_clockTimer->start (60000); } prepareGeometryChange(); m_bounds = QRect(-m_textRect.width()/2 - m_textPadding, -m_textRect.height()/2, m_textRect.width() + m_textPadding * 2, m_textRect.height()); Q_EMIT signalBoundingRectChanged(); ::memset(&m_lastUpdateTime, 0, sizeof(m_lastUpdateTime)); tick(); }
StatusBar::StatusBar(StatusBarType type, int width, int height) : m_type(type) , m_showRssiIndicators(false) , m_rssiIndex(RSSI_0) , m_rssi1xIndex(RSSI_1X_0) , m_rssiShown(false) , m_rssi1xShown(false) , m_appMaximized(false) , m_showAppTitle(false) , m_svcConnector(0) , m_bkgPixmap(0) , m_battery(0) , m_clock(0) , m_title(0) , m_infoItems(0) , m_notif(0) , m_systemUiGroup(0) , m_titleGroup(0) , m_notifGroup(0) , m_forceOpaque(false) , m_platformHasPhoneRadio(false) { m_carrierText = kDefaultCarrierName; m_appTitle = " "; m_bounds = QRect(-width/2, -height/2, width, height); // Charging icon m_battery = new StatusBarBattery(); unsigned int clockPadding = 0; if(m_type == TypeDockMode) clockPadding = 5; // Text for clock m_clock = new StatusBarClock(clockPadding); m_infoItems = new StatusBarInfo(m_type); // Title Bar (a value of true on the third arg turns on non-tablet UI) m_title = new StatusBarTitle(Settings::LunaSettings()->statusBarTitleMaxWidth, height, false); if(Settings::LunaSettings()->tabletUi) { m_systemUiGroup = new StatusBarItemGroup(height, (m_type == TypeNormal || m_type == TypeDockMode), (m_type == TypeNormal || m_type == TypeDockMode), StatusBarItemGroup::AlignRight); connect(m_systemUiGroup, SIGNAL(signalBoundingRectChanged()), this, SLOT(slotChildBoundingRectChanged())); connect(m_systemUiGroup, SIGNAL(signalActivated(StatusBarItemGroup*)), this, SLOT(slotMenuGroupActivated(StatusBarItemGroup*))); m_systemUiGroup->setParentItem(this); if(m_clock) { if (m_type == TypeLockScreen) m_clock->setParentItem(this); else m_systemUiGroup->addItem(m_clock); } m_systemUiGroup->addItem(m_battery); m_systemUiGroup->addItem(m_infoItems); m_titleGroup = new StatusBarItemGroup(height, (m_type == TypeNormal || m_type == TypeDockMode), (m_type == TypeNormal || m_type == TypeDockMode), StatusBarItemGroup::AlignLeft); connect(m_titleGroup, SIGNAL(signalBoundingRectChanged()), this, SLOT(slotChildBoundingRectChanged())); connect(m_titleGroup, SIGNAL(signalActivated(StatusBarItemGroup*)), this, SLOT(slotMenuGroupActivated(StatusBarItemGroup*))); m_titleGroup->setParentItem(this); m_titleGroup->addItem(m_title); if(m_type == TypeNormal || m_type == TypeDockMode || m_type == TypeFirstUse) { m_titleGroup->setActionable(false); connect(m_titleGroup, SIGNAL(signalActionTriggered(bool)), this, SLOT(slotAppMenuMenuAction(bool))); }