Qt 4.8
Public Functions | Properties | List of all members
QVNCIntegration Class Reference

#include <qvncintegration.h>

Inheritance diagram for QVNCIntegration:
QPlatformIntegration

Public Functions

QPixmapDatacreatePixmapData (QPixmapData::PixelType type) const
 Factory function for QPixmapData. More...
 
QPlatformWindowcreatePlatformWindow (QWidget *widget, WId winId) const
 Factory function for QPlatformWindow. More...
 
QWindowSurfacecreateWindowSurface (QWidget *widget, WId winId) const
 Factory function for QWindowSurface. More...
 
QPlatformFontDatabasefontDatabase () const
 Accessor for the platform integrations fontdatabase. More...
 
QPixmap grabWindow (WId window, int x, int y, int width, int height) const
 This function is called when Qt needs to be able to grab the content of a window. More...
 
bool hasCapability (QPlatformIntegration::Capability cap) const
 
bool isVirtualDesktop ()
 Returns if the current windowing system configuration defines all the screens to be one desktop(virtual desktop), or if each screen is a desktop of its own. More...
 
void moveToScreen (QWidget *window, int screen)
 This function is called when a QWidget is displayed on screen, or the QWidget is to be displayed on a new screen. More...
 
 QVNCIntegration (const QStringList &paramList)
 
QList< QPlatformScreen * > screens () const
 Accessor function to a list of all the screens on the current system. More...
 
- Public Functions inherited from QPlatformIntegration
virtual QPlatformClipboardclipboard () const
 Accessor for the platform integrations clipboard. More...
 
virtual QPlatformEventLoopIntegrationcreateEventLoopIntegration () const
 Factory function for the eventloop integration interface. More...
 
virtual QPlatformNativeInterfacenativeInterface () const
 
virtual ~QPlatformIntegration ()
 

Properties

QPlatformFontDatabasefontDb
 
QVNCScreenmPrimaryScreen
 
QList< QPlatformScreen * > mScreens
 
bool virtualDesktop
 

Additional Inherited Members

- Public Types inherited from QPlatformIntegration
enum  Capability { ThreadedPixmaps = 1, OpenGL = 2 }
 

Detailed Description

Definition at line 79 of file qvncintegration.h.

Constructors and Destructors

◆ QVNCIntegration()

QVNCIntegration::QVNCIntegration ( const QStringList paramList)

Definition at line 103 of file qvncintegration.cpp.

