aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@digia.com>2013-12-09 11:01:42 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-10 11:48:04 +0100
commit6c8706cdfa961a42230048e944613639a3c25536 (patch)
tree0b15fa7642d00524e05ed7b1a8c8a9871ef686d1 /tests
parent2f2ba9d199154732d942aa4c18874e40446919d5 (diff)
Rewrite the Mac native toolbar classes.
Rename the classes to QMacToolBar and QMacToolBarItem. (Keep the Qt-style ToolBar name capitalization.) API-review and document a core set of the API, remove the rest. Missing functionality can be added back later on. Add a simple QWindow-based mactoolbar example that shows the core toolbar functionality. Add manual test for more comprehensive testing. Make the QToolbarItem properties actually work, you can now change the text and icon after the toolbar has been displayed. Update license headers. Change-Id: I99fb207df7f1b3cf0d5df178aa863c77cd372a1f Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/manual/mactoolbar/mactoolbar.pro5
-rw-r--r--tests/manual/mactoolbar/mactoolbar.qrc5
-rw-r--r--tests/manual/mactoolbar/main.cpp54
-rw-r--r--tests/manual/mactoolbar/qtlogo.pngbin0 -> 1478 bytes
-rw-r--r--tests/manual/mactoolbar/toolbarcontrollerwidget.cpp79
-rw-r--r--tests/manual/mactoolbar/toolbarcontrollerwidget.h58
6 files changed, 201 insertions, 0 deletions
diff --git a/tests/manual/mactoolbar/mactoolbar.pro b/tests/manual/mactoolbar/mactoolbar.pro
new file mode 100644
index 0000000..ff1fe0d
--- /dev/null
+++ b/tests/manual/mactoolbar/mactoolbar.pro
@@ -0,0 +1,5 @@
+QT += macextras widgets
+
+HEADERS += toolbarcontrollerwidget.h
+SOURCES += toolbarcontrollerwidget.cpp main.cpp
+RESOURCES += mactoolbar.qrc
diff --git a/tests/manual/mactoolbar/mactoolbar.qrc b/tests/manual/mactoolbar/mactoolbar.qrc
new file mode 100644
index 0000000..04a9419
--- /dev/null
+++ b/tests/manual/mactoolbar/mactoolbar.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>qtlogo.png</file>
+ </qresource>
+</RCC>
diff --git a/tests/manual/mactoolbar/main.cpp b/tests/manual/mactoolbar/main.cpp
new file mode 100644
index 0000000..df72002
--- /dev/null
+++ b/tests/manual/mactoolbar/main.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 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 "toolbarcontrollerwidget.h"
+
+#include <QtGui/QGuiApplication>
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+
+ ToolBarControllerWidget toolbarControllerWidget;
+ toolbarControllerWidget.show();
+
+ return app.exec();
+}
diff --git a/tests/manual/mactoolbar/qtlogo.png b/tests/manual/mactoolbar/qtlogo.png
new file mode 100644
index 0000000..d75936b
--- /dev/null
+++ b/tests/manual/mactoolbar/qtlogo.png
Binary files differ
diff --git a/tests/manual/mactoolbar/toolbarcontrollerwidget.cpp b/tests/manual/mactoolbar/toolbarcontrollerwidget.cpp
new file mode 100644
index 0000000..09148a8
--- /dev/null
+++ b/tests/manual/mactoolbar/toolbarcontrollerwidget.cpp
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 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 "toolbarcontrollerwidget.h"
+
+ToolBarControllerWidget::ToolBarControllerWidget()
+ :QWidget(0)
+{
+
+ setWindowTitle("QMacToolBar Test");
+ resize(400, 200);
+
+ QMacToolBar *toolBar = new QMacToolBar(this);
+
+ QIcon qtIcon(QStringLiteral(":qtlogo.png"));
+ fooItem = toolBar->addItem(qtIcon, QStringLiteral("Foo"));
+ fooItem->setText("foo");
+
+ connect(fooItem, SIGNAL(activated()), this, SLOT(activated()));
+
+ QMacToolBarItem *item5 = toolBar->addAllowedItem(qtIcon, QStringLiteral("AllowedFoo"));
+ connect(item5, SIGNAL(activated()), this, SLOT(activated()));
+
+ QLineEdit *fooItemText = new QLineEdit(this);
+ fooItemText->setText("Foo");
+ fooItemText->move(10, 10);
+ connect(fooItemText, SIGNAL(textChanged(const QString &)), this, SLOT(changeItemText(const QString &)));
+
+ winId();
+ toolBar->attachToWindow(windowHandle());
+}
+
+void ToolBarControllerWidget::activated()
+{
+ qDebug() << "activated" << sender();
+}
+
+void ToolBarControllerWidget::changeItemText(const QString &text)
+{
+ fooItem->setText(text);
+}
diff --git a/tests/manual/mactoolbar/toolbarcontrollerwidget.h b/tests/manual/mactoolbar/toolbarcontrollerwidget.h
new file mode 100644
index 0000000..c949c85
--- /dev/null
+++ b/tests/manual/mactoolbar/toolbarcontrollerwidget.h
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 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 <QtCore/qdebug.h>
+#include <QtWidgets>
+#include <QtMacExtras/QMacToolBar>
+
+class ToolBarControllerWidget : public QWidget
+{
+Q_OBJECT
+public:
+ ToolBarControllerWidget();
+public Q_SLOTS:
+ void activated();
+ void changeItemText(const QString &);
+private:
+ QVBoxLayout *layout;
+ QMacToolBarItem *fooItem;
+};
+