#include <QMessageBox>
#include <QTextStream>
#include <QProcess>
+#include <QDesktopWidget>
#define APPNAME "QCPUFreq"
ui->setupUi(this);
refresh();
- // enable auto rotation
- setAutoRotaion();
+ // enable auto rotation
+ setAutoRotaion();
+
+ //create a QGraphicsScene for the little chip icon
+ scene = new QGraphicsScene();
+ orientationChanged();
//connect signals and slots
connect( ui->actionAbout, SIGNAL(triggered()), this, SLOT(about()) );
connect( ui->freq_adjust, SIGNAL(valueChanged(int)), this, SLOT(adjustFreq()) );
+ connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(orientationChanged()));
+
}
MainWindow::~MainWindow()
{
delete ui;
+ delete scene;
}
/**
return txt;
}
+
+/**
+ * Refreshes all of the values to display
+ */
void MainWindow::refresh()
{
//get the current frequency and calculate the MHz value
ui->freq_adjust->setSliderPosition( getScalingStep(getMaxFreq()) );
}
+
+/**
+ * Repaints part of the GUI after the device was rotated
+ */
+void MainWindow::orientationChanged()
+{
+ QPixmap image;
+
+ //check whether we are using portrait or landscape mode
+ if ( usePortrait() ) {
+ //in portrait mode we want to display the large image
+ image.load( ":/img/chip256" );
+ this->scene->clear();
+ this->scene->addPixmap( image );
+
+ ui->graphicsPortrait->setScene( this->scene );
+ ui->graphicsPortrait->setMaximumSize( 256, 256 );
+ ui->graphicsLandscape->setMaximumSize( 0, 0 );
+ } else {
+ image.load( ":/img/chip128" );
+ this->scene->clear();
+ this->scene->addPixmap( image );
+
+ ui->graphicsLandscape->setScene( this->scene );
+ ui->graphicsLandscape->setMaximumSize( 128, 128 );
+ ui->graphicsPortrait->setMaximumSize( 0, 0 );
+ }
+}
+
+
+/**
+ * Enables the auto-rotation feature of Maemo5 devices
+ */
void MainWindow::setAutoRotaion()
{
#if defined(Q_WS_MAEMO_5)
setAttribute(Qt::WA_Maemo5AutoOrientation, true);
- //setAttribute(Qt::WA_Maemo5PortraitOrientation, true);
#endif
}
+
+
+/**
+ * Returns true when the device is in portrait mode
+ */
+bool MainWindow::usePortrait()
+{
+ QRect screenGeometry = QApplication::desktop()->screenGeometry();
+ if (screenGeometry.width() > screenGeometry.height())
+ return false;
+ else
+ return true;
+}
<rect>
<x>0</x>
<y>0</y>
- <width>616</width>
- <height>469</height>
+ <width>699</width>
+ <height>619</height>
</rect>
</property>
<property name="windowTitle">
<widget class="QWidget" name="centralWidget">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
- <layout class="QVBoxLayout" name="verticalLayout_2">
+ <layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
</property>
</widget>
</item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_5">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>SmartReflex™:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QPushButton" name="sr_btn">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Disabled</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <spacer name="verticalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QGraphicsView" name="graphicsLandscape">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>128</width>
+ <height>128</height>
+ </size>
+ </property>
+ <property name="baseSize">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">background: transparent;</string>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="lineWidth">
+ <number>0</number>
+ </property>
+ <property name="verticalScrollBarPolicy">
+ <enum>Qt::ScrollBarAlwaysOff</enum>
+ </property>
+ <property name="horizontalScrollBarPolicy">
+ <enum>Qt::ScrollBarAlwaysOff</enum>
+ </property>
+ <property name="interactive">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>18</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
</layout>
</item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_4">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
</property>
</spacer>
</item>
+ <item>
+ <widget class="QGraphicsView" name="graphicsPortrait">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>128</width>
+ <height>128</height>
+ </size>
+ </property>
+ <property name="baseSize">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">background: transparent;</string>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="lineWidth">
+ <number>0</number>
+ </property>
+ <property name="verticalScrollBarPolicy">
+ <enum>Qt::ScrollBarAlwaysOff</enum>
+ </property>
+ <property name="horizontalScrollBarPolicy">
+ <enum>Qt::ScrollBarAlwaysOff</enum>
+ </property>
+ <property name="interactive">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
</layout>
</item>
<item>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
- <height>40</height>
+ <height>68</height>
</size>
</property>
</spacer>
<rect>
<x>0</x>
<y>0</y>
- <width>616</width>
+ <width>699</width>
<height>21</height>
</rect>
</property>