From 14cd3a87e04b5b75e586b62a63153c09e593c71e Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Thu, 20 Aug 2015 18:05:14 +0000
Subject: mythtv: fix QT virtual keyboard patch

---
 abs/core/mythtv/stable-0.27/mythplugins/PKGBUILD   |  2 +-
 abs/core/mythtv/stable-0.27/mythtv/PKGBUILD        |  9 +++--
 .../stable-0.27/mythtv/fixQTvirtualkeyboard.patch  | 45 ++++++++++++++++++++++
 abs/core/mythtv/stable-0.27/mythtv/recordings      | 22 ++++++++++-
 4 files changed, 72 insertions(+), 6 deletions(-)
 create mode 100644 abs/core/mythtv/stable-0.27/mythtv/fixQTvirtualkeyboard.patch

diff --git a/abs/core/mythtv/stable-0.27/mythplugins/PKGBUILD b/abs/core/mythtv/stable-0.27/mythplugins/PKGBUILD
index 32acd30..1eedd22 100644
--- a/abs/core/mythtv/stable-0.27/mythplugins/PKGBUILD
+++ b/abs/core/mythtv/stable-0.27/mythplugins/PKGBUILD
@@ -9,7 +9,7 @@ pkgname=('mytharchive'
          'mythweather'
          'mythzoneminder')
 pkgver=0.27.5
-pkgrel=3
+pkgrel=4
 arch=('i686' 'x86_64')
 url="http://www.mythtv.org"
 license=('GPL')
diff --git a/abs/core/mythtv/stable-0.27/mythtv/PKGBUILD b/abs/core/mythtv/stable-0.27/mythtv/PKGBUILD
index ef238a4..a629cb5 100644
--- a/abs/core/mythtv/stable-0.27/mythtv/PKGBUILD
+++ b/abs/core/mythtv/stable-0.27/mythtv/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=mythtv
 pkgver=0.27.5
-pkgrel=3
+pkgrel=4
 commit_hash=`cat ../git_src/git_hash`
 pkgdesc="A Homebrew PVR project $commit_hash"
 arch=('i686' 'x86_64')
@@ -21,8 +21,10 @@ install='mythtv.install'
 
 patches=('myth_settings.patch' 
          'videoAlwaysUseBookmark.patch'
+         'fixQTvirtualkeyboard.patch'
          'suggestedstarttime.patch.v1')
-         #http://code.mythtv.org/trac/ticket/11562   next mythfilldatabase run in mythweb
+         #fixQTvirtualkeyboard.patch: https://code.mythtv.org/trac/ticket/12347
+         #suggestedstarttime.patch.v1: http://code.mythtv.org/trac/ticket/11562   next mythfilldatabase run in mythweb
 
 optdepends=()
 replaces=('mythvideo' 'myththemes')