105 {
106  int sizeX = defaultWidth();
107  int sizeY = defaultHeight();
108  int offsetX = 0;
109  int offsetY = 0;
110  int display = defaultDisplay();
111  bool showUsage = false;
112 
113  foreach(QString confString, paramList) {
114  if (confString.startsWith(QLatin1String("size="))) {
115  QString val = confString.section(QLatin1Char('='), 1, 1);
116  sizeX = val.section(QLatin1Char('x'), 0, 0).toInt();
117  sizeY = val.section(QLatin1Char('x'), 1, 1).toInt();
118  }
119  else if (confString.startsWith(QLatin1String("display="))) {
120  display = confString.section(QLatin1Char('='), 1, 1).toInt();
121  }
122  else if (confString.startsWith(QLatin1String("offset="))) {
123  QString val = confString.section(QLatin1Char('='), 1, 1);
124  offsetX = val.section(QLatin1Char('x'), 0, 0).toInt();
125  offsetY = val.section(QLatin1Char('x'), 1, 1).toInt();
126  }
127  else if (confString == QLatin1String("vnc")) {
128  QRect screenRect(offsetX, offsetY, sizeX, sizeY);
129  QVNCScreen *screen = new QVNCScreen(screenRect, display);
130  mScreens.append(screen);
131  screen->setObjectName(QString("screen %1").arg(display));
132  screen->setDirty(screenRect);
133  ++display;
134  }
135  else if (confString == QLatin1String("virtual")) {
136  virtualDesktop = true;
137  }
138  else {
139  qWarning() << "Unknown VNC option:" << confString;
140  showUsage = true;
141  }
142  }
143 
144  if (showUsage)
145  usage();
146 
147  QRect screenRect(offsetX, offsetY, sizeX, sizeY);
148  QVNCScreen *screen = new QVNCScreen(screenRect, display);
149  mScreens.append(screen);
151  screen->setObjectName(QString("screen %1").arg(display));
152  screen->setDirty(screenRect);
153 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
QString section(QChar sep, int start, int end=-1, SectionFlags flags=SectionDefault) const
This function returns a section of the string.
Definition: qstring.h:781
static int defaultWidth()
static void usage()
int toInt(bool *ok=0, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
Definition: qstring.cpp:6090
QBasicUnixFontDatabase QGenericUnixFontDatabase
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
void setObjectName(const QString &name)
Definition: qobject.cpp:1112
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
The QVNCScreen class implements a screen driver for VNC servers.
QPlatformFontDatabase * fontDb
Q_CORE_EXPORT void qWarning(const char *,...)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
static int defaultHeight()
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
static int defaultDisplay()
QList< QPlatformScreen * > mScreens
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void setDirty(const QRect &)
Reimplemented Function
QVNCScreen * mPrimaryScreen
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

Functions

◆ createPixmapData()

QPixmapData * QVNCIntegration::createPixmapData ( QPixmapData::PixelType  type) const
virtual

Factory function for QPixmapData.

PixelType can be either PixmapType or BitmapType.

See also
QPixmapData

Implements QPlatformIntegration.

Definition at line 164 of file qvncintegration.cpp.

165 {
166  return new QRasterPixmapData(type);
167 }
int type
Definition: qmetatype.cpp:239

◆ createPlatformWindow()

QPlatformWindow * QVNCIntegration::createPlatformWindow ( QWidget widget,
WId  winId 
) const
virtual

Factory function for QPlatformWindow.

The widget parameter is a pointer to the top level widget(tlw) which the QPlatformWindow is suppose to be created for. The WId handle is actually never used, but there for future reference. Its purpose is if it is going to be possible to create QPlatformWindows on existing WId.

All tlw has to have a QPlatformWindow, and it will be created when the QPlatformWindow is set to be visible for the first time. If the tlw's window flags are changed, or if the tlw's QPlatformWindowFormat is changed, then the tlw's QPlatformWindow is deleted and a new one is created.

See also
QPlatformWindow, QPlatformWindowFormat
createWindowSurface(QWidget *widget, WId winId) const

Implements QPlatformIntegration.

Definition at line 177 of file qvncintegration.cpp.

178 {
179  QFbWindow *w = new QFbWindow(widget);
180  if (virtualDesktop) {
183  QFbScreen *screen;
184  while (i != end) {
185  screen = static_cast<QFbScreen *>(*i);
186  screen->addWindow(w);
187  ++i;
188  }
189  }
190  else
192  return w;
193 }
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
The QList::const_iterator class provides an STL-style const iterator for QList and QQueue...
Definition: qlist.h:228
virtual void addWindow(QFbWindow *surface)
Definition: fb_base.cpp:305
QList< QPlatformScreen * > mScreens
QVNCScreen * mPrimaryScreen
static const KeyPair *const end
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:272

◆ createWindowSurface()

QWindowSurface * QVNCIntegration::createWindowSurface ( QWidget widget,
WId  winId 
) const
virtual

Factory function for QWindowSurface.

The QWidget parameter is a pointer to the top level widget(tlw) the window surface is created for. A QPlatformWindow is always created before the QWindowSurface for tlw where the widget also requires a WindowSurface. It is possible to create top level QWidgets without a QWindowSurface by specifying QPlatformWindowFormat::setWindowSurface(false) for the tlw QPlatformWindowFormat.

See also
QWindowSurface
createPlatformWindow(QWidget *widget, WId winId = 0) const

Implements QPlatformIntegration.

Definition at line 169 of file qvncintegration.cpp.

170 {
171  QFbWindowSurface * surface;
172  surface = new QFbWindowSurface(mPrimaryScreen, widget);
173  return surface;
174 }
QVNCScreen * mPrimaryScreen

◆ fontDatabase()

QPlatformFontDatabase * QVNCIntegration::fontDatabase ( ) const
virtual

Accessor for the platform integrations fontdatabase.

Default implementation returns a default QPlatformFontDatabase.

See also
QPlatformFontDatabase

Reimplemented from QPlatformIntegration.

Definition at line 248 of file qvncintegration.cpp.

249 {
250  return fontDb;
251 }
QPlatformFontDatabase * fontDb

◆ grabWindow()

QPixmap QVNCIntegration::grabWindow ( WId  window,
int  x,
int  y,
int  width,
int  height 
) const
virtual

This function is called when Qt needs to be able to grab the content of a window.

Returnes the content of the window specified with the WId handle within the boundaries of QRect(x,y,width,height).

Reimplemented from QPlatformIntegration.

Definition at line 195 of file qvncintegration.cpp.

196 {
197 // qDebug() << "QVNCIntegration::grabWindow" << window << x << y << width << height;
198 
199  if (window == 0) { //desktop
200  QImage *desktopImage = mPrimaryScreen->image();
201  if (x==0 && y == 0 && width < 0 && height < 0) {
202  return QPixmap::fromImage(*desktopImage);
203  }
204  if (width < 0)
205  width = desktopImage->width() - x;
206  if (height < 0)
207  height = desktopImage->height() - y;
208  int bytesPerPixel = desktopImage->depth()/8; //We don't support 1, 2, or 4 bpp
209  QImage img(desktopImage->scanLine(y) + bytesPerPixel*x, width, height, desktopImage->bytesPerLine(), desktopImage->format());
210  return QPixmap::fromImage(img);
211  }
212  QWidget *win = QWidget::find(window);
213  if (win) {
214  QRect r = win->geometry();
215  if (width < 0)
216  width = r.width() - x;
217  if (height < 0)
218  height = r.height() - y;
219  QImage *desktopImage = mPrimaryScreen->image();
220  int bytesPerPixel = desktopImage->depth()/8; //We don't support 1, 2, or 4 bpp
221 
222  QImage img(desktopImage->scanLine(r.top() + y) + bytesPerPixel*(r.left()+x), width, height, desktopImage->bytesPerLine(), desktopImage->format());
223  return QPixmap::fromImage(img);
224  }
225  return QPixmap();
226 }
static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Converts the given image to a pixmap using the specified flags to control the conversion.
Definition: qpixmap.cpp:2197
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
static int bytesPerPixel(QImage::Format format)
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int bytesPerLine() const
Returns the number of bytes per image scanline.
Definition: qimage.cpp:1812
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
Format format() const
Returns the format of the image.
Definition: qimage.cpp:2305
NSWindow * window
static QWidget * find(WId)
Returns a pointer to the widget with window identifer/handle id.
Definition: qwidget.cpp:2517
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
int depth() const
Returns the depth of the image.
Definition: qimage.cpp:1620
QImage * image() const
Definition: fb_base.h:180
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
QVNCScreen * mPrimaryScreen
QRect geometry
the geometry of the widget relative to its parent and excluding the window frame
Definition: qwidget.h:158
uchar * scanLine(int)
Returns a pointer to the pixel data at the scanline with index i.
Definition: qimage.cpp:1886

◆ hasCapability()

bool QVNCIntegration::hasCapability ( QPlatformIntegration::Capability  cap) const
virtual

Reimplemented from QPlatformIntegration.

Definition at line 155 of file qvncintegration.cpp.

156 {
157  switch (cap) {
158  case ThreadedPixmaps: return true;
159  default: return QPlatformIntegration::hasCapability(cap);
160  }
161 }
virtual bool hasCapability(Capability cap) const

◆ isVirtualDesktop()

bool QVNCIntegration::isVirtualDesktop ( )
inlinevirtual

Returns if the current windowing system configuration defines all the screens to be one desktop(virtual desktop), or if each screen is a desktop of its own.

Default implementation returns false.

Reimplemented from QPlatformIntegration.

Definition at line 93 of file qvncintegration.h.

93 { return virtualDesktop; }

◆ moveToScreen()

void QVNCIntegration::moveToScreen ( QWidget window,
int  screen 
)
virtual

This function is called when a QWidget is displayed on screen, or the QWidget is to be displayed on a new screen.

The QWidget parameter is a pointer to the top level widget and the int parameter is the index to the screen in QList<QPlatformScreen *> screens() const.

Default implementation does nothing.

See also
screens() const

Reimplemented from QPlatformIntegration.

Definition at line 229 of file qvncintegration.cpp.

230 {
231  if (virtualDesktop) { // all windows exist on all screens in virtual desktop mode
232  return;
233  }
234  if (screen < 0 || screen > mScreens.size())
235  return;
236  QVNCScreen * newScreen = qobject_cast<QVNCScreen *>(mScreens.at(screen));
237  for(int i = 0; i < mScreens.size(); i++) {
238  QVNCScreen *oldScreen = qobject_cast<QVNCScreen *>(mScreens.at(i));
239  if (oldScreen->windowStack.contains(static_cast<QFbWindow *>(window->platformWindow()))) {
240  oldScreen->removeWindow(static_cast<QFbWindow *>(window->platformWindow()));
241  break;
242  }
243  }
244  window->platformWindow()->setGeometry(window->geometry()); // this should be unified elsewhere
245  newScreen->addWindow(static_cast<QFbWindow *>(window->platformWindow()));
246 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
void setGeometry(int x, int y, int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qwidget.h:1017
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
Definition: qlist.h:880
virtual void addWindow(QFbWindow *surface)
Definition: fb_base.cpp:305
The QVNCScreen class implements a screen driver for VNC servers.
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
virtual void removeWindow(QFbWindow *surface)
Definition: fb_base.cpp:313
QList< QPlatformScreen * > mScreens
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QList< QFbWindow * > windowStack
Definition: fb_base.h:184
QRect geometry
the geometry of the widget relative to its parent and excluding the window frame
Definition: qwidget.h:158

◆ screens()

QList<QPlatformScreen *> QVNCIntegration::screens ( ) const
inlinevirtual

Accessor function to a list of all the screens on the current system.

The screen with the index == 0 is the default/main screen.

Implements QPlatformIntegration.

Definition at line 91 of file qvncintegration.h.

91 { return mScreens; }
QList< QPlatformScreen * > mScreens

Properties

◆ fontDb

QPlatformFontDatabase* QVNCIntegration::fontDb
private

Definition at line 102 of file qvncintegration.h.

Referenced by fontDatabase().

◆ mPrimaryScreen

QVNCScreen* QVNCIntegration::mPrimaryScreen
private

◆ mScreens

QList<QPlatformScreen *> QVNCIntegration::mScreens
private

Definition at line 100 of file qvncintegration.h.

Referenced by createPlatformWindow(), moveToScreen(), and QVNCIntegration().

◆ virtualDesktop

bool QVNCIntegration::virtualDesktop
private

Definition at line 101 of file qvncintegration.h.

Referenced by createPlatformWindow(), moveToScreen(), and QVNCIntegration().


The documentation for this class was generated from the following files: