summaryrefslogtreecommitdiffstats
path: root/qtsingleapplication/examples
diff options
context:
space:
mode:
authoraavit <qt-info@nokia.com>2010-10-06 12:57:48 +0200
committeraavit <qt-info@nokia.com>2010-10-06 12:57:48 +0200
commit5019ece540d1f9dc08157f67b55d1c4ed896ae39 (patch)
tree2983f19a546336def390f7a43fa4f8426eea8bc8 /qtsingleapplication/examples
Long live the Qt Solutions archive!
This commit adds the contents of distribution packages of the relevant subset of the Qt Solutions components, generated from the last versions in Perforce.
Diffstat (limited to 'qtsingleapplication/examples')
-rw-r--r--qtsingleapplication/examples/console/console.pro5
-rw-r--r--qtsingleapplication/examples/console/console.qdoc64
-rw-r--r--qtsingleapplication/examples/console/main.cpp88
-rw-r--r--qtsingleapplication/examples/examples.pro4
-rw-r--r--qtsingleapplication/examples/loader/file1.qsl1
-rw-r--r--qtsingleapplication/examples/loader/file2.qsl1
-rw-r--r--qtsingleapplication/examples/loader/loader.pro5
-rw-r--r--qtsingleapplication/examples/loader/loader.qdoc80
-rw-r--r--qtsingleapplication/examples/loader/main.cpp151
-rw-r--r--qtsingleapplication/examples/trivial/main.cpp77
-rw-r--r--qtsingleapplication/examples/trivial/trivial.pro5
-rw-r--r--qtsingleapplication/examples/trivial/trivial.qdoc75
12 files changed, 556 insertions, 0 deletions
diff --git a/qtsingleapplication/examples/console/console.pro b/qtsingleapplication/examples/console/console.pro
new file mode 100644
index 0000000..e0390e2
--- /dev/null
+++ b/qtsingleapplication/examples/console/console.pro
@@ -0,0 +1,5 @@
+TEMPLATE = app
+CONFIG += console
+SOURCES += main.cpp
+include(../../src/qtsinglecoreapplication.pri)
+QT -= gui
diff --git a/qtsingleapplication/examples/console/console.qdoc b/qtsingleapplication/examples/console/console.qdoc
new file mode 100644
index 0000000..7bef07c
--- /dev/null
+++ b/qtsingleapplication/examples/console/console.qdoc
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of a Qt Solutions component.
+**
+** 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."
+**
+****************************************************************************/
+
+/*! \page qtsinglecoreapplication-example-console.html
+ \title A non-GUI example
+
+ This example shows how to use the single-application functionality
+ in a console application. It does not require the \c QtGui library
+ at all.
+
+ The only differences from the GUI application usage demonstrated
+ in the other examples are:
+
+ 1) The \c.pro file should include \c qtsinglecoreapplication.pri
+ instead of \c qtsingleapplication.pri
+
+ 2) The class name is \c QtSingleCoreApplication instead of \c
+ QtSingleApplication.
+
+ 3) No calls are made regarding window activation, for obvious reasons.
+
+ console.pro:
+ \quotefile console/console.pro
+
+ main.cpp:
+ \quotefile console/main.cpp
+
+*/
diff --git a/qtsingleapplication/examples/console/main.cpp b/qtsingleapplication/examples/console/main.cpp
new file mode 100644
index 0000000..de4816a
--- /dev/null
+++ b/qtsingleapplication/examples/console/main.cpp
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of a Qt Solutions component.
+**
+** 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."
+**
+****************************************************************************/
+
+
+#include "qtsinglecoreapplication.h"
+#include <QtCore/QDebug>
+
+
+void report(const QString& msg)
+{
+ qDebug("[%i] %s", (int)QCoreApplication::applicationPid(), qPrintable(msg));
+}
+
+class MainClass : public QObject
+{
+ Q_OBJECT
+public:
+ MainClass()
+ : QObject()
+ {}
+
+public slots:
+ void handleMessage(const QString& message)
+ {
+ report( "Message received: \"" + message + "\"");
+ }
+};
+
+int main(int argc, char **argv)
+{
+ report("Starting up");
+
+ QtSingleCoreApplication app(argc, argv);
+
+ if (app.isRunning()) {
+ QString msg(QString("Hi master, I am %1.").arg(QCoreApplication::applicationPid()));
+ bool sentok = app.sendMessage(msg, 2000);
+ QString rep("Another instance is running, so I will exit.");
+ rep += sentok ? " Message sent ok." : " Message sending failed; the other instance may be frozen.";
+ report(rep);
+ return 0;
+ } else {
+ report("No other instance is running; so I will.");
+ MainClass mainObj;
+ QObject::connect(&app, SIGNAL(messageReceived(const QString&)),
+ &mainObj, SLOT(handleMessage(const QString&)));
+ return app.exec();
+ }
+}
+
+
+#include "main.moc"
diff --git a/qtsingleapplication/examples/examples.pro b/qtsingleapplication/examples/examples.pro
new file mode 100644
index 0000000..36b8fd3
--- /dev/null
+++ b/qtsingleapplication/examples/examples.pro
@@ -0,0 +1,4 @@
+TEMPLATE = subdirs
+SUBDIRS = trivial \
+ loader \
+ console
diff --git a/qtsingleapplication/examples/loader/file1.qsl b/qtsingleapplication/examples/loader/file1.qsl
new file mode 100644
index 0000000..50fcd26
--- /dev/null
+++ b/qtsingleapplication/examples/loader/file1.qsl
@@ -0,0 +1 @@
+File 1
diff --git a/qtsingleapplication/examples/loader/file2.qsl b/qtsingleapplication/examples/loader/file2.qsl
new file mode 100644
index 0000000..4475433
--- /dev/null
+++ b/qtsingleapplication/examples/loader/file2.qsl
@@ -0,0 +1 @@
+File 2
diff --git a/qtsingleapplication/examples/loader/loader.pro b/qtsingleapplication/examples/loader/loader.pro
new file mode 100644
index 0000000..673497a
--- /dev/null
+++ b/qtsingleapplication/examples/loader/loader.pro
@@ -0,0 +1,5 @@
+TEMPLATE = app
+
+include(../../src/qtsingleapplication.pri)
+
+SOURCES += main.cpp
diff --git a/qtsingleapplication/examples/loader/loader.qdoc b/qtsingleapplication/examples/loader/loader.qdoc
new file mode 100644
index 0000000..2ae59e3
--- /dev/null
+++ b/qtsingleapplication/examples/loader/loader.qdoc
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of a Qt Solutions component.
+**
+** 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."
+**
+****************************************************************************/
+
+/*! \page qtsingleapplication-example-loader.html
+ \title Loading Documents
+
+ The application in this example loads or prints the documents
+ passed as commandline parameters to further instances of this
+ application.
+
+ \quotefromfile loader/main.cpp
+ \printuntil };
+ The user interface in this application is a QMainWindow subclass
+ with a QMdiArea as the central widget. It implements a slot
+ \c handleMessage() that will be connected to the messageReceived()
+ signal of the QtSingleApplication class.
+
+ \printuntil }
+ The MainWindow constructor creates a minimal user interface.
+
+ \printto case Print:
+ The handleMessage() slot interprets the message passed in as a
+ filename that can be prepended with \e /print to indicate that
+ the file should just be printed rather than loaded.
+
+ \printto #include
+ Loading the file will also activate the window.
+
+ \printto mw
+ The \c main entry point function creates a QtSingleApplication
+ object, and creates a message to send to a running instance
+ of the application. If the message was sent successfully the
+ process exits immediately.
+
+ \printuntil }
+ If the message could not be sent the application starts up. Note
+ that \c false is passed to the call to setActivationWindow() to
+ prevent automatic activation for every message received, e.g. when
+ the application should just print a file. Instead, the message
+ handling function determines whether activation is requested, and
+ signals that by emitting the needToShow() signal. This is then
+ simply connected directly to QtSingleApplication's
+ activateWindow() slot.
+*/
diff --git a/qtsingleapplication/examples/loader/main.cpp b/qtsingleapplication/examples/loader/main.cpp
new file mode 100644
index 0000000..7bc5686
--- /dev/null
+++ b/qtsingleapplication/examples/loader/main.cpp
@@ -0,0 +1,151 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of a Qt Solutions component.
+**
+** 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."
+**
+****************************************************************************/
+
+#include <qtsingleapplication.h>
+#include <QtCore/QFile>
+#include <QtGui/QMainWindow>
+#include <QtGui/QPrinter>
+#include <QtGui/QPainter>
+#include <QtGui/QTextEdit>
+#include <QtGui/QMdiArea>
+#include <QtCore/QTextStream>
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+public:
+ MainWindow();
+
+public slots:
+ void handleMessage(const QString& message);
+
+signals:
+ void needToShow();
+
+private:
+ QMdiArea *workspace;
+};
+
+MainWindow::MainWindow()
+{
+ workspace = new QMdiArea(this);
+
+ setCentralWidget(workspace);
+}
+
+void MainWindow::handleMessage(const QString& message)
+{
+ enum Action {
+ Nothing,
+ Open,
+ Print
+ } action;
+
+ action = Nothing;
+ QString filename = message;
+ if (message.toLower().startsWith("/print ")) {
+ filename = filename.mid(7);
+ action = Print;
+ } else if (!message.isEmpty()) {
+ action = Open;
+ }
+ if (action == Nothing) {
+ emit needToShow();
+ return;
+ }
+
+ QFile file(filename);
+ QString contents;
+ if (file.open(QIODevice::ReadOnly))
+ contents = file.readAll();
+ else
+ contents = "[[Error: Could not load file " + filename + "]]";
+
+ QTextEdit *view = new QTextEdit;
+ view->setPlainText(contents);
+
+ switch(action) {
+ case Print:
+ {
+ QPrinter printer;
+ view->print(&printer);
+ delete view;
+ }
+ break;
+
+ case Open:
+ {
+ workspace->addSubWindow(view);
+ view->setWindowTitle(message);
+ view->show();
+ emit needToShow();
+ }
+ break;
+ default:
+ break;
+ };
+}
+
+#include "main.moc"
+
+int main(int argc, char **argv)
+{
+ QtSingleApplication instance("File loader QtSingleApplication example", argc, argv);
+ QString message;
+ for (int a = 1; a < argc; ++a) {
+ message += argv[a];
+ if (a < argc-1)
+ message += " ";
+ }
+
+ if (instance.sendMessage(message))
+ return 0;
+
+ MainWindow mw;
+ mw.handleMessage(message);
+ mw.show();
+
+ QObject::connect(&instance, SIGNAL(messageReceived(const QString&)),
+ &mw, SLOT(handleMessage(const QString&)));
+
+ instance.setActivationWindow(&mw, false);
+ QObject::connect(&mw, SIGNAL(needToShow()), &instance, SLOT(activateWindow()));
+
+ return instance.exec();
+}
diff --git a/qtsingleapplication/examples/trivial/main.cpp b/qtsingleapplication/examples/trivial/main.cpp
new file mode 100644
index 0000000..8552fe3
--- /dev/null
+++ b/qtsingleapplication/examples/trivial/main.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of a Qt Solutions component.
+**
+** 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."
+**
+****************************************************************************/
+
+#include <qtsingleapplication.h>
+#include <QtGui/QTextEdit>
+
+class TextEdit : public QTextEdit
+{
+ Q_OBJECT
+public:
+ TextEdit(QWidget *parent = 0)
+ : QTextEdit(parent)
+ {}
+public slots:
+ void append(const QString &str)
+ {
+ QTextEdit::append(str);
+ }
+};
+
+#include "main.moc"
+
+
+
+int main(int argc, char **argv)
+{
+ QtSingleApplication instance(argc, argv);
+ if (instance.sendMessage("Wake up!"))
+ return 0;
+
+ TextEdit logview;
+ logview.setReadOnly(true);
+ logview.show();
+
+ instance.setActivationWindow(&logview);
+
+ QObject::connect(&instance, SIGNAL(messageReceived(const QString&)),
+ &logview, SLOT(append(const QString&)));
+
+ return instance.exec();
+}
diff --git a/qtsingleapplication/examples/trivial/trivial.pro b/qtsingleapplication/examples/trivial/trivial.pro
new file mode 100644
index 0000000..673497a
--- /dev/null
+++ b/qtsingleapplication/examples/trivial/trivial.pro
@@ -0,0 +1,5 @@
+TEMPLATE = app
+
+include(../../src/qtsingleapplication.pri)
+
+SOURCES += main.cpp
diff --git a/qtsingleapplication/examples/trivial/trivial.qdoc b/qtsingleapplication/examples/trivial/trivial.qdoc
new file mode 100644
index 0000000..3185199
--- /dev/null
+++ b/qtsingleapplication/examples/trivial/trivial.qdoc
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of a Qt Solutions component.
+**
+** 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."
+**
+****************************************************************************/
+
+/*! \page qtsingleapplication-example-trivial.html
+ \title A Trivial Example
+
+ The application in this example has a log-view that displays
+ messages sent by further instances of the same application.
+
+ The example demonstrates the use of the QtSingleApplication
+ class to detect and communicate with a running instance of
+ the application using the sendMessage() API. The messageReceived()
+ signal is used to display received messages in a QTextEdit log.
+
+ \quotefromfile trivial/main.cpp
+ \printuntil instance
+ The example has only the \c main entry point function.
+ A QtSingleApplication object is created immediately.
+
+ \printuntil return
+ If another instance of this application is already running,
+ sendMessage() will succeed, and this instance just exits
+ immediately.
+
+ \printuntil show()
+ Otherwise the instance continues as normal and creates the
+ user interface.
+
+ \printuntil return instance.exec();
+ The \c logview object is also set as the application's activation
+ window. Every time a message is received, the window will be raised
+ and activated automatically.
+
+ The messageReceived() signal is also connected to the QTextEdit's
+ append() slot. Every message received from further instances of
+ this application will be displayed in the log.
+
+ Finally the event loop is entered.
+*/