summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/kernel/qapplication.h1
-rw-r--r--src/gui/kernel/qapplication_s60.cpp56
-rw-r--r--src/gui/styles/qs60style.cpp26
-rw-r--r--src/s60main/qts60mainappui.cpp13
-rw-r--r--src/s60main/qts60mainappui.h7
-rw-r--r--tests/auto/symbian/orientationchange/orientationchange.pro7
-rw-r--r--tests/auto/symbian/orientationchange/tst_orientationchange.cpp165
-rw-r--r--tests/auto/symbian/qsymbiantests.pro2
8 files changed, 247 insertions, 30 deletions
diff --git a/src/gui/kernel/qapplication.h b/src/gui/kernel/qapplication.h
index f9559fa..6088780 100644
--- a/src/gui/kernel/qapplication.h
+++ b/src/gui/kernel/qapplication.h
@@ -234,6 +234,7 @@ public:
int s60ProcessEvent(TWsEvent *event);
virtual bool s60EventFilter(TWsEvent *aEvent);
void symbianHandleCommand(int command);
+ void s60ResourceChangeL(int type);
#endif
#if defined(Q_WS_QWS)
virtual bool qwsEventFilter(QWSEvent *);
diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp
index 7b1817f..dc2b9d3 100644
--- a/src/gui/kernel/qapplication_s60.cpp
+++ b/src/gui/kernel/qapplication_s60.cpp
@@ -649,21 +649,7 @@ void QSymbianControl::HandleResourceChange(int resourceType)
// font change event
break;
case KEikDynamicLayoutVariantSwitch:
- {
-#ifndef QT_NO_STYLE_S60
- QS60Style *s60Style = 0;
-
-#ifndef QT_NO_STYLE_STYLESHEET
- QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle*>(QApplication::style());
- if (proxy)
- s60Style = qobject_cast<QS60Style*>(proxy->baseStyle());
- else
-#endif
- s60Style = qobject_cast<QS60Style*>(QApplication::style());
-
- if (s60Style)
- s60Style->handleDynamicLayoutVariantSwitch();
-#endif
+ {
if (qwidget->isFullScreen()) {
SetExtentToWholeScreen();
} else if (qwidget->isMaximized()) {
@@ -672,12 +658,6 @@ void QSymbianControl::HandleResourceChange(int resourceType)
}
break;
}
-#ifndef QT_NO_STYLE_S60
- case KAknsMessageSkinChange:
- if (QS60Style *s60Style = qobject_cast<QS60Style*>(QApplication::style()))
- s60Style->handleSkinChange();
- break;
-#endif
default:
break;
}
@@ -1060,6 +1040,40 @@ void QApplication::symbianHandleCommand(int command)
}
}
+void QApplication::s60ResourceChangeL(int type)
+{
+ switch (type) {
+ case KEikDynamicLayoutVariantSwitch:
+ {
+#ifndef QT_NO_STYLE_S60
+ QS60Style *s60Style = 0;
+
+#ifndef QT_NO_STYLE_STYLESHEET
+ QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle*>(QApplication::style());
+ if (proxy)
+ s60Style = qobject_cast<QS60Style*>(proxy->baseStyle());
+ else
+#endif
+ s60Style = qobject_cast<QS60Style*>(QApplication::style());
+
+ if (s60Style)
+ s60Style->handleDynamicLayoutVariantSwitch();
+#endif
+ }
+ break;
+
+#ifndef QT_NO_STYLE_S60
+ case KAknsMessageSkinChange:
+ if (QS60Style *s60Style = qobject_cast<QS60Style*>(QApplication::style()))
+ s60Style->handleSkinChange();
+ break;
+#endif
+
+ default:
+ break;
+ }
+}
+
#ifndef QT_NO_WHEELEVENT
int QApplication::wheelScrollLines()
{
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index fde1cc6..3aaa839 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -119,6 +119,22 @@ static const int frameElementsCount =
const int KNotFound = -1;
+static void updateWidgets(const QList<QWidget *>& widgets)
+{
+ // This is based on updateWidgets in qstylesheetstyle.cpp.
+
+ for (int i = 0; i < widgets.size(); ++i) {
+ QWidget *widget = const_cast<QWidget *>(widgets.at(i));
+ if (widget == 0)
+ continue;
+ widget->style()->polish(widget);
+ QEvent event(QEvent::StyleChange);
+ qApp->sendEvent(widget, &event);
+ widget->update();
+ widget->updateGeometry();
+ }
+}
+
QS60StylePrivate::~QS60StylePrivate()
{
clearCaches(); //deletes also background image
@@ -584,14 +600,8 @@ QPixmap QS60StylePrivate::cachedFrame(SkinFrameElements frame, const QSize &size
}
void QS60StylePrivate::refreshUI()
-{
- foreach (QWidget *topLevelWidget, QApplication::allWidgets()) {
- topLevelWidget->updateGeometry();
- //todo: study how we can get rid of this. Apparently scrollbars cache pixelmetrics values, and we need them to update themselves
- // maybe styleChanged event is enough?
- //QCoreApplication::postEvent(topLevelWidget, new QEvent(QEvent::StyleChange));
- QCoreApplication::postEvent(topLevelWidget, new QResizeEvent(topLevelWidget->size(), topLevelWidget->size()));
- }
+{
+ updateWidgets(QApplication::allWidgets());
}
void QS60StylePrivate::setFont(QWidget *widget) const
diff --git a/src/s60main/qts60mainappui.cpp b/src/s60main/qts60mainappui.cpp
index 8467aef..f7e570b 100644
--- a/src/s60main/qts60mainappui.cpp
+++ b/src/s60main/qts60mainappui.cpp
@@ -76,6 +76,19 @@ void CQtS60MainAppUi::HandleCommandL( TInt aCommand )
qApp->symbianHandleCommand(aCommand);
}
+// -----------------------------------------------------------------------------
+// CQtS60MainAppUi::HandleResourceChangeL()
+// Takes care of event handling.
+// -----------------------------------------------------------------------------
+//
+void CQtS60MainAppUi::HandleResourceChangeL(TInt aType)
+{
+ CAknAppUi::HandleResourceChangeL(aType);
+
+ if (qApp)
+ qApp->s60ResourceChangeL(aType);
+}
+
void CQtS60MainAppUi::HandleWsEventL(const TWsEvent& aEvent, CCoeControl *control)
{
int result = 0;
diff --git a/src/s60main/qts60mainappui.h b/src/s60main/qts60mainappui.h
index 3addb0c..8124fa3 100644
--- a/src/s60main/qts60mainappui.h
+++ b/src/s60main/qts60mainappui.h
@@ -61,6 +61,13 @@ class CQtS60MainAppUi : public CAknAppUi
void HandleCommandL( TInt aCommand );
/**
+ * From CAknAppUi, HandleResourceChangeL
+ * Handles resource change events such as layout switches in global level.
+ * @param aType event type.
+ */
+ void HandleResourceChangeL(TInt aType);
+
+ /**
* HandleStatusPaneSizeChange.
* Called by the framework when the application status pane
* size is changed.
diff --git a/tests/auto/symbian/orientationchange/orientationchange.pro b/tests/auto/symbian/orientationchange/orientationchange.pro
new file mode 100644
index 0000000..d240fa1
--- /dev/null
+++ b/tests/auto/symbian/orientationchange/orientationchange.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+HEADERS +=
+SOURCES += tst_orientationchange.cpp
+
+symbian {
+ INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE
+}
diff --git a/tests/auto/symbian/orientationchange/tst_orientationchange.cpp b/tests/auto/symbian/orientationchange/tst_orientationchange.cpp
new file mode 100644
index 0000000..9d57ae1
--- /dev/null
+++ b/tests/auto/symbian/orientationchange/tst_orientationchange.cpp
@@ -0,0 +1,165 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+
+#ifdef Q_OS_SYMBIAN
+
+#include <eikenv.h>
+#include <aknappui.h>
+
+class tst_orientationchange : public QObject
+{
+ Q_OBJECT
+public:
+ tst_orientationchange(){};
+ ~tst_orientationchange(){};
+
+private slots:
+ void resizeEventOnOrientationChange();
+};
+
+class TestWidget : public QWidget
+{
+public:
+ TestWidget(QWidget *parent = 0);
+
+ void reset();
+public:
+ void resizeEvent(QResizeEvent *event);
+
+public:
+ QSize resizeEventSize;
+ int resizeEventCount;
+};
+
+TestWidget::TestWidget(QWidget *parent)
+: QWidget(parent)
+{
+ reset();
+}
+
+void TestWidget::reset()
+{
+ resizeEventSize = QSize();
+ resizeEventCount = 0;
+}
+
+void TestWidget::resizeEvent(QResizeEvent *event)
+{
+ QWidget::resizeEvent(event);
+
+ // Size delivered in first resize event is stored.
+ if (!resizeEventCount)
+ resizeEventSize = event->size();
+
+ resizeEventCount++;
+}
+
+void tst_orientationchange::resizeEventOnOrientationChange()
+{
+ // This will test that when orientation 'changes', then
+ // at most one resize event is generated.
+
+ TestWidget *normalWidget = new TestWidget();
+ TestWidget *fullScreenWidget = new TestWidget();
+ TestWidget *maximizedWidget = new TestWidget();
+
+ fullScreenWidget->showFullScreen();
+ maximizedWidget->showMaximized();
+ normalWidget->show();
+
+ QCoreApplication::sendPostedEvents();
+ QCoreApplication::sendPostedEvents();
+
+ QCOMPARE(fullScreenWidget->resizeEventCount, 1);
+ QCOMPARE(fullScreenWidget->size(), fullScreenWidget->resizeEventSize);
+ QCOMPARE(maximizedWidget->resizeEventCount, 1);
+ QCOMPARE(maximizedWidget->size(), maximizedWidget->resizeEventSize);
+ QCOMPARE(normalWidget->resizeEventCount, 1);
+ QCOMPARE(normalWidget->size(), normalWidget->resizeEventSize);
+
+ fullScreenWidget->reset();
+ maximizedWidget->reset();
+ normalWidget->reset();
+
+ // Assumes that Qt application is AVKON application.
+ CAknAppUi *appUi = static_cast<CAknAppUi*>(CEikonEnv::Static()->EikAppUi());
+
+ // Determine 'opposite' orientation to the current orientation.
+
+ CAknAppUi::TAppUiOrientation orientation = CAknAppUi::EAppUiOrientationLandscape;
+ if (fullScreenWidget->size().width() > fullScreenWidget->size().height()) {
+ orientation = CAknAppUi::EAppUiOrientationPortrait;
+ }
+
+ TRAPD(err, appUi->SetOrientationL(orientation));
+
+ QCoreApplication::sendPostedEvents();
+ QCoreApplication::sendPostedEvents();
+
+ // setOrientationL is not guaranteed to change orientation
+ // (if emulator configured to support just portrait or landscape, then
+ // setOrientationL call shouldn't do anything).
+ // So let's ensure that we do not get resize event twice.
+
+ QVERIFY(fullScreenWidget->resizeEventCount <= 1);
+ if (fullScreenWidget->resizeEventCount) {
+ QCOMPARE(fullScreenWidget->size(), fullScreenWidget->resizeEventSize);
+ }
+ QVERIFY(maximizedWidget->resizeEventCount <= 1);
+ if (fullScreenWidget->resizeEventCount) {
+ QCOMPARE(maximizedWidget->size(), maximizedWidget->resizeEventSize);
+ }
+ QCOMPARE(normalWidget->resizeEventCount, 0);
+
+ TRAP(err, appUi->SetOrientationL(CAknAppUi::EAppUiOrientationUnspecified));
+
+ delete normalWidget;
+ delete fullScreenWidget;
+ delete maximizedWidget;
+}
+
+QTEST_MAIN(tst_orientationchange)
+#include "tst_orientationchange.moc"
+#else
+QTEST_NOOP_MAIN
+#endif
diff --git a/tests/auto/symbian/qsymbiantests.pro b/tests/auto/symbian/qsymbiantests.pro
index 151d7ec..648335e 100644
--- a/tests/auto/symbian/qsymbiantests.pro
+++ b/tests/auto/symbian/qsymbiantests.pro
@@ -1,2 +1,2 @@
TEMPLATE = subdirs
-SUBDIRS = qmainexceptions \ No newline at end of file
+SUBDIRS = qmainexceptions orientationchange \ No newline at end of file