From 806dda08d685bc5f9ed71dfe8b61f21848d48066 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 17 Aug 2012 13:23:19 +0200 Subject: Moving .qdoc files under examples/widgets/doc Updated those .qdoc files to refer to the new relative examples emplacement. Images and snippets to be moved later. Also grouped all widgets related examples under widgets. Change-Id: Ib29696e2d8948524537f53e8dda88f9ee26a597f Reviewed-by: J-P Nurmi --- examples/widgets/widgets/orientation/image_a.png | Bin 0 -> 1075 bytes examples/widgets/widgets/orientation/image_b.png | Bin 0 -> 1020 bytes examples/widgets/widgets/orientation/image_c.png | Bin 0 -> 1163 bytes examples/widgets/widgets/orientation/images.qrc | 7 ++ examples/widgets/widgets/orientation/landscape.ui | 114 +++++++++++++++++++++ examples/widgets/widgets/orientation/main.cpp | 55 ++++++++++ .../widgets/widgets/orientation/mainwindow.cpp | 112 ++++++++++++++++++++ examples/widgets/widgets/orientation/mainwindow.h | 75 ++++++++++++++ .../widgets/orientation/orientation.desktop | 11 ++ .../widgets/widgets/orientation/orientation.pro | 31 ++++++ examples/widgets/widgets/orientation/portrait.ui | 61 +++++++++++ 11 files changed, 466 insertions(+) create mode 100644 examples/widgets/widgets/orientation/image_a.png create mode 100644 examples/widgets/widgets/orientation/image_b.png create mode 100644 examples/widgets/widgets/orientation/image_c.png create mode 100644 examples/widgets/widgets/orientation/images.qrc create mode 100644 examples/widgets/widgets/orientation/landscape.ui create mode 100644 examples/widgets/widgets/orientation/main.cpp create mode 100644 examples/widgets/widgets/orientation/mainwindow.cpp create mode 100644 examples/widgets/widgets/orientation/mainwindow.h create mode 100644 examples/widgets/widgets/orientation/orientation.desktop create mode 100644 examples/widgets/widgets/orientation/orientation.pro create mode 100644 examples/widgets/widgets/orientation/portrait.ui (limited to 'examples/widgets/widgets/orientation') diff --git a/examples/widgets/widgets/orientation/image_a.png b/examples/widgets/widgets/orientation/image_a.png new file mode 100644 index 0000000000..4a1a0d3252 Binary files /dev/null and b/examples/widgets/widgets/orientation/image_a.png differ diff --git a/examples/widgets/widgets/orientation/image_b.png b/examples/widgets/widgets/orientation/image_b.png new file mode 100644 index 0000000000..8722d1edee Binary files /dev/null and b/examples/widgets/widgets/orientation/image_b.png differ diff --git a/examples/widgets/widgets/orientation/image_c.png b/examples/widgets/widgets/orientation/image_c.png new file mode 100644 index 0000000000..6c9304fda0 Binary files /dev/null and b/examples/widgets/widgets/orientation/image_c.png differ diff --git a/examples/widgets/widgets/orientation/images.qrc b/examples/widgets/widgets/orientation/images.qrc new file mode 100644 index 0000000000..b258291e6f --- /dev/null +++ b/examples/widgets/widgets/orientation/images.qrc @@ -0,0 +1,7 @@ + + + image_a.png + image_b.png + image_c.png + + diff --git a/examples/widgets/widgets/orientation/landscape.ui b/examples/widgets/widgets/orientation/landscape.ui new file mode 100644 index 0000000000..4616c041dc --- /dev/null +++ b/examples/widgets/widgets/orientation/landscape.ui @@ -0,0 +1,114 @@ + + + LandscapeUI + + + + 0 + 0 + 514 + 265 + + + + Form + + + + + + + 0 + 0 + + + + font-weight: bold; + + + Landscape mode + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + 0 + 0 + + + + Exit + + + + + + + + 0 + 0 + + + + Choices + + + + + + Long description explaining choice A + + + true + + + buttonGroup + + + + + + + Long description explaining choice B + + + buttonGroup + + + + + + + Long description explaining choice C + + + buttonGroup + + + + + + + + + + + 0 + 0 + + + + + + + + + + + + diff --git a/examples/widgets/widgets/orientation/main.cpp b/examples/widgets/widgets/orientation/main.cpp new file mode 100644 index 0000000000..d92ae0c16f --- /dev/null +++ b/examples/widgets/widgets/orientation/main.cpp @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "mainwindow.h" + +//! [0] +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + + MainWindow w; + w.showFullScreen(); + + return a.exec(); +} +//! [0] + diff --git a/examples/widgets/widgets/orientation/mainwindow.cpp b/examples/widgets/widgets/orientation/mainwindow.cpp new file mode 100644 index 0000000000..3acbef12f8 --- /dev/null +++ b/examples/widgets/widgets/orientation/mainwindow.cpp @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "mainwindow.h" +#include "ui_landscape.h" +#include "ui_portrait.h" + +#include +#include + +//! [0] +MainWindow::MainWindow(QWidget *parent) : + QWidget(parent), + landscapeWidget(0), + portraitWidget(0) +{ + landscapeWidget = new QWidget(this); + landscape.setupUi(landscapeWidget); + + portraitWidget = new QWidget(this); + portrait.setupUi(portraitWidget); +//! [0] + +//! [1] + connect(portrait.exitButton, SIGNAL(clicked()), this, SLOT(close())); + connect(landscape.exitButton, SIGNAL(clicked()), this, SLOT(close())); + connect(landscape.buttonGroup, SIGNAL(buttonClicked(QAbstractButton*)), + this, SLOT(onRadioButtonClicked(QAbstractButton*))); + + landscape.radioAButton->setChecked(true); + onRadioButtonClicked(landscape.radioAButton); +//! [1] + +//! [2] +} +//! [2] + +//! [3] +void MainWindow::resizeEvent(QResizeEvent *event) +{ + QSize size = event->size(); + bool isLandscape = size.width() > size.height(); + + if (!isLandscape) + size.transpose(); + + landscapeWidget->setFixedSize(size); + size.transpose(); + portraitWidget->setFixedSize(size); + + landscapeWidget->setVisible(isLandscape); + portraitWidget->setVisible(!isLandscape); +} +//! [3] + +//! [4] +void MainWindow::onRadioButtonClicked(QAbstractButton *button) +{ + QString styleTemplate = "background-image: url(:/image_%1.png);" + "background-repeat: no-repeat;" + "background-position: center center"; + + QString imageStyle(""); + if (button == landscape.radioAButton) + imageStyle = styleTemplate.arg("a"); + else if (button == landscape.radioBButton) + imageStyle = styleTemplate.arg("b"); + else if (button == landscape.radioCButton) + imageStyle = styleTemplate.arg("c"); + + portrait.choiceWidget->setStyleSheet(imageStyle); + landscape.choiceWidget->setStyleSheet(imageStyle); +} +//! [4] + diff --git a/examples/widgets/widgets/orientation/mainwindow.h b/examples/widgets/widgets/orientation/mainwindow.h new file mode 100644 index 0000000000..d0f1b07242 --- /dev/null +++ b/examples/widgets/widgets/orientation/mainwindow.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +#include "ui_landscape.h" +#include "ui_portrait.h" + +QT_BEGIN_NAMESPACE +class QAbstractButton; +QT_END_NAMESPACE + +//! [0] +class MainWindow : public QWidget +{ + Q_OBJECT + +public: + MainWindow(QWidget *parent = 0); + +protected: + void resizeEvent(QResizeEvent *event); + +private slots: + void onRadioButtonClicked(QAbstractButton *button); + +private: + Ui::LandscapeUI landscape; + Ui::PortraitUI portrait; + QWidget *landscapeWidget; + QWidget *portraitWidget; +}; +//! [0] + +#endif // MAINWINDOW_H diff --git a/examples/widgets/widgets/orientation/orientation.desktop b/examples/widgets/widgets/orientation/orientation.desktop new file mode 100644 index 0000000000..7bbf5584d3 --- /dev/null +++ b/examples/widgets/widgets/orientation/orientation.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Terminal=false +Name=Orientation +Exec=/opt/usr/bin/orientation +Icon=orientation +X-Window-Icon= +X-HildonDesk-ShowInToolbar=true +X-Osso-Type=application/x-executable diff --git a/examples/widgets/widgets/orientation/orientation.pro b/examples/widgets/widgets/orientation/orientation.pro new file mode 100644 index 0000000000..36a3e91a9c --- /dev/null +++ b/examples/widgets/widgets/orientation/orientation.pro @@ -0,0 +1,31 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2010-08-04T10:27:31 +# +#------------------------------------------------- + +QT += core gui widgets + +TARGET = orientation +TEMPLATE = app + + +SOURCES += main.cpp\ + mainwindow.cpp + +HEADERS += mainwindow.h + +FORMS += \ + portrait.ui \ + landscape.ui + +RESOURCES += \ + images.qrc + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/widgets/orientation +sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.png *.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/widgets/orientation +INSTALLS += target sources + +simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/widgets/widgets/orientation/portrait.ui b/examples/widgets/widgets/orientation/portrait.ui new file mode 100644 index 0000000000..31a55aff73 --- /dev/null +++ b/examples/widgets/widgets/orientation/portrait.ui @@ -0,0 +1,61 @@ + + + PortraitUI + + + + 0 + 0 + 201 + 300 + + + + Form + + + + + + font-weight: bold; + + + Portrait mode + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + Exit + + + + + + + Switch to landscape mode. In landscape mode you can change visible image. + + + true + + + + + + + + 0 + 0 + + + + + + + + + -- cgit v1.2.3