summaryrefslogtreecommitdiffstats
path: root/examples/mainwindows
diff options
context:
space:
mode:
Diffstat (limited to 'examples/mainwindows')
-rw-r--r--examples/mainwindows/README9
-rw-r--r--examples/mainwindows/application/application.desktop11
-rw-r--r--examples/mainwindows/application/application.pro16
-rw-r--r--examples/mainwindows/application/application.qrc10
-rw-r--r--examples/mainwindows/application/images/copy.pngbin1338 -> 0 bytes
-rw-r--r--examples/mainwindows/application/images/cut.pngbin1323 -> 0 bytes
-rw-r--r--examples/mainwindows/application/images/new.pngbin852 -> 0 bytes
-rw-r--r--examples/mainwindows/application/images/open.pngbin2073 -> 0 bytes
-rw-r--r--examples/mainwindows/application/images/paste.pngbin1645 -> 0 bytes
-rw-r--r--examples/mainwindows/application/images/save.pngbin1187 -> 0 bytes
-rw-r--r--examples/mainwindows/application/main.cpp57
-rw-r--r--examples/mainwindows/application/mainwindow.cpp392
-rw-r--r--examples/mainwindows/application/mainwindow.h105
-rw-r--r--examples/mainwindows/dockwidgets/dockwidgets.desktop11
-rw-r--r--examples/mainwindows/dockwidgets/dockwidgets.pro15
-rw-r--r--examples/mainwindows/dockwidgets/dockwidgets.qrc8
-rw-r--r--examples/mainwindows/dockwidgets/images/new.pngbin977 -> 0 bytes
-rw-r--r--examples/mainwindows/dockwidgets/images/print.pngbin1732 -> 0 bytes
-rw-r--r--examples/mainwindows/dockwidgets/images/save.pngbin1894 -> 0 bytes
-rw-r--r--examples/mainwindows/dockwidgets/images/undo.pngbin1768 -> 0 bytes
-rw-r--r--examples/mainwindows/dockwidgets/main.cpp52
-rw-r--r--examples/mainwindows/dockwidgets/mainwindow.cpp345
-rw-r--r--examples/mainwindows/dockwidgets/mainwindow.h97
-rw-r--r--examples/mainwindows/mainwindow/colorswatch.cpp746
-rw-r--r--examples/mainwindows/mainwindow/colorswatch.h136
-rw-r--r--examples/mainwindows/mainwindow/main.cpp164
-rw-r--r--examples/mainwindows/mainwindow/mainwindow.cpp509
-rw-r--r--examples/mainwindows/mainwindow/mainwindow.h90
-rw-r--r--examples/mainwindows/mainwindow/mainwindow.pro17
-rw-r--r--examples/mainwindows/mainwindow/mainwindow.qrc8
-rw-r--r--examples/mainwindows/mainwindow/qt.pngbin2037 -> 0 bytes
-rw-r--r--examples/mainwindows/mainwindow/titlebarCenter.pngbin146 -> 0 bytes
-rw-r--r--examples/mainwindows/mainwindow/titlebarLeft.pngbin5148 -> 0 bytes
-rw-r--r--examples/mainwindows/mainwindow/titlebarRight.pngbin2704 -> 0 bytes
-rw-r--r--examples/mainwindows/mainwindow/toolbar.cpp383
-rw-r--r--examples/mainwindows/mainwindow/toolbar.h118
-rw-r--r--examples/mainwindows/mainwindows.pro16
-rw-r--r--examples/mainwindows/mdi/images/copy.pngbin1338 -> 0 bytes
-rw-r--r--examples/mainwindows/mdi/images/cut.pngbin1323 -> 0 bytes
-rw-r--r--examples/mainwindows/mdi/images/new.pngbin852 -> 0 bytes
-rw-r--r--examples/mainwindows/mdi/images/open.pngbin2073 -> 0 bytes
-rw-r--r--examples/mainwindows/mdi/images/paste.pngbin1645 -> 0 bytes
-rw-r--r--examples/mainwindows/mdi/images/save.pngbin1187 -> 0 bytes
-rw-r--r--examples/mainwindows/mdi/main.cpp53
-rw-r--r--examples/mainwindows/mdi/mainwindow.cpp411
-rw-r--r--examples/mainwindows/mdi/mainwindow.h122
-rw-r--r--examples/mainwindows/mdi/mdi.desktop11
-rw-r--r--examples/mainwindows/mdi/mdi.pro16
-rw-r--r--examples/mainwindows/mdi/mdi.qrc10
-rw-r--r--examples/mainwindows/mdi/mdichild.cpp175
-rw-r--r--examples/mainwindows/mdi/mdichild.h76
-rw-r--r--examples/mainwindows/menus/main.cpp51
-rw-r--r--examples/mainwindows/menus/mainwindow.cpp370
-rw-r--r--examples/mainwindows/menus/mainwindow.h124
-rw-r--r--examples/mainwindows/menus/menus.desktop11
-rw-r--r--examples/mainwindows/menus/menus.pro11
-rw-r--r--examples/mainwindows/recentfiles/main.cpp53
-rw-r--r--examples/mainwindows/recentfiles/mainwindow.cpp251
-rw-r--r--examples/mainwindows/recentfiles/mainwindow.h96
-rw-r--r--examples/mainwindows/recentfiles/recentfiles.desktop11
-rw-r--r--examples/mainwindows/recentfiles/recentfiles.pro13
-rw-r--r--examples/mainwindows/sdi/images/copy.pngbin1338 -> 0 bytes
-rw-r--r--examples/mainwindows/sdi/images/cut.pngbin1323 -> 0 bytes
-rw-r--r--examples/mainwindows/sdi/images/new.pngbin852 -> 0 bytes
-rw-r--r--examples/mainwindows/sdi/images/open.pngbin2073 -> 0 bytes
-rw-r--r--examples/mainwindows/sdi/images/paste.pngbin1645 -> 0 bytes
-rw-r--r--examples/mainwindows/sdi/images/save.pngbin1187 -> 0 bytes
-rw-r--r--examples/mainwindows/sdi/main.cpp54
-rw-r--r--examples/mainwindows/sdi/mainwindow.cpp372
-rw-r--r--examples/mainwindows/sdi/mainwindow.h110
-rw-r--r--examples/mainwindows/sdi/sdi.desktop11
-rw-r--r--examples/mainwindows/sdi/sdi.pro14
-rw-r--r--examples/mainwindows/sdi/sdi.qrc10
73 files changed, 0 insertions, 5751 deletions
diff --git a/examples/mainwindows/README b/examples/mainwindows/README
deleted file mode 100644
index b63adee6e3..0000000000
--- a/examples/mainwindows/README
+++ /dev/null
@@ -1,9 +0,0 @@
-All the standard features of application main windows are provided by Qt.
-
-Main windows can have pull down menus, tool bars, and dock windows. These
-separate forms of user input are unified in an integrated action system that
-also supports keyboard shortcuts and accelerator keys in menu items.
-
-
-Documentation for these examples can be found via the Examples
-link in the main Qt documentation.
diff --git a/examples/mainwindows/application/application.desktop b/examples/mainwindows/application/application.desktop
deleted file mode 100644
index b6fab1f1fe..0000000000
--- a/examples/mainwindows/application/application.desktop
+++ /dev/null
@@ -1,11 +0,0 @@
-[Desktop Entry]
-Encoding=UTF-8
-Version=1.0
-Type=Application
-Terminal=false
-Name=Application
-Exec=/opt/usr/bin/application
-Icon=application
-X-Window-Icon=
-X-HildonDesk-ShowInToolbar=true
-X-Osso-Type=application/x-executable
diff --git a/examples/mainwindows/application/application.pro b/examples/mainwindows/application/application.pro
deleted file mode 100644
index ef866a6d5f..0000000000
--- a/examples/mainwindows/application/application.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-HEADERS = mainwindow.h
-SOURCES = main.cpp \
- mainwindow.cpp
-#! [0]
-RESOURCES = application.qrc
-#! [0]
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows/application
-sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS application.pro images
-sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows/application
-INSTALLS += target sources
-
-QT += widgets
-
-simulator: warning(This example might not fully work on Simulator platform)
diff --git a/examples/mainwindows/application/application.qrc b/examples/mainwindows/application/application.qrc
deleted file mode 100644
index 0a776fab4d..0000000000
--- a/examples/mainwindows/application/application.qrc
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>images/copy.png</file>
- <file>images/cut.png</file>
- <file>images/new.png</file>
- <file>images/open.png</file>
- <file>images/paste.png</file>
- <file>images/save.png</file>
-</qresource>
-</RCC>
diff --git a/examples/mainwindows/application/images/copy.png b/examples/mainwindows/application/images/copy.png
deleted file mode 100644
index 2aeb28288f..0000000000
--- a/examples/mainwindows/application/images/copy.png
+++ /dev/null
Binary files differ
diff --git a/examples/mainwindows/application/images/cut.png b/examples/mainwindows/application/images/cut.png
deleted file mode 100644
index 54638e9386..0000000000
--- a/examples/mainwindows/application/images/cut.png
+++ /dev/null
Binary files differ
diff --git a/examples/mainwindows/application/images/new.png b/examples/mainwindows/application/images/new.png
deleted file mode 100644
index 12131b0100..0000000000
--- a/examples/mainwindows/application/images/new.png
+++ /dev/null
Binary files differ
diff --git a/examples/mainwindows/application/images/open.png b/examples/mainwindows/application/images/open.png
deleted file mode 100644
index 45fa2883a7..0000000000
--- a/examples/mainwindows/application/images/open.png
+++ /dev/null
Binary files differ
diff --git a/examples/mainwindows/application/images/paste.png b/examples/mainwindows/application/images/paste.png
deleted file mode 100644
index c14425cad1..0000000000
--- a/examples/mainwindows/application/images/paste.png
+++ /dev/null
Binary files differ
diff --git a/examples/mainwindows/application/images/save.png b/examples/mainwindows/application/images/save.png
deleted file mode 100644
index daba865faf..0000000000
--- a/examples/mainwindows/application/images/save.png
+++ /dev/null
Binary files differ
diff --git a/examples/mainwindows/application/main.cpp b/examples/mainwindows/application/main.cpp
deleted file mode 100644
index 9ff6799574..0000000000
--- a/examples/mainwindows/application/main.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples 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$
-**
-****************************************************************************/
-
-//! [0]
-#include <QApplication>
-
-#include "mainwindow.h"
-
-int main(int argc, char *argv[])
-{
- Q_INIT_RESOURCE(application);
-
- QApplication app(argc, argv);
- app.setOrganizationName("Trolltech");
- app.setApplicationName("Application Example");
- MainWindow mainWin;
- mainWin.show();
- return app.exec();
-}
-//! [0]
diff --git a/examples/mainwindows/application/mainwindow.cpp b/examples/mainwindows/application/mainwindow.cpp
deleted file mode 100644
index 8f60353da9..0000000000
--- a/examples/mainwindows/application/mainwindow.cpp
+++ /dev/null
@@ -1,392 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples 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$
-**
-****************************************************************************/
-
-//! [0]
-#include <QtWidgets>
-
-#include "mainwindow.h"
-//! [0]
-
-//! [1]
-MainWindow::MainWindow()
-//! [1] //! [2]
-{
- textEdit = new QPlainTextEdit;
- setCentralWidget(textEdit);
-
- createActions();
- createMenus();
- createToolBars();
- createStatusBar();
-
- readSettings();
-
- connect(textEdit->document(), SIGNAL(contentsChanged()),
- this, SLOT(documentWasModified()));
-
- setCurrentFile("");
- setUnifiedTitleAndToolBarOnMac(true);
-}
-//! [2]
-
-//! [3]
-void MainWindow::closeEvent(QCloseEvent *event)
-//! [3] //! [4]
-{
- if (maybeSave()) {
- writeSettings();
- event->accept();
- } else {
- event->ignore();
- }
-}
-//! [4]
-
-//! [5]
-void MainWindow::newFile()
-//! [5] //! [6]
-{
- if (maybeSave()) {
- textEdit->clear();
- setCurrentFile("");
- }
-}
-//! [6]
-
-//! [7]
-void MainWindow::open()
-//! [7] //! [8]
-{
- if (maybeSave()) {
- QString fileName = QFileDialog::getOpenFileName(this);
- if (!fileName.isEmpty())
- loadFile(fileName);
- }
-}
-//! [8]
-
-//! [9]
-bool MainWindow::save()
-//! [9] //! [10]
-{
- if (curFile.isEmpty()) {
- return saveAs();
- } else {
- return saveFile(curFile);
- }
-}
-//! [10]
-
-//! [11]
-bool MainWindow::saveAs()
-//! [11] //! [12]
-{
- QString fileName = QFileDialog::getSaveFileName(this);
- if (fileName.isEmpty())
- return false;
-
- return saveFile(fileName);
-}
-//! [12]
-
-//! [13]
-void MainWindow::about()
-//! [13] //! [14]
-{
- QMessageBox::about(this, tr("About Application"),
- tr("The <b>Application</b> example demonstrates how to "
- "write modern GUI applications using Qt, with a menu bar, "
- "toolbars, and a status bar."));
-}
-//! [14]
-
-//! [15]
-void MainWindow::documentWasModified()
-//! [15] //! [16]
-{
- setWindowModified(textEdit->document()->isModified());
-}
-//! [16]
-
-//! [17]
-void MainWindow::createActions()
-//! [17] //! [18]
-{
- newAct = new QAction(QIcon(":/images/new.png"), tr("&New"), this);
- newAct->setShortcuts(QKeySequence::New);
- newAct->setStatusTip(tr("Create a new file"));
- connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));
-
-//! [19]
- openAct = new QAction(QIcon(":/images/open.png"), tr("&Open..."), this);
- openAct->setShortcuts(QKeySequence::Open);
- openAct->setStatusTip(tr("Open an existing file"));
- connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
-//! [18] //! [19]
-
- saveAct = new QAction(QIcon(":/images/save.png"), tr("&Save"), this);
- saveAct->setShortcuts(QKeySequence::Save);
- saveAct->setStatusTip(tr("Save the document to disk"));
- connect(saveAct, SIGNAL(triggered()), this, SLOT(save()));
-
- saveAsAct = new QAction(tr("Save &As..."), this);
- saveAsAct->setShortcuts(QKeySequence::SaveAs);
- saveAsAct->setStatusTip(tr("Save the document under a new name"));
- connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs()));
-
-//! [20]
- exitAct = new QAction(tr("E&xit"), this);
- exitAct->setShortcuts(QKeySequence::Quit);
-//! [20]
- exitAct->setStatusTip(tr("Exit the application"));
- connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
-
-//! [21]
- cutAct = new QAction(QIcon(":/images/cut.png"), tr("Cu&t"), this);
-//! [21]
- cutAct->setShortcuts(QKeySequence::Cut);
- cutAct->setStatusTip(tr("Cut the current selection's contents to the "
- "clipboard"));
- connect(cutAct, SIGNAL(triggered()), textEdit, SLOT(cut()));
-
- copyAct = new QAction(QIcon(":/images/copy.png"), tr("&Copy"), this);
- copyAct->setShortcuts(QKeySequence::Copy);
- copyAct->setStatusTip(tr("Copy the current selection's contents to the "
- "clipboard"));
- connect(copyAct, SIGNAL(triggered()), textEdit, SLOT(copy()));
-
- pasteAct = new QAction(QIcon(":/images/paste.png"), tr("&Paste"), this);
- pasteAct->setShortcuts(QKeySequence::Paste);
- pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current "
- "selection"));
- connect(pasteAct, SIGNAL(triggered()), textEdit, SLOT(paste()));
-
- aboutAct = new QAction(tr("&About"), this);
- aboutAct->setStatusTip(tr("Show the application's About box"));
- connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
-
-//! [22]
- aboutQtAct = new QAction(tr("About &Qt"), this);
- aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
- connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
-//! [22]
-
-//! [23]
- cutAct->setEnabled(false);
-//! [23] //! [24]
- copyAct->setEnabled(false);
- connect(textEdit, SIGNAL(copyAvailable(bool)),
- cutAct, SLOT(setEnabled(bool)));
- connect(textEdit, SIGNAL(copyAvailable(bool)),
- copyAct, SLOT(setEnabled(bool)));
-}
-//! [24]
-
-//! [25] //! [26]
-void MainWindow::createMenus()
-//! [25] //! [27]
-{
- fileMenu = menuBar()->addMenu(tr("&File"));
- fileMenu->addAction(newAct);
-//! [28]
- fileMenu->addAction(openAct);
-//! [28]
- fileMenu->addAction(saveAct);
-//! [26]
- fileMenu->addAction(saveAsAct);
- fileMenu->addSeparator();
- fileMenu->addAction(exitAct);
-
- editMenu = menuBar()->addMenu(tr("&Edit"));
- editMenu->addAction(cutAct);
- editMenu->addAction(copyAct);
- editMenu->addAction(pasteAct);
-
- menuBar()->addSeparator();
-
- helpMenu = menuBar()->addMenu(tr("&Help"));
- helpMenu->addAction(aboutAct);
- helpMenu->addAction(aboutQtAct);
-}
-//! [27]
-
-//! [29] //! [30]
-void MainWindow::createToolBars()
-{
- fileToolBar = addToolBar(tr("File"));
- fileToolBar->addAction(newAct);
-//! [29] //! [31]
- fileToolBar->addAction(openAct);
-//! [31]
- fileToolBar->addAction(saveAct);
-
- editToolBar = addToolBar(tr("Edit"));
- editToolBar->addAction(cutAct);
- editToolBar->addAction(copyAct);
- editToolBar->addAction(pasteAct);
-}
-//! [30]
-
-//! [32]
-void MainWindow::createStatusBar()
-//! [32] //! [33]
-{
- statusBar()->showMessage(tr("Ready"));
-}
-//! [33]
-
-//! [34] //! [35]
-void MainWindow::readSettings()
-//! [34] //! [36]
-{
- QSettings settings("Trolltech", "Application Example");
- QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
- QSize size = settings.value("size", QSize(400, 400)).toSize();
- resize(size);
- move(pos);
-}
-//! [35] //! [36]
-
-//! [37] //! [38]
-void MainWindow::writeSettings()
-//! [37] //! [39]
-{
- QSettings settings("Trolltech", "Application Example");
- settings.setValue("pos", pos());
- settings.setValue("size", size());
-}
-//! [38] //! [39]
-
-//! [40]
-bool MainWindow::maybeSave()
-//! [40] //! [41]
-{
- if (textEdit->document()->isModified()) {
- QMessageBox::StandardButton ret;
- ret = QMessageBox::warning(this, tr("Application"),
- tr("The document has been modified.\n"
- "Do you want to save your changes?"),
- QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
- if (ret == QMessageBox::Save)
- return save();
- else if (ret == QMessageBox::Cancel)
- return false;
- }
- return true;
-}
-//! [41]
-
-//! [42]
-void MainWindow::loadFile(const QString &fileName)
-//! [42] //! [43]
-{
- QFile file(fileName);
- if (!file.open(QFile::ReadOnly | QFile::Text)) {
- QMessageBox::warning(this, tr("Application"),
- tr("Cannot read file %1:\n%2.")
- .arg(fileName)
- .arg(file.errorString()));
- return;
- }
-
- QTextStream in(&file);
-#ifndef QT_NO_CURSOR
- QApplication::setOverrideCursor(Qt::WaitCursor);
-#endif
- textEdit->setPlainText(in.readAll());
-#ifndef QT_NO_CURSOR
- QApplication::restoreOverrideCursor();
-#endif
-
- setCurrentFile(fileName);
- statusBar()->showMessage(tr("File loaded"), 2000);
-}
-//! [43]
-
-//! [44]
-bool MainWindow::saveFile(const QString &fileName)
-//! [44] //! [45]
-{
- QFile file(fileName);
- if (!file.open(QFile::WriteOnly | QFile::Text)) {
- QMessageBox::warning(this, tr("Application"),
- tr("Cannot write file %1:\n%2.")
- .arg(fileName)
- .arg(file.errorString()));
- return false;
- }
-
- QTextStream out(&file);
-#ifndef QT_NO_CURSOR
- QApplication::setOverrideCursor(Qt::WaitCursor);
-#endif
- out << textEdit->toPlainText();
-#ifndef QT_NO_CURSOR
- QApplication::restoreOverrideCursor();
-#endif
-
- setCurrentFile(fileName);
- statusBar()->showMessage(tr("File saved"), 2000);
- return true;
-}
-//! [45]
-
-//! [46]
-void MainWindow::setCurrentFile(const QString &fileName)
-//! [46] //! [47]
-{
- curFile = fileName;
- textEdit->document()->setModified(false);
- setWindowModified(false);
-
- QString shownName = curFile;
- if (curFile.isEmpty())
- shownName = "untitled.txt";
- setWindowFilePath(shownName);
-}
-//! [47]
-
-//! [48]
-QString MainWindow::strippedName(const QString &fullFileName)
-//! [48] //! [49]
-{
- return QFileInfo(fullFileName).fileName();
-}
-//! [49]
diff --git a/examples/mainwindows/application/mainwindow.h b/examples/mainwindows/application/mainwindow.h
deleted file mode 100644
index 7f429e0ea3..0000000000
--- a/examples/mainwindows/application/mainwindow.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples 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 <QMainWindow>
-
-QT_BEGIN_NAMESPACE
-class QAction;
-class QMenu;
-class QPlainTextEdit;
-QT_END_NAMESPACE
-
-//! [0]
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- MainWindow();
-
-protected:
- void closeEvent(QCloseEvent *event);
-
-private slots:
- void newFile();
- void open();
- bool save();
- bool saveAs();
- void about();
- void documentWasModified();
-
-private:
- void createActions();
- void createMenus();
- void createToolBars();
- void createStatusBar();
- void readSettings();
- void writeSettings();
- bool maybeSave();
- void loadFile(const QString &fileName);
- bool saveFile(const QString &fileName);
- void setCurrentFile(const QString &fileName);
- QString strippedName(const QString &fullFileName);
-
- QPlainTextEdit *textEdit;
- QString curFile;
-
- QMenu *fileMenu;
- QMenu *editMenu;
- QMenu *helpMenu;
- QToolBar *fileToolBar;
- QToolBar *editToolBar;
- QAction *newAct;
- QAction *openAct;
- QAction *saveAct;
- QAction *saveAsAct;
- QAction *exitAct;
- QAction *cutAct;
- QAction *copyAct;
- QAction *pasteAct;
- QAction *aboutAct;
- QAction *aboutQtAct;
-};
-//! [0]
-
-#endif
diff --git a/examples/mainwindows/dockwidgets/dockwidgets.desktop b/examples/mainwindows/dockwidgets/dockwidgets.desktop
deleted file mode 100644
index 1f57cb613b..0000000000
--- a/examples/mainwindows/dockwidgets/dockwidgets.desktop
+++ /dev/null
@@ -1,11 +0,0 @@
-[Desktop Entry]
-Encoding=UTF-8
-Version=1.0
-Type=Application
-Terminal=false
-Name=Dock Widgets
-Exec=/opt/usr/bin/dockwidgets
-Icon=dockwidgets
-X-Window-Icon=
-X-HildonDesk-ShowInToolbar=true
-X-Osso-Type=application/x-executable
diff --git a/examples/mainwindows/dockwidgets/dockwidgets.pro b/examples/mainwindows/dockwidgets/dockwidgets.pro
deleted file mode 100644
index 7e0da2496e..0000000000
--- a/examples/mainwindows/dockwidgets/dockwidgets.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-HEADERS = mainwindow.h
-SOURCES = main.cpp \
- mainwindow.cpp
-RESOURCES = dockwidgets.qrc
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows/dockwidgets
-sources.files = $$SOURCES $$HEADERS $$RESOURCES dockwidgets.pro images
-sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows/dockwidgets
-INSTALLS += target sources
-
-QT += widgets
-!isEmpty(QT.printsupport.name): QT += printsupport
-
-simulator: warning(This example might not fully work on Simulator platform)
diff --git a/examples/mainwindows/dockwidgets/dockwidgets.qrc b/examples/mainwindows/dockwidgets/dockwidgets.qrc
deleted file mode 100644
index 968feac7ea..0000000000
--- a/examples/mainwindows/dockwidgets/dockwidgets.qrc
+++ /dev/null
@@ -1,8 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>images/new.png</file>
- <file>images/print.png</file>
- <file>images/save.png</file>
- <file>images/undo.png</file>
-</qresource>
-</RCC>
diff --git a/examples/mainwindows/dockwidgets/images/new.png b/examples/mainwindows/dockwidgets/images/new.png
deleted file mode 100644
index dd795cfffc..0000000000
--- a/examples/mainwindows/dockwidgets/images/new.png
+++ /dev/null
Binary files differ
diff --git a/examples/mainwindows/dockwidgets/images/print.png b/examples/mainwindows/dockwidgets/images/print.png
deleted file mode 100644
index 2afb769ee2..0000000000
--- a/examples/mainwindows/dockwidgets/images/print.png
+++ /dev/null
Binary files differ
diff --git a/examples/mainwindows/dockwidgets/images/save.png b/examples/mainwindows/dockwidgets/images/save.png
deleted file mode 100644
index 46eac82ad1..0000000000
--- a/examples/mainwindows/dockwidgets/images/save.png
+++ /dev/null
Binary files differ
diff --git a/examples/mainwindows/dockwidgets/images/undo.png b/examples/mainwindows/dockwidgets/images/undo.png
deleted file mode 100644
index eee23d24a3..0000000000
--- a/examples/mainwindows/dockwidgets/images/undo.png
+++ /dev/null
Binary files differ
diff --git a/examples/mainwindows/dockwidgets/main.cpp b/examples/mainwindows/dockwidgets/main.cpp
deleted file mode 100644
index 19deafbb86..0000000000
--- a/examples/mainwindows/dockwidgets/main.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples 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 <QApplication>
-
-#include "mainwindow.h"
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- Q_INIT_RESOURCE(dockwidgets);
- MainWindow mainWin;
- mainWin.show();
- return app.exec();
-}
diff --git a/examples/mainwindows/dockwidgets/mainwindow.cpp b/examples/mainwindows/dockwidgets/mainwindow.cpp
deleted file mode 100644
index da01d56502..0000000000
--- a/examples/mainwindows/dockwidgets/mainwindow.cpp
+++ /dev/null
@@ -1,345 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples 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$
-**
-****************************************************************************/
-
-//! [0]
-#include <QtWidgets>
-#ifndef QT_NO_PRINTDIALOG
-#include <QtPrintSupport>
-#endif
-
-#include "mainwindow.h"
-//! [0]
-
-//! [1]
-MainWindow::MainWindow()
-{
- textEdit = new QTextEdit;
- setCentralWidget(textEdit);
-
- createActions();
- createMenus();
- createToolBars();
- createStatusBar();
- createDockWindows();
-
- setWindowTitle(tr("Dock Widgets"));
-
- newLetter();
- setUnifiedTitleAndToolBarOnMac(true);
-}
-//! [1]
-
-//! [2]
-void MainWindow::newLetter()
-{
- textEdit->clear();
-
- QTextCursor cursor(textEdit->textCursor());
- cursor.movePosition(QTextCursor::Start);
- QTextFrame *topFrame = cursor.currentFrame();
- QTextFrameFormat topFrameFormat = topFrame->frameFormat();
- topFrameFormat.setPadding(16);
- topFrame->setFrameFormat(topFrameFormat);
-
- QTextCharFormat textFormat;
- QTextCharFormat boldFormat;
- boldFormat.setFontWeight(QFont::Bold);
- QTextCharFormat italicFormat;
- italicFormat.setFontItalic(true);
-
- QTextTableFormat tableFormat;
- tableFormat.setBorder(1);
- tableFormat.setCellPadding(16);
- tableFormat.setAlignment(Qt::AlignRight);
- cursor.insertTable(1, 1, tableFormat);
- cursor.insertText("The Firm", boldFormat);
- cursor.insertBlock();
- cursor.insertText("321 City Street", textFormat);
- cursor.insertBlock();
- cursor.insertText("Industry Park");
- cursor.insertBlock();
- cursor.insertText("Some Country");
- cursor.setPosition(topFrame->lastPosition());
- cursor.insertText(QDate::currentDate().toString("d MMMM yyyy"), textFormat);
- cursor.insertBlock();
- cursor.insertBlock();
- cursor.insertText("Dear ", textFormat);
- cursor.insertText("NAME", italicFormat);
- cursor.insertText(",", textFormat);
- for (int i = 0; i < 3; ++i)
- cursor.insertBlock();
- cursor.insertText(tr("Yours sincerely,"), textFormat);
- for (int i = 0; i < 3; ++i)
- cursor.insertBlock();
- cursor.insertText("The Boss", textFormat);
- cursor.insertBlock();
- cursor.insertText("ADDRESS", italicFormat);
-}
-//! [2]
-
-//! [3]
-void MainWindow::print()
-{
-#ifndef QT_NO_PRINTDIALOG
- QTextDocument *document = textEdit->document();
- QPrinter printer;
-
- QPrintDialog *dlg = new QPrintDialog(&printer, this);
- if (dlg->exec() != QDialog::Accepted)
- return;
-
- document->print(&printer);
-
- statusBar()->showMessage(tr("Ready"), 2000);
-#endif
-}
-//! [3]
-
-//! [4]
-void MainWindow::save()
-{
- QString fileName = QFileDialog::getSaveFileName(this,
- tr("Choose a file name"), ".",
- tr("HTML (*.html *.htm)"));
- if (fileName.isEmpty())
- return;
- QFile file(fileName);
- if (!file.open(QFile::WriteOnly | QFile::Text)) {
- QMessageBox::warning(this, tr("Dock Widgets"),
- tr("Cannot write file %1:\n%2.")
- .arg(fileName)
- .arg(file.errorString()));
- return;
- }
-
- QTextStream out(&file);
- QApplication::setOverrideCursor(Qt::WaitCursor);
- out << textEdit->toHtml();
- QApplication::restoreOverrideCursor();
-
- statusBar()->showMessage(tr("Saved '%1'").arg(fileName), 2000);
-}
-//! [4]
-
-//! [5]
-void MainWindow::undo()
-{
- QTextDocument *document = textEdit->document();
- document->undo();
-}
-//! [5]
-
-//! [6]
-void MainWindow::insertCustomer(const QString &customer)
-{
- if (customer.isEmpty())
- return;
- QStringList customerList = customer.split(", ");
- QTextDocument *document = textEdit->document();
- QTextCursor cursor = document->find("NAME");
- if (!cursor.isNull()) {
- cursor.beginEditBlock();
- cursor.insertText(customerList.at(0));
- QTextCursor oldcursor = cursor;
- cursor = document->find("ADDRESS");
- if (!cursor.isNull()) {
- for (int i = 1; i < customerList.size(); ++i) {
- cursor.insertBlock();
- cursor.insertText(customerList.at(i));
- }
- cursor.endEditBlock();
- }
- else
- oldcursor.endEditBlock();
- }
-}
-//! [6]
-
-//! [7]
-void MainWindow::addParagraph(const QString &paragraph)
-{
- if (paragraph.isEmpty())
- return;
- QTextDocument *document = textEdit->document();
- QTextCursor cursor = document->find(tr("Yours sincerely,"));
- if (cursor.isNull())
- return;
- cursor.beginEditBlock();
- cursor.movePosition(QTextCursor::PreviousBlock, QTextCursor::MoveAnchor, 2);
- cursor.insertBlock();
- cursor.insertText(paragraph);
- cursor.insertBlock();
- cursor.endEditBlock();
-
-}
-//! [7]
-
-void MainWindow::about()
-{
- QMessageBox::about(this, tr("About Dock Widgets"),
- tr("The <b>Dock Widgets</b> example demonstrates how to "
- "use Qt's dock widgets. You can enter your own text, "
- "click a customer to add a customer name and "
- "address, and click standard paragraphs to add them."));
-}
-
-void MainWindow::createActions()
-{
- newLetterAct = new QAction(QIcon(":/images/new.png"), tr("&New Letter"),
- this);
- newLetterAct->setShortcuts(QKeySequence::New);
- newLetterAct->setStatusTip(tr("Create a new form letter"));
- connect(newLetterAct, SIGNAL(triggered()), this, SLOT(newLetter()));
-
- saveAct = new QAction(QIcon(":/images/save.png"), tr("&Save..."), this);
- saveAct->setShortcuts(QKeySequence::Save);
- saveAct->setStatusTip(tr("Save the current form letter"));
- connect(saveAct, SIGNAL(triggered()), this, SLOT(save()));
-
- printAct = new QAction(QIcon(":/images/print.png"), tr("&Print..."), this);
- printAct->setShortcuts(QKeySequence::Print);
- printAct->setStatusTip(tr("Print the current form letter"));
- connect(printAct, SIGNAL(triggered()), this, SLOT(print()));
-
- undoAct = new QAction(QIcon(":/images/undo.png"), tr("&Undo"), this);
- undoAct->setShortcuts(QKeySequence::Undo);
- undoAct->setStatusTip(tr("Undo the last editing action"));
- connect(undoAct, SIGNAL(triggered()), this, SLOT(undo()));
-
- quitAct = new QAction(tr("&Quit"), this);
- quitAct->setShortcuts(QKeySequence::Quit);
- quitAct->setStatusTip(tr("Quit the application"));
- connect(quitAct, SIGNAL(triggered()), this, SLOT(close()));
-
- aboutAct = new QAction(tr("&About"), this);
- aboutAct->setStatusTip(tr("Show the application's About box"));
- connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
-
- aboutQtAct = new QAction(tr("About &Qt"), this);
- aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
- connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
-}
-
-void MainWindow::createMenus()
-{
- fileMenu = menuBar()->addMenu(tr("&File"));
- fileMenu->addAction(newLetterAct);
- fileMenu->addAction(saveAct);
- fileMenu->addAction(printAct);
- fileMenu->addSeparator();
- fileMenu->addAction(quitAct);
-
- editMenu = menuBar()->addMenu(tr("&Edit"));
- editMenu->addAction(undoAct);
-
- viewMenu = menuBar()->addMenu(tr("&View"));
-
- menuBar()->addSeparator();
-
- helpMenu = menuBar()->addMenu(tr("&Help"));
- helpMenu->addAction(aboutAct);
- helpMenu->addAction(aboutQtAct);
-}
-
-void MainWindow::createToolBars()
-{
- fileToolBar = addToolBar(tr("File"));
- fileToolBar->addAction(newLetterAct);
- fileToolBar->addAction(saveAct);
- fileToolBar->addAction(printAct);
-
- editToolBar = addToolBar(tr("Edit"));
- editToolBar->addAction(undoAct);
-}
-
-//! [8]
-void MainWindow::createStatusBar()
-{
- statusBar()->showMessage(tr("Ready"));
-}
-//! [8]
-
-//! [9]
-void MainWindow::createDockWindows()
-{
- QDockWidget *dock = new QDockWidget(tr("Customers"), this);
- dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
- customerList = new QListWidget(dock);
- customerList->addItems(QStringList()
- << "John Doe, Harmony Enterprises, 12 Lakeside, Ambleton"
- << "Jane Doe, Memorabilia, 23 Watersedge, Beaton"
- << "Tammy Shea, Tiblanka, 38 Sea Views, Carlton"
- << "Tim Sheen, Caraba Gifts, 48 Ocean Way, Deal"
- << "Sol Harvey, Chicos Coffee, 53 New Springs, Eccleston"
- << "Sally Hobart, Tiroli Tea, 67 Long River, Fedula");
- dock->setWidget(customerList);
- addDockWidget(Qt::RightDockWidgetArea, dock);
- viewMenu->addAction(dock->toggleViewAction());
-
- dock = new QDockWidget(tr("Paragraphs"), this);
- paragraphsList = new QListWidget(dock);
- paragraphsList->addItems(QStringList()
- << "Thank you for your payment which we have received today."
- << "Your order has been dispatched and should be with you "
- "within 28 days."
- << "We have dispatched those items that were in stock. The "
- "rest of your order will be dispatched once all the "
- "remaining items have arrived at our warehouse. No "
- "additional shipping charges will be made."
- << "You made a small overpayment (less than $5) which we "
- "will keep on account for you, or return at your request."
- << "You made a small underpayment (less than $1), but we have "
- "sent your order anyway. We'll add this underpayment to "
- "your next bill."
- << "Unfortunately you did not send enough money. Please remit "
- "an additional $. Your order will be dispatched as soon as "
- "the complete amount has been received."
- << "You made an overpayment (more than $5). Do you wish to "
- "buy more items, or should we return the excess to you?");
- dock->setWidget(paragraphsList);
- addDockWidget(Qt::RightDockWidgetArea, dock);
- viewMenu->addAction(dock->toggleViewAction());
-
- connect(customerList, SIGNAL(currentTextChanged(QString)),
- this, SLOT(insertCustomer(QString)));
- connect(paragraphsList, SIGNAL(currentTextChanged(QString)),
- this, SLOT(addParagraph(QString)));
-}
-//! [9]
diff --git a/examples/mainwindows/dockwidgets/mainwindow.h b/examples/mainwindows/dockwidgets/mainwindow.h
deleted file mode 100644
index 9f3eeb4e6b..0000000000
--- a/examples/mainwindows/dockwidgets/mainwindow.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples 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 <QMainWindow>
-
-QT_BEGIN_NAMESPACE
-class QAction;
-class QListWidget;
-class QMenu;
-class QTextEdit;
-QT_END_NAMESPACE
-
-//! [0]
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- MainWindow();
-
-private slots:
- void newLetter();
- void save();
- void print();
- void undo();
- void about();
- void insertCustomer(const QString &customer);
- void addParagraph(const QString &paragraph);
-
-private:
- void createActions();
- void createMenus();
- void createToolBars();
- void createStatusBar();
- void createDockWindows();
-
- QTextEdit *textEdit;
- QListWidget *customerList;
- QListWidget *paragraphsList;
-
- QMenu *fileMenu;
- QMenu *editMenu;
- QMenu *viewMenu;
- QMenu *helpMenu;
- QToolBar *fileToolBar;
- QToolBar *editToolBar;
- QAction *newLetterAct;
- QAction *saveAct;
- QAction *printAct;
- QAction *undoAct;
- QAction *aboutAct;
- QAction *aboutQtAct;
- QAction *quitAct;
-};
-//! [0]
-
-#endif
diff --git a/examples/mainwindows/mainwindow/colorswatch.cpp b/examples/mainwindows/mainwindow/colorswatch.cpp
deleted file mode 100644
index c84669d377..0000000000
--- a/examples/mainwindows/mainwindow/colorswatch.cpp
+++ /dev/null
@@ -1,746 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "colorswatch.h"
-
-#include <QAction>
-#include <QtEvents>
-#include <QFrame>
-#include <QMainWindow>
-#include <QMenu>
-#include <QPainter>
-#include <QImage>
-#include <QColor>
-#include <QDialog>
-#include <QGridLayout>
-#include <QSpinBox>
-#include <QLabel>
-#include <QPainterPath>
-#include <QPushButton>
-#include <QHBoxLayout>
-#include <QBitmap>
-#include <QtDebug>
-
-#undef DEBUG_SIZEHINTS
-
-QColor bgColorForName(const QString &name)
-{
- if (name == "Black")
- return QColor("#D8D8D8");
- else if (name == "White")
- return QColor("#F1F1F1");
- else if (name == "Red")
- return QColor("#F1D8D8");
- else if (name == "Green")
- return QColor("#D8E4D8");
- else if (name == "Blue")
- return QColor("#D8D8F1");
- else if (name == "Yellow")
- return QColor("#F1F0D8");
- return QColor(name).light(110);
-}
-
-QColor fgColorForName(const QString &name)
-{
- if (name == "Black")
- return QColor("#6C6C6C");
- else if (name == "White")
- return QColor("#F8F8F8");
- else if (name == "Red")
- return QColor("#F86C6C");
- else if (name == "Green")
- return QColor("#6CB26C");
- else if (name == "Blue")
- return QColor("#6C6CF8");
- else if (name == "Yellow")
- return QColor("#F8F76C");
- return QColor(name);
-}
-
-class ColorDock : public QFrame
-{
- Q_OBJECT
-public:
- ColorDock(const QString &c, QWidget *parent);
-
- virtual QSize sizeHint() const;
- virtual QSize minimumSizeHint() const;
-
- void setCustomSizeHint(const QSize &size);
-
-public slots:
- void changeSizeHints();
-
-protected:
- void paintEvent(QPaintEvent *);
- QString color;
- QSize szHint, minSzHint;
-};
-
-ColorDock::ColorDock(const QString &c, QWidget *parent)
- : QFrame(parent) , color(c)
-{
- QFont font = this->font();
- font.setPointSize(8);
- setFont(font);
- szHint = QSize(-1, -1);
- minSzHint = QSize(125, 75);
-}
-
-QSize ColorDock::sizeHint() const
-{
- return szHint;
-}
-
-QSize ColorDock::minimumSizeHint() const
-{
- return minSzHint;
-}
-
-void ColorDock::paintEvent(QPaintEvent *)
-{
- QPainter p(this);
- p.setRenderHint(QPainter::Antialiasing);
- p.fillRect(rect(), bgColorForName(color));
-
- p.save();
-
- extern void render_qt_text(QPainter *, int, int, const QColor &);
- render_qt_text(&p, width(), height(), fgColorForName(color));
-
- p.restore();
-
-#ifdef DEBUG_SIZEHINTS
- p.setRenderHint(QPainter::Antialiasing, false);
-
- QSize sz = size();
- QSize szHint = sizeHint();
- QSize minSzHint = minimumSizeHint();
- QSize maxSz = maximumSize();
- QString text = QString::fromLatin1("sz: %1x%2\nszHint: %3x%4\nminSzHint: %5x%6\n"
- "maxSz: %8x%9")
- .arg(sz.width()).arg(sz.height())
- .arg(szHint.width()).arg(szHint.height())
- .arg(minSzHint.width()).arg(minSzHint.height())
- .arg(maxSz.width()).arg(maxSz.height());
-
- QRect r = fontMetrics().boundingRect(rect(), Qt::AlignLeft|Qt::AlignTop, text);
- r.adjust(-2, -2, 1, 1);
- p.translate(4, 4);
- QColor bg = Qt::yellow;
- bg.setAlpha(120);
- p.setBrush(bg);
- p.setPen(Qt::black);
- p.drawRect(r);
- p.drawText(rect(), Qt::AlignLeft|Qt::AlignTop, text);
-#endif // DEBUG_SIZEHINTS
-}
-
-static QSpinBox *createSpinBox(int value, QWidget *parent, int max = 1000)
-{
- QSpinBox *result = new QSpinBox(parent);
- result->setMinimum(-1);
- result->setMaximum(max);
- result->setValue(value);
- return result;
-}
-
-void ColorDock::changeSizeHints()
-{
- QDialog dialog(this);
- dialog.setWindowTitle(color);
-
- QVBoxLayout *topLayout = new QVBoxLayout(&dialog);
-
- QGridLayout *inputLayout = new QGridLayout();
- topLayout->addLayout(inputLayout);
-
- inputLayout->addWidget(new QLabel(tr("Size Hint:"), &dialog), 0, 0);
- inputLayout->addWidget(new QLabel(tr("Min Size Hint:"), &dialog), 1, 0);
- inputLayout->addWidget(new QLabel(tr("Max Size:"), &dialog), 2, 0);
- inputLayout->addWidget(new QLabel(tr("Dockwgt Max Size:"), &dialog), 3, 0);
-
- QSpinBox *szHintW = createSpinBox(szHint.width(), &dialog);
- inputLayout->addWidget(szHintW, 0, 1);
- QSpinBox *szHintH = createSpinBox(szHint.height(), &dialog);
- inputLayout->addWidget(szHintH, 0, 2);
-
- QSpinBox *minSzHintW = createSpinBox(minSzHint.width(), &dialog);
- inputLayout->addWidget(minSzHintW, 1, 1);
- QSpinBox *minSzHintH = createSpinBox(minSzHint.height(), &dialog);
- inputLayout->addWidget(minSzHintH, 1, 2);
-
- QSize maxSz = maximumSize();
- QSpinBox *maxSzW = createSpinBox(maxSz.width(), &dialog, QWIDGETSIZE_MAX);
- inputLayout->addWidget(maxSzW, 2, 1);
- QSpinBox *maxSzH = createSpinBox(maxSz.height(), &dialog, QWIDGETSIZE_MAX);
- inputLayout->addWidget(maxSzH, 2, 2);
-
- QSize dwMaxSz = parentWidget()->maximumSize();
- QSpinBox *dwMaxSzW = createSpinBox(dwMaxSz.width(), &dialog, QWIDGETSIZE_MAX);
- inputLayout->addWidget(dwMaxSzW, 3, 1);
- QSpinBox *dwMaxSzH = createSpinBox(dwMaxSz.height(), &dialog, QWIDGETSIZE_MAX);
- inputLayout->addWidget(dwMaxSzH, 3, 2);
-
- inputLayout->setColumnStretch(1, 1);
- inputLayout->setColumnStretch(2, 1);
-
- topLayout->addStretch();
-
- QHBoxLayout *buttonBox = new QHBoxLayout();
- topLayout->addLayout(buttonBox);
-
- QPushButton *okButton = new QPushButton(tr("Ok"), &dialog);
- QPushButton *cancelButton = new QPushButton(tr("Cancel"), &dialog);
- connect(okButton, SIGNAL(clicked()), &dialog, SLOT(accept()));
- connect(cancelButton, SIGNAL(clicked()), &dialog, SLOT(reject()));
- buttonBox->addStretch();
- buttonBox->addWidget(cancelButton);
- buttonBox->addWidget(okButton);
-
-
- if (!dialog.exec())
- return;
-
- szHint = QSize(szHintW->value(), szHintH->value());
- minSzHint = QSize(minSzHintW->value(), minSzHintH->value());
- maxSz = QSize(maxSzW->value(), maxSzH->value());
- setMaximumSize(maxSz);
- dwMaxSz = QSize(dwMaxSzW->value(), dwMaxSzH->value());
- parentWidget()->setMaximumSize(dwMaxSz);
- updateGeometry();
- update();
-}
-
-void ColorDock::setCustomSizeHint(const QSize &size)
-{
- szHint = size;
- updateGeometry();
-}
-
-ColorSwatch::ColorSwatch(const QString &colorName, QWidget *parent, Qt::WindowFlags flags)
- : QDockWidget(parent, flags)
-{
- setObjectName(colorName + QLatin1String(" Dock Widget"));
- setWindowTitle(objectName() + QLatin1String(" [*]"));
-
- QFrame *swatch = new ColorDock(colorName, this);
- swatch->setFrameStyle(QFrame::Box | QFrame::Sunken);
-
- setWidget(swatch);
-
- changeSizeHintsAction = new QAction(tr("Change Size Hints"), this);
- connect(changeSizeHintsAction, SIGNAL(triggered()), swatch, SLOT(changeSizeHints()));
-
- closableAction = new QAction(tr("Closable"), this);
- closableAction->setCheckable(true);
- connect(closableAction, SIGNAL(triggered(bool)), SLOT(changeClosable(bool)));
-
- movableAction = new QAction(tr("Movable"), this);
- movableAction->setCheckable(true);
- connect(movableAction, SIGNAL(triggered(bool)), SLOT(changeMovable(bool)));
-
- floatableAction = new QAction(tr("Floatable"), this);
- floatableAction->setCheckable(true);
- connect(floatableAction, SIGNAL(triggered(bool)), SLOT(changeFloatable(bool)));
-
- verticalTitleBarAction = new QAction(tr("Vertical title bar"), this);
- verticalTitleBarAction->setCheckable(true);
- connect(verticalTitleBarAction, SIGNAL(triggered(bool)),
- SLOT(changeVerticalTitleBar(bool)));
-
- floatingAction = new QAction(tr("Floating"), this);
- floatingAction->setCheckable(true);
- connect(floatingAction, SIGNAL(triggered(bool)), SLOT(changeFloating(bool)));
-
- allowedAreasActions = new QActionGroup(this);
- allowedAreasActions->setExclusive(false);
-
- allowLeftAction = new QAction(tr("Allow on Left"), this);
- allowLeftAction->setCheckable(true);
- connect(allowLeftAction, SIGNAL(triggered(bool)), SLOT(allowLeft(bool)));
-
- allowRightAction = new QAction(tr("Allow on Right"), this);
- allowRightAction->setCheckable(true);
- connect(allowRightAction, SIGNAL(triggered(bool)), SLOT(allowRight(bool)));
-
- allowTopAction = new QAction(tr("Allow on Top"), this);
- allowTopAction->setCheckable(true);
- connect(allowTopAction, SIGNAL(triggered(bool)), SLOT(allowTop(bool)));
-
- allowBottomAction = new QAction(tr("Allow on Bottom"), this);
- allowBottomAction->setCheckable(true);
- connect(allowBottomAction, SIGNAL(triggered(bool)), SLOT(allowBottom(bool)));
-
- allowedAreasActions->addAction(allowLeftAction);
- allowedAreasActions->addAction(allowRightAction);
- allowedAreasActions->addAction(allowTopAction);
- allowedAreasActions->addAction(allowBottomAction);
-
- areaActions = new QActionGroup(this);
- areaActions->setExclusive(true);
-
- leftAction = new QAction(tr("Place on Left") , this);
- leftAction->setCheckable(true);
- connect(leftAction, SIGNAL(triggered(bool)), SLOT(placeLeft(bool)));
-
- rightAction = new QAction(tr("Place on Right") , this);
- rightAction->setCheckable(true);
- connect(rightAction, SIGNAL(triggered(bool)), SLOT(placeRight(bool)));
-
- topAction = new QAction(tr("Place on Top") , this);
- topAction->setCheckable(true);
- connect(topAction, SIGNAL(triggered(bool)), SLOT(placeTop(bool)));
-
- bottomAction = new QAction(tr("Place on Bottom") , this);
- bottomAction->setCheckable(true);
- connect(bottomAction, SIGNAL(triggered(bool)), SLOT(placeBottom(bool)));
-
- areaActions->addAction(leftAction);
- areaActions->addAction(rightAction);
- areaActions->addAction(topAction);
- areaActions->addAction(bottomAction);
-
- connect(movableAction, SIGNAL(triggered(bool)), areaActions, SLOT(setEnabled(bool)));
-
- connect(movableAction, SIGNAL(triggered(bool)), allowedAreasActions, SLOT(setEnabled(bool)));
-
- connect(floatableAction, SIGNAL(triggered(bool)), floatingAction, SLOT(setEnabled(bool)));
-
- connect(floatingAction, SIGNAL(triggered(bool)), floatableAction, SLOT(setDisabled(bool)));
- connect(movableAction, SIGNAL(triggered(bool)), floatableAction, SLOT(setEnabled(bool)));
-
- tabMenu = new QMenu(this);
- tabMenu->setTitle(tr("Tab into"));
- connect(tabMenu, SIGNAL(triggered(QAction*)), this, SLOT(tabInto(QAction*)));
-
- splitHMenu = new QMenu(this);
- splitHMenu->setTitle(tr("Split horizontally into"));
- connect(splitHMenu, SIGNAL(triggered(QAction*)), this, SLOT(splitInto(QAction*)));
-
- splitVMenu = new QMenu(this);
- splitVMenu->setTitle(tr("Split vertically into"));
- connect(splitVMenu, SIGNAL(triggered(QAction*)), this, SLOT(splitInto(QAction*)));
-
- windowModifiedAction = new QAction(tr("Modified"), this);
- windowModifiedAction->setCheckable(true);
- windowModifiedAction->setChecked(false);
- connect(windowModifiedAction, SIGNAL(toggled(bool)), this, SLOT(setWindowModified(bool)));
-
- menu = new QMenu(colorName, this);
- menu->addAction(toggleViewAction());
- QAction *action = menu->addAction(tr("Raise"));
- connect(action, SIGNAL(triggered()), this, SLOT(raise()));
- menu->addAction(changeSizeHintsAction);
- menu->addSeparator();
- menu->addAction(closableAction);
- menu->addAction(movableAction);
- menu->addAction(floatableAction);
- menu->addAction(floatingAction);
- menu->addAction(verticalTitleBarAction);
- menu->addSeparator();
- menu->addActions(allowedAreasActions->actions());
- menu->addSeparator();
- menu->addActions(areaActions->actions());
- menu->addSeparator();
- menu->addMenu(splitHMenu);
- menu->addMenu(splitVMenu);
- menu->addMenu(tabMenu);
- menu->addSeparator();
- menu->addAction(windowModifiedAction);
-
- connect(menu, SIGNAL(aboutToShow()), this, SLOT(updateContextMenu()));
-
- if(colorName == "Black") {
- leftAction->setShortcut(Qt::CTRL|Qt::Key_W);
- rightAction->setShortcut(Qt::CTRL|Qt::Key_E);
- toggleViewAction()->setShortcut(Qt::CTRL|Qt::Key_R);
- }
-}
-
-void ColorSwatch::updateContextMenu()
-{
- QMainWindow *mainWindow = qobject_cast<QMainWindow *>(parentWidget());
- const Qt::DockWidgetArea area = mainWindow->dockWidgetArea(this);
- const Qt::DockWidgetAreas areas = allowedAreas();
-
- closableAction->setChecked(features() & QDockWidget::DockWidgetClosable);
- if (windowType() == Qt::Drawer) {
- floatableAction->setEnabled(false);
- floatingAction->setEnabled(false);
- movableAction->setEnabled(false);
- verticalTitleBarAction->setChecked(false);
- } else {
- floatableAction->setChecked(features() & QDockWidget::DockWidgetFloatable);
- floatingAction->setChecked(isWindow());
- // done after floating, to get 'floatable' correctly initialized
- movableAction->setChecked(features() & QDockWidget::DockWidgetMovable);
- verticalTitleBarAction
- ->setChecked(features() & QDockWidget::DockWidgetVerticalTitleBar);
- }
-
- allowLeftAction->setChecked(isAreaAllowed(Qt::LeftDockWidgetArea));
- allowRightAction->setChecked(isAreaAllowed(Qt::RightDockWidgetArea));
- allowTopAction->setChecked(isAreaAllowed(Qt::TopDockWidgetArea));
- allowBottomAction->setChecked(isAreaAllowed(Qt::BottomDockWidgetArea));
-
- if (allowedAreasActions->isEnabled()) {
- allowLeftAction->setEnabled(area != Qt::LeftDockWidgetArea);
- allowRightAction->setEnabled(area != Qt::RightDockWidgetArea);
- allowTopAction->setEnabled(area != Qt::TopDockWidgetArea);
- allowBottomAction->setEnabled(area != Qt::BottomDockWidgetArea);
- }
-
- leftAction->blockSignals(true);
- rightAction->blockSignals(true);
- topAction->blockSignals(true);
- bottomAction->blockSignals(true);
-
- leftAction->setChecked(area == Qt::LeftDockWidgetArea);
- rightAction->setChecked(area == Qt::RightDockWidgetArea);
- topAction->setChecked(area == Qt::TopDockWidgetArea);
- bottomAction->setChecked(area == Qt::BottomDockWidgetArea);
-
- leftAction->blockSignals(false);
- rightAction->blockSignals(false);
- topAction->blockSignals(false);
- bottomAction->blockSignals(false);
-
- if (areaActions->isEnabled()) {
- leftAction->setEnabled(areas & Qt::LeftDockWidgetArea);
- rightAction->setEnabled(areas & Qt::RightDockWidgetArea);
- topAction->setEnabled(areas & Qt::TopDockWidgetArea);
- bottomAction->setEnabled(areas & Qt::BottomDockWidgetArea);
- }
-
- tabMenu->clear();
- splitHMenu->clear();
- splitVMenu->clear();
- QList<ColorSwatch*> dock_list = mainWindow->findChildren<ColorSwatch*>();
- foreach (ColorSwatch *dock, dock_list) {
-// if (!dock->isVisible() || dock->isFloating())
-// continue;
- tabMenu->addAction(dock->objectName());
- splitHMenu->addAction(dock->objectName());
- splitVMenu->addAction(dock->objectName());
- }
-}
-
-void ColorSwatch::splitInto(QAction *action)
-{
- QMainWindow *mainWindow = qobject_cast<QMainWindow *>(parentWidget());
- QList<ColorSwatch*> dock_list = mainWindow->findChildren<ColorSwatch*>();
- ColorSwatch *target = 0;
- foreach (ColorSwatch *dock, dock_list) {
- if (action->text() == dock->objectName()) {
- target = dock;
- break;
- }
- }
- if (target == 0)
- return;
-
- Qt::Orientation o = action->parent() == splitHMenu
- ? Qt::Horizontal : Qt::Vertical;
- mainWindow->splitDockWidget(target, this, o);
-}
-
-void ColorSwatch::tabInto(QAction *action)
-{
- QMainWindow *mainWindow = qobject_cast<QMainWindow *>(parentWidget());
- QList<ColorSwatch*> dock_list = mainWindow->findChildren<ColorSwatch*>();
- ColorSwatch *target = 0;
- foreach (ColorSwatch *dock, dock_list) {
- if (action->text() == dock->objectName()) {
- target = dock;
- break;
- }
- }
- if (target == 0)
- return;
-
- mainWindow->tabifyDockWidget(target, this);
-}
-
-void ColorSwatch::contextMenuEvent(QContextMenuEvent *event)
-{
- event->accept();
- menu->exec(event->globalPos());
-}
-
-void ColorSwatch::resizeEvent(QResizeEvent *e)
-{
- if (BlueTitleBar *btb = qobject_cast<BlueTitleBar*>(titleBarWidget()))
- btb->updateMask();
-
- QDockWidget::resizeEvent(e);
-}
-
-
-void ColorSwatch::allow(Qt::DockWidgetArea area, bool a)
-{
- Qt::DockWidgetAreas areas = allowedAreas();
- areas = a ? areas | area : areas & ~area;
- setAllowedAreas(areas);
-
- if (areaActions->isEnabled()) {
- leftAction->setEnabled(areas & Qt::LeftDockWidgetArea);
- rightAction->setEnabled(areas & Qt::RightDockWidgetArea);
- topAction->setEnabled(areas & Qt::TopDockWidgetArea);
- bottomAction->setEnabled(areas & Qt::BottomDockWidgetArea);
- }
-}
-
-void ColorSwatch::place(Qt::DockWidgetArea area, bool p)
-{
- if (!p) return;
-
- QMainWindow *mainWindow = qobject_cast<QMainWindow *>(parentWidget());
- mainWindow->addDockWidget(area, this);
-
- if (allowedAreasActions->isEnabled()) {
- allowLeftAction->setEnabled(area != Qt::LeftDockWidgetArea);
- allowRightAction->setEnabled(area != Qt::RightDockWidgetArea);
- allowTopAction->setEnabled(area != Qt::TopDockWidgetArea);
- allowBottomAction->setEnabled(area != Qt::BottomDockWidgetArea);
- }
-}
-
-void ColorSwatch::setCustomSizeHint(const QSize &size)
-{
- if (ColorDock *dock = qobject_cast<ColorDock*>(widget()))
- dock->setCustomSizeHint(size);
-}
-
-void ColorSwatch::changeClosable(bool on)
-{ setFeatures(on ? features() | DockWidgetClosable : features() & ~DockWidgetClosable); }
-
-void ColorSwatch::changeMovable(bool on)
-{ setFeatures(on ? features() | DockWidgetMovable : features() & ~DockWidgetMovable); }
-
-void ColorSwatch::changeFloatable(bool on)
-{ setFeatures(on ? features() | DockWidgetFloatable : features() & ~DockWidgetFloatable); }
-
-void ColorSwatch::changeFloating(bool floating)
-{ setFloating(floating); }
-
-void ColorSwatch::allowLeft(bool a)
-{ allow(Qt::LeftDockWidgetArea, a); }
-
-void ColorSwatch::allowRight(bool a)
-{ allow(Qt::RightDockWidgetArea, a); }
-
-void ColorSwatch::allowTop(bool a)
-{ allow(Qt::TopDockWidgetArea, a); }
-
-void ColorSwatch::allowBottom(bool a)
-{ allow(Qt::BottomDockWidgetArea, a); }
-
-void ColorSwatch::placeLeft(bool p)
-{ place(Qt::LeftDockWidgetArea, p); }
-
-void ColorSwatch::placeRight(bool p)
-{ place(Qt::RightDockWidgetArea, p); }
-
-void ColorSwatch::placeTop(bool p)
-{ place(Qt::TopDockWidgetArea, p); }
-
-void ColorSwatch::placeBottom(bool p)
-{ place(Qt::BottomDockWidgetArea, p); }
-
-void ColorSwatch::changeVerticalTitleBar(bool on)
-{
- setFeatures(on ? features() | DockWidgetVerticalTitleBar
- : features() & ~DockWidgetVerticalTitleBar);
-}
-
-QSize BlueTitleBar::minimumSizeHint() const
-{
- QDockWidget *dw = qobject_cast<QDockWidget*>(parentWidget());
- Q_ASSERT(dw != 0);
- QSize result(leftPm.width() + rightPm.width(), centerPm.height());
- if (dw->features() & QDockWidget::DockWidgetVerticalTitleBar)
- result.transpose();
- return result;
-}
-
-BlueTitleBar::BlueTitleBar(QWidget *parent)
- : QWidget(parent)
-{
- leftPm = QPixmap(":/res/titlebarLeft.png");
- centerPm = QPixmap(":/res/titlebarCenter.png");
- rightPm = QPixmap(":/res/titlebarRight.png");
-}
-
-void BlueTitleBar::paintEvent(QPaintEvent*)
-{
- QPainter painter(this);
- QRect rect = this->rect();
-
- QDockWidget *dw = qobject_cast<QDockWidget*>(parentWidget());
- Q_ASSERT(dw != 0);
-
- if (dw->features() & QDockWidget::DockWidgetVerticalTitleBar) {
- QSize s = rect.size();
- s.transpose();
- rect.setSize(s);
-
- painter.translate(rect.left(), rect.top() + rect.width());
- painter.rotate(-90);
- painter.translate(-rect.left(), -rect.top());
- }
-
- painter.drawPixmap(rect.topLeft(), leftPm);
- painter.drawPixmap(rect.topRight() - QPoint(rightPm.width() - 1, 0), rightPm);
- QBrush brush(centerPm);
- painter.fillRect(rect.left() + leftPm.width(), rect.top(),
- rect.width() - leftPm.width() - rightPm.width(),
- centerPm.height(), centerPm);
-}
-
-void BlueTitleBar::mousePressEvent(QMouseEvent *event)
-{
- QPoint pos = event->pos();
-
- QRect rect = this->rect();
-
- QDockWidget *dw = qobject_cast<QDockWidget*>(parentWidget());
- Q_ASSERT(dw != 0);
-
- if (dw->features() & QDockWidget::DockWidgetVerticalTitleBar) {
- QPoint p = pos;
- pos.setX(rect.left() + rect.bottom() - p.y());
- pos.setY(rect.top() + p.x() - rect.left());
-
- QSize s = rect.size();
- s.transpose();
- rect.setSize(s);
- }
-
- const int buttonRight = 7;
- const int buttonWidth = 20;
- int right = rect.right() - pos.x();
- int button = (right - buttonRight)/buttonWidth;
- switch (button) {
- case 0:
- event->accept();
- dw->close();
- break;
- case 1:
- event->accept();
- dw->setFloating(!dw->isFloating());
- break;
- case 2: {
- event->accept();
- QDockWidget::DockWidgetFeatures features = dw->features();
- if (features & QDockWidget::DockWidgetVerticalTitleBar)
- features &= ~QDockWidget::DockWidgetVerticalTitleBar;
- else
- features |= QDockWidget::DockWidgetVerticalTitleBar;
- dw->setFeatures(features);
- break;
- }
- default:
- event->ignore();
- break;
- }
-}
-
-void BlueTitleBar::updateMask()
-{
- QDockWidget *dw = qobject_cast<QDockWidget*>(parent());
- Q_ASSERT(dw != 0);
-
- QRect rect = dw->rect();
- QPixmap bitmap(dw->size());
-
- {
- QPainter painter(&bitmap);
-
- ///initialize to transparent
- painter.fillRect(rect, Qt::color0);
-
- QRect contents = rect;
- contents.setTopLeft(geometry().bottomLeft());
- contents.setRight(geometry().right());
- contents.setBottom(contents.bottom()-y());
- painter.fillRect(contents, Qt::color1);
-
-
-
- //let's pait the titlebar
-
- QRect titleRect = this->geometry();
-
- if (dw->features() & QDockWidget::DockWidgetVerticalTitleBar) {
- QSize s = rect.size();
- s.transpose();
- rect.setSize(s);
-
- QSize s2 = size();
- s2.transpose();
- titleRect.setSize(s2);
-
- painter.translate(rect.left(), rect.top() + rect.width());
- painter.rotate(-90);
- painter.translate(-rect.left(), -rect.top());
- }
-
- contents.setTopLeft(titleRect.bottomLeft());
- contents.setRight(titleRect.right());
- contents.setBottom(rect.bottom()-y());
-
- QRect rect = titleRect;
-
-
- painter.drawPixmap(rect.topLeft(), leftPm.mask());
- painter.fillRect(rect.left() + leftPm.width(), rect.top(),
- rect.width() - leftPm.width() - rightPm.width(),
- centerPm.height(), Qt::color1);
- painter.drawPixmap(rect.topRight() - QPoint(rightPm.width() - 1, 0), rightPm.mask());
-
- painter.fillRect(contents, Qt::color1);
- }
-
- dw->setMask(bitmap);
-}
-
-#include "colorswatch.moc"
diff --git a/examples/mainwindows/mainwindow/colorswatch.h b/examples/mainwindows/mainwindow/colorswatch.h
deleted file mode 100644
index 794a69cd6c..0000000000
--- a/examples/mainwindows/mainwindow/colorswatch.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef COLORSWATCH_H
-#define COLORSWATCH_H
-
-#include <QDockWidget>
-
-QT_FORWARD_DECLARE_CLASS(QAction)
-QT_FORWARD_DECLARE_CLASS(QActionGroup)
-QT_FORWARD_DECLARE_CLASS(QMenu)
-
-class ColorSwatch : public QDockWidget
-{
- Q_OBJECT
-
- QAction *closableAction;
- QAction *movableAction;
- QAction *floatableAction;
- QAction *floatingAction;
- QAction *verticalTitleBarAction;
-
- QActionGroup *allowedAreasActions;
- QAction *allowLeftAction;
- QAction *allowRightAction;
- QAction *allowTopAction;
- QAction *allowBottomAction;
-
- QActionGroup *areaActions;
- QAction *leftAction;
- QAction *rightAction;
- QAction *topAction;
- QAction *bottomAction;
-
- QAction *changeSizeHintsAction;
-
- QMenu *tabMenu;
- QMenu *splitHMenu;
- QMenu *splitVMenu;
-
- QAction *windowModifiedAction;
-
-public:
- ColorSwatch(const QString &colorName, QWidget *parent = 0, Qt::WindowFlags flags = 0);
-
- QMenu *menu;
- void setCustomSizeHint(const QSize &size);
-
-protected:
- virtual void contextMenuEvent(QContextMenuEvent *event);
- virtual void resizeEvent(QResizeEvent *e);
-
-private:
- void allow(Qt::DockWidgetArea area, bool allow);
- void place(Qt::DockWidgetArea area, bool place);
-
-private slots:
- void changeClosable(bool on);
- void changeMovable(bool on);
- void changeFloatable(bool on);
- void changeFloating(bool on);
- void changeVerticalTitleBar(bool on);
- void updateContextMenu();
-
- void allowLeft(bool a);
- void allowRight(bool a);
- void allowTop(bool a);
- void allowBottom(bool a);
-
- void placeLeft(bool p);
- void placeRight(bool p);
- void placeTop(bool p);
- void placeBottom(bool p);
-
- void splitInto(QAction *action);
- void tabInto(QAction *action);
-};
-
-class BlueTitleBar : public QWidget
-{
- Q_OBJECT
-public:
- BlueTitleBar(QWidget *parent = 0);
-
- QSize sizeHint() const { return minimumSizeHint(); }
- QSize minimumSizeHint() const;
-protected:
- void paintEvent(QPaintEvent *event);
- void mousePressEvent(QMouseEvent *event);
-public slots:
- void updateMask();
-
-private:
- QPixmap leftPm, centerPm, rightPm;
-};
-
-
-#endif
diff --git a/examples/mainwindows/mainwindow/main.cpp b/examples/mainwindows/mainwindow/main.cpp
deleted file mode 100644
index 2b6342367a..0000000000
--- a/examples/mainwindows/mainwindow/main.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "mainwindow.h"
-
-#include <QApplication>
-#include <QPainterPath>
-#include <QPainter>
-#include <QMap>
-#include <qdebug.h>
-
-void render_qt_text(QPainter *painter, int w, int h, const QColor &color) {
- QPainterPath path;
- path.moveTo(-0.083695, 0.283849);
- path.cubicTo(-0.049581, 0.349613, -0.012720, 0.397969, 0.026886, 0.428917);
- path.cubicTo(0.066493, 0.459865, 0.111593, 0.477595, 0.162186, 0.482108);
- path.lineTo(0.162186, 0.500000);
- path.cubicTo(0.115929, 0.498066, 0.066565, 0.487669, 0.014094, 0.468810);
- path.cubicTo(-0.038378, 0.449952, -0.088103, 0.423839, -0.135082, 0.390474);
- path.cubicTo(-0.182061, 0.357108, -0.222608, 0.321567, -0.256722, 0.283849);
- path.cubicTo(-0.304712, 0.262250, -0.342874, 0.239362, -0.371206, 0.215184);
- path.cubicTo(-0.411969, 0.179078, -0.443625, 0.134671, -0.466175, 0.081963);
- path.cubicTo(-0.488725, 0.029255, -0.500000, -0.033043, -0.500000, -0.104932);
- path.cubicTo(-0.500000, -0.218407, -0.467042, -0.312621, -0.401127, -0.387573);
- path.cubicTo(-0.335212, -0.462524, -0.255421, -0.500000, -0.161752, -0.500000);
- path.cubicTo(-0.072998, -0.500000, 0.003903, -0.462444, 0.068951, -0.387331);
- path.cubicTo(0.133998, -0.312218, 0.166522, -0.217440, 0.166522, -0.102998);
- path.cubicTo(0.166522, -0.010155, 0.143394, 0.071325, 0.097138, 0.141441);
- path.cubicTo(0.050882, 0.211557, -0.009396, 0.259026, -0.083695, 0.283849);
- path.moveTo(-0.167823, -0.456963);
- path.cubicTo(-0.228823, -0.456963, -0.277826, -0.432624, -0.314831, -0.383946);
- path.cubicTo(-0.361665, -0.323340, -0.385082, -0.230335, -0.385082, -0.104932);
- path.cubicTo(-0.385082, 0.017569, -0.361376, 0.112025, -0.313964, 0.178433);
- path.cubicTo(-0.277248, 0.229368, -0.228534, 0.254836, -0.167823, 0.254836);
- path.cubicTo(-0.105088, 0.254836, -0.054496, 0.229368, -0.016045, 0.178433);
- path.cubicTo(0.029055, 0.117827, 0.051605, 0.028691, 0.051605, -0.088975);
- path.cubicTo(0.051605, -0.179562, 0.039318, -0.255803, 0.014744, -0.317698);
- path.cubicTo(-0.004337, -0.365409, -0.029705, -0.400548, -0.061362, -0.423114);
- path.cubicTo(-0.093018, -0.445680, -0.128505, -0.456963, -0.167823, -0.456963);
- path.moveTo(0.379011, -0.404739);
- path.lineTo(0.379011, -0.236460);
- path.lineTo(0.486123, -0.236460);
- path.lineTo(0.486123, -0.197292);
- path.lineTo(0.379011, -0.197292);
- path.lineTo(0.379011, 0.134913);
- path.cubicTo(0.379011, 0.168117, 0.383276, 0.190442, 0.391804, 0.201886);
- path.cubicTo(0.400332, 0.213330, 0.411246, 0.219052, 0.424545, 0.219052);
- path.cubicTo(0.435531, 0.219052, 0.446227, 0.215264, 0.456635, 0.207689);
- path.cubicTo(0.467042, 0.200113, 0.474993, 0.188910, 0.480486, 0.174081);
- path.lineTo(0.500000, 0.174081);
- path.cubicTo(0.488436, 0.210509, 0.471957, 0.237911, 0.450564, 0.256286);
- path.cubicTo(0.429170, 0.274662, 0.407054, 0.283849, 0.384215, 0.283849);
- path.cubicTo(0.368893, 0.283849, 0.353859, 0.279094, 0.339115, 0.269584);
- path.cubicTo(0.324371, 0.260074, 0.313530, 0.246534, 0.306592, 0.228965);
- path.cubicTo(0.299653, 0.211396, 0.296184, 0.184075, 0.296184, 0.147002);
- path.lineTo(0.296184, -0.197292);
- path.lineTo(0.223330, -0.197292);
- path.lineTo(0.223330, -0.215667);
- path.cubicTo(0.241833, -0.224049, 0.260697, -0.237992, 0.279922, -0.257495);
- path.cubicTo(0.299147, -0.276999, 0.316276, -0.300129, 0.331310, -0.326886);
- path.cubicTo(0.338826, -0.341070, 0.349523, -0.367021, 0.363400, -0.404739);
- path.lineTo(0.379011, -0.404739);
- path.moveTo(-0.535993, 0.275629);
-
- painter->translate(w / 2, h / 2);
- double scale = qMin(w, h) * 8 / 10.0;
- painter->scale(scale, scale);
-
- painter->setRenderHint(QPainter::Antialiasing);
-
- painter->save();
- painter->translate(.1, .1);
- painter->fillPath(path, QColor(0, 0, 0, 63));
- painter->restore();
-
- painter->setBrush(color);
- painter->setPen(QPen(Qt::black, 0.02, Qt::SolidLine, Qt::FlatCap, Qt::RoundJoin));
- painter->drawPath(path);
-}
-
-void usage()
-{
- qWarning() << "Usage: mainwindow [-SizeHint<color> <width>x<height>] ...";
- exit(1);
-}
-
-QMap<QString, QSize> parseCustomSizeHints(int argc, char **argv)
-{
- QMap<QString, QSize> result;
-
- for (int i = 1; i < argc; ++i) {
- QString arg = QString::fromLocal8Bit(argv[i]);
-
- if (arg.startsWith(QLatin1String("-SizeHint"))) {
- QString name = arg.mid(9);
- if (name.isEmpty())
- usage();
- if (++i == argc)
- usage();
- QString sizeStr = QString::fromLocal8Bit(argv[i]);
- int idx = sizeStr.indexOf(QLatin1Char('x'));
- if (idx == -1)
- usage();
- bool ok;
- int w = sizeStr.left(idx).toInt(&ok);
- if (!ok)
- usage();
- int h = sizeStr.mid(idx + 1).toInt(&ok);
- if (!ok)
- usage();
- result[name] = QSize(w, h);
- }
- }
-
- return result;
-}
-
-int main(int argc, char **argv)
-{
- QApplication app(argc, argv);
- QMap<QString, QSize> customSizeHints = parseCustomSizeHints(argc, argv);
- MainWindow mainWin(customSizeHints);
- mainWin.resize(800, 600);
- mainWin.show();
- return app.exec();
-}
diff --git a/examples/mainwindows/mainwindow/mainwindow.cpp b/examples/mainwindows/mainwindow/mainwindow.cpp
deleted file mode 100644
index 2ac2b562f2..0000000000
--- a/examples/mainwindows/mainwindow/mainwindow.cpp
+++ /dev/null
@@ -1,509 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "mainwindow.h"
-#include "colorswatch.h"
-#include "toolbar.h"
-
-#include <QAction>
-#include <QLayout>
-#include <QMenu>
-#include <QMenuBar>
-#include <QStatusBar>
-#include <QTextEdit>
-#include <QFile>
-#include <QDataStream>
-#include <QFileDialog>
-#include <QMessageBox>
-#include <QSignalMapper>
-#include <QApplication>
-#include <QPainter>
-#include <QMouseEvent>
-#include <QLineEdit>
-#include <QComboBox>
-#include <QLabel>
-#include <QPushButton>
-#include <qdebug.h>
-
-static const char * const message =
- "<p><b>Qt Main Window Example</b></p>"
-
- "<p>This is a demonstration of the QMainWindow, QToolBar and "
- "QDockWidget classes.</p>"
-
- "<p>The tool bar and dock widgets can be dragged around and rearranged "
- "using the mouse or via the menu.</p>"
-
- "<p>Each dock widget contains a colored frame and a context "
- "(right-click) menu.</p>"
-
-#ifdef Q_OS_MAC
- "<p>On Mac OS X, the \"Black\" dock widget has been created as a "
- "<em>Drawer</em>, which is a special kind of QDockWidget.</p>"
-#endif
- ;
-
-Q_DECLARE_METATYPE(QDockWidget::DockWidgetFeatures)
-
-MainWindow::MainWindow(const QMap<QString, QSize> &customSizeHints,
- QWidget *parent, Qt::WindowFlags flags)
- : QMainWindow(parent, flags)
-{
- setObjectName("MainWindow");
- setWindowTitle("Qt Main Window Example");
-
- center = new QTextEdit(this);
- center->setReadOnly(true);
- center->setMinimumSize(400, 205);
- setCentralWidget(center);
-
- setupToolBar();
- setupMenuBar();
- setupDockWidgets(customSizeHints);
-
- statusBar()->showMessage(tr("Status Bar"));
-}
-
-void MainWindow::actionTriggered(QAction *action)
-{
- qDebug("action '%s' triggered", action->text().toLocal8Bit().data());
-}
-
-void MainWindow::setupToolBar()
-{
- for (int i = 0; i < 3; ++i) {
- ToolBar *tb = new ToolBar(QString::fromLatin1("Tool Bar %1").arg(i + 1), this);
- toolBars.append(tb);
- addToolBar(tb);
- }
-}
-
-void MainWindow::setupMenuBar()
-{
- QMenu *menu = menuBar()->addMenu(tr("&File"));
-
- QAction *action = menu->addAction(tr("Save layout..."));
- connect(action, SIGNAL(triggered()), this, SLOT(saveLayout()));
-
- action = menu->addAction(tr("Load layout..."));
- connect(action, SIGNAL(triggered()), this, SLOT(loadLayout()));
-
- action = menu->addAction(tr("Switch layout direction"));
- connect(action, SIGNAL(triggered()), this, SLOT(switchLayoutDirection()));
-
- menu->addSeparator();
-
- menu->addAction(tr("&Quit"), this, SLOT(close()));
-
- mainWindowMenu = menuBar()->addMenu(tr("Main window"));
-
- action = mainWindowMenu->addAction(tr("Animated docks"));
- action->setCheckable(true);
- action->setChecked(dockOptions() & AnimatedDocks);
- connect(action, SIGNAL(toggled(bool)), this, SLOT(setDockOptions()));
-
- action = mainWindowMenu->addAction(tr("Allow nested docks"));
- action->setCheckable(true);
- action->setChecked(dockOptions() & AllowNestedDocks);
- connect(action, SIGNAL(toggled(bool)), this, SLOT(setDockOptions()));
-
- action = mainWindowMenu->addAction(tr("Allow tabbed docks"));
- action->setCheckable(true);
- action->setChecked(dockOptions() & AllowTabbedDocks);
- connect(action, SIGNAL(toggled(bool)), this, SLOT(setDockOptions()));
-
- action = mainWindowMenu->addAction(tr("Force tabbed docks"));
- action->setCheckable(true);
- action->setChecked(dockOptions() & ForceTabbedDocks);
- connect(action, SIGNAL(toggled(bool)), this, SLOT(setDockOptions()));
-
- action = mainWindowMenu->addAction(tr("Vertical tabs"));
- action->setCheckable(true);
- action->setChecked(dockOptions() & VerticalTabs);
- connect(action, SIGNAL(toggled(bool)), this, SLOT(setDockOptions()));
-
- QMenu *toolBarMenu = menuBar()->addMenu(tr("Tool bars"));
- for (int i = 0; i < toolBars.count(); ++i)
- toolBarMenu->addMenu(toolBars.at(i)->menu);
-
- dockWidgetMenu = menuBar()->addMenu(tr("&Dock Widgets"));
-}
-
-void MainWindow::setDockOptions()
-{
- DockOptions opts;
- QList<QAction*> actions = mainWindowMenu->actions();
-
- if (actions.at(0)->isChecked())
- opts |= AnimatedDocks;
- if (actions.at(1)->isChecked())
- opts |= AllowNestedDocks;
- if (actions.at(2)->isChecked())
- opts |= AllowTabbedDocks;
- if (actions.at(3)->isChecked())
- opts |= ForceTabbedDocks;
- if (actions.at(4)->isChecked())
- opts |= VerticalTabs;
-
- QMainWindow::setDockOptions(opts);
-}
-
-void MainWindow::saveLayout()
-{
- QString fileName
- = QFileDialog::getSaveFileName(this, tr("Save layout"));
- if (fileName.isEmpty())
- return;
- QFile file(fileName);
- if (!file.open(QFile::WriteOnly)) {
- QString msg = tr("Failed to open %1\n%2")
- .arg(fileName)
- .arg(file.errorString());
- QMessageBox::warning(this, tr("Error"), msg);
- return;
- }
-
- QByteArray geo_data = saveGeometry();
- QByteArray layout_data = saveState();
-
- bool ok = file.putChar((uchar)geo_data.size());
- if (ok)
- ok = file.write(geo_data) == geo_data.size();
- if (ok)
- ok = file.write(layout_data) == layout_data.size();
-
- if (!ok) {
- QString msg = tr("Error writing to %1\n%2")
- .arg(fileName)
- .arg(file.errorString());
- QMessageBox::warning(this, tr("Error"), msg);
- return;
- }
-}
-
-void MainWindow::loadLayout()
-{
- QString fileName
- = QFileDialog::getOpenFileName(this, tr("Load layout"));
- if (fileName.isEmpty())
- return;
- QFile file(fileName);
- if (!file.open(QFile::ReadOnly)) {
- QString msg = tr("Failed to open %1\n%2")
- .arg(fileName)
- .arg(file.errorString());
- QMessageBox::warning(this, tr("Error"), msg);
- return;
- }
-
- uchar geo_size;
- QByteArray geo_data;
- QByteArray layout_data;
-
- bool ok = file.getChar((char*)&geo_size);
- if (ok) {
- geo_data = file.read(geo_size);
- ok = geo_data.size() == geo_size;
- }
- if (ok) {
- layout_data = file.readAll();
- ok = layout_data.size() > 0;
- }
-
- if (ok)
- ok = restoreGeometry(geo_data);
- if (ok)
- ok = restoreState(layout_data);
-
- if (!ok) {
- QString msg = tr("Error reading %1")
- .arg(fileName);
- QMessageBox::warning(this, tr("Error"), msg);
- return;
- }
-}
-
-QAction *addAction(QMenu *menu, const QString &text, QActionGroup *group, QSignalMapper *mapper,
- int id)
-{
- bool first = group->actions().isEmpty();
- QAction *result = menu->addAction(text);
- result->setCheckable(true);
- result->setChecked(first);
- group->addAction(result);
- QObject::connect(result, SIGNAL(triggered()), mapper, SLOT(map()));
- mapper->setMapping(result, id);
- return result;
-}
-
-void MainWindow::setupDockWidgets(const QMap<QString, QSize> &customSizeHints)
-{
- qRegisterMetaType<QDockWidget::DockWidgetFeatures>();
-
- mapper = new QSignalMapper(this);
- connect(mapper, SIGNAL(mapped(int)), this, SLOT(setCorner(int)));
-
- QMenu *corner_menu = dockWidgetMenu->addMenu(tr("Top left corner"));
- QActionGroup *group = new QActionGroup(this);
- group->setExclusive(true);
- ::addAction(corner_menu, tr("Top dock area"), group, mapper, 0);
- ::addAction(corner_menu, tr("Left dock area"), group, mapper, 1);
-
- corner_menu = dockWidgetMenu->addMenu(tr("Top right corner"));
- group = new QActionGroup(this);
- group->setExclusive(true);
- ::addAction(corner_menu, tr("Top dock area"), group, mapper, 2);
- ::addAction(corner_menu, tr("Right dock area"), group, mapper, 3);
-
- corner_menu = dockWidgetMenu->addMenu(tr("Bottom left corner"));
- group = new QActionGroup(this);
- group->setExclusive(true);
- ::addAction(corner_menu, tr("Bottom dock area"), group, mapper, 4);
- ::addAction(corner_menu, tr("Left dock area"), group, mapper, 5);
-
- corner_menu = dockWidgetMenu->addMenu(tr("Bottom right corner"));
- group = new QActionGroup(this);
- group->setExclusive(true);
- ::addAction(corner_menu, tr("Bottom dock area"), group, mapper, 6);
- ::addAction(corner_menu, tr("Right dock area"), group, mapper, 7);
-
- dockWidgetMenu->addSeparator();
-
- static const struct Set {
- const char * name;
- uint flags;
- Qt::DockWidgetArea area;
- } sets [] = {
-#ifndef Q_OS_MAC
- { "Black", 0, Qt::LeftDockWidgetArea },
-#else
- { "Black", Qt::Drawer, Qt::LeftDockWidgetArea },
-#endif
- { "White", 0, Qt::RightDockWidgetArea },
- { "Red", 0, Qt::TopDockWidgetArea },
- { "Green", 0, Qt::TopDockWidgetArea },
- { "Blue", 0, Qt::BottomDockWidgetArea },
- { "Yellow", 0, Qt::BottomDockWidgetArea }
- };
- const int setCount = sizeof(sets) / sizeof(Set);
-
- for (int i = 0; i < setCount; ++i) {
- ColorSwatch *swatch = new ColorSwatch(tr(sets[i].name), this, Qt::WindowFlags(sets[i].flags));
- if (i%2)
- swatch->setWindowIcon(QIcon(QPixmap(":/res/qt.png")));
- if (qstrcmp(sets[i].name, "Blue") == 0) {
- BlueTitleBar *titlebar = new BlueTitleBar(swatch);
- swatch->setTitleBarWidget(titlebar);
- connect(swatch, SIGNAL(topLevelChanged(bool)), titlebar, SLOT(updateMask()));
- connect(swatch, SIGNAL(featuresChanged(QDockWidget::DockWidgetFeatures)), titlebar, SLOT(updateMask()), Qt::QueuedConnection);
-
- }
-
- QString name = QString::fromLatin1(sets[i].name);
- if (customSizeHints.contains(name))
- swatch->setCustomSizeHint(customSizeHints.value(name));
-
- addDockWidget(sets[i].area, swatch);
- dockWidgetMenu->addMenu(swatch->menu);
- }
-
- createDockWidgetAction = new QAction(tr("Add dock widget..."), this);
- connect(createDockWidgetAction, SIGNAL(triggered()), this, SLOT(createDockWidget()));
- destroyDockWidgetMenu = new QMenu(tr("Destroy dock widget"), this);
- destroyDockWidgetMenu->setEnabled(false);
- connect(destroyDockWidgetMenu, SIGNAL(triggered(QAction*)), this, SLOT(destroyDockWidget(QAction*)));
-
- dockWidgetMenu->addSeparator();
- dockWidgetMenu->addAction(createDockWidgetAction);
- dockWidgetMenu->addMenu(destroyDockWidgetMenu);
-}
-
-void MainWindow::setCorner(int id)
-{
- switch (id) {
- case 0:
- QMainWindow::setCorner(Qt::TopLeftCorner, Qt::TopDockWidgetArea);
- break;
- case 1:
- QMainWindow::setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
- break;
- case 2:
- QMainWindow::setCorner(Qt::TopRightCorner, Qt::TopDockWidgetArea);
- break;
- case 3:
- QMainWindow::setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea);
- break;
- case 4:
- QMainWindow::setCorner(Qt::BottomLeftCorner, Qt::BottomDockWidgetArea);
- break;
- case 5:
- QMainWindow::setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
- break;
- case 6:
- QMainWindow::setCorner(Qt::BottomRightCorner, Qt::BottomDockWidgetArea);
- break;
- case 7:
- QMainWindow::setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
- break;
- }
-}
-
-void MainWindow::showEvent(QShowEvent *event)
-{
- QMainWindow::showEvent(event);
-}
-
-void MainWindow::switchLayoutDirection()
-{
- if (layoutDirection() == Qt::LeftToRight)
- qApp->setLayoutDirection(Qt::RightToLeft);
- else
- qApp->setLayoutDirection(Qt::LeftToRight);
-}
-
-class CreateDockWidgetDialog : public QDialog
-{
-public:
- CreateDockWidgetDialog(QWidget *parent = 0);
-
- QString objectName() const;
- Qt::DockWidgetArea location() const;
-
-private:
- QLineEdit *m_objectName;
- QComboBox *m_location;
-};
-
-CreateDockWidgetDialog::CreateDockWidgetDialog(QWidget *parent)
- : QDialog(parent)
-{
- QGridLayout *layout = new QGridLayout(this);
-
- layout->addWidget(new QLabel(tr("Object name:")), 0, 0);
- m_objectName = new QLineEdit;
- layout->addWidget(m_objectName, 0, 1);
-
- layout->addWidget(new QLabel(tr("Location:")), 1, 0);
- m_location = new QComboBox;
- m_location->setEditable(false);
- m_location->addItem(tr("Top"));
- m_location->addItem(tr("Left"));
- m_location->addItem(tr("Right"));
- m_location->addItem(tr("Bottom"));
- m_location->addItem(tr("Restore"));
- layout->addWidget(m_location, 1, 1);
-
- QHBoxLayout *buttonLayout = new QHBoxLayout;
- layout->addLayout(buttonLayout, 2, 0, 1, 2);
- buttonLayout->addStretch();
-
- QPushButton *cancelButton = new QPushButton(tr("Cancel"));
- connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
- buttonLayout->addWidget(cancelButton);
- QPushButton *okButton = new QPushButton(tr("Ok"));
- connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
- buttonLayout->addWidget(okButton);
-
- okButton->setDefault(true);
-}
-
-QString CreateDockWidgetDialog::objectName() const
-{
- return m_objectName->text();
-}
-
-Qt::DockWidgetArea CreateDockWidgetDialog::location() const
-{
- switch (m_location->currentIndex()) {
- case 0: return Qt::TopDockWidgetArea;
- case 1: return Qt::LeftDockWidgetArea;
- case 2: return Qt::RightDockWidgetArea;
- case 3: return Qt::BottomDockWidgetArea;
- default:
- break;
- }
- return Qt::NoDockWidgetArea;
-}
-
-void MainWindow::createDockWidget()
-{
- CreateDockWidgetDialog dialog(this);
- int ret = dialog.exec();
- if (ret == QDialog::Rejected)
- return;
-
- QDockWidget *dw = new QDockWidget;
- dw->setObjectName(dialog.objectName());
- dw->setWindowTitle(dialog.objectName());
- dw->setWidget(new QTextEdit);
-
- Qt::DockWidgetArea area = dialog.location();
- switch (area) {
- case Qt::LeftDockWidgetArea:
- case Qt::RightDockWidgetArea:
- case Qt::TopDockWidgetArea:
- case Qt::BottomDockWidgetArea:
- addDockWidget(area, dw);
- break;
- default:
- if (!restoreDockWidget(dw)) {
- QMessageBox::warning(this, QString(), tr("Failed to restore dock widget"));
- delete dw;
- return;
- }
- break;
- }
-
- extraDockWidgets.append(dw);
- destroyDockWidgetMenu->setEnabled(true);
- destroyDockWidgetMenu->addAction(new QAction(dialog.objectName(), this));
-}
-
-void MainWindow::destroyDockWidget(QAction *action)
-{
- int index = destroyDockWidgetMenu->actions().indexOf(action);
- delete extraDockWidgets.takeAt(index);
- destroyDockWidgetMenu->removeAction(action);
- action->deleteLater();
-
- if (destroyDockWidgetMenu->isEmpty())
- destroyDockWidgetMenu->setEnabled(false);
-}
diff --git a/examples/mainwindows/mainwindow/mainwindow.h b/examples/mainwindows/mainwindow/mainwindow.h
deleted file mode 100644
index 51969acaa3..0000000000
--- a/examples/mainwindows/mainwindow/mainwindow.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QMainWindow>
-#include <QTextEdit>
-
-class ToolBar;
-QT_FORWARD_DECLARE_CLASS(QMenu)
-QT_FORWARD_DECLARE_CLASS(QSignalMapper)
-
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
- QTextEdit *center;
- QList<ToolBar*> toolBars;
- QMenu *dockWidgetMenu;
- QMenu *mainWindowMenu;
- QSignalMapper *mapper;
- QList<QDockWidget*> extraDockWidgets;
- QAction *createDockWidgetAction;
- QMenu *destroyDockWidgetMenu;
-
-public:
- MainWindow(const QMap<QString, QSize> &customSizeHints,
- QWidget *parent = 0, Qt::WindowFlags flags = 0);
-
-protected:
- void showEvent(QShowEvent *event);
-
-public slots:
- void actionTriggered(QAction *action);
- void saveLayout();
- void loadLayout();
- void setCorner(int id);
- void switchLayoutDirection();
- void setDockOptions();
-
- void createDockWidget();
- void destroyDockWidget(QAction *action);
-
-private:
- void setupToolBar();
- void setupMenuBar();
- void setupDockWidgets(const QMap<QString, QSize> &customSizeHints);
-};
-
-
-#endif
diff --git a/examples/mainwindows/mainwindow/mainwindow.pro b/examples/mainwindows/mainwindow/mainwindow.pro
deleted file mode 100644
index 1381c460c2..0000000000
--- a/examples/mainwindows/mainwindow/mainwindow.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-TEMPLATE = app
-HEADERS += colorswatch.h mainwindow.h toolbar.h
-SOURCES += colorswatch.cpp mainwindow.cpp toolbar.cpp main.cpp
-build_all:!build_pass {
- CONFIG -= build_all
- CONFIG += release
-}
-
-RESOURCES += mainwindow.qrc
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows/mainwindow
-sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.png *.jpg *.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows/mainwindow
-INSTALLS += target sources
-
-QT += widgets
diff --git a/examples/mainwindows/mainwindow/mainwindow.qrc b/examples/mainwindows/mainwindow/mainwindow.qrc
deleted file mode 100644
index 47ff22a3e4..0000000000
--- a/examples/mainwindows/mainwindow/mainwindow.qrc
+++ /dev/null
@@ -1,8 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource prefix="/res">
- <file>qt.png</file>
- <file>titlebarLeft.png</file>
- <file>titlebarCenter.png</file>
- <file>titlebarRight.png</file>
-</qresource>
-</RCC>
diff --git a/examples/mainwindows/mainwindow/qt.png b/examples/mainwindows/mainwindow/qt.png
deleted file mode 100644
index 48fa9fc2ef..0000000000
--- a/examples/mainwindows/mainwindow/qt.png
+++ /dev/null
Binary files differ
diff --git a/examples/mainwindows/mainwindow/titlebarCenter.png b/examples/mainwindows/mainwindow/titlebarCenter.png
deleted file mode 100644
index 5cc141355c..0000000000
--- a/examples/mainwindows/mainwindow/titlebarCenter.png
+++ /dev/null
Binary files differ
diff --git a/examples/mainwindows/mainwindow/titlebarLeft.png b/examples/mainwindows/mainwindow/titlebarLeft.png
deleted file mode 100644
index 315166202b..0000000000
--- a/examples/mainwindows/mainwindow/titlebarLeft.png
+++ /dev/null
Binary files differ
diff --git a/examples/mainwindows/mainwindow/titlebarRight.png b/examples/mainwindows/mainwindow/titlebarRight.png
deleted file mode 100644
index a4505268ec..0000000000
--- a/examples/mainwindows/mainwindow/titlebarRight.png
+++ /dev/null
Binary files differ
diff --git a/examples/mainwindows/mainwindow/toolbar.cpp b/examples/mainwindows/mainwindow/toolbar.cpp
deleted file mode 100644
index d10eccb46d..0000000000
--- a/examples/mainwindows/mainwindow/toolbar.cpp
+++ /dev/null
@@ -1,383 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "toolbar.h"
-
-#include <QMainWindow>
-#include <QMenu>
-#include <QPainter>
-#include <QPainterPath>
-#include <QSpinBox>
-#include <QLabel>
-#include <QToolTip>
-
-#include <stdlib.h>
-
-static QPixmap genIcon(const QSize &iconSize, const QString &, const QColor &color)
-{
- int w = iconSize.width();
- int h = iconSize.height();
-
- QImage image(w, h, QImage::Format_ARGB32_Premultiplied);
- image.fill(0);
-
- QPainter p(&image);
-
- extern void render_qt_text(QPainter *, int, int, const QColor &);
- render_qt_text(&p, w, h, color);
-
- return QPixmap::fromImage(image, Qt::DiffuseDither | Qt::DiffuseAlphaDither);
-}
-
-static QPixmap genIcon(const QSize &iconSize, int number, const QColor &color)
-{ return genIcon(iconSize, QString::number(number), color); }
-
-ToolBar::ToolBar(const QString &title, QWidget *parent)
- : QToolBar(parent), spinbox(0), spinboxAction(0)
-{
- tip = 0;
- setWindowTitle(title);
- setObjectName(title);
-
- setIconSize(QSize(32, 32));
-
- QColor bg(palette().background().color());
- menu = new QMenu("One", this);
- menu->setIcon(genIcon(iconSize(), 1, Qt::black));
- menu->addAction(genIcon(iconSize(), "A", Qt::blue), "A");
- menu->addAction(genIcon(iconSize(), "B", Qt::blue), "B");
- menu->addAction(genIcon(iconSize(), "C", Qt::blue), "C");
- addAction(menu->menuAction());
-
- QAction *two = addAction(genIcon(iconSize(), 2, Qt::white), "Two");
- QFont boldFont;
- boldFont.setBold(true);
- two->setFont(boldFont);
-
- addAction(genIcon(iconSize(), 3, Qt::red), "Three");
- addAction(genIcon(iconSize(), 4, Qt::green), "Four");
- addAction(genIcon(iconSize(), 5, Qt::blue), "Five");
- addAction(genIcon(iconSize(), 6, Qt::yellow), "Six");
- orderAction = new QAction(this);
- orderAction->setText(tr("Order Items in Tool Bar"));
- connect(orderAction, SIGNAL(triggered()), SLOT(order()));
-
- randomizeAction = new QAction(this);
- randomizeAction->setText(tr("Randomize Items in Tool Bar"));
- connect(randomizeAction, SIGNAL(triggered()), SLOT(randomize()));
-
- addSpinBoxAction = new QAction(this);
- addSpinBoxAction->setText(tr("Add Spin Box"));
- connect(addSpinBoxAction, SIGNAL(triggered()), SLOT(addSpinBox()));
-
- removeSpinBoxAction = new QAction(this);
- removeSpinBoxAction->setText(tr("Remove Spin Box"));
- removeSpinBoxAction->setEnabled(false);
- connect(removeSpinBoxAction, SIGNAL(triggered()), SLOT(removeSpinBox()));
-
- movableAction = new QAction(tr("Movable"), this);
- movableAction->setCheckable(true);
- connect(movableAction, SIGNAL(triggered(bool)), SLOT(changeMovable(bool)));
-
- allowedAreasActions = new QActionGroup(this);
- allowedAreasActions->setExclusive(false);
-
- allowLeftAction = new QAction(tr("Allow on Left"), this);
- allowLeftAction->setCheckable(true);
- connect(allowLeftAction, SIGNAL(triggered(bool)), SLOT(allowLeft(bool)));
-
- allowRightAction = new QAction(tr("Allow on Right"), this);
- allowRightAction->setCheckable(true);
- connect(allowRightAction, SIGNAL(triggered(bool)), SLOT(allowRight(bool)));
-
- allowTopAction = new QAction(tr("Allow on Top"), this);
- allowTopAction->setCheckable(true);
- connect(allowTopAction, SIGNAL(triggered(bool)), SLOT(allowTop(bool)));
-
- allowBottomAction = new QAction(tr("Allow on Bottom"), this);
- allowBottomAction->setCheckable(true);
- connect(allowBottomAction, SIGNAL(triggered(bool)), SLOT(allowBottom(bool)));
-
- allowedAreasActions->addAction(allowLeftAction);
- allowedAreasActions->addAction(allowRightAction);
- allowedAreasActions->addAction(allowTopAction);
- allowedAreasActions->addAction(allowBottomAction);
-
- areaActions = new QActionGroup(this);
- areaActions->setExclusive(true);
-
- leftAction = new QAction(tr("Place on Left") , this);
- leftAction->setCheckable(true);
- connect(leftAction, SIGNAL(triggered(bool)), SLOT(placeLeft(bool)));
-
- rightAction = new QAction(tr("Place on Right") , this);
- rightAction->setCheckable(true);
- connect(rightAction, SIGNAL(triggered(bool)), SLOT(placeRight(bool)));
-
- topAction = new QAction(tr("Place on Top") , this);
- topAction->setCheckable(true);
- connect(topAction, SIGNAL(triggered(bool)), SLOT(placeTop(bool)));
-
- bottomAction = new QAction(tr("Place on Bottom") , this);
- bottomAction->setCheckable(true);
- connect(bottomAction, SIGNAL(triggered(bool)), SLOT(placeBottom(bool)));
-
- areaActions->addAction(leftAction);
- areaActions->addAction(rightAction);
- areaActions->addAction(topAction);
- areaActions->addAction(bottomAction);
-
- toolBarBreakAction = new QAction(tr("Insert break"), this);
- connect(toolBarBreakAction, SIGNAL(triggered(bool)), this, SLOT(insertToolBarBreak()));
-
- connect(movableAction, SIGNAL(triggered(bool)), areaActions, SLOT(setEnabled(bool)));
-
- connect(movableAction, SIGNAL(triggered(bool)), allowedAreasActions, SLOT(setEnabled(bool)));
-
- menu = new QMenu(title, this);
- menu->addAction(toggleViewAction());
- menu->addSeparator();
- menu->addAction(orderAction);
- menu->addAction(randomizeAction);
- menu->addSeparator();
- menu->addAction(addSpinBoxAction);
- menu->addAction(removeSpinBoxAction);
- menu->addSeparator();
- menu->addAction(movableAction);
- menu->addSeparator();
- menu->addActions(allowedAreasActions->actions());
- menu->addSeparator();
- menu->addActions(areaActions->actions());
- menu->addSeparator();
- menu->addAction(toolBarBreakAction);
-
- connect(menu, SIGNAL(aboutToShow()), this, SLOT(updateMenu()));
-
- randomize();
-}
-
-void ToolBar::updateMenu()
-{
- QMainWindow *mainWindow = qobject_cast<QMainWindow *>(parentWidget());
- Q_ASSERT(mainWindow != 0);
-
- const Qt::ToolBarArea area = mainWindow->toolBarArea(this);
- const Qt::ToolBarAreas areas = allowedAreas();
-
- movableAction->setChecked(isMovable());
-
- allowLeftAction->setChecked(isAreaAllowed(Qt::LeftToolBarArea));
- allowRightAction->setChecked(isAreaAllowed(Qt::RightToolBarArea));
- allowTopAction->setChecked(isAreaAllowed(Qt::TopToolBarArea));
- allowBottomAction->setChecked(isAreaAllowed(Qt::BottomToolBarArea));
-
- if (allowedAreasActions->isEnabled()) {
- allowLeftAction->setEnabled(area != Qt::LeftToolBarArea);
- allowRightAction->setEnabled(area != Qt::RightToolBarArea);
- allowTopAction->setEnabled(area != Qt::TopToolBarArea);
- allowBottomAction->setEnabled(area != Qt::BottomToolBarArea);
- }
-
- leftAction->setChecked(area == Qt::LeftToolBarArea);
- rightAction->setChecked(area == Qt::RightToolBarArea);
- topAction->setChecked(area == Qt::TopToolBarArea);
- bottomAction->setChecked(area == Qt::BottomToolBarArea);
-
- if (areaActions->isEnabled()) {
- leftAction->setEnabled(areas & Qt::LeftToolBarArea);
- rightAction->setEnabled(areas & Qt::RightToolBarArea);
- topAction->setEnabled(areas & Qt::TopToolBarArea);
- bottomAction->setEnabled(areas & Qt::BottomToolBarArea);
- }
-}
-
-void ToolBar::order()
-{
- QList<QAction *> ordered, actions1 = actions(),
- actions2 = findChildren<QAction *>();
- while (!actions2.isEmpty()) {
- QAction *action = actions2.takeFirst();
- if (!actions1.contains(action))
- continue;
- actions1.removeAll(action);
- ordered.append(action);
- }
-
- clear();
- addActions(ordered);
-
- orderAction->setEnabled(false);
-}
-
-void ToolBar::randomize()
-{
- QList<QAction *> randomized, actions = this->actions();
- while (!actions.isEmpty()) {
- QAction *action = actions.takeAt(rand() % actions.size());
- randomized.append(action);
- }
- clear();
- addActions(randomized);
-
- orderAction->setEnabled(true);
-}
-
-void ToolBar::addSpinBox()
-{
- if (!spinbox) {
- spinbox = new QSpinBox(this);
- }
- if (!spinboxAction)
- spinboxAction = addWidget(spinbox);
- else
- addAction(spinboxAction);
-
- addSpinBoxAction->setEnabled(false);
- removeSpinBoxAction->setEnabled(true);
-}
-
-void ToolBar::removeSpinBox()
-{
- if (spinboxAction)
- removeAction(spinboxAction);
-
- addSpinBoxAction->setEnabled(true);
- removeSpinBoxAction->setEnabled(false);
-}
-
-void ToolBar::allow(Qt::ToolBarArea area, bool a)
-{
- Qt::ToolBarAreas areas = allowedAreas();
- areas = a ? areas | area : areas & ~area;
- setAllowedAreas(areas);
-
- if (areaActions->isEnabled()) {
- leftAction->setEnabled(areas & Qt::LeftToolBarArea);
- rightAction->setEnabled(areas & Qt::RightToolBarArea);
- topAction->setEnabled(areas & Qt::TopToolBarArea);
- bottomAction->setEnabled(areas & Qt::BottomToolBarArea);
- }
-}
-
-void ToolBar::place(Qt::ToolBarArea area, bool p)
-{
- if (!p)
- return;
-
- QMainWindow *mainWindow = qobject_cast<QMainWindow *>(parentWidget());
- Q_ASSERT(mainWindow != 0);
-
- mainWindow->addToolBar(area, this);
-
- if (allowedAreasActions->isEnabled()) {
- allowLeftAction->setEnabled(area != Qt::LeftToolBarArea);
- allowRightAction->setEnabled(area != Qt::RightToolBarArea);
- allowTopAction->setEnabled(area != Qt::TopToolBarArea);
- allowBottomAction->setEnabled(area != Qt::BottomToolBarArea);
- }
-}
-
-void ToolBar::changeMovable(bool movable)
-{ setMovable(movable); }
-
-void ToolBar::allowLeft(bool a)
-{ allow(Qt::LeftToolBarArea, a); }
-
-void ToolBar::allowRight(bool a)
-{ allow(Qt::RightToolBarArea, a); }
-
-void ToolBar::allowTop(bool a)
-{ allow(Qt::TopToolBarArea, a); }
-
-void ToolBar::allowBottom(bool a)
-{ allow(Qt::BottomToolBarArea, a); }
-
-void ToolBar::placeLeft(bool p)
-{ place(Qt::LeftToolBarArea, p); }
-
-void ToolBar::placeRight(bool p)
-{ place(Qt::RightToolBarArea, p); }
-
-void ToolBar::placeTop(bool p)
-{ place(Qt::TopToolBarArea, p); }
-
-void ToolBar::placeBottom(bool p)
-{ place(Qt::BottomToolBarArea, p); }
-
-void ToolBar::insertToolBarBreak()
-{
- QMainWindow *mainWindow = qobject_cast<QMainWindow *>(parentWidget());
- Q_ASSERT(mainWindow != 0);
-
- mainWindow->insertToolBarBreak(this);
-}
-
-void ToolBar::enterEvent(QEvent*)
-{
-/*
- These labels on top of toolbars look darn ugly
-
- if (tip == 0) {
- tip = new QLabel(windowTitle(), this);
- QPalette pal = tip->palette();
- QColor c = Qt::black;
- c.setAlpha(100);
- pal.setColor(QPalette::Window, c);
- pal.setColor(QPalette::Foreground, Qt::white);
- tip->setPalette(pal);
- tip->setAutoFillBackground(true);
- tip->setMargin(3);
- tip->setText(windowTitle());
- }
- QPoint c = rect().center();
- QSize hint = tip->sizeHint();
- tip->setGeometry(c.x() - hint.width()/2, c.y() - hint.height()/2,
- hint.width(), hint.height());
-
- tip->show();
-*/
-}
-
-void ToolBar::leaveEvent(QEvent*)
-{
- if (tip != 0)
- tip->hide();
-}
diff --git a/examples/mainwindows/mainwindow/toolbar.h b/examples/mainwindows/mainwindow/toolbar.h
deleted file mode 100644
index 0ffb1eea5d..0000000000
--- a/examples/mainwindows/mainwindow/toolbar.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef TOOLBAR_H
-#define TOOLBAR_H
-
-#include <QToolBar>
-
-QT_FORWARD_DECLARE_CLASS(QAction)
-QT_FORWARD_DECLARE_CLASS(QActionGroup)
-QT_FORWARD_DECLARE_CLASS(QMenu)
-QT_FORWARD_DECLARE_CLASS(QSpinBox)
-QT_FORWARD_DECLARE_CLASS(QLabel)
-
-class ToolBar : public QToolBar
-{
- Q_OBJECT
-
- QSpinBox *spinbox;
- QAction *spinboxAction;
-
- QAction *orderAction;
- QAction *randomizeAction;
- QAction *addSpinBoxAction;
- QAction *removeSpinBoxAction;
-
- QAction *movableAction;
-
- QActionGroup *allowedAreasActions;
- QAction *allowLeftAction;
- QAction *allowRightAction;
- QAction *allowTopAction;
- QAction *allowBottomAction;
-
- QActionGroup *areaActions;
- QAction *leftAction;
- QAction *rightAction;
- QAction *topAction;
- QAction *bottomAction;
-
- QAction *toolBarBreakAction;
-
-public:
- ToolBar(const QString &title, QWidget *parent);
-
- QMenu *menu;
-
-protected:
- void enterEvent(QEvent*);
- void leaveEvent(QEvent*);
-
-private:
- void allow(Qt::ToolBarArea area, bool allow);
- void place(Qt::ToolBarArea area, bool place);
- QLabel *tip;
-
-private slots:
- void order();
- void randomize();
- void addSpinBox();
- void removeSpinBox();
-
- void changeMovable(bool movable);
-
- void allowLeft(bool a);
- void allowRight(bool a);
- void allowTop(bool a);
- void allowBottom(bool a);
-
- void placeLeft(bool p);
- void placeRight(bool p);
- void placeTop(bool p);
- void placeBottom(bool p);
-
- void updateMenu();
- void insertToolBarBreak();
-
-};
-
-#endif
diff --git a/examples/mainwindows/mainwindows.pro b/examples/mainwindows/mainwindows.pro
deleted file mode 100644
index c30d29e95a..0000000000
--- a/examples/mainwindows/mainwindows.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-TEMPLATE = subdirs
-SUBDIRS = application \
- dockwidgets \
- mainwindow \
- mdi \
- menus \
- recentfiles \
- sdi
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows
-sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS mainwindows.pro README
-sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows
-INSTALLS += target sources
-
-QT += widgets
diff --git a/examples/mainwindows/mdi/images/copy.png b/examples/mainwindows/mdi/images/copy.png
deleted file mode 100644
index 2aeb28288f..0000000000
--- a/examples/mainwindows/mdi/images/copy.png
+++ /dev/null
Binary files differ
diff --git a/examples/mainwindows/mdi/images/cut.png b/examples/mainwindows/mdi/images/cut.png
deleted file mode 100644
index 54638e9386..0000000000
--- a/examples/mainwindows/mdi/images/cut.png
+++ /dev/null
Binary files differ
diff --git a/examples/mainwindows/mdi/images/new.png b/examples/mainwindows/mdi/images/new.png
deleted file mode 100644
index 12131b0100..0000000000
--- a/examples/mainwindows/mdi/images/new.png
+++ /dev/null
Binary files differ
diff --git a/examples/mainwindows/mdi/images/open.png b/examples/mainwindows/mdi/images/open.png
deleted file mode 100644
index 45fa2883a7..0000000000
--- a/examples/mainwindows/mdi/images/open.png
+++ /dev/null
Binary files differ
diff --git a/examples/mainwindows/mdi/images/paste.png b/examples/mainwindows/mdi/images/paste.png
deleted file mode 100644
index c14425cad1..0000000000
--- a/examples/mainwindows/mdi/images/paste.png
+++ /dev/null
Binary files differ
diff --git a/examples/mainwindows/mdi/images/save.png b/examples/mainwindows/mdi/images/save.png
deleted file mode 100644
index daba865faf..0000000000
--- a/examples/mainwindows/mdi/images/save.png
+++ /dev/null
Binary files differ
diff --git a/examples/mainwindows/mdi/main.cpp b/examples/mainwindows/mdi/main.cpp
deleted file mode 100644
index 8beec478a4..0000000000
--- a/examples/mainwindows/mdi/main.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples 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 <QApplication>
-
-#include "mainwindow.h"
-
-int main(int argc, char *argv[])
-{
- Q_INIT_RESOURCE(mdi);
-
- QApplication app(argc, argv);
- MainWindow mainWin;
- mainWin.show();
- return app.exec();
-}
diff --git a/examples/mainwindows/mdi/mainwindow.cpp b/examples/mainwindows/mdi/mainwindow.cpp
deleted file mode 100644
index 6ba15aa224..0000000000
--- a/examples/mainwindows/mdi/mainwindow.cpp
+++ /dev/null
@@ -1,411 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples 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 <QtWidgets>
-
-#include "mainwindow.h"
-#include "mdichild.h"
-
-MainWindow::MainWindow()
-{
- mdiArea = new QMdiArea;
- mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
- mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
- setCentralWidget(mdiArea);
- connect(mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)),
- this, SLOT(updateMenus()));
- windowMapper = new QSignalMapper(this);
- connect(windowMapper, SIGNAL(mapped(QWidget*)),
- this, SLOT(setActiveSubWindow(QWidget*)));
-
- createActions();
- createMenus();
- createToolBars();
- createStatusBar();
- updateMenus();
-
- readSettings();
-
- setWindowTitle(tr("MDI"));
- setUnifiedTitleAndToolBarOnMac(true);
-}
-
-void MainWindow::closeEvent(QCloseEvent *event)
-{
- mdiArea->closeAllSubWindows();
- if (mdiArea->currentSubWindow()) {
- event->ignore();
- } else {
- writeSettings();
- event->accept();
- }
-}
-
-void MainWindow::newFile()
-{
- MdiChild *child = createMdiChild();
- child->newFile();
- child->show();
-}
-
-void MainWindow::open()
-{
- QString fileName = QFileDialog::getOpenFileName(this);
- if (!fileName.isEmpty()) {
- QMdiSubWindow *existing = findMdiChild(fileName);
- if (existing) {
- mdiArea->setActiveSubWindow(existing);
- return;
- }
-
- MdiChild *child = createMdiChild();
- if (child->loadFile(fileName)) {
- statusBar()->showMessage(tr("File loaded"), 2000);
- child->show();
- } else {
- child->close();
- }
- }
-}
-
-void MainWindow::save()
-{
- if (activeMdiChild() && activeMdiChild()->save())
- statusBar()->showMessage(tr("File saved"), 2000);
-}
-
-void MainWindow::saveAs()
-{
- if (activeMdiChild() && activeMdiChild()->saveAs())
- statusBar()->showMessage(tr("File saved"), 2000);
-}
-
-#ifndef QT_NO_CLIPBOARD
-void MainWindow::cut()
-{
- if (activeMdiChild())
- activeMdiChild()->cut();
-}
-
-void MainWindow::copy()
-{
- if (activeMdiChild())
- activeMdiChild()->copy();
-}
-
-void MainWindow::paste()
-{
- if (activeMdiChild())
- activeMdiChild()->paste();
-}
-#endif
-
-void MainWindow::about()
-{
- QMessageBox::about(this, tr("About MDI"),
- tr("The <b>MDI</b> example demonstrates how to write multiple "
- "document interface applications using Qt."));
-}
-
-void MainWindow::updateMenus()
-{
- bool hasMdiChild = (activeMdiChild() != 0);
- saveAct->setEnabled(hasMdiChild);
- saveAsAct->setEnabled(hasMdiChild);
-#ifndef QT_NO_CLIPBOARD
- pasteAct->setEnabled(hasMdiChild);
-#endif
- closeAct->setEnabled(hasMdiChild);
- closeAllAct->setEnabled(hasMdiChild);
- tileAct->setEnabled(hasMdiChild);
- cascadeAct->setEnabled(hasMdiChild);
- nextAct->setEnabled(hasMdiChild);
- previousAct->setEnabled(hasMdiChild);
- separatorAct->setVisible(hasMdiChild);
-
-#ifndef QT_NO_CLIPBOARD
- bool hasSelection = (activeMdiChild() &&
- activeMdiChild()->textCursor().hasSelection());
- cutAct->setEnabled(hasSelection);
- copyAct->setEnabled(hasSelection);
-#endif
-}
-
-void MainWindow::updateWindowMenu()
-{
- windowMenu->clear();
- windowMenu->addAction(closeAct);
- windowMenu->addAction(closeAllAct);
- windowMenu->addSeparator();
- windowMenu->addAction(tileAct);
- windowMenu->addAction(cascadeAct);
- windowMenu->addSeparator();
- windowMenu->addAction(nextAct);
- windowMenu->addAction(previousAct);
- windowMenu->addAction(separatorAct);
-
- QList<QMdiSubWindow *> windows = mdiArea->subWindowList();
- separatorAct->setVisible(!windows.isEmpty());
-
- for (int i = 0; i < windows.size(); ++i) {
- MdiChild *child = qobject_cast<MdiChild *>(windows.at(i)->widget());
-
- QString text;
- if (i < 9) {
- text = tr("&%1 %2").arg(i + 1)
- .arg(child->userFriendlyCurrentFile());
- } else {
- text = tr("%1 %2").arg(i + 1)
- .arg(child->userFriendlyCurrentFile());
- }
- QAction *action = windowMenu->addAction(text);
- action->setCheckable(true);
- action ->setChecked(child == activeMdiChild());
- connect(action, SIGNAL(triggered()), windowMapper, SLOT(map()));
- windowMapper->setMapping(action, windows.at(i));
- }
-}
-
-MdiChild *MainWindow::createMdiChild()
-{
- MdiChild *child = new MdiChild;
- mdiArea->addSubWindow(child);
-
-#ifndef QT_NO_CLIPBOARD
- connect(child, SIGNAL(copyAvailable(bool)),
- cutAct, SLOT(setEnabled(bool)));
- connect(child, SIGNAL(copyAvailable(bool)),
- copyAct, SLOT(setEnabled(bool)));
-#endif
-
- return child;
-}
-
-void MainWindow::createActions()
-{
- newAct = new QAction(QIcon(":/images/new.png"), tr("&New"), this);
- newAct->setShortcuts(QKeySequence::New);
- newAct->setStatusTip(tr("Create a new file"));
- connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));
-
- openAct = new QAction(QIcon(":/images/open.png"), tr("&Open..."), this);
- openAct->setShortcuts(QKeySequence::Open);
- openAct->setStatusTip(tr("Open an existing file"));
- connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
-
- saveAct = new QAction(QIcon(":/images/save.png"), tr("&Save"), this);
- saveAct->setShortcuts(QKeySequence::Save);
- saveAct->setStatusTip(tr("Save the document to disk"));
- connect(saveAct, SIGNAL(triggered()), this, SLOT(save()));
-
- saveAsAct = new QAction(tr("Save &As..."), this);
- saveAsAct->setShortcuts(QKeySequence::SaveAs);
- saveAsAct->setStatusTip(tr("Save the document under a new name"));
- connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs()));
-
-//! [0]
- exitAct = new QAction(tr("E&xit"), this);
- exitAct->setShortcuts(QKeySequence::Quit);
- exitAct->setStatusTip(tr("Exit the application"));
- connect(exitAct, SIGNAL(triggered()), qApp, SLOT(closeAllWindows()));
-//! [0]
-
-#ifndef QT_NO_CLIPBOARD
- cutAct = new QAction(QIcon(":/images/cut.png"), tr("Cu&t"), this);
- cutAct->setShortcuts(QKeySequence::Cut);
- cutAct->setStatusTip(tr("Cut the current selection's contents to the "
- "clipboard"));
- connect(cutAct, SIGNAL(triggered()), this, SLOT(cut()));
-
- copyAct = new QAction(QIcon(":/images/copy.png"), tr("&Copy"), this);
- copyAct->setShortcuts(QKeySequence::Copy);
- copyAct->setStatusTip(tr("Copy the current selection's contents to the "
- "clipboard"));
- connect(copyAct, SIGNAL(triggered()), this, SLOT(copy()));
-
- pasteAct = new QAction(QIcon(":/images/paste.png"), tr("&Paste"), this);
- pasteAct->setShortcuts(QKeySequence::Paste);
- pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current "
- "selection"));
- connect(pasteAct, SIGNAL(triggered()), this, SLOT(paste()));
-#endif
-
- closeAct = new QAction(tr("Cl&ose"), this);
- closeAct->setStatusTip(tr("Close the active window"));
- connect(closeAct, SIGNAL(triggered()),
- mdiArea, SLOT(closeActiveSubWindow()));
-
- closeAllAct = new QAction(tr("Close &All"), this);
- closeAllAct->setStatusTip(tr("Close all the windows"));
- connect(closeAllAct, SIGNAL(triggered()),
- mdiArea, SLOT(closeAllSubWindows()));
-
- tileAct = new QAction(tr("&Tile"), this);
- tileAct->setStatusTip(tr("Tile the windows"));
- connect(tileAct, SIGNAL(triggered()), mdiArea, SLOT(tileSubWindows()));
-
- cascadeAct = new QAction(tr("&Cascade"), this);
- cascadeAct->setStatusTip(tr("Cascade the windows"));
- connect(cascadeAct, SIGNAL(triggered()), mdiArea, SLOT(cascadeSubWindows()));
-
- nextAct = new QAction(tr("Ne&xt"), this);
- nextAct->setShortcuts(QKeySequence::NextChild);
- nextAct->setStatusTip(tr("Move the focus to the next window"));
- connect(nextAct, SIGNAL(triggered()),
- mdiArea, SLOT(activateNextSubWindow()));
-
- previousAct = new QAction(tr("Pre&vious"), this);
- previousAct->setShortcuts(QKeySequence::PreviousChild);
- previousAct->setStatusTip(tr("Move the focus to the previous "
- "window"));
- connect(previousAct, SIGNAL(triggered()),
- mdiArea, SLOT(activatePreviousSubWindow()));
-
- separatorAct = new QAction(this);
- separatorAct->setSeparator(true);
-
- aboutAct = new QAction(tr("&About"), this);
- aboutAct->setStatusTip(tr("Show the application's About box"));
- connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
-
- aboutQtAct = new QAction(tr("About &Qt"), this);
- aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
- connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
-}
-
-void MainWindow::createMenus()
-{
- fileMenu = menuBar()->addMenu(tr("&File"));
- fileMenu->addAction(newAct);
- fileMenu->addAction(openAct);
- fileMenu->addAction(saveAct);
- fileMenu->addAction(saveAsAct);
- fileMenu->addSeparator();
- QAction *action = fileMenu->addAction(tr("Switch layout direction"));
- connect(action, SIGNAL(triggered()), this, SLOT(switchLayoutDirection()));
- fileMenu->addAction(exitAct);
-
- editMenu = menuBar()->addMenu(tr("&Edit"));
-#ifndef QT_NO_CLIPBOARD
- editMenu->addAction(cutAct);
- editMenu->addAction(copyAct);
- editMenu->addAction(pasteAct);
-#endif
-
- windowMenu = menuBar()->addMenu(tr("&Window"));
- updateWindowMenu();
- connect(windowMenu, SIGNAL(aboutToShow()), this, SLOT(updateWindowMenu()));
-
- menuBar()->addSeparator();
-
- helpMenu = menuBar()->addMenu(tr("&Help"));
- helpMenu->addAction(aboutAct);
- helpMenu->addAction(aboutQtAct);
-}
-
-void MainWindow::createToolBars()
-{
- fileToolBar = addToolBar(tr("File"));
- fileToolBar->addAction(newAct);
- fileToolBar->addAction(openAct);
- fileToolBar->addAction(saveAct);
-
-#ifndef QT_NO_CLIPBOARD
- editToolBar = addToolBar(tr("Edit"));
- editToolBar->addAction(cutAct);
- editToolBar->addAction(copyAct);
- editToolBar->addAction(pasteAct);
-#endif
-}
-
-void MainWindow::createStatusBar()
-{
- statusBar()->showMessage(tr("Ready"));
-}
-
-void MainWindow::readSettings()
-{
- QSettings settings("Trolltech", "MDI Example");
- QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
- QSize size = settings.value("size", QSize(400, 400)).toSize();
- move(pos);
- resize(size);
-}
-
-void MainWindow::writeSettings()
-{
- QSettings settings("Trolltech", "MDI Example");
- settings.setValue("pos", pos());
- settings.setValue("size", size());
-}
-
-MdiChild *MainWindow::activeMdiChild()
-{
- if (QMdiSubWindow *activeSubWindow = mdiArea->activeSubWindow())
- return qobject_cast<MdiChild *>(activeSubWindow->widget());
- return 0;
-}
-
-QMdiSubWindow *MainWindow::findMdiChild(const QString &fileName)
-{
- QString canonicalFilePath = QFileInfo(fileName).canonicalFilePath();
-
- foreach (QMdiSubWindow *window, mdiArea->subWindowList()) {
- MdiChild *mdiChild = qobject_cast<MdiChild *>(window->widget());
- if (mdiChild->currentFile() == canonicalFilePath)
- return window;
- }
- return 0;
-}
-
-void MainWindow::switchLayoutDirection()
-{
- if (layoutDirection() == Qt::LeftToRight)
- qApp->setLayoutDirection(Qt::RightToLeft);
- else
- qApp->setLayoutDirection(Qt::LeftToRight);
-}
-
-void MainWindow::setActiveSubWindow(QWidget *window)
-{
- if (!window)
- return;
- mdiArea->setActiveSubWindow(qobject_cast<QMdiSubWindow *>(window));
-}
diff --git a/examples/mainwindows/mdi/mainwindow.h b/examples/mainwindows/mdi/mainwindow.h
deleted file mode 100644
index 1652ca9749..0000000000
--- a/examples/mainwindows/mdi/mainwindow.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples 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 <QMainWindow>
-
-class MdiChild;
-QT_BEGIN_NAMESPACE
-class QAction;
-class QMenu;
-class QMdiArea;
-class QMdiSubWindow;
-class QSignalMapper;
-QT_END_NAMESPACE
-
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- MainWindow();
-
-protected:
- void closeEvent(QCloseEvent *event);
-
-private slots:
- void newFile();
- void open();
- void save();
- void saveAs();
-#ifndef QT_NO_CLIPBOARD
- void cut();
- void copy();
- void paste();
-#endif
- void about();
- void updateMenus();
- void updateWindowMenu();
- MdiChild *createMdiChild();
- void switchLayoutDirection();
- void setActiveSubWindow(QWidget *window);
-
-private:
- void createActions();
- void createMenus();
- void createToolBars();
- void createStatusBar();
- void readSettings();
- void writeSettings();
- MdiChild *activeMdiChild();
- QMdiSubWindow *findMdiChild(const QString &fileName);
-
- QMdiArea *mdiArea;
- QSignalMapper *windowMapper;
-
- QMenu *fileMenu;
- QMenu *editMenu;
- QMenu *windowMenu;
- QMenu *helpMenu;
- QToolBar *fileToolBar;
- QToolBar *editToolBar;
- QAction *newAct;
- QAction *openAct;
- QAction *saveAct;
- QAction *saveAsAct;
- QAction *exitAct;
-#ifndef QT_NO_CLIPBOARD
- QAction *cutAct;
- QAction *copyAct;
- QAction *pasteAct;
-#endif
- QAction *closeAct;
- QAction *closeAllAct;
- QAction *tileAct;
- QAction *cascadeAct;
- QAction *nextAct;
- QAction *previousAct;
- QAction *separatorAct;
- QAction *aboutAct;
- QAction *aboutQtAct;
-};
-
-#endif
diff --git a/examples/mainwindows/mdi/mdi.desktop b/examples/mainwindows/mdi/mdi.desktop
deleted file mode 100644
index 267e6f19d0..0000000000
--- a/examples/mainwindows/mdi/mdi.desktop
+++ /dev/null
@@ -1,11 +0,0 @@
-[Desktop Entry]
-Encoding=UTF-8
-Version=1.0
-Type=Application
-Terminal=false
-Name=MDI
-Exec=/opt/usr/bin/mdi
-Icon=mdi
-X-Window-Icon=
-X-HildonDesk-ShowInToolbar=true
-X-Osso-Type=application/x-executable
diff --git a/examples/mainwindows/mdi/mdi.pro b/examples/mainwindows/mdi/mdi.pro
deleted file mode 100644
index a4387fecd6..0000000000
--- a/examples/mainwindows/mdi/mdi.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-HEADERS = mainwindow.h \
- mdichild.h
-SOURCES = main.cpp \
- mainwindow.cpp \
- mdichild.cpp
-RESOURCES = mdi.qrc
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows/mdi
-sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS mdi.pro images
-sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows/mdi
-INSTALLS += target sources
-
-QT += widgets
-
-simulator: warning(This example might not fully work on Simulator platform)
diff --git a/examples/mainwindows/mdi/mdi.qrc b/examples/mainwindows/mdi/mdi.qrc
deleted file mode 100644
index 0a776fab4d..0000000000
--- a/examples/mainwindows/mdi/mdi.qrc
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>images/copy.png</file>
- <file>images/cut.png</file>
- <file>images/new.png</file>
- <file>images/open.png</file>
- <file>images/paste.png</file>
- <file>images/save.png</file>
-</qresource>
-</RCC>
diff --git a/examples/mainwindows/mdi/mdichild.cpp b/examples/mainwindows/mdi/mdichild.cpp
deleted file mode 100644
index 2279fe7044..0000000000
--- a/examples/mainwindows/mdi/mdichild.cpp
+++ /dev/null
@@ -1,175 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples 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 <QtWidgets>
-
-#include "mdichild.h"
-
-MdiChild::MdiChild()
-{
- setAttribute(Qt::WA_DeleteOnClose);
- isUntitled = true;
-}
-
-void MdiChild::newFile()
-{
- static int sequenceNumber = 1;
-
- isUntitled = true;
- curFile = tr("document%1.txt").arg(sequenceNumber++);
- setWindowTitle(curFile + "[*]");
-
- connect(document(), SIGNAL(contentsChanged()),
- this, SLOT(documentWasModified()));
-}
-
-bool MdiChild::loadFile(const QString &fileName)
-{
- QFile file(fileName);
- if (!file.open(QFile::ReadOnly | QFile::Text)) {
- QMessageBox::warning(this, tr("MDI"),
- tr("Cannot read file %1:\n%2.")
- .arg(fileName)
- .arg(file.errorString()));
- return false;
- }
-
- QTextStream in(&file);
- QApplication::setOverrideCursor(Qt::WaitCursor);
- setPlainText(in.readAll());
- QApplication::restoreOverrideCursor();
-
- setCurrentFile(fileName);
-
- connect(document(), SIGNAL(contentsChanged()),
- this, SLOT(documentWasModified()));
-
- return true;
-}
-
-bool MdiChild::save()
-{
- if (isUntitled) {
- return saveAs();
- } else {
- return saveFile(curFile);
- }
-}
-
-bool MdiChild::saveAs()
-{
- QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"),
- curFile);
- if (fileName.isEmpty())
- return false;
-
- return saveFile(fileName);
-}
-
-bool MdiChild::saveFile(const QString &fileName)
-{
- QFile file(fileName);
- if (!file.open(QFile::WriteOnly | QFile::Text)) {
- QMessageBox::warning(this, tr("MDI"),
- tr("Cannot write file %1:\n%2.")
- .arg(fileName)
- .arg(file.errorString()));
- return false;
- }
-
- QTextStream out(&file);
- QApplication::setOverrideCursor(Qt::WaitCursor);
- out << toPlainText();
- QApplication::restoreOverrideCursor();
-
- setCurrentFile(fileName);
- return true;
-}
-
-QString MdiChild::userFriendlyCurrentFile()
-{
- return strippedName(curFile);
-}
-
-void MdiChild::closeEvent(QCloseEvent *event)
-{
- if (maybeSave()) {
- event->accept();
- } else {
- event->ignore();
- }
-}
-
-void MdiChild::documentWasModified()
-{
- setWindowModified(document()->isModified());
-}
-
-bool MdiChild::maybeSave()
-{
- if (document()->isModified()) {
- QMessageBox::StandardButton ret;
- ret = QMessageBox::warning(this, tr("MDI"),
- tr("'%1' has been modified.\n"
- "Do you want to save your changes?")
- .arg(userFriendlyCurrentFile()),
- QMessageBox::Save | QMessageBox::Discard
- | QMessageBox::Cancel);
- if (ret == QMessageBox::Save)
- return save();
- else if (ret == QMessageBox::Cancel)
- return false;
- }
- return true;
-}
-
-void MdiChild::setCurrentFile(const QString &fileName)
-{
- curFile = QFileInfo(fileName).canonicalFilePath();
- isUntitled = false;
- document()->setModified(false);
- setWindowModified(false);
- setWindowTitle(userFriendlyCurrentFile() + "[*]");
-}
-
-QString MdiChild::strippedName(const QString &fullFileName)
-{
- return QFileInfo(fullFileName).fileName();
-}
diff --git a/examples/mainwindows/mdi/mdichild.h b/examples/mainwindows/mdi/mdichild.h
deleted file mode 100644
index aacdd0f0f6..0000000000
--- a/examples/mainwindows/mdi/mdichild.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples 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 MDICHILD_H
-#define MDICHILD_H
-
-#include <QTextEdit>
-
-class MdiChild : public QTextEdit
-{
- Q_OBJECT
-
-public:
- MdiChild();
-
- void newFile();
- bool loadFile(const QString &fileName);
- bool save();
- bool saveAs();
- bool saveFile(const QString &fileName);
- QString userFriendlyCurrentFile();
- QString currentFile() { return curFile; }
-
-protected:
- void closeEvent(QCloseEvent *event);
-
-private slots:
- void documentWasModified();
-
-private:
- bool maybeSave();
- void setCurrentFile(const QString &fileName);
- QString strippedName(const QString &fullFileName);
-
- QString curFile;
- bool isUntitled;
-};
-
-#endif
diff --git a/examples/mainwindows/menus/main.cpp b/examples/mainwindows/menus/main.cpp
deleted file mode 100644
index 09a923477c..0000000000
--- a/examples/mainwindows/menus/main.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples 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 <QApplication>
-
-#include "mainwindow.h"
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- MainWindow window;
- window.show();
- return app.exec();
-}
diff --git a/examples/mainwindows/menus/mainwindow.cpp b/examples/mainwindows/menus/mainwindow.cpp
deleted file mode 100644
index e1f3a0c099..0000000000
--- a/examples/mainwindows/menus/mainwindow.cpp
+++ /dev/null
@@ -1,370 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples 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 <QtWidgets>
-
-#include "mainwindow.h"
-
-//! [0]
-MainWindow::MainWindow()
-{
- QWidget *widget = new QWidget;
- setCentralWidget(widget);
-//! [0]
-
-//! [1]
- QWidget *topFiller = new QWidget;
- topFiller->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
-
- infoLabel = new QLabel(tr("<i>Choose a menu option, or right-click to "
- "invoke a context menu</i>"));
- infoLabel->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
- infoLabel->setAlignment(Qt::AlignCenter);
-
- QWidget *bottomFiller = new QWidget;
- bottomFiller->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
-
- QVBoxLayout *layout = new QVBoxLayout;
- layout->setMargin(5);
- layout->addWidget(topFiller);
- layout->addWidget(infoLabel);
- layout->addWidget(bottomFiller);
- widget->setLayout(layout);
-//! [1]
-
-//! [2]
- createActions();
- createMenus();
-
- QString message = tr("A context menu is available by right-clicking");
- statusBar()->showMessage(message);
-
- setWindowTitle(tr("Menus"));
- setMinimumSize(160, 160);
- resize(480, 320);
-}
-//! [2]
-
-//! [3]
-void MainWindow::contextMenuEvent(QContextMenuEvent *event)
-{
- QMenu menu(this);
- menu.addAction(cutAct);
- menu.addAction(copyAct);
- menu.addAction(pasteAct);
- menu.exec(event->globalPos());
-}
-//! [3]
-
-void MainWindow::newFile()
-{
- infoLabel->setText(tr("Invoked <b>File|New</b>"));
-}
-
-void MainWindow::open()
-{
- infoLabel->setText(tr("Invoked <b>File|Open</b>"));
-}
-
-void MainWindow::save()
-{
- infoLabel->setText(tr("Invoked <b>File|Save</b>"));
-}
-
-void MainWindow::print()
-{
- infoLabel->setText(tr("Invoked <b>File|Print</b>"));
-}
-
-void MainWindow::undo()
-{
- infoLabel->setText(tr("Invoked <b>Edit|Undo</b>"));
-}
-
-void MainWindow::redo()
-{
- infoLabel->setText(tr("Invoked <b>Edit|Redo</b>"));
-}
-
-void MainWindow::cut()
-{
- infoLabel->setText(tr("Invoked <b>Edit|Cut</b>"));
-}
-
-void MainWindow::copy()
-{
- infoLabel->setText(tr("Invoked <b>Edit|Copy</b>"));
-}
-
-void MainWindow::paste()
-{
- infoLabel->setText(tr("Invoked <b>Edit|Paste</b>"));
-}
-
-void MainWindow::bold()
-{
- infoLabel->setText(tr("Invoked <b>Edit|Format|Bold</b>"));
-}
-
-void MainWindow::italic()
-{
- infoLabel->setText(tr("Invoked <b>Edit|Format|Italic</b>"));
-}
-
-void MainWindow::leftAlign()
-{
- infoLabel->setText(tr("Invoked <b>Edit|Format|Left Align</b>"));
-}
-
-void MainWindow::rightAlign()
-{
- infoLabel->setText(tr("Invoked <b>Edit|Format|Right Align</b>"));
-}
-
-void MainWindow::justify()
-{
- infoLabel->setText(tr("Invoked <b>Edit|Format|Justify</b>"));
-}
-
-void MainWindow::center()
-{
- infoLabel->setText(tr("Invoked <b>Edit|Format|Center</b>"));
-}
-
-void MainWindow::setLineSpacing()
-{
- infoLabel->setText(tr("Invoked <b>Edit|Format|Set Line Spacing</b>"));
-}
-
-void MainWindow::setParagraphSpacing()
-{
- infoLabel->setText(tr("Invoked <b>Edit|Format|Set Paragraph Spacing</b>"));
-}
-
-void MainWindow::about()
-{
- infoLabel->setText(tr("Invoked <b>Help|About</b>"));
- QMessageBox::about(this, tr("About Menu"),
- tr("The <b>Menu</b> example shows how to create "
- "menu-bar menus and context menus."));
-}
-
-void MainWindow::aboutQt()
-{
- infoLabel->setText(tr("Invoked <b>Help|About Qt</b>"));
-}
-
-//! [4]
-void MainWindow::createActions()
-{
-//! [5]
- newAct = new QAction(tr("&New"), this);
- newAct->setShortcuts(QKeySequence::New);
- newAct->setStatusTip(tr("Create a new file"));
- connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));
-//! [4]
-
- openAct = new QAction(tr("&Open..."), this);
- openAct->setShortcuts(QKeySequence::Open);
- openAct->setStatusTip(tr("Open an existing file"));
- connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
-//! [5]
-
- saveAct = new QAction(tr("&Save"), this);
- saveAct->setShortcuts(QKeySequence::Save);
- saveAct->setStatusTip(tr("Save the document to disk"));
- connect(saveAct, SIGNAL(triggered()), this, SLOT(save()));
-
- printAct = new QAction(tr("&Print..."), this);
- printAct->setShortcuts(QKeySequence::Print);
- printAct->setStatusTip(tr("Print the document"));
- connect(printAct, SIGNAL(triggered()), this, SLOT(print()));
-
- exitAct = new QAction(tr("E&xit"), this);
- exitAct->setShortcuts(QKeySequence::Quit);
- exitAct->setStatusTip(tr("Exit the application"));
- connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
-
- undoAct = new QAction(tr("&Undo"), this);
- undoAct->setShortcuts(QKeySequence::Undo);
- undoAct->setStatusTip(tr("Undo the last operation"));
- connect(undoAct, SIGNAL(triggered()), this, SLOT(undo()));
-
- redoAct = new QAction(tr("&Redo"), this);
- redoAct->setShortcuts(QKeySequence::Redo);
- redoAct->setStatusTip(tr("Redo the last operation"));
- connect(redoAct, SIGNAL(triggered()), this, SLOT(redo()));
-
- cutAct = new QAction(tr("Cu&t"), this);
- cutAct->setShortcuts(QKeySequence::Cut);
- cutAct->setStatusTip(tr("Cut the current selection's contents to the "
- "clipboard"));
- connect(cutAct, SIGNAL(triggered()), this, SLOT(cut()));
-
- copyAct = new QAction(tr("&Copy"), this);
- copyAct->setShortcuts(QKeySequence::Copy);
- copyAct->setStatusTip(tr("Copy the current selection's contents to the "
- "clipboard"));
- connect(copyAct, SIGNAL(triggered()), this, SLOT(copy()));
-
- pasteAct = new QAction(tr("&Paste"), this);
- pasteAct->setShortcuts(QKeySequence::Paste);
- pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current "
- "selection"));
- connect(pasteAct, SIGNAL(triggered()), this, SLOT(paste()));
-
- boldAct = new QAction(tr("&Bold"), this);
- boldAct->setCheckable(true);
- boldAct->setShortcut(QKeySequence::Bold);
- boldAct->setStatusTip(tr("Make the text bold"));
- connect(boldAct, SIGNAL(triggered()), this, SLOT(bold()));
-
- QFont boldFont = boldAct->font();
- boldFont.setBold(true);
- boldAct->setFont(boldFont);
-
- italicAct = new QAction(tr("&Italic"), this);
- italicAct->setCheckable(true);
- italicAct->setShortcut(QKeySequence::Italic);
- italicAct->setStatusTip(tr("Make the text italic"));
- connect(italicAct, SIGNAL(triggered()), this, SLOT(italic()));
-
- QFont italicFont = italicAct->font();
- italicFont.setItalic(true);
- italicAct->setFont(italicFont);
-
- setLineSpacingAct = new QAction(tr("Set &Line Spacing..."), this);
- setLineSpacingAct->setStatusTip(tr("Change the gap between the lines of a "
- "paragraph"));
- connect(setLineSpacingAct, SIGNAL(triggered()), this, SLOT(setLineSpacing()));
-
- setParagraphSpacingAct = new QAction(tr("Set &Paragraph Spacing..."), this);
- setParagraphSpacingAct->setStatusTip(tr("Change the gap between paragraphs"));
- connect(setParagraphSpacingAct, SIGNAL(triggered()),
- this, SLOT(setParagraphSpacing()));
-
- aboutAct = new QAction(tr("&About"), this);
- aboutAct->setStatusTip(tr("Show the application's About box"));
- connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
-
- aboutQtAct = new QAction(tr("About &Qt"), this);
- aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
- connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
- connect(aboutQtAct, SIGNAL(triggered()), this, SLOT(aboutQt()));
-
- leftAlignAct = new QAction(tr("&Left Align"), this);
- leftAlignAct->setCheckable(true);
- leftAlignAct->setShortcut(tr("Ctrl+L"));
- leftAlignAct->setStatusTip(tr("Left align the selected text"));
- connect(leftAlignAct, SIGNAL(triggered()), this, SLOT(leftAlign()));
-
- rightAlignAct = new QAction(tr("&Right Align"), this);
- rightAlignAct->setCheckable(true);
- rightAlignAct->setShortcut(tr("Ctrl+R"));
- rightAlignAct->setStatusTip(tr("Right align the selected text"));
- connect(rightAlignAct, SIGNAL(triggered()), this, SLOT(rightAlign()));
-
- justifyAct = new QAction(tr("&Justify"), this);
- justifyAct->setCheckable(true);
- justifyAct->setShortcut(tr("Ctrl+J"));
- justifyAct->setStatusTip(tr("Justify the selected text"));
- connect(justifyAct, SIGNAL(triggered()), this, SLOT(justify()));
-
- centerAct = new QAction(tr("&Center"), this);
- centerAct->setCheckable(true);
- centerAct->setShortcut(tr("Ctrl+E"));
- centerAct->setStatusTip(tr("Center the selected text"));
- connect(centerAct, SIGNAL(triggered()), this, SLOT(center()));
-
-//! [6] //! [7]
- alignmentGroup = new QActionGroup(this);
- alignmentGroup->addAction(leftAlignAct);
- alignmentGroup->addAction(rightAlignAct);
- alignmentGroup->addAction(justifyAct);
- alignmentGroup->addAction(centerAct);
- leftAlignAct->setChecked(true);
-//! [6]
-}
-//! [7]
-
-//! [8]
-void MainWindow::createMenus()
-{
-//! [9] //! [10]
- fileMenu = menuBar()->addMenu(tr("&File"));
- fileMenu->addAction(newAct);
-//! [9]
- fileMenu->addAction(openAct);
-//! [10]
- fileMenu->addAction(saveAct);
- fileMenu->addAction(printAct);
-//! [11]
- fileMenu->addSeparator();
-//! [11]
- fileMenu->addAction(exitAct);
-
- editMenu = menuBar()->addMenu(tr("&Edit"));
- editMenu->addAction(undoAct);
- editMenu->addAction(redoAct);
- editMenu->addSeparator();
- editMenu->addAction(cutAct);
- editMenu->addAction(copyAct);
- editMenu->addAction(pasteAct);
- editMenu->addSeparator();
-
- helpMenu = menuBar()->addMenu(tr("&Help"));
- helpMenu->addAction(aboutAct);
- helpMenu->addAction(aboutQtAct);
-//! [8]
-
-//! [12]
- formatMenu = editMenu->addMenu(tr("&Format"));
- formatMenu->addAction(boldAct);
- formatMenu->addAction(italicAct);
- formatMenu->addSeparator()->setText(tr("Alignment"));
- formatMenu->addAction(leftAlignAct);
- formatMenu->addAction(rightAlignAct);
- formatMenu->addAction(justifyAct);
- formatMenu->addAction(centerAct);
- formatMenu->addSeparator();
- formatMenu->addAction(setLineSpacingAct);
- formatMenu->addAction(setParagraphSpacingAct);
-}
-//! [12]
diff --git a/examples/mainwindows/menus/mainwindow.h b/examples/mainwindows/menus/mainwindow.h
deleted file mode 100644
index ebafb529eb..0000000000
--- a/examples/mainwindows/menus/mainwindow.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples 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 <QMainWindow>
-
-QT_BEGIN_NAMESPACE
-class QAction;
-class QActionGroup;
-class QLabel;
-class QMenu;
-QT_END_NAMESPACE
-
-//! [0]
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- MainWindow();
-
-protected:
- void contextMenuEvent(QContextMenuEvent *event);
-//! [0]
-
-//! [1]
-private slots:
- void newFile();
- void open();
- void save();
- void print();
- void undo();
- void redo();
- void cut();
- void copy();
- void paste();
- void bold();
- void italic();
- void leftAlign();
- void rightAlign();
- void justify();
- void center();
- void setLineSpacing();
- void setParagraphSpacing();
- void about();
- void aboutQt();
-//! [1]
-
-//! [2]
-private:
- void createActions();
- void createMenus();
-//! [2]
-
-//! [3]
- QMenu *fileMenu;
- QMenu *editMenu;
- QMenu *formatMenu;
- QMenu *helpMenu;
- QActionGroup *alignmentGroup;
- QAction *newAct;
- QAction *openAct;
- QAction *saveAct;
- QAction *printAct;
- QAction *exitAct;
- QAction *undoAct;
- QAction *redoAct;
- QAction *cutAct;
- QAction *copyAct;
- QAction *pasteAct;
- QAction *boldAct;
- QAction *italicAct;
- QAction *leftAlignAct;
- QAction *rightAlignAct;
- QAction *justifyAct;
- QAction *centerAct;
- QAction *setLineSpacingAct;
- QAction *setParagraphSpacingAct;
- QAction *aboutAct;
- QAction *aboutQtAct;
- QLabel *infoLabel;
-};
-//! [3]
-
-#endif
diff --git a/examples/mainwindows/menus/menus.desktop b/examples/mainwindows/menus/menus.desktop
deleted file mode 100644
index dc2bda92af..0000000000
--- a/examples/mainwindows/menus/menus.desktop
+++ /dev/null
@@ -1,11 +0,0 @@
-[Desktop Entry]
-Encoding=UTF-8
-Version=1.0
-Type=Application
-Terminal=false
-Name=Menus
-Exec=/opt/usr/bin/menus
-Icon=menus
-X-Window-Icon=
-X-HildonDesk-ShowInToolbar=true
-X-Osso-Type=application/x-executable
diff --git a/examples/mainwindows/menus/menus.pro b/examples/mainwindows/menus/menus.pro
deleted file mode 100644
index 5ed1e0dae5..0000000000
--- a/examples/mainwindows/menus/menus.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-HEADERS = mainwindow.h
-SOURCES = mainwindow.cpp \
- main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows/menus
-sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS menus.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows/menus
-INSTALLS += target sources
-
-QT += widgets
diff --git a/examples/mainwindows/recentfiles/main.cpp b/examples/mainwindows/recentfiles/main.cpp
deleted file mode 100644
index 023357719e..0000000000
--- a/examples/mainwindows/recentfiles/main.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples 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 <QApplication>
-
-#include "mainwindow.h"
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- app.setOrganizationName("Trolltech");
- app.setApplicationName("Recent Files Example");
- MainWindow *mainWin = new MainWindow;
- mainWin->show();
- return app.exec();
-}
diff --git a/examples/mainwindows/recentfiles/mainwindow.cpp b/examples/mainwindows/recentfiles/mainwindow.cpp
deleted file mode 100644
index b439ae8950..0000000000
--- a/examples/mainwindows/recentfiles/mainwindow.cpp
+++ /dev/null
@@ -1,251 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples 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 <QtWidgets>
-
-#include "mainwindow.h"
-
-MainWindow::MainWindow()
-{
- setAttribute(Qt::WA_DeleteOnClose);
-
- textEdit = new QTextEdit;
- setCentralWidget(textEdit);
-
- createActions();
- createMenus();
- (void)statusBar();
-
- setWindowFilePath(QString());
- resize(400, 300);
-}
-
-void MainWindow::newFile()
-{
- MainWindow *other = new MainWindow;
- other->show();
-}
-
-void MainWindow::open()
-{
- QString fileName = QFileDialog::getOpenFileName(this);
- if (!fileName.isEmpty())
- loadFile(fileName);
-}
-
-void MainWindow::save()
-{
- if (curFile.isEmpty())
- saveAs();
- else
- saveFile(curFile);
-}
-
-void MainWindow::saveAs()
-{
- QString fileName = QFileDialog::getSaveFileName(this);
- if (fileName.isEmpty())
- return;
-
- saveFile(fileName);
-}
-
-void MainWindow::openRecentFile()
-{
- QAction *action = qobject_cast<QAction *>(sender());
- if (action)
- loadFile(action->data().toString());
-}
-
-void MainWindow::about()
-{
- QMessageBox::about(this, tr("About Recent Files"),
- tr("The <b>Recent Files</b> example demonstrates how to provide a "
- "recently used file menu in a Qt application."));
-}
-
-void MainWindow::createActions()
-{
- newAct = new QAction(tr("&New"), this);
- newAct->setShortcuts(QKeySequence::New);
- newAct->setStatusTip(tr("Create a new file"));
- connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));
-
- openAct = new QAction(tr("&Open..."), this);
- openAct->setShortcuts(QKeySequence::Open);
- openAct->setStatusTip(tr("Open an existing file"));
- connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
-
- saveAct = new QAction(tr("&Save"), this);
- saveAct->setShortcuts(QKeySequence::Save);
- saveAct->setStatusTip(tr("Save the document to disk"));
- connect(saveAct, SIGNAL(triggered()), this, SLOT(save()));
-
- saveAsAct = new QAction(tr("Save &As..."), this);
- saveAsAct->setShortcuts(QKeySequence::SaveAs);
- saveAsAct->setStatusTip(tr("Save the document under a new name"));
- connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs()));
-
- for (int i = 0; i < MaxRecentFiles; ++i) {
- recentFileActs[i] = new QAction(this);
- recentFileActs[i]->setVisible(false);
- connect(recentFileActs[i], SIGNAL(triggered()),
- this, SLOT(openRecentFile()));
- }
-
- exitAct = new QAction(tr("E&xit"), this);
- exitAct->setShortcuts(QKeySequence::Quit);
- exitAct->setStatusTip(tr("Exit the application"));
- connect(exitAct, SIGNAL(triggered()), qApp, SLOT(closeAllWindows()));
-
- aboutAct = new QAction(tr("&About"), this);
- aboutAct->setStatusTip(tr("Show the application's About box"));
- connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
-
- aboutQtAct = new QAction(tr("About &Qt"), this);
- aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
- connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
-}
-
-void MainWindow::createMenus()
-{
- fileMenu = menuBar()->addMenu(tr("&File"));
- fileMenu->addAction(newAct);
- fileMenu->addAction(openAct);
- fileMenu->addAction(saveAct);
- fileMenu->addAction(saveAsAct);
- separatorAct = fileMenu->addSeparator();
- for (int i = 0; i < MaxRecentFiles; ++i)
- fileMenu->addAction(recentFileActs[i]);
- fileMenu->addSeparator();
- fileMenu->addAction(exitAct);
- updateRecentFileActions();
-
- menuBar()->addSeparator();
-
- helpMenu = menuBar()->addMenu(tr("&Help"));
- helpMenu->addAction(aboutAct);
- helpMenu->addAction(aboutQtAct);
-}
-
-void MainWindow::loadFile(const QString &fileName)
-{
- QFile file(fileName);
- if (!file.open(QFile::ReadOnly | QFile::Text)) {
- QMessageBox::warning(this, tr("Recent Files"),
- tr("Cannot read file %1:\n%2.")
- .arg(fileName)
- .arg(file.errorString()));
- return;
- }
-
- QTextStream in(&file);
- QApplication::setOverrideCursor(Qt::WaitCursor);
- textEdit->setPlainText(in.readAll());
- QApplication::restoreOverrideCursor();
-
- setCurrentFile(fileName);
- statusBar()->showMessage(tr("File loaded"), 2000);
-}
-
-void MainWindow::saveFile(const QString &fileName)
-{
- QFile file(fileName);
- if (!file.open(QFile::WriteOnly | QFile::Text)) {
- QMessageBox::warning(this, tr("Recent Files"),
- tr("Cannot write file %1:\n%2.")
- .arg(fileName)
- .arg(file.errorString()));
- return;
- }
-
- QTextStream out(&file);
- QApplication::setOverrideCursor(Qt::WaitCursor);
- out << textEdit->toPlainText();
- QApplication::restoreOverrideCursor();
-
- setCurrentFile(fileName);
- statusBar()->showMessage(tr("File saved"), 2000);
-}
-
-void MainWindow::setCurrentFile(const QString &fileName)
-{
- curFile = fileName;
- setWindowFilePath(curFile);
-
- QSettings settings;
- QStringList files = settings.value("recentFileList").toStringList();
- files.removeAll(fileName);
- files.prepend(fileName);
- while (files.size() > MaxRecentFiles)
- files.removeLast();
-
- settings.setValue("recentFileList", files);
-
- foreach (QWidget *widget, QApplication::topLevelWidgets()) {
- MainWindow *mainWin = qobject_cast<MainWindow *>(widget);
- if (mainWin)
- mainWin->updateRecentFileActions();
- }
-}
-
-void MainWindow::updateRecentFileActions()
-{
- QSettings settings;
- QStringList files = settings.value("recentFileList").toStringList();
-
- int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
-
- for (int i = 0; i < numRecentFiles; ++i) {
- QString text = tr("&%1 %2").arg(i + 1).arg(strippedName(files[i]));
- recentFileActs[i]->setText(text);
- recentFileActs[i]->setData(files[i]);
- recentFileActs[i]->setVisible(true);
- }
- for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
- recentFileActs[j]->setVisible(false);
-
- separatorAct->setVisible(numRecentFiles > 0);
-}
-
-QString MainWindow::strippedName(const QString &fullFileName)
-{
- return QFileInfo(fullFileName).fileName();
-}
diff --git a/examples/mainwindows/recentfiles/mainwindow.h b/examples/mainwindows/recentfiles/mainwindow.h
deleted file mode 100644
index dd548838fc..0000000000
--- a/examples/mainwindows/recentfiles/mainwindow.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples 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 <QList>
-#include <QMainWindow>
-
-QT_BEGIN_NAMESPACE
-class QAction;
-class QMenu;
-class QTextEdit;
-QT_END_NAMESPACE
-
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- MainWindow();
-
-private slots:
- void newFile();
- void open();
- void save();
- void saveAs();
- void openRecentFile();
- void about();
-
-private:
- void createActions();
- void createMenus();
- void loadFile(const QString &fileName);
- void saveFile(const QString &fileName);
- void setCurrentFile(const QString &fileName);
- void updateRecentFileActions();
- QString strippedName(const QString &fullFileName);
-
- QString curFile;
-
- QTextEdit *textEdit;
- QMenu *fileMenu;
- QMenu *recentFilesMenu;
- QMenu *helpMenu;
- QAction *newAct;
- QAction *openAct;
- QAction *saveAct;
- QAction *saveAsAct;
- QAction *exitAct;
- QAction *aboutAct;
- QAction *aboutQtAct;
- QAction *separatorAct;
-
- enum { MaxRecentFiles = 5 };
- QAction *recentFileActs[MaxRecentFiles];
-};
-
-#endif
diff --git a/examples/mainwindows/recentfiles/recentfiles.desktop b/examples/mainwindows/recentfiles/recentfiles.desktop
deleted file mode 100644
index c314cf7f7c..0000000000
--- a/examples/mainwindows/recentfiles/recentfiles.desktop
+++ /dev/null
@@ -1,11 +0,0 @@
-[Desktop Entry]
-Encoding=UTF-8
-Version=1.0
-Type=Application
-Terminal=false
-Name=Recent Files
-Exec=/opt/usr/bin/recentfiles
-Icon=recentfiles
-X-Window-Icon=
-X-HildonDesk-ShowInToolbar=true
-X-Osso-Type=application/x-executable
diff --git a/examples/mainwindows/recentfiles/recentfiles.pro b/examples/mainwindows/recentfiles/recentfiles.pro
deleted file mode 100644
index 5425efc68f..0000000000
--- a/examples/mainwindows/recentfiles/recentfiles.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-HEADERS = mainwindow.h
-SOURCES = main.cpp \
- mainwindow.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows/recentfiles
-sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS recentfiles.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows/recentfiles
-INSTALLS += target sources
-
-QT += widgets
-
-simulator: warning(This example might not fully work on Simulator platform)
diff --git a/examples/mainwindows/sdi/images/copy.png b/examples/mainwindows/sdi/images/copy.png
deleted file mode 100644
index 2aeb28288f..0000000000
--- a/examples/mainwindows/sdi/images/copy.png
+++ /dev/null
Binary files differ
diff --git a/examples/mainwindows/sdi/images/cut.png b/examples/mainwindows/sdi/images/cut.png
deleted file mode 100644
index 54638e9386..0000000000
--- a/examples/mainwindows/sdi/images/cut.png
+++ /dev/null
Binary files differ
diff --git a/examples/mainwindows/sdi/images/new.png b/examples/mainwindows/sdi/images/new.png
deleted file mode 100644
index 12131b0100..0000000000
--- a/examples/mainwindows/sdi/images/new.png
+++ /dev/null
Binary files differ
diff --git a/examples/mainwindows/sdi/images/open.png b/examples/mainwindows/sdi/images/open.png
deleted file mode 100644
index 45fa2883a7..0000000000
--- a/examples/mainwindows/sdi/images/open.png
+++ /dev/null
Binary files differ
diff --git a/examples/mainwindows/sdi/images/paste.png b/examples/mainwindows/sdi/images/paste.png
deleted file mode 100644
index c14425cad1..0000000000
--- a/examples/mainwindows/sdi/images/paste.png
+++ /dev/null
Binary files differ
diff --git a/examples/mainwindows/sdi/images/save.png b/examples/mainwindows/sdi/images/save.png
deleted file mode 100644
index daba865faf..0000000000
--- a/examples/mainwindows/sdi/images/save.png
+++ /dev/null
Binary files differ
diff --git a/examples/mainwindows/sdi/main.cpp b/examples/mainwindows/sdi/main.cpp
deleted file mode 100644
index fbbedd9f0d..0000000000
--- a/examples/mainwindows/sdi/main.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples 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 <QApplication>
-
-#include "mainwindow.h"
-
-int main(int argc, char *argv[])
-{
- Q_INIT_RESOURCE(sdi);
- QApplication app(argc, argv);
- app.setApplicationName("SDI Example");
- app.setOrganizationName("Trolltech");
- MainWindow *mainWin = new MainWindow;
- mainWin->show();
- return app.exec();
-}
diff --git a/examples/mainwindows/sdi/mainwindow.cpp b/examples/mainwindows/sdi/mainwindow.cpp
deleted file mode 100644
index bc0685fd77..0000000000
--- a/examples/mainwindows/sdi/mainwindow.cpp
+++ /dev/null
@@ -1,372 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples 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 <QtWidgets>
-
-#include "mainwindow.h"
-
-MainWindow::MainWindow()
-{
- init();
- setCurrentFile("");
-}
-
-MainWindow::MainWindow(const QString &fileName)
-{
- init();
- loadFile(fileName);
-}
-
-void MainWindow::closeEvent(QCloseEvent *event)
-{
- if (maybeSave()) {
- writeSettings();
- event->accept();
- } else {
- event->ignore();
- }
-}
-
-void MainWindow::newFile()
-{
- MainWindow *other = new MainWindow;
- other->move(x() + 40, y() + 40);
- other->show();
-}
-
-void MainWindow::open()
-{
- QString fileName = QFileDialog::getOpenFileName(this);
- if (!fileName.isEmpty()) {
- MainWindow *existing = findMainWindow(fileName);
- if (existing) {
- existing->show();
- existing->raise();
- existing->activateWindow();
- return;
- }
-
- if (isUntitled && textEdit->document()->isEmpty()
- && !isWindowModified()) {
- loadFile(fileName);
- } else {
- MainWindow *other = new MainWindow(fileName);
- if (other->isUntitled) {
- delete other;
- return;
- }
- other->move(x() + 40, y() + 40);
- other->show();
- }
- }
-}
-
-bool MainWindow::save()
-{
- if (isUntitled) {
- return saveAs();
- } else {
- return saveFile(curFile);
- }
-}
-
-bool MainWindow::saveAs()
-{
- QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"),
- curFile);
- if (fileName.isEmpty())
- return false;
-
- return saveFile(fileName);
-}
-
-void MainWindow::about()
-{
- QMessageBox::about(this, tr("About SDI"),
- tr("The <b>SDI</b> example demonstrates how to write single "
- "document interface applications using Qt."));
-}
-
-void MainWindow::documentWasModified()
-{
- setWindowModified(true);
-}
-
-void MainWindow::init()
-{
- setAttribute(Qt::WA_DeleteOnClose);
-
- isUntitled = true;
-
- textEdit = new QTextEdit;
- setCentralWidget(textEdit);
-
- createActions();
- createMenus();
- createToolBars();
- createStatusBar();
-
- readSettings();
-
- connect(textEdit->document(), SIGNAL(contentsChanged()),
- this, SLOT(documentWasModified()));
-
- setUnifiedTitleAndToolBarOnMac(true);
-}
-
-void MainWindow::createActions()
-{
- newAct = new QAction(QIcon(":/images/new.png"), tr("&New"), this);
- newAct->setShortcuts(QKeySequence::New);
- newAct->setStatusTip(tr("Create a new file"));
- connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));
-
- openAct = new QAction(QIcon(":/images/open.png"), tr("&Open..."), this);
- openAct->setShortcuts(QKeySequence::Open);
- openAct->setStatusTip(tr("Open an existing file"));
- connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
-
- saveAct = new QAction(QIcon(":/images/save.png"), tr("&Save"), this);
- saveAct->setShortcuts(QKeySequence::Save);
- saveAct->setStatusTip(tr("Save the document to disk"));
- connect(saveAct, SIGNAL(triggered()), this, SLOT(save()));
-
- saveAsAct = new QAction(tr("Save &As..."), this);
- saveAsAct->setShortcuts(QKeySequence::SaveAs);
- saveAsAct->setStatusTip(tr("Save the document under a new name"));
- connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs()));
-
- closeAct = new QAction(tr("&Close"), this);
- closeAct->setShortcut(tr("Ctrl+W"));
- closeAct->setStatusTip(tr("Close this window"));
- connect(closeAct, SIGNAL(triggered()), this, SLOT(close()));
-
- exitAct = new QAction(tr("E&xit"), this);
- exitAct->setShortcuts(QKeySequence::Quit);
- exitAct->setStatusTip(tr("Exit the application"));
- connect(exitAct, SIGNAL(triggered()), qApp, SLOT(closeAllWindows()));
-
- cutAct = new QAction(QIcon(":/images/cut.png"), tr("Cu&t"), this);
- cutAct->setShortcuts(QKeySequence::Cut);
- cutAct->setStatusTip(tr("Cut the current selection's contents to the "
- "clipboard"));
- connect(cutAct, SIGNAL(triggered()), textEdit, SLOT(cut()));
-
- copyAct = new QAction(QIcon(":/images/copy.png"), tr("&Copy"), this);
- copyAct->setShortcuts(QKeySequence::Copy);
- copyAct->setStatusTip(tr("Copy the current selection's contents to the "
- "clipboard"));
- connect(copyAct, SIGNAL(triggered()), textEdit, SLOT(copy()));
-
- pasteAct = new QAction(QIcon(":/images/paste.png"), tr("&Paste"), this);
- pasteAct->setShortcuts(QKeySequence::Paste);
- pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current "
- "selection"));
- connect(pasteAct, SIGNAL(triggered()), textEdit, SLOT(paste()));
-
- aboutAct = new QAction(tr("&About"), this);
- aboutAct->setStatusTip(tr("Show the application's About box"));
- connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
-
- aboutQtAct = new QAction(tr("About &Qt"), this);
- aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
- connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
-
-
- cutAct->setEnabled(false);
- copyAct->setEnabled(false);
- connect(textEdit, SIGNAL(copyAvailable(bool)),
- cutAct, SLOT(setEnabled(bool)));
- connect(textEdit, SIGNAL(copyAvailable(bool)),
- copyAct, SLOT(setEnabled(bool)));
-}
-
-//! [implicit tr context]
-void MainWindow::createMenus()
-{
- fileMenu = menuBar()->addMenu(tr("&File"));
-//! [implicit tr context]
- fileMenu->addAction(newAct);
- fileMenu->addAction(openAct);
- fileMenu->addAction(saveAct);
- fileMenu->addAction(saveAsAct);
- fileMenu->addSeparator();
- fileMenu->addAction(closeAct);
- fileMenu->addAction(exitAct);
-
- editMenu = menuBar()->addMenu(tr("&Edit"));
- editMenu->addAction(cutAct);
- editMenu->addAction(copyAct);
- editMenu->addAction(pasteAct);
-
- menuBar()->addSeparator();
-
- helpMenu = menuBar()->addMenu(tr("&Help"));
- helpMenu->addAction(aboutAct);
- helpMenu->addAction(aboutQtAct);
-}
-
-void MainWindow::createToolBars()
-{
-//! [0]
- fileToolBar = addToolBar(tr("File"));
- fileToolBar->addAction(newAct);
- fileToolBar->addAction(openAct);
-//! [0]
- fileToolBar->addAction(saveAct);
-
- editToolBar = addToolBar(tr("Edit"));
- editToolBar->addAction(cutAct);
- editToolBar->addAction(copyAct);
- editToolBar->addAction(pasteAct);
-}
-
-void MainWindow::createStatusBar()
-{
- statusBar()->showMessage(tr("Ready"));
-}
-
-void MainWindow::readSettings()
-{
- QSettings settings;
- QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
- QSize size = settings.value("size", QSize(400, 400)).toSize();
- move(pos);
- resize(size);
-}
-
-void MainWindow::writeSettings()
-{
- QSettings settings;
- settings.setValue("pos", pos());
- settings.setValue("size", size());
-}
-
-bool MainWindow::maybeSave()
-{
- if (textEdit->document()->isModified()) {
- QMessageBox::StandardButton ret;
- ret = QMessageBox::warning(this, tr("SDI"),
- tr("The document has been modified.\n"
- "Do you want to save your changes?"),
- QMessageBox::Save | QMessageBox::Discard
- | QMessageBox::Cancel);
- if (ret == QMessageBox::Save)
- return save();
- else if (ret == QMessageBox::Cancel)
- return false;
- }
- return true;
-}
-
-void MainWindow::loadFile(const QString &fileName)
-{
-
- QFile file(fileName);
- if (!file.open(QFile::ReadOnly | QFile::Text)) {
- QMessageBox::warning(this, tr("SDI"),
- tr("Cannot read file %1:\n%2.")
- .arg(fileName)
- .arg(file.errorString()));
- return;
- }
-
- QTextStream in(&file);
- QApplication::setOverrideCursor(Qt::WaitCursor);
- textEdit->setPlainText(in.readAll());
- QApplication::restoreOverrideCursor();
-
- setCurrentFile(fileName);
- statusBar()->showMessage(tr("File loaded"), 2000);
-}
-
-bool MainWindow::saveFile(const QString &fileName)
-{
- QFile file(fileName);
- if (!file.open(QFile::WriteOnly | QFile::Text)) {
- QMessageBox::warning(this, tr("SDI"),
- tr("Cannot write file %1:\n%2.")
- .arg(fileName)
- .arg(file.errorString()));
- return false;
- }
-
- QTextStream out(&file);
- QApplication::setOverrideCursor(Qt::WaitCursor);
- out << textEdit->toPlainText();
- QApplication::restoreOverrideCursor();
-
- setCurrentFile(fileName);
- statusBar()->showMessage(tr("File saved"), 2000);
- return true;
-}
-
-void MainWindow::setCurrentFile(const QString &fileName)
-{
- static int sequenceNumber = 1;
-
- isUntitled = fileName.isEmpty();
- if (isUntitled) {
- curFile = tr("document%1.txt").arg(sequenceNumber++);
- } else {
- curFile = QFileInfo(fileName).canonicalFilePath();
- }
-
- textEdit->document()->setModified(false);
- setWindowModified(false);
- setWindowFilePath(curFile);
-}
-
-QString MainWindow::strippedName(const QString &fullFileName)
-{
- return QFileInfo(fullFileName).fileName();
-}
-
-MainWindow *MainWindow::findMainWindow(const QString &fileName)
-{
- QString canonicalFilePath = QFileInfo(fileName).canonicalFilePath();
-
- foreach (QWidget *widget, qApp->topLevelWidgets()) {
- MainWindow *mainWin = qobject_cast<MainWindow *>(widget);
- if (mainWin && mainWin->curFile == canonicalFilePath)
- return mainWin;
- }
- return 0;
-}
diff --git a/examples/mainwindows/sdi/mainwindow.h b/examples/mainwindows/sdi/mainwindow.h
deleted file mode 100644
index 4bf5ebe9b5..0000000000
--- a/examples/mainwindows/sdi/mainwindow.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples 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 <QMainWindow>
-
-QT_BEGIN_NAMESPACE
-class QAction;
-class QMenu;
-class QTextEdit;
-QT_END_NAMESPACE
-
-//! [class definition with macro]
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- MainWindow();
-//! [class definition with macro]
- MainWindow(const QString &fileName);
-
-protected:
- void closeEvent(QCloseEvent *event);
-
-private slots:
- void newFile();
- void open();
- bool save();
- bool saveAs();
- void about();
- void documentWasModified();
-
-private:
- void init();
- void createActions();
- void createMenus();
- void createToolBars();
- void createStatusBar();
- void readSettings();
- void writeSettings();
- bool maybeSave();
- void loadFile(const QString &fileName);
- bool saveFile(const QString &fileName);
- void setCurrentFile(const QString &fileName);
- QString strippedName(const QString &fullFileName);
- MainWindow *findMainWindow(const QString &fileName);
-
- QTextEdit *textEdit;
- QString curFile;
- bool isUntitled;
-
- QMenu *fileMenu;
- QMenu *editMenu;
- QMenu *helpMenu;
- QToolBar *fileToolBar;
- QToolBar *editToolBar;
- QAction *newAct;
- QAction *openAct;
- QAction *saveAct;
- QAction *saveAsAct;
- QAction *closeAct;
- QAction *exitAct;
- QAction *cutAct;
- QAction *copyAct;
- QAction *pasteAct;
- QAction *aboutAct;
- QAction *aboutQtAct;
-};
-
-#endif
diff --git a/examples/mainwindows/sdi/sdi.desktop b/examples/mainwindows/sdi/sdi.desktop
deleted file mode 100644
index 06d7289c8b..0000000000
--- a/examples/mainwindows/sdi/sdi.desktop
+++ /dev/null
@@ -1,11 +0,0 @@
-[Desktop Entry]
-Encoding=UTF-8
-Version=1.0
-Type=Application
-Terminal=false
-Name=SDI
-Exec=/opt/usr/bin/sdi
-Icon=sdi
-X-Window-Icon=
-X-HildonDesk-ShowInToolbar=true
-X-Osso-Type=application/x-executable
diff --git a/examples/mainwindows/sdi/sdi.pro b/examples/mainwindows/sdi/sdi.pro
deleted file mode 100644
index cd5e0f1616..0000000000
--- a/examples/mainwindows/sdi/sdi.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-HEADERS = mainwindow.h
-SOURCES = main.cpp \
- mainwindow.cpp
-RESOURCES = sdi.qrc
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows/sdi
-sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS sdi.pro images
-sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows/sdi
-INSTALLS += target sources
-
-QT += widgets
-
-simulator: warning(This example might not fully work on Simulator platform)
diff --git a/examples/mainwindows/sdi/sdi.qrc b/examples/mainwindows/sdi/sdi.qrc
deleted file mode 100644
index 0a776fab4d..0000000000
--- a/examples/mainwindows/sdi/sdi.qrc
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>images/copy.png</file>
- <file>images/cut.png</file>
- <file>images/new.png</file>
- <file>images/open.png</file>
- <file>images/paste.png</file>
- <file>images/save.png</file>
-</qresource>
-</RCC>