Advertisement
luiscesjr

mainwindow.cpp

Nov 26th, 2011
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3. #include <QPalette>
  4. #include <QDesktopWidget>
  5. #include "keys.h"
  6.  
  7. QString game;
  8.  
  9. #include <QtCore/QCoreApplication>
  10.  
  11. MainWindow::MainWindow(QWidget *parent)
  12.     : QMainWindow(parent), ui(new Ui::MainWindow)
  13. {
  14.     ui->setupUi(this);
  15.  
  16. }
  17.     void MainWindow::set_keys(){
  18.         keyopt=new keys(this);
  19.         keyopt->show();
  20.         keyopt=NULL;
  21.     }
  22.  
  23.  
  24. void MainWindow::setOrientation(ScreenOrientation orientation)
  25. {
  26. #if defined(Q_OS_SYMBIAN)
  27.     // If the version of Qt on the device is < 4.7.2, that attribute won't work
  28.     if (orientation != ScreenOrientationAuto) {
  29.         const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.'));
  30.         if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) {
  31.             qWarning("Screen orientation locking only supported with Qt 4.7.2 and above");
  32.             return;
  33.         }
  34.     }
  35. #endif // Q_OS_SYMBIAN
  36.  
  37.     Qt::WidgetAttribute attribute;
  38.     switch (orientation) {
  39. #if QT_VERSION < 0x040702
  40.     // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes
  41.     case ScreenOrientationLockPortrait:
  42.         attribute = static_cast<Qt::WidgetAttribute>(128);
  43.         break;
  44.     case ScreenOrientationLockLandscape:
  45.         attribute = static_cast<Qt::WidgetAttribute>(129);
  46.         break;
  47.     default:
  48.     case ScreenOrientationAuto:
  49.         attribute = static_cast<Qt::WidgetAttribute>(130);
  50.         break;
  51. #else // QT_VERSION < 0x040702
  52.     case ScreenOrientationLockPortrait:
  53.         attribute = Qt::WA_LockPortraitOrientation;
  54.         break;
  55.     case ScreenOrientationLockLandscape:
  56.         attribute = Qt::WA_LockLandscapeOrientation;
  57.         break;
  58.     default:
  59.     case ScreenOrientationAuto:
  60.         attribute = Qt::WA_AutoOrientation;
  61.         break;
  62. #endif // QT_VERSION < 0x040702
  63.     };
  64.     setAttribute(attribute, true);
  65. }
  66.  
  67. void MainWindow::showExpanded()
  68. {
  69. #if defined(Q_OS_SYMBIAN) || defined(Q_WS_SIMULATOR)
  70.     showFullScreen();
  71. #elif defined(Q_WS_MAEMO_5)
  72.     showMaximized();
  73. #else
  74.     show();
  75. #endif
  76. }
  77.  
  78. void MainWindow::emu_exec(){
  79.  
  80.     QProcess *myProcess = new QProcess(this);
  81.     myProcess->startDetached("/opt/gpsp/gpspm");
  82.     this->close();
  83. }
  84.  
  85. void MainWindow::on_Configure_Buttons_clicked()
  86. {
  87.     connect (ui->Configure_Buttons,SIGNAL(clicked()),this,SLOT(set_keys()));
  88.     return;
  89. }
  90.  
  91. void MainWindow::on_StartEmulator_clicked()
  92. {
  93.     connect (ui->StartEmulator,SIGNAL(clicked()),this,SLOT(emu_exec()));
  94.     return;
  95. }
  96.  
  97. void MainWindow::on_Download_clicked()
  98. {
  99.     QDesktopServices::openUrl(QUrl("http://talk.maemo.org/showpost.php?p=897604&postcount=1"));
  100. }
  101.  
  102. MainWindow::~MainWindow()
  103. {
  104.     delete ui;
  105. }
  106.  
  107.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement