From 65f5909df2b660402cf89031b8a1b308df289823 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 31 Aug 2012 15:43:49 +0200 Subject: [PATCH] Moved gui example documentation to the proper location. Gui example documentation should be in examples/gui/doc/ Change-Id: I3cd196a2bb5d76b6e275f336b29a2ad1811159dd Reviewed-by: Frederik Gladhorn --- .../gui/doc}/analogclockwindow.qdoc | 26 +++++++++---------- .../gui/doc}/openglwindow.qdoc | 22 ++++++++-------- .../gui/doc}/rasterwindow.qdoc | 18 ++++++------- examples/gui/gui.pro | 1 + src/gui/doc/qtgui.qdocconf | 12 ++++++--- 5 files changed, 42 insertions(+), 37 deletions(-) rename {src/gui/doc/examples => examples/gui/doc}/analogclockwindow.qdoc (89%) rename {doc/src/examples => examples/gui/doc}/openglwindow.qdoc (93%) rename {src/gui/doc/examples => examples/gui/doc}/rasterwindow.qdoc (92%) diff --git a/src/gui/doc/examples/analogclockwindow.qdoc b/examples/gui/doc/analogclockwindow.qdoc similarity index 89% rename from src/gui/doc/examples/analogclockwindow.qdoc rename to examples/gui/doc/analogclockwindow.qdoc index 17db0511f8..27c27fc540 100644 --- a/src/gui/doc/examples/analogclockwindow.qdoc +++ b/examples/gui/doc/analogclockwindow.qdoc @@ -45,17 +45,17 @@ make use of the RasterWindow from the \l {Raster Window Example} and reimplement the \c render function to draw the clock face: - \snippet gui/analogclock/main.cpp 5 + \snippet analogclock/main.cpp 5 \section1 AnalogClock Class Implementation - \snippet gui/analogclock/main.cpp 6 + \snippet analogclock/main.cpp 6 We set a title on the window and resize to a reasonable size. Then we start a timer which we will use to redraw the clock every second. - \snippet gui/analogclock/main.cpp 7 + \snippet analogclock/main.cpp 7 The timerEvent function is called every second as a result of our startTimer call. Making use of the convenience in the base @@ -65,21 +65,21 @@ one active timer in this instance, but it is good practice to do so. - \snippet gui/analogclock/main.cpp 14 - \snippet gui/analogclock/main.cpp 8 + \snippet analogclock/main.cpp 14 + \snippet analogclock/main.cpp 8 Before we set up the painter and draw the clock, we first define two lists of \l {QPoint}s and two \l{QColor}s that will be used for the hour and minute hands. The minute hand's color has an alpha component of 191, meaning that it's 75% opaque. - \snippet gui/analogclock/main.cpp 9 + \snippet analogclock/main.cpp 9 We call QPainter::setRenderHint() with QPainter::Antialiasing to turn on antialiasing. This makes drawing of diagonal lines much smoother. - \snippet gui/analogclock/main.cpp 10 + \snippet analogclock/main.cpp 10 The translation moves the origin to the center of the window, and the scale operation ensures that the following drawing operations @@ -106,31 +106,31 @@ hour and minute. This means that the hand will be shown rotated clockwise by the required amount. - \snippet gui/analogclock/main.cpp 11 + \snippet analogclock/main.cpp 11 We set the pen to be Qt::NoPen because we don't want any outline, and we use a solid brush with the color appropriate for displaying hours. Brushes are used when filling in polygons and other geometric shapes. - \snippet gui/analogclock/main.cpp 2 + \snippet analogclock/main.cpp 2 We save and restore the transformation matrix before and after the rotation because we want to place the minute hand without having to take into account any previous rotations. - \snippet gui/analogclock/main.cpp 12 + \snippet analogclock/main.cpp 12 We draw markers around the edge of the clock for each hour. We draw each marker then rotate the coordinate system so that the painter is ready for the next one. - \snippet gui/analogclock/main.cpp 13 - \snippet gui/analogclock/main.cpp 3 + \snippet analogclock/main.cpp 13 + \snippet analogclock/main.cpp 3 The minute hand is rotated in a similar way to the hour hand. - \snippet gui/analogclock/main.cpp 4 + \snippet analogclock/main.cpp 4 Again, we draw markers around the edge of the clock, but this time to indicate minutes. We skip multiples of 5 to avoid drawing diff --git a/doc/src/examples/openglwindow.qdoc b/examples/gui/doc/openglwindow.qdoc similarity index 93% rename from doc/src/examples/openglwindow.qdoc rename to examples/gui/doc/openglwindow.qdoc index 9d93af5154..bb5a8d2505 100644 --- a/doc/src/examples/openglwindow.qdoc +++ b/examples/gui/doc/openglwindow.qdoc @@ -53,13 +53,13 @@ you will not have to worry about resolving those functions if you want your application to work with OpenGL as well as OpenGL ES 2.0. - \snippet gui/openglwindow/openglwindow.h 1 + \snippet openglwindow/openglwindow.h 1 The window's surface type must be set to QSurface::OpenGLSurface to indicate that the window is to be used for OpenGL rendering and not for rendering raster content with QPainter using a QBackingStore. - \snippet gui/openglwindow/openglwindow.cpp 1 + \snippet openglwindow/openglwindow.cpp 1 Any OpenGL initialization needed can be done by overriding the initialize() function, which is called once before the first call to render(), with a @@ -68,7 +68,7 @@ whereas the default render() implementation initializes a QOpenGLPaintDevice and then calls into render(QPainter *). - \snippet gui/openglwindow/openglwindow.cpp 2 + \snippet openglwindow/openglwindow.cpp 2 The renderLater() function simply puts an update request event on the event loop, which leads to renderNow() being called once the event @@ -83,7 +83,7 @@ size might be unknown, and in addition what is rendered might not even end up on the screen. - \snippet gui/openglwindow/openglwindow.cpp 3 + \snippet openglwindow/openglwindow.cpp 3 In renderNow() we return if we are not currently exposed, in which case rendering is delayed until we actually get an expose event. If we have not @@ -111,12 +111,12 @@ If animation has been enabled with OpenGLWindow::setAnimating(true), we call renderLater() to put another update request on the event loop. - \snippet gui/openglwindow/openglwindow.cpp 4 + \snippet openglwindow/openglwindow.cpp 4 Enabling animation also triggers an update request as shown in the following code snippet. - \snippet gui/openglwindow/openglwindow.cpp 5 + \snippet openglwindow/openglwindow.cpp 5 \section1 Example OpenGL rendering sub class @@ -124,7 +124,7 @@ rotating triangle. By indirectly sub classing QOpenGLFunctions we gain access to all OpenGL ES 2.0 level functionality. - \snippet gui/openglwindow/main.cpp 1 + \snippet openglwindow/main.cpp 1 In our main function we initialize QGuiApplication and instantiate our TriangleOpenGLWindow. We give it a QSurfaceFormat specifying that we want @@ -132,13 +132,13 @@ Since we want to have animation we call the above mentioned setAnimating() function with an argument of true. - \snippet gui/openglwindow/main.cpp 2 + \snippet openglwindow/main.cpp 2 The following code snippet shows the OpenGL shader program used in this example. The vertex and fragment shaders are relatively simple, doing vertex transformation and interpolated vertex coloring. - \snippet gui/openglwindow/main.cpp 3 + \snippet openglwindow/main.cpp 3 Here is the code that loads the shaders and initializes the shader program By using QOpenGLShaderProgram instead of raw OpenGL we get the convenience @@ -147,10 +147,10 @@ locations in member variables to avoid having to do the location lookup each frame. - \snippet gui/openglwindow/main.cpp 4 + \snippet openglwindow/main.cpp 4 Finally, here is our render() function, where we use OpenGL to set up the viewport, clear the background, and render a rotating triangle. - \snippet gui/openglwindow/main.cpp 5 + \snippet openglwindow/main.cpp 5 */ diff --git a/src/gui/doc/examples/rasterwindow.qdoc b/examples/gui/doc/rasterwindow.qdoc similarity index 92% rename from src/gui/doc/examples/rasterwindow.qdoc rename to examples/gui/doc/rasterwindow.qdoc index d78f003b40..bb71ff4249 100644 --- a/src/gui/doc/examples/rasterwindow.qdoc +++ b/examples/gui/doc/rasterwindow.qdoc @@ -35,7 +35,7 @@ \section1 Application Entry Point - \snippet gui/rasterwindow/main.cpp 1 + \snippet rasterwindow/main.cpp 1 The entry point for a QWindow based application is the \l QGuiApplication class. It manages the GUI application's control @@ -52,7 +52,7 @@ \section1 RasterWindow Declaration - \snippet gui/rasterwindow/rasterwindow.h 1 + \snippet rasterwindow/rasterwindow.h 1 We first start by including the the QtGui headers. This means we can use all classes in the Qt GUI module. Classes can also be @@ -72,7 +72,7 @@ \section1 RasterWindow Implementation - \snippet gui/rasterwindow/rasterwindow.cpp 1 + \snippet rasterwindow/rasterwindow.cpp 1 The constructor first of all calls \l QWindow::create(). This will create the window in the windowing system. Without calling create, @@ -83,7 +83,7 @@ Then we create the backingstore and pass it the window instance it is supposed to manage. - \snippet gui/rasterwindow/rasterwindow.cpp 2 + \snippet rasterwindow/rasterwindow.cpp 2 Shortly after calling \l QWindow::show() on a created window, the virtual function \l QWindow::exposeEvent() will be called to @@ -100,7 +100,7 @@ system with some visual content. - \snippet gui/rasterwindow/rasterwindow.cpp 5 + \snippet rasterwindow/rasterwindow.cpp 5 The resize event is guaranteed to be called prior to the window being shown on screen and will also be called whenever the window @@ -108,7 +108,7 @@ and call renderNow() if we are visible to immediately update the visual representation of the window on screen. - \snippet gui/rasterwindow/rasterwindow.cpp 3 + \snippet rasterwindow/rasterwindow.cpp 3 The renderNow function sets up what is needed for a \l QWindow to render its content using QPainter. As obscured windows have will @@ -130,7 +130,7 @@ using \l QBackingStore::flush(). - \snippet gui/rasterwindow/rasterwindow.cpp 4 + \snippet rasterwindow/rasterwindow.cpp 4 The render function contains the drawing code for the window. In this minial example, we only draw the string "QWindow" in the @@ -140,7 +140,7 @@ \section1 Rendering Asynchronously - \snippet gui/rasterwindow/rasterwindow.cpp 6 + \snippet rasterwindow/rasterwindow.cpp 6 We went through a few places where the window needed to repainted immediately. There are some cases where this is not desierable, @@ -151,7 +151,7 @@ is already pending, we store this state in the \c m_update_pending variable. - \snippet gui/rasterwindow/rasterwindow.cpp 7 + \snippet rasterwindow/rasterwindow.cpp 7 We reimplement the virtual \l QObject::event() function to handle the update event we posted to ourselves. When the event comes in diff --git a/examples/gui/gui.pro b/examples/gui/gui.pro index baf5d7f3f3..1a4067e893 100644 --- a/examples/gui/gui.pro +++ b/examples/gui/gui.pro @@ -1,4 +1,5 @@ TEMPLATE = subdirs +CONFIG += no_docs_target SUBDIRS += analogclock SUBDIRS += rasterwindow diff --git a/src/gui/doc/qtgui.qdocconf b/src/gui/doc/qtgui.qdocconf index 5fdc9b7818..85fcbab3ca 100644 --- a/src/gui/doc/qtgui.qdocconf +++ b/src/gui/doc/qtgui.qdocconf @@ -71,12 +71,16 @@ depends += qtcore headerdirs += .. -sourcedirs += .. +sourcedirs += .. \ + ../../../examples/gui/doc -exampledirs += ../../../examples \ +exampledirs += ../../../examples/gui \ + ../../../doc/src/snippets \ ../ \ snippets -excludedirs += ../../../examples/widgets/doc +excludedirs += snippets -imagedirs += images +imagedirs += images \ + ../../../doc/src/images \ + ../../../examples/gui/doc/images