Ticket #3684: patch_videomanager

File patch_videomanager, 9.4 KB (added by jmortensen@…, 17 years ago)

patch

Line 
1Index: video-ui.xml
2===================================================================
3--- video-ui.xml        (revision 13165)
4+++ video-ui.xml        (working copy)
5@@ -279,6 +279,26 @@
6       </textarea>
7     </container>
8 
9+    <container name="entertitle">
10+      <area>220,200,360,200</area>
11+      <image name="box" draworder="7">
12+        <filename>mv-popup.png</filename>
13+        <position>0,0</position>
14+      </image>
15+      <textarea name="msg" draworder="7" align="center">
16+        <font>directorfnt</font>
17+        <value>Enter IMDB Title</value>
18+        <area>0,15,360,25</area>
19+      </textarea>
20+      <textarea name="titlehold" draworder="7" align="center">
21+        <font>titlefnt</font>
22+        <area>0,57,360,50</area>
23+      </textarea>
24+        <blackhole name="title_hack" draworder="0">
25+            <area>310,95,300,40</area>
26+        </blackhole>       
27+    </container>
28+
29     <container name="playwait">
30       <area>0,0,800,600</area>
31       <textarea name="ld1" draworder="0">
32Index: videomanager.h
33===================================================================
34--- videomanager.h      (revision 13165)
35+++ videomanager.h      (working copy)
36@@ -14,7 +14,8 @@
37         SHOWING_MAINWINDOW = 0,
38         SHOWING_EDITWINDOW,
39         SHOWING_IMDBLIST,
40-        SHOWING_IMDBMANUAL
41+        SHOWING_IMDBMANUAL,
42+        SHOWING_IMDBTITLE
43     };
44 }
45 
46@@ -32,8 +33,10 @@
47     int videoExitType() { return 0; }
48 
49   public slots:
50+    void slotManualTitle();
51     void slotManualIMDB();
52     void slotAutoIMDB();
53+    void SearchIMDB(QString title);
54     void slotEditMeta();
55     void slotRemoveVideo();
56     void slotResetMeta();
57@@ -65,6 +68,7 @@
58 
59   private:
60     void handleIMDBList();
61+    void handleIMDBTitle();
62     void handleIMDBManual();
63     void doParental(int amount);
64 
65@@ -85,6 +89,7 @@
66     void updateMovieList(QPainter *);
67     void updateInfo(QPainter *);
68     void updateIMDBEnter(QPainter *);
69+    void updateIMDBTitle(QPainter *);
70 
71     void grayOut(QPainter *);
72 
73@@ -98,6 +103,7 @@
74 
75     QStringList movieList;
76     QString curIMDBNum;
77+    QString curTitle;
78 
79     std::auto_ptr<QPixmap> bgTransBackup;
80     Metadata *curitem;
81@@ -115,6 +121,7 @@
82     QRect imdbEnterRect;
83 
84     QString movieNumber;
85+    QString movieTitle;
86 
87     MythPopupBox *popup;
88     bool expectingPopup;
89Index: videomanager.cpp
90===================================================================
91--- videomanager.cpp    (revision 13165)
92+++ videomanager.cpp    (working copy)
93@@ -21,6 +21,7 @@
94 #include "editmetadata.h"
95 #include "videoutils.h"
96 
97+
98 namespace
99 {
100     class ListBehaviorManager
101@@ -320,23 +321,47 @@
102 
103 void VideoManager::keyPressEvent(QKeyEvent *e)
104 {
105
106     if (isbusy) // ignore keypresses while doing http query
107         return;
108 
109     bool handled = false;
110     QStringList actions;
111-    gContext->GetMainWindow()->TranslateKeyPress("Video", e, actions);
112 
113+    if (m_state == SHOWING_IMDBTITLE)
114+    {
115+        int key = e->ascii();
116+
117+        if ((key >= 32) && (key <= 122))
118+        { // display character
119+            curTitle = curTitle + e->text();
120+            update(imdbEnterRect);
121+
122+        } else if (key == 8)
123+        {   // backspace
124+            curTitle.truncate(curTitle.length()-1);
125+            update(imdbEnterRect);
126+        } else
127+        {
128+            gContext->GetMainWindow()->TranslateKeyPress("Video", e, actions);
129+        }
130+    } else
131+    {
132+        gContext->GetMainWindow()->TranslateKeyPress("Video", e, actions);
133+    }
134     for (unsigned int i = 0; i < actions.size() && !handled; i++)
135     {
136         QString action = actions[i];
137         handled = true;
138+
139         if (action == "SELECT" && allowselect)
140         {
141             if (m_state == SHOWING_IMDBLIST)
142                 handleIMDBList();
143             else if (m_state == SHOWING_IMDBMANUAL)
144                 handleIMDBManual();
145+            else if (m_state == SHOWING_IMDBTITLE)
146+                handleIMDBTitle();
147             else
148                slotEditMeta();
149             return;
150@@ -817,7 +842,7 @@
151         count++;
152     }
153 
154-    // if only a single match, assume this is it
155+     //if only a single match, assume this is it
156     if (count == 1)
157     {
158         movieNumber = movieList[0].section(':', 0, 0);
159@@ -828,13 +853,14 @@
160         movieList.push_back(""); // visual separator - can't get selected
161     }
162 
163-    movieList.push_back("manual:Manually Enter IMDB #");
164+    movieList.push_back("manualimdb:Manually Enter IMDB #");
165+    movieList.push_back("manualtitle:Manually Enter Title");
166     movieList.push_back("reset:Reset Entry");
167     movieList.push_back("cancel:Cancel");
168 
169     m_movie_list_behave->setItemCount(movieList.size());
170     if (count > 0)
171-        m_movie_list_behave->setSkipIndex(movieList.size() - 4);
172+        m_movie_list_behave->setSkipIndex(movieList.size() - 5);
173     else
174         m_movie_list_behave->setSkipIndex();
175 
176@@ -852,7 +878,7 @@
177     QRect r = e->rect();
178     QPainter p(this);
179 
180-    if (m_state == SHOWING_MAINWINDOW || m_state == SHOWING_IMDBMANUAL)
181+    if (m_state == SHOWING_MAINWINDOW || m_state == SHOWING_IMDBMANUAL || m_state == SHOWING_IMDBTITLE)
182     {
183        if (r.intersects(listRect) && noUpdate == false)
184        {
185@@ -867,6 +893,11 @@
186            noUpdate = true;
187            updateIMDBEnter(&p);
188        }
189+       if (r.intersects(imdbEnterRect) && m_state == SHOWING_IMDBTITLE)
190+       {
191+           noUpdate = true;
192+           updateIMDBTitle(&p);
193+       }
194     }
195 
196     if (m_state == SHOWING_IMDBLIST)
197@@ -1007,6 +1038,29 @@
198     p->drawPixmap(pr.topLeft(), pix);
199 }
200 
201+void VideoManager::updateIMDBTitle(QPainter *p)
202+{
203+    QRect pr = imdbEnterRect;
204+    QPixmap pix(pr.size());
205+    pix.fill(this, pr.topLeft());
206+    QPainter tmp(&pix);
207+
208+    LayerSet *container = m_theme->GetSet("entertitle");
209+    if (container)
210+    {
211+        checkedSetText((UITextType *)container->GetType("titlehold"), curTitle);
212+
213+        for (int i = 0; i < 25; ++i)
214+        {
215+            container->Draw(&tmp, i, 0);
216+        }
217+    }
218+
219+    tmp.end();
220+
221+    p->drawPixmap(pr.topLeft(), pix);
222+}
223+
224 void VideoManager::updateInfo(QPainter *p)
225 {
226     QRect pr = infoRect;
227@@ -1285,6 +1339,8 @@
228         popup->addButton(tr("Search IMDB"), this, SLOT(slotAutoIMDB()));
229         popup->addButton(tr("Manually Enter IMDB #"), this,
230                          SLOT(slotManualIMDB()));
231+        popup->addButton(tr("Manually Enter IMDB title"), this,
232+                         SLOT(slotManualTitle()));
233         popup->addButton(tr("Reset Metadata"), this, SLOT(slotResetMeta()));
234         popup->addButton(tr("Toggle Browseable"), this,
235                          SLOT(slotToggleBrowseable()));
236@@ -1335,6 +1391,37 @@
237     RefreshMovieList(false);
238 }
239 
240+
241+void VideoManager::slotManualTitle()
242+{
243+    cancelPopup();
244+
245+    backup->begin(this);
246+    backup->drawPixmap(0, 0, myBackground);
247+    backup->end();
248+    curTitle = "";
249+    m_state = SHOWING_IMDBTITLE;
250+    update(fullRect);
251+    movieNumber = "";
252+}
253+
254+void VideoManager::handleIMDBTitle()
255+{
256+   
257+    QPainter p(this);
258+    movieTitle = curTitle;
259+
260+    backup->begin(this);
261+    grayOut(backup.get());
262+    doWaitBackground(p, curTitle);
263+    backup->end();
264+
265+    qApp->processEvents();
266+   
267+    m_state = SHOWING_EDITWINDOW;
268+    SearchIMDB(curTitle);
269+}
270+
271 void VideoManager::slotManualIMDB()
272 {
273     cancelPopup();
274@@ -1408,8 +1495,10 @@
275         movieNumber = "";
276         return;
277     }
278-    else if (movieNumber == "manual")
279+    else if (movieNumber == "manualimdb")
280          slotManualIMDB();
281+    else if (movieNumber == "manualtitle")
282+         slotManualTitle();
283     else if (movieNumber == "reset")
284          slotResetMeta();
285     else if (movieNumber == "")
286@@ -1441,16 +1530,23 @@
287         backup->end();
288         qApp->processEvents(); // Without this we get drawing errors.
289 
290-        m_state = SHOWING_MAINWINDOW;
291-        update(infoRect);
292-        update(listRect);
293-        update(fullRect);
294+        exitWin();
295+//        m_state = SHOWING_MAINWINDOW;
296+//        update(infoRect);
297+//        update(listRect);
298+//        update(fullRect);
299         movieNumber = "";
300     }
301 }
302 
303 void VideoManager::slotAutoIMDB()
304 {
305+    SearchIMDB("");
306+}
307+
308+void VideoManager::SearchIMDB(QString title)
309+{
310+   
311     cancelPopup();
312 
313     // Do queries
314@@ -1463,26 +1559,33 @@
315         backup->begin(this);
316         grayOut(backup.get());
317         backup->end();
318-
319-        // set the title for the wait background
320-        doWaitBackground(p, curitem->Title());
321-        backup->flush();
322-
323         int ret;
324+       
325+        if (title=="")
326+        {
327+            // set the title for the wait background
328+            doWaitBackground(p, curitem->Title());
329+            backup->flush();
330 
331-        if (curitem->InetRef() == VIDEO_INETREF_DEFAULT)
332+            if (curitem->InetRef() == VIDEO_INETREF_DEFAULT)
333+            {
334+                    ret = GetMovieListing(curitem->Title());
335+            }
336+            else
337+            {
338+                movieNumber = curitem->InetRef();
339+                ret = -1;
340+            }
341+        } else
342         {
343-            ret = GetMovieListing(curitem->Title());
344+            doWaitBackground(p, title);
345+            ret = GetMovieListing(title);
346         }
347-        else
348-        {
349-            movieNumber = curitem->InetRef();
350-            ret = 1;
351-        }
352-
353+           
354         VERBOSE(VB_IMPORTANT,
355                 QString("GetMovieList returned %1 possible matches").arg(ret));
356-        if (ret == 1)
357+
358+        if (ret == -1)
359         {
360             if (movieNumber.isNull() || movieNumber.length() == 0)
361             {