Skip to content

Commit

Permalink
Fixes: NB#287151 - §qtn_noti_and_more§ is not retranslated when the l…
Browse files Browse the repository at this point in the history
…anguage is changed on first boot

RevBy: Vesa Halttunen
Details:
 On first boot the UI language may change between the time system-ui starts
 and the screen lock window is created. Make sure the UI is retranslated by
 issuing a LanguageChange event after the window is created.
  • Loading branch information
Artem Egorkine committed Oct 25, 2011
1 parent b90f242 commit ee533cf
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 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.14~1) unstable; urgency=low

* [UNRELEASED]
* Fixes: NB#287151 - §qtn_noti_and_more§ is not retranslated when the language is changed on first boot

-- Vesa Halttunen <[email protected]> Tue, 25 Oct 2011 15:23:36 +0300

Expand Down
6 changes: 6 additions & 0 deletions src/systemui/screenlock/screenlockwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <MSceneWindow>
#include <QGraphicsLinearLayout>
#include <QX11Info>
#include <QApplication>
#include "x11wrapper.h"

ScreenLockWindow::ScreenLockWindow(MApplicationExtensionArea *extensionArea, QWidget *parent) :
Expand All @@ -44,6 +45,11 @@ ScreenLockWindow::ScreenLockWindow(MApplicationExtensionArea *extensionArea, QWi
screenLockWindow->setStyleName("ScreenLockWindow");
screenLockWindow->setLayout(layout);
screenLockWindow->appear(this);

// The language may have changed before the window was created,
// retranslate the UI
QEvent event(QEvent::LanguageChange);
QApplication::sendEvent(this, &event);
}

ScreenLockWindow::~ScreenLockWindow()
Expand Down
15 changes: 15 additions & 0 deletions tests/ut_screenlockwindow/ut_screenlockwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <MApplication>
#include <MSceneWindow>
#include <MApplicationExtensionArea>
#include <MFileDataStore>
#include <QShowEvent>
#include "ut_screenlockwindow.h"
#include "screenlockwindow.h"
Expand Down Expand Up @@ -72,6 +73,14 @@ void MSceneWindow::appear(MWindow* window, MSceneWindow::DeletionPolicy policy)
Q_UNUSED(policy);
}

int languageChangeEventSendCount = 0;
bool MWindow::event(QEvent *event)
{
if(event->type() == QEvent::LanguageChange) {
languageChangeEventSendCount++;
}
return false;
}

void Ut_ScreenLockWindow::initTestCase()
{
Expand Down Expand Up @@ -100,13 +109,19 @@ void Ut_ScreenLockWindow::cleanup()
mWindowOrientation.clear();
mWindowOrientationAngle = M::Angle180;
gX11WrapperStub->stubReset();
languageChangeEventSendCount = 0;
}

void Ut_ScreenLockWindow::testWhenWindowIsCreatedLockScreenAppears()
{
QCOMPARE(appearedWindow, lockScreenWindow);
}

void Ut_ScreenLockWindow::testWhenWindowIsCreatedLanguageChangeEventIsSent()
{
QCOMPARE(languageChangeEventSendCount, 1);
}

void Ut_ScreenLockWindow::testWhenWindowIsShownItIsExcludedFromTaskbar()
{
// The stub needs to be reset so that things done at construction time won't affect the test
Expand Down
1 change: 1 addition & 0 deletions tests/ut_screenlockwindow/ut_screenlockwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ private slots:
void cleanupTestCase();

void testWhenWindowIsCreatedLockScreenAppears();
void testWhenWindowIsCreatedLanguageChangeEventIsSent();
void testWhenWindowIsShownItIsExcludedFromTaskbar();
void testOrientationLocking_data();
void testOrientationLocking();
Expand Down

0 comments on commit ee533cf

Please sign in to comment.