Changeset 7590 in vbox
- Timestamp:
- Mar 27, 2008 1:21:57 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 29085
- Location:
- trunk/src/VBox/Frontends/VirtualBox4
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/src/VBox/Frontends/VirtualBox4/include/VBoxConsoleView.h ¶
r7512 r7590 26 26 27 27 /* Qt includes */ 28 #include <q3scrollview.h> 28 #include <QAbstractScrollArea> 29 #include <QScrollBar> 29 30 30 31 #if defined (Q_WS_PM) … … 46 47 class QMenuData; 47 48 48 class VBoxConsoleView : public Q 3ScrollView49 class VBoxConsoleView : public QAbstractScrollArea 49 50 { 50 51 Q_OBJECT … … 64 65 const CConsole &console, 65 66 VBoxDefs::RenderMode rm, 66 QWidget *parent = 0 , const char *name = 0, Qt::WFlags f = 0);67 QWidget *parent = 0); 67 68 ~VBoxConsoleView(); 68 69 … … 95 96 96 97 QRect getDesktopGeometry(); 98 99 /* todo: This are some support functions for the qt4 port. Maybe we get rid 100 * of them some day. */ 101 int contentsX() const { return horizontalScrollBar()->value(); } 102 int contentsY() const { return verticalScrollBar()->value(); } 103 int contentsWidth() const; 104 int contentsHeight() const; 105 int visibleWidth() const { return horizontalScrollBar()->pageStep(); } 106 int visibleHeight() const { return verticalScrollBar()->pageStep(); } 107 void scrollBy (int dx, int dy) 108 { 109 horizontalScrollBar()->setValue (horizontalScrollBar()->value() + dx); 110 verticalScrollBar()->setValue (verticalScrollBar()->value() + dy); 111 } 112 QPoint viewportToContents ( const QPoint & vp ) const 113 { 114 return QPoint (vp.x() + contentsX(), 115 vp.y() + contentsY()); 116 } 117 void updateSliders(); 97 118 98 119 signals: … … 141 162 bool mouseEvent (int aType, const QPoint &aPos, const QPoint &aGlobalPos, 142 163 Qt::ButtonState aButton, 143 Qt:: ButtonState aState, Qt::ButtonState aStateAfter,164 Qt::MouseButtons aButtons, Qt::KeyboardModifiers aModifiers, 144 165 int aWheelDelta, Qt::Orientation aWheelDir); 145 166 … … 162 183 void doRefresh(); 163 184 164 void viewportPaintEvent( QPaintEvent * ); 185 void resizeEvent (QResizeEvent *); 186 void paintEvent (QPaintEvent *); 165 187 #ifdef VBOX_GUI_USE_REFRESH_TIMER 166 188 void timerEvent( QTimerEvent * ); … … 170 192 void captureMouse (bool aCapture, bool aEmitSignal = true); 171 193 172 bool processHotKey (const QKeySequence &key, QMenuData *data);194 bool processHotKey (const QKeySequence &key, const QList<QAction*>& data); 173 195 void updateModifiers (bool fNumLock, bool fCapsLock, bool fScrollLock); 174 196 … … 235 257 long muCapsLockAdaptionCnt; 236 258 237 QTimer *resize_hint_timer;238 259 QTimer *mToggleFSModeTimer; 239 260 -
TabularUnified trunk/src/VBox/Frontends/VirtualBox4/src/VBoxConsoleView.cpp ¶
r7512 r7590 259 259 { 260 260 public: 261 ActivateMenuEvent (Q MenuData *menuData, uint index) :261 ActivateMenuEvent (QAction *aData) : 262 262 QEvent ((QEvent::Type) VBoxDefs::ActivateMenuEventType), 263 md (menuData), i (index) {} 264 QMenuData *menuData() const { return md; } 265 uint index() const { return i; } 263 mAction (aData) {} 264 QAction *action() const { return mAction; } 266 265 private: 267 QMenuData *md; 268 uint i; 266 QAction *mAction; 269 267 }; 270 268 … … 574 572 #endif 575 573 574 class VBoxViewport: public QWidget 575 { 576 public: 577 VBoxViewport (QWidget *aParent) 578 : QWidget (aParent) 579 { 580 /* No need for background drawing */ 581 setAttribute (Qt::WA_OpaquePaintEvent); 582 } 583 virtual QPaintEngine * paintEngine() const 584 { 585 if (testAttribute (Qt::WA_PaintOnScreen)) 586 return NULL; 587 else 588 return QWidget::paintEngine(); 589 } 590 }; 591 576 592 // 577 593 // VBoxConsoleView class … … 587 603 const CConsole &console, 588 604 VBoxDefs::RenderMode rm, 589 QWidget *parent , const char *name, Qt::WFlags f)590 : Q 3ScrollView (parent, name, f | Qt::WStaticContents | Qt::WNoAutoErase)605 QWidget *parent) 606 : QAbstractScrollArea (parent) 591 607 , mMainWnd (mainWnd) 592 608 , mConsole (console) … … 630 646 #endif 631 647 648 VBoxViewport *pViewport = new VBoxViewport (this); 649 setViewport (pViewport); 650 632 651 /* enable MouseMove events */ 633 652 viewport()->setMouseTracking (true); … … 652 671 ::memset (mPressedKeys, 0, SIZEOF_ARRAY (mPressedKeys)); 653 672 654 resize_hint_timer = new QTimer (this);655 connect (resize_hint_timer, SIGNAL (timeout()),656 this, SLOT (doResizeHint()));657 658 673 mToggleFSModeTimer = new QTimer (this); 659 674 mToggleFSModeTimer->setSingleShot (true); … … 688 703 #if defined (VBOX_GUI_USE_SDL) 689 704 case VBoxDefs::SDLMode: 705 /* Indicate that we are doing all 706 * drawing stuff ourself */ 707 pViewport->setAttribute (Qt::WA_PaintOnScreen); 690 708 # ifdef Q_WS_X11 691 709 /* This is somehow necessary to prevent strange X11 warnings on … … 1058 1076 1059 1077 if (mToggleFSModeTimer->isActive()) 1060 mToggleFSModeTimer->stop(); 1078 mToggleFSModeTimer->stop(); 1061 1079 1062 1080 /* do frame buffer dependent resize */ … … 1080 1098 1081 1099 /* resize the guest canvas */ 1082 resizeContents (re->width(), re->height()); 1100 resize (re->width(), re->height()); 1101 updateSliders(); 1083 1102 /* let our toplevel widget calculate its sizeHint properly */ 1084 1103 QApplication::sendPostedEvents (0, QEvent::LayoutRequest); … … 1221 1240 { 1222 1241 ActivateMenuEvent *ame = (ActivateMenuEvent *) e; 1223 #warning port me 1224 // ame->menuData()->activateItemAt (ame->index()); 1242 ame->action()->trigger(); 1225 1243 1226 1244 /* … … 1414 1432 /* process hot keys not processed in keyEvent() 1415 1433 * (as in case of non-alphanumeric keys) */ 1416 #warning port me 1417 // processHotKey (QKeySequence (ke->key()), 1418 // mMainWnd->menuBar()); 1434 processHotKey (QKeySequence (ke->key()), 1435 mMainWnd->menuBar()->actions()); 1419 1436 } 1420 1437 } … … 1461 1478 } 1462 1479 1463 return Q 3ScrollView::event (e);1480 return QAbstractScrollArea::event (e); 1464 1481 } 1465 1482 … … 1477 1494 QMouseEvent *me = (QMouseEvent *) e; 1478 1495 if (mouseEvent (me->type(), me->pos(), me->globalPos(), 1479 me->button(), me-> state(), me->stateAfter(),1496 me->button(), me->buttons(), me->modifiers(), 1480 1497 0, Qt::Horizontal)) 1481 1498 return true; /* stop further event handling */ … … 1486 1503 QWheelEvent *we = (QWheelEvent *) e; 1487 1504 if (mouseEvent (we->type(), we->pos(), we->globalPos(), 1488 Qt::NoButton, we-> state(), we->state(),1505 Qt::NoButton, we->buttons(), we->modifiers(), 1489 1506 we->delta(), we->orientation())) 1490 1507 return true; /* stop further event handling */ … … 1555 1572 if (!mIgnoreMainwndResize && 1556 1573 mIsAdditionsActive && mAutoresizeGuest) 1557 resize_hint_timer->start (300, TRUE);1574 QTimer::singleShot (300, this, SLOT (doResizeHint())); 1558 1575 break; 1559 1576 } … … 1582 1599 { 1583 1600 QKeyEvent *ke = (QKeyEvent *) e; 1584 if (ke->key() == Qt::Key_Escape && !(ke->state() & Qt::KeyboardModifierMask))1601 if (ke->key() == Qt::Key_Escape && (ke->modifiers() == Qt::NoModifier)) 1585 1602 if (mMainWnd->menuBar()->hasFocus()) 1586 1603 setFocus(); … … 1592 1609 } 1593 1610 1594 return Q 3ScrollView::eventFilter (watched, e);1611 return QAbstractScrollArea::eventFilter (watched, e); 1595 1612 } 1596 1613 … … 2503 2520 processed = processHotKey (QKeySequence (Qt::UNICODE_ACCEL + 2504 2521 QChar (ch).upper().unicode()), 2505 mMainWnd->menuBar() );2522 mMainWnd->menuBar()->actions()); 2506 2523 } 2507 2524 delete[] list; … … 2521 2538 { 2522 2539 QChar c = QString::fromLocal8Bit (&ch, 1) [0]; 2523 #warning port me 2524 // processed = processHotKey (QKeySequence (Qt::UNICODE_ACCEL + 2525 // c.upper().unicode()), 2526 // mMainWnd->menuBar()); 2540 processed = processHotKey (QKeySequence (Qt::UNICODE_ACCEL + 2541 c.toUpper().unicode()), 2542 mMainWnd->menuBar()->actions()); 2527 2543 } 2528 2544 } 2529 2545 #elif defined (Q_WS_MAC) 2530 #warning port me 2531 // if (aUniKey && aUniKey [0] && !aUniKey [1]) 2532 // processed = processHotKey (QKeySequence (Qt::UNICODE_ACCEL + 2533 // QChar (aUniKey [0]).upper().unicode()), 2534 // mMainWnd->menuBar()); 2546 if (aUniKey && aUniKey [0] && !aUniKey [1]) 2547 processed = processHotKey (QKeySequence (Qt::UNICODE_ACCEL + 2548 QChar (aUniKey [0]).upper().unicode()), 2549 mMainWnd->menuBar()->actions()); 2535 2550 2536 2551 /* Don't consider the hot key as pressed since the guest never saw … … 2585 2600 bool VBoxConsoleView::mouseEvent (int aType, const QPoint &aPos, 2586 2601 const QPoint &aGlobalPos, Qt::ButtonState aButton, 2587 Qt:: ButtonState aState, Qt::ButtonState aStateAfter,2602 Qt::MouseButtons aButtons, Qt::KeyboardModifiers aModifiers, 2588 2603 int aWheelDelta, Qt::Orientation aWheelDir) 2589 2604 { … … 2591 2606 char buf [256]; 2592 2607 sprintf (buf, 2593 "MOUSE: type=%03d x=%03d y=%03d btn=%03d st=%08X stAfter=%08X "2608 "MOUSE: type=%03d x=%03d y=%03d btn=%03d btns=%08X mod=%08X " 2594 2609 "wdelta=%03d wdir=%03d", 2595 aType, aPos.x(), aPos.y(), aButton, a State, aStateAfter,2610 aType, aPos.x(), aPos.y(), aButton, aButtons, aModifiers, 2596 2611 aWheelDelta, aWheelDir); 2597 2612 mMainWnd->statusBar()->message (buf); 2598 2613 #else 2599 2614 Q_UNUSED (aButton); 2600 Q_UNUSED (a State);2615 Q_UNUSED (aModifiers); 2601 2616 #endif 2602 2617 2603 2618 int state = 0; 2604 if (a StateAfter& Qt::LeftButton)2619 if (aButtons & Qt::LeftButton) 2605 2620 state |= KMouseButtonState_LeftButton; 2606 if (a StateAfter& Qt::RightButton)2621 if (aButtons & Qt::RightButton) 2607 2622 state |= KMouseButtonState_RightButton; 2608 if (a StateAfter& Qt::MidButton)2623 if (aButtons & Qt::MidButton) 2609 2624 state |= KMouseButtonState_MiddleButton; 2610 2625 … … 2784 2799 if (hasFocus() && 2785 2800 (aType == QEvent::MouseButtonRelease && 2786 !aStateAfter))2801 aButtons == Qt::NoButton)) 2787 2802 { 2788 2803 if (isPaused()) … … 2844 2859 mPausedShot = QPixmap::fromImage (shot); 2845 2860 /* fully repaint to pick up mPausedShot */ 2846 viewport()->repaint();2861 repaint(); 2847 2862 } 2848 2863 } … … 2913 2928 { 2914 2929 int pw = pm.width(), ph = pm.height(); 2915 resizeContents(pw, ph);2930 viewport()->resize (pw, ph); 2916 2931 updateGeometry(); 2917 2932 setMaximumSize (sizeHint()); … … 2925 2940 * on the next event loop iteration. currently disabled. 2926 2941 * updateContents(); */ 2927 repaintContents (false);2942 viewport()->repaint(); 2928 2943 } 2929 2944 } … … 2933 2948 else 2934 2949 #endif 2935 repaintContents (false); 2936 } 2937 2938 void VBoxConsoleView::viewportPaintEvent (QPaintEvent *pe) 2950 viewport()->repaint(); 2951 } 2952 2953 void VBoxConsoleView::resizeEvent (QResizeEvent *) 2954 { 2955 updateSliders(); 2956 } 2957 2958 void VBoxConsoleView::paintEvent (QPaintEvent *pe) 2939 2959 { 2940 2960 #if defined (VBOX_GUI_USE_REFRESH_TIMER) 2941 if (mode == VBoxDefs::TimerMode) 2942 { 2943 if (!pm.isNull()) 2944 { 2945 /* draw a part of vbuf */ 2946 const QRect &r = pe->rect(); 2947 #warning port me 2961 #warning "port me: Is this needed anymore?" 2962 // if (mode == VBoxDefs::TimerMode) 2963 // { 2964 // if (!pm.isNull()) 2965 // { 2966 // /* draw a part of vbuf */ 2967 // const QRect &r = pe->rect(); 2948 2968 // ::bitBlt (viewport(), r.x(), r.y(), 2949 2969 // &pm, r.x() + contentsX(), r.y() + contentsY(), 2950 2970 // r.width(), r.height(), 2951 2971 // CopyROP, TRUE); 2952 }2953 else2954 {2955 viewport()->erase (pe->rect());2956 }2957 }2958 else2972 // } 2973 // else 2974 // { 2975 // viewport()->erase (pe->rect()); 2976 // } 2977 // } 2978 // else 2959 2979 #endif 2960 2980 { … … 3118 3138 * is found, activates it and returns true. Otherwise returns false. 3119 3139 */ 3120 bool VBoxConsoleView::processHotKey (const QKeySequence &key, QMenuData *data) 3121 { 3122 if (!data) return false; 3123 3124 /* 3125 * Note: below, we use the internal class QMenuItem, that is subject 3126 * to change w/o notice... (the alternative would be to explicitly assign 3127 * specific IDs to all popup submenus in VBoxConsoleWnd and then 3128 * look through its children in order to find a popup with a given ID, 3129 * which is unconvenient). 3130 */ 3131 3132 #warning port me 3133 // for (uint i = 0; i < data->count(); i++) 3134 // { 3135 // int id = data->idAt (i); 3136 // QMenuItem *item = data->findItem (id); 3137 // if (item->popup()) 3138 // { 3139 // if (processHotKey (key, item->popup())) 3140 // return true; 3141 // } 3142 // else 3143 // { 3144 // QStringList list = QStringList::split ("\tHost+", data->text (id)); 3145 // if (list.count() == 2) 3146 // { 3147 // if (key.matches (QKeySequence (list[1])) == Identical) 3148 // { 3149 // /* 3150 // * we asynchronously post a special event instead of calling 3151 // * data->activateItemAt (i) directly, to let key presses 3152 // * and releases be processed correctly by Qt first. 3153 // * Note: we assume that nobody will delete the menu item 3154 // * corresponding to the key sequence, so that the pointer to 3155 // * menu data posted along with the event will remain valid in 3156 // * the event handler, at least until the main window is closed. 3157 // */ 3158 // 3159 // QApplication::postEvent (this, 3160 // new ActivateMenuEvent (data, i)); 3161 // return true; 3162 // } 3163 // } 3164 // } 3165 // } 3140 bool VBoxConsoleView::processHotKey (const QKeySequence &key, const QList<QAction*>& data) 3141 { 3142 foreach (QAction *pAction, data) 3143 { 3144 if (QMenu *menu = pAction->menu()) 3145 return processHotKey (key, menu->actions()); 3146 3147 QStringList list = pAction->text().split ("\tHost+"); 3148 if (list.count() == 2) 3149 { 3150 if (key.matches (QKeySequence (list[1])) == QKeySequence::ExactMatch) 3151 { 3152 /* 3153 * we asynchronously post a special event instead of calling 3154 * pAction->trigger() directly, to let key presses and 3155 * releases be processed correctly by Qt first. Note: we 3156 * assume that nobody will delete the menu item corresponding 3157 * to the key sequence, so that the pointer to menu data 3158 * posted along with the event will remain valid in the event 3159 * handler, at least until the main window is closed. 3160 */ 3161 QApplication::postEvent (this, 3162 new ActivateMenuEvent (pAction)); 3163 return true; 3164 } 3165 } 3166 } 3166 3167 3167 3168 return false; … … 3676 3677 } 3677 3678 } 3679 3680 int VBoxConsoleView::contentsWidth() const 3681 { 3682 return mFrameBuf->width(); 3683 } 3684 3685 int VBoxConsoleView::contentsHeight() const 3686 { 3687 return mFrameBuf->height(); 3688 } 3689 3690 void VBoxConsoleView::updateSliders() 3691 { 3692 QSize p = viewport()->size(); 3693 QSize m = maximumViewportSize(); 3694 3695 QSize v = QSize (mFrameBuf->width(), mFrameBuf->height()); 3696 /* no scroll bars needed */ 3697 if (m.expandedTo(v) == m) 3698 p = m; 3699 3700 horizontalScrollBar()->setRange(0, v.width() - p.width()); 3701 verticalScrollBar()->setRange(0, v.height() - p.height()); 3702 horizontalScrollBar()->setPageStep(p.width()); 3703 verticalScrollBar()->setPageStep(p.height()); 3704 } 3705 -
TabularUnified trunk/src/VBox/Frontends/VirtualBox4/src/VBoxConsoleWnd.cpp ¶
r7565 r7590 680 680 681 681 console = new VBoxConsoleView (this, cconsole, mode, 682 centralWidget() , "console");682 centralWidget()); 683 683 684 684 activateUICustomizations(); … … 837 837 /* set the correct initial machine_state value */ 838 838 machine_state = cconsole.GetState(); 839 840 console->normalizeGeometry (true /* adjustPosition */); 839 841 840 842 updateAppearanceOf (AllStuff); … … 2091 2093 foreach (QWidget *w, list) 2092 2094 { 2093 if (w != centralWidget()) 2095 /* todo: The list is now recursive. So think about a better way to 2096 * prevent the childrens of the centralWidget to be hidden */ 2097 if (w != centralWidget() && 2098 w != console && 2099 w != console->viewport()) 2094 2100 { 2095 2101 if (!w->isHidden()) … … 2115 2121 centralWidget()->setEraseColor (Qt::black); 2116 2122 console_style = console->frameStyle(); 2117 console->setFrameStyle (Q 3Frame::NoFrame);2123 console->setFrameStyle (QFrame::NoFrame); 2118 2124 console->setMaximumSize (scrGeo.size()); 2119 #warning port me 2120 /* console->setVScrollBarMode (Q3ScrollView::AlwaysOff);*/ 2121 /* console->setHScrollBarMode (Q3ScrollView::AlwaysOff);*/ 2125 console->setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff); 2126 console->setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOff); 2122 2127 2123 2128 /* Going fullscreen */ … … 2204 2209 console->setFrameStyle (console_style); 2205 2210 console->setMaximumSize (console->sizeHint()); 2206 #warning port me 2207 /* console->setVScrollBarMode (Q3ScrollView::Auto);*/ 2208 /* console->setHScrollBarMode (Q3ScrollView::Auto);*/ 2211 console->setHorizontalScrollBarPolicy (Qt::ScrollBarAsNeeded); 2212 console->setVerticalScrollBarPolicy (Qt::ScrollBarAsNeeded); 2209 2213 2210 2214 /* Show everything hidden when going fullscreen. */ -
TabularUnified trunk/src/VBox/Frontends/VirtualBox4/src/VBoxProblemReporter.cpp ¶
r7447 r7590 1507 1507 "operation. The currently assigned host key is shown on the status bar " 1508 1508 "at the bottom of the Virtual Machine window, next to the " 1509 "<img src= hostkey_16px.png/> icon. This icon, together "1509 "<img src=:/hostkey_16px.png/> icon. This icon, together " 1510 1510 "with the mouse icon placed nearby, indicate the current keyboard " 1511 1511 "and mouse capture state." … … 1540 1540 "operation. The currently assigned host key is shown on the status bar " 1541 1541 "at the bottom of the Virtual Machine window, next to the " 1542 "<img src= hostkey_16px.png/> icon. This icon, together "1542 "<img src=:/hostkey_16px.png/> icon. This icon, together " 1543 1543 "with the mouse icon placed nearby, indicate the current keyboard " 1544 1544 "and mouse capture state." … … 1581 1581 "</p>" 1582 1582 "<p>The mouse icon on the status bar will look like " 1583 "<img src= mouse_seamless_16px.png/> to inform you that mouse "1583 "<img src=:/mouse_seamless_16px.png/> to inform you that mouse " 1584 1584 "pointer integration is supported by the guest OS and is " 1585 1585 "currently turned on." … … 1700 1700 "You can go back to windowed mode at any time by pressing " 1701 1701 "<b>%1</b>. Note that the <i>Host</i> key is currently " 1702 "defined as <b>% 1</b>.</p>"1702 "defined as <b>%2</b>.</p>" 1703 1703 "<p>Note that the main menu bar is hidden in fullscreen mode. You " 1704 1704 "can access it by pressing <b>Host+Home</b>.</p>") … … 1722 1722 "You can go back to windowed mode at any time by pressing " 1723 1723 "<b>%1</b>. Note that the <i>Host</i> key is currently " 1724 "defined as <b>% 1</b>.</p>"1724 "defined as <b>%2</b>.</p>" 1725 1725 "<p>Note that the main menu bar is hidden in seamless mode. You " 1726 1726 "can access it by pressing <b>Host+Home</b>.</p>")
Note:
See TracChangeset
for help on using the changeset viewer.