mainwindow.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // checksum 0xfd0b version 0x20001
  2. /*
  3. This file was generated by the Mobile Qt Application wizard of Qt Creator.
  4. MainWindow is a convenience class containing mobile device specific code
  5. such as screen orientation handling.
  6. It is recommended not to modify this file, since newer versions of Qt Creator
  7. may offer an updated version of it.
  8. */
  9. #include "mainwindow.h"
  10. #include "ui_mainwindow.h"
  11. #include <QtCore/QCoreApplication>
  12. #if defined(Q_OS_SYMBIAN) && defined(ORIENTATIONLOCK)
  13. #include <eikenv.h>
  14. #include <eikappui.h>
  15. #include <aknenv.h>
  16. #include <aknappui.h>
  17. #endif // Q_OS_SYMBIAN && ORIENTATIONLOCK
  18. MainWindow::MainWindow(QWidget *parent)
  19. : QMainWindow(parent), ui(new Ui::MainWindow)
  20. {
  21. ui->setupUi(this);
  22. }
  23. MainWindow::~MainWindow()
  24. {
  25. delete ui;
  26. }
  27. void MainWindow::setOrientation(ScreenOrientation orientation)
  28. {
  29. #ifdef Q_OS_SYMBIAN
  30. if (orientation != ScreenOrientationAuto) {
  31. #if defined(ORIENTATIONLOCK)
  32. const CAknAppUiBase::TAppUiOrientation uiOrientation =
  33. (orientation == ScreenOrientationLockPortrait) ? CAknAppUi::EAppUiOrientationPortrait
  34. : CAknAppUi::EAppUiOrientationLandscape;
  35. CAknAppUi* appUi = dynamic_cast<CAknAppUi*> (CEikonEnv::Static()->AppUi());
  36. TRAPD(error,
  37. if (appUi)
  38. appUi->SetOrientationL(uiOrientation);
  39. );
  40. Q_UNUSED(error)
  41. #else // ORIENTATIONLOCK
  42. qWarning("'ORIENTATIONLOCK' needs to be defined on Symbian when locking the orientation.");
  43. #endif // ORIENTATIONLOCK
  44. }
  45. #elif defined(Q_WS_MAEMO_5)
  46. Qt::WidgetAttribute attribute;
  47. switch (orientation) {
  48. case ScreenOrientationLockPortrait:
  49. attribute = Qt::WA_Maemo5PortraitOrientation;
  50. break;
  51. case ScreenOrientationLockLandscape:
  52. attribute = Qt::WA_Maemo5LandscapeOrientation;
  53. break;
  54. case ScreenOrientationAuto:
  55. default:
  56. attribute = Qt::WA_Maemo5AutoOrientation;
  57. break;
  58. }
  59. setAttribute(attribute, true);
  60. #else // Q_OS_SYMBIAN
  61. Q_UNUSED(orientation);
  62. #endif // Q_OS_SYMBIAN
  63. }
  64. void MainWindow::showExpanded()
  65. {
  66. #ifdef Q_OS_SYMBIAN
  67. showFullScreen();
  68. #elif defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
  69. showMaximized();
  70. #else
  71. show();
  72. #endif
  73. }