From 339502da5c49b049ca3ce58198f6f20710c0a3b6 Mon Sep 17 00:00:00 2001
From: Chad Parry <github@chad.parry.org>
Date: Sat, 29 Jan 2011 09:55:33 -0700
Subject: [PATCH] Create a key binding that jumps directly to a random slideshow of the entire gallery

---
 mythplugins/mythgallery/mythgallery/iconview.h |    2 +-
 mythplugins/mythgallery/mythgallery/main.cpp   |   18 ++++++++++++++++--
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/mythplugins/mythgallery/mythgallery/iconview.h b/mythplugins/mythgallery/mythgallery/iconview.h
index 1b57e63..e447bb6 100644
--- a/mythplugins/mythgallery/mythgallery/iconview.h
+++ b/mythplugins/mythgallery/mythgallery/iconview.h
@@ -58,6 +58,7 @@ class IconView : public MythScreenType
     bool Create(void);
     bool keyPressEvent(QKeyEvent *);
     void customEvent(QEvent*);
+    void HandleRandomShow(void);
 
     QString GetError(void) { return m_errorStr; }
 
@@ -83,7 +84,6 @@ class IconView : public MythScreenType
     void HandleRotateCCW(void);
     void HandleDeleteCurrent(void);
     void HandleSlideShow(void);
-    void HandleRandomShow(void);
     void HandleSettings(void);
     void HandleEject(void);
     void HandleImport(void);
diff --git a/mythplugins/mythgallery/mythgallery/main.cpp b/mythplugins/mythgallery/mythgallery/main.cpp
index 82146ef..f1362f7 100644
--- a/mythplugins/mythgallery/mythgallery/main.cpp
+++ b/mythplugins/mythgallery/mythgallery/main.cpp
@@ -21,7 +21,7 @@
 Q_IMPORT_PLUGIN(dcrawplugin)
 #endif // DCRAW_SUPPORT
 
-static int run(MythMediaDevice *dev = NULL)
+static int run(MythMediaDevice *dev = NULL, bool startRandomShow = false)
 {
     QDir startdir(gCoreContext->GetSetting("GalleryDir"));
     if (startdir.exists() && startdir.isReadable())
@@ -33,7 +33,14 @@ static int run(MythMediaDevice *dev = NULL)
 
         if (iconview->Create())
         {
-            mainStack->AddScreen(iconview);
+            if (startRandomShow)
+            {
+                iconview->HandleRandomShow();
+            }
+            else
+            {
+                mainStack->AddScreen(iconview);
+            }
             return 0;
         }
         else
@@ -57,6 +64,11 @@ static void runGallery(void)
     run();
 }
 
+void runRandomSlideshow(void)
+{
+    run(NULL, true);
+}
+
 static void handleMedia(MythMediaDevice *dev)
 {
     if (dev && dev->isUsable())
@@ -67,6 +79,8 @@ static void setupKeys(void)
 {
     REG_JUMP("MythGallery", QT_TRANSLATE_NOOP("MythControls",
         "Image viewer / slideshow"), "", runGallery);
+    REG_JUMP("Random Slideshow", QT_TRANSLATE_NOOP("MythControls",
+        "Start Random Slideshow in thumbnail view"), "", runRandomSlideshow);
 
     REG_KEY("Gallery", "PLAY", QT_TRANSLATE_NOOP("MythControls",
         "Start/Stop Slideshow"), "P");
-- 
1.7.0.4

