[mythtv] [patch] EPG scrolling with keyborad repeat, etc

avalanche at beyondmonkey.com avalanche at beyondmonkey.com
Mon Sep 15 20:19:56 EDT 2003


Some updates to the EPG:
Enables scrolling in EPG by holding down a key. (system keyboard repeat req.)
Changed some redraw stuff so the redraws are more simultaneous,
adds some snappiness to the yellow selector box and in general.
Fixed some key repeat issues so scrolling will stop as soon as the
key is released (Seems to be a general QT issue, see patch for more details).
Changed the max displayable channels from 8 to 12 (for more then 8, 
smaller font settings req.).

av
--
Index: mythtv/libs/libmythtv/guidegrid.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/guidegrid.cpp,v
retrieving revision 1.126
diff -u -d -p -r1.126 guidegrid.cpp
--- mythtv/libs/libmythtv/guidegrid.cpp 8 Sep 2003 04:22:32 -0000 1.126
+++ mythtv/libs/libmythtv/guidegrid.cpp 15 Sep 2003 16:02:37 -0000
@@ -213,6 +213,9 @@ GuideGrid::GuideGrid(MythMainWindow *par
 
     setNoErase();
     gContext->addListener(this);
+    
+    keyDown = false;
+    setFocusPolicy(QWidget::StrongFocus); //get keyRelease events after refocus
 }
 
 GuideGrid::~GuideGrid()
@@ -237,6 +240,20 @@ GuideGrid::~GuideGrid()
 
 void GuideGrid::keyPressEvent(QKeyEvent *e)
 {
+    //keyDown limits keyrepeats to prevent continued scrolling
+    //after key is released. Note: Qt's keycompress should handle
+    //this but will fail with fast key strokes and keyboard repeat
+    //enabled. Keys will not be marked as autorepeat and flood buffer.
+    //setFocusPolicy(QWidget::StrongFocus) in constructor is important 
+    //or keyRelease events will not be received after a refocus.
+    
+    if(keyDown && e->key() != Key_Escape && e->key() != Key_C)
+        return; //check for Key_Escape incase something goes wrong 
+                //with KeyRelease events, shouldn't happen.
+       
+    if(e->key() != Key_Control)
+        keyDown = true;    
+    
     if (e->state() == Qt::ControlButton)
     {
         switch (e->key())
@@ -279,6 +296,14 @@ void GuideGrid::keyPressEvent(QKeyEvent 
     }
 }
 
+void GuideGrid::keyReleaseEvent(QKeyEvent *e)
+{
+    //note: KeyRelease events may not reflect the released 
+    //key if delayed (key==0 instead).
+    e->key(); //stop compiler warning
+    keyDown = false;
+}
+
 void GuideGrid::updateBackground(void)
 {
     QPixmap bground(size());
@@ -1170,9 +1195,9 @@ void GuideGrid::cursorLeft()
     else
     {
         fillProgramRowInfos(m_currentRow);
-        update(programRect);
-        update(infoRect);
-        update(timeRect);
+        repaint(programRect, false);
+        repaint(infoRect, false);
+        repaint(timeRect, false);
     }
 }
 
@@ -1199,9 +1224,9 @@ void GuideGrid::cursorRight()
     else
     {
         fillProgramRowInfos(m_currentRow);
-        update(programRect);
-        update(infoRect);
-        update(timeRect);
+        repaint(programRect, false);
+        repaint(infoRect, false);
+        repaint(timeRect, false); 
     }
 }
 
@@ -1219,8 +1244,8 @@ void GuideGrid::cursorDown()
         else
         {
             fillProgramRowInfos(m_currentRow);
-            update(programRect);
-            update(infoRect);
+            repaint(programRect, false);
+            repaint(infoRect, false);
         }
     }
     else
@@ -1241,8 +1266,8 @@ void GuideGrid::cursorUp()
         else
         {
             fillProgramRowInfos(m_currentRow);
-            update(programRect);
-            update(infoRect);
+            repaint(programRect, false);
+            repaint(infoRect, false);
         }
     }
     else
@@ -1265,10 +1290,10 @@ void GuideGrid::scrollLeft()
     fillTimeInfos();
     fillProgramInfos();
 
-    update(infoRect);
-    update(timeRect);
-    update(dateRect);
-    update(programRect);
+    repaint(programRect, false);
+    repaint(infoRect, false);
+    repaint(dateRect, false);
+    repaint(timeRect, false);
 }
 
 void GuideGrid::scrollRight()
@@ -1286,10 +1311,10 @@ void GuideGrid::scrollRight()
     fillTimeInfos();
     fillProgramInfos();
 
-    update(infoRect);
-    update(dateRect);
-    update(timeRect);
-    update(programRect);
+    repaint(programRect, false);
+    repaint(infoRect, false);
+    repaint(dateRect, false);
+    repaint(timeRect, false);
 }
 
 void GuideGrid::setStartChannel(int newStartChannel)
