Ticket #4337: mythbrowser2.patch
File mythbrowser2.patch, 11.3 KB (added by , 16 years ago) |
---|
-
mythbrowser/tabview.cpp
42 42 43 43 using namespace std; 44 44 45 TabView::TabView(MythMainWindow *parent, const char *name, QStringList urls, 45 TabView::TabView(MythMainWindow *parent, const char *name, QStringList urls, 46 46 int zoom, int width, int height, WFlags flags) 47 47 :MythDialog(parent, name) 48 48 { … … 69 69 scrollSpeed = gContext->GetNumSetting("WebBrowserScrollSpeed", 4); 70 70 scrollPage = gContext->GetNumSetting("WebBrowserScrollMode", 1); 71 71 hideScrollbars = gContext->GetNumSetting("WebBrowserHideScrollbars", 0); 72 if (scrollPage == 1) 72 if (scrollPage == 1) 73 73 scrollSpeed *= -1; // scroll page vs background 74 74 75 75 urlHistory.setAutoDelete(true); … … 109 109 void TabView::pageCompleted(WebPage *page) 110 110 { 111 111 // Strip leading and trailing whitespace from page title 112 QString title = 112 QString title = 113 113 page->browser->htmlDocument().title().string().stripWhiteSpace(); 114 114 115 115 if (title.isEmpty()) … … 190 190 int step = 5; 191 191 192 192 // speed up mouse movement if the same key is held down 193 if (action == lastMouseAction && 193 if (action == lastMouseAction && 194 194 lastMouseActionTime.msecsTo(QTime::currentTime()) < 500) 195 195 { 196 196 lastMouseActionTime = QTime::currentTime(); … … 205 205 mouseKeyCount = 1; 206 206 } 207 207 208 if (action == "MOUSEUP") 208 if (action == "MOUSEUP") 209 209 { 210 210 QPoint curPos = QCursor::pos(); 211 211 QCursor::setPos(curPos.x(), curPos.y() - step); 212 212 } 213 else if (action == "MOUSELEFT") 213 else if (action == "MOUSELEFT") 214 214 { 215 215 QPoint curPos = QCursor::pos(); 216 216 QCursor::setPos(curPos.x() - step, curPos.y()); 217 217 } 218 else if (action == "MOUSERIGHT") 218 else if (action == "MOUSERIGHT") 219 219 { 220 220 QPoint curPos = QCursor::pos(); 221 221 QCursor::setPos(curPos.x() + step, curPos.y()); 222 222 } 223 else if (action == "MOUSEDOWN") 223 else if (action == "MOUSEDOWN") 224 224 { 225 225 QPoint curPos = QCursor::pos(); 226 226 QCursor::setPos(curPos.x(), curPos.y() + step); 227 227 } 228 else if (action == "MOUSELEFTBUTTON") 228 else if (action == "MOUSELEFTBUTTON") 229 229 { 230 230 QPoint curPos = mouse->pos(); 231 231 QWidget *widget = QApplication::widgetAt(curPos, TRUE); 232 232 233 if (widget) 233 if (widget) 234 234 { 235 235 curPos = widget->mapFromGlobal(curPos); 236 236 … … 240 240 241 241 me = new QMouseEvent(QEvent::MouseButtonRelease, curPos, 242 242 Qt::LeftButton, Qt::NoButton); 243 QApplication::postEvent(widget, me); 243 QApplication::postEvent(widget, me); 244 244 } 245 245 } 246 246 } … … 275 275 276 276 int index = mytab->currentPageIndex(); 277 277 278 // delete web pages stored in history 278 // delete web pages stored in history 279 279 urlHistory.remove(index); 280 280 281 281 // delete current web page … … 315 315 caption->setAlignment(Qt::AlignCenter); 316 316 317 317 popup->addLabel(tr("Group:"), MythPopupBox::Small); 318 MythRemoteLineEdit *group = new MythRemoteLineEdit(popup); 318 MythRemoteLineEdit *group = new MythRemoteLineEdit(popup); 319 319 popup->addWidget(group); 320 320 321 321 popup->addLabel(tr("Description:"), MythPopupBox::Small); 322 MythRemoteLineEdit *desc = new MythRemoteLineEdit(popup); 322 MythRemoteLineEdit *desc = new MythRemoteLineEdit(popup); 323 323 popup->addWidget(desc); 324 324 325 325 popup->addLabel(tr("URL:"), MythPopupBox::Small); 326 MythRemoteLineEdit *url = new MythRemoteLineEdit(popup); 326 MythRemoteLineEdit *url = new MythRemoteLineEdit(popup); 327 327 url->setText(((WebPage*)mytab->currentPage())->browser->baseURL().htmlURL()); 328 328 popup->addWidget(url); 329 329 … … 354 354 QString descStr = QString(desc); 355 355 QString urlStr = QString(url); 356 356 urlStr.stripWhiteSpace(); 357 if( !urlStr.startsWith("http://") && !urlStr.startsWith("https://") && 357 if( !urlStr.startsWith("http://") && !urlStr.startsWith("https://") && 358 358 !urlStr.startsWith("file:/") ) 359 359 urlStr.prepend("http://"); 360 360 … … 394 394 395 395 MythRemoteLineEdit *editor = new MythRemoteLineEdit(popup); 396 396 popup->addWidget(editor); 397 editor->setFocus(); 397 editor->setFocus(); 398 398 399 399 popup->addButton(tr("OK"), popup, SLOT(accept())); 400 400 popup->addButton(tr("Cancel"), popup, SLOT(reject())); … … 427 427 connect(page,SIGNAL( newUrlRequested(const KURL &,const KParts::URLArgs&)), 428 428 this, SLOT( newUrlRequested(const KURL &,const KParts::URLArgs &))); 429 429 430 connect(page, SIGNAL( newWindowRequested( const KURL &, const KParts::URLArgs &, 431 const KParts::WindowArgs &, KParts::ReadOnlyPart *&) ), 432 this, SLOT( newWindowRequested( const KURL &, const KParts::URLArgs &, 430 connect(page, SIGNAL( newWindowRequested( const KURL &, const KParts::URLArgs &, 431 const KParts::WindowArgs &, KParts::ReadOnlyPart *&) ), 432 this, SLOT( newWindowRequested( const KURL &, const KParts::URLArgs &, 433 433 const KParts::WindowArgs &, KParts::ReadOnlyPart *&) ) ); 434 434 connect(page, SIGNAL( pageCompleted(WebPage *) ), 435 435 this, SLOT( pageCompleted(WebPage *) ) ); … … 451 451 452 452 if (mytab->tabLabel(mytab->currentPage()) == "") 453 453 { 454 // if the tab title is blank then a new blank web page has already been 455 // created for a popup window just need to open the URL 454 // if the tab title is blank then a new blank web page has already been 455 // created for a popup window just need to open the URL 456 456 ((WebPage*)mytab->currentPage())->openURL(url.url()); 457 457 458 458 mytab->setTabLabel(mytab->currentPage(), tr("Loading...")); … … 485 485 { 486 486 object = object; 487 487 488 if (event->type() == QEvent::MouseButtonPress) 488 if (event->type() == QEvent::MouseButtonPress) 489 489 { 490 490 QMouseEvent* me = (QMouseEvent*)event; 491 491 … … 500 500 } 501 501 } 502 502 503 if (event->type() == QEvent::MouseButtonRelease) 503 if (event->type() == QEvent::MouseButtonRelease) 504 504 { 505 505 QMouseEvent* me = (QMouseEvent*)event; 506 506 lastButtonState = me->stateAfter(); 507 507 } 508 508 509 509 QScrollView *view=((WebPage*)mytab->currentPage())->browser->view(); 510 if (event->type() == QEvent::Show) 510 if (event->type() == QEvent::Show) 511 511 { 512 // hide scrollbars - kind of a hack to do it on a show event but 513 // for some reason I can't get it to work upon creation of the page 512 // hide scrollbars - kind of a hack to do it on a show event but 513 // for some reason I can't get it to work upon creation of the page 514 514 // - TSH 515 if (hideScrollbars) 515 if (hideScrollbars) 516 516 { 517 517 QScrollView *view=((WebPage*)mytab->currentPage())->browser->view(); 518 518 view->setVScrollBarMode(QScrollView::AlwaysOff); … … 522 522 523 523 // MouseMove while middlebutton pressed pans page 524 524 int deltax = 0, deltay = 0; 525 if (event->type() == QEvent::MouseMove) 525 if (event->type() == QEvent::MouseMove) 526 526 { 527 527 QMouseEvent* me = (QMouseEvent*)event; 528 528 lastButtonState = me->stateAfter(); … … 530 530 deltay = me->globalY() - lastPosY; 531 531 deltax *= scrollSpeed; 532 532 deltay *= scrollSpeed; 533 if (lastPosX != -1 534 // && (lastButtonState & (LeftButton|AltButton)) 535 && (lastButtonState & (MidButton|AltButton)) 533 if (lastPosX != -1 534 // && (lastButtonState & (LeftButton|AltButton)) 535 && (lastButtonState & (MidButton|AltButton)) 536 536 && !view->isHorizontalSliderPressed() 537 && !view->isVerticalSliderPressed() ) 537 && !view->isVerticalSliderPressed() ) 538 538 { 539 539 view->scrollBy(deltax, deltay); 540 540 } … … 543 543 } 544 544 545 545 // MouseWheel scrolling while middlebutton/ctrlkey pressed to zoom in/out 546 if (event->type() == QEvent::Wheel) 546 if (event->type() == QEvent::Wheel) 547 547 { 548 548 QWheelEvent* we = (QWheelEvent*)event; 549 if (lastButtonState & MidButton || we->state() & AltButton) 549 if (lastButtonState & MidButton || we->state() & AltButton) 550 550 { 551 if (we->delta() > 0) 551 if (we->delta() > 0) 552 552 { 553 553 we->accept(); 554 554 ((WebPage*)mytab->currentPage())->zoomIn(); 555 555 return true; 556 556 } 557 else if (we->delta() < 0) 557 else if (we->delta() < 0) 558 558 { 559 559 we->accept(); 560 560 ((WebPage*)mytab->currentPage())->zoomOut(); … … 598 598 QString action = actions[i]; 599 599 handled = true; 600 600 601 if (action == "TOGGLEINPUT") 601 if (action == "TOGGLEINPUT") 602 602 { 603 603 if (gContext->GetNumSetting("UseVirtualKeyboard", 1) == 1) 604 604 { … … 607 607 608 608 inputToggled = true; 609 609 VirtualKeyboard *keyboard = new VirtualKeyboard( 610 gContext->GetMainWindow(), 610 gContext->GetMainWindow(), 611 611 ((WebPage*)mytab->currentPage())->browser->view()); 612 612 gContext->GetMainWindow()->detach(keyboard); 613 613 keyboard->exec(); … … 627 627 if (inputToggled) 628 628 return false; 629 629 630 if (action == "NEXTTAB") 630 if (action == "NEXTTAB") 631 631 { 632 632 actionNextTab(); 633 633 return true; … … 661 661 actionZoomOut(); 662 662 return true; 663 663 } 664 else if (action == "MOUSEUP" || action == "MOUSEDOWN" || 664 else if (action == "MOUSEUP" || action == "MOUSEDOWN" || 665 665 action == "MOUSELEFT" || action == "MOUSERIGHT" || 666 666 action == "MOUSELEFTBUTTON") { 667 667 handleMouseAction(action); … … 678 678 showEnterURLDialog(); 679 679 return true; 680 680 } 681 else if (action == "MENU") 681 else if (action == "MENU") 682 682 { 683 683 emit menuPressed(); 684 684 return true; 685 685 } 686 else if (action == "UP") 686 else if (action == "UP") 687 687 { 688 688 KHTMLView *view = ((WebPage*)mytab->currentPage())->browser->view(); 689 689 view->scrollBy(0, -view->visibleHeight() / 10); 690 690 return true; 691 692 691 } 693 else if (action == "DOWN") 692 else if (action == "DOWN") 694 693 { 695 694 KHTMLView *view = ((WebPage*)mytab->currentPage())->browser->view(); 696 695 view->scrollBy(0, view->visibleHeight() / 10); 697 696 return true; 698 697 } 698 else if (action == "PAGEUP") 699 { 700 KHTMLView *view = ((WebPage*)mytab->currentPage())->browser->view(); 701 view->scrollBy(0, -view->visibleHeight()); 702 return true; 703 } 704 else if (action == "PAGEDOWN") 705 { 706 KHTMLView *view = ((WebPage*)mytab->currentPage())->browser->view(); 707 view->scrollBy(0, view->visibleHeight()); 708 return true; 709 } 699 710 } 700 711 } 701 712