orientation.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #include "orientation.h"
  2. Qt::WidgetAttribute Orientation::setOrientation(ScreenOrientation orientation)
  3. {
  4. #if defined(Q_OS_SYMBIAN)
  5. // If the version of Qt on the device is < 4.7.2, that attribute won't work
  6. if (orientation != ScreenOrientationAuto) {
  7. const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.'));
  8. if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) {
  9. qWarning("Screen orientation locking only supported with Qt 4.7.2 and above");
  10. return;
  11. }
  12. }
  13. #endif // Q_OS_SYMBIAN
  14. Qt::WidgetAttribute attribute;
  15. switch (orientation) {
  16. #if QT_VERSION < 0x040702
  17. // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes
  18. case ScreenOrientationLockPortrait:
  19. attribute = static_cast<Qt::WidgetAttribute>(128);
  20. break;
  21. case ScreenOrientationLockLandscape:
  22. attribute = static_cast<Qt::WidgetAttribute>(129);
  23. break;
  24. default:
  25. case ScreenOrientationAuto:
  26. attribute = static_cast<Qt::WidgetAttribute>(130);
  27. break;
  28. #else // QT_VERSION < 0x040702
  29. case ScreenOrientationLockPortrait:
  30. attribute = Qt::WA_LockPortraitOrientation;
  31. break;
  32. case ScreenOrientationLockLandscape:
  33. attribute = Qt::WA_LockLandscapeOrientation;
  34. break;
  35. default:
  36. case ScreenOrientationAuto:
  37. attribute = Qt::WA_AutoOrientation;
  38. break;
  39. #endif // QT_VERSION < 0x040702
  40. };
  41. //setAttribute(attribute, true);
  42. return attribute;
  43. }
  44. int Orientation::showMode()
  45. {
  46. #ifdef Q_OS_SYMBIAN
  47. return ShowModeFullScreen;//showFullScreen();
  48. #elif defined(Q_WS_MAEMO_5)
  49. return ShowModeMaximized;//showMaximized();
  50. #else
  51. return ShowModeNormal;//show();
  52. #endif
  53. }