Browse Source

Changes to how we switch modes.

We now have layout option that can be auto, tv or desktop. This locks
the mode to that. Auto behaves as 1.2.0 did.
Tobias Hieta 8 years ago
parent
commit
a42bd77273

+ 10 - 0
resources/settings/settings_description.json

@@ -28,6 +28,16 @@
           [ "tv", "tv" ]
         ]
       },
+      {
+        "value": "layout",
+        "default": "auto",
+        "hidden": false,
+        "possible_values": [
+          [ "auto", "auto" ],
+          [ "tv", "tv" ],
+          [ "desktop", "desktop" ]
+        ]
+      },
       {
         "value": "remoteInspector",
         "default": false,

+ 1 - 0
src/main.cpp

@@ -98,6 +98,7 @@ int main(int argc, char *argv[])
                        {{"a", "from-auto-update"}, "When invoked from auto-update"},
                        {"desktop",                 "Start in desktop mode"},
                        {"tv",                      "Start in TV mode"},
+                       {"auto-layout",             "Use auto-layout mode"},
                        {"windowed",                "Start in windowed mode"},
                        {"fullscreen",              "Start in fullscreen"},
                        {"terminal",                "Log to terminal"}});

+ 8 - 8
src/player/OpenGLDetect.cpp

@@ -15,14 +15,14 @@
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 void detectOpenGLEarly()
 {
-    // Request OpenGL 4.1 if possible on OSX, otherwise it defaults to 2.0
-    // This needs to be done before we create the QGuiApplication
-    //
-    QSurfaceFormat format = QSurfaceFormat::defaultFormat();
-    format.setMajorVersion(3);
-    format.setMinorVersion(2);
-    format.setProfile(QSurfaceFormat::CoreProfile);
-    QSurfaceFormat::setDefaultFormat(format);
+  // Request OpenGL 4.1 if possible on OSX, otherwise it defaults to 2.0
+  // This needs to be done before we create the QGuiApplication
+  //
+  QSurfaceFormat format = QSurfaceFormat::defaultFormat();
+  format.setMajorVersion(3);
+  format.setMinorVersion(2);
+  format.setProfile(QSurfaceFormat::CoreProfile);
+  QSurfaceFormat::setDefaultFormat(format);
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////

+ 8 - 2
src/settings/SettingsComponent.cpp

@@ -754,9 +754,15 @@ void SettingsComponent::setCommandLineValues(const QStringList& values)
     else if (value == "windowed")
       setValue(SETTINGS_SECTION_MAIN, "fullscreen", false);
     else if (value == "desktop")
-      setValue(SETTINGS_SECTION_MAIN, "webMode", "desktop");
+      setValue(SETTINGS_SECTION_MAIN, "layout", "desktop");
     else if (value == "tv")
-      setValue(SETTINGS_SECTION_MAIN, "webMode", "tv");
+      setValue(SETTINGS_SECTION_MAIN, "layout", "tv");
+    else if (value == "auto-layout")
+      setValue(SETTINGS_SECTION_MAIN, "layout", "auto");
   }
+
+  auto layout = value(SETTINGS_SECTION_MAIN, "layout").toString();
+  if (layout != "auto")
+    setValue(SETTINGS_SECTION_MAIN, "webMode", layout);
 }
 

+ 25 - 14
src/ui/KonvergoWindow.cpp

@@ -316,26 +316,37 @@ void KonvergoWindow::updateMainSectionSettings(const QVariantMap& values)
     bool oldDesktopMode = m_webDesktopMode;
     bool newDesktopMode = (SettingsComponent::Get().value(SETTINGS_SECTION_MAIN, "webMode").toString() == "desktop");
 
-    bool fullscreen = SettingsComponent::Get().value(SETTINGS_SECTION_MAIN, "fullscreen").toBool();
-
-    if (oldDesktopMode && !newDesktopMode)
-      fullscreen = true;
-    else if (!oldDesktopMode && newDesktopMode)
-      fullscreen = false;
-
-    PlayerComponent::Get().stop();
-
-    SettingsComponent::Get().setValue(SETTINGS_SECTION_MAIN, "fullscreen", fullscreen);
-    QTimer::singleShot(0, [=]
+    if (SettingsComponent::Get().value(SETTINGS_SECTION_MAIN, "layout").toString() != "auto")
     {
       m_webDesktopMode = newDesktopMode;
       emit webDesktopModeChanged();
       emit webUrlChanged();
-
-      SystemComponent::Get().setCursorVisibility(true);
       updateWindowState();
       notifyScale(size());
-    });
+    }
+    else
+    {
+      bool fullscreen = SettingsComponent::Get().value(SETTINGS_SECTION_MAIN, "fullscreen").toBool();
+
+      if (oldDesktopMode && !newDesktopMode)
+        fullscreen = true;
+      else if (!oldDesktopMode && newDesktopMode)
+        fullscreen = false;
+
+      PlayerComponent::Get().stop();
+
+      SettingsComponent::Get().setValue(SETTINGS_SECTION_MAIN, "fullscreen", fullscreen);
+      QTimer::singleShot(0, [=]
+      {
+        m_webDesktopMode = newDesktopMode;
+        emit webDesktopModeChanged();
+        emit webUrlChanged();
+
+        SystemComponent::Get().setCursorVisibility(true);
+        updateWindowState();
+        notifyScale(size());
+      });
+    }
   }
 
   if (values.contains("startupurl"))

+ 2 - 1
src/ui/KonvergoWindow.h

@@ -73,7 +73,8 @@ public:
 
   Q_SLOT void toggleFullscreen()
   {
-    if (!m_webDesktopMode && isFullScreen())
+    if (SettingsComponent::Get().value(SETTINGS_SECTION_MAIN, "layout").toString() == "auto" &&
+        m_webDesktopMode && isFullScreen())
       SettingsComponent::Get().setValue(SETTINGS_SECTION_MAIN, "webMode", "desktop");
     else
       setFullScreen(!isFullScreen());

+ 1 - 1
src/ui/webview.qml

@@ -26,7 +26,7 @@ KonvergoWindow
       if (components.system.isMacos) return "Ctrl+Shift+F";
       return "Shift+F11";
     }
-    onTriggered: components.settings.setValue("main", "webMode", "tv")
+    onTriggered: mainWindow.toggleFullscreen()
   }
 
   Action