aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@digia.com>2013-09-18 12:07:45 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-26 10:24:54 +0200
commit24d45304aa363c9a08f7157d549cb37c07212108 (patch)
treef50b6e671f19d663dcd5ce4b18a57479a760b2d8
parent1ef71fcdb15ac0b93751142629b4a2d1ab1e73c8 (diff)
Remove QtWidgets dependencies from QtMacExtras.
This makes it possible to use QtMacExtras from other modules without adding a QtWidgets dependency. It also makes it possible to use QtMacExtras from QtWidgets. Widget-related classes and functions will be added to QtWidgets. Specifics: Make QMacNativeToolBar private, for use by QMainWindow:: setUnifiedTitleAndToolBarOnMac(). Remove the QAction based APIs. Remove the example. We can make QMacNativeToolBar public again when the API is ready and documented. Remove misc functions: toNSMenu, setDockMenu, isMainWindow. Make toCfSTring/Url private pending inclusion into QtCore. Change-Id: Ic55e78d8ef923149c23884f6589732f7dfb94153 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
-rw-r--r--examples/embeddedqwindow/main.mm5
-rw-r--r--examples/examples.pro5
-rw-r--r--examples/macfunctions/main.cpp10
-rw-r--r--examples/macpasteboardmime/macpasteboardmime.pro2
-rw-r--r--examples/macunifiedtoolbar/macunifiedtoolbar.pro20
-rw-r--r--examples/macunifiedtoolbar/macunifiedtoolbar.qrc5
-rw-r--r--examples/macunifiedtoolbar/main.cpp52
-rw-r--r--examples/macunifiedtoolbar/preferenceswindow.cpp101
-rw-r--r--examples/macunifiedtoolbar/preferenceswindow.h65
-rw-r--r--examples/macunifiedtoolbar/preferenceswindow.ui209
-rw-r--r--examples/macunifiedtoolbar/qtlogo.icnsbin129539 -> 0 bytes
-rw-r--r--examples/macunifiedtoolbar/qtlogo.pngbin1478 -> 0 bytes
-rw-r--r--examples/macunifiedtoolbar/window.cpp140
-rw-r--r--examples/macunifiedtoolbar/window.h72
-rw-r--r--examples/macunifiedtoolbar/window.ui151
-rw-r--r--examples/qmaccocoaviewcontainer/main.mm67
-rw-r--r--examples/qmaccocoaviewcontainer/qmaccocoaviewcontainer.pro7
-rw-r--r--examples/qmacnativewidget/main.mm137
-rw-r--r--examples/qmacnativewidget/qmacnativewidget.pro7
-rw-r--r--src/macextras/macextras-lib.pri10
-rw-r--r--src/macextras/macextras.pro1
-rw-r--r--src/macextras/qmaccocoaviewcontainer.h70
-rw-r--r--src/macextras/qmaccocoaviewcontainer.mm166
-rw-r--r--src/macextras/qmacextrasglobal.h2
-rw-r--r--src/macextras/qmacfunctions.h25
-rw-r--r--src/macextras/qmacfunctions.mm5
-rw-r--r--src/macextras/qmacfunctions_ios.mm1
-rw-r--r--src/macextras/qmacfunctions_mac.mm61
-rw-r--r--src/macextras/qmacfunctions_p.h14
-rw-r--r--src/macextras/qmacnativetoolbar.mm157
-rw-r--r--src/macextras/qmacnativetoolbar_p.h (renamed from src/macextras/qmacnativetoolbar.h)51
-rw-r--r--src/macextras/qmacnativewidget.h72
-rw-r--r--src/macextras/qmacnativewidget.mm148
-rw-r--r--src/macextras/qmacpasteboardmime.mm5
-rw-r--r--src/macextras/qmactoolbardelegate.mm85
-rw-r--r--src/macextras/qmactoolbardelegate_p.h27
-rw-r--r--src/macextras/qmactoolbutton.mm33
-rw-r--r--src/macextras/qmactoolbutton_p.h (renamed from src/macextras/qmactoolbutton.h)18
-rw-r--r--tests/auto/auto.pro3
-rw-r--r--tests/auto/macfunctions/tst_qmacfunctions.mm30
40 files changed, 158 insertions, 1881 deletions
diff --git a/examples/embeddedqwindow/main.mm b/examples/embeddedqwindow/main.mm
index 810d789..f24533b 100644
--- a/examples/embeddedqwindow/main.mm
+++ b/examples/embeddedqwindow/main.mm
@@ -39,15 +39,14 @@
**
****************************************************************************/
+#include <Cocoa/Cocoa.h>
+
#include "window.h"
#include <QtGui>
#include <qpa/qplatformnativeinterface.h>
-#include <Cocoa/Cocoa.h>
-
-
NSView *getEmbeddableView(QWindow *qtWindow)
{
// Make sure the platform window is created
diff --git a/examples/examples.pro b/examples/examples.pro
index 891e3d6..8fe1d13 100644
--- a/examples/examples.pro
+++ b/examples/examples.pro
@@ -2,7 +2,4 @@ TEMPLATE = subdirs
mac:SUBDIRS = macfunctions
mac:!ios:SUBDIRS += embeddedqwindow \
- macpasteboardmime \
- macunifiedtoolbar \
- qmaccocoaviewcontainer \
- qmacnativewidget \
+ macpasteboardmime
diff --git a/examples/macfunctions/main.cpp b/examples/macfunctions/main.cpp
index de77b08..a1563ba 100644
--- a/examples/macfunctions/main.cpp
+++ b/examples/macfunctions/main.cpp
@@ -40,7 +40,7 @@
****************************************************************************/
-#include <QApplication>
+#include <QGuiApplication>
#include <QMenu>
#include <QPixmap>
#include <QWidget>
@@ -48,17 +48,11 @@
int main(int argc, char **argv)
{
- QApplication app(argc, argv);
+ QGuiApplication app(argc, argv);
QWidget widget;
widget.show();
- // Dock menu
- QMenu menu;
- menu.addAction("Item 1");
- menu.addAction("Item 2");
- QtMac::setDockMenu(&menu);
-
// Pixmap <-> CGImage conversion
QPixmap pixmap(":qtlogo.png");
CGImageRef cgImage = QtMac::toCGImageRef(pixmap);
diff --git a/examples/macpasteboardmime/macpasteboardmime.pro b/examples/macpasteboardmime/macpasteboardmime.pro
index 9869637..3ce4cd4 100644
--- a/examples/macpasteboardmime/macpasteboardmime.pro
+++ b/examples/macpasteboardmime/macpasteboardmime.pro
@@ -1,4 +1,4 @@
-QT += macextras
+QT += macextras widgets
SOURCES += main.cpp
diff --git a/examples/macunifiedtoolbar/macunifiedtoolbar.pro b/examples/macunifiedtoolbar/macunifiedtoolbar.pro
deleted file mode 100644
index c13f714..0000000
--- a/examples/macunifiedtoolbar/macunifiedtoolbar.pro
+++ /dev/null
@@ -1,20 +0,0 @@
-QT += core gui macextras
-greaterThan(QT_MAJOR_VERSION, 4):QT += widgets
-
-SOURCES += \
- main.cpp \
- preferenceswindow.cpp \
- window.cpp
-
-HEADERS += \
- preferenceswindow.h \
- window.h
-
-FORMS += \
- preferenceswindow.ui \
- window.ui
-
-RESOURCES += \
- macunifiedtoolbar.qrc
-
-ICON = qtlogo.icns
diff --git a/examples/macunifiedtoolbar/macunifiedtoolbar.qrc b/examples/macunifiedtoolbar/macunifiedtoolbar.qrc
deleted file mode 100644
index 04a9419..0000000
--- a/examples/macunifiedtoolbar/macunifiedtoolbar.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>qtlogo.png</file>
- </qresource>
-</RCC>
diff --git a/examples/macunifiedtoolbar/main.cpp b/examples/macunifiedtoolbar/main.cpp
deleted file mode 100644
index 9b764c7..0000000
--- a/examples/macunifiedtoolbar/main.cpp
+++ /dev/null
@@ -1,52 +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 <QApplication>
-#include "window.h"
-
-int main(int argc, char **argv)
-{
- QApplication app(argc, argv);
- Window window;
- window.show();
- return app.exec();
-}
-
diff --git a/examples/macunifiedtoolbar/preferenceswindow.cpp b/examples/macunifiedtoolbar/preferenceswindow.cpp
deleted file mode 100644
index 4991023..0000000
--- a/examples/macunifiedtoolbar/preferenceswindow.cpp
+++ /dev/null
@@ -1,101 +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 "preferenceswindow.h"
-#include <QMacNativeToolBar>
-#include <QTimer>
-
-PreferencesWindow::PreferencesWindow(QWidget *parent) :
- QMainWindow(parent),
- ui(new Ui::PreferencesWindow)
-{
- ui->setupUi(this);
-
- // Ensure we can only select one 'tab' at a time
- QActionGroup *items = new QActionGroup(this);
- foreach (QAction *action, ui->toolBar->actions())
- items->addAction(action);
-
- // This single line of code is all that's needed to transform a QToolBar into a native toolbar!
- QtMac::setNativeToolBar(ui->toolBar, ui->useNativeToolbarCheckBox->isChecked());
-
- QTimer::singleShot(0, this, SLOT(pack()));
-}
-
-PreferencesWindow::~PreferencesWindow()
-{
- delete ui;
-}
-
-void PreferencesWindow::toolbarItemTriggered()
-{
- QAction *action = qobject_cast<QAction*>(sender());
- if (action)
- {
- setWindowTitle(action->text());
- }
-
- if (sender() == ui->actionGeneral)
- {
- ui->stackedWidget->setCurrentWidget(ui->generalPage);
- }
- else if (sender() == ui->actionNetwork)
- {
- ui->stackedWidget->setCurrentWidget(ui->networkPage);
- }
- else if (sender() == ui->actionAdvanced)
- {
- ui->stackedWidget->setCurrentWidget(ui->advancedPage);
- }
-
- QTimer::singleShot(0, this, SLOT(pack()));
-}
-
-void PreferencesWindow::useNativeToolBarToggled(bool on)
-{
- QtMac::setNativeToolBar(ui->toolBar, on);
- QTimer::singleShot(0, this, SLOT(pack()));
-}
-
-void PreferencesWindow::pack()
-{
- resize(QSize());
-}
diff --git a/examples/macunifiedtoolbar/preferenceswindow.h b/examples/macunifiedtoolbar/preferenceswindow.h
deleted file mode 100644
index 0accb83..0000000
--- a/examples/macunifiedtoolbar/preferenceswindow.h
+++ /dev/null
@@ -1,65 +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$
-**
-****************************************************************************/
-
-#ifndef PREFERENCESWINDOW_H
-#define PREFERENCESWINDOW_H
-
-#include <QMainWindow>
-#include "ui_preferenceswindow.h"
-
-class PreferencesWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- explicit PreferencesWindow(QWidget *parent = 0);
- ~PreferencesWindow();
-
-private slots:
- void toolbarItemTriggered();
- void useNativeToolBarToggled(bool);
- void pack();
-
-private:
- Ui::PreferencesWindow *ui;
-};
-
-#endif // PREFERENCESWINDOW_H
diff --git a/examples/macunifiedtoolbar/preferenceswindow.ui b/examples/macunifiedtoolbar/preferenceswindow.ui
deleted file mode 100644
index 7f3ef00..0000000
--- a/examples/macunifiedtoolbar/preferenceswindow.ui
+++ /dev/null
@@ -1,209 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>PreferencesWindow</class>
- <widget class="QMainWindow" name="PreferencesWindow">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>400</width>
- <height>300</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Preferences</string>
- </property>
- <widget class="QWidget" name="centralwidget">
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QCheckBox" name="useNativeToolbarCheckBox">
- <property name="text">
- <string>Use native NSToolbar</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QStackedWidget" name="stackedWidget">
- <widget class="QWidget" name="generalPage">
- <layout class="QGridLayout" name="gridLayout_2">
- <item row="0" column="0">
- <widget class="QLabel" name="generalLabel">
- <property name="text">
- <string>General preferences would go here</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="networkPage">
- <layout class="QGridLayout" name="gridLayout_3">
- <item row="0" column="0">
- <widget class="QLabel" name="networkLabel">
- <property name="text">
- <string>Network preferences would go here</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="advancedPage">
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="advancedLabel">
- <property name="text">
- <string>Advanced preferences would go here</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </widget>
- </item>
- </layout>
- </widget>
- <widget class="QToolBar" name="toolBar">
- <property name="movable">
- <bool>false</bool>
- </property>
- <property name="toolButtonStyle">
- <enum>Qt::ToolButtonTextUnderIcon</enum>
- </property>
- <property name="floatable">
- <bool>false</bool>
- </property>
- <attribute name="toolBarArea">
- <enum>TopToolBarArea</enum>
- </attribute>
- <attribute name="toolBarBreak">
- <bool>false</bool>
- </attribute>
- <addaction name="actionGeneral"/>
- <addaction name="actionNetwork"/>
- <addaction name="actionAdvanced"/>
- </widget>
- <action name="actionGeneral">
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- <property name="icon">
- <iconset resource="macunifiedtoolbar.qrc">
- <normaloff>:/qtlogo.png</normaloff>:/qtlogo.png</iconset>
- </property>
- <property name="text">
- <string>General</string>
- </property>
- </action>
- <action name="actionNetwork">
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="icon">
- <iconset resource="macunifiedtoolbar.qrc">
- <normaloff>:/qtlogo.png</normaloff>:/qtlogo.png</iconset>
- </property>
- <property name="text">
- <string>Network</string>
- </property>
- </action>
- <action name="actionAdvanced">
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="icon">
- <iconset resource="macunifiedtoolbar.qrc">
- <normaloff>:/qtlogo.png</normaloff>:/qtlogo.png</iconset>
- </property>
- <property name="text">
- <string>Advanced</string>
- </property>
- </action>
- </widget>
- <resources>
- <include location="macunifiedtoolbar.qrc"/>
- </resources>
- <connections>
- <connection>
- <sender>actionGeneral</sender>
- <signal>triggered()</signal>
- <receiver>PreferencesWindow</receiver>
- <slot>toolbarItemTriggered()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>-1</x>
- <y>-1</y>
- </hint>
- <hint type="destinationlabel">
- <x>399</x>
- <y>299</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>actionNetwork</sender>
- <signal>triggered()</signal>
- <receiver>PreferencesWindow</receiver>
- <slot>toolbarItemTriggered()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>-1</x>
- <y>-1</y>
- </hint>
- <hint type="destinationlabel">
- <x>399</x>
- <y>299</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>actionAdvanced</sender>
- <signal>triggered()</signal>
- <receiver>PreferencesWindow</receiver>
- <slot>toolbarItemTriggered()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>-1</x>
- <y>-1</y>
- </hint>
- <hint type="destinationlabel">
- <x>399</x>
- <y>299</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>useNativeToolbarCheckBox</sender>
- <signal>toggled(bool)</signal>
- <receiver>PreferencesWindow</receiver>
- <slot>useNativeToolBarToggled(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>61</x>
- <y>87</y>
- </hint>
- <hint type="destinationlabel">
- <x>199</x>
- <y>149</y>
- </hint>
- </hints>
- </connection>
- </connections>
- <slots>
- <slot>toolbarItemTriggered()</slot>
- <slot>useNativeToolBarToggled(bool)</slot>
- </slots>
-</ui>
diff --git a/examples/macunifiedtoolbar/qtlogo.icns b/examples/macunifiedtoolbar/qtlogo.icns
deleted file mode 100644
index def5f0e..0000000
--- a/examples/macunifiedtoolbar/qtlogo.icns
+++ /dev/null
Binary files differ
diff --git a/examples/macunifiedtoolbar/qtlogo.png b/examples/macunifiedtoolbar/qtlogo.png
deleted file mode 100644
index d75936b..0000000
--- a/examples/macunifiedtoolbar/qtlogo.png
+++ /dev/null
Binary files differ
diff --git a/examples/macunifiedtoolbar/window.cpp b/examples/macunifiedtoolbar/window.cpp
deleted file mode 100644
index dde27e3..0000000
--- a/examples/macunifiedtoolbar/window.cpp
+++ /dev/null
@@ -1,140 +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 "window.h"
-#include "preferenceswindow.h"
-#include <QMacNativeToolBar>
-#include <QDesktopWidget>
-#include <QMenuBar>
-#include <QTimer>
-
-class WindowPrivate
-{
-public:
- PreferencesWindow *preferencesWindow;
- QMenuBar *mainMenuBar;
- QMacNativeToolBar *toolBar;
-};
-
-Window::Window(QWidget *parent) :
- QWidget(parent),
- d(new WindowPrivate),
- ui(new Ui::Window)
-{
- ui->setupUi(this);
-
- d->preferencesWindow = new PreferencesWindow();
-
- d->mainMenuBar = new QMenuBar();
- QMenu *toolsMenu = d->mainMenuBar->addMenu("Tools");
- toolsMenu->addAction("Options", d->preferencesWindow, SLOT(show()));
-
- d->toolBar = new QMacNativeToolBar(this);
- d->toolBar->addAction(QIcon(":/qtlogo.png"), "Hello");
- d->toolBar->addAction(QIcon(":/qtlogo.png"), "World");
- d->toolBar->addStandardItem(QMacToolButton::FlexibleSpace);
- d->toolBar->addStandardItem(QMacToolButton::ShowColors);
- d->toolBar->addStandardItem(QMacToolButton::ShowFonts);
- d->toolBar->addStandardItem(QMacToolButton::PrintItem);
-
- d->toolBar->addAllowedAction(QIcon(":/qtlogo.png"), "Extra Button 1");
- d->toolBar->addAllowedAction(QIcon(":/qtlogo.png"), "Extra Button 2");
-
- d->toolBar->showInWindowForWidget(this);
-
- connect(d->toolBar, SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)), SLOT(displayModeChanged(Qt::ToolButtonStyle)));
- ui->displayModeComboBox->setCurrentIndex(d->toolBar->toolButtonStyle());
-
- connect(d->toolBar, SIGNAL(iconSizeChanged(QMacToolButton::IconSize)), SLOT(sizeModeChanged(QMacToolButton::IconSize)));
- ui->sizeModeComboBox->setCurrentIndex(d->toolBar->iconSizeType());
-
- connect(ui->visibleCheckBox, SIGNAL(clicked(bool)), d->toolBar, SLOT(setVisible(bool)));
- connect(d->toolBar, SIGNAL(visibilityChanged(bool)), ui->visibleCheckBox, SLOT(setChecked(bool)));
- ui->visibleCheckBox->setChecked(d->toolBar->isVisible());
-
- connect(ui->showsBaselineSeparatorCheckBox, SIGNAL(clicked(bool)), d->toolBar, SLOT(setShowsBaselineSeparator(bool)));
- connect(d->toolBar, SIGNAL(showsBaselineSeparatorChanged(bool)), ui->showsBaselineSeparatorCheckBox, SLOT(setChecked(bool)));
- ui->showsBaselineSeparatorCheckBox->setChecked(d->toolBar->showsBaselineSeparator());
-
- connect(ui->allowsUserCustomizationCheckBox, SIGNAL(clicked(bool)), d->toolBar, SLOT(setAllowsUserCustomization(bool)));
- connect(d->toolBar, SIGNAL(allowsUserCustomizationChanged(bool)), ui->allowsUserCustomizationCheckBox, SLOT(setChecked(bool)));
- ui->allowsUserCustomizationCheckBox->setChecked(d->toolBar->allowsUserCustomization());
-
- connect(ui->showCustomizationSheetPushButton, SIGNAL(clicked()), d->toolBar, SLOT(showCustomizationSheet()));
- connect(d->toolBar, SIGNAL(allowsUserCustomizationChanged(bool)), ui->showCustomizationSheetPushButton, SLOT(setEnabled(bool)));
- ui->showCustomizationSheetPushButton->setEnabled(d->toolBar->allowsUserCustomization());
-
- QTimer::singleShot(0, this, SLOT(positionWindow()));
-}
-
-Window::~Window()
-{
- delete ui;
- delete d->mainMenuBar;
- delete d->preferencesWindow;
- delete d;
-}
-
-void Window::changeDisplayMode(int toolButtonStyle)
-{
- d->toolBar->setToolButtonStyle(static_cast<Qt::ToolButtonStyle>(toolButtonStyle));
-}
-
-void Window::displayModeChanged(Qt::ToolButtonStyle toolButtonStyle)
-{
- ui->displayModeComboBox->setCurrentIndex(toolButtonStyle);
-}
-
-void Window::changeSizeMode(int sizeMode)
-{
- d->toolBar->setIconSize(static_cast<QMacToolButton::IconSize>(sizeMode));
-}
-
-void Window::sizeModeChanged(QMacToolButton::IconSize size)
-{
- ui->sizeModeComboBox->setCurrentIndex(size);
-}
-
-void Window::positionWindow()
-{
- resize(QSize());
- setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, size(), qApp->desktop()->availableGeometry()));
-}
diff --git a/examples/macunifiedtoolbar/window.h b/examples/macunifiedtoolbar/window.h
deleted file mode 100644
index 7f0dc54..0000000
--- a/examples/macunifiedtoolbar/window.h
+++ /dev/null
@@ -1,72 +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$
-**
-****************************************************************************/
-
-#ifndef WINDOW_H
-#define WINDOW_H
-
-#include <QWidget>
-#include "qmactoolbutton.h"
-#include "ui_window.h"
-
-class WindowPrivate;
-class Window : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit Window(QWidget *parent = 0);
- ~Window();
-
-private slots:
- void changeDisplayMode(int);
- void displayModeChanged(Qt::ToolButtonStyle);
-
- void changeSizeMode(int);
- void sizeModeChanged(QMacToolButton::IconSize);
-
- void positionWindow();
-
-private:
- WindowPrivate *d;
- Ui::Window *ui;
-};
-
-#endif // WINDOW_H
diff --git a/examples/macunifiedtoolbar/window.ui b/examples/macunifiedtoolbar/window.ui
deleted file mode 100644
index 90081a0..0000000
--- a/examples/macunifiedtoolbar/window.ui
+++ /dev/null
@@ -1,151 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>Window</class>
- <widget class="QWidget" name="Window">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>265</width>
- <height>173</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Qt Mac Toolbar Example</string>
- </property>
- <layout class="QFormLayout" name="formLayout">
- <property name="fieldGrowthPolicy">
- <enum>QFormLayout::FieldsStayAtSizeHint</enum>
- </property>
- <item row="0" column="0">
- <widget class="QLabel" name="displayModeLabel">
- <property name="text">
- <string>Display mode:</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QComboBox" name="displayModeComboBox">
- <item>
- <property name="text">
- <string>IconOnly</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>TextOnly</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>TextBesideIcon</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>TextUnderIcon</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>FollowStyle</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="sizeModeLabel">
- <property name="text">
- <string>Size mode:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QComboBox" name="sizeModeComboBox">
- <item>
- <property name="text">
- <string>Default</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Regular</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Small</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="2" column="0" colspan="2">
- <widget class="QCheckBox" name="visibleCheckBox">
- <property name="text">
- <string>Visible</string>
- </property>
- </widget>
- </item>
- <item row="3" column="0" colspan="2">
- <widget class="QCheckBox" name="showsBaselineSeparatorCheckBox">
- <property name="text">
- <string>Shows baseline separator</string>
- </property>
- </widget>
- </item>
- <item row="4" column="0" colspan="2">
- <widget class="QCheckBox" name="allowsUserCustomizationCheckBox">
- <property name="text">
- <string>Allows user customization</string>
- </property>
- </widget>
- </item>
- <item row="5" column="0" colspan="2">
- <widget class="QPushButton" name="showCustomizationSheetPushButton">
- <property name="text">
- <string>Show customization sheet</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections>
- <connection>
- <sender>displayModeComboBox</sender>
- <signal>currentIndexChanged(int)</signal>
- <receiver>Window</receiver>
- <slot>changeDisplayMode(int)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>337</x>
- <y>22</y>
- </hint>
- <hint type="destinationlabel">
- <x>288</x>
- <y>149</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>sizeModeComboBox</sender>
- <signal>currentIndexChanged(int)</signal>
- <receiver>Window</receiver>
- <slot>changeSizeMode(int)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>158</x>
- <y>52</y>
- </hint>
- <hint type="destinationlabel">
- <x>132</x>
- <y>86</y>
- </hint>
- </hints>
- </connection>
- </connections>
- <slots>
- <slot>changeDisplayMode(int)</slot>
- <slot>changeSizeMode(int)</slot>
- </slots>
-</ui>
diff --git a/examples/qmaccocoaviewcontainer/main.mm b/examples/qmaccocoaviewcontainer/main.mm
deleted file mode 100644
index e8ebc23..0000000
--- a/examples/qmaccocoaviewcontainer/main.mm
+++ /dev/null
@@ -1,67 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 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 <QtWidgets>
-#include <Cocoa/Cocoa.h>
-#include <QMacCocoaViewContainer>
-
-class WindowWidget : public QWidget
-{
-public:
- WindowWidget()
- {
- QMacCocoaViewContainer *cocoaViewContainer = new QMacCocoaViewContainer(0, this);
- cocoaViewContainer->move(100, 100);
- cocoaViewContainer->resize(300, 300);
- NSTextView *text = [[NSTextView alloc] initWithFrame : NSMakeRect(0, 0, 300, 300)];
- cocoaViewContainer->setCocoaView(text);
- }
-};
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- WindowWidget widget;
- widget.show();
-
- return app.exec();
-}
diff --git a/examples/qmaccocoaviewcontainer/qmaccocoaviewcontainer.pro b/examples/qmaccocoaviewcontainer/qmaccocoaviewcontainer.pro
deleted file mode 100644
index 47b5de1..0000000
--- a/examples/qmaccocoaviewcontainer/qmaccocoaviewcontainer.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-TEMPLATE = app
-
-OBJECTIVE_SOURCES += main.mm
-LIBS += -framework Cocoa
-
-QT += gui widgets macextras
-
diff --git a/examples/qmacnativewidget/main.mm b/examples/qmacnativewidget/main.mm
deleted file mode 100644
index 22d0957..0000000
--- a/examples/qmacnativewidget/main.mm
+++ /dev/null
@@ -1,137 +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 <QApplication>
-#include <QDebug>
-#include <QHBoxLayout>
-#include <QLineEdit>
-#include <QPainter>
-#include <QPushButton>
-#include <QVBoxLayout>
-#include <QWidget>
-#include <Cocoa/Cocoa.h>
-#include <qmacnativewidget.h>
-
-class RedWidget : public QWidget
-{
-public:
- RedWidget() {
-
- }
-
- void resizeEvent(QResizeEvent *)
- {
- qDebug() << "RedWidget::resize" << size();
- }
-
- void paintEvent(QPaintEvent *event)
- {
- QPainter p(this);
- Q_UNUSED(event);
- QRect rect(QPoint(0, 0), size());
- qDebug() << "Painting geometry" << rect;
- p.fillRect(rect, QColor(133, 50, 50));
- }
-};
-
-@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"];
-
- // Create widget hierarchy with QPushButton and QLineEdit
- QMacNativeWidget *nativeWidget = new QMacNativeWidget();
-
- QHBoxLayout *hlayout = new QHBoxLayout();
- hlayout->addWidget(new QPushButton("Push", nativeWidget));
- hlayout->addWidget(new QLineEdit);
-
- QVBoxLayout *vlayout = new QVBoxLayout();
- vlayout->addLayout(hlayout);
-
- //RedWidget * redWidget = new RedWidget;
- //vlayout->addWidget(redWidget);
-
- nativeWidget->setLayout(vlayout);
-
- // Get the NSView for QMacNativeWidget and set it as the content view for the NSWindow
- [window setContentView:nativeWidget->nativeView()];
-
- // show() must be called on nativeWiget to get the widgets int he correct state.
- nativeWidget->show();
-
- // Show the NSWindow
- [window makeKeyAndOrderFront:NSApp];
-}
-@end
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- // Start Cocoa. Create NSApplicaiton.
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
- [NSApplication sharedApplication];
-
- // Schedule call to create the UI using a zero timer.
- WindowCreator *windowCreator= [WindowCreator alloc];
- [NSTimer scheduledTimerWithTimeInterval:0 target:windowCreator selector:@selector(createWindow) userInfo:nil repeats:NO];
-
- // Stare the Cocoa event loop.
- [(NSApplication *)NSApp run];
- [NSApp release];
- [pool release];
- exit(0);
- return 0;
-}
-
-
-
diff --git a/examples/qmacnativewidget/qmacnativewidget.pro b/examples/qmacnativewidget/qmacnativewidget.pro
deleted file mode 100644
index df5f825..0000000
--- a/examples/qmacnativewidget/qmacnativewidget.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-TEMPLATE = app
-
-OBJECTIVE_SOURCES += main.mm
-LIBS += -framework Cocoa
-
-QT += gui widgets macextras
-QT += widgets-private gui-private core-private
diff --git a/src/macextras/macextras-lib.pri b/src/macextras/macextras-lib.pri
index 245c4c5..8240436 100644
--- a/src/macextras/macextras-lib.pri
+++ b/src/macextras/macextras-lib.pri
@@ -11,21 +11,15 @@ mac {
LIBS *= -framework UIKit
} else {
- PUBLIC_HEADERS += \
- $$PWD/qmaccocoaviewcontainer.h \
- $$PWD/qmacnativetoolbar.h \
- $$PWD/qmacnativewidget.h \
- $$PWD/qmactoolbutton.h
-
PRIVATE_HEADERS += \
+ $$PWD/qmacnativetoolbar_p.h \
+ $$PWD/qmactoolbutton_p.h \
$$PWD/qmactoolbardelegate_p.h \
$$PWD/qnstoolbar_p.h
OBJECTIVE_SOURCES += \
- $$PWD/qmaccocoaviewcontainer.mm \
$$PWD/qmacfunctions_mac.mm \
$$PWD/qmacnativetoolbar.mm \
- $$PWD/qmacnativewidget.mm \
$$PWD/qmactoolbardelegate.mm \
$$PWD/qmactoolbutton.mm \
$$PWD/qnstoolbar.mm
diff --git a/src/macextras/macextras.pro b/src/macextras/macextras.pro
index 221dbdd..12f00cd 100644
--- a/src/macextras/macextras.pro
+++ b/src/macextras/macextras.pro
@@ -1,7 +1,6 @@
include($$PWD/macextras-lib.pri)
load(qt_build_config)
-QT += widgets
QT_PRIVATE += gui-private core-private
TARGET = QtMacExtras
load(qt_module)
diff --git a/src/macextras/qmaccocoaviewcontainer.h b/src/macextras/qmaccocoaviewcontainer.h
deleted file mode 100644
index a9172ab..0000000
--- a/src/macextras/qmaccocoaviewcontainer.h
+++ /dev/null
@@ -1,70 +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 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$
- **
- ****************************************************************************/
-#ifndef QMACCOCOAVIEWCONTAINER_H
-#define QMACCOCOAVIEWCONTAINER_H
-
-#include "qmacextrasglobal.h"
-
-#include <QtWidgets/QWidget>
-
-Q_FORWARD_DECLARE_OBJC_CLASS(NSView);
-
-QT_BEGIN_NAMESPACE
-
-class QMacCocoaViewContainerPrivate;
-class Q_MACEXTRAS_EXPORT QMacCocoaViewContainer : public QWidget
-{
- Q_OBJECT
-public:
- QMacCocoaViewContainer(NSView *cocoaViewToWrap, QWidget *parent = 0);
- virtual ~QMacCocoaViewContainer();
-
- void setCocoaView(NSView *view);
- NSView *cocoaView() const;
-
-private:
- QMacCocoaViewContainerPrivate *d;
-};
-
-QT_END_NAMESPACE
-
-#endif // QMACCOCOAVIEWCONTAINER_H
-
diff --git a/src/macextras/qmaccocoaviewcontainer.mm b/src/macextras/qmaccocoaviewcontainer.mm
deleted file mode 100644
index 8b9acc1..0000000
--- a/src/macextras/qmaccocoaviewcontainer.mm
+++ /dev/null
@@ -1,166 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 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$
-**
-****************************************************************************/
-
-#import <Cocoa/Cocoa.h>
-
-#include "qmaccocoaviewcontainer.h"
-
-#include <qpa/qplatformnativeinterface.h>
-#include <QtGui/QWindow>
-
-/*!
- \class QMacCocoaViewContainer
-
- \brief The QMacCocoaViewContainer class provides a widget for Mac OS X that can be used to wrap arbitrary
- Cocoa views (i.e., NSView subclasses) and insert them into Qt hierarchies.
-
- \ingroup advanced
-
- While Qt offers a lot of classes for writing your application, Apple's
- Cocoa framework offers lots of functionality that is not currently in Qt or
- may never end up in Qt. Using QMacCocoaViewContainer, it is possible to put an
- arbitrary NSView-derived class from Cocoa and put it in a Qt hierarchy.
- Depending on how comfortable you are with using objective-C, you can use
- QMacCocoaViewContainer directly, or subclass it to wrap further functionality
- of the underlying NSView.
-
- It should be also noted that at the low level on Mac OS X, there is a
- difference between windows (top-levels) and view (widgets that are inside a
- window). For this reason, make sure that the NSView that you are wrapping
- doesn't end up as a top-level. The best way to ensure this is to make sure
- you always have a parent and not set the parent to 0.
-
- If you are using QMacCocoaViewContainer as a sub-class and are mixing and
- matching objective-C with C++ (a.k.a. objective-C++). It is probably
- simpler to have your file end with \tt{.mm} than \tt{.cpp}. Most Apple tools will
- correctly identify the source as objective-C++.
-
- QMacCocoaViewContainer requires knowledge of how Cocoa works, especially in
- regard to its reference counting (retain/release) nature. It is noted in
- the functions below if there is any change in the reference count. Cocoa
- views often generate temporary objects that are released by an autorelease
- pool. If this is done outside of a running event loop, it is up to the
- developer to provide the autorelease pool.
-
- The following is a snippet of subclassing QMacCocoaViewContainer to wrap a NSSearchField.
- \snippet demos/macmainwindow/macmainwindow.mm 0
-
-*/
-
-QT_BEGIN_NAMESPACE
-
-class QMacCocoaViewContainerPrivate
-{
-public:
- NSView *nsview;
- QMacCocoaViewContainerPrivate();
- ~QMacCocoaViewContainerPrivate();
-};
-
-QMacCocoaViewContainerPrivate::QMacCocoaViewContainerPrivate()
- : nsview(0)
-{
-}
-
-QMacCocoaViewContainerPrivate::~QMacCocoaViewContainerPrivate()
-{
- [nsview release];
-}
-
-/*!
- \fn QMacCocoaViewContainer::QMacCocoaViewContainer(NSView *cocoaViewToWrap, QWidget *parent)
-
- Create a new QMacCocoaViewContainer using the NSView pointer in \a
- cocoaViewToWrap with parent, \a parent. QMacCocoaViewContainer will
- retain \a cocoaViewToWrap.
-
-*/
-QMacCocoaViewContainer::QMacCocoaViewContainer(NSView *view, QWidget *parent)
- : QWidget(parent, 0)
- , d(new QMacCocoaViewContainerPrivate)
-{
-
- if (view)
- setCocoaView(view);
-
- // QMacCocoaViewContainer requires a native window handle.
- setAttribute(Qt::WA_NativeWindow);
-}
-
-/*!
- Destroy the QMacCocoaViewContainer and release the wrapped view.
-*/
-QMacCocoaViewContainer::~QMacCocoaViewContainer()
-{
- delete d;
-}
-
-/*!
- Returns the NSView that has been set on this container.
-*/
-NSView *QMacCocoaViewContainer::cocoaView() const
-{
- return d->nsview;
-}
-
-/*!
- Sets the NSView to contain to be \a cocoaViewToWrap and retains it. If this
- container already had a view set, it will release the previously set view.
-*/
-void QMacCocoaViewContainer::setCocoaView(NSView *view)
-{
- NSView *oldView = d->nsview;
- [view retain];
- d->nsview = view;
-
- // Create window and platformwindow
- winId();
- QPlatformWindow *platformWindow = this->windowHandle()->handle();
-
- // Set the new view as the content view for the window.
- extern QPlatformNativeInterface::NativeResourceForIntegrationFunction resolvePlatformFunction(const QByteArray &functionName);
- typedef void (*SetWindowContentViewFunction)(QPlatformWindow *window, NSView *nsview);
- reinterpret_cast<SetWindowContentViewFunction>(resolvePlatformFunction("setwindowcontentview"))(platformWindow, view);
-
- [oldView release];
-}
-
-QT_END_NAMESPACE
diff --git a/src/macextras/qmacextrasglobal.h b/src/macextras/qmacextrasglobal.h
index f6a6f99..dacb110 100644
--- a/src/macextras/qmacextrasglobal.h
+++ b/src/macextras/qmacextrasglobal.h
@@ -52,6 +52,8 @@ QT_BEGIN_NAMESPACE
# define Q_MACEXTRAS_EXPORT Q_DECL_IMPORT
#endif
+
+// ### remove when merged to QtCore
/*!
* \macro Q_FORWARD_DECLARE_OBJC_CLASS(classname)
*
diff --git a/src/macextras/qmacfunctions.h b/src/macextras/qmacfunctions.h
index 2f794a9..7ab0cdd 100644
--- a/src/macextras/qmacfunctions.h
+++ b/src/macextras/qmacfunctions.h
@@ -53,9 +53,6 @@ typedef struct CGContext *CGContextRef;
Q_FORWARD_DECLARE_OBJC_CLASS(NSData);
Q_FORWARD_DECLARE_OBJC_CLASS(NSImage);
-Q_FORWARD_DECLARE_OBJC_CLASS(NSString);
-Q_FORWARD_DECLARE_OBJC_CLASS(NSMenu);
-Q_FORWARD_DECLARE_OBJC_CLASS(NSURL);
QT_BEGIN_NAMESPACE
@@ -65,18 +62,11 @@ class QMenuBar;
class QPixmap;
class QString;
class QUrl;
-class QWidget;
class QWindow;
namespace QtMac
{
-Q_MACEXTRAS_EXPORT NSString* toNSString(const QString &string);
-Q_MACEXTRAS_EXPORT QString fromNSString(const NSString *string);
-
-Q_MACEXTRAS_EXPORT NSURL* toNSURL(const QUrl &url);
-Q_MACEXTRAS_EXPORT QUrl fromNSURL(const NSURL *url);
-
-Q_MACEXTRAS_EXPORT NSData* toNSData(const QByteArray &data);
+Q_MACEXTRAS_EXPORT NSData *toNSData(const QByteArray &data);
Q_MACEXTRAS_EXPORT QByteArray fromNSData(const NSData *data);
Q_MACEXTRAS_EXPORT CGImageRef toCGImageRef(const QPixmap &pixmap);
@@ -85,26 +75,15 @@ Q_MACEXTRAS_EXPORT QPixmap fromCGImageRef(CGImageRef image);
Q_MACEXTRAS_EXPORT CGContextRef currentCGContext();
#ifndef Q_OS_IOS
-Q_MACEXTRAS_EXPORT NSImage* toNSImage(const QPixmap &pixmap);
-
-Q_MACEXTRAS_EXPORT NSMenu* toNSMenu(QMenu *menu);
-Q_MACEXTRAS_EXPORT NSMenu* toNSMenu(QMenuBar *menubar);
-
-Q_MACEXTRAS_EXPORT void setDockMenu(QMenu *menu);
+Q_MACEXTRAS_EXPORT NSImage *toNSImage(const QPixmap &pixmap);
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
Q_MACEXTRAS_EXPORT bool isMainWindow(QWindow *window);
#endif
-Q_MACEXTRAS_EXPORT bool isMainWindow(QWidget *widget);
#endif
}
-#ifndef Q_OS_IOS
-// ### Qt 4 compatibility; remove in Qt 6
-inline void qt_mac_set_dock_menu(QMenu *menu) { QtMac::setDockMenu(menu); }
-#endif
-
QT_END_NAMESPACE
#endif // QMACFUNCTIONS_H
diff --git a/src/macextras/qmacfunctions.mm b/src/macextras/qmacfunctions.mm
index d5a6dd8..d843981 100644
--- a/src/macextras/qmacfunctions.mm
+++ b/src/macextras/qmacfunctions.mm
@@ -40,10 +40,13 @@
****************************************************************************/
#include "qmacfunctions.h"
-#include "qmacfunctions_p.h"
+
#include <QByteArray>
#include <QPixmap>
#include <QUrl>
+
+#include "qmacfunctions_p.h"
+
#import <Foundation/Foundation.h>
#ifdef Q_OS_IOS
#import <CoreGraphics/CoreGraphics.h>
diff --git a/src/macextras/qmacfunctions_ios.mm b/src/macextras/qmacfunctions_ios.mm
index 2ea718f..2508941 100644
--- a/src/macextras/qmacfunctions_ios.mm
+++ b/src/macextras/qmacfunctions_ios.mm
@@ -41,6 +41,7 @@
#include "qmacfunctions.h"
#include "qmacfunctions_p.h"
+
#import <UIKit/UIKit.h>
QT_BEGIN_NAMESPACE
diff --git a/src/macextras/qmacfunctions_mac.mm b/src/macextras/qmacfunctions_mac.mm
index bdb1cae..9209c2f 100644
--- a/src/macextras/qmacfunctions_mac.mm
+++ b/src/macextras/qmacfunctions_mac.mm
@@ -64,53 +64,6 @@ NSImage* toNSImage(const QPixmap &pixmap)
return image;
}
-NSMenu* toNSMenu(QMenu *menu)
-{
-#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
- // Get the platform menu, which will be a QCocoaMenu
- QPlatformMenu *platformMenu = menu->platformMenu();
-
- // Get the qMenuToNSMenu function and call it.
- QPlatformNativeInterface::NativeResourceForIntegrationFunction function = resolvePlatformFunction("qmenutonsmenu");
- if (function) {
- typedef void* (*QMenuToNSMenuFunction)(QPlatformMenu *platformMenu);
- return reinterpret_cast<NSMenu *>(reinterpret_cast<QMenuToNSMenuFunction>(function)(platformMenu));
- }
- return nil;
-#else
- return menu->nsMenu();
-#endif
-}
-
-#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
-NSMenu* toNSMenu(QMenuBar *menubar)
-{
- // Get the platform menubar, which will be a QCocoaMenuBar
- QPlatformMenuBar *platformMenuBar = menubar->platformMenuBar();
-
- // Get the qMenuBarToNSMenu function and call it.
- QPlatformNativeInterface::NativeResourceForIntegrationFunction function = resolvePlatformFunction("qmenubartonsmenu");
- if (function) {
- typedef void* (*QMenuBarToNSMenuFunction)(QPlatformMenuBar *platformMenuBar);
- return reinterpret_cast<NSMenu *>(reinterpret_cast<QMenuBarToNSMenuFunction>(function)(platformMenuBar));
- }
- return nil;
-}
-#endif
-
-void setDockMenu(QMenu *menu)
-{
- // Get the platform menu, which will be a QCocoaMenu
- QPlatformMenu *platformMenu = menu->platformMenu();
-
- // Get the setDockMenu function and call it.
- QPlatformNativeInterface::NativeResourceForIntegrationFunction function = resolvePlatformFunction("setdockmenu");
- if (function) {
- typedef void (*SetDockMenuFunction)(QPlatformMenu *platformMenu);
- reinterpret_cast<SetDockMenuFunction>(function)(platformMenu);
- }
-}
-
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
bool isMainWindow(QWindow *window)
{
@@ -123,20 +76,6 @@ bool isMainWindow(QWindow *window)
}
#endif
-bool isMainWindow(QWidget *widget)
-{
- if (!widget)
- return false;
-
-#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
- return isMainWindow(widget->windowHandle());
-#else
- NSWindow *macWindow =
- reinterpret_cast<NSWindow*>([reinterpret_cast<NSView*>(widget->window()->winId()) window]);
- return [macWindow isMainWindow];
-#endif
-}
-
CGContextRef currentCGContext()
{
return reinterpret_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]);
diff --git a/src/macextras/qmacfunctions_p.h b/src/macextras/qmacfunctions_p.h
index 6d8211b..b03b7ae 100644
--- a/src/macextras/qmacfunctions_p.h
+++ b/src/macextras/qmacfunctions_p.h
@@ -49,8 +49,22 @@
#include <QtGui/QGuiApplication>
#include <qpa/qplatformnativeinterface.h>
+// ### remove when merged to QtCore
+
+Q_FORWARD_DECLARE_OBJC_CLASS(NSString);
+Q_FORWARD_DECLARE_OBJC_CLASS(NSURL);
+
QT_BEGIN_NAMESPACE
+namespace QtMac
+{
+ Q_MACEXTRAS_EXPORT NSString *toNSString(const QString &string);
+ Q_MACEXTRAS_EXPORT QString fromNSString(const NSString *string);
+
+ Q_MACEXTRAS_EXPORT NSURL *toNSURL(const QUrl &url);
+ Q_MACEXTRAS_EXPORT QUrl fromNSURL(const NSURL *url);
+}
+
inline QPlatformNativeInterface::NativeResourceForIntegrationFunction resolvePlatformFunction(const QByteArray &functionName)
{
QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();
diff --git a/src/macextras/qmacnativetoolbar.mm b/src/macextras/qmacnativetoolbar.mm
index f6b9020..22c6a6b 100644
--- a/src/macextras/qmacnativetoolbar.mm
+++ b/src/macextras/qmacnativetoolbar.mm
@@ -38,27 +38,25 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-
#import <AppKit/AppKit.h>
-#include "qmacfunctions.h"
-#include "qmacnativetoolbar.h"
-#include "qmactoolbardelegate_p.h"
-#include "qnstoolbar_p.h"
-#include <QAction>
-#include <QApplication>
-#include <QDebug>
-#include <QTimer>
-#include <QToolBar>
-#include <QUuid>
-#include <QWidget>
+#include "qmacnativetoolbar_p.h"
+
+#include <QtGui/QGuiApplication>
+#include <QtCore/QDebug>
+#include <QtCore/QTimer>
+#include <QtCore/QUuid>
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
-#include <QGuiApplication>
+#include <QtGui/QGuiApplication>
#include <qpa/qplatformnativeinterface.h>
#else
-#include <QMainWindow>
+#include <QtGui/QMainWindow>
#endif
+#include "qmacfunctions.h"
+#include "qmacfunctions_p.h"
+#include "qmactoolbardelegate_p.h"
+#include "qnstoolbar_p.h"
// from the Apple NSToolbar documentation
#define kNSToolbarIconSizeSmall 24
@@ -190,48 +188,6 @@ public:
}
};
-QMacNativeToolBar* QtMac::setNativeToolBar(QToolBar *toolbar, bool on)
-{
- return QtMac::setNativeToolBar(toolbar, QString(), on);
-}
-
-QMacNativeToolBar* QtMac::setNativeToolBar(QToolBar *toolbar, const QString &identifier, bool on)
-{
- if (!toolbar)
- {
- qWarning() << "setNativeToolBar: toolbar was NULL";
- return NULL;
- }
-
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- // Turn off unified title and toolbar if it's on, because we're adding our own NSToolbar
- QMainWindow *mainWindow = qobject_cast<QMainWindow*>(toolbar->window());
- if (mainWindow && mainWindow->unifiedTitleAndToolBarOnMac())
- mainWindow->setUnifiedTitleAndToolBarOnMac(false);
-#endif
-
- static const char *macToolBarProperty = "_q_mac_native_toolbar";
-
- // Check if we've already created a Mac equivalent for this toolbar and create one if not
- QVariant toolBarProperty = toolbar->property(macToolBarProperty);
- QMacNativeToolBar *macToolBar;
- if (toolBarProperty.canConvert<QMacNativeToolBar*>()) {
- macToolBar = toolBarProperty.value<QMacNativeToolBar*>();
- } else {
- macToolBar = QMacNativeToolBar::fromQToolBar(toolbar, identifier);
- macToolBar->setParent(toolbar);
- toolbar->setProperty(macToolBarProperty, QVariant::fromValue(macToolBar));
- }
-
- toolbar->setVisible(!on);
- if (on)
- macToolBar->showInWindowForWidget(toolbar->window());
- else
- macToolBar->removeFromWindowForWidget(toolbar->window());
-
- return macToolBar;
-}
-
QMacNativeToolBar::QMacNativeToolBar(QObject *parent)
: QObject(parent), targetWindow(NULL), targetWidget(NULL), d(new QMacNativeToolBarPrivate(this))
{
@@ -257,18 +213,6 @@ NSToolbar *QMacNativeToolBar::nativeToolbar() const
return d->toolbar;
}
-QMacNativeToolBar *QMacNativeToolBar::fromQToolBar(const QToolBar *toolBar, const QString &identifier)
-{
- // TODO: add the QToolBar's QWidgets to the Mac toolbar once it supports this
- QMacNativeToolBar *macToolBar = new QMacNativeToolBar(identifier);
- foreach (QAction *action, toolBar->actions())
- {
- macToolBar->addAction(action);
- }
-
- return macToolBar;
-}
-
QString QMacNativeToolBar::identifier() const
{
return QtMac::fromNSString([d->toolbar identifier]);
@@ -394,33 +338,8 @@ void QMacNativeToolBar::showInWindow(QWindow *window)
QTimer::singleShot(100, this, SLOT(showInWindow_impl())); // ### hackety hack
}
-void QMacNativeToolBar::showInWindowForWidget(QWidget *widget)
-{
- targetWidget = widget;
- widget->winId(); // create window
- showInWindow_impl();
-}
-
-void QMacNativeToolBar::showInMainWindow()
-{
- QWidgetList widgets = QApplication::topLevelWidgets();
- if (widgets.isEmpty())
- return;
-
-#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
- showInWindow(widgets.at(0)->windowHandle());
-#else
- showInWindowForWidget(widgets.at(0)->window());
-#endif
-}
-
-
void QMacNativeToolBar::showInWindow_impl()
{
-#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
- if (!targetWindow)
- targetWindow = targetWidget->windowHandle();
-
if (!targetWindow) {
QTimer::singleShot(100, this, SLOT(showInWindow_impl()));
return;
@@ -428,9 +347,6 @@ void QMacNativeToolBar::showInWindow_impl()
NSWindow *macWindow = static_cast<NSWindow*>(
QGuiApplication::platformNativeInterface()->nativeResourceForWindow("nswindow", targetWindow));
-#else
- NSWindow *macWindow = reinterpret_cast<NSWindow*>([reinterpret_cast<NSView*>(targetWidget->winId()) window]);
-#endif
if (!macWindow) {
QTimer::singleShot(100, this, SLOT(showInWindow_impl()));
@@ -440,8 +356,6 @@ void QMacNativeToolBar::showInWindow_impl()
[macWindow setToolbar: d->toolbar];
[macWindow setShowsToolbarButton:YES];
}
-
-#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
void QMacNativeToolBar::removeFromWindow(QWindow *window)
{
if (!window)
@@ -451,23 +365,16 @@ void QMacNativeToolBar::removeFromWindow(QWindow *window)
QGuiApplication::platformNativeInterface()->nativeResourceForWindow("nswindow", window));
[macWindow setToolbar:nil];
}
-#endif
-void QMacNativeToolBar::removeFromWindowForWidget(QWidget *widget)
-{
- if (!widget)
- return;
-
- NSWindow *macWindow = reinterpret_cast<NSWindow*>([reinterpret_cast<NSView*>(widget->winId()) window]);
- [macWindow setToolbar:nil];
-}
void QMacNativeToolBar::setSelectedItem()
{
- setSelectedItem(qobject_cast<QAction*>(sender()));
+// setSelectedItem(qobject_cast<QMacToolButton*>(sender()));
}
-QAction *QMacNativeToolBar::setSelectedItem(QAction *action)
+//### TODO- re-implement
+#if 0
+QMacToolButton *QMacNativeToolBar::setSelectedItem(QMacToolButton *action)
{
// If this action is checkable, find the corresponding NSToolBarItem on the
// real NSToolbar and set it to the selected item if it is checked
@@ -495,7 +402,7 @@ QAction *QMacNativeToolBar::setSelectedItem(QAction *action)
void QMacNativeToolBar::checkSelectableItemSanity()
{
// Find a list of all selectable actions
- QList<QAction*> selectableActions;
+ QList<QMacToolButton*> selectableActions;
foreach (QMacToolButton *button, allowedButtons())
if (button->m_action && button->m_action->isCheckable())
selectableActions.append(button->m_action);
@@ -504,9 +411,9 @@ void QMacNativeToolBar::checkSelectableItemSanity()
if (selectableActions.size() > 1)
{
// The action group that all selectable actions must belong to
- QActionGroup *group = NULL;
+ QMacToolButtonGroup *group = NULL;
- foreach (QAction *action, selectableActions)
+ foreach (QMacToolButton *action, selectableActions)
{
// The first action group we find is "the" action group that
// all selectable actions on the toolbar must belong to
@@ -518,56 +425,46 @@ void QMacNativeToolBar::checkSelectableItemSanity()
// The group not being exclusive is a failure
if (!group || (group != action->actionGroup()) || (group && !group->isExclusive()))
{
- qWarning() << "All selectable actions in a QMacUnifiedToolBar should belong to the same exclusive QActionGroup if there is more than one selectable action.";
+ qWarning() << "All selectable actions in a QMacUnifiedToolBar should belong to the same exclusive QMacToolButtonGroup if there is more than one selectable action.";
break;
}
}
}
}
+#endif
-QAction *QMacNativeToolBar::addAction(const QString &text)
+QMacToolButton *QMacNativeToolBar::addAction(const QString &text)
{
return [d->delegate addActionWithText:&text];
}
-QAction *QMacNativeToolBar::addAction(const QIcon &icon, const QString &text)
+QMacToolButton *QMacNativeToolBar::addAction(const QIcon &icon, const QString &text)
{
return [d->delegate addActionWithText:&text icon:&icon];
}
-QAction *QMacNativeToolBar::addAction(QAction *action)
-{
- connect(action, SIGNAL(triggered()), this, SLOT(setSelectedItem()));
- return setSelectedItem([d->delegate addAction:action]);
-}
-
void QMacNativeToolBar::addSeparator()
{
addStandardItem(QMacToolButton::Space); // No Seprator on OS X.
}
-QAction *QMacNativeToolBar::addStandardItem(QMacToolButton::StandardItem standardItem)
+QMacToolButton *QMacNativeToolBar::addStandardItem(QMacToolButton::StandardItem standardItem)
{
return [d->delegate addStandardItem:standardItem];
}
-QAction *QMacNativeToolBar::addAllowedAction(const QString &text)
+QMacToolButton *QMacNativeToolBar::addAllowedAction(const QString &text)
{
return [d->delegate addAllowedActionWithText:&text];
}
-QAction *QMacNativeToolBar::addAllowedAction(const QIcon &icon, const QString &text)
+QMacToolButton *QMacNativeToolBar::addAllowedAction(const QIcon &icon, const QString &text)
{
return [d->delegate addAllowedActionWithText:&text icon:&icon];
}
-QAction *QMacNativeToolBar::addAllowedAction(QAction *action)
-{
- connect(action, SIGNAL(triggered()), this, SLOT(setSelectedItem()));
- return setSelectedItem([d->delegate addAllowedAction:action]);
-}
-QAction *QMacNativeToolBar::addAllowedStandardItem(QMacToolButton::StandardItem standardItem)
+QMacToolButton *QMacNativeToolBar::addAllowedStandardItem(QMacToolButton::StandardItem standardItem)
{
return [d->delegate addAllowedStandardItem:standardItem];
}
diff --git a/src/macextras/qmacnativetoolbar.h b/src/macextras/qmacnativetoolbar_p.h
index 4c903cf..fe15ea2 100644
--- a/src/macextras/qmacnativetoolbar.h
+++ b/src/macextras/qmacnativetoolbar_p.h
@@ -43,32 +43,21 @@
#define QMACTOOLBAR_H
#include "qmacextrasglobal.h"
-#include "qmactoolbutton.h"
+#include "qmactoolbutton_p.h"
-#include <QString>
-#include <QObject>
-#include <QIcon>
-#include <QVariant>
+#include <QtCore/QString>
+#include <QtCore/QObject>
+#include <QtCore/QVariant>
+#include <QtGui/QIcon>
Q_FORWARD_DECLARE_OBJC_CLASS(NSToolbar);
QT_BEGIN_NAMESPACE
-class QToolBar;
-class QWidget;
-
-class QMacNativeToolBar;
-
-namespace QtMac
-{
-Q_MACEXTRAS_EXPORT QMacNativeToolBar* setNativeToolBar(QToolBar *toolbar, bool on = true);
-Q_MACEXTRAS_EXPORT QMacNativeToolBar* setNativeToolBar(QToolBar *toolbar, const QString &identifier, bool on = true);
-}
-
-class QAction;
class QWindow;
-
+class QMacNativeToolBar;
class QMacNativeToolBarPrivate;
+
class Q_MACEXTRAS_EXPORT QMacNativeToolBar : public QObject
{
friend class QMacNativeToolBarPrivate;
@@ -83,8 +72,6 @@ public:
NSToolbar* nativeToolbar() const;
- static QMacNativeToolBar* fromQToolBar(const QToolBar *toolBar, const QString &identifier = QString());
-
QString identifier() const;
bool isVisible() const;
bool showsBaselineSeparator() const;
@@ -97,24 +84,19 @@ public:
QList<QMacToolButton *> allowedButtons();
void showInWindow(QWindow *window);
- void showInWindowForWidget(QWidget *widget);
- Q_INVOKABLE void showInMainWindow();
void removeFromWindow(QWindow *window);
- void removeFromWindowForWidget(QWidget *widget);
// Add actions to the toolbar
- Q_INVOKABLE QAction *addAction(const QString &text);
- Q_INVOKABLE QAction *addAction(const QIcon &icon, const QString &text);
- Q_INVOKABLE QAction *addAction(QAction *action);
+ Q_INVOKABLE QMacToolButton *addAction(const QString &text);
+ Q_INVOKABLE QMacToolButton *addAction(const QIcon &icon, const QString &text);
Q_INVOKABLE void addSeparator();
- Q_INVOKABLE QAction *addStandardItem(QMacToolButton::StandardItem standardItem);
+ Q_INVOKABLE QMacToolButton *addStandardItem(QMacToolButton::StandardItem standardItem);
// Add actions to the "Customize Toolbar" menu
- Q_INVOKABLE QAction *addAllowedAction(const QString &text);
- Q_INVOKABLE QAction *addAllowedAction(const QIcon &icon, const QString &text);
- Q_INVOKABLE QAction *addAllowedAction(QAction *action);
- Q_INVOKABLE QAction *addAllowedStandardItem(QMacToolButton::StandardItem standardItem);
+ Q_INVOKABLE QMacToolButton *addAllowedAction(const QString &text);
+ Q_INVOKABLE QMacToolButton *addAllowedAction(const QIcon &icon, const QString &text);
+ Q_INVOKABLE QMacToolButton *addAllowedStandardItem(QMacToolButton::StandardItem standardItem);
Q_SIGNALS:
void visibilityChanged(bool visible);
@@ -136,11 +118,14 @@ public Q_SLOTS:
private Q_SLOTS:
void showInWindow_impl();
void setSelectedItem();
- QAction *setSelectedItem(QAction *action);
+//### TODO- re-implement
+#if 0
+ QMacToolButton *setSelectedItem(QMacToolbarAction *action);
void checkSelectableItemSanity();
+#endif
private:
QWindow *targetWindow;
- QWidget *targetWidget;
+ void *targetWidget;
QList<QMacToolButton *> m_buttons;
QList<QMacToolButton *> m_allowedButtons;
QMacNativeToolBarPrivate *d;
diff --git a/src/macextras/qmacnativewidget.h b/src/macextras/qmacnativewidget.h
deleted file mode 100644
index 72c3e8f..0000000
--- a/src/macextras/qmacnativewidget.h
+++ /dev/null
@@ -1,72 +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$
-**
-****************************************************************************/
-
-#ifndef QMACNATIVEWIDGET_H
-#define QMACNATIVEWIDGET_H
-
-#include "qmacextrasglobal.h"
-
-#include <QWidget>
-
-Q_FORWARD_DECLARE_OBJC_CLASS(NSView);
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class Q_MACEXTRAS_EXPORT QMacNativeWidget : public QWidget
-{
- Q_OBJECT
-public:
- QMacNativeWidget(NSView *parentView = 0);
- ~QMacNativeWidget();
-
- NSView *nativeView() const;
-
- QSize sizeHint() const;
-protected:
- void init(NSView *parentView);
- bool event(QEvent *ev);
-};
-
-QT_END_NAMESPACE
-
-#endif // QMACNATIVEWIDGET_H
diff --git a/src/macextras/qmacnativewidget.mm b/src/macextras/qmacnativewidget.mm
deleted file mode 100644
index 305de86..0000000
--- a/src/macextras/qmacnativewidget.mm
+++ /dev/null
@@ -1,148 +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$
-**
-****************************************************************************/
-
-#import <Cocoa/Cocoa.h>
-#include "qmacnativewidget.h"
-#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
-#include <QtGui/QWindow>
-#include <QtGui/QGuiApplication>
-#include <qpa/qplatformnativeinterface.h>
-#endif
-#include <qdebug.h>
-
-
-/*!
- \class QMacNativeWidget
- \brief The QMacNativeWidget class provides a widget for Mac OS X that provides a way to put Qt widgets
- into Cocoa hierarchies.
-
- QMacNativeWidget bridges the gap between NSViews and QWidgets and makes it possible to put a
- hierarchy of Qt widgets into a non-Qt window or view.
-
- QMacNativeWidget pretends it is a window (i.e. isWindow() will return true),
- but it cannot be shown on its own. It needs to be put into a window
- when it is created or later through a native call.
-
- Note that QMacNativeWidget requires knowledge of Cocoa. All it
- does is get the Qt hierarchy into a window not owned by Qt. It is then up
- to the programmer to ensure it is placed correctly in the window and
- responds correctly to events.
-*/
-
-QT_BEGIN_NAMESPACE
-
-#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
-NSView *getEmbeddableView(QWindow *qtWindow)
-{
- // Make sure the platform window is created
- qtWindow->create();
-
- // Inform the window that it's a subwindow of a non-Qt window. This must be
- // done after create() because we need to have a QPlatformWindow instance.
- // The corresponding NSWindow will not be shown and can be deleted later.
- extern QPlatformNativeInterface::NativeResourceForIntegrationFunction resolvePlatformFunction(const QByteArray &functionName);
- typedef void (*SetEmbeddedInForeignViewFunction)(QPlatformWindow *window, bool embedded);
- reinterpret_cast<SetEmbeddedInForeignViewFunction>(resolvePlatformFunction("setEmbeddedInForeignView"))(qtWindow->handle(), true);
-
- // Get the Qt content NSView for the QWindow from the Qt platform plugin
- QPlatformNativeInterface *platformNativeInterface = QGuiApplication::platformNativeInterface();
- NSView *qtView = (NSView *)platformNativeInterface->nativeResourceForWindow("nsview", qtWindow);
- return qtView; // qtView is ready for use.
-}
-#endif
-
-/*!
- Create a QMacNativeWidget with \a parentView as its "superview" (i.e.,
- parent). The \a parentView is a NSView pointer.
-*/
-QMacNativeWidget::QMacNativeWidget(NSView *parentView)
- : QWidget(0)
-{
- Q_UNUSED(parentView);
-
- //d_func()->topData()->embedded = true;
- setPalette(QPalette(Qt::transparent));
- setAttribute(Qt::WA_SetPalette, false);
- setAttribute(Qt::WA_LayoutUsesWidgetRect);
-}
-
-NSView *QMacNativeWidget::nativeView() const
-{
-#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
- winId();
- return getEmbeddableView(windowHandle());
-#else
- return reinterpret_cast<NSView*>(winId());
-#endif
-}
-
-/*!
- Destroy the QMacNativeWidget.
-*/
-QMacNativeWidget::~QMacNativeWidget()
-{
-}
-
-/*!
- \reimp
-*/
-QSize QMacNativeWidget::sizeHint() const
-{
- // QMacNativeWidget really does not have any other choice
- // than to fill its designated area.
-#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
- if (windowHandle())
- return windowHandle()->size();
- return QWidget::sizeHint();
-#else
- NSRect frame = [nativeView() frame];
- return QSize(frame.size.width, frame.size.height);
-#endif
-}
-/*!
- \reimp
-*/
-bool QMacNativeWidget::event(QEvent *ev)
-{
- return QWidget::event(ev);
-}
-
-QT_END_NAMESPACE
diff --git a/src/macextras/qmacpasteboardmime.mm b/src/macextras/qmacpasteboardmime.mm
index 1ad437a..ec8fa7e 100644
--- a/src/macextras/qmacpasteboardmime.mm
+++ b/src/macextras/qmacpasteboardmime.mm
@@ -41,10 +41,9 @@
#include <Cocoa/Cocoa.h>
#include "qmacpasteboardmime.h"
-#include <qpa/qplatformnativeinterface.h>
-#include <qapplication.h>
-#include <qlogging.h>
+#include <QtCore/qlogging.h>
+#include <qpa/qplatformnativeinterface.h>
QT_BEGIN_NAMESPACE
diff --git a/src/macextras/qmactoolbardelegate.mm b/src/macextras/qmactoolbardelegate.mm
index 2a76e00..678423e 100644
--- a/src/macextras/qmactoolbardelegate.mm
+++ b/src/macextras/qmactoolbardelegate.mm
@@ -39,11 +39,14 @@
**
****************************************************************************/
-#include "qmacfunctions.h"
#include "qmactoolbardelegate_p.h"
-#include <QAction>
-#include <QImage>
-#include <QPixmap>
+
+#include <QtGui/QImage>
+#include <QtGui/QPixmap>
+
+#include "qmacfunctions.h"
+#include "qmacfunctions_p.h"
+#include "qmacnativetoolbar_p.h"
QT_USE_NAMESPACE
@@ -73,7 +76,7 @@ NSMutableArray *itemIdentifiers(const QList<QMacToolButton *> &items, bool cullU
return array;
}
-// from qaction.cpp
+// from QMacToolButton.cpp
QString qt_strippedText(QString s)
{
s.remove( QString::fromLatin1("...") );
@@ -116,9 +119,6 @@ QString qt_strippedText(QString s)
NSToolbarItem *item = reinterpret_cast<NSToolbarItem *>(sender);
QString identifier = QtMac::fromNSString([item itemIdentifier]);
QMacToolButton *toolButton = reinterpret_cast<QMacToolButton *>(identifier.toULongLong());
- if (toolButton->m_action) {
- toolButton->m_action->trigger();
- }
toolButton->emitActivated();
}
@@ -129,14 +129,13 @@ QString qt_strippedText(QString s)
const QString identifier = QtMac::fromNSString(itemIdentifier);
QMacToolButton *toolButton = reinterpret_cast<QMacToolButton *>(identifier.toULongLong()); // string -> unisgned long long -> pointer
- NSToolbarItem *toolbarItem= [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdentifier] autorelease];
- [toolbarItem setLabel: QtMac::toNSString(qt_strippedText(toolButton->m_action->iconText()))];
- [toolbarItem setPaletteLabel:[toolbarItem label]];
- [toolbarItem setToolTip: QtMac::toNSString(toolButton->m_action->toolTip())];
+ NSToolbarItem *toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdentifier] autorelease];
+ [toolbarItem setLabel: QtMac::toNSString(toolButton->text())];
+ [toolbarItem setPaletteLabel :[toolbarItem label]];
- QPixmap icon = toolButton->m_action->icon().pixmap(64, 64);
+ QPixmap icon = toolButton->icon().pixmap(64, 64);
if (icon.isNull() == false) {
- [toolbarItem setImage : QtMac::toNSImage(icon)];
+ [toolbarItem setImage: QtMac::toNSImage(icon)];
}
[toolbarItem setTarget : self];
@@ -145,73 +144,53 @@ QString qt_strippedText(QString s)
return toolbarItem;
}
-- (QAction *)addActionWithText:(const QString *)text
+- (QMacToolButton *)addActionWithText:(const QString *)text
{
QIcon nullIcon;
return [self addActionWithText:text icon:&nullIcon];
}
-- (QAction *)addActionWithText:(const QString *)text icon:(const QIcon *)icon
+- (QMacToolButton *)addActionWithText:(const QString *)text icon:(const QIcon *)icon
{
- QAction *action = new QAction(*icon, *text, 0);
- QMacToolButton *button = new QMacToolButton(action);
- button->m_action = action;
+ QMacToolButton *button = new QMacToolButton(0);
+ button->setText(*text);
+ button->setIcon(*icon);
items.append(button);
allowedItems.append(button);
- return action;
+ return button;
}
-- (QAction *)addAction:(QAction *)action
+- (QMacToolButton *)addStandardItem:(QMacToolButton::StandardItem) standardItem
{
- QMacToolButton *button = new QMacToolButton(action);
- button->m_action = action;
- items.append(button);
- allowedItems.append(button);
- return action;
-}
-
-- (QAction *)addStandardItem:(QMacToolButton::StandardItem) standardItem
-{
- QAction *action = new QAction(0);
- QMacToolButton *button = new QMacToolButton(action);
- button->m_action = action;
+ QMacToolButton *button = new QMacToolButton(0);
button->setStandardItem(standardItem);
items.append(button);
allowedItems.append(button);
- return action;
+ return button;
}
-- (QAction *)addAllowedActionWithText:(const QString *)text
+- (QMacToolButton *)addAllowedActionWithText:(const QString *)text
{
QIcon nullIcon;
return [self addAllowedActionWithText:text icon:&nullIcon];
}
-- (QAction *)addAllowedActionWithText:(const QString *)text icon:(const QIcon *)icon
+- (QMacToolButton *)addAllowedActionWithText:(const QString *)text icon:(const QIcon *)icon
{
- QAction *action = new QAction(*icon, *text, 0);
- QMacToolButton *button = new QMacToolButton(action);
- button->m_action = action;
+ QMacToolButton *button = new QMacToolButton(0);
+ button->setText(*text);
+ button->setIcon(*icon);
allowedItems.append(button);
- return action;
+ return button;
}
-- (QAction *)addAllowedAction:(QAction *)action
+- (QMacToolButton *)addAllowedStandardItem:(QMacToolButton::StandardItem)standardItem
{
- QMacToolButton *button = new QMacToolButton(action);
- button->m_action = action;
- allowedItems.append(button);
- return action;
-}
-
-- (QAction *)addAllowedStandardItem:(QMacToolButton::StandardItem)standardItem
-{
- QAction *action = new QAction(0);
- QMacToolButton *button = new QMacToolButton(action);
- button->m_action = action;
+ QMacToolButton *button = new QMacToolButton(0);
button->setStandardItem(standardItem);
allowedItems.append(button);
- return action;
+ return button;
}
+
@end
diff --git a/src/macextras/qmactoolbardelegate_p.h b/src/macextras/qmactoolbardelegate_p.h
index b40a6ed..8c71804 100644
--- a/src/macextras/qmactoolbardelegate_p.h
+++ b/src/macextras/qmactoolbardelegate_p.h
@@ -43,24 +43,17 @@
#define QMACTOOLBARDELEGATE_H
#import <AppKit/AppKit.h>
-#include "qmactoolbutton.h"
-//#include <QString>
-//#include <QHash>
+#include "qmactoolbutton_p.h"
-#include <qglobal.h>
+#include <QtCore/qglobal.h>
#include <private/qcore_mac_p.h>
-
-#include <QAction>
-#include <QIcon>
+#include <QtGui/QIcon>
@interface QT_MANGLE_NAMESPACE(QMacToolbarDelegate) : NSObject <NSToolbarDelegate>
{
@public
QList<QMacToolButton *> items;
QList<QMacToolButton *> allowedItems;
-
-// QHash<QString, QAction*> actions;
-// QHash<QString, QAction*> allowedActions;
}
- (NSToolbarItem *) toolbar: (NSToolbar *)toolbar itemForItemIdentifier: (NSString *) itemIdent willBeInsertedIntoToolbar:(BOOL) willBeInserted;
@@ -68,15 +61,13 @@
- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar*)toolbar;
- (NSArray *)toolbarSelectableItemIdentifiers:(NSToolbar *)toolbar;
-- (QAction *)addActionWithText:(const QString *)text;
-- (QAction *)addActionWithText:(const QString *)text icon:(const QIcon *)icon;
-- (QAction *)addAction:(QAction *)action;
-- (QAction *)addStandardItem:(QMacToolButton::StandardItem)standardItem;
+- (QMacToolButton *)addActionWithText:(const QString *)text;
+- (QMacToolButton *)addActionWithText:(const QString *)text icon:(const QIcon *)icon;
+- (QMacToolButton *)addStandardItem:(QMacToolButton::StandardItem)standardItem;
-- (QAction *)addAllowedActionWithText:(const QString *)text;
-- (QAction *)addAllowedActionWithText:(const QString *)text icon:(const QIcon *)icon;
-- (QAction *)addAllowedAction:(QAction *)action;
-- (QAction *)addAllowedStandardItem:(QMacToolButton::StandardItem)standardItem;
+- (QMacToolButton *)addAllowedActionWithText:(const QString *)text;
+- (QMacToolButton *)addAllowedActionWithText:(const QString *)text icon:(const QIcon *)icon;
+- (QMacToolButton *)addAllowedStandardItem:(QMacToolButton::StandardItem)standardItem;
- (IBAction)itemClicked:(id)sender;
@end
diff --git a/src/macextras/qmactoolbutton.mm b/src/macextras/qmactoolbutton.mm
index cd3b343..ca41f2a 100644
--- a/src/macextras/qmactoolbutton.mm
+++ b/src/macextras/qmactoolbutton.mm
@@ -39,8 +39,7 @@
**
****************************************************************************/
-#include "qmactoolbutton.h"
-#include <QAction>
+#include "qmactoolbutton_p.h"
QT_BEGIN_NAMESPACE
@@ -48,7 +47,6 @@ QMacToolButton::QMacToolButton()
{
m_standardItem = NoItem;
m_selectable = false;
- m_action = 0;
}
QMacToolButton::QMacToolButton(QObject *parent)
@@ -56,7 +54,6 @@ QMacToolButton::QMacToolButton(QObject *parent)
{
m_standardItem = NoItem;
m_selectable = false;
- m_action = 0;
}
QMacToolButton::~QMacToolButton()
@@ -66,18 +63,12 @@ QMacToolButton::~QMacToolButton()
bool QMacToolButton::selectable() const
{
- if (m_action)
- return m_action->isCheckable();
-
return m_selectable;
}
void QMacToolButton::setSelectable(bool selectable)
{
- if (m_action)
- m_action->setCheckable(selectable);
- else
- m_selectable = selectable;
+ m_selectable = selectable;
}
QMacToolButton::StandardItem QMacToolButton::standardItem() const
@@ -90,4 +81,24 @@ void QMacToolButton::setStandardItem(StandardItem standardItem)
m_standardItem = standardItem;
}
+QString QMacToolButton::text() const
+{
+ return m_text;
+}
+
+void QMacToolButton::setText(const QString &text)
+{
+ m_text = text;
+}
+
+QIcon QMacToolButton::icon() const
+{
+ return m_icon;
+}
+
+void QMacToolButton::setIcon(const QIcon &icon)
+{
+ m_icon = icon;
+}
+
QT_END_NAMESPACE
diff --git a/src/macextras/qmactoolbutton.h b/src/macextras/qmactoolbutton_p.h
index e63fefc..584b391 100644
--- a/src/macextras/qmactoolbutton.h
+++ b/src/macextras/qmactoolbutton_p.h
@@ -42,17 +42,19 @@
#ifndef QMACTOOLBUTTON_H
#define QMACTOOLBUTTON_H
-#include <QObject>
+#include <QtCore/QObject>
+#include <QtCore/QString>
+#include <QtGui/QIcon>
QT_BEGIN_NAMESPACE
-class QAction;
-
class QMacToolButton : public QObject
{
Q_OBJECT
Q_PROPERTY(bool selectable READ selectable WRITE setSelectable)
Q_PROPERTY(StandardItem standardItem READ standardItem WRITE setStandardItem)
+ Q_PROPERTY(QString text READ text WRITE setText)
+ Q_PROPERTY(QIcon icon READ icon WRITE setIcon)
Q_ENUMS(StandardItem)
public:
enum StandardItem
@@ -81,13 +83,21 @@ public:
StandardItem standardItem() const;
void setStandardItem(StandardItem standardItem);
+
+ QString text() const;
+ void setText(const QString &text);
+
+ QIcon icon() const;
+ void setIcon(const QIcon &icon);
Q_SIGNALS:
void activated();
private:
bool m_selectable;
StandardItem m_standardItem;
+ QString m_text;
+ QIcon m_icon;
+
public: // (not really public)
- QAction *m_action;
void emitActivated() { Q_EMIT activated(); }
};
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 915b01e..bfa2c7c 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -1,5 +1,6 @@
TEMPLATE = subdirs
SUBDIRS = \
- cmake \
headersclean \
macfunctions
+### FIXME Mac native toolbar is now private in this module
+#SUBDIRS += cmake
diff --git a/tests/auto/macfunctions/tst_qmacfunctions.mm b/tests/auto/macfunctions/tst_qmacfunctions.mm
index f34ed25..591d1dd 100644
--- a/tests/auto/macfunctions/tst_qmacfunctions.mm
+++ b/tests/auto/macfunctions/tst_qmacfunctions.mm
@@ -38,6 +38,7 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+#import <AppKit/AppKit.h>
#include <QString>
#include <QtTest>
@@ -47,47 +48,18 @@
#include <QtWidgets/QMainWindow>
#include <qmacfunctions.h>
-#import <AppKit/AppKit.h>
-
class tst_QMacFunctions : public QObject
{
Q_OBJECT
public:
tst_QMacFunctions();
-
-private slots:
- void testToNSMenu();
};
tst_QMacFunctions::tst_QMacFunctions()
{
}
-void tst_QMacFunctions::testToNSMenu()
-{
- QMainWindow window;
- QMenu *qMenu = new QMenu("Menu", &window);
- QAction *action = new QAction("&Item", &window);
- qMenu->addAction(action);
- window.menuBar()->addMenu(qMenu);
-
- NSMenu *nsMenu = QtMac::toNSMenu(qMenu);
- QVERIFY(nsMenu != NULL);
- QCOMPARE([[nsMenu title] UTF8String], "Menu");
-
- NSMenuItem *item = [nsMenu itemAtIndex:0];
- QCOMPARE([[item title] UTF8String], "Item");
-
- // get NSMenu from QMenuBar
- nsMenu = QtMac::toNSMenu(window.menuBar());
- QVERIFY(nsMenu != NULL);
-
- // the first item should be our menu
- item = [nsMenu itemAtIndex:0];
- QCOMPARE([[item title] UTF8String], "Menu");
-}
-
QTEST_MAIN(tst_QMacFunctions)
#include "tst_qmacfunctions.moc"