Difference between revisions of "Patch for lcdprocclient for small displays for Mythtv-0.19"

From MythTV Official Wiki
Jump to: navigation, search
m (added to Patches category)
 
Line 215: Line 215:
  
 
</pre>
 
</pre>
 +
 +
[[Category:Patches]]

Latest revision as of 18:52, 9 March 2008

--KAFE 23:04, 1 March 2007 (UTC) did this patch for mythtv-0.19 to use the small (1 line / 9 characters) display of the AOpen XC Cube AV EA65

--- lcdprocclient.cpp.org	2005-12-10 06:11:52.000000000 +0100
+++ lcdprocclient.cpp	2007-02-28 22:33:43.000000000 +0100
@@ -29,6 +29,8 @@
 #define LCD_TIME_TIME       5000
 #define LCD_SCROLLLIST_TIME 2000
 
+int lcdStartCol = LCD_START_COL;
+
 LCDProcClient::LCDProcClient(LCDServer *lparent) :
     QObject(NULL, "LCDProcClient")
 {
@@ -52,6 +54,9 @@
     lcdHeight = 1;
     cellWidth = 1;
     cellHeight = 1;    
+    lcdStartCol = LCD_START_COL;
+    if (lcdWidth < 12)
+        lcdStartCol = 0;
    
     hostname = "";
     port = 13666;
@@ -419,6 +424,8 @@
     // the ghetto way
     sendToServer("screen_add Menu");
     setPriority("Menu", LOW);
+    if (lcdHeight > 1)
+    {
     sendToServer("widget_add Menu topWidget string");
     for (unsigned int i = 1; i < lcdHeight; i++) 
     {
@@ -427,7 +434,11 @@
         aString += " string";
         sendToServer(aString);
     }
-
+    }
+    else
+    {
+        sendToServer("widget_add Menu menuWidget1 string");
+    }
     // The Music Screen
     sendToServer("screen_add Music");
     setPriority("Music", LOW);
@@ -1040,7 +1051,10 @@
         setPriority("Menu", URGENT);
 
     // Write out the app name
+    if (lcdHeight >= 2)
+    {
     outputCenteredText("Menu", app_name, "topWidget", 1);
+    }
 
     QPtrListIterator<LCDMenuItem> it(*menuItems);
     LCDMenuItem *curItem;
@@ -1066,8 +1080,11 @@
     // If there isn't one selected item, then write it on the display and return
     if (!oneSelected)
     {
+        if (lcdHeight >= 2)
+        {
         sendToServer("widget_set Menu topWidget 1 1 \"No menu item selected\"");
         sendToServer("widget_set Menu menuWidget1 1 2 \"     ABORTING     \"");
+        }
         menuScrollTimer->stop();
         return;
     }
@@ -1093,7 +1110,7 @@
 
     // If there is only two lines on the display, then just write the selected
     //  item and leave
-    if (lcdHeight == 2)
+    if (lcdHeight <= 2)
     {
         it.toFirst();
         while ((curItem = it.current()) != 0)
@@ -1102,7 +1119,7 @@
             if (curItem->isSelected())
             {
                 // Set the scroll flag if necessary, otherwise set it to false
-                if (curItem->ItemName().length()  > (lcdWidth - LCD_START_COL))
+                if (curItem->ItemName().length()  > (lcdWidth - lcdStartCol))
                 {
                     menuPreScrollTimer->start(2000, true);
                     curItem->setScroll(true);
@@ -1112,9 +1129,27 @@
                     menuPreScrollTimer->stop();
                     curItem->setScroll(false);
                 }
-
+                if (lcdHeight == 2)
+                {
                 aString  = "widget_set Menu menuWidget1 1 2 \">";
+                }
+                else
+                {
+                    aString  = "widget_set Menu menuWidget1 1 1 \"";
+                }
 
+                if (lcdWidth < 12)
+                {
+                        switch(curItem->isChecked())
+                        {
+                        case CHECKED: aString += "X"; break;
+                        case UNCHECKED: aString += "O"; break;
+                        case NOTCHECKABLE: aString += ""; break;
+                        default: break;
+                        }
+                }
+                else
+                {
                 switch (curItem->isChecked())
                 {
                     case CHECKED: aString += "X "; break;
@@ -1122,8 +1157,9 @@
                     case NOTCHECKABLE: aString += "  "; break;
                     default: break;
                 }
+                }
 
-                aString += curItem->ItemName().left(lcdWidth - LCD_START_COL) +
+                aString += curItem->ItemName().left(lcdWidth - lcdStartCol) +
                            "\"";
                 sendToServer(aString);
                 return;
@@ -1183,7 +1219,7 @@
             default: break;
         }
 
-        aString += curItem->ItemName().left(lcdWidth - LCD_START_COL) + "\"";
+        aString += curItem->ItemName().left(lcdWidth - lcdStartCol) + "\"";
         sendToServer(aString);
 
         ++counter;
@@ -1224,10 +1260,10 @@
         ++it;
         // Don't setup for smooth scrolling if the item isn't long enough
         // (It causes problems with items being scrolled when they shouldn't)
-        if (curItem->ItemName().length()  > (lcdWidth - LCD_START_COL))
+        if (curItem->ItemName().length()  > (lcdWidth - lcdStartCol))
         {
             temp = temp.fill(QChar(' '), lcdWidth - curItem->getIndent() - 
-                             LCD_START_COL);
+                             lcdStartCol);
             curItem->setItemName(temp + curItem->ItemName());
             curItem->setScrollPos(curItem->getIndent() + temp.length());
             curItem->setScroll(true);
@@ -1273,7 +1309,7 @@
     // If there is only two lines on the display, then just write the selected
     // item and leave
     curItem = it.toFirst();
-    if (lcdHeight == 2)
+    if (lcdHeight <= 2)
     {
         it.toFirst();
         while ((curItem = it.current()) != 0)
@@ -1293,11 +1329,30 @@
                 // Stop the timer if this item really doesn't need to scroll.
                 // This should never have to get invoked because in theory
                 // the code in startMenu has done its job. . .
-                if (curItem->ItemName().length()  < (lcdWidth - LCD_START_COL))
+                if (curItem->ItemName().length()  < (lcdWidth - lcdStartCol))
                     menuScrollTimer->stop();
 
+                if (lcdHeight == 2)
+                {
                 aString  = "widget_set Menu menuWidget1 1 2 \">";
+                }
+                else
+                {
+                    aString  = "widget_set Menu menuWidget1 1 1 \"";
+                }
 
+                if (lcdWidth < 12)
+                {
+                        switch(curItem->isChecked())
+                        {
+                        case CHECKED: aString += "X"; break;
+                        case UNCHECKED: aString += "O"; break;
+                        case NOTCHECKABLE: aString += ""; break;
+                        default: break;
+                        }
+                }
+                else
+                {
                 switch(curItem->isChecked())
                 {
                     case CHECKED: aString += "X "; break;
@@ -1305,12 +1360,13 @@
                     case NOTCHECKABLE: aString += "  "; break;
                     default: break;
                 }
+                }
 
                 // Indent this item if nessicary
                 aString += bString.fill(' ', curItem->getIndent());
 
                 aString += curItem->ItemName().mid(curItem->getScrollPos(), 
-                                                   (lcdWidth - LCD_START_COL));
+                                                   (lcdWidth - lcdStartCol));
                 aString += "\"";
                 sendToServer(aString);
                 return;
@@ -1413,7 +1469,7 @@
 
             if (curItem->getScrollPos() <= longest_line)
                 aString += curItem->ItemName().mid(curItem->getScrollPos(), 
-                                                   (lcdWidth-LCD_START_COL));
+                                                   (lcdWidth-lcdStartCol));
 
             aString += "\"";
             sendToServer(aString);