From 972bdcf241a78ae655b536d3822a4d89837f7963 Mon Sep 17 00:00:00 2001 From: axis Date: Thu, 7 Jan 2010 16:01:58 +0100 Subject: Added a flag to avoid construction of application panes. This is purely an optimization for fullscreen-only apps. Task: QTBUG-6098 RevBy: Jason Barron RevBy: mread AutoTest: Included (cherry picked from commit 4a84b272459160780529f654e6aee3abf8569b51) --- src/corelib/global/qnamespace.h | 1 + src/corelib/global/qnamespace.qdoc | 6 ++ src/gui/dialogs/qdialog.cpp | 9 ++- src/gui/kernel/qsoftkeymanager.cpp | 3 +- src/gui/s60framework/qs60mainappui.cpp | 12 +++- tests/auto/qapplication/heart.svg | 55 +++++++++++++++++ tests/auto/qapplication/test/test.pro | 4 +- tests/auto/qapplication/tst_qapplication.cpp | 88 ++++++++++++++++++++++++++++ 8 files changed, 172 insertions(+), 6 deletions(-) create mode 100644 tests/auto/qapplication/heart.svg diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index ef73e2f..a5b6705 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -511,6 +511,7 @@ public: AA_MacPluginApplication = 5, AA_DontUseNativeMenuBar = 6, AA_MacDontSwapCtrlAndMeta = 7, + AA_S60DontConstructApplicationPanes = 8, // Add new attributes before this line AA_AttributeCount diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 93950eb..e40e51b 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -164,6 +164,12 @@ Command+C on the keyboard regardless of the value set, though what is output for QKeySequence::toString(QKeySequence::PortableText) will be different). + \value AA_S60DontConstructApplicationPanes Stops Qt from initializing the S60 status + pane and softkey pane on Symbian. This is useful to save memory and reduce + startup time for applications that will run in fullscreen mode during their + whole lifetime. This attribute must be set before QApplication is + constructed. + \omitvalue AA_AttributeCount */ diff --git a/src/gui/dialogs/qdialog.cpp b/src/gui/dialogs/qdialog.cpp index 7bffdba..a5b19f5 100644 --- a/src/gui/dialogs/qdialog.cpp +++ b/src/gui/dialogs/qdialog.cpp @@ -888,7 +888,14 @@ bool QDialog::s60AdjustedPosition() if (doS60Positioning) { // naive way to deduce screen orientation if (S60->screenHeightInPixels > S60->screenWidthInPixels) { - p.setY(S60->screenHeightInPixels-height()-qt_TSize2QSize(S60->buttonGroupContainer()->Size()).height()); + int cbaHeight; + const CEikButtonGroupContainer* bgContainer = S60->buttonGroupContainer(); + if (!bgContainer) { + cbaHeight = 0; + } else { + cbaHeight = qt_TSize2QSize(bgContainer->Size()).height(); + } + p.setY(S60->screenHeightInPixels-height()-cbaHeight); p.setX(0); } else { const int scrollbarWidth = style()->pixelMetric(QStyle::PM_ScrollBarExtent); diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp index 41d2108..8f21da8 100644 --- a/src/gui/kernel/qsoftkeymanager.cpp +++ b/src/gui/kernel/qsoftkeymanager.cpp @@ -211,7 +211,8 @@ bool QSoftKeyManager::event(QEvent *e) void QSoftKeyManagerPrivate::updateSoftKeys_sys(const QList &softkeys) { // lets not update softkeys if s60 native dialog or menu is shown - if (CCoeEnv::Static()->AppUi()->IsDisplayingMenuOrDialog()) + if (QApplication::testAttribute(Qt::AA_S60DontConstructApplicationPanes) + || CCoeEnv::Static()->AppUi()->IsDisplayingMenuOrDialog()) return; CEikButtonGroupContainer* nativeContainer = S60->buttonGroupContainer(); diff --git a/src/gui/s60framework/qs60mainappui.cpp b/src/gui/s60framework/qs60mainappui.cpp index 0ace481..f0cceaf 100644 --- a/src/gui/s60framework/qs60mainappui.cpp +++ b/src/gui/s60framework/qs60mainappui.cpp @@ -104,10 +104,16 @@ void QS60MainAppUi::ConstructL() // ENoAppResourceFile and ENonStandardResourceFile makes UI to work without // resource files in most SDKs. S60 3rd FP1 public seems to require resource file // even these flags are defined - BaseConstructL(CAknAppUi::EAknEnableSkin); + TInt flags = CAknAppUi::EAknEnableSkin; + if (QApplication::testAttribute(Qt::AA_S60DontConstructApplicationPanes)) { + flags |= CAknAppUi::ENoScreenFurniture | CAknAppUi::ENonStandardResourceFile; + } + BaseConstructL(flags); - CEikButtonGroupContainer* nativeContainer = Cba(); - nativeContainer->SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY_WITH_IDS); + if (!QApplication::testAttribute(Qt::AA_S60DontConstructApplicationPanes)) { + CEikButtonGroupContainer* nativeContainer = Cba(); + nativeContainer->SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY_WITH_IDS); + } } /*! diff --git a/tests/auto/qapplication/heart.svg b/tests/auto/qapplication/heart.svg new file mode 100644 index 0000000..8c982cd --- /dev/null +++ b/tests/auto/qapplication/heart.svg @@ -0,0 +1,55 @@ + + + + + +Heart Left-Highlight +This is a normal valentines day heart. + + +holiday +valentines + +valentine +hash(0x8a091c0) +hash(0x8a0916c) +signs_and_symbols +hash(0x8a091f0) +day + + + + +Jon Phillips + + + + +Jon Phillips + + + + +Jon Phillips + + + +image/svg+xml + + +en + + + + + + + + + + + + + + + diff --git a/tests/auto/qapplication/test/test.pro b/tests/auto/qapplication/test/test.pro index 7c3de3c..e68af26 100644 --- a/tests/auto/qapplication/test/test.pro +++ b/tests/auto/qapplication/test/test.pro @@ -16,7 +16,9 @@ symbian*: { additional.path = desktopsettingsaware someTest.sources = test.pro someTest.path = test - DEPLOYMENT = additional deploy someTest + windowIcon.sources = ../heart.svg + DEPLOYMENT = additional deploy someTest windowIcon + LIBS += -lcone -lavkon } win32 { diff --git a/tests/auto/qapplication/tst_qapplication.cpp b/tests/auto/qapplication/tst_qapplication.cpp index 31b56c5..83add97 100644 --- a/tests/auto/qapplication/tst_qapplication.cpp +++ b/tests/auto/qapplication/tst_qapplication.cpp @@ -53,6 +53,9 @@ #ifdef Q_OS_WINCE #include #endif +#ifdef Q_OS_SYMBIAN +#include +#endif //TESTED_CLASS= //TESTED_FILES= @@ -138,6 +141,8 @@ private slots: void touchEventPropagation(); + void symbianNoApplicationPanes(); + void symbianNeedForTraps(); void symbianLeaveThroughMain(); }; @@ -2036,6 +2041,89 @@ void tst_QApplication::touchEventPropagation() } } +void tst_QApplication::symbianNoApplicationPanes() +{ +#ifndef Q_OS_SYMBIAN + QSKIP("This is a Symbian only test", SkipAll); +#else + QApplication::setAttribute(Qt::AA_S60DontConstructApplicationPanes); + + // Run in a block so that QApplication is destroyed before resetting the attribute. + { + // Actually I wasn't able to get the forced orientation change to work properly, + // but I'll leave the code here for the future in case we manage to test that + // later. If someone knows how to force an orientation switch in an autotest, do + // feel free to fix this testcase. + int argc = 0; + QApplication app(argc, 0); + QWidget *w; + + w = new QWidget; + w->show(); + QT_TRAP_THROWING(static_cast(CCoeEnv::Static()->AppUi()) + ->SetOrientationL(CAknAppUi::EAppUiOrientationLandscape)); + app.processEvents(); + delete w; + + w = new QWidget; + w->show(); + QT_TRAP_THROWING(static_cast(CCoeEnv::Static()->AppUi()) + ->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait)); + app.processEvents(); + delete w; + + w = new QWidget; + w->showMaximized(); + QT_TRAP_THROWING(static_cast(CCoeEnv::Static()->AppUi()) + ->SetOrientationL(CAknAppUi::EAppUiOrientationLandscape)); + app.processEvents(); + delete w; + + w = new QWidget; + w->showMaximized(); + QT_TRAP_THROWING(static_cast(CCoeEnv::Static()->AppUi()) + ->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait)); + app.processEvents(); + delete w; + + w = new QWidget; + w->showFullScreen(); + QT_TRAP_THROWING(static_cast(CCoeEnv::Static()->AppUi()) + ->SetOrientationL(CAknAppUi::EAppUiOrientationLandscape)); + app.processEvents(); + delete w; + + w = new QWidget; + w->showFullScreen(); + QT_TRAP_THROWING(static_cast(CCoeEnv::Static()->AppUi()) + ->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait)); + app.processEvents(); + delete w; + + // These will have no effect, since there is no status pane, but they shouldn't + // crash either. + w = new QWidget; + w->show(); + w->setWindowTitle("Testing title"); + app.processEvents(); + delete w; + + w = new QWidget; + w->show(); + w->setWindowIcon(QIcon(QPixmap("heart.svg"))); + app.processEvents(); + delete w; + + QDesktopWidget desktop; + QCOMPARE(desktop.availableGeometry(), desktop.screenGeometry()); + } + + QApplication::setAttribute(Qt::AA_S60DontConstructApplicationPanes, false); + + // No other error condition. Program will crash if unsuccessful. +#endif +} + #ifdef Q_OS_SYMBIAN class CBaseDummy : public CBase { -- cgit v0.12