PageRenderTime 37ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/src/controller/aboutcontroller.cpp

https://bitbucket.org/adrianogil/qdominoes
C++ | 144 lines | 129 code | 14 blank | 1 comment | 7 complexity | 654a35fbd42bde1d10f282803499ed15 MD5 | raw file
  1. #include <QtCore/QDebug>
  2. #include <QtCore/QEvent>
  3. #include <QtCore/QHash>
  4. #include <QtCore/QProcess>
  5. #include <QtCore/QUrl>
  6. #include <QtGui/QApplication>
  7. #include <QtGui/QDesktopServices>
  8. #include <QtGui/QInputContext>
  9. #include "aboutcontroller.h"
  10. #if defined (TARGET_SYMBIAN)
  11. #include "symbianutils.h"
  12. #elif defined (TARGET_MEEGO)
  13. #include <QSystemInfo>
  14. #include <QSystemDeviceInfo>
  15. QTM_USE_NAMESPACE
  16. #endif
  17. AboutController::AboutController(QObject *parent) :
  18. QObject(parent),
  19. m_showUpdateButton(false)
  20. {
  21. }
  22. void AboutController::setUpAboutMessage(){
  23. QHash<QString,QString> modelList;
  24. modelList["5230"] = QString("10.4");
  25. modelList["5233"] = QString("12.1");
  26. modelList["5235-1d"] = QString("12.8");
  27. modelList["5530"] = QString("20.0");
  28. modelList["5800"] = QString("20.0");
  29. modelList["5800 XpressMusic"] = QString("20.0");
  30. modelList["X6-00"] = QString("12.2");
  31. modelList["C5-03"] = QString("11.1.024");
  32. modelList["N97"] = QString("21.2");
  33. modelList["N97 mini"] = QString("11.2");
  34. modelList["C6-00"] = QString("10.2");
  35. modelList["N8-00"] = QString("011.012");
  36. modelList["C7-00"] = QString("013.016");
  37. modelList["E7-00"] = QString("013.016");
  38. modelList["N9"] = QString("10.2011");
  39. modelList["N950"] = QString("10.2011");
  40. QHash<QString,QString> rmList;
  41. rmList["5230"] = QString("RM-629");
  42. rmList["5233"] = QString("RM-625");
  43. rmList["5235-1d"] = QString("RM-629");
  44. rmList["5530"] = QString("RM-504");
  45. rmList["5800"] = QString("RM-356");
  46. rmList["5800 XpressMusic"] = QString("RM-356");
  47. rmList["X6-00"] = QString("RM-551");
  48. rmList["C5-03"] = QString("RM-697");
  49. rmList["N97"] = QString("RM-507");
  50. rmList["N97 mini"] = QString("RM-553");
  51. rmList["C6-00"] = QString("RM-624");
  52. rmList["N8-00"] = QString("RM-596");
  53. rmList["C7-00"] = QString("RM-675");
  54. rmList["E7-00"] = QString("RM-626");
  55. rmList["N9"] = QString("RM-696");
  56. rmList["N950"] = QString("RM-680");
  57. #if defined (TARGET_SYMBIAN)
  58. m_model = SymbianUtils::model() + ", " + SymbianUtils::rm();
  59. m_firmware = SymbianUtils::firmware();
  60. #elif defined(TARGET_MEEGO)
  61. QtMobility::QSystemInfo s;
  62. m_firmware = s.version(QtMobility::QSystemInfo::Firmware);
  63. QtMobility::QSystemDeviceInfo sd;
  64. m_model = sd.model() + ", " + sd.productName();
  65. #endif
  66. if (modelList.contains(m_model)) {
  67. m_homofirmware = modelList[m_model];
  68. if (QString::compare(m_firmware, m_homofirmware) < 0) {
  69. m_message =
  70. "<p align='justify'>"
  71. "A vers&#227;o do software do seu Nokia <strong>" + m_model + "</strong> &#233; a "
  72. "<strong>" + m_firmware + "</strong> e esta aplica&#231;&#227;o foi projetada "
  73. "para a vers&#227;o <strong>" + modelList[m_model] + "</strong> com o <strong>" + rmList[m_model] + "</strong> e superiores."
  74. "</p>"
  75. "<p align='justify'>"
  76. "Para um bom funcionamento sugerimos a "
  77. "atualiza&#231;&#227;o do software de seu aparelho.<br />"
  78. "Caso deseje fazer isso agora, pressione o "
  79. "bot&#227;o ATUALIZAR e na tela escolha "
  80. "OP&#199;&#213;ES e CHECAR ATUALIZA&#199;&#213;ES."
  81. "</p>";
  82. m_showUpdateButton = true;
  83. }
  84. else if (QString::compare(m_firmware, m_homofirmware) == 0) {
  85. m_message =
  86. "<p align='justify'>"
  87. "A vers&#227;o do software do seu Nokia <strong>" + m_model + "</strong> &#223; a "
  88. "<strong>" + m_firmware + "</strong>, vers&#227;o para a qual esta aplica&#231;&#227;o foi projetada."
  89. "</p>";
  90. }
  91. else {
  92. m_message =
  93. "A vers&#227;o do software do seu Nokia <strong>" + m_model + "</strong> &#233; a "
  94. "<strong>" + m_firmware + "</strong>, vers&#227;o acima da qual sua aplica&#231;&#227;o foi projetada, <strong>" + modelList[m_model] + "</strong>.";
  95. }
  96. }
  97. else {
  98. m_message =
  99. "<p align='justify'>"
  100. "Esta aplica&#231;&#227;o n&#227;o foi homologada para o seu aparelho Nokia <strong>" + m_model + "</strong>. Eventuais problemas poder&#227;o ocorrer durante a sua execu&#231;&#227;o."
  101. "</p>";
  102. }
  103. // qDebug()<< __PRETTY_FUNCTION__ <<"aboutMessage";
  104. }
  105. void AboutController::updateSoftware(){
  106. #if defined (TARGET_SYMBIAN)
  107. SymbianUtils::openWindowByUID(0x101f6de5);
  108. #elif defined(TARGET_MEEGO)
  109. QProcess::startDetached("/usr/bin/invoker",
  110. QStringList() << "--type=e" <<
  111. "--single-instance" << "/usr/bin/package-manager-ui");
  112. #endif
  113. }
  114. QString AboutController::getAboutMessage(){
  115. setUpAboutMessage();
  116. return m_message;
  117. }
  118. bool AboutController::showUpdateButton(){
  119. return m_showUpdateButton;
  120. }
  121. void AboutController::downloadApps()
  122. {
  123. QDesktopServices::openUrl(QUrl(tr("http://bit.ly/atRQmu")));
  124. }
  125. void AboutController::closeMeegoKeyboard()
  126. {
  127. QInputContext *ic = qApp->inputContext();
  128. QEvent closeSIPEvent(QEvent::CloseSoftwareInputPanel);
  129. ic->filterEvent(&closeSIPEvent);
  130. }