@@ -1318,9 +1343,9 @@ void GuideGrid::scrollDown()
     m_programs[DISPLAY_CHANS - 1] = proglist;
     fillProgramInfos();
 
-    update(infoRect);
-    update(channelRect);
-    update(programRect);
+    repaint(programRect, false);
+    repaint(infoRect, false);
+    repaint(channelRect, false);
 }
 
 void GuideGrid::scrollUp()
@@ -1339,9 +1364,9 @@ void GuideGrid::scrollUp()
     m_programs[0] = proglist;
     fillProgramInfos();
 
-    update(infoRect);
-    update(channelRect);
-    update(programRect);
+    repaint(programRect, false);
+    repaint(infoRect, false);
+    repaint(channelRect, false);
 }
 
 void GuideGrid::dayLeft()
@@ -1351,7 +1376,7 @@ void GuideGrid::dayLeft()
     fillTimeInfos();
     fillProgramInfos();
 
-    update(fullRect);
+    repaint(fullRect, false);
 }
 
 void GuideGrid::dayRight()
@@ -1361,7 +1386,7 @@ void GuideGrid::dayRight()
     fillTimeInfos();
     fillProgramInfos();
 
-    update(fullRect);
+    repaint(fullRect, false);
 }
 
 void GuideGrid::pageLeft()
@@ -1380,7 +1405,7 @@ void GuideGrid::pageLeft()
     fillTimeInfos();
     fillProgramInfos();
 
-    update(fullRect);
+    repaint(fullRect, false);
 }
 
 void GuideGrid::pageRight()
@@ -1399,7 +1424,7 @@ void GuideGrid::pageRight()
     fillTimeInfos();
     fillProgramInfos();
 
-    update(fullRect);
+    repaint(fullRect, false);
 }
 
 void GuideGrid::pageDown()
@@ -1408,7 +1433,7 @@ void GuideGrid::pageDown()
 
     fillProgramInfos();
 
-    update(fullRect);
+    repaint(fullRect, false);
 }
 
 void GuideGrid::pageUp()
@@ -1417,7 +1442,7 @@ void GuideGrid::pageUp()
 
     fillProgramInfos();
 
-    update(fullRect);
+    repaint(fullRect, false);
 }
  
 void GuideGrid::showProgFinder()
Index: mythtv/libs/libmythtv/guidegrid.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/guidegrid.h,v
retrieving revision 1.47
diff -u -d -p -r1.47 guidegrid.h
--- mythtv/libs/libmythtv/guidegrid.h 8 Sep 2003 04:22:32 -0000 1.47
+++ mythtv/libs/libmythtv/guidegrid.h 15 Sep 2003 16:02:37 -0000
@@ -23,7 +23,7 @@ class TV;
 class QTimer;
 class QWidget;
 
-#define MAX_DISPLAY_CHANS 8
+#define MAX_DISPLAY_CHANS 12
 #define MAX_DISPLAY_TIMES 30
 
 // Use this function to instantiate a guidegrid instance.
@@ -81,6 +81,7 @@ class GuideGrid : public MythDialog
 
   private:
     void keyPressEvent(QKeyEvent *e);
+    void keyReleaseEvent(QKeyEvent *e);
 
     void updateBackground(void);
     void paintDate(QPainter *);
@@ -163,6 +164,7 @@ class GuideGrid : public MythDialog
     QSqlDatabase *m_db;
 
     bool ignoreevents;
+    bool keyDown;
 };
 
 #endif
Index: mythtv/programs/mythfrontend/globalsettings.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfrontend/globalsettings.cpp,v
retrieving revision 1.95
diff -u -d -p -r1.95 globalsettings.cpp
--- mythtv/programs/mythfrontend/globalsettings.cpp 13 Sep 2003 15:41:41 -0000 1.95
+++ mythtv/programs/mythfrontend/globalsettings.cpp 15 Sep 2003 16:02:39 -0000
@@ -920,7 +920,7 @@ public:
 class EPGChanDisplay: public SpinBoxSetting, public GlobalSetting {
 public:
     EPGChanDisplay():
-        SpinBoxSetting(3, 8, 1), GlobalSetting("chanPerPage") {
+        SpinBoxSetting(3, 12, 1), GlobalSetting("chanPerPage") {
         setLabel("Channels to Display");
  setValue(5);
  
-------------- next part --------------
A non-text attachment was scrubbed...
Name: epgscroll.diff
Type: application/octet-stream
Size: 7225 bytes
Desc: not available
Url : http://mythtv.org/pipermail/mythtv-dev/attachments/20030915/357be087/epgscroll.obj


More information about the mythtv-dev mailing list