[mythtv] [PATCH] Mythbrowser GUIOffset fix and misc additions
Tim Harvey
tharvey at alumni.calpoly.edu
Thu Jan 22 02:32:02 EST 2004
He's planning it, as he contacted me for the 'mythbrowsermanager' patch
(I goofed and didn't do my diff from the mythbrowser base dir) that I
forgot to include. It's attached if needed.
Tim
> -----Original Message-----
> From: mythtv-dev-bounces at mythtv.org
[mailto:mythtv-dev-bounces at mythtv.org]
> On Behalf Of Isaac Richards
> Sent: Wednesday, January 21, 2004 7:22 PM
> To: Development of mythtv
> Subject: Re: [mythtv] [PATCH] Mythbrowser GUIOffset fix and misc
additions
>
> On Wednesday 21 January 2004 05:43 am, Tim Harvey wrote:
> > Woops... how about I actually attach the patch this time!
>
> If Philppe doesn't apply this (haven't heard from him for a few
weeks),
> I'll
> do it in a day or so.
>
> Isaac
> _______________________________________________
> mythtv-dev mailing list
> mythtv-dev at mythtv.org
> http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev
-------------- next part --------------
Index: mythbrowser/README
===================================================================
RCS file: /var/lib/mythcvs/mythbrowser/README,v
retrieving revision 1.2
diff -u -r1.2 README
--- mythbrowser/README 30 Dec 2003 21:20:19 -0000 1.2
+++ mythbrowser/README 22 Jan 2004 01:49:51 -0000
@@ -56,7 +56,13 @@
First you have to enter the MythBrowser Settings to define your favorite
webpages and groups. This is also where you can adjust the zoom level of the
fonts on the webpages as well as define the command to execute mythbrowser
-(default: PREFIX+/bin/mythbrowser). Then exit setup.
+(default: PREFIX+/bin/mythbrowser). The Zoom Level is a percentage between
+20 (smaller text) and 300 (larger text). Check 'Scroll Page' to drag the
+page within the background when moving the mouse while holding 'Alt' or
+pressing the middle button. If 'Scroll Page' is unchecked then the
+background will be dragged instead of the page. Set the 'Scroll Speed'
+to a value according to how fast you want this mouse-scrolling to
+scroll. Then exit setup.
In the MythBrowser screen you can then select a webpage to display. If
you select (SPACE/Enter) on a group the browser will be startet with all
@@ -76,6 +82,11 @@
PrintScreen Popup Menu
Right mouse button Popup Menu
+
+ MouseScroll + MidBut Scroll Page/Background (depending on settings)
+ MouseScroll + AltBut Scroll Page/Background (depending on settings)
+ WheelScroll + MidBut Zoom Page
+ WheelScroll + AltBut Zoom Page
The popup menu (PrintScreen Button) allows to switch between tabs as well.
Furthermore it features a Back menu item, as well as a zoomin and zoomout
Index: mythbrowser/mythbookmarkmanager/bookmarkmanager.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythbrowser/mythbookmarkmanager/bookmarkmanager.cpp,v
retrieving revision 1.3
diff -u -r1.3 bookmarkmanager.cpp
--- mythbrowser/mythbookmarkmanager/bookmarkmanager.cpp 31 Dec 2003 21:47:44 -0000 1.3
+++ mythbrowser/mythbookmarkmanager/bookmarkmanager.cpp 22 Jan 2004 01:49:52 -0000
@@ -193,6 +193,11 @@
// delete myTree;
gContext->SaveSetting("WebBrowserZoomLevel", zoom->value());
gContext->SaveSetting("WebBrowserCommand", browser->text());
+ gContext->SaveSetting("WebBrowserScrollMode",
+ scrollmode->isChecked()?1:0);
+ gContext->SaveSetting("WebBrowserScrollSpeed", scrollspeed->value());
+ gContext->SaveSetting("WebBrowserHideScrollbars",
+ hidescrollbars->isChecked()?1:0);
}
@@ -278,11 +283,11 @@
hbox2->addWidget(zoomLabel);
zoom = new MythSpinBox(this);
- zoom->setMinValue(30);
+ zoom->setMinValue(20);
zoom->setMaxValue(300);
zoom->setLineStep(5);
hbox2->addWidget(zoom);
- zoom->setValue(gContext->GetNumSetting("WebBrowserZoomLevel", 200));
+ zoom->setValue(gContext->GetNumSetting("WebBrowserZoomLevel", 20));
QLabel *browserLabel = new QLabel(this);
browserLabel->setText("Browser:");
@@ -296,6 +301,35 @@
// browser->setText(gContext->GetSetting("WebBrowserCommand", "/usr/local/bin/mythbrowser"));
browser->setText(gContext->GetSetting("WebBrowserCommand", PREFIX "/bin/mythbrowser"));
+ // Scroll Settings
+ QHBoxLayout *hbox3 = new QHBoxLayout(vbox);
+
+ hidescrollbars = new MythCheckBox(this);
+ hidescrollbars->setText("Hide Scrollbars");
+ hidescrollbars->setChecked(gContext->GetNumSetting(
+ "WebBrowserHideScrollbars", 0)
+ == 1);
+ hbox3->addWidget(hidescrollbars);
+
+ scrollmode = new MythCheckBox(this);
+ scrollmode->setText("Scroll Page");
+ scrollmode->setChecked(gContext->GetNumSetting("WebBrowserScrollMode", 1)
+ == 1);
+ hbox3->addWidget(scrollmode);
+
+ QLabel *label = new QLabel(this);
+ label->setText("Scroll Speed:");
+ label->setBackgroundOrigin(QWidget::WindowOrigin);
+ label->setBackgroundOrigin(QWidget::WindowOrigin);
+ hbox3->addWidget(label);
+
+ scrollspeed = new MythSpinBox(this);
+ scrollspeed->setMinValue(1);
+ scrollspeed->setMaxValue(8);
+ scrollspeed->setLineStep(1);
+ hbox3->addWidget(scrollspeed);
+ scrollspeed->setValue(gContext->GetNumSetting("WebBrowserScrollSpeed", 4));
+
// Add new bookmark ------------------------------------
QHBoxLayout *hbox = new QHBoxLayout(vbox);
Index: mythbrowser/mythbookmarkmanager/bookmarkmanager.h
===================================================================
RCS file: /var/lib/mythcvs/mythbrowser/mythbookmarkmanager/bookmarkmanager.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 bookmarkmanager.h
--- mythbrowser/mythbookmarkmanager/bookmarkmanager.h 29 Oct 2003 16:04:50 -0000 1.1.1.1
+++ mythbrowser/mythbookmarkmanager/bookmarkmanager.h 22 Jan 2004 01:49:52 -0000
@@ -48,6 +48,9 @@
void setupView();
MythSpinBox *zoom;
+ MythSpinBox *scrollspeed;
+ MythCheckBox *scrollmode;
+ MythCheckBox *hidescrollbars;
MythLineEdit *browser;
QSqlDatabase *myDb;
MythListView *myBookmarksView;
Index: mythbrowser/mythbrowser/main.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythbrowser/mythbrowser/main.cpp,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 main.cpp
--- mythbrowser/mythbrowser/main.cpp 29 Oct 2003 16:04:51 -0000 1.1.1.1
+++ mythbrowser/mythbrowser/main.cpp 22 Jan 2004 01:49:52 -0000
@@ -39,6 +39,8 @@
int main(int argc, char **argv)
{
+ int x = 0, y = 0;
+ float xm = 0, ym = 0;
int zoom,width=-1,height=-1; // defaults
char usage[] = "Usage: mythbrowser [-z n] [-w n] [-h n] -u URL [URL]";
QStringList urls;
@@ -80,10 +82,15 @@
// gContext->SetMainWindow(mainWindow);
// a.setMainWidget(mainWindow);
+ // Obtain width/height and x/y offset from context
+ gContext->GetScreenSettings(x, width, xm, y, height, ym);
+
TabView *mainWindow =
new TabView(db, urls, zoom, width, height, Qt::WStyle_Customize | Qt::WStyle_NoBorder);
gContext->SetMainWindow(mainWindow);
a.setMainWidget(mainWindow);
+ mainWindow->setGeometry(x, y, width, height);
+ mainWindow->setFixedSize(QSize(width, height));
mainWindow->Show();
return a.exec();
Index: mythbrowser/mythbrowser/tabview.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythbrowser/mythbrowser/tabview.cpp,v
retrieving revision 1.4
diff -u -r1.4 tabview.cpp
--- mythbrowser/mythbrowser/tabview.cpp 31 Dec 2003 21:47:44 -0000 1.4
+++ mythbrowser/mythbrowser/tabview.cpp 22 Jan 2004 01:49:52 -0000
@@ -32,6 +32,7 @@
#include <kaction.h>
#include <kstdaction.h>
#include <khtml_part.h>
+#include <khtmlview.h>
#include "mythtv/mythcontext.h"
@@ -52,6 +53,19 @@
h=height-rect.height();
f=flags;
+ // Qt doesn't give you mousebutton states from QWheelEvent->state()
+ // so we have to remember the last mousebutton press/release state
+ lastButtonState = (ButtonState)0;
+
+ lastPosX = -1;
+ lastPosY = -1;
+ scrollSpeed = gContext->GetNumSetting("WebBrowserScrollSpeed", 4);
+ scrollPage = gContext->GetNumSetting("WebBrowserScrollMode", 1);
+ hideScrollbars = gContext->GetNumSetting("WebBrowserHideScrollbars", 0);
+ if (scrollPage == 1) {
+ scrollSpeed *= -1; // scroll page vs background
+ }
+
for(QStringList::Iterator it = urls.begin(); it != urls.end(); ++it) {
// is rect.height() really the height of the tab in pixels???
WebPage *page = new WebPage(*it,z,w,h,f);
@@ -59,6 +73,15 @@
this, SLOT( newUrlRequested(const KURL &,const KParts::URLArgs &)));
mytab->addTab(page,*it);
+/* moved this into show event processing
+ // Hide Scrollbars - Why doesn't this work??? TSH 1/20/04
+ if (hideScrollbars) {
+ KHTMLView* view = page->browser->view();
+ view->setVScrollBarMode(QScrollView::AlwaysOff);
+ view->setHScrollBarMode(QScrollView::AlwaysOff);
+ }
+*/
+
QPtrStack<QWidget> *currWidgetHistory = new QPtrStack<QWidget>;
widgetHistory.append(currWidgetHistory);
QValueStack<QString> *currUrlHistory = new QValueStack<QString>;
@@ -256,6 +279,7 @@
if (event->type() == QEvent::MouseButtonPress) {
QMouseEvent* me = (QMouseEvent*)event;
+ lastButtonState = me->stateAfter();
if(me->button() == Qt::RightButton) {
if(menuIsOpen)
emit closeMenu();
@@ -265,6 +289,61 @@
}
}
+ if (event->type() == QEvent::MouseButtonRelease) {
+ QMouseEvent* me = (QMouseEvent*)event;
+ lastButtonState = me->stateAfter();
+ }
+
+ QScrollView *view=((WebPage*)mytab->currentPage())->browser->view();
+ if (event->type() == QEvent::Show) {
+ // hide scrollbars - kind of a hack to do it on a show event but
+ // for some reason I can't get it to work upon creation of the page
+ // - TSH
+ if (hideScrollbars) {
+ QScrollView *view=((WebPage*)mytab->currentPage())->browser->view();
+ view->setVScrollBarMode(QScrollView::AlwaysOff);
+ view->setHScrollBarMode(QScrollView::AlwaysOff);
+ }
+ }
+
+ // MouseMove while middlebutton pressed pans page
+ int deltax = 0, deltay = 0;
+ if (event->type() == QEvent::MouseMove) {
+ QMouseEvent* me = (QMouseEvent*)event;
+ lastButtonState = me->stateAfter();
+ deltax = me->globalX() - lastPosX;
+ deltay = me->globalY() - lastPosY;
+ deltax *= scrollSpeed;
+ deltay *= scrollSpeed;
+ if (lastPosX != -1
+// && (lastButtonState & (LeftButton|AltButton))
+ && (lastButtonState & (MidButton|AltButton))
+ && !view->isHorizontalSliderPressed()
+ && !view->isVerticalSliderPressed() )
+ {
+ view->scrollBy(deltax, deltay);
+ }
+ lastPosX = me->globalX();
+ lastPosY = me->globalY();
+ }
+
+ // MouseWheel scrolling while middlebutton/ctrlkey pressed to zoom in/out
+ if (event->type() == QEvent::Wheel) {
+ QWheelEvent* we = (QWheelEvent*)event;
+ if (lastButtonState & MidButton || we->state() & AltButton) {
+ if (we->delta() > 0) {
+ we->accept();
+ ((WebPage*)mytab->currentPage())->zoomIn();
+ return true;
+ } else if (we->delta() < 0) {
+ we->accept();
+ ((WebPage*)mytab->currentPage())->zoomOut();
+ return true;
+ }
+ }
+
+ }
+
if(menuIsOpen)
return false;
Index: mythbrowser/mythbrowser/tabview.h
===================================================================
RCS file: /var/lib/mythcvs/mythbrowser/mythbrowser/tabview.h,v
retrieving revision 1.2
diff -u -r1.2 tabview.h
--- mythbrowser/mythbrowser/tabview.h 30 Dec 2003 21:20:20 -0000 1.2
+++ mythbrowser/mythbrowser/tabview.h 22 Jan 2004 01:49:52 -0000
@@ -78,6 +78,13 @@
QPtrList<WIDGET_HISTORY> widgetHistory;
QPtrList<URL_HISTORY> urlHistory;
+
+ ButtonState lastButtonState;
+ int lastPosX;
+ int lastPosY;
+ int scrollSpeed;
+ int scrollPage;
+ int hideScrollbars;
};
class PopupBox : public QDialog
More information about the mythtv-dev
mailing list