Changeset 7407 in vbox
- Timestamp:
- Mar 10, 2008 2:35:46 PM (17 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox4
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxConsoleView.h
r7233 r7407 25 25 #include "VBoxGlobalSettings.h" 26 26 27 #include <qdatetime.h> 27 /* Qt includes */ 28 28 #include <q3scrollview.h> 29 #include <qpixmap.h>30 #include <qimage.h>31 32 #include <qkeysequence.h>33 //Added by qt3to4:34 #include <QTimerEvent>35 #include <QPaintEvent>36 #include <QLabel>37 #include <QEvent>38 29 39 30 #if defined (Q_WS_PM) -
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxFrameBuffer.h
r7220 r7407 21 21 22 22 #include "COMDefs.h" 23 //Added by qt3to4: 24 #include <QMoveEvent> 25 #include <QPaintEvent> 26 27 class VBoxConsoleView; 28 29 #include <qmutex.h> 30 #include <qevent.h> 31 #include <qpixmap.h> 32 #include <qimage.h> 23 24 /* Qt includes */ 25 #include <QImage> 26 #include <QPixmap> 27 #include <QMutex> 33 28 34 29 #if defined (VBOX_GUI_USE_SDL) … … 45 40 #include <ddraw.h> 46 41 #endif 42 43 class VBoxConsoleView; 47 44 48 45 //#define VBOX_GUI_FRAMEBUF_STAT … … 151 148 AssertMsg (addr, ("The buffer address must not be null")); 152 149 153 bool rc = pm.convertFromImage (QImage (addr, 154 display.GetWidth(), display.GetHeight(), 155 display.GetBitsPerPixel(), 156 0, 0, QImage::LittleEndian)); 157 AssertMsg (rc, ("convertFromImage() must always return true")); 150 QImage::Format format = QImage::Format_Invalid; 151 switch (display.GetBitsPerPixel()) 152 { 153 /* 32-, 8- and 1-bpp are the only depths suported by QImage */ 154 case 32: 155 format = QImage::Format_RGB32; 156 break; 157 case 8: 158 format = QImage::Format_Indexed8; 159 break; 160 case 1: 161 format = QImage::Format_Mono; 162 break; 163 } 164 165 bool rc = false; 166 if(format != QImage::Format_Invalid) 167 { 168 pm = QPixmap::fromImage (QImage (addr, 169 display.GetWidth(), display.GetHeight(), 170 format)); 171 rc = !pm.isNull(); 172 AssertMsg (rc, ("convertFromImage() must always return true")); 173 } 158 174 159 175 display.UnlockFramebuffer(); -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxConsoleView.cpp
r7346 r7407 29 29 #endif 30 30 31 #include <qapplication.h> 32 #include <qstatusbar.h> 33 #include <qlabel.h> 34 #include <qpainter.h> 35 #include <qpixmap.h> 36 #include <qimage.h> 37 #include <qbitmap.h> 38 #include <qcursor.h> 39 #include <qthread.h> 40 41 #include <qmenudata.h> 42 #include <qmenubar.h> 43 #include <qwidget.h> 44 #include <qtimer.h> 45 //Added by qt3to4: 31 /* Qt includes */ 32 #include <QMenuBar> 46 33 #include <QDesktopWidget> 47 #include <QTimerEvent> 48 #include <QMoveEvent> 49 #include <QWheelEvent> 50 #include <QMouseEvent> 51 #include <QKeyEvent> 52 #include <QEvent> 53 #include <QPaintEvent> 34 #include <QTimer> 35 #include <QStatusBar> 36 #include <QPainter> 54 37 55 38 #ifdef Q_WS_WIN … … 441 424 CGuest guest = mView->console().GetGuest(); 442 425 LogFlowFunc (("ver=%s, active=%d\n", 443 guest.GetAdditionsVersion(). latin1(),426 guest.GetAdditionsVersion().toLatin1().constData(), 444 427 guest.GetAdditionsActive())); 445 428 QApplication::postEvent (mView, … … 521 504 QApplication::postEvent (mView, 522 505 new RuntimeErrorEvent (!!fatal, 523 QString::fromU cs2(id),524 QString::fromU cs2(message)));506 QString::fromUtf16 (id), 507 QString::fromUtf16 (message))); 525 508 return S_OK; 526 509 } … … 664 647 #ifdef Q_WS_X11 665 648 /* initialize the X keyboard subsystem */ 666 initXKeyboard ( this->x11Display());649 initXKeyboard (QX11Info::display()); 667 650 #endif 668 651 … … 674 657 675 658 mToggleFSModeTimer = new QTimer (this); 659 mToggleFSModeTimer->setSingleShot (true); 676 660 connect (mToggleFSModeTimer, SIGNAL (timeout()), 677 661 this, SIGNAL (resizeHintDone())); … … 707 691 /* This is somehow necessary to prevent strange X11 warnings on 708 692 * i386 and segfaults on x86_64. */ 709 XFlush( this->x11Display());693 XFlush(QX11Info::display()); 710 694 # endif 711 695 mFrameBuf = new VBoxSDLFrameBuffer (this); … … 756 740 AssertWrapperOk (mConsole); 757 741 758 viewport()->setEraseColor (Qt::black); 742 QPalette palette (viewport()->palette()); 743 palette.setColor (viewport()->backgroundRole(), Qt::black); 744 viewport()->setPalette (palette); 759 745 760 746 setSizePolicy (QSizePolicy (QSizePolicy::Maximum, QSizePolicy::Maximum)); … … 907 893 /* resize the frame to fit the contents */ 908 894 s -= tlw->size(); 909 fr. rRight() += s.width();910 fr. rBottom() += s.height();895 fr.setRight (fr.right() + s.width()); 896 fr.setBottom (fr.bottom() + s.height()); 911 897 912 898 if (adjustPosition) … … 1118 1104 viewport()->repaint (re->x() - contentsX(), 1119 1105 re->y() - contentsY(), 1120 re->width(), re->height() , false);1106 re->width(), re->height()); 1121 1107 /* mConsole.GetDisplay().UpdateCompleted(); - the event was acked already */ 1122 1108 return true; … … 1133 1119 mMainWnd->setMask (sre->region()); 1134 1120 } 1135 else if (!mLastVisibleRegion.is Null() &&1121 else if (!mLastVisibleRegion.isEmpty() && 1136 1122 !mMainWnd->isTrueSeamless()) 1137 1123 mLastVisibleRegion = QRegion(); … … 1235 1221 bool destroyed = list.indexOf (mMainWnd) < 0; 1236 1222 if (!destroyed && mMainWnd->statusBar()) 1237 mMainWnd->statusBar()->clear ();1223 mMainWnd->statusBar()->clearMessage(); 1238 1224 1239 1225 return true; … … 1917 1903 1918 1904 /* perform the mega-complex translation using the wine algorithms */ 1919 handleXKeyEvent ( this->x11Display(), event, &wineKeyboardInfo);1905 handleXKeyEvent (QX11Info::display(), event, &wineKeyboardInfo); 1920 1906 1921 1907 #if 0 … … 2257 2243 doResizeHint (newSize); 2258 2244 } 2259 mToggleFSModeTimer->start (2000 , true);2245 mToggleFSModeTimer->start (2000); 2260 2246 } 2261 2247 … … 2507 2493 #elif defined (Q_WS_X11) 2508 2494 NOREF(aUniKey); 2509 Display *display = x11Display();2495 Display *display = QX11Info::display(); 2510 2496 int keysyms_per_keycode = getKeysymsPerKeycode(); 2511 2497 KeyCode kc = XKeysymToKeycode (display, aKey); … … 2736 2722 if (scrGeo.width() < contentsWidth()) 2737 2723 { 2738 if (scrGeo. rLeft() == aGlobalPos.x()) dx = -1;2739 if (scrGeo.r Right() == aGlobalPos.x()) dx = +1;2724 if (scrGeo.left() == aGlobalPos.x()) dx = -1; 2725 if (scrGeo.right() == aGlobalPos.x()) dx = +1; 2740 2726 } 2741 2727 if (scrGeo.height() < contentsHeight()) 2742 2728 { 2743 if (scrGeo. rTop() == aGlobalPos.y()) dy = -1;2744 if (scrGeo. rBottom() == aGlobalPos.y()) dy = +1;2729 if (scrGeo.top() == aGlobalPos.y()) dy = -1; 2730 if (scrGeo.bottom() == aGlobalPos.y()) dy = +1; 2745 2731 } 2746 2732 if (dx || dy) … … 2830 2816 * needs a 32bpp image 2831 2817 */ 2832 QImage shot = QImage (mFrameBuf->width(), mFrameBuf->height(), 32, 0);2818 QImage shot = QImage (mFrameBuf->width(), mFrameBuf->height(), QImage::Format_RGB32); 2833 2819 CDisplay dsp = mConsole.GetDisplay(); 2834 2820 dsp.TakeScreenShot (shot.bits(), shot.width(), shot.height()); … … 2841 2827 { 2842 2828 dimImage (shot); 2843 mPausedShot = shot;2829 mPausedShot = QPixmap::fromImage (shot); 2844 2830 /* fully repaint to pick up mPausedShot */ 2845 2831 viewport()->repaint(); … … 2862 2848 { 2863 2849 /* reset the pixmap to free memory */ 2864 mPausedShot .resize (0, 0);2850 mPausedShot = QPixmap (); 2865 2851 /* 2866 2852 * ask for full guest display update (it will also update … … 3015 3001 #elif defined (Q_WS_X11) 3016 3002 if (aCapture) 3017 XGrabKey ( x11Display(), AnyKey, AnyModifier,3003 XGrabKey (QX11Info::display(), AnyKey, AnyModifier, 3018 3004 topLevelWidget()->winId(), False, 3019 3005 GrabModeAsync, GrabModeAsync); 3020 3006 else 3021 XUngrabKey ( x11Display(), AnyKey, AnyModifier,3007 XUngrabKey (QX11Info::display(), AnyKey, AnyModifier, 3022 3008 topLevelWidget()->winId()); 3023 3009 #elif defined (Q_WS_MAC) … … 3461 3447 } 3462 3448 3463 Cursor cur = XcursorImageLoadCursor ( x11Display(), img);3449 Cursor cur = XcursorImageLoadCursor (QX11Info::display(), img); 3464 3450 Assert (cur); 3465 3451 if (cur) -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxFrameBuffer.cpp
r7220 r7407 23 23 #include "VBoxGlobal.h" 24 24 25 #include <qapplication.h> 26 //Added by qt3to4: 27 #include <QPaintEvent> 25 /* Qt includes */ 26 #include <QPainter> 28 27 29 28 // … … 42 41 43 42 VBoxFrameBuffer::VBoxFrameBuffer (VBoxConsoleView *aView) 44 : mView (aView), mMutex (new QMutex ( true))43 : mView (aView), mMutex (new QMutex (QMutex::Recursive)) 45 44 , mWdt (0), mHgt (0) 46 45 #if defined (Q_OS_WIN32) … … 336 335 FRAMEBUF_DEBUG_START (xxx); 337 336 338 if (r.width() < mWdt * 2 / 3) 339 { 340 /* this method is faster for narrow updates */ 341 mPM.convertFromImage (mImg.copy (r.x() + mView->contentsX(), 342 r.y() + mView->contentsY(), 343 r.width(), r.height())); 344 345 #warning port me 337 /* In Qt4 there is not bitblt anymore. So 338 * we create a qpainter object and paint on 339 * that. Todo: Do some performance test. */ 340 #warning port me: do it faster? 341 QPainter painter (mView->viewport()); 342 painter.drawImage (r.x(), r.y(), mImg, 343 r.x() + mView->contentsX(), 344 r.y() + mView->contentsY(), 345 r.width(), r.height()); 346 // if (r.width() < mWdt * 2 / 3) 347 // { 348 // /* this method is faster for narrow updates */ 349 // mPM.convertFromImage (mImg.copy (r.x() + mView->contentsX(), 350 // r.y() + mView->contentsY(), 351 // r.width(), r.height())); 346 352 // ::bitBlt (mView->viewport(), r.x(), r.y(), 347 353 // &mPM, 0, 0, 348 354 // r.width(), r.height(), 349 355 // Qt::CopyROP, TRUE); 350 } 351 else 352 { 353 /* this method is faster for wide updates */ 354 mPM.convertFromImage (QImage (mImg.scanLine (r.y() + mView->contentsY()), 355 mImg.width(), r.height(), mImg.depth(), 356 0, 0, QImage::LittleEndian)); 357 358 #warning port me 356 // } 357 // else 358 // { 359 // /* this method is faster for wide updates */ 360 // mPM.convertFromImage (QImage (mImg.scanLine (r.y() + mView->contentsY()), 361 // mImg.width(), r.height(), mImg.depth(), 362 // 0, 0, QImage::LittleEndian)); 359 363 // ::bitBlt (mView->viewport(), r.x(), r.y(), 360 364 // &mPM, r.x() + mView->contentsX(), 0, 361 365 // r.width(), r.height(), 362 366 // Qt::CopyROP, TRUE); 363 }367 // } 364 368 365 369 FRAMEBUF_DEBUG_STOP (xxx, r.width(), r.height()); … … 384 388 if (re->pixelFormat() == FramebufferPixelFormat_FOURCC_RGB) 385 389 { 390 QImage::Format format; 386 391 switch (re->bitsPerPixel()) 387 392 { 388 393 /* 32-, 8- and 1-bpp are the only depths suported by QImage */ 389 394 case 32: 395 format = QImage::Format_RGB32; 390 396 break; 391 397 case 8: 398 format = QImage::Format_Indexed8; 399 remind = true; 400 break; 392 401 case 1: 402 format = QImage::Format_Mono; 393 403 remind = true; 394 404 break; … … 407 417 if (!fallback) 408 418 { 409 mImg = QImage ((uchar *) re->VRAM(), mWdt, mHgt, 410 re->bitsPerPixel(), NULL, 0, QImage::LittleEndian); 419 mImg = QImage ((uchar *) re->VRAM(), mWdt, mHgt, format); 411 420 mPixelFormat = FramebufferPixelFormat_FOURCC_RGB; 412 421 mUsesGuestVRAM = true; … … 423 432 /* we don't support either the pixel format or the color depth, 424 433 * fallback to a self-provided 32bpp RGB buffer */ 425 mImg = QImage (mWdt, mHgt, 32, 0, QImage::LittleEndian);434 mImg = QImage (mWdt, mHgt, QImage::Format_RGB32); 426 435 mPixelFormat = FramebufferPixelFormat_FOURCC_RGB; 427 436 mUsesGuestVRAM = false;
Note:
See TracChangeset
for help on using the changeset viewer.