Skip to content

Commit

Permalink
Changes: Use style names instead of object names on notification area
Browse files Browse the repository at this point in the history
RevBy: TrustMe
  • Loading branch information
Vesa Halttunen committed Dec 20, 2010
1 parent fdfd31d commit 1c0a3c5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
11 changes: 7 additions & 4 deletions src/systemui/statusindicatormenu/notificationareaview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ NotificationAreaView::NotificationAreaView(NotificationArea *controller) :

// Create the "and more" area
andMore->setStyleName("AndMore");
andMore->setVisible(false);
//% "And more"
MLabel *andMoreLabel = new MLabel(qtTrId("qtn_noti_and_more"));
andMoreLabel->setObjectName("AndMoreLabel");
andMoreLabel->setStyleName("AndMoreLabel");
QGraphicsLinearLayout *andMoreLayout = new QGraphicsLinearLayout(Qt::Horizontal);
andMoreLayout->setContentsMargins(0, 0, 0, 0);
andMoreLayout->setSpacing(0);
Expand All @@ -67,7 +68,7 @@ NotificationAreaView::NotificationAreaView(NotificationArea *controller) :
// Put a clear button into the clear button layout
clearButtonLayout->setContentsMargins(0, 0, 0, 0);
clearButtonLayout->setSpacing(0);
clearButton->setObjectName("NotificationAreaClearButton");
clearButton->setStyleName("NotificationAreaClearButton");
connect(clearButton, SIGNAL(clicked()), controller, SLOT(removeAllRemovableBanners()));
clearButtonLayout->addStretch();
clearButtonLayout->addItem(clearButton);
Expand Down Expand Up @@ -119,10 +120,12 @@ void NotificationAreaView::updateLayout()
}

// If there are more than maximum number of banners to be added show "and more"
andMore->setStyleName((style()->maxBanners() >= 0 && model()->banners().count() > style()->maxBanners()) ? "AndMoreVisible" : "AndMore");
bool andMoreVisible = style()->maxBanners() >= 0 && model()->banners().count() > style()->maxBanners();
andMore->setStyleName(andMoreVisible ? "AndMoreVisible" : "AndMore");
andMore->setVisible(andMoreVisible);

// If removable banners exist make the clear button visible
clearButton->setObjectName((removableBannersExist && style()->clearButton()) ? "NotificationAreaClearButtonVisible" : "NotificationAreaClearButton");
clearButton->setStyleName((removableBannersExist && style()->clearButton()) ? "NotificationAreaClearButtonVisible" : "NotificationAreaClearButton");
}

M_REGISTER_VIEW_NEW(NotificationAreaView, NotificationArea)
10 changes: 6 additions & 4 deletions tests/ut_notificationareaview/ut_notificationareaview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void Ut_NotificationAreaView::testAddClearButton()
notificationArea->model()->setBanners(banners);

QCOMPARE(m_subject->bannerLayout->count(), numRemovableBanners + numNonRemovableBanners);
QCOMPARE(m_subject->clearButton->objectName(), clearButtonExists ? QString("NotificationAreaClearButtonVisible") : QString("NotificationAreaClearButton"));
QCOMPARE(m_subject->clearButton->styleName(), clearButtonExists ? QString("NotificationAreaClearButtonVisible") : QString("NotificationAreaClearButton"));
}

void Ut_NotificationAreaView::testRemoveClearButton()
Expand All @@ -118,7 +118,7 @@ void Ut_NotificationAreaView::testRemoveClearButton()
notificationArea->model()->setBanners(banners);
banners.clear();
notificationArea->model()->setBanners(banners);
QCOMPARE(m_subject->clearButton->objectName(), QString("NotificationAreaClearButton"));
QCOMPARE(m_subject->clearButton->styleName(), QString("NotificationAreaClearButton"));
}

void Ut_NotificationAreaView::testClearButtonStyle_data()
Expand All @@ -140,7 +140,7 @@ void Ut_NotificationAreaView::testClearButtonStyle()
banners << createBanner(true);

notificationArea->model()->setBanners(banners);
QCOMPARE(m_subject->clearButton->objectName(), QString(clearButtonEnabled ? "NotificationAreaClearButtonVisible" : "NotificationAreaClearButton"));
QCOMPARE(m_subject->clearButton->styleName(), QString(clearButtonEnabled ? "NotificationAreaClearButtonVisible" : "NotificationAreaClearButton"));
}

void Ut_NotificationAreaView::testMaxBannersStyle_data()
Expand Down Expand Up @@ -168,7 +168,9 @@ void Ut_NotificationAreaView::testMaxBannersStyle()

notificationArea->model()->setBanners(banners);
QCOMPARE(m_subject->bannerLayout->count(), maxBanners >= 0 ? maxBanners : 10);
QCOMPARE(m_subject->andMore->styleName(), QString(maxBanners >= 0 && banners.count() > maxBanners ? "AndMoreVisible" : "AndMore"));
bool andMoreVisible = maxBanners >= 0 && banners.count() > maxBanners;
QCOMPARE(m_subject->andMore->styleName(), QString(andMoreVisible ? "AndMoreVisible" : "AndMore"));
QCOMPARE(m_subject->andMore->isVisible(), andMoreVisible);
}

QTEST_APPLESS_MAIN(Ut_NotificationAreaView)

0 comments on commit 1c0a3c5

Please sign in to comment.