on xenial help sign in
Don't rotate when on external monitor
commit782aa162f6ceb06ae138f47f861aade8da8b1566 authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateMon 5 Oct 2015, 13:43 (11 years ago) parent7a40575
5 files changed+22−5
qml/DeviceConfiguration.qml+1 qml/OrientedShell.qml+4−1 src/ApplicationArguments.h+10−2 src/ShellApplication.cpp+6−2 src/ShellApplication.h+1
qml/DeviceConfiguration.qml+1
@@ -86,6 +86,7 @@ StateGroup {
8686 PropertyChanges {
8787 target: root
8888 category: "desktop"
89+ supportedOrientations: root.useNativeOrientation
8990 }
9091 }
9192 ]
qml/OrientedShell.qml+4−1
@@ -89,7 +89,10 @@ Rectangle {
8989 }
9090
9191 readonly property int supportedOrientations: shell.supportedOrientations
92− & deviceConfiguration.supportedOrientations
92+ & (deviceConfiguration.supportedOrientations == deviceConfiguration.useNativeOrientation
93+ ? nativeOrientation
94+ : deviceConfiguration.supportedOrientations)
95+
9396 property int acceptedOrientationAngle: {
9497 if (orientation & supportedOrientations) {
9598 return Screen.angleBetween(nativeOrientation, orientation);
src/ApplicationArguments.h+10−2
@@ -26,17 +26,25 @@
2626class ApplicationArguments : public QObject
2727{
2828 Q_OBJECT
29− Q_PROPERTY(QString deviceName READ deviceName CONSTANT)
29+ Q_PROPERTY(QString deviceName READ deviceName NOTIFY deviceNameChanged)
3030 Q_PROPERTY(QString mode READ mode CONSTANT)
3131public:
3232 ApplicationArguments(QObject *parent = nullptr);
3333
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+ }
3540 QString deviceName() const { return m_deviceName; }
3641
3742 void setMode(const QString &mode) { m_mode = mode; }
3843 QString mode() const { return m_mode; }
3944
45+Q_SIGNALS:
46+ void deviceNameChanged(const QString&);
47+
4048private:
4149 QString m_deviceName;
4250 QString m_mode;
src/ShellApplication.cpp+6−2
@@ -44,12 +44,13 @@ ShellApplication::ShellApplication(int & argc, char ** argv, bool isMirServer)
4444 UnityCommandLineParser parser(*this);
4545
4646 if (!parser.deviceName().isEmpty()) {
47− m_qmlArgs.setDeviceName(parser.deviceName());
47+ m_deviceName = parser.deviceName();
4848 } else {
4949 char buffer[200];
5050 property_get("ro.product.device", buffer /* value */, "desktop" /* default_value*/);
51− m_qmlArgs.setDeviceName(QString(buffer));
51+ m_deviceName = QString(buffer);
5252 }
53+ m_qmlArgs.setDeviceName(m_deviceName);
5354
5455 m_qmlArgs.setMode(parser.mode());
5556
@@ -98,6 +99,7 @@ ShellApplication::ShellApplication(int & argc, char ** argv, bool isMirServer)
9899 // (eg cloned desktop, several desktops, etc)
99100 if (isMirServer && screens().count() == 2) {
100101 m_shellView->setScreen(screens().at(1));
102+ m_qmlArgs.setDeviceName("desktop");
101103
102104 m_secondaryWindow.reset(new SecondaryWindow(m_qmlEngine));
103105 m_secondaryWindow->setScreen(screens().at(0));
@@ -136,6 +138,7 @@ void ShellApplication::onScreenAdded(QScreen * /*screen*/)
136138 // (eg cloned desktop, several desktops, etc)
137139 if (screens().count() == 2) {
138140 m_shellView->setScreen(screens().at(1));
141+ m_qmlArgs.setDeviceName("desktop");
139142 // Changing the QScreen where a QWindow is drawn makes it also lose focus (besides having
140143 // its backing QPlatformWindow recreated). So lets refocus it.
141144 m_shellView->requestActivate();
@@ -159,6 +162,7 @@ void ShellApplication::onScreenAboutToBeRemoved(QScreen *screen)
159162 Q_ASSERT(!m_secondaryWindow.isNull());
160163 m_secondaryWindow.reset();
161164 m_shellView->setScreen(screens().first());
165+ m_qmlArgs.setDeviceName(m_deviceName);
162166 // Changing the QScreen where a QWindow is drawn makes it also lose focus (besides having
163167 // its backing QPlatformWindow recreated). So lets refocus it.
164168 m_shellView->requestActivate();
src/ShellApplication.h+1
@@ -42,6 +42,7 @@ private Q_SLOTS:
4242
4343private:
4444 void setupQmlEngine(bool isMirServer);
45+ QString m_deviceName;
4546 ApplicationArguments m_qmlArgs;
4647 QScopedPointer<ShellView> m_shellView;
4748 QScopedPointer<SecondaryWindow> m_secondaryWindow;