summaryrefslogtreecommitdiffstats
path: root/src/gui/doc/snippets
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/doc/snippets')
-rw-r--r--src/gui/doc/snippets/clipboard/clipboard.pro3
-rw-r--r--src/gui/doc/snippets/clipboard/clipwindow.cpp103
-rw-r--r--src/gui/doc/snippets/clipboard/clipwindow.h72
-rw-r--r--src/gui/doc/snippets/clipboard/main.cpp52
-rw-r--r--src/gui/doc/snippets/draganddrop/draganddrop.pro5
-rw-r--r--src/gui/doc/snippets/draganddrop/dragwidget.cpp153
-rw-r--r--src/gui/doc/snippets/draganddrop/dragwidget.h79
-rw-r--r--src/gui/doc/snippets/draganddrop/main.cpp53
-rw-r--r--src/gui/doc/snippets/draganddrop/mainwindow.cpp84
-rw-r--r--src/gui/doc/snippets/draganddrop/mainwindow.h71
-rw-r--r--src/gui/doc/snippets/dragging/dragging.pro5
-rw-r--r--src/gui/doc/snippets/dragging/images.qrc5
-rw-r--r--src/gui/doc/snippets/dragging/images/file.pngbin0 -> 313 bytes
-rw-r--r--src/gui/doc/snippets/dragging/main.cpp51
-rw-r--r--src/gui/doc/snippets/dragging/mainwindow.h71
-rw-r--r--src/gui/doc/snippets/dropevents/dropevents.pro3
-rw-r--r--src/gui/doc/snippets/dropevents/main.cpp52
-rw-r--r--src/gui/doc/snippets/dropevents/window.cpp87
-rw-r--r--src/gui/doc/snippets/dropevents/window.h71
-rw-r--r--src/gui/doc/snippets/droprectangle/droprectangle.pro3
-rw-r--r--src/gui/doc/snippets/droprectangle/main.cpp51
-rw-r--r--src/gui/doc/snippets/droprectangle/window.cpp96
-rw-r--r--src/gui/doc/snippets/droprectangle/window.h71
-rw-r--r--src/gui/doc/snippets/separations/finalwidget.h77
-rw-r--r--src/gui/doc/snippets/separations/main.cpp50
-rw-r--r--src/gui/doc/snippets/separations/screenwidget.cpp217
-rw-r--r--src/gui/doc/snippets/separations/screenwidget.h86
-rw-r--r--src/gui/doc/snippets/separations/separations.pro7
-rw-r--r--src/gui/doc/snippets/separations/separations.qdoc54
-rw-r--r--src/gui/doc/snippets/separations/viewer.cpp328
-rw-r--r--src/gui/doc/snippets/separations/viewer.h89
31 files changed, 2149 insertions, 0 deletions
diff --git a/src/gui/doc/snippets/clipboard/clipboard.pro b/src/gui/doc/snippets/clipboard/clipboard.pro
new file mode 100644
index 0000000000..a26fea6b57
--- /dev/null
+++ b/src/gui/doc/snippets/clipboard/clipboard.pro
@@ -0,0 +1,3 @@
+HEADERS = clipwindow.h
+SOURCES = clipwindow.cpp \
+ main.cpp
diff --git a/src/gui/doc/snippets/clipboard/clipwindow.cpp b/src/gui/doc/snippets/clipboard/clipwindow.cpp
new file mode 100644
index 0000000000..376d92afac
--- /dev/null
+++ b/src/gui/doc/snippets/clipboard/clipwindow.cpp
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "clipwindow.h"
+
+ClipWindow::ClipWindow(QWidget *parent)
+ : QMainWindow(parent)
+{
+ clipboard = QApplication::clipboard();
+
+ QWidget *centralWidget = new QWidget(this);
+ QWidget *currentItem = new QWidget(centralWidget);
+ QLabel *mimeTypeLabel = new QLabel(tr("MIME types:"), currentItem);
+ mimeTypeCombo = new QComboBox(currentItem);
+ QLabel *dataLabel = new QLabel(tr("Data:"), currentItem);
+ dataInfoLabel = new QLabel("", currentItem);
+
+ previousItems = new QListWidget(centralWidget);
+
+//! [0]
+ connect(clipboard, SIGNAL(dataChanged()), this, SLOT(updateClipboard()));
+//! [0]
+ connect(mimeTypeCombo, SIGNAL(activated(const QString &)),
+ this, SLOT(updateData(const QString &)));
+
+ QVBoxLayout *currentLayout = new QVBoxLayout(currentItem);
+ currentLayout->addWidget(mimeTypeLabel);
+ currentLayout->addWidget(mimeTypeCombo);
+ currentLayout->addWidget(dataLabel);
+ currentLayout->addWidget(dataInfoLabel);
+ currentLayout->addStretch(1);
+
+ QHBoxLayout *mainLayout = new QHBoxLayout(centralWidget);
+ mainLayout->addWidget(currentItem, 1);
+ mainLayout->addWidget(previousItems);
+
+ setCentralWidget(centralWidget);
+ setWindowTitle(tr("Clipboard"));
+}
+
+//! [1]
+void ClipWindow::updateClipboard()
+{
+ QStringList formats = clipboard->mimeData()->formats();
+ QByteArray data = clipboard->mimeData()->data(format);
+//! [1]
+
+ mimeTypeCombo->clear();
+ mimeTypeCombo->insertStringList(formats);
+
+ int size = clipboard->mimeData()->data(formats[0]).size();
+ QListWidgetItem *newItem = new QListWidgetItem(previousItems);
+ newItem->setText(tr("%1 (%2 bytes)").arg(formats[0]).arg(size));
+
+ updateData(formats[0]);
+//! [2]
+}
+//! [2]
+
+void ClipWindow::updateData(const QString &format)
+{
+ QByteArray data = clipboard->mimeData()->data(format);
+ dataInfoLabel->setText(tr("%1 bytes").arg(data.size()));
+}
diff --git a/src/gui/doc/snippets/clipboard/clipwindow.h b/src/gui/doc/snippets/clipboard/clipwindow.h
new file mode 100644
index 0000000000..2ab42c9174
--- /dev/null
+++ b/src/gui/doc/snippets/clipboard/clipwindow.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CLIPWINDOW_H
+#define CLIPWINDOW_H
+
+#include <QMainWindow>
+
+class QClipboard;
+class QComboBox;
+class QLabel;
+class QListWidget;
+class QMimeData;
+class QWidget;
+
+class ClipWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ ClipWindow(QWidget *parent = 0);
+
+public slots:
+ void updateClipboard();
+ void updateData(const QString &format);
+
+private:
+ int currentItem;
+ QClipboard *clipboard;
+ QComboBox *mimeTypeCombo;
+ QLabel *dataInfoLabel;
+ QListWidget *previousItems;
+};
+
+#endif
diff --git a/src/gui/doc/snippets/clipboard/main.cpp b/src/gui/doc/snippets/clipboard/main.cpp
new file mode 100644
index 0000000000..f94fe4994a
--- /dev/null
+++ b/src/gui/doc/snippets/clipboard/main.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+
+#include "clipwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ ClipWindow *window = new ClipWindow;
+ window->resize(640, 480);
+ window->show();
+ return app.exec();
+}
diff --git a/src/gui/doc/snippets/draganddrop/draganddrop.pro b/src/gui/doc/snippets/draganddrop/draganddrop.pro
new file mode 100644
index 0000000000..67bc32bd10
--- /dev/null
+++ b/src/gui/doc/snippets/draganddrop/draganddrop.pro
@@ -0,0 +1,5 @@
+HEADERS = dragwidget.h \
+ mainwindow.h
+SOURCES = dragwidget.cpp \
+ main.cpp \
+ mainwindow.cpp
diff --git a/src/gui/doc/snippets/draganddrop/dragwidget.cpp b/src/gui/doc/snippets/draganddrop/dragwidget.cpp
new file mode 100644
index 0000000000..aa2075a977
--- /dev/null
+++ b/src/gui/doc/snippets/draganddrop/dragwidget.cpp
@@ -0,0 +1,153 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "dragwidget.h"
+
+DragWidget::DragWidget(QWidget *parent)
+ : QFrame(parent)
+{
+ setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
+ dragDropLabel = new QLabel("", this);
+ dragDropLabel->setAlignment(Qt::AlignHCenter);
+
+ QHBoxLayout *layout = new QHBoxLayout(this);
+ layout->addStretch(0);
+ layout->addWidget(dragDropLabel);
+ layout->addStretch(0);
+
+ setAcceptDrops(true);
+}
+
+// Accept all actions, but deal with them separately later.
+//! [0]
+void DragWidget::dragEnterEvent(QDragEnterEvent *event)
+{
+ event->acceptProposedAction();
+}
+//! [0]
+
+//! [1]
+void DragWidget::dropEvent(QDropEvent *event)
+{
+ if (event->source() == this && event->possibleActions() & Qt::MoveAction)
+ return;
+//! [1]
+
+//! [2]
+ if (event->proposedAction() == Qt::MoveAction) {
+ event->acceptProposedAction();
+ // Process the data from the event.
+//! [2]
+ emit dragResult(tr("The data was moved here."));
+//! [3]
+ } else if (event->proposedAction() == Qt::CopyAction) {
+ event->acceptProposedAction();
+ // Process the data from the event.
+//! [3]
+ emit dragResult(tr("The data was copied here."));
+//! [4]
+ } else {
+ // Ignore the drop.
+ return;
+ }
+//! [4]
+ // End of quote
+
+ emit mimeTypes(event->mimeData()->formats());
+ setData(event->mimeData()->formats()[0],
+ event->mimeData()->data(event->mimeData()->formats()[0]));
+//! [5]
+}
+//! [5]
+
+//! [6]
+void DragWidget::mousePressEvent(QMouseEvent *event)
+{
+ if (event->button() == Qt::LeftButton)
+ dragStartPosition = event->pos();
+}
+//! [6]
+
+//! [7]
+void DragWidget::mouseMoveEvent(QMouseEvent *event)
+{
+ if (!(event->buttons() & Qt::LeftButton))
+ return;
+ if ((event->pos() - dragStartPosition).manhattanLength()
+ < QApplication::startDragDistance())
+ return;
+
+ QDrag *drag = new QDrag(this);
+ QMimeData *mimeData = new QMimeData;
+
+ mimeData->setData(mimeType, data);
+ drag->setMimeData(mimeData);
+
+ Qt::DropAction dropAction = drag->exec(Qt::CopyAction | Qt::MoveAction);
+//! [7]
+
+ switch (dropAction) {
+ case Qt::CopyAction:
+ emit dragResult(tr("The text was copied."));
+ break;
+ case Qt::MoveAction:
+ emit dragResult(tr("The text was moved."));
+ break;
+ default:
+ emit dragResult(tr("Unknown action."));
+ break;
+ }
+//! [8]
+}
+//! [8]
+
+void DragWidget::setData(const QString &mimetype, const QByteArray &newData)
+{
+ mimeType = mimetype;
+ data = QByteArray(newData);
+
+ dragDropLabel->setText(tr("%1 bytes").arg(data.size()));
+
+ QStringList formats;
+ formats << mimetype;
+ emit mimeTypes(formats);
+}
diff --git a/src/gui/doc/snippets/draganddrop/dragwidget.h b/src/gui/doc/snippets/draganddrop/dragwidget.h
new file mode 100644
index 0000000000..cd12c08884
--- /dev/null
+++ b/src/gui/doc/snippets/draganddrop/dragwidget.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DRAGWIDGET_H
+#define DRAGWIDGET_H
+
+#include <QByteArray>
+#include <QFrame>
+#include <QString>
+#include <QStringList>
+
+class QComboBox;
+class QFrame;
+class QLabel;
+class QTextBrowser;
+
+class DragWidget : public QFrame
+{
+ Q_OBJECT
+
+public:
+ DragWidget(QWidget *parent);
+ void setData(const QString &mimetype, const QByteArray &newData);
+
+signals:
+ void dragResult(const QString &actionText);
+ void mimeTypes(const QStringList &types);
+
+protected:
+ void dragEnterEvent(QDragEnterEvent *event);
+ void dropEvent(QDropEvent *event);
+ void mouseMoveEvent(QMouseEvent *event);
+ void mousePressEvent(QMouseEvent *event);
+
+private:
+ QByteArray data;
+ QLabel *dragDropLabel;
+ QPoint dragStartPosition;
+ QString mimeType;
+};
+
+#endif
diff --git a/src/gui/doc/snippets/draganddrop/main.cpp b/src/gui/doc/snippets/draganddrop/main.cpp
new file mode 100644
index 0000000000..c15b641249
--- /dev/null
+++ b/src/gui/doc/snippets/draganddrop/main.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window1 = new MainWindow;
+ MainWindow *window2 = new MainWindow;
+ window1->show();
+ window2->show();
+ return app.exec();
+}
diff --git a/src/gui/doc/snippets/draganddrop/mainwindow.cpp b/src/gui/doc/snippets/draganddrop/mainwindow.cpp
new file mode 100644
index 0000000000..4c443bbc09
--- /dev/null
+++ b/src/gui/doc/snippets/draganddrop/mainwindow.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "dragwidget.h"
+#include "mainwindow.h"
+
+MainWindow::MainWindow(QWidget *parent)
+ : QMainWindow(parent)
+{
+ QFrame *centralWidget = new QFrame(this);
+
+ QLabel *mimeTypeLabel = new QLabel(tr("MIME types:"), centralWidget);
+ mimeTypeCombo = new QComboBox(centralWidget);
+
+ QLabel *dataLabel = new QLabel(tr("Amount of data (bytes):"), centralWidget);
+ dragWidget = new DragWidget(centralWidget);
+
+ connect(dragWidget, SIGNAL(mimeTypes(const QStringList &)),
+ this, SLOT(setMimeTypes(const QStringList &)));
+ connect(dragWidget, SIGNAL(dragResult(const QString &)),
+ this, SLOT(setDragResult(const QString &)));
+
+ QVBoxLayout *mainLayout = new QVBoxLayout(centralWidget);
+ mainLayout->addWidget(mimeTypeLabel);
+ mainLayout->addWidget(mimeTypeCombo);
+ mainLayout->addSpacing(32);
+ mainLayout->addWidget(dataLabel);
+ mainLayout->addWidget(dragWidget);
+
+ statusBar();
+ dragWidget->setData(QString("text/plain"), QByteArray("Hello world"));
+ setCentralWidget(centralWidget);
+ setWindowTitle(tr("Drag and Drop"));
+}
+
+void MainWindow::setDragResult(const QString &actionText)
+{
+ statusBar()->showMessage(actionText);
+}
+
+void MainWindow::setMimeTypes(const QStringList &types)
+{
+ mimeTypeCombo->clear();
+ mimeTypeCombo->addItems(types);
+}
diff --git a/src/gui/doc/snippets/draganddrop/mainwindow.h b/src/gui/doc/snippets/draganddrop/mainwindow.h
new file mode 100644
index 0000000000..5b9018e1a2
--- /dev/null
+++ b/src/gui/doc/snippets/draganddrop/mainwindow.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+#include <QPixmap>
+#include <QPoint>
+
+class QComboBox;
+class QLabel;
+class QLineEdit;
+class QMouseEvent;
+class QTextEdit;
+class DragWidget;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow(QWidget *parent = 0);
+
+public slots:
+ void setDragResult(const QString &actionText);
+ void setMimeTypes(const QStringList &types);
+
+private:
+ QComboBox *mimeTypeCombo;
+ DragWidget *dragWidget;
+};
+
+#endif
diff --git a/src/gui/doc/snippets/dragging/dragging.pro b/src/gui/doc/snippets/dragging/dragging.pro
new file mode 100644
index 0000000000..0a16eb19bf
--- /dev/null
+++ b/src/gui/doc/snippets/dragging/dragging.pro
@@ -0,0 +1,5 @@
+QT += widgets
+HEADERS += mainwindow.h
+RESOURCES += images.qrc
+SOURCES += main.cpp \
+ mainwindow.cpp
diff --git a/src/gui/doc/snippets/dragging/images.qrc b/src/gui/doc/snippets/dragging/images.qrc
new file mode 100644
index 0000000000..30b8a2986e
--- /dev/null
+++ b/src/gui/doc/snippets/dragging/images.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>images/file.png</file>
+</qresource>
+</RCC>
diff --git a/src/gui/doc/snippets/dragging/images/file.png b/src/gui/doc/snippets/dragging/images/file.png
new file mode 100644
index 0000000000..9520080ed0
--- /dev/null
+++ b/src/gui/doc/snippets/dragging/images/file.png
Binary files differ
diff --git a/src/gui/doc/snippets/dragging/main.cpp b/src/gui/doc/snippets/dragging/main.cpp
new file mode 100644
index 0000000000..1eb4112e60
--- /dev/null
+++ b/src/gui/doc/snippets/dragging/main.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow *window = new MainWindow;
+ window->show();
+ return app.exec();
+}
diff --git a/src/gui/doc/snippets/dragging/mainwindow.h b/src/gui/doc/snippets/dragging/mainwindow.h
new file mode 100644
index 0000000000..216afbc6db
--- /dev/null
+++ b/src/gui/doc/snippets/dragging/mainwindow.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+#include <QPixmap>
+#include <QPoint>
+
+class QLabel;
+class QLineEdit;
+class QMouseEvent;
+class QTextEdit;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow(QWidget *parent = 0);
+
+protected:
+ void mousePressEvent(QMouseEvent *event);
+
+private:
+ QLabel *iconLabel;
+ QLineEdit *nameEdit;
+ QPixmap iconPixmap;
+ QPoint dragStartPosition;
+ QTextEdit *commentEdit;
+};
+
+#endif
diff --git a/src/gui/doc/snippets/dropevents/dropevents.pro b/src/gui/doc/snippets/dropevents/dropevents.pro
new file mode 100644
index 0000000000..6283406f25
--- /dev/null
+++ b/src/gui/doc/snippets/dropevents/dropevents.pro
@@ -0,0 +1,3 @@
+HEADERS = window.h
+SOURCES = main.cpp \
+ window.cpp
diff --git a/src/gui/doc/snippets/dropevents/main.cpp b/src/gui/doc/snippets/dropevents/main.cpp
new file mode 100644
index 0000000000..1337f7f921
--- /dev/null
+++ b/src/gui/doc/snippets/dropevents/main.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "window.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ Window *window = new Window;
+ window->show();
+ return app.exec();
+}
diff --git a/src/gui/doc/snippets/dropevents/window.cpp b/src/gui/doc/snippets/dropevents/window.cpp
new file mode 100644
index 0000000000..f3c4a0c610
--- /dev/null
+++ b/src/gui/doc/snippets/dropevents/window.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "window.h"
+
+//! [0]
+Window::Window(QWidget *parent)
+ : QWidget(parent)
+{
+//! [0]
+ QLabel *textLabel = new QLabel(tr("Data:"), this);
+ textBrowser = new QTextBrowser(this);
+
+ QLabel *mimeTypeLabel = new QLabel(tr("MIME types:"), this);
+ mimeTypeCombo = new QComboBox(this);
+
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ layout->addWidget(textLabel);
+ layout->addWidget(textBrowser);
+ layout->addWidget(mimeTypeLabel);
+ layout->addWidget(mimeTypeCombo);
+
+//! [1]
+ setAcceptDrops(true);
+//! [1]
+ setWindowTitle(tr("Drop Events"));
+//! [2]
+}
+//! [2]
+
+//! [3]
+void Window::dragEnterEvent(QDragEnterEvent *event)
+{
+ if (event->mimeData()->hasFormat("text/plain"))
+ event->acceptProposedAction();
+}
+//! [3]
+
+//! [4]
+void Window::dropEvent(QDropEvent *event)
+{
+ textBrowser->setPlainText(event->mimeData()->text());
+ mimeTypeCombo->clear();
+ mimeTypeCombo->addItems(event->mimeData()->formats());
+
+ event->acceptProposedAction();
+}
+//! [4]
diff --git a/src/gui/doc/snippets/dropevents/window.h b/src/gui/doc/snippets/dropevents/window.h
new file mode 100644
index 0000000000..dd5487a7e2
--- /dev/null
+++ b/src/gui/doc/snippets/dropevents/window.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QString>
+#include <QStringList>
+#include <QWidget>
+
+class QComboBox;
+class QFrame;
+class QTextBrowser;
+
+class Window : public QWidget
+{
+ Q_OBJECT
+
+public:
+ Window(QWidget *parent = 0);
+
+protected:
+ void dragEnterEvent(QDragEnterEvent *event);
+ void dropEvent(QDropEvent *event);
+
+private:
+ QComboBox *mimeTypeCombo;
+ QFrame *dropFrame;
+ QTextBrowser *textBrowser;
+ QString oldText;
+ QStringList oldMimeTypes;
+};
+
+#endif
diff --git a/src/gui/doc/snippets/droprectangle/droprectangle.pro b/src/gui/doc/snippets/droprectangle/droprectangle.pro
new file mode 100644
index 0000000000..6283406f25
--- /dev/null
+++ b/src/gui/doc/snippets/droprectangle/droprectangle.pro
@@ -0,0 +1,3 @@
+HEADERS = window.h
+SOURCES = main.cpp \
+ window.cpp
diff --git a/src/gui/doc/snippets/droprectangle/main.cpp b/src/gui/doc/snippets/droprectangle/main.cpp
new file mode 100644
index 0000000000..e436e24e97
--- /dev/null
+++ b/src/gui/doc/snippets/droprectangle/main.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "window.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Window *window = new Window;
+ window->show();
+ return app.exec();
+}
diff --git a/src/gui/doc/snippets/droprectangle/window.cpp b/src/gui/doc/snippets/droprectangle/window.cpp
new file mode 100644
index 0000000000..d488a8742b
--- /dev/null
+++ b/src/gui/doc/snippets/droprectangle/window.cpp
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "window.h"
+
+Window::Window(QWidget *parent)
+ : QWidget(parent)
+{
+ QLabel *textLabel = new QLabel(tr("Data:"), this);
+ textBrowser = new QTextBrowser(this);
+
+ QLabel *mimeTypeLabel = new QLabel(tr("MIME types:"), this);
+ mimeTypeCombo = new QComboBox(this);
+
+ dropFrame = new QFrame(this);
+ dropFrame->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
+ QLabel *dropLabel = new QLabel(tr("Drop items here"), dropFrame);
+ dropLabel->setAlignment(Qt::AlignHCenter);
+
+ QVBoxLayout *dropFrameLayout = new QVBoxLayout(dropFrame);
+ dropFrameLayout->addWidget(dropLabel);
+
+ QHBoxLayout *dropLayout = new QHBoxLayout;
+ dropLayout->addStretch(0);
+ dropLayout->addWidget(dropFrame);
+ dropLayout->addStretch(0);
+
+ QVBoxLayout *mainLayout = new QVBoxLayout(this);
+ mainLayout->addWidget(textLabel);
+ mainLayout->addWidget(textBrowser);
+ mainLayout->addWidget(mimeTypeLabel);
+ mainLayout->addWidget(mimeTypeCombo);
+ mainLayout->addSpacing(32);
+ mainLayout->addLayout(dropLayout);
+
+ setAcceptDrops(true);
+ setWindowTitle(tr("Drop Rectangle"));
+}
+
+//! [0]
+void Window::dragMoveEvent(QDragMoveEvent *event)
+{
+ if (event->mimeData()->hasFormat("text/plain")
+ && event->answerRect().intersects(dropFrame->geometry()))
+
+ event->acceptProposedAction();
+}
+//! [0]
+
+void Window::dropEvent(QDropEvent *event)
+{
+ textBrowser->setPlainText(event->mimeData()->text());
+ mimeTypeCombo->clear();
+ mimeTypeCombo->addItems(event->mimeData()->formats());
+
+ event->acceptProposedAction();
+}
diff --git a/src/gui/doc/snippets/droprectangle/window.h b/src/gui/doc/snippets/droprectangle/window.h
new file mode 100644
index 0000000000..b07d030d13
--- /dev/null
+++ b/src/gui/doc/snippets/droprectangle/window.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QString>
+#include <QStringList>
+#include <QWidget>
+
+class QComboBox;
+class QFrame;
+class QTextBrowser;
+
+class Window : public QWidget
+{
+ Q_OBJECT
+
+public:
+ Window(QWidget *parent = 0);
+
+protected:
+ void dragMoveEvent(QDragMoveEvent *event);
+ void dropEvent(QDropEvent *event);
+
+private:
+ QComboBox *mimeTypeCombo;
+ QFrame *dropFrame;
+ QTextBrowser *textBrowser;
+ QString oldText;
+ QStringList oldMimeTypes;
+};
+
+#endif
diff --git a/src/gui/doc/snippets/separations/finalwidget.h b/src/gui/doc/snippets/separations/finalwidget.h
new file mode 100644
index 0000000000..e7247d31c0
--- /dev/null
+++ b/src/gui/doc/snippets/separations/finalwidget.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef FINALWIDGET_H
+#define FINALWIDGET_H
+
+#include <QFrame>
+#include <QImage>
+#include <QPoint>
+#include <QSize>
+
+class QGridLayout;
+class QLabel;
+class QMouseEvent;
+class QWidget;
+
+class FinalWidget : public QFrame
+{
+ Q_OBJECT
+
+public:
+ FinalWidget(QWidget *parent, const QString &name, const QSize &labelSize);
+ void setPixmap(const QPixmap &pixmap);
+ const QPixmap *pixmap() const;
+
+protected:
+ void mouseMoveEvent(QMouseEvent *event);
+ void mousePressEvent(QMouseEvent *event);
+
+private:
+ void createImage();
+
+ bool hasImage;
+ QImage originalImage;
+ QLabel *imageLabel;
+ QLabel *nameLabel;
+ QPoint dragStartPosition;
+};
+
+#endif
diff --git a/src/gui/doc/snippets/separations/main.cpp b/src/gui/doc/snippets/separations/main.cpp
new file mode 100644
index 0000000000..963dab3635
--- /dev/null
+++ b/src/gui/doc/snippets/separations/main.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include "viewer.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Viewer viewer;
+ viewer.show();
+ return app.exec();
+}
diff --git a/src/gui/doc/snippets/separations/screenwidget.cpp b/src/gui/doc/snippets/separations/screenwidget.cpp
new file mode 100644
index 0000000000..328b1d0624
--- /dev/null
+++ b/src/gui/doc/snippets/separations/screenwidget.cpp
@@ -0,0 +1,217 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+screenwidget.cpp
+
+A widget to display colour components from an image using independently
+selected colors. Controls are provided to allow the image to be inverted, and
+the color to be selection via a standard dialog. The image is displayed in a
+label widget.
+*/
+
+#include <QApplication>
+#include <QColorDialog>
+#include <QGridLayout>
+#include <QImage>
+#include <QLabel>
+#include <QMenu>
+#include <QMimeData>
+#include <QMouseEvent>
+#include <QPixmap>
+#include <QPushButton>
+#include <QWidget>
+
+#include "screenwidget.h"
+
+/*!
+Initializes the paint color, the mask color (cyan, magenta,
+or yellow), connects the color selector and invert checkbox to functions,
+and creates a two-by-two grid layout.
+*/
+
+ScreenWidget::ScreenWidget(QWidget *parent, QColor initialColor,
+ const QString &name, Separation mask,
+ const QSize &labelSize)
+ : QFrame(parent)
+{
+ paintColor = initialColor;
+ maskColor = mask;
+ inverted = false;
+
+ imageLabel = new QLabel;
+ imageLabel->setFrameShadow(QFrame::Sunken);
+ imageLabel->setFrameShape(QFrame::StyledPanel);
+ imageLabel->setMinimumSize(labelSize);
+
+ nameLabel = new QLabel(name);
+ colorButton = new QPushButton(tr("Modify..."));
+ colorButton->setBackgroundRole(QPalette::Button);
+ colorButton->setMinimumSize(32, 32);
+
+ QPalette palette(colorButton->palette());
+ palette.setColor(QPalette::Button, initialColor);
+ colorButton->setPalette(palette);
+
+ invertButton = new QPushButton(tr("Invert"));
+ //invertButton->setToggleButton(true);
+ //invertButton->setOn(inverted);
+ invertButton->setEnabled(false);
+
+ connect(colorButton, SIGNAL(clicked()), this, SLOT(setColor()));
+ connect(invertButton, SIGNAL(clicked()), this, SLOT(invertImage()));
+
+ QGridLayout *gridLayout = new QGridLayout;
+ gridLayout->addWidget(imageLabel, 0, 0, 1, 2);
+ gridLayout->addWidget(nameLabel, 1, 0);
+ gridLayout->addWidget(colorButton, 1, 1);
+ gridLayout->addWidget(invertButton, 2, 1, 1, 1);
+ setLayout(gridLayout);
+}
+
+/*!
+ Creates a new image by separating out the cyan, magenta, or yellow
+ component, depending on the mask color specified in the constructor.
+
+ The amount of the component found in each pixel of the image is used
+ to determine how much of a user-selected ink is used for each pixel
+ in the new image for the label widget.
+*/
+
+void ScreenWidget::createImage()
+{
+ newImage = originalImage.copy();
+
+ // Create CMY components for the ink being used.
+ float cyanInk = (255 - paintColor.red())/255.0;
+ float magentaInk = (255 - paintColor.green())/255.0;
+ float yellowInk = (255 - paintColor.blue())/255.0;
+
+ int (*convert)(QRgb);
+
+ switch (maskColor) {
+ case Cyan:
+ convert = qRed;
+ break;
+ case Magenta:
+ convert = qGreen;
+ break;
+ case Yellow:
+ convert = qBlue;
+ break;
+ }
+
+ for (int y = 0; y < newImage.height(); ++y) {
+ for (int x = 0; x < newImage.width(); ++x) {
+ QRgb p(originalImage.pixel(x, y));
+
+ // Separate the source pixel into its cyan component.
+ int amount;
+
+ if (inverted)
+ amount = convert(p);
+ else
+ amount = 255 - convert(p);
+
+ QColor newColor(
+ 255 - qMin(int(amount * cyanInk), 255),
+ 255 - qMin(int(amount * magentaInk), 255),
+ 255 - qMin(int(amount * yellowInk), 255));
+
+ newImage.setPixel(x, y, newColor.rgb());
+ }
+ }
+
+ imageLabel->setPixmap(QPixmap::fromImage(newImage));
+}
+
+/*!
+ Returns a pointer to the modified image.
+*/
+
+QImage* ScreenWidget::image()
+{
+ return &newImage;
+}
+
+/*!
+ Sets whether the amount of ink applied to the canvas is to be inverted
+ (subtracted from the maximum value) before the ink is applied.
+*/
+
+void ScreenWidget::invertImage()
+{
+ //inverted = invertButton->isOn();
+ inverted = !inverted;
+ createImage();
+ emit imageChanged();
+}
+
+/*!
+ Separate the current image into cyan, magenta, and yellow components.
+ Create a representation of how each component might appear when applied
+ to a blank white piece of paper.
+*/
+
+void ScreenWidget::setColor()
+{
+ QColor newColor = QColorDialog::getColor(paintColor);
+
+ if (newColor.isValid()) {
+ paintColor = newColor;
+ QPalette palette(colorButton->palette());
+ palette.setColor(QPalette::Button, paintColor);
+ colorButton->setPalette(palette);
+ createImage();
+ emit imageChanged();
+ }
+}
+
+/*!
+ Records the original image selected by the user, creates a color
+ separation, and enables the invert image checkbox.
+*/
+
+void ScreenWidget::setImage(QImage &image)
+{
+ originalImage = image;
+ createImage();
+ invertButton->setEnabled(true);
+}
diff --git a/src/gui/doc/snippets/separations/screenwidget.h b/src/gui/doc/snippets/separations/screenwidget.h
new file mode 100644
index 0000000000..82d079f533
--- /dev/null
+++ b/src/gui/doc/snippets/separations/screenwidget.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SCREENWIDGET_H
+#define SCREENWIDGET_H
+
+#include <QColor>
+#include <QFrame>
+#include <QImage>
+#include <QSize>
+
+class QGridLayout;
+class QLabel;
+class QPushButton;
+class QWidget;
+
+class ScreenWidget : public QFrame
+{
+ Q_OBJECT
+public:
+ enum Separation { Cyan, Magenta, Yellow };
+
+ ScreenWidget(QWidget *parent, QColor initialColor, const QString &name,
+ Separation mask, const QSize &labelSize);
+ void setImage(QImage &image);
+ QImage* image();
+
+signals:
+ void imageChanged();
+
+public slots:
+ void setColor();
+ void invertImage();
+
+private:
+ void createImage();
+
+ bool inverted;
+ QColor paintColor;
+ QImage newImage;
+ QImage originalImage;
+ QLabel *imageLabel;
+ QLabel *nameLabel;
+ QPushButton *colorButton;
+ QPushButton *invertButton;
+ Separation maskColor;
+};
+
+#endif
diff --git a/src/gui/doc/snippets/separations/separations.pro b/src/gui/doc/snippets/separations/separations.pro
new file mode 100644
index 0000000000..48af2c8472
--- /dev/null
+++ b/src/gui/doc/snippets/separations/separations.pro
@@ -0,0 +1,7 @@
+HEADERS = finalwidget.h \
+ screenwidget.h \
+ viewer.h
+SOURCES = finalwidget.cpp \
+ main.cpp \
+ screenwidget.cpp \
+ viewer.cpp
diff --git a/src/gui/doc/snippets/separations/separations.qdoc b/src/gui/doc/snippets/separations/separations.qdoc
new file mode 100644
index 0000000000..005ee7be22
--- /dev/null
+++ b/src/gui/doc/snippets/separations/separations.qdoc
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ \example painting/separations
+ \title Color Separations Example
+
+ This example enables simple color manipulation of images and demonstrates a
+ number of image-related features of Qt, from per-pixel image manipulation to
+ drag and drop handling of images.
+
+ \image separations-example.png
+
+ The application allows the user to load an image, shown in the top-left
+ part of the main window, and to adjust its color balance by replacing its
+ initial cyan, magenta, and yellow components with different colors.
+*/
diff --git a/src/gui/doc/snippets/separations/viewer.cpp b/src/gui/doc/snippets/separations/viewer.cpp
new file mode 100644
index 0000000000..1cb7d2d0d5
--- /dev/null
+++ b/src/gui/doc/snippets/separations/viewer.cpp
@@ -0,0 +1,328 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+viewer.cpp
+
+Provides a main window for displaying a user-specified original image
+with three color separations in a grid layout.
+
+A main menu provides entries for selecting files, and adjusting the
+brightness of the separations.
+*/
+
+#include <QtGui>
+
+#include "finalwidget.h"
+#include "screenwidget.h"
+#include "viewer.h"
+
+/*
+ Constructor: initializes a default value for the brightness, creates
+ the main menu entries, and constructs a central widget that contains
+ enough space for images to be displayed.
+*/
+
+Viewer::Viewer()
+{
+ setWindowTitle(tr("QImage Color Separations"));
+
+ brightness = 255;
+
+ createMenus();
+ setCentralWidget(createCentralWidget());
+}
+
+/*
+ Creates a main menu with two entries: a File menu, to allow the image
+ to be selected, and a Brightness menu to allow the brightness of the
+ separations to be changed.
+
+ Initially, the Brightness menu items are disabled, but the first entry in
+ the menu is checked to reflect the default brightness.
+*/
+
+void Viewer::createMenus()
+{
+ fileMenu = new QMenu(tr("&File"), this);
+ brightnessMenu = new QMenu(tr("&Brightness"), this);
+
+ QAction *openAction = fileMenu->addAction(tr("&Open..."));
+ openAction->setShortcut(QKeySequence("Ctrl+O"));
+ saveAction = fileMenu->addAction(tr("&Save..."));
+ saveAction->setShortcut(QKeySequence("Ctrl+S"));
+ saveAction->setEnabled(false);
+ QAction *quitAction = fileMenu->addAction(tr("E&xit"));
+ quitAction->setShortcut(QKeySequence("Ctrl+Q"));
+
+ QAction *noBrightness = brightnessMenu->addAction(tr("&0%"));
+ noBrightness->setCheckable(true);
+ QAction *quarterBrightness = brightnessMenu->addAction(tr("&25%"));
+ quarterBrightness->setCheckable(true);
+ QAction *halfBrightness = brightnessMenu->addAction(tr("&50%"));
+ halfBrightness->setCheckable(true);
+ QAction *threeQuartersBrightness = brightnessMenu->addAction(tr("&75%"));
+ threeQuartersBrightness->setCheckable(true);
+ QAction *fullBrightness = brightnessMenu->addAction(tr("&100%"));
+ fullBrightness->setCheckable(true);
+
+ menuMap[noBrightness] = None;
+ menuMap[quarterBrightness] = Quarter;
+ menuMap[halfBrightness] = Half;
+ menuMap[threeQuartersBrightness] = ThreeQuarters;
+ menuMap[fullBrightness] = Full;
+
+ currentBrightness = fullBrightness;
+ currentBrightness->setChecked(true);
+ brightnessMenu->setEnabled(false);
+
+ menuBar()->addMenu(fileMenu);
+ menuBar()->addMenu(brightnessMenu);
+
+ connect(openAction, SIGNAL(triggered()), this, SLOT(chooseFile()));
+ connect(saveAction, SIGNAL(triggered()), this, SLOT(saveImage()));
+ connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
+ connect(brightnessMenu, SIGNAL(triggered(QAction *)), this,
+ SLOT(setBrightness(QAction *)));
+}
+
+/*
+ Constructs a central widget for the window consisting of a two-by-two
+ grid of labels, each of which will contain an image. We restrict the
+ size of the labels to 256 pixels, and ensure that the window cannot
+ be resized.
+*/
+
+QFrame* Viewer::createCentralWidget()
+{
+ QFrame* frame = new QFrame(this);
+ grid = new QGridLayout(frame);
+ grid->setSpacing(8);
+ grid->setMargin(4);
+
+ layout()->setSizeConstraint(QLayout::SetFixedSize);
+
+ QSize labelSize(256, 256);
+
+ finalWidget = new FinalWidget(frame, tr("Final image"), labelSize);
+
+ cyanWidget = new ScreenWidget(frame, Qt::cyan, tr("Cyan"),
+ ScreenWidget::Cyan, labelSize);
+ magentaWidget = new ScreenWidget(frame, Qt::magenta, tr("Magenta"),
+ ScreenWidget::Magenta, labelSize);
+ yellowWidget = new ScreenWidget(frame, Qt::yellow, tr("Yellow"),
+ ScreenWidget::Yellow, labelSize);
+
+ connect(cyanWidget, SIGNAL(imageChanged()), this, SLOT(createImage()));
+ connect(magentaWidget, SIGNAL(imageChanged()), this, SLOT(createImage()));
+ connect(yellowWidget, SIGNAL(imageChanged()), this, SLOT(createImage()));
+
+ grid->addWidget(finalWidget, 0, 0, Qt::AlignTop | Qt::AlignHCenter);
+ grid->addWidget(cyanWidget, 0, 1, Qt::AlignTop | Qt::AlignHCenter);
+ grid->addWidget(magentaWidget, 1, 0, Qt::AlignTop | Qt::AlignHCenter);
+ grid->addWidget(yellowWidget, 1, 1, Qt::AlignTop | Qt::AlignHCenter);
+
+ return frame;
+}
+
+/*
+ Provides a dialog window to allow the user to specify an image file.
+ If a file is selected, the appropriate function is called to process
+ and display it.
+*/
+
+void Viewer::chooseFile()
+{
+ QString imageFile = QFileDialog::getOpenFileName(this,
+ tr("Choose an image file to open"), path, tr("Images (*.*)"));
+
+ if (!imageFile.isEmpty()) {
+ openImageFile(imageFile);
+ path = imageFile;
+ }
+}
+
+/*
+ Changes the value of the brightness according to the entry selected in the
+ Brightness menu. The selected entry is checked, and the previously selected
+ entry is unchecked.
+
+ The color separations are updated to use the new value for the brightness.
+*/
+
+void Viewer::setBrightness(QAction *action)
+{
+ if (!menuMap.contains(action) || scaledImage.isNull())
+ return;
+
+ Brightness amount = menuMap[action];
+
+ switch (amount) {
+ case None:
+ brightness = 0; break;
+ case Quarter:
+ brightness = 64; break;
+ case Half:
+ brightness = 128; break;
+ case ThreeQuarters:
+ brightness = 191; break;
+ case Full:
+ brightness = 255; break;
+ default: return;
+ }
+
+ currentBrightness->setChecked(false);
+ currentBrightness = action;
+ currentBrightness->setChecked(true);
+
+ createImage();
+}
+
+/*
+ Load the image from the file given, and create four pixmaps based
+ on the original image.
+
+ The window caption is set, and the Brightness menu enabled if the image file
+ can be loaded.
+*/
+
+void Viewer::openImageFile(QString &imageFile)
+{
+ QImage originalImage;
+
+ if (originalImage.load(imageFile)) {
+ setWindowTitle(imageFile);
+ //menuBar()->setItemEnabled(brightnessMenuId, true);
+ saveAction->setEnabled(true);
+ brightnessMenu->setEnabled(true);
+
+ /* Note: the ScaleMin value may be different for Qt 4. */
+ scaledImage = originalImage.scaled(256, 256, Qt::KeepAspectRatio);
+
+ cyanWidget->setImage(scaledImage);
+ magentaWidget->setImage(scaledImage);
+ yellowWidget->setImage(scaledImage);
+ createImage();
+ }
+ else
+ (void) QMessageBox::warning(this, tr("Cannot open file"),
+ tr("The selected file could not be opened."),
+ QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton);
+}
+
+/*
+ Creates an image by combining the contents of the three screens
+ to present a page preview.
+
+ The image associated with each screen is separated into cyan,
+ magenta, and yellow components. We add up the values for each
+ component from the three screen images, and subtract the totals
+ from the maximum value for each corresponding primary color.
+*/
+
+void Viewer::createImage()
+{
+ QImage newImage = scaledImage.copy();
+
+ QImage *image1 = cyanWidget->image();
+ QImage *image2 = magentaWidget->image();
+ QImage *image3 = yellowWidget->image();
+ int darkness = 255 - brightness;
+
+ for (int y = 0; y < newImage.height(); ++y) {
+ for (int x = 0; x < newImage.width(); ++x) {
+
+ // Create three screens, using the quantities of the source
+ // CMY components to determine how much of each of the
+ // inks are to be put on each screen.
+ QRgb p1(image1->pixel(x, y));
+ float cyan1 = 255 - qRed(p1);
+ float magenta1 = 255 - qGreen(p1);
+ float yellow1 = 255 - qBlue(p1);
+
+ QRgb p2(image2->pixel(x, y));
+ float cyan2 = 255 - qRed(p2);
+ float magenta2 = 255 - qGreen(p2);
+ float yellow2 = 255 - qBlue(p2);
+
+ QRgb p3(image3->pixel(x, y));
+ float cyan3 = 255 - qRed(p3);
+ float magenta3 = 255 - qGreen(p3);
+ float yellow3 = 255 - qBlue(p3);
+
+ QColor newColor(
+ qMax(255 - int(cyan1+cyan2+cyan3) - darkness, 0),
+ qMax(255 - int(magenta1+magenta2+magenta3) - darkness, 0),
+ qMax(255 - int(yellow1+yellow2+yellow3) - darkness, 0));
+
+ newImage.setPixel(x, y, newColor.rgb());
+ }
+ }
+
+ finalWidget->setPixmap(QPixmap::fromImage(newImage));
+}
+
+/*
+ Provides a dialog window to allow the user to save the image file.
+*/
+
+void Viewer::saveImage()
+{
+ QString imageFile = QFileDialog::getSaveFileName(this,
+ tr("Choose a filename to save the image"), "", tr("Images (*.png)"));
+
+ QFileInfo info(imageFile);
+
+ if (!info.baseName().isEmpty()) {
+ QString newImageFile = QFileInfo(info.absoluteDir(),
+ info.baseName() + ".png").absoluteFilePath();
+
+ if (!finalWidget->pixmap()->save(newImageFile, "PNG"))
+ (void) QMessageBox::warning(this, tr("Cannot save file"),
+ tr("The file could not be saved."),
+ QMessageBox::Cancel, QMessageBox::NoButton,
+ QMessageBox::NoButton);
+ }
+ else
+ (void) QMessageBox::warning(this, tr("Cannot save file"),
+ tr("Please enter a valid filename."),
+ QMessageBox::Cancel, QMessageBox::NoButton,
+ QMessageBox::NoButton);
+}
diff --git a/src/gui/doc/snippets/separations/viewer.h b/src/gui/doc/snippets/separations/viewer.h
new file mode 100644
index 0000000000..c1e3725895
--- /dev/null
+++ b/src/gui/doc/snippets/separations/viewer.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef VIEWER_H
+#define VIEWER_H
+
+#include <QImage>
+#include <QMainWindow>
+#include <QMap>
+
+class QAction;
+class QFrame;
+class QGridLayout;
+class QLabel;
+class QMenu;
+class FinalWidget;
+class ScreenWidget;
+
+class Viewer : public QMainWindow
+{
+ Q_OBJECT
+public:
+ enum Brightness { None, Quarter, Half, ThreeQuarters, Full };
+ Viewer();
+
+public slots:
+ void chooseFile();
+ void setBrightness(QAction *action);
+ void createImage();
+ void saveImage();
+
+private:
+ void createMenus();
+ QFrame *createCentralWidget();
+ void openImageFile(QString &filePath);
+
+ FinalWidget *finalWidget;
+ int brightness;
+ QAction *currentBrightness;
+ QAction *saveAction;
+ QGridLayout *grid;
+ QImage scaledImage;
+ QMap <QAction*,Brightness> menuMap;
+ QMenu *brightnessMenu;
+ QMenu *fileMenu;
+ QString path;
+ ScreenWidget *cyanWidget;
+ ScreenWidget *magentaWidget;
+ ScreenWidget *yellowWidget;
+};
+
+#endif