on xenial help sign in
Don't rotate when on external monitor
782aa16Daniel d'Andrada
qml/DeviceConfiguration.qml+1
@@ -86,6 +86,7 @@ StateGroup {
86 PropertyChanges {
86 PropertyChanges {
87 target: root
87 target: root
88 category: "desktop"
88 category: "desktop"
89+ supportedOrientations: root.useNativeOrientation
89 }
90 }
90 }
91 }
91 ]
92 ]
qml/OrientedShell.qml+4−1
@@ -89,7 +89,10 @@ Rectangle {
89 }
89 }
90
90
91 readonly property int supportedOrientations: shell.supportedOrientations
91 readonly property int supportedOrientations: shell.supportedOrientations
92− & deviceConfiguration.supportedOrientations
92+ & (deviceConfiguration.supportedOrientations == deviceConfiguration.useNativeOrientation
93+ ? nativeOrientation
94+ : deviceConfiguration.supportedOrientations)
95+
93 property int acceptedOrientationAngle: {
96 property int acceptedOrientationAngle: {
94 if (orientation & supportedOrientations) {
97 if (orientation & supportedOrientations) {
95 return Screen.angleBetween(nativeOrientation, orientation);
98 return Screen.angleBetween(nativeOrientation, orientation);
src/ApplicationArguments.h+10−2
@@ -26,17 +26,25 @@
26class ApplicationArguments : public QObject
26class ApplicationArguments : public QObject
27{
27{
28 Q_OBJECT
28 Q_OBJECT
29− Q_PROPERTY(QString deviceName READ deviceName CONSTANT)
29+ Q_PROPERTY(QString deviceName READ deviceName NOTIFY deviceNameChanged)
30 Q_PROPERTY(QString mode READ mode CONSTANT)
30 Q_PROPERTY(QString mode READ mode CONSTANT)
31public:
31public:
32 ApplicationArguments(QObject *parent = nullptr);
32 ApplicationArguments(QObject *parent = nullptr);
33
33
34− void setDeviceName(const QString &deviceName) { m_deviceName = deviceName; }
34+ void setDeviceName(const QString &deviceName) {
35+ if (deviceName != m_deviceName) {
36+ m_deviceName = deviceName;
37+ Q_EMIT deviceNameChanged(m_deviceName);
38+ }
39+ }
35 QString deviceName() const { return m_deviceName; }
40 QString deviceName() const { return m_deviceName; }
36
41
37 void setMode(const QString &mode) { m_mode = mode; }
42 void setMode(const QString &mode) { m_mode = mode; }
38 QString mode() const { return m_mode; }
43 QString mode() const { return m_mode; }
39
44
45+Q_SIGNALS:
46+ void deviceNameChanged(const QString&);
47+
40private:
48private:
41 QString m_deviceName;
49 QString m_deviceName;
42 QString m_mode;
50 QString m_mode;
src/ShellApplication.cpp+6−2
@@ -44,12 +44,13 @@ ShellApplication::ShellApplication(int & argc, char ** argv, bool isMirServer)
44 UnityCommandLineParser parser(*this);
44 UnityCommandLineParser parser(*this);
45
45
46 if (!parser.deviceName().isEmpty()) {
46 if (!parser.deviceName().isEmpty()) {
47− m_qmlArgs.setDeviceName(parser.deviceName());
47+ m_deviceName = parser.deviceName();
48 } else {
48 } else {
49 char buffer[200];
49 char buffer[200];
50 property_get("ro.product.device", buffer /* value */, "desktop" /* default_value*/);
50 property_get("ro.product.device", buffer /* value */, "desktop" /* default_value*/);
51− m_qmlArgs.setDeviceName(QString(buffer));
51+ m_deviceName = QString(buffer);
52 }
52 }
53+ m_qmlArgs.setDeviceName(m_deviceName);
53
54
54 m_qmlArgs.setMode(parser.mode());
55 m_qmlArgs.setMode(parser.mode());
55
56
@@ -98,6 +99,7 @@ ShellApplication::ShellApplication(int & argc, char ** argv, bool isMirServer)
98 // (eg cloned desktop, several desktops, etc)
99 // (eg cloned desktop, several desktops, etc)
99 if (isMirServer && screens().count() == 2) {
100 if (isMirServer && screens().count() == 2) {
100 m_shellView->setScreen(screens().at(1));
101 m_shellView->setScreen(screens().at(1));
102+ m_qmlArgs.setDeviceName("desktop");
101
103
102 m_secondaryWindow.reset(new SecondaryWindow(m_qmlEngine));
104 m_secondaryWindow.reset(new SecondaryWindow(m_qmlEngine));
103 m_secondaryWindow->setScreen(screens().at(0));
105 m_secondaryWindow->setScreen(screens().at(0));
@@ -136,6 +138,7 @@ void ShellApplication::onScreenAdded(QScreen * /*screen*/)
136 // (eg cloned desktop, several desktops, etc)
138 // (eg cloned desktop, several desktops, etc)
137 if (screens().count() == 2) {
139 if (screens().count() == 2) {
138 m_shellView->setScreen(screens().at(1));
140 m_shellView->setScreen(screens().at(1));
141+ m_qmlArgs.setDeviceName("desktop");
139 // Changing the QScreen where a QWindow is drawn makes it also lose focus (besides having
142 // Changing the QScreen where a QWindow is drawn makes it also lose focus (besides having
140 // its backing QPlatformWindow recreated). So lets refocus it.
143 // its backing QPlatformWindow recreated). So lets refocus it.
141 m_shellView->requestActivate();
144 m_shellView->requestActivate();
@@ -159,6 +162,7 @@ void ShellApplication::onScreenAboutToBeRemoved(QScreen *screen)
159 Q_ASSERT(!m_secondaryWindow.isNull());
162 Q_ASSERT(!m_secondaryWindow.isNull());
160 m_secondaryWindow.reset();
163 m_secondaryWindow.reset();
161 m_shellView->setScreen(screens().first());
164 m_shellView->setScreen(screens().first());
165+ m_qmlArgs.setDeviceName(m_deviceName);
162 // Changing the QScreen where a QWindow is drawn makes it also lose focus (besides having
166 // Changing the QScreen where a QWindow is drawn makes it also lose focus (besides having
163 // its backing QPlatformWindow recreated). So lets refocus it.
167 // its backing QPlatformWindow recreated). So lets refocus it.
164 m_shellView->requestActivate();
168 m_shellView->requestActivate();
src/ShellApplication.h+1
@@ -42,6 +42,7 @@ private Q_SLOTS:
42
42
43private:
43private:
44 void setupQmlEngine(bool isMirServer);
44 void setupQmlEngine(bool isMirServer);
45+ QString m_deviceName;
45 ApplicationArguments m_qmlArgs;
46 ApplicationArguments m_qmlArgs;
46 QScopedPointer<ShellView> m_shellView;
47 QScopedPointer<ShellView> m_shellView;
47 QScopedPointer<SecondaryWindow> m_secondaryWindow;
48 QScopedPointer<SecondaryWindow> m_secondaryWindow;