| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** All rights reserved.
|
|---|
| 5 | ** Contact: Nokia Corporation (qt-info@nokia.com)
|
|---|
| 6 | **
|
|---|
| 7 | ** This file is part of the documentation of the Qt Toolkit.
|
|---|
| 8 | **
|
|---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 10 | ** Commercial Usage
|
|---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 14 | ** a written agreement between you and Nokia.
|
|---|
| 15 | **
|
|---|
| 16 | ** GNU Lesser General Public License Usage
|
|---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 20 | ** packaging of this file. Please review the following information to
|
|---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 23 | **
|
|---|
| 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
|---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
|---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|---|
| 27 | **
|
|---|
| 28 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you have questions regarding the use of this file, please contact
|
|---|
| 37 | ** Nokia at qt-info@nokia.com.
|
|---|
| 38 | ** $QT_END_LICENSE$
|
|---|
| 39 | **
|
|---|
| 40 | ****************************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | /*!
|
|---|
| 43 | \class QDesktopWidget
|
|---|
| 44 | \brief The QDesktopWidget class provides access to screen information on multi-head systems.
|
|---|
| 45 |
|
|---|
| 46 | \ingroup advanced
|
|---|
| 47 | \ingroup desktop
|
|---|
| 48 |
|
|---|
| 49 | Systems with more than one graphics card and monitor can manage the
|
|---|
| 50 | physical screen space available either as multiple desktops, or as a
|
|---|
| 51 | large virtual desktop.
|
|---|
| 52 |
|
|---|
| 53 | This class provides information about the user's desktop, such as its
|
|---|
| 54 | total size, number of screens, the geometry of each screen, and whether
|
|---|
| 55 | they are configured as separate desktops or a single virtual desktop.
|
|---|
| 56 |
|
|---|
| 57 | Widgets provided by Qt use this class to place tooltips, menus and
|
|---|
| 58 | dialog boxes on the correct screen for their parent or application
|
|---|
| 59 | widgets. Applications can use this class to obtain information that
|
|---|
| 60 | can be used to save window positions, or to place child widgets and
|
|---|
| 61 | dialogs on one particular screen.
|
|---|
| 62 |
|
|---|
| 63 | \section1 Obtaining a Desktop Widget
|
|---|
| 64 |
|
|---|
| 65 | The QApplication::desktop() function is used to get an instance of
|
|---|
| 66 | QDesktopWidget.
|
|---|
| 67 |
|
|---|
| 68 | The widget's screenGeometry() function provides information about the
|
|---|
| 69 | geometry of the available screens with. The number of screens
|
|---|
| 70 | available is returned by screenCount, and the screenCountChanged()
|
|---|
| 71 | signal is emitted when screens are added or removed.
|
|---|
| 72 | The screen number that a particular point or widget is located in
|
|---|
| 73 | is returned by screenNumber().
|
|---|
| 74 |
|
|---|
| 75 | \section1 Screen Geometry
|
|---|
| 76 |
|
|---|
| 77 | To obtain the dimensions of a particular screen, call the screenGeometry()
|
|---|
| 78 | function. On some desktop environments, not all of the screen is
|
|---|
| 79 | available for applications to use; for example, an application dock or
|
|---|
| 80 | menu bar may take up some space. Use the availableGeometry() function
|
|---|
| 81 | to obtain the available area for applications.
|
|---|
| 82 |
|
|---|
| 83 | QDesktopWidget also inherits the QWidget properties, width() and
|
|---|
| 84 | height(), which specify the size of the desktop. However, for
|
|---|
| 85 | desktops with multiple screens, the size of the desktop is the union
|
|---|
| 86 | of all the screen sizes, so width() and height() should \e not be
|
|---|
| 87 | used for computing the size of a widget to be placed on one of the
|
|---|
| 88 | screens.
|
|---|
| 89 |
|
|---|
| 90 | On systems that are configured to use the available screens as a
|
|---|
| 91 | single, large virtual desktop, the virtualDesktop property will be
|
|---|
| 92 | set to true. In this case, the widget's size is usually the size of
|
|---|
| 93 | the bounding rectangle of all the screens.
|
|---|
| 94 |
|
|---|
| 95 | \section1 Use of the Primary Screen
|
|---|
| 96 |
|
|---|
| 97 | For an application, the screen where the main widget resides is the
|
|---|
| 98 | primary screen. This is stored in the primaryScreen property.
|
|---|
| 99 | All windows opened in the context of the application should be
|
|---|
| 100 | constrained to the boundaries of the primary screen; for example,
|
|---|
| 101 | it would be inconvenient if a dialog box popped up on a different
|
|---|
| 102 | screen, or split over two screens.
|
|---|
| 103 |
|
|---|
| 104 | \image qdesktopwidget.png Managing Multiple Screens
|
|---|
| 105 |
|
|---|
| 106 | In the illustration above, Application One's primary screen is
|
|---|
| 107 | screen 0, and App Two's primary screen is screen 1.
|
|---|
| 108 |
|
|---|
| 109 | \sa QApplication, QApplication::desktop(), QX11Info::appRootWindow()
|
|---|
| 110 | */
|
|---|
| 111 |
|
|---|
| 112 | /*!
|
|---|
| 113 | \fn QDesktopWidget::QDesktopWidget()
|
|---|
| 114 |
|
|---|
| 115 | \internal
|
|---|
| 116 |
|
|---|
| 117 | Creates the desktop widget.
|
|---|
| 118 |
|
|---|
| 119 | If the system supports a virtual desktop, this widget will have
|
|---|
| 120 | the size of the virtual desktop; otherwise this widget will have
|
|---|
| 121 | the size of the primary screen.
|
|---|
| 122 |
|
|---|
| 123 | Instead of using QDesktopWidget directly, use QApplication::desktop().
|
|---|
| 124 | */
|
|---|
| 125 |
|
|---|
| 126 | /*!
|
|---|
| 127 | \fn QDesktopWidget::~QDesktopWidget()
|
|---|
| 128 |
|
|---|
| 129 | \internal
|
|---|
| 130 |
|
|---|
| 131 | Destroys the desktop widget and frees any allocated resources.
|
|---|
| 132 | */
|
|---|
| 133 |
|
|---|
| 134 | /*!
|
|---|
| 135 | \fn int QDesktopWidget::numScreens() const
|
|---|
| 136 |
|
|---|
| 137 | Returns the number of available screens.
|
|---|
| 138 |
|
|---|
| 139 | \obsolete
|
|---|
| 140 |
|
|---|
| 141 | This function is deprecated. Use screenCount instead.
|
|---|
| 142 |
|
|---|
| 143 | \sa primaryScreen
|
|---|
| 144 | */
|
|---|
| 145 |
|
|---|
| 146 | /*!
|
|---|
| 147 | \fn QWidget *QDesktopWidget::screen(int screen)
|
|---|
| 148 |
|
|---|
| 149 | Returns a widget that represents the screen with index \a screen
|
|---|
| 150 | (a value of -1 means the default screen).
|
|---|
| 151 |
|
|---|
| 152 | If the system uses a virtual desktop, the returned widget will
|
|---|
| 153 | have the geometry of the entire virtual desktop; i.e., bounding
|
|---|
| 154 | every \a screen.
|
|---|
| 155 |
|
|---|
| 156 | \sa primaryScreen, screenCount, virtualDesktop
|
|---|
| 157 | */
|
|---|
| 158 |
|
|---|
| 159 | /*!
|
|---|
| 160 | \fn const QRect QDesktopWidget::availableGeometry(int screen) const
|
|---|
| 161 |
|
|---|
| 162 | Returns the available geometry of the screen with index \a screen. What
|
|---|
| 163 | is available will be subrect of screenGeometry() based on what the
|
|---|
| 164 | platform decides is available (for example excludes the dock and menu bar
|
|---|
| 165 | on Mac OS X, or the task bar on Windows). The default screen is used if
|
|---|
| 166 | \a screen is -1.
|
|---|
| 167 |
|
|---|
| 168 | \sa screenNumber(), screenGeometry()
|
|---|
| 169 | */
|
|---|
| 170 |
|
|---|
| 171 | /*!
|
|---|
| 172 | \fn const QRect QDesktopWidget::availableGeometry(const QWidget *widget) const
|
|---|
| 173 | \overload
|
|---|
| 174 |
|
|---|
| 175 | Returns the available geometry of the screen which contains \a widget.
|
|---|
| 176 |
|
|---|
| 177 | \sa screenGeometry()
|
|---|
| 178 | */
|
|---|
| 179 |
|
|---|
| 180 | /*!
|
|---|
| 181 | \fn const QRect QDesktopWidget::availableGeometry(const QPoint &p) const
|
|---|
| 182 | \overload
|
|---|
| 183 |
|
|---|
| 184 | Returns the available geometry of the screen which contains \a p.
|
|---|
| 185 |
|
|---|
| 186 | \sa screenGeometry()
|
|---|
| 187 | */
|
|---|
| 188 |
|
|---|
| 189 |
|
|---|
| 190 | /*!
|
|---|
| 191 | \fn const QRect QDesktopWidget::screenGeometry(int screen) const
|
|---|
| 192 |
|
|---|
| 193 | Returns the geometry of the screen with index \a screen. The default
|
|---|
| 194 | screen is used if \a screen is -1.
|
|---|
| 195 |
|
|---|
| 196 | \sa screenNumber()
|
|---|
| 197 | */
|
|---|
| 198 |
|
|---|
| 199 | /*!
|
|---|
| 200 | \fn const QRect QDesktopWidget::screenGeometry(const QWidget *widget) const
|
|---|
| 201 | \overload
|
|---|
| 202 |
|
|---|
| 203 | Returns the geometry of the screen which contains \a widget.
|
|---|
| 204 | */
|
|---|
| 205 |
|
|---|
| 206 | /*!
|
|---|
| 207 | \fn const QRect QDesktopWidget::screenGeometry(const QPoint &p) const
|
|---|
| 208 | \overload
|
|---|
| 209 |
|
|---|
| 210 | Returns the geometry of the screen which contains \a p.
|
|---|
| 211 | */
|
|---|
| 212 |
|
|---|
| 213 |
|
|---|
| 214 | /*!
|
|---|
| 215 | \fn int QDesktopWidget::screenNumber(const QWidget *widget) const
|
|---|
| 216 |
|
|---|
| 217 | Returns the index of the screen that contains the largest
|
|---|
| 218 | part of \a widget, or -1 if the widget not on a screen.
|
|---|
| 219 |
|
|---|
| 220 | \sa primaryScreen
|
|---|
| 221 | */
|
|---|
| 222 |
|
|---|
| 223 | /*!
|
|---|
| 224 | \fn int QDesktopWidget::screenNumber(const QPoint &point) const
|
|---|
| 225 |
|
|---|
| 226 | \overload
|
|---|
| 227 | Returns the index of the screen that contains the \a point, or the
|
|---|
| 228 | screen which is the shortest distance from the \a point.
|
|---|
| 229 |
|
|---|
| 230 | \sa primaryScreen
|
|---|
| 231 | */
|
|---|
| 232 |
|
|---|
| 233 | /*!
|
|---|
| 234 | \fn void QDesktopWidget::resizeEvent(QResizeEvent *event)
|
|---|
| 235 | \reimp
|
|---|
| 236 | */
|
|---|
| 237 |
|
|---|
| 238 | /*!
|
|---|
| 239 | \fn void QDesktopWidget::resized(int screen)
|
|---|
| 240 |
|
|---|
| 241 | This signal is emitted when the size of \a screen changes.
|
|---|
| 242 | */
|
|---|
| 243 |
|
|---|
| 244 | /*!
|
|---|
| 245 | \fn void QDesktopWidget::workAreaResized(int screen)
|
|---|
| 246 |
|
|---|
| 247 | This signal is emitted when the work area available on \a screen changes.
|
|---|
| 248 | */
|
|---|
| 249 |
|
|---|
| 250 | /*!
|
|---|
| 251 | \property QDesktopWidget::screenCount
|
|---|
| 252 | \brief the number of screens currently available on the system.
|
|---|
| 253 |
|
|---|
| 254 | \since 4.6
|
|---|
| 255 |
|
|---|
| 256 | \sa screenCountChanged()
|
|---|
| 257 | */
|
|---|
| 258 |
|
|---|
| 259 | /*!
|
|---|
| 260 | \property QDesktopWidget::primaryScreen
|
|---|
| 261 | \brief the index of the screen that is configured to be the primary screen
|
|---|
| 262 | on the system.
|
|---|
| 263 | */
|
|---|
| 264 |
|
|---|
| 265 | /*!
|
|---|
| 266 | \property QDesktopWidget::virtualDesktop
|
|---|
| 267 |
|
|---|
| 268 | \brief if the system manages the available screens in a virtual desktop.
|
|---|
| 269 |
|
|---|
| 270 | For virtual desktops, screen() will always return the same widget.
|
|---|
| 271 | The size of the virtual desktop is the size of this desktop
|
|---|
| 272 | widget.
|
|---|
| 273 | */
|
|---|
| 274 |
|
|---|
| 275 | /*!
|
|---|
| 276 | \fn void QDesktopWidget::screenCountChanged(int newCount)
|
|---|
| 277 |
|
|---|
| 278 | \since 4.6
|
|---|
| 279 |
|
|---|
| 280 | This signal is emitted when the number of screens changes to \a newCount.
|
|---|
| 281 |
|
|---|
| 282 | \sa screenCount
|
|---|
| 283 | */
|
|---|