1 #include "mainwindow.h"
2 #include "ui_mainwindow.h"
4 #include <QtCore/QCoreApplication>
6 MainWindow::MainWindow(QWidget *parent)
7 : QMainWindow(parent), ui(new Ui::MainWindow)
10 this->setAttribute(Qt::WA_Maemo5StackedWindow);
11 this->setWindowFlags(Qt::Window);
17 void MainWindow::setupcodedUI()
19 cent = centralWidget();
20 //mlayout = qobject_cast<QVBoxLayout *>(cent->layout());
21 mlayout = new QVBoxLayout;
22 btlayout = new QHBoxLayout;
24 QScrollArea *scrollArea = new QScrollArea;
25 scrollArea->setBackgroundRole(QPalette::Dark);
26 mlayout->addWidget(scrollArea);
28 btnClear = new QPushButton;
29 btnClear->setIcon(QIcon("/usr/share/icons/hicolor/64x64/hildon/general_delete.png"));
30 wordinput = new QLineEdit;
31 labVerb = new QLabel();
32 labVerb->setMinimumWidth(250);
33 btlayout->addWidget(btnClear);
34 btlayout->addWidget(labVerb);
35 btlayout->addWidget(wordinput);
36 btnLookup = new QPushButton; // Lookup button
37 btnLookup->setIcon(QIcon("/usr/share/icons/hicolor/64x64/hildon/general_search.png"));
38 btlayout->addWidget(btnLookup);
40 mlayout->addLayout(btlayout);
41 cent->setLayout(mlayout);
43 // Clear the word input when Clear button is tapped
44 QObject::connect(btnClear, SIGNAL(clicked()), wordinput, SLOT(clear()));
45 QObject::connect(btnClear, SIGNAL(clicked()), labVerb, SLOT(clear()));
47 QObject::connect(wordinput, SIGNAL(returnPressed()), this, SLOT(startLookup()));
48 QObject::connect(btnLookup, SIGNAL(clicked()), this, SLOT(startLookup()));
51 MainWindow::~MainWindow()
56 void MainWindow::setOrientation(ScreenOrientation orientation)
58 #if defined(Q_OS_SYMBIAN)
59 // If the version of Qt on the device is < 4.7.2, that attribute won't work
60 if (orientation != ScreenOrientationAuto) {
61 const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.'));
62 if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) {
63 qWarning("Screen orientation locking only supported with Qt 4.7.2 and above");
67 #endif // Q_OS_SYMBIAN
69 Qt::WidgetAttribute attribute;
70 switch (orientation) {
71 #if QT_VERSION < 0x040702
72 // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes
73 case ScreenOrientationLockPortrait:
74 attribute = static_cast<Qt::WidgetAttribute>(128);
76 case ScreenOrientationLockLandscape:
77 attribute = static_cast<Qt::WidgetAttribute>(129);
80 case ScreenOrientationAuto:
81 attribute = static_cast<Qt::WidgetAttribute>(130);
83 #else // QT_VERSION < 0x040702
84 case ScreenOrientationLockPortrait:
85 attribute = Qt::WA_LockPortraitOrientation;
87 case ScreenOrientationLockLandscape:
88 attribute = Qt::WA_LockLandscapeOrientation;
91 case ScreenOrientationAuto:
92 attribute = Qt::WA_AutoOrientation;
94 #endif // QT_VERSION < 0x040702
96 setAttribute(attribute, true);
99 void MainWindow::showExpanded()
101 #if defined(Q_OS_SYMBIAN) || defined(Q_WS_SIMULATOR)
103 #elif defined(Q_WS_MAEMO_5)
110 void MainWindow::startLookup()
112 QString text = wordinput->text();
113 labVerb->setText(text);