@@ -103,5 +105,6 @@ package() {
 
 md5sums=('5f3e43567e62afe17bad39f5a9b604cf'
          '41098e898361a5a3cde3eaae358482a8'
+         'a853dff0f5c92ca58fcc1e389cd16266'
          '35a7fd3e3057691e3b1bf355bb9e8b16'
-         'c56731fa55f1d24b7229942561c2aafe')
+         '928de4b070d9f3b784d55c0db415eaf3')
diff --git a/abs/core/mythtv/stable-0.27/mythtv/fixQTvirtualkeyboard.patch b/abs/core/mythtv/stable-0.27/mythtv/fixQTvirtualkeyboard.patch
new file mode 100644
index 0000000..1688bd6
--- /dev/null
+++ b/abs/core/mythtv/stable-0.27/mythtv/fixQTvirtualkeyboard.patch
@@ -0,0 +1,45 @@
+--- src/mythtv/libs/libmythui/mythmainwindow.cpp.orig	2015-08-19 21:24:59.990554429 +0000
++++ src/mythtv/libs/libmythui/mythmainwindow.cpp	2015-08-19 21:23:33.851546588 +0000
+@@ -1380,7 +1380,7 @@
+             .arg(::GetCurrentThreadId()));
+ #endif
+     if (currentWidget())
+-    {
++#ifdef Q_OS_MAC
+         // don't disable the current widget, instead we disable all its children
+         // on mac, disabling the current active widget entirely prevent keyboard to
+         // work on the newly opened widget.
+@@ -1395,8 +1395,9 @@
+                 d->enabledWidgets[w] = true;
+             }
+         }
+-    }
+-
++#else
++        currentWidget()->setEnabled(false);
++#endif
+     d->widgetList.push_back(child);
+     child->winId();
+     child->raise();
+@@ -1419,11 +1420,8 @@
+     d->widgetList.erase(it);
+     QWidget *current = currentWidget();
+     if (!current)
+-    {
+         current = this;
+-        // We're be to the main window, enable it just in case
+-        setEnabled(true);
+-    }
++#ifdef Q_OS_MAC
+     else
+     {
+         QList<QWidget*> list = current->findChildren<QWidget *>();
+@@ -1438,6 +1436,8 @@
+         }
+     }
+     current->raise();
++#endif
++    current->setEnabled(true);
+     current->setFocus();
+     current->setMouseTracking(true);
+ 
diff --git a/abs/core/mythtv/stable-0.27/mythtv/recordings b/abs/core/mythtv/stable-0.27/mythtv/recordings
index e364f3c..984fea9 100644
--- a/abs/core/mythtv/stable-0.27/mythtv/recordings
+++ b/abs/core/mythtv/stable-0.27/mythtv/recordings
@@ -24,7 +24,8 @@ if [ -f /usr/share/mythtv/contrib/user_jobs/mythlink.pl ]
 then
     recdir="/data/storage/disk0/media/recordings"
     tmprecdir="/data/storage/disk0/media/tmp/recordings"
-    su - mythtv -c "perl /usr/share/mythtv/contrib/user_jobs/mythlink.pl --format '%U/%T/%T %- S%ssE%ep %- %oY-%om-%od %- %S' --link '$tmprecdir'"
+    rm -r $tmprecdir
+    su - mythtv -c "perl /usr/share/mythtv/contrib/user_jobs/mythlink.pl --format '%U/%T/%T %- S%ssE%ep %- %oY-%om-%od = %S' --link '$tmprecdir'"
 
     #delete Deleted recgroup and move files out of other dirs
     if [ -d "$tmprecdir/Deleted" ]
@@ -64,6 +65,22 @@ then
         newlink=`echo "$link" | sed 's/ - 0000-00-00 - / - /'`
         mv "$link" "$newlink"
     done
+    #add dash pt suffix if filename before the subtitle is the same
+    #so that plex will scan and include in library
+    uniqs="$(ls $tmprecdir/**/* | sed 's/ = .*//' | sort | uniq -d)"
+    SAVEIFS=$IFS
+    IFS=$'\n'
+    for link in $uniqs
+    do
+        i=1
+        for dup in `ls -v $link*`
+        do
+            newlink=`echo "$dup" | sed "s/ = /-pt$i = /"`
+            mv "$dup" "$newlink"
+            i=$((i+1))
+        done
+    done
+    IFS=$SAVEIFS
 
     #change symlinks mtime to match the file it is linked to
 #    for link in $tmprecdir/**/*
@@ -83,7 +100,8 @@ then
     if [[ `pidof "Plex Media Server"` ]]
     then
         #get plex section and update
-        /usr/LH/bin/plexmediascanner.sh -l | grep -i myth | cut -d: -f1 | while read -r line ; do
+        /usr/LH/bin/plexmediascanner.sh -l | grep -i myth | cut -d: -f1 | while read -r line
+        do
             /usr/LH/bin/plexmediascanner.sh --scan --refresh --section $line
         done
     fi
-- 
cgit v0.12

