From ff3b658c771d8fbc17109ff5e0096ad1fe62f2e4 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Tue, 24 Sep 2013 14:26:54 +0200 Subject: Doc: Create documentation structure for Qt Mac Extras MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Create documentation structure for the module - Module qdocconf - Documentation pages for module index, namespace/classes, examples (not much content yet) Other doc-related changes - Enable running 'make docs' on all platforms - Move examples under examples/macextras for a clean installing to QT_INSTALL_EXAMPLES - Ensure documented classes use correct \inmodule and \since commands - Add \namespace QtMac - Other minor fixes Change-Id: I1376d68fcd7ab324a5d3355f1d15914092900e5b Reviewed-by: Morten Johan Sørvig --- examples/embeddedqwindow/embeddedqwindow.pro | 9 - examples/embeddedqwindow/main.mm | 115 ------------ examples/embeddedqwindow/window.cpp | 209 --------------------- examples/embeddedqwindow/window.h | 74 -------- examples/examples.pro | 5 +- .../macextras/embeddedqwindow/embeddedqwindow.pro | 9 + examples/macextras/embeddedqwindow/main.mm | 115 ++++++++++++ examples/macextras/embeddedqwindow/window.cpp | 209 +++++++++++++++++++++ examples/macextras/embeddedqwindow/window.h | 74 ++++++++ examples/macextras/macextras.pro | 5 + examples/macextras/macfunctions/macfunctions.pro | 11 ++ examples/macextras/macfunctions/macfunctions.qrc | 5 + examples/macextras/macfunctions/main.cpp | 62 ++++++ examples/macextras/macfunctions/qtlogo.png | Bin 0 -> 1478 bytes .../macpasteboardmime/macpasteboardmime.pro | 6 + examples/macextras/macpasteboardmime/main.cpp | 155 +++++++++++++++ examples/macfunctions/macfunctions.pro | 11 -- examples/macfunctions/macfunctions.qrc | 5 - examples/macfunctions/main.cpp | 62 ------ examples/macfunctions/qtlogo.png | Bin 1478 -> 0 bytes examples/macpasteboardmime/macpasteboardmime.pro | 6 - examples/macpasteboardmime/main.cpp | 155 --------------- src/macextras/doc/qtmacextras.qdocconf | 42 +++++ .../doc/snippets/code/use-qtmacextras.cpp | 43 +++++ .../doc/snippets/code/use-qtmacextras.pro | 3 + src/macextras/doc/src/qtmacextras-examples.qdoc | 52 +++++ src/macextras/doc/src/qtmacextras-index.qdoc | 71 +++++++ src/macextras/doc/src/qtmacextras-module-cpp.qdoc | 51 +++++ src/macextras/macextras.pro | 1 + src/macextras/qmacfunctions.mm | 7 + src/macextras/qmacpasteboardmime.mm | 35 ++-- src/src.pro | 11 +- 32 files changed, 955 insertions(+), 663 deletions(-) delete mode 100644 examples/embeddedqwindow/embeddedqwindow.pro delete mode 100644 examples/embeddedqwindow/main.mm delete mode 100644 examples/embeddedqwindow/window.cpp delete mode 100644 examples/embeddedqwindow/window.h create mode 100644 examples/macextras/embeddedqwindow/embeddedqwindow.pro create mode 100644 examples/macextras/embeddedqwindow/main.mm create mode 100644 examples/macextras/embeddedqwindow/window.cpp create mode 100644 examples/macextras/embeddedqwindow/window.h create mode 100644 examples/macextras/macextras.pro create mode 100644 examples/macextras/macfunctions/macfunctions.pro create mode 100644 examples/macextras/macfunctions/macfunctions.qrc create mode 100644 examples/macextras/macfunctions/main.cpp create mode 100644 examples/macextras/macfunctions/qtlogo.png create mode 100644 examples/macextras/macpasteboardmime/macpasteboardmime.pro create mode 100644 examples/macextras/macpasteboardmime/main.cpp delete mode 100644 examples/macfunctions/macfunctions.pro delete mode 100644 examples/macfunctions/macfunctions.qrc delete mode 100644 examples/macfunctions/main.cpp delete mode 100644 examples/macfunctions/qtlogo.png delete mode 100644 examples/macpasteboardmime/macpasteboardmime.pro delete mode 100644 examples/macpasteboardmime/main.cpp create mode 100644 src/macextras/doc/qtmacextras.qdocconf create mode 100644 src/macextras/doc/snippets/code/use-qtmacextras.cpp create mode 100644 src/macextras/doc/snippets/code/use-qtmacextras.pro create mode 100644 src/macextras/doc/src/qtmacextras-examples.qdoc create mode 100644 src/macextras/doc/src/qtmacextras-index.qdoc create mode 100644 src/macextras/doc/src/qtmacextras-module-cpp.qdoc diff --git a/examples/embeddedqwindow/embeddedqwindow.pro b/examples/embeddedqwindow/embeddedqwindow.pro deleted file mode 100644 index 022a614..0000000 --- a/examples/embeddedqwindow/embeddedqwindow.pro +++ /dev/null @@ -1,9 +0,0 @@ -TEMPLATE = app - -OBJECTIVE_SOURCES += main.mm -HEADERS += window.h -SOURCES += window.cpp -LIBS += -framework Cocoa - -QT += gui widgets macextras -QT += widgets-private gui-private core-private diff --git a/examples/embeddedqwindow/main.mm b/examples/embeddedqwindow/main.mm deleted file mode 100644 index f24533b..0000000 --- a/examples/embeddedqwindow/main.mm +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include "window.h" - -#include -#include - - -NSView *getEmbeddableView(QWindow *qtWindow) -{ - // Make sure the platform window is created - qtWindow->create(); - - QPlatformNativeInterface *platformNativeInterface = QGuiApplication::platformNativeInterface(); - - // Inform the window that it's a "guest" of a non-QWindow - typedef void (*SetEmbeddedInForeignViewFunction)(QPlatformWindow *window, bool embedded); - reinterpret_cast(platformNativeInterface-> - nativeResourceFunctionForIntegration("setEmbeddedInForeignView"))(qtWindow->handle(), true); - - // Get the Qt content NSView for the QWindow from the Qt platform plugin - NSView *qtView = (NSView *)platformNativeInterface->nativeResourceForWindow("nsview", qtWindow); - return qtView; // qtView is ready for use. -} - -@interface WindowCreator : NSObject {} -- (void)createWindow; -@end - -@implementation WindowCreator -- (void)createWindow { - - // Create the NSWindow - NSRect frame = NSMakeRect(500, 500, 500, 500); - NSWindow* window = [[NSWindow alloc] initWithContentRect:frame - styleMask:NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask - backing:NSBackingStoreBuffered - defer:NO]; - - [window setTitle:@"NSWindow"]; - [window setBackgroundColor:[NSColor blueColor]]; // if you see blue something is wrong - - // Create the QWindow and embed its view. - Window *qtWindow = new Window(); // ### who owns this window? - NSView *qtView = getEmbeddableView(qtWindow); - [window setContentView:qtView]; - - // Show the NSWindow - [window makeKeyAndOrderFront:NSApp]; -} -@end - -int main(int argc, char *argv[]) -{ - QGuiApplication app(argc, argv); - - // Start Cocoa. Create NSApplicaiton. - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - [NSApplication sharedApplication]; - - // Schedule call to create the UI using a timer. - WindowCreator *windowCreator= [WindowCreator alloc]; - [NSTimer scheduledTimerWithTimeInterval:0 target:windowCreator selector:@selector(createWindow) userInfo:nil repeats:NO]; - - // Starte the Cocoa event loop. - [(NSApplication *)NSApp run]; - [NSApp release]; - [pool release]; - exit(0); - return 0; -} - - - diff --git a/examples/embeddedqwindow/window.cpp b/examples/embeddedqwindow/window.cpp deleted file mode 100644 index 1868591..0000000 --- a/examples/embeddedqwindow/window.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "window.h" - -#include - -#include -#include -#include - -static int colorIndexId = 0; - -QColor colorTable[] = -{ - QColor("#f09f8f"), - QColor("#a2bff2"), - QColor("#c0ef8f") -}; - -Window::Window(QScreen *screen) - : QWindow(screen) - , m_backgroundColorIndex(colorIndexId++) - , m_backingStore(0) -{ - initialize(); -} - -Window::Window(QWindow *parent) - : QWindow(parent) - , m_backgroundColorIndex(colorIndexId++) - , m_backingStore(0) -{ - initialize(); -} - -void Window::initialize() -{ - if (parent()) - setGeometry(QRect(160, 120, 320, 240)); - else { - setGeometry(QRect(10, 10, 640, 480)); - - setSizeIncrement(QSize(10, 10)); - setBaseSize(QSize(640, 480)); - setMinimumSize(QSize(240, 160)); - setMaximumSize(QSize(800, 600)); - } - - setFlags(flags() | Qt::SubWindow); // Don't create a toplevel window. - - create(); - m_backingStore = new QBackingStore(this); - - m_image = QImage(geometry().size(), QImage::Format_RGB32); - m_image.fill(colorTable[m_backgroundColorIndex % (sizeof(colorTable) / sizeof(colorTable[0]))].rgba()); - - m_lastPos = QPoint(-1, -1); - m_renderTimer = 0; -} - -void Window::mousePressEvent(QMouseEvent *event) -{ - m_lastPos = event->pos(); -} - -void Window::mouseMoveEvent(QMouseEvent *event) -{ - if (m_lastPos != QPoint(-1, -1)) { - QPainter p(&m_image); - p.setRenderHint(QPainter::Antialiasing); - p.drawLine(m_lastPos, event->pos()); - m_lastPos = event->pos(); - } - - scheduleRender(); -} - -void Window::mouseReleaseEvent(QMouseEvent *event) -{ - if (m_lastPos != QPoint(-1, -1)) { - QPainter p(&m_image); - p.setRenderHint(QPainter::Antialiasing); - p.drawLine(m_lastPos, event->pos()); - m_lastPos = QPoint(-1, -1); - } - - scheduleRender(); -} - -void Window::exposeEvent(QExposeEvent *) -{ - scheduleRender(); -} - -void Window::resizeEvent(QResizeEvent *) -{ - QImage old = m_image; - - //qDebug() << "Window::resizeEvent" << width << height; - - int width = qMax(geometry().width(), old.width()); - int height = qMax(geometry().height(), old.height()); - - if (width > old.width() || height > old.height()) { - m_image = QImage(width, height, QImage::Format_RGB32); - m_image.fill(colorTable[(m_backgroundColorIndex) % (sizeof(colorTable) / sizeof(colorTable[0]))].rgba()); - - QPainter p(&m_image); - p.drawImage(0, 0, old); - } - - render(); -} - -void Window::keyPressEvent(QKeyEvent *event) -{ - switch (event->key()) { - case Qt::Key_Backspace: - m_text.chop(1); - break; - case Qt::Key_Enter: - case Qt::Key_Return: - m_text.append('\n'); - break; - default: - m_text.append(event->text()); - break; - } - scheduleRender(); -} - -void Window::scheduleRender() -{ - if (!m_renderTimer) - m_renderTimer = startTimer(1); -} - -void Window::timerEvent(QTimerEvent *) -{ - render(); - killTimer(m_renderTimer); - m_renderTimer = 0; -} - -void Window::render() -{ - if (!m_backingStore) - return; - QRect rect(QPoint(), geometry().size()); - - m_backingStore->resize(rect.size()); - - m_backingStore->beginPaint(rect); - - QPaintDevice *device = m_backingStore->paintDevice(); - - QPainter p(device); - p.drawImage(0, 0, m_image); - - QFont font; - font.setPixelSize(32); - - p.setFont(font); - p.drawText(rect, 0, m_text); - - m_backingStore->endPaint(); - m_backingStore->flush(rect); -} - - diff --git a/examples/embeddedqwindow/window.h b/examples/embeddedqwindow/window.h deleted file mode 100644 index cdd6ebd..0000000 --- a/examples/embeddedqwindow/window.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -class Window : public QWindow -{ -public: - Window(QWindow *parent = 0); - Window(QScreen *screen); - -protected: - void mousePressEvent(QMouseEvent *); - void mouseMoveEvent(QMouseEvent *); - void mouseReleaseEvent(QMouseEvent *); - - void keyPressEvent(QKeyEvent *); - - void exposeEvent(QExposeEvent *); - void resizeEvent(QResizeEvent *); - - void timerEvent(QTimerEvent *); - -private: - void render(); - void scheduleRender(); - void initialize(); - - QString m_text; - QImage m_image; - QPoint m_lastPos; - int m_backgroundColorIndex; - QBackingStore *m_backingStore; - int m_renderTimer; -}; diff --git a/examples/examples.pro b/examples/examples.pro index 8fe1d13..f23b00b 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -1,5 +1,2 @@ TEMPLATE = subdirs - -mac:SUBDIRS = macfunctions -mac:!ios:SUBDIRS += embeddedqwindow \ - macpasteboardmime +mac:SUBDIRS = macextras diff --git a/examples/macextras/embeddedqwindow/embeddedqwindow.pro b/examples/macextras/embeddedqwindow/embeddedqwindow.pro new file mode 100644 index 0000000..022a614 --- /dev/null +++ b/examples/macextras/embeddedqwindow/embeddedqwindow.pro @@ -0,0 +1,9 @@ +TEMPLATE = app + +OBJECTIVE_SOURCES += main.mm +HEADERS += window.h +SOURCES += window.cpp +LIBS += -framework Cocoa + +QT += gui widgets macextras +QT += widgets-private gui-private core-private diff --git a/examples/macextras/embeddedqwindow/main.mm b/examples/macextras/embeddedqwindow/main.mm new file mode 100644 index 0000000..f24533b --- /dev/null +++ b/examples/macextras/embeddedqwindow/main.mm @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "window.h" + +#include +#include + + +NSView *getEmbeddableView(QWindow *qtWindow) +{ + // Make sure the platform window is created + qtWindow->create(); + + QPlatformNativeInterface *platformNativeInterface = QGuiApplication::platformNativeInterface(); + + // Inform the window that it's a "guest" of a non-QWindow + typedef void (*SetEmbeddedInForeignViewFunction)(QPlatformWindow *window, bool embedded); + reinterpret_cast(platformNativeInterface-> + nativeResourceFunctionForIntegration("setEmbeddedInForeignView"))(qtWindow->handle(), true); + + // Get the Qt content NSView for the QWindow from the Qt platform plugin + NSView *qtView = (NSView *)platformNativeInterface->nativeResourceForWindow("nsview", qtWindow); + return qtView; // qtView is ready for use. +} + +@interface WindowCreator : NSObject {} +- (void)createWindow; +@end + +@implementation WindowCreator +- (void)createWindow { + + // Create the NSWindow + NSRect frame = NSMakeRect(500, 500, 500, 500); + NSWindow* window = [[NSWindow alloc] initWithContentRect:frame + styleMask:NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask + backing:NSBackingStoreBuffered + defer:NO]; + + [window setTitle:@"NSWindow"]; + [window setBackgroundColor:[NSColor blueColor]]; // if you see blue something is wrong + + // Create the QWindow and embed its view. + Window *qtWindow = new Window(); // ### who owns this window? + NSView *qtView = getEmbeddableView(qtWindow); + [window setContentView:qtView]; + + // Show the NSWindow + [window makeKeyAndOrderFront:NSApp]; +} +@end + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + // Start Cocoa. Create NSApplicaiton. + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + [NSApplication sharedApplication]; + + // Schedule call to create the UI using a timer. + WindowCreator *windowCreator= [WindowCreator alloc]; + [NSTimer scheduledTimerWithTimeInterval:0 target:windowCreator selector:@selector(createWindow) userInfo:nil repeats:NO]; + + // Starte the Cocoa event loop. + [(NSApplication *)NSApp run]; + [NSApp release]; + [pool release]; + exit(0); + return 0; +} + + + diff --git a/examples/macextras/embeddedqwindow/window.cpp b/examples/macextras/embeddedqwindow/window.cpp new file mode 100644 index 0000000..1868591 --- /dev/null +++ b/examples/macextras/embeddedqwindow/window.cpp @@ -0,0 +1,209 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "window.h" + +#include + +#include +#include +#include + +static int colorIndexId = 0; + +QColor colorTable[] = +{ + QColor("#f09f8f"), + QColor("#a2bff2"), + QColor("#c0ef8f") +}; + +Window::Window(QScreen *screen) + : QWindow(screen) + , m_backgroundColorIndex(colorIndexId++) + , m_backingStore(0) +{ + initialize(); +} + +Window::Window(QWindow *parent) + : QWindow(parent) + , m_backgroundColorIndex(colorIndexId++) + , m_backingStore(0) +{ + initialize(); +} + +void Window::initialize() +{ + if (parent()) + setGeometry(QRect(160, 120, 320, 240)); + else { + setGeometry(QRect(10, 10, 640, 480)); + + setSizeIncrement(QSize(10, 10)); + setBaseSize(QSize(640, 480)); + setMinimumSize(QSize(240, 160)); + setMaximumSize(QSize(800, 600)); + } + + setFlags(flags() | Qt::SubWindow); // Don't create a toplevel window. + + create(); + m_backingStore = new QBackingStore(this); + + m_image = QImage(geometry().size(), QImage::Format_RGB32); + m_image.fill(colorTable[m_backgroundColorIndex % (sizeof(colorTable) / sizeof(colorTable[0]))].rgba()); + + m_lastPos = QPoint(-1, -1); + m_renderTimer = 0; +} + +void Window::mousePressEvent(QMouseEvent *event) +{ + m_lastPos = event->pos(); +} + +void Window::mouseMoveEvent(QMouseEvent *event) +{ + if (m_lastPos != QPoint(-1, -1)) { + QPainter p(&m_image); + p.setRenderHint(QPainter::Antialiasing); + p.drawLine(m_lastPos, event->pos()); + m_lastPos = event->pos(); + } + + scheduleRender(); +} + +void Window::mouseReleaseEvent(QMouseEvent *event) +{ + if (m_lastPos != QPoint(-1, -1)) { + QPainter p(&m_image); + p.setRenderHint(QPainter::Antialiasing); + p.drawLine(m_lastPos, event->pos()); + m_lastPos = QPoint(-1, -1); + } + + scheduleRender(); +} + +void Window::exposeEvent(QExposeEvent *) +{ + scheduleRender(); +} + +void Window::resizeEvent(QResizeEvent *) +{ + QImage old = m_image; + + //qDebug() << "Window::resizeEvent" << width << height; + + int width = qMax(geometry().width(), old.width()); + int height = qMax(geometry().height(), old.height()); + + if (width > old.width() || height > old.height()) { + m_image = QImage(width, height, QImage::Format_RGB32); + m_image.fill(colorTable[(m_backgroundColorIndex) % (sizeof(colorTable) / sizeof(colorTable[0]))].rgba()); + + QPainter p(&m_image); + p.drawImage(0, 0, old); + } + + render(); +} + +void Window::keyPressEvent(QKeyEvent *event) +{ + switch (event->key()) { + case Qt::Key_Backspace: + m_text.chop(1); + break; + case Qt::Key_Enter: + case Qt::Key_Return: + m_text.append('\n'); + break; + default: + m_text.append(event->text()); + break; + } + scheduleRender(); +} + +void Window::scheduleRender() +{ + if (!m_renderTimer) + m_renderTimer = startTimer(1); +} + +void Window::timerEvent(QTimerEvent *) +{ + render(); + killTimer(m_renderTimer); + m_renderTimer = 0; +} + +void Window::render() +{ + if (!m_backingStore) + return; + QRect rect(QPoint(), geometry().size()); + + m_backingStore->resize(rect.size()); + + m_backingStore->beginPaint(rect); + + QPaintDevice *device = m_backingStore->paintDevice(); + + QPainter p(device); + p.drawImage(0, 0, m_image); + + QFont font; + font.setPixelSize(32); + + p.setFont(font); + p.drawText(rect, 0, m_text); + + m_backingStore->endPaint(); + m_backingStore->flush(rect); +} + + diff --git a/examples/macextras/embeddedqwindow/window.h b/examples/macextras/embeddedqwindow/window.h new file mode 100644 index 0000000..cdd6ebd --- /dev/null +++ b/examples/macextras/embeddedqwindow/window.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +class Window : public QWindow +{ +public: + Window(QWindow *parent = 0); + Window(QScreen *screen); + +protected: + void mousePressEvent(QMouseEvent *); + void mouseMoveEvent(QMouseEvent *); + void mouseReleaseEvent(QMouseEvent *); + + void keyPressEvent(QKeyEvent *); + + void exposeEvent(QExposeEvent *); + void resizeEvent(QResizeEvent *); + + void timerEvent(QTimerEvent *); + +private: + void render(); + void scheduleRender(); + void initialize(); + + QString m_text; + QImage m_image; + QPoint m_lastPos; + int m_backgroundColorIndex; + QBackingStore *m_backingStore; + int m_renderTimer; +}; diff --git a/examples/macextras/macextras.pro b/examples/macextras/macextras.pro new file mode 100644 index 0000000..8fe1d13 --- /dev/null +++ b/examples/macextras/macextras.pro @@ -0,0 +1,5 @@ +TEMPLATE = subdirs + +mac:SUBDIRS = macfunctions +mac:!ios:SUBDIRS += embeddedqwindow \ + macpasteboardmime diff --git a/examples/macextras/macfunctions/macfunctions.pro b/examples/macextras/macfunctions/macfunctions.pro new file mode 100644 index 0000000..8d11880 --- /dev/null +++ b/examples/macextras/macfunctions/macfunctions.pro @@ -0,0 +1,11 @@ +TEMPLATE = app +TARGET = macfunctions +DEPENDPATH += . +INCLUDEPATH += . +QT += widgets macextras + +# Input +SOURCES += main.cpp + +RESOURCES += \ + macfunctions.qrc diff --git a/examples/macextras/macfunctions/macfunctions.qrc b/examples/macextras/macfunctions/macfunctions.qrc new file mode 100644 index 0000000..04a9419 --- /dev/null +++ b/examples/macextras/macfunctions/macfunctions.qrc @@ -0,0 +1,5 @@ + + + qtlogo.png + + diff --git a/examples/macextras/macfunctions/main.cpp b/examples/macextras/macfunctions/main.cpp new file mode 100644 index 0000000..a1563ba --- /dev/null +++ b/examples/macextras/macfunctions/main.cpp @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtMacExtras module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include +#include +#include +#include +#include + +int main(int argc, char **argv) +{ + QGuiApplication app(argc, argv); + + QWidget widget; + widget.show(); + + // Pixmap <-> CGImage conversion + QPixmap pixmap(":qtlogo.png"); + CGImageRef cgImage = QtMac::toCGImageRef(pixmap); + QPixmap pixmap2 = QtMac::fromCGImageRef(cgImage); + + return app.exec(); +} diff --git a/examples/macextras/macfunctions/qtlogo.png b/examples/macextras/macfunctions/qtlogo.png new file mode 100644 index 0000000..d75936b Binary files /dev/null and b/examples/macextras/macfunctions/qtlogo.png differ diff --git a/examples/macextras/macpasteboardmime/macpasteboardmime.pro b/examples/macextras/macpasteboardmime/macpasteboardmime.pro new file mode 100644 index 0000000..3ce4cd4 --- /dev/null +++ b/examples/macextras/macpasteboardmime/macpasteboardmime.pro @@ -0,0 +1,6 @@ +QT += macextras widgets + +SOURCES += main.cpp + + + diff --git a/examples/macextras/macpasteboardmime/main.cpp b/examples/macextras/macpasteboardmime/main.cpp new file mode 100644 index 0000000..4d3063a --- /dev/null +++ b/examples/macextras/macpasteboardmime/main.cpp @@ -0,0 +1,155 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtMacExtras module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include + +#include + +class VCardMime : public QMacPasteboardMime +{ +public: + VCardMime() : QMacPasteboardMime(MIME_ALL) + { } + + QString convertorName() + { + return QString("VCardMime"); + } + + bool canConvert(const QString &mime, QString flav) + { + return mimeFor(flav) == mime; + } + + QString mimeFor(QString flav) + { + if (flav == QString("public.vcard")) + return QString("application/x-mycompany-VCard"); + return QString(); + } + + QString flavorFor(const QString &mime) + { + if (mime == QString("application/x-mycompany-VCard")) + return QString("public.vcard"); + return QString(); + } + + QVariant convertToMime(const QString &mime, QList data, QString flav) + { + Q_UNUSED(mime); + Q_UNUSED(flav); + + QByteArray all; + foreach (QByteArray i, data) { + all += i; + } + return QVariant(all); + } + + QList convertFromMime(const QString &mime, QVariant data, QString flav) + { + Q_UNUSED(mime); + Q_UNUSED(data); + Q_UNUSED(flav); + // Todo: implement! + return QList(); + } + +}; + +class TestWidget : public QWidget +{ +public: + TestWidget() : QWidget(0) + { + vcardMime = new VCardMime(); + setAcceptDrops(true); + } + + ~TestWidget() + { + delete vcardMime; + } + + void dragEnterEvent(QDragEnterEvent *e) + { + e->accept(); + + } + + virtual void dropEvent(QDropEvent *e) + { + e->accept(); + contentsDropEvent(e); + } + + void contentsDropEvent(QDropEvent* e) + { + if ( e->mimeData()->hasFormat( "application/x-mycompany-VCard" ) ) + { + QString s = QString( e->mimeData()->data( "application/x-mycompany-VCard" ) ); + + // s now contains text of vcard + qDebug() << "got vcard" << s.count(); + + e->acceptProposedAction(); + } + } +private: + VCardMime *vcardMime; +}; + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + qRegisterDraggedTypes(QStringList() << QLatin1String("public.vcard")); + + TestWidget wid1; + wid1.show(); + + return app.exec(); +} diff --git a/examples/macfunctions/macfunctions.pro b/examples/macfunctions/macfunctions.pro deleted file mode 100644 index 8d11880..0000000 --- a/examples/macfunctions/macfunctions.pro +++ /dev/null @@ -1,11 +0,0 @@ -TEMPLATE = app -TARGET = macfunctions -DEPENDPATH += . -INCLUDEPATH += . -QT += widgets macextras - -# Input -SOURCES += main.cpp - -RESOURCES += \ - macfunctions.qrc diff --git a/examples/macfunctions/macfunctions.qrc b/examples/macfunctions/macfunctions.qrc deleted file mode 100644 index 04a9419..0000000 --- a/examples/macfunctions/macfunctions.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - qtlogo.png - - diff --git a/examples/macfunctions/main.cpp b/examples/macfunctions/main.cpp deleted file mode 100644 index a1563ba..0000000 --- a/examples/macfunctions/main.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtMacExtras module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include -#include -#include -#include -#include - -int main(int argc, char **argv) -{ - QGuiApplication app(argc, argv); - - QWidget widget; - widget.show(); - - // Pixmap <-> CGImage conversion - QPixmap pixmap(":qtlogo.png"); - CGImageRef cgImage = QtMac::toCGImageRef(pixmap); - QPixmap pixmap2 = QtMac::fromCGImageRef(cgImage); - - return app.exec(); -} diff --git a/examples/macfunctions/qtlogo.png b/examples/macfunctions/qtlogo.png deleted file mode 100644 index d75936b..0000000 Binary files a/examples/macfunctions/qtlogo.png and /dev/null differ diff --git a/examples/macpasteboardmime/macpasteboardmime.pro b/examples/macpasteboardmime/macpasteboardmime.pro deleted file mode 100644 index 3ce4cd4..0000000 --- a/examples/macpasteboardmime/macpasteboardmime.pro +++ /dev/null @@ -1,6 +0,0 @@ -QT += macextras widgets - -SOURCES += main.cpp - - - diff --git a/examples/macpasteboardmime/main.cpp b/examples/macpasteboardmime/main.cpp deleted file mode 100644 index 4d3063a..0000000 --- a/examples/macpasteboardmime/main.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtMacExtras module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include - -#include - -class VCardMime : public QMacPasteboardMime -{ -public: - VCardMime() : QMacPasteboardMime(MIME_ALL) - { } - - QString convertorName() - { - return QString("VCardMime"); - } - - bool canConvert(const QString &mime, QString flav) - { - return mimeFor(flav) == mime; - } - - QString mimeFor(QString flav) - { - if (flav == QString("public.vcard")) - return QString("application/x-mycompany-VCard"); - return QString(); - } - - QString flavorFor(const QString &mime) - { - if (mime == QString("application/x-mycompany-VCard")) - return QString("public.vcard"); - return QString(); - } - - QVariant convertToMime(const QString &mime, QList data, QString flav) - { - Q_UNUSED(mime); - Q_UNUSED(flav); - - QByteArray all; - foreach (QByteArray i, data) { - all += i; - } - return QVariant(all); - } - - QList convertFromMime(const QString &mime, QVariant data, QString flav) - { - Q_UNUSED(mime); - Q_UNUSED(data); - Q_UNUSED(flav); - // Todo: implement! - return QList(); - } - -}; - -class TestWidget : public QWidget -{ -public: - TestWidget() : QWidget(0) - { - vcardMime = new VCardMime(); - setAcceptDrops(true); - } - - ~TestWidget() - { - delete vcardMime; - } - - void dragEnterEvent(QDragEnterEvent *e) - { - e->accept(); - - } - - virtual void dropEvent(QDropEvent *e) - { - e->accept(); - contentsDropEvent(e); - } - - void contentsDropEvent(QDropEvent* e) - { - if ( e->mimeData()->hasFormat( "application/x-mycompany-VCard" ) ) - { - QString s = QString( e->mimeData()->data( "application/x-mycompany-VCard" ) ); - - // s now contains text of vcard - qDebug() << "got vcard" << s.count(); - - e->acceptProposedAction(); - } - } -private: - VCardMime *vcardMime; -}; - -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - - qRegisterDraggedTypes(QStringList() << QLatin1String("public.vcard")); - - TestWidget wid1; - wid1.show(); - - return app.exec(); -} diff --git a/src/macextras/doc/qtmacextras.qdocconf b/src/macextras/doc/qtmacextras.qdocconf new file mode 100644 index 0000000..1fc3c4d --- /dev/null +++ b/src/macextras/doc/qtmacextras.qdocconf @@ -0,0 +1,42 @@ +include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) + +project = QtMacExtras +description = Qt Mac Extras Reference Documentation +url = http://qt-project.org/doc/qt-$QT_VER/qtmacextras +version = $QT_VERSION + +exampledirs += ../../../examples/macextras \ + snippets + +examplesinstallpath = macextras + +headerdirs = .. +sourcedirs = .. +imagedirs += images + +Cpp.ignoretokens += Q_MACEXTRAS_EXPORT + +depends += qtcore qtgui qtwidgets qtdoc + +qhp.projects = QtMacExtras + +qhp.QtMacExtras.file = qtmacextras.qhp + +qhp.QtMacExtras.namespace = org.qt-project.qtmacextras.$QT_VERSION_TAG + +qhp.QtMacExtras.indexTitle = Qt Mac Extras +qhp.QtMacExtras.indexRoot = + +qhp.QtMacExtras.filterAttributes = qtmacextras $QT_VERSION qtrefdoc +qhp.QtMacExtras.customFilters.Qt.name = QtMacExtras $QT_VERSION +qhp.QtMacExtras.customFilters.Qt.filterAttributes = qtmacextras $QT_VERSION + +qhp.QtMacExtras.virtualFolder = qtmacextras +qhp.QtMacExtras.subprojects = classes examples +qhp.QtMacExtras.subprojects.classes.title = C++ Classes and Namespaces +qhp.QtMacExtras.subprojects.classes.indexTitle = Qt Mac Extras C++ Classes +qhp.QtMacExtras.subprojects.classes.selectors = class function namespace fake:headerfile +qhp.QtMacExtras.subprojects.classes.sortPages = true +qhp.QtMacExtras.subprojects.examples.title = Examples +qhp.QtMacExtras.subprojects.examples.indexTitle = Qt Mac Extras Examples +qhp.QtMacExtras.subprojects.examples.selectors = fake:example diff --git a/src/macextras/doc/snippets/code/use-qtmacextras.cpp b/src/macextras/doc/snippets/code/use-qtmacextras.cpp new file mode 100644 index 0000000..b138e0c --- /dev/null +++ b/src/macextras/doc/snippets/code/use-qtmacextras.cpp @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2013 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] +#include +//! [include] diff --git a/src/macextras/doc/snippets/code/use-qtmacextras.pro b/src/macextras/doc/snippets/code/use-qtmacextras.pro new file mode 100644 index 0000000..b0496bb --- /dev/null +++ b/src/macextras/doc/snippets/code/use-qtmacextras.pro @@ -0,0 +1,3 @@ +#! [link] +QT += macextras +#! [link] diff --git a/src/macextras/doc/src/qtmacextras-examples.qdoc b/src/macextras/doc/src/qtmacextras-examples.qdoc new file mode 100644 index 0000000..4076278 --- /dev/null +++ b/src/macextras/doc/src/qtmacextras-examples.qdoc @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2013 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$ +** +****************************************************************************/ + +/*! + +\group examples-qtmacextras +\title Qt Mac Extras Examples +\brief Examples for the Qt Mac Extras module. +\ingroup all-examples + +Here is a list of example applications demonstrating the functionality +provided by the \l{Qt Mac Extras} module. + +\note These examples work only on \l{Qt for Mac OS X}{Mac OS X} operating system. +*/ diff --git a/src/macextras/doc/src/qtmacextras-index.qdoc b/src/macextras/doc/src/qtmacextras-index.qdoc new file mode 100644 index 0000000..f0af333 --- /dev/null +++ b/src/macextras/doc/src/qtmacextras-index.qdoc @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2013 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$ +** +****************************************************************************/ + +/*! + \page qtmacextras-index.html + \title Qt Mac Extras + \brief Provides functionality specific to Mac OS X and iOS operating systems. + + Qt Mac Extras provide classes and functions that enable you to use + miscellaneous functionality specific to Mac OS X and iOS operating systems. + + \section1 Getting Started + + To include the definitions of the module's classes and functions, use the + following include statement: + + \snippet code/use-qtmacextras.cpp include + + To link against the module, add this line to your qmake .pro file: + + \snippet code/use-qtmacextras.pro link + + \section1 Examples + + \list + \li \l {Qt Mac Extras Examples} + \endlist + + \section1 API Reference + + \list + \li \l {Qt Mac Extras C++ Classes}{C++ Classes and Namespaces} + \endlist +*/ diff --git a/src/macextras/doc/src/qtmacextras-module-cpp.qdoc b/src/macextras/doc/src/qtmacextras-module-cpp.qdoc new file mode 100644 index 0000000..f636fdf --- /dev/null +++ b/src/macextras/doc/src/qtmacextras-module-cpp.qdoc @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2013 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$ +** +****************************************************************************/ + +/*! + \module QtMacExtras + \title Qt Mac Extras C++ Classes + \brief Provides classes and functions specific to Mac OS X and iOS operating systems. + + \ingroup modules + \ingroup technology-apis + \qtvariable macextras + + \sa QMacCocoaViewContainer, QMacNativeWidget +*/ diff --git a/src/macextras/macextras.pro b/src/macextras/macextras.pro index 12f00cd..acce83c 100644 --- a/src/macextras/macextras.pro +++ b/src/macextras/macextras.pro @@ -4,3 +4,4 @@ load(qt_build_config) QT_PRIVATE += gui-private core-private TARGET = QtMacExtras load(qt_module) +QMAKE_DOCS = $$PWD/doc/qtmacextras.qdocconf diff --git a/src/macextras/qmacfunctions.mm b/src/macextras/qmacfunctions.mm index d843981..3484bbc 100644 --- a/src/macextras/qmacfunctions.mm +++ b/src/macextras/qmacfunctions.mm @@ -54,6 +54,13 @@ QT_BEGIN_NAMESPACE +/*! + \namespace QtMac + \inmodule QtMacExtras + \since 5.2 + \brief The QtMac namespace contains miscellaneous functionality specific to Mac OS X and iOS operating systems. + \inheaderfile QMacFunctions + */ namespace QtMac { diff --git a/src/macextras/qmacpasteboardmime.mm b/src/macextras/qmacpasteboardmime.mm index ec8fa7e..ee51bfb 100644 --- a/src/macextras/qmacpasteboardmime.mm +++ b/src/macextras/qmacpasteboardmime.mm @@ -73,6 +73,8 @@ void qRegisterDraggedTypes(const QStringList &types) /*! \class QMacPasteboardMime + \inmodule QtMacExtras + \since 5.2 \brief The QMacPasteboardMime class converts between a MIME type and a \l{http://developer.apple.com/macosx/uniformtypeidentifiers.html}{Uniform Type Identifier (UTI)} format. @@ -89,17 +91,28 @@ void qRegisterDraggedTypes(const QStringList &types) A subclass of QMacPasteboardMime will automatically be registered, and active, upon instantiation. Qt has predefined support for the following UTIs: - \list - \i public.utf8-plain-text - converts to "text/plain" - \i public.utf16-plain-text - converts to "text/plain" - \i public.html - converts to "text/html" - \i public.url - converts to "text/uri-list" - \i public.file-url - converts to "text/uri-list" - \i public.tiff - converts to "application/x-qt-image" - \i public.vcard - converts to "text/plain" - \i com.apple.traditional-mac-plain-text - converts to "text/plain" - \i com.apple.pict - converts to "application/x-qt-image" - \endlist + \table + \header \li UTI + \li Converts to + \row \li \c public.utf8-plain-text + \li \c text/plain + \row \li \c public.utf16-plain-text + \li \c text/plain + \row \li \c public.html + \li \c text/html + \row \li \c public.url + \li \c text/uri-list + \row \li \c public.file-url + \li \c text/uri-list + \row \li \c public.tiff + \li \c application/x-qt-image + \row \li \c public.vcard + \li \c text/plain + \row \li \c com.apple.traditional-mac-plain-text + \li \c text/plain + \row \li \c com.apple.pict + \li \c application/x-qt-image + \endtable When working with MIME data, Qt will interate through all instances of QMacPasteboardMime to find an instance that can convert to, or from, a specific MIME type. It will do this by calling diff --git a/src/src.pro b/src/src.pro index 317df66..fd1ffb1 100644 --- a/src/src.pro +++ b/src/src.pro @@ -1,2 +1,9 @@ -TEMPLATE = subdirs -mac:SUBDIRS += macextras +mac { + TEMPLATE = subdirs + SUBDIRS += macextras +} +else { + # fake project for creating the documentation + TEMPLATE = aux + QMAKE_DOCS = $$PWD/macextras/doc/qtmacextras.qdocconf +} -- cgit v1.2.3