Browse Source

Rework hotkeys for desktop mode

Fixes plexinc/plex-media-player-private#523
Tobias Hieta 8 years ago
parent
commit
f4c36a215a

+ 2 - 1
resources/inputmaps/keyboard.json

@@ -46,7 +46,8 @@
     "Home": "step_backward",
     "End": "step_forward",
     "Ctrl\\+F": "search",
-    "Ctrl\\+M": "host:cycle_setting main.webMode",
+    "Ctrl\\+M": "host:minimize",
+    "Meta\\+Down": "host:minimize",
 
     // application shortcuts
     "Ctrl\\+Shift\\+F": "host:fullscreen",

+ 8 - 0
src/system/SystemComponent.h

@@ -15,6 +15,10 @@ class SystemComponent : public ComponentBase
   Q_OBJECT
   DEFINE_SINGLETON(SystemComponent);
 
+  Q_PROPERTY(bool isMacos READ platformIsMac CONSTANT)
+  Q_PROPERTY(bool isWindows READ platformIsWindows CONSTANT)
+  Q_PROPERTY(bool isLinux READ platformIsLinux CONSTANT)
+
 public:
   bool componentExport() override { return true; }
   const char* componentName() override { return "system"; }
@@ -90,6 +94,10 @@ private:
   explicit SystemComponent(QObject* parent = nullptr);
   static QMap<QString, QString> networkInterfaces();
 
+  bool platformIsWindows() const { return m_platformType == platformTypeWindows; }
+  bool platformIsMac() const { return m_platformType == platformTypeOsx; }
+  bool platformIsLinux() const { return m_platformType == platformTypeLinux; }
+
   QTimer* m_mouseOutTimer;
   PlatformType m_platformType;
   PlatformArch m_platformArch;

+ 4 - 0
src/system/UpdaterComponent.cpp

@@ -53,6 +53,10 @@ UpdaterComponent::UpdaterComponent(QObject* parent) :
 /////////////////////////////////////////////////////////////////////////////////////////
 void UpdaterComponent::checkForUpdate()
 {
+#if !defined(NDEBUG)
+  return;
+#endif
+
   auto systemInfo = SystemComponent::Get().systemInformation();
   QUrl baseUrl = QString("https://plex.tv/updater/products/%0/check.xml").arg(systemInfo["productid"].toInt());
   QUrlQuery query;

+ 4 - 0
src/ui/KonvergoWindow.cpp

@@ -45,6 +45,7 @@ KonvergoWindow::KonvergoWindow(QWindow* parent) :
   InputComponent::Get().registerHostCommand("toggleDebug", this, "toggleDebug");
   InputComponent::Get().registerHostCommand("reload", this, "reloadWeb");
   InputComponent::Get().registerHostCommand("fullscreen", this, "toggleFullscreen");
+  InputComponent::Get().registerHostCommand("minimize", this, "minimizeWindow");
 
 #ifdef TARGET_RPI
   // On RPI, we use dispmanx layering - the video is on a layer below Konvergo,
@@ -412,6 +413,9 @@ void KonvergoWindow::onVisibilityChanged(QWindow::Visibility visibility)
     SettingsComponent::Get().setValue(SETTINGS_SECTION_MAIN, "fullscreen", fs);
   }
 
+  if (visibility == QWindow::Minimized)
+    InputComponent::Get().cancelAutoRepeat();
+
   notifyScale(size());
 }
 

+ 6 - 0
src/ui/KonvergoWindow.h

@@ -89,6 +89,12 @@ public:
     emit reloadWebClient();
   }
 
+  Q_INVOKABLE Q_SLOT void minimizeWindow()
+  {
+    if (!isFullScreen())
+      setVisibility(QWindow::Minimized);
+  }
+
   qreal windowScale() { return CalculateScale(size()); }
   qreal webScale() { return CalculateWebScale(size(), devicePixelRatio()); }
   qreal webHeightMax() { return WEBUI_MAX_HEIGHT; }

