-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rotator.cpp
73 lines (59 loc) · 1.77 KB
/
Rotator.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "Rotator.h"
// TODO: Adapt to Qalendar
Rotator* Rotator::instance = NULL;
Rotator* Rotator::acquire()
{
return instance ? instance : instance = new Rotator();
}
Rotator::Rotator() : m_slave(NULL), m_policy(Automatic)
{
connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(onResized()));
}
void Rotator::setPolicy(Orientation policy)
{
m_policy = policy;
if (m_slave) switch (m_policy) {
case Automatic:
m_slave->setProperty("X-Maemo-Orientation", 2);
//m_slave->setAttribute(Qt::WA_Maemo5AutoOrientation, true);
//m_slave->setAttribute(Qt::WA_Maemo5LandscapeOrientation, false);
//m_slave->setAttribute(Qt::WA_Maemo5PortraitOrientation, false);
break;
case Landscape:
m_slave->setProperty("X-Maemo-Orientation", 0);
//m_slave->setAttribute(Qt::WA_Maemo5AutoOrientation, false);
//m_slave->setAttribute(Qt::WA_Maemo5LandscapeOrientation, true);
//m_slave->setAttribute(Qt::WA_Maemo5PortraitOrientation, false);
break;
case Portrait:
m_slave->setProperty("X-Maemo-Orientation", 1);
//m_slave->setAttribute(Qt::WA_Maemo5AutoOrientation, false);
//m_slave->setAttribute(Qt::WA_Maemo5LandscapeOrientation, false);
//m_slave->setAttribute(Qt::WA_Maemo5PortraitOrientation, true);
break;
}
onResized();
}
void Rotator::setSlave(QWidget *slave)
{
m_slave = slave;
}
Rotator::Orientation Rotator::policy()
{
return m_policy;
}
int Rotator::width()
{
return w;
}
int Rotator::height()
{
return h;
}
void Rotator::onResized()
{
QRect screen = QApplication::desktop()->screenGeometry();
w = screen.width();
h = screen.height();
emit rotated(w, h);
}