Skip to content

Commit

Permalink
Fixes: NB#291715 - Shutdown screen uses almost one megabyte of extra …
Browse files Browse the repository at this point in the history
…memory for no reason

Bug: NB#291715 - Shutdown screen uses almost one megabyte of extra memory for no reason
RevBy: Anssi Eteläniemi
  • Loading branch information
Vesa Halttunen committed Nov 18, 2011
1 parent 7d9d377 commit d4bcfc0
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 63 deletions.
1 change: 1 addition & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
system-ui (1.2.18~1) unstable; urgency=low

* [UNRELEASED]
* Fixes: NB#291715 - Shutdown screen uses almost one megabyte of extra memory for no reason

-- Vesa Halttunen <[email protected]> Mon, 07 Nov 2011 18:40:23 +0200

Expand Down
54 changes: 26 additions & 28 deletions src/systemui/shutdownui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <MTheme>
#include <MLabel>
#include <MFeedback>
#include <MStylableWidget>
#include <MImageWidget>
#include <MSceneWindow>
#include <QTimer>
#include <QGraphicsLinearLayout>
Expand Down Expand Up @@ -86,14 +86,9 @@ void ShutdownUI::realize()
label2->setAlignment(Qt::AlignCenter);
label2->setObjectName("shutdownTextSecond");

// A full screen logo shown when the labels are already gone
logo = new MStylableWidget;
logo->setObjectName("shutdownLogo");

layout = new QGraphicsLinearLayout(Qt::Vertical);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);

layout->addItem(label1);
layout->addItem(label2);

Expand Down Expand Up @@ -123,28 +118,22 @@ void ShutdownUI::showWindow(const QString &text1, const QString &text2, int time
// If the widgets are not created create them now
realize();

// If the widgets have been created once but the labels are NULL the logo has already been shown so do nothing
if (label1 == NULL || label2 == NULL) {
return;
}

timer->stop();

if (!(text1.isEmpty() && text2.isEmpty())) {
// Set the labels to show the text strings that we got only if they exist
if (label1 != NULL) {
if (text1.startsWith("qtn")) {
label1->setText(qtTrId(text1.toLatin1().constData()));
} else {
label1->setText(text1);
}
}

if (label2 != NULL) {
if (text2.startsWith("qtn")) {
label2->setText(qtTrId(text2.toLatin1().constData()));
} else {
label2->setText(text2);
}
}
// Set the labels to show the received text strings
label1->setText(text1.startsWith("qtn") ? qtTrId(text1.toLatin1().constData()) : text1);
label2->setText(text2.startsWith("qtn") ? qtTrId(text2.toLatin1().constData()) : text2);

// Set the interval and start the timer to the next phase: hiding the labels and showing the logo
timer->start(timeout);
} else {
// No text to show so show the logo immediately
showLogo();
}

Expand All @@ -159,17 +148,26 @@ void ShutdownUI::showLogo()
{
timer->stop();

// Hide the labels and show the image
for (int i = layout->count(); i > 0; i--) {
layout->removeAt(0);
}
layout->addItem(logo);
// Create the logo and make it invisible until it's in the correct position
const ShutdownWindowStyle *style = static_cast<const ShutdownWindowStyle *>(MTheme::style("ShutdownWindowStyle"));
logo = new MImageWidget(style->image());
logo->setZoomFactor(1);
logo->hide();
MTheme::releaseStyle(style);

delete label1;
// Destroy the labels (which will also remove them from the layout), lower one first
delete label2;
delete label1;
label1 = NULL;
label2 = NULL;

// Make sure the logo is laid out to the correct position before showing it
layout->addStretch();
layout->addItem(logo);
layout->addStretch();
layout->activate();
logo->show();

QTimer::singleShot(2000, this, SLOT(turnOffScreen()));
}

Expand Down
4 changes: 2 additions & 2 deletions src/systemui/shutdownui.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
class MSceneWindow;
class MLabel;
class MFeedback;
class MStylableWidget;
class MImageWidget;
class QGraphicsLinearLayout;
class QTimer;

Expand Down Expand Up @@ -84,7 +84,7 @@ private slots:
QTimer *timer;
MLabel *label1;
MLabel *label2;
MStylableWidget *logo;
MImageWidget *logo;
QGraphicsLinearLayout *layout;
MFeedback *feedback;

Expand Down
3 changes: 3 additions & 0 deletions src/systemui/shutdownwindowstyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class ShutdownWindowStyle : public MStyle

// The locked orientation: "landscape", "portrait" or any other value for unlocked
M_STYLE_ATTRIBUTE(QString, lockedOrientation, LockedOrientation)

//! The ID of the image to be shown in the shutdown window
M_STYLE_ATTRIBUTE(QString, image, Image)
};

class ShutdownWindowStyleContainer : public MStyleContainer
Expand Down
28 changes: 18 additions & 10 deletions tests/ut_shutdownui/ut_shutdownui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <MApplication>
#include <MWindow>
#include <MNotification>
#include <MStylableWidget>
#include <MImageWidget>
#include <QGraphicsLinearLayout>

#ifdef HAVE_QMSYSTEM
Expand Down Expand Up @@ -152,14 +152,14 @@ void Ut_ShutdownUI::testInitialization()

void Ut_ShutdownUI::testRealize()
{
// Check that calling realize() will realize the widget
// Check that calling realize() will realize other widgets except the logo
m_subject->realize();
QVERIFY (m_subject->realized);
QVERIFY (m_subject->feedback);
QVERIFY (m_subject->label1);
QVERIFY (m_subject->label2);
QVERIFY (m_subject->logo);
QVERIFY (m_subject->sceneWindow);
QVERIFY(m_subject->realized);
QVERIFY(m_subject->feedback);
QVERIFY(m_subject->label1);
QVERIFY(m_subject->label2);
QVERIFY(m_subject->sceneWindow);
QCOMPARE(m_subject->logo, (MImageWidget*)NULL);
}

void Ut_ShutdownUI::testShowWindow()
Expand All @@ -179,12 +179,19 @@ void Ut_ShutdownUI::testShowWindow()

void Ut_ShutdownUI::testShowWindowWithEmptyStrings()
{
// Set the style
ShutdownWindowStyle *style = const_cast<ShutdownWindowStyle *>(static_cast<const ShutdownWindowStyle *>(MTheme::style("ShutdownWindowStyle", "", "", "", M::Landscape, NULL)));
style->setImage("test");

// Check that calling showWindow() will realize the widget and show logo
m_subject->showWindow("", "", 2000);

QVERIFY(m_subject->realized);
QVERIFY(m_subject->layout->itemAt(0) == m_subject->logo);
QCOMPARE(m_subject->realized, true);
QVERIFY(m_subject->logo != NULL);
QCOMPARE(m_subject->layout->itemAt(0), m_subject->logo);
QCOMPARE(m_subject->logo->imageId(), style->image());
QCOMPARE(gTimerStarted, false);
MTheme::releaseStyle(style);
}

void Ut_ShutdownUI::testOrientationLocking_data()
Expand Down Expand Up @@ -223,6 +230,7 @@ void Ut_ShutdownUI::testOrientationLocking()
QCOMPARE(mWindowOrientationAngleLocked, orientationLocked);
QCOMPARE(mWindowOrientation, expectedOrientation);
QCOMPARE(mWindowOrientationAngle, (M::OrientationAngle)expectedOrientationAngle);
MTheme::releaseStyle(style);
}

QTEST_APPLESS_MAIN(Ut_ShutdownUI)
24 changes: 1 addition & 23 deletions themes/style/shutdownscreen.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ShutdownWindowStyle {
locked-orientation: "portrait";
image: "icon-l-startup-nokia-logo-portrait";
}

MSceneWindowStyle#shutdownWindow {
Expand All @@ -17,26 +18,3 @@ MLabelStyle#shutdownTextSecond {
preferred-size: 100% 50%;
}

MWidgetStyle#shutdownLogo.Landscape {
background-image: "icon-l-startup-nokia-logo";
background-opacity: 1.0;

vertical-align: top;
horizontal-align: left;

minimum-size: 100% 100%;
preferred-size: 100% 100%;
maximum-size: 100% 100%;
}

MWidgetStyle#shutdownLogo.Portrait {
background-image: "icon-l-startup-nokia-logo-portrait";
background-opacity: 1.0;

vertical-align: top;
horizontal-align: left;

minimum-size: 100% 100%;
preferred-size: 100% 100%;
maximum-size: 100% 100%;
}

0 comments on commit d4bcfc0

Please sign in to comment.