+ 33 - 39
src/ui/webview.qml

@@ -19,73 +19,69 @@ KonvergoWindow
       web.triggerWebAction(action)
   }
 
-  function actionEnable(enable)
-  {
-    action_switchmode.enabled = enable
-    action_copy.enabled = enable
-    action_cut.enabled = enable
-    action_paste.enabled = enable
-    action_undo.enabled = enable
-    action_redo.enabled = enable
-    action_selectall.enabled = enable
-    action_fullscreen_win.enabled = enable
-    action_fullscreen_mac.enabled = enable
-    action_fullscreen_win_alt.enabled = enable
-    action_quit.enabled = enable
-    action_quit_win.enabled = enable
-  }
-
   Action
   {
-    id: action_quit
-    shortcut: "Ctrl+Q"
-    onTriggered: mainWindow.close()
+    enabled: mainWindow.webDesktopMode
+    shortcut: {
+      if (components.system.isMacos) return "Ctrl+Shift+F";
+      return "Shift+F11";
+    }
+    onTriggered: components.settings.setValue("main", "webMode", "tv")
   }
 
   Action
   {
-    id: action_quit_win
-    shortcut: "Alt+F4"
+    enabled: mainWindow.webDesktopMode
+    shortcut: StandardKey.Close
     onTriggered: mainWindow.close()
   }
 
   Action
   {
-    id: action_debug_overlay
-    shortcut: "Ctrl+Shift+D"
-    onTriggered: mainWindow.toggleDebug()
+    enabled: mainWindow.webDesktopMode
+    shortcut: {
+      if (components.system.isMacos) return "Ctrl+M";
+      return "Meta+Down";
+    }
+    onTriggered: mainWindow.minimizeWindow()
   }
 
   Action
   {
-    id: action_fullscreen_win_alt
-    shortcut: "Alt+Return"
-    onTriggered: mainWindow.toggleFullscreen()
+    enabled: mainWindow.webDesktopMode
+    shortcut: StandardKey.Quit
+    onTriggered: mainWindow.close()
   }
 
   Action
   {
-    id: action_fullscreen_win
-    shortcut: "F11"
-    onTriggered: mainWindow.toggleFullscreen()
+    shortcut: "Ctrl+Shift+D"
+    enabled: mainWindow.webDesktopMode
+    onTriggered: mainWindow.toggleDebug()
   }
 
   Action
   {
-    id: action_fullscreen_mac
-    shortcut: "Ctrl+Meta+F"
+    shortcut: "Alt+Return"
+    enabled:
+    {
+      if (mainWindow.webDesktopMode && components.system.isWindows)
+        return true;
+      return false;
+    }
     onTriggered: mainWindow.toggleFullscreen()
   }
 
   Action
   {
-    id: action_switchmode
-    shortcut: "Ctrl+M"
-    onTriggered:
+    enabled: mainWindow.webDesktopMode
+    shortcut:
     {
-      if (mainWindow.webDesktopMode)
-        components.settings.cycleSetting("main.webMode")
+      if (components.system.isMacos)
+        return "Ctrl+Meta+F"
+      return "F11"
     }
+    onTriggered: mainWindow.toggleFullscreen()
   }
 
   Action
@@ -185,7 +181,6 @@ KonvergoWindow
       backgroundColor : "#111111"
       forceActiveFocus()
       mainWindow.reloadWebClient.connect(reload)
-      actionEnable(mainWindow.webDesktopMode)
     }
 
     onLoadingChanged:
@@ -207,7 +202,6 @@ KonvergoWindow
                           loadRequest.errorString + " [" + loadRequest.errorCode + "]</pre><br><br>" +
                           "Provide the <a target='_blank' href='file://"+ components.system.logFilePath + "'>logfile</a> as well."
       }
-      actionEnable(mainWindow.webDesktopMode)
     }
 
     onNewViewRequested: