Remove WinCE-specific sipdialog example
Task-number: QTBUG-52590 Task-number: QTBUG-60635 Change-Id: Ie6d59d1431645faf93d1538fe9f5bf1bea9f3014 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>bb10
parent
5ed446102a
commit
c8602f45cc
|
|
@ -1,131 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the examples of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:BSD$
|
||||
** 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 The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** BSD License Usage
|
||||
** Alternatively, 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 The Qt Company Ltd 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 <QtWidgets>
|
||||
|
||||
#include "dialog.h"
|
||||
|
||||
//! [Dialog constructor part1]
|
||||
Dialog::Dialog()
|
||||
{
|
||||
desktopGeometry = QApplication::desktop()->availableGeometry(0);
|
||||
|
||||
setWindowTitle(tr("SIP Dialog Example"));
|
||||
QScrollArea *scrollArea = new QScrollArea(this);
|
||||
QGroupBox *groupBox = new QGroupBox(scrollArea);
|
||||
groupBox->setTitle(tr("SIP Dialog Example"));
|
||||
QGridLayout *gridLayout = new QGridLayout(groupBox);
|
||||
groupBox->setLayout(gridLayout);
|
||||
//! [Dialog constructor part1]
|
||||
|
||||
//! [Dialog constructor part2]
|
||||
QLineEdit* lineEdit = new QLineEdit(groupBox);
|
||||
lineEdit->setText(tr("Open and close the SIP"));
|
||||
lineEdit->setMinimumWidth(220);
|
||||
|
||||
QLabel* label = new QLabel(groupBox);
|
||||
label->setText(tr("This dialog resizes if the SIP is opened"));
|
||||
label->setMinimumWidth(220);
|
||||
|
||||
QPushButton* button = new QPushButton(groupBox);
|
||||
button->setText(tr("Close Dialog"));
|
||||
button->setMinimumWidth(220);
|
||||
//! [Dialog constructor part2]
|
||||
|
||||
//! [Dialog constructor part3]
|
||||
if (desktopGeometry.height() < 400)
|
||||
gridLayout->setVerticalSpacing(80);
|
||||
else
|
||||
gridLayout->setVerticalSpacing(150);
|
||||
|
||||
gridLayout->addWidget(label);
|
||||
gridLayout->addWidget(lineEdit);
|
||||
gridLayout->addWidget(button);
|
||||
//! [Dialog constructor part3]
|
||||
|
||||
//! [Dialog constructor part4]
|
||||
scrollArea->setWidget(groupBox);
|
||||
QHBoxLayout* layout = new QHBoxLayout();
|
||||
layout->addWidget(scrollArea);
|
||||
setLayout(layout);
|
||||
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
//! [Dialog constructor part4]
|
||||
|
||||
//! [Dialog constructor part5]
|
||||
connect(button, &QAbstractButton::clicked, qApp, &QApplication::closeAllWindows);
|
||||
connect(QApplication::desktop(), &QDesktopWidget::workAreaResized,
|
||||
this, &Dialog::desktopResized);
|
||||
}
|
||||
//! [Dialog constructor part5]
|
||||
|
||||
//! [desktopResized() function]
|
||||
void Dialog::desktopResized(int screen)
|
||||
{
|
||||
if (screen != 0)
|
||||
return;
|
||||
reactToSIP();
|
||||
}
|
||||
//! [desktopResized() function]
|
||||
|
||||
//! [reactToSIP() function]
|
||||
void Dialog::reactToSIP()
|
||||
{
|
||||
QRect availableGeometry = QApplication::desktop()->availableGeometry(0);
|
||||
|
||||
if (desktopGeometry != availableGeometry) {
|
||||
if (windowState() | Qt::WindowMaximized)
|
||||
setWindowState(windowState() & ~Qt::WindowMaximized);
|
||||
|
||||
setGeometry(availableGeometry);
|
||||
}
|
||||
|
||||
desktopGeometry = availableGeometry;
|
||||
}
|
||||
//! [reactToSIP() function]
|
||||
|
|
@ -1,73 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the examples of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:BSD$
|
||||
** 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 The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** BSD License Usage
|
||||
** Alternatively, 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 The Qt Company Ltd 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 DIALOG_H
|
||||
#define DIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
//! [Dialog header]
|
||||
class Dialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Dialog();
|
||||
void reactToSIP();
|
||||
|
||||
private:
|
||||
QRect desktopGeometry;
|
||||
|
||||
public slots:
|
||||
void desktopResized(int screen);
|
||||
};
|
||||
//! [Dialog header]
|
||||
|
||||
#endif
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the examples of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:BSD$
|
||||
** 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 The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** BSD License Usage
|
||||
** Alternatively, 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 The Qt Company Ltd 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 <QtWidgets>
|
||||
|
||||
#include "dialog.h"
|
||||
|
||||
//! [main() function]
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
Dialog dialog;
|
||||
return dialog.exec();
|
||||
}
|
||||
//! [main() function]
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
QT += widgets
|
||||
|
||||
HEADERS = dialog.h
|
||||
SOURCES = main.cpp \
|
||||
dialog.cpp
|
||||
|
||||
# install
|
||||
target.path = $$[QT_INSTALL_EXAMPLES]/widgets/dialogs/sipdialog
|
||||
INSTALLS += target
|
||||
|
||||
wince50standard-x86-msvc2005: LIBS += libcmt.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib coredll.lib winsock.lib ws2.lib
|
||||
|
|
@ -1,127 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the documentation of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:FDL$
|
||||
** 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 The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Free Documentation License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Free
|
||||
** Documentation License version 1.3 as published by the Free Software
|
||||
** Foundation and appearing in the file included in the packaging of
|
||||
** this file. Please review the following information to ensure
|
||||
** the GNU Free Documentation License version 1.3 requirements
|
||||
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
/*!
|
||||
\example dialogs/sipdialog
|
||||
\title SIP Dialog Example
|
||||
\ingroup qtce
|
||||
|
||||
\brief The SIP Dialog example shows how to create a dialog that is aware of
|
||||
the Windows Mobile SIP (Software Input Panel) and reacts to it.
|
||||
|
||||
\table
|
||||
\row \li \inlineimage sipdialog-closed.png
|
||||
\li \inlineimage sipdialog-opened.png
|
||||
\endtable
|
||||
|
||||
Sometimes it is necessary for a dialog to take the SIP into account,
|
||||
as the SIP may hide important input widgets. The SIP Dialog Example
|
||||
shows how a \c Dialog object, \c dialog, can be resized accordingly
|
||||
if the SIP is opened, by embedding the contents of \c dialog in a
|
||||
QScrollArea.
|
||||
|
||||
\section1 Dialog Class Definition
|
||||
|
||||
The \c Dialog class is a subclass of QDialog that implements a public
|
||||
slot, \c desktopResized(), and a public function, \c reactToSIP(). Also,
|
||||
it holds a private instance of QRect, \c desktopGeometry.
|
||||
|
||||
\snippet dialogs/sipdialog/dialog.h Dialog header
|
||||
|
||||
\section1 Dialog Class Implementation
|
||||
|
||||
In the constructor of \c Dialog, we start by obtaining the
|
||||
available geometry of the screen with
|
||||
\l{QDesktopWidget::availableGeometry()}{availableGeometry()}. The
|
||||
parameter used is \c 0 to indicate that we require the primary screen.
|
||||
|
||||
\snippet dialogs/sipdialog/dialog.cpp Dialog constructor part1
|
||||
|
||||
We set the window's title to "SIP Dialog Example" and declare a QScrollArea
|
||||
object, \c scrollArea. Next we instantiate a QGroupBox, \c groupBox, with
|
||||
\c scrollArea as its parent. The title of \c groupBox is also set to
|
||||
"SIP Dialog Example". A QGridLayout object, \c gridLayout, is then used
|
||||
as \c{groupBox}'s layout.
|
||||
|
||||
We create a QLineEdit, a QLabel and a QPushButton and we set the
|
||||
\l{QWidget::setMinimumWidth()}{minimumWidth} property to 220 pixels,
|
||||
respectively.
|
||||
|
||||
\snippet dialogs/sipdialog/dialog.cpp Dialog constructor part2
|
||||
|
||||
Also, all three widgets' text are set accordingly. The
|
||||
\l{QGridLayout::setVerticalSpacing()}{verticalSpacing} property of
|
||||
\c gridLayout is set based on the height of \c desktopGeometry. This
|
||||
is to adapt to the different form factors of Windows Mobile. Then, we
|
||||
add our widgets to the layout.
|
||||
|
||||
\snippet dialogs/sipdialog/dialog.cpp Dialog constructor part3
|
||||
|
||||
The \c{scrollArea}'s widget is set to \c groupBox. We use a QHBoxLayout
|
||||
object, \c layout, to contain \c scrollArea. The \c{Dialog}'s layout
|
||||
is set to \c layout and the scroll area's horizontal scroll bar is turned
|
||||
off.
|
||||
|
||||
\snippet dialogs/sipdialog/dialog.cpp Dialog constructor part4
|
||||
|
||||
The following signals are connected to their respective slots:
|
||||
\list
|
||||
\li \c{button}'s \l{QPushButton::pressed()}{pressed()} signal to
|
||||
\l{QApplication}'s \l{QApplication::closeAllWindows()}
|
||||
{closeAllWindows()} slot,
|
||||
\li \l{QDesktopWidget}'s \l{QDesktopWidget::workAreaResized()}
|
||||
{workAreaResized()} signal to \c{dialog}'s \c desktopResized() slot.
|
||||
\endlist
|
||||
|
||||
\snippet dialogs/sipdialog/dialog.cpp Dialog constructor part5
|
||||
|
||||
The \c desktopResized() function accepts an integer, \a screen,
|
||||
corresponding to the screen's index. We only invoke \c reactToSIP()
|
||||
if \a screen is the primary screen (e.g. index = 0).
|
||||
|
||||
\snippet dialogs/sipdialog/dialog.cpp desktopResized() function
|
||||
|
||||
The \c reactToSIP() function resizes \c dialog accordingly if the
|
||||
desktop's available geometry changed vertically, as this change signifies
|
||||
that the SIP may have been opened or closed.
|
||||
|
||||
\snippet dialogs/sipdialog/dialog.cpp reactToSIP() function
|
||||
|
||||
If the height has decreased, we unset the maximized window state.
|
||||
Otherwise, we set the maximized window state. Lastly, we update
|
||||
\c desktopGeometry to the desktop's available geometry.
|
||||
|
||||
\section1 The \c main() function
|
||||
|
||||
The \c main() function for the SIP Dialog example instantiates \c Dialog
|
||||
and invokes its \l{QDialog::exec()}{exec()} function.
|
||||
|
||||
\snippet dialogs/sipdialog/main.cpp main() function
|
||||
|
||||
\note Although this example uses a dialog, the techniques used here apply to
|
||||
all top-level widgets respectively.
|
||||
*/
|
||||
Loading…
Reference in New Issue