summaryrefslogtreecommitdiff
path: root/qt4
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-12-12 14:00:20 +0100
committerErich Eckner <git@eckner.net>2019-12-12 14:00:20 +0100
commitaea50ea70924ce64a580e4df9d4860a917bfd54e (patch)
tree0dd928c0bb230a71984dc7f27306fb5ba06c8842 /qt4
parentb8d841f4773f344f3e89b6c9d692ad8af0d3818e (diff)
downloadarchlinuxewe.git.save-aea50ea70924ce64a580e4df9d4860a917bfd54e.tar.xz
qt4 neu
Diffstat (limited to 'qt4')
-rw-r--r--qt4/PKGBUILD208
-rw-r--r--qt4/assistant-qt4.desktop9
-rw-r--r--qt4/designer-qt4.desktop11
-rw-r--r--qt4/disable-sslv3.patch54
-rw-r--r--qt4/glib-honor-ExcludeSocketNotifiers-flag.diff63
-rw-r--r--qt4/improve-cups-support.patch84
-rw-r--r--qt4/kde4-settings.patch11
-rw-r--r--qt4/kubuntu_14_systemtrayicon.diff1466
-rw-r--r--qt4/l-qclipboard_delay.patch12
-rw-r--r--qt4/l-qclipboard_fix_recursive.patch94
-rw-r--r--qt4/linguist-qt4.desktop10
-rw-r--r--qt4/moc-boost-workaround.patch12
-rw-r--r--qt4/qdbusviewer-qt4.desktop10
-rw-r--r--qt4/qt4-gcc6.patch36
-rw-r--r--qt4/qt4-gcc8.patch314
-rw-r--r--qt4/qt4-gcc9.patch46
-rw-r--r--qt4/qt4-glibc-2.25.patch30
-rw-r--r--qt4/qt4-icu59.patch11
-rw-r--r--qt4/qt4-openssl-1.1.patch409
-rw-r--r--qt4/qtconfig-qt4.desktop9
20 files changed, 2899 insertions, 0 deletions
diff --git a/qt4/PKGBUILD b/qt4/PKGBUILD
new file mode 100644
index 00000000..a61d73d9
--- /dev/null
+++ b/qt4/PKGBUILD
@@ -0,0 +1,208 @@
+# Maintainer: Erich Eckner <arch at eckner dot net>
+# Contributor: Viktor Drobot (aka dviktor) linux776 [at] gmail [dot] com
+# Contributor: Felix Yan <felixonmars@archlinux.org>
+# Contributor: Andrea Scarpino <andrea@archlinux.org>
+# Contributor: Pierre Schmitz <pierre@archlinux.de>
+
+pkgname=qt4
+pkgver=4.8.7
+pkgrel=31
+arch=('x86_64')
+url='https://www.qt.io'
+license=('GPL3' 'LGPL' 'FDL' 'custom')
+pkgdesc='A cross-platform application and UI framework'
+depends=('sqlite' 'ca-certificates' 'fontconfig' 'libgl' 'libxrandr' 'libxv' 'libxi' 'alsa-lib'
+ 'xdg-utils' 'hicolor-icon-theme' 'desktop-file-utils' 'libmng' 'dbus')
+makedepends=('postgresql-libs' 'mariadb-libs' 'unixodbc' 'cups' 'gtk2' 'libfbclient'
+ 'mesa')
+optdepends=('postgresql-libs: PostgreSQL driver'
+ 'mariadb-libs: MariaDB driver'
+ 'unixodbc: ODBC driver'
+ 'libfbclient: Firebird/iBase driver'
+ 'libxinerama: Xinerama support'
+ 'libxcursor: Xcursor support'
+ 'libxfixes: Xfixes support'
+ 'icu: Unicode support'
+ 'sni-qt: StatusNotifierItem (AppIndicators) support')
+replaces=('qt<=4.8.4')
+conflicts=('qt')
+_pkgfqn="qt-everywhere-opensource-src-${pkgver}"
+source=("https://download.qt.io/archive/qt/4.8/${pkgver}/${_pkgfqn}.tar.gz"
+ 'qtconfig-qt4.desktop' 'assistant-qt4.desktop' 'designer-qt4.desktop'
+ 'linguist-qt4.desktop' 'qdbusviewer-qt4.desktop'
+ 'improve-cups-support.patch'
+ 'moc-boost-workaround.patch'
+ 'kubuntu_14_systemtrayicon.diff'
+ 'kde4-settings.patch'
+ 'glib-honor-ExcludeSocketNotifiers-flag.diff'
+ 'disable-sslv3.patch'
+ 'l-qclipboard_fix_recursive.patch'
+ 'l-qclipboard_delay.patch'
+ 'qt4-gcc6.patch' 'qt4-gcc8.patch' 'qt4-gcc9.patch' 'qt4-glibc-2.25.patch' 'qt4-icu59.patch' 'qt4-openssl-1.1.patch')
+sha256sums=('e2882295097e47fe089f8ac741a95fef47e0a73a3f3cdf21b56990638f626ea0'
+ '157eb47865f0b43e4717819783823c569127a2e9fc48309982ca0f2b753517a1'
+ 'd63f22858174489068c30a12b9115d1b4e23ade00c31c117513212e9a225c1ce'
+ 'c154de65da1b81564fa68f29c773b5f1751e0ee821e858ee8f0684b8d027da58'
+ '22bd69ee3ba986448a63e41f529a7d28d0f2e6d83d6114e763eba761db302e01'
+ '915a1cb0f7328840cac742c03f5121dc6e19498952c082b46c0bf7263bf6676d'
+ '3ccfefb432015e4a4ea967b030c51b10dcdfb1f63445557908ddae5e75012d33'
+ '876c681ef8fbcc25f28cd4ad6c697abf8a4165d540bae37433bc40256dbf9d62'
+ '9fad22674c5eec835613a7f16c11b865aa793b448e90974c0f804105284a548b'
+ 'ce97da195445f145d9f82df8f8e5d8716128e869ec6632db66c7125be663d813'
+ 'e7f8d1c906640b836454e8202a48602352609d8e44a33a3de05dc1d20f5b1a8a'
+ '829b02ba10f208c2beba8e8a0110b6d10c63932612dabc08d536f099b9f66101'
+ '5db36cbb0686b8a503941779c821febc4a0330dc260e51d603f7aa1e4d8860ad'
+ 'af3648ddb2372333b0e428788fd2ffbcfe571653fb46f898a55ae5a202f7e242'
+ '51da49e41edac66559d3ec8dd0a152995a51a53e5d1f63f09fa089a8af7e3112'
+ '0497411e54a0461f76ffa204236f5146a2ed0d272ae66afcfabd74090459208b'
+ '8d6104d7bc3b050ec87e82b9df245154cd1d80e03eb3bbe633084d6b3c079d5e'
+ 'e6555f4a681227447e94e9f14e11626d50b7e5108aad06088311e87063bc0347'
+ '61d6bf45649c728dec5f8d22be5b496ed9d40f52c2c70102696d07133cd1750d'
+ 'ff3ddb5428cd2ff243558dc0c75b35f470077e9204bbc989ddcba04c866c1b68')
+
+prepare() {
+ cd ${_pkgfqn}
+
+ # (FS#28381) (KDEBUG#180051)
+ patch -p1 -i "${srcdir}"/improve-cups-support.patch
+
+ # QTBUG#22829
+ patch -p1 -i "${srcdir}"/moc-boost-workaround.patch
+
+ # http://blog.martin-graesslin.com/blog/2014/06/where-are-my-systray-icons/
+ patch -p1 -i "${srcdir}"/kubuntu_14_systemtrayicon.diff
+
+ # FS#45106
+ patch -p0 -i "${srcdir}"/kde4-settings.patch
+
+ # fixes for LibreOffice from the upstream Qt bug tracker FS#46436, FS#41648, FS#39819
+ # https://bugreports.qt.io/browse/QTBUG-37380
+ patch -p1 -i "${srcdir}"/glib-honor-ExcludeSocketNotifiers-flag.diff
+ # https://bugreports.qt.io/browse/QTBUG-34614
+ patch -p0 -i "${srcdir}"/l-qclipboard_fix_recursive.patch
+ # https://bugreports.qt.io/browse/QTBUG-38585
+ patch -p0 -i "${srcdir}"/l-qclipboard_delay.patch
+
+ # React to OpenSSL's OPENSSL_NO_SSL3 define
+ patch -p1 -i "${srcdir}"/disable-sslv3.patch
+
+ sed -i "s|-O2|${CXXFLAGS}|" mkspecs/common/{g++,gcc}-base.conf
+ sed -i "/^QMAKE_LFLAGS_RPATH/s| -Wl,-rpath,||g" mkspecs/common/gcc-base-unix.conf
+ sed -i "/^QMAKE_LFLAGS\s/s|+=|+= ${LDFLAGS}|g" mkspecs/common/gcc-base.conf
+
+ cp mkspecs/common/linux{,32}.conf
+ sed -i "/^QMAKE_LIBDIR\s/s|=|= /usr/lib32|g" mkspecs/common/linux32.conf
+ sed -i "s|common/linux.conf|common/linux32.conf|" mkspecs/linux-g++-32/qmake.conf
+
+ # Fix build with GCC6 (Fedora)
+ patch -p1 -i "$srcdir"/qt4-gcc6.patch
+
+ # Fix build with GCC-8.3
+ patch -Np0 -i "$srcdir"/qt4-gcc8.patch
+
+ # Fix build with GCC9
+ patch -Np0 -i "$srcdir"/qt4-gcc9.patch
+
+ # Fix build of Qt4 applications with glibc 2.25 (Fedora)
+ patch -p1 -i "$srcdir"/qt4-glibc-2.25.patch
+
+ # Fix build with ICU 59 (pld-linux)
+ patch -p1 -i "$srcdir"/qt4-icu59.patch
+
+ # Fix build with OpenSSL 1.1 (Debian + OpenMandriva)
+ patch -p1 -i "$srcdir"/qt4-openssl-1.1.patch
+
+ echo "QMAKE_CXXFLAGS += -std=gnu++98" >> src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.pri
+ echo "QMAKE_CXXFLAGS += -std=gnu++98" >> src/plugins/accessible/qaccessiblebase.pri
+}
+
+build() {
+ export QT4DIR="${srcdir}"/${_pkgfqn}
+ export LD_LIBRARY_PATH=${QT4DIR}/lib:${LD_LIBRARY_PATH}
+
+ cd ${_pkgfqn}
+
+ ./configure -confirm-license -opensource \
+ -prefix /usr \
+ -bindir /usr/lib/qt4/bin \
+ -headerdir /usr/include/qt4 \
+ -docdir /usr/share/doc/qt4 \
+ -plugindir /usr/lib/qt4/plugins \
+ -importdir /usr/lib/qt4/imports \
+ -datadir /usr/share/qt4 \
+ -translationdir /usr/share/qt4/translations \
+ -sysconfdir /etc/xdg \
+ -examplesdir /usr/share/doc/qt4/examples \
+ -demosdir /usr/share/doc/qt4/demos \
+ -plugin-sql-{psql,mysql,sqlite,odbc,ibase} \
+ -system-sqlite \
+ -no-phonon \
+ -no-phonon-backend \
+ -no-webkit \
+ -graphicssystem raster \
+ -openssl-linked \
+ -nomake demos \
+ -nomake examples \
+ -nomake docs \
+ -xmlpatterns \
+ -silent \
+ -no-rpath \
+ -optimized-qmake \
+ -no-reduce-relocations \
+ -dbus-linked \
+ -no-openvg
+ make
+}
+
+package() {
+ cd ${_pkgfqn}
+ make INSTALL_ROOT="${pkgdir}" install
+
+ # install missing icons and desktop files
+ install -D -m644 src/gui/dialogs/images/qtlogo-64.png \
+ "${pkgdir}"/usr/share/icons/hicolor/64x64/apps/qt4logo.png
+ install -D -m644 tools/assistant/tools/assistant/images/assistant.png \
+ "${pkgdir}"/usr/share/icons/hicolor/32x32/apps/assistant-qt4.png
+ install -D -m644 tools/assistant/tools/assistant/images/assistant-128.png \
+ "${pkgdir}"/usr/share/icons/hicolor/128x128/apps/assistant-qt4.png
+ install -D -m644 tools/designer/src/designer/images/designer.png \
+ "${pkgdir}"/usr/share/icons/hicolor/128x128/apps/designer-qt4.png
+ for icon in tools/linguist/linguist/images/icons/linguist-*-32.png ; do
+ size=$(echo $(basename ${icon}) | cut -d- -f2)
+ install -D -m644 ${icon} \
+ "${pkgdir}"/usr/share/icons/hicolor/${size}x${size}/apps/linguist-qt4.png
+ done
+ install -D -m644 tools/qdbus/qdbusviewer/images/qdbusviewer.png \
+ "${pkgdir}"/usr/share/icons/hicolor/32x32/apps/qdbusviewer-qt4.png
+ install -D -m644 tools/qdbus/qdbusviewer/images/qdbusviewer-128.png \
+ "${pkgdir}"/usr/share/icons/hicolor/128x128/apps/qdbusviewer-qt4.png
+
+ install -d "${pkgdir}"/usr/share/applications
+ install -m644 "${srcdir}"/{assistant,designer,linguist,qtconfig,qdbusviewer}-qt4.desktop \
+ "${pkgdir}"/usr/share/applications/
+
+ # Useful symlinks for cmake and configure scripts
+ install -d "${pkgdir}"/usr/bin
+ for b in "${pkgdir}"/usr/lib/qt4/bin/*; do
+ ln -s /usr/lib/qt4/bin/$(basename $b) "${pkgdir}"/usr/bin/$(basename $b)-qt4
+ done
+
+ # install license addition
+ install -D -m644 LGPL_EXCEPTION.txt \
+ ${pkgdir}/usr/share/licenses/${pkgname}/LGPL_EXCEPTION.txt
+
+ # Fix wrong libs path in pkgconfig files
+ find "${pkgdir}/usr/lib/pkgconfig" -type f -name '*.pc' \
+ -exec perl -pi -e "s, -L${srcdir}/?\S+,,g" {} \;
+
+ # Fix wrong bins path in pkgconfig files
+ find "${pkgdir}/usr/lib/pkgconfig" -type f -name '*.pc' \
+ -exec sed -i 's|/usr/bin/|/usr/lib/qt4/bin/|g' {} \;
+
+ # Fix wrong path in prl files
+ find "${pkgdir}/usr/lib" -type f -name '*.prl' \
+ -exec sed -i -e '/^QMAKE_PRL_BUILD_DIR/d;s/\(QMAKE_PRL_LIBS =\).*/\1/' {} \;
+
+ # The TGA plugin is broken (FS#33568)
+ rm "${pkgdir}"/usr/lib/qt4/plugins/imageformats/libqtga.so
+}
diff --git a/qt4/assistant-qt4.desktop b/qt4/assistant-qt4.desktop
new file mode 100644
index 00000000..d874d612
--- /dev/null
+++ b/qt4/assistant-qt4.desktop
@@ -0,0 +1,9 @@
+[Desktop Entry]
+Name=Qt4 Assistant
+Comment=Shows Qt4 documentation and examples
+Exec=assistant-qt4
+Icon=assistant-qt4
+Terminal=false
+Encoding=UTF-8
+Type=Application
+Categories=Qt;Development;Documentation;
diff --git a/qt4/designer-qt4.desktop b/qt4/designer-qt4.desktop
new file mode 100644
index 00000000..86ea4eda
--- /dev/null
+++ b/qt4/designer-qt4.desktop
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Name=Qt4 Designer
+GenericName=Interface Designer
+Comment=Design GUIs for Qt4 applications
+Exec=designer-qt4
+Icon=designer-qt4
+MimeType=application/x-designer;
+Terminal=false
+Encoding=UTF-8
+Type=Application
+Categories=Qt;Development;
diff --git a/qt4/disable-sslv3.patch b/qt4/disable-sslv3.patch
new file mode 100644
index 00000000..5ebd9741
--- /dev/null
+++ b/qt4/disable-sslv3.patch
@@ -0,0 +1,54 @@
+diff -u -r qt-everywhere-opensource-src-4.8.7/src/network/ssl/qsslsocket_openssl.cpp qt-everywhere-opensource-src-4.8.7-nossl3/src/network/ssl/qsslsocket_openssl.cpp
+--- qt-everywhere-opensource-src-4.8.7/src/network/ssl/qsslsocket_openssl.cpp 2015-05-07 16:14:44.000000000 +0200
++++ qt-everywhere-opensource-src-4.8.7-nossl3/src/network/ssl/qsslsocket_openssl.cpp 2016-03-04 11:29:17.119300898 +0100
+@@ -267,7 +267,11 @@
+ #endif
+ break;
+ case QSsl::SslV3:
++#ifndef OPENSSL_NO_SSL3
+ ctx = q_SSL_CTX_new(client ? q_SSLv3_client_method() : q_SSLv3_server_method());
++#else
++ ctx = 0; // SSL 3 not supported by the system, but chosen deliberately -> error
++#endif
+ break;
+ case QSsl::SecureProtocols: // SslV2 will be disabled below
+ case QSsl::TlsV1SslV3: // SslV2 will be disabled below
+diff -u -r qt-everywhere-opensource-src-4.8.7/src/network/ssl/qsslsocket_openssl_symbols.cpp qt-everywhere-opensource-src-4.8.7-nossl3/src/network/ssl/qsslsocket_openssl_symbols.cpp
+--- qt-everywhere-opensource-src-4.8.7/src/network/ssl/qsslsocket_openssl_symbols.cpp 2015-05-07 16:14:44.000000000 +0200
++++ qt-everywhere-opensource-src-4.8.7-nossl3/src/network/ssl/qsslsocket_openssl_symbols.cpp 2016-03-04 11:28:52.806050135 +0100
+@@ -228,13 +228,17 @@
+ #ifndef OPENSSL_NO_SSL2
+ DEFINEFUNC(const SSL_METHOD *, SSLv2_client_method, DUMMYARG, DUMMYARG, return 0, return)
+ #endif
++#ifndef OPENSSL_NO_SSL3
+ DEFINEFUNC(const SSL_METHOD *, SSLv3_client_method, DUMMYARG, DUMMYARG, return 0, return)
++#endif
+ DEFINEFUNC(const SSL_METHOD *, SSLv23_client_method, DUMMYARG, DUMMYARG, return 0, return)
+ DEFINEFUNC(const SSL_METHOD *, TLSv1_client_method, DUMMYARG, DUMMYARG, return 0, return)
+ #ifndef OPENSSL_NO_SSL2
+ DEFINEFUNC(const SSL_METHOD *, SSLv2_server_method, DUMMYARG, DUMMYARG, return 0, return)
+ #endif
++#ifndef OPENSSL_NO_SSL3
+ DEFINEFUNC(const SSL_METHOD *, SSLv3_server_method, DUMMYARG, DUMMYARG, return 0, return)
++#endif
+ DEFINEFUNC(const SSL_METHOD *, SSLv23_server_method, DUMMYARG, DUMMYARG, return 0, return)
+ DEFINEFUNC(const SSL_METHOD *, TLSv1_server_method, DUMMYARG, DUMMYARG, return 0, return)
+ #else
+@@ -822,13 +826,17 @@
+ #ifndef OPENSSL_NO_SSL2
+ RESOLVEFUNC(SSLv2_client_method)
+ #endif
++#ifndef OPENSSL_NO_SSL3
+ RESOLVEFUNC(SSLv3_client_method)
++#endif
+ RESOLVEFUNC(SSLv23_client_method)
+ RESOLVEFUNC(TLSv1_client_method)
+ #ifndef OPENSSL_NO_SSL2
+ RESOLVEFUNC(SSLv2_server_method)
+ #endif
++#ifndef OPENSSL_NO_SSL3
+ RESOLVEFUNC(SSLv3_server_method)
++#endif
+ RESOLVEFUNC(SSLv23_server_method)
+ RESOLVEFUNC(TLSv1_server_method)
+ RESOLVEFUNC(X509_NAME_entry_count)
diff --git a/qt4/glib-honor-ExcludeSocketNotifiers-flag.diff b/qt4/glib-honor-ExcludeSocketNotifiers-flag.diff
new file mode 100644
index 00000000..6949bbfe
--- /dev/null
+++ b/qt4/glib-honor-ExcludeSocketNotifiers-flag.diff
@@ -0,0 +1,63 @@
+Author: Jan-Marek Glogowski <glogow@fbihome.de>
+Date: Thu Mar 06 18:44:43 2014 +0100
+
+ Honor QEventLoop::ExcludeSocketNotifiers in glib event loop.
+
+ Implements QEventLoop::ExcludeSocketNotifiers in the same way
+ QEventLoop::X11ExcludeTimers is already implemented for the glib
+ event loop.
+
+--- qt4-x11-4.8.1.orig/src/corelib/kernel/qeventdispatcher_glib.cpp
++++ qt4-x11-4.8.1/src/corelib/kernel/qeventdispatcher_glib.cpp
+@@ -65,6 +65,7 @@ struct GPollFDWithQSocketNotifier
+ struct GSocketNotifierSource
+ {
+ GSource source;
++ QEventLoop::ProcessEventsFlags processEventsFlags;
+ QList<GPollFDWithQSocketNotifier *> pollfds;
+ };
+
+@@ -80,6 +81,9 @@ static gboolean socketNotifierSourceChec
+ GSocketNotifierSource *src = reinterpret_cast<GSocketNotifierSource *>(source);
+
+ bool pending = false;
++ if (src->processEventsFlags & QEventLoop::ExcludeSocketNotifiers)
++ return pending;
++
+ for (int i = 0; !pending && i < src->pollfds.count(); ++i) {
+ GPollFDWithQSocketNotifier *p = src->pollfds.at(i);
+
+@@ -103,6 +107,9 @@ static gboolean socketNotifierSourceDisp
+ QEvent event(QEvent::SockAct);
+
+ GSocketNotifierSource *src = reinterpret_cast<GSocketNotifierSource *>(source);
++ if (src->processEventsFlags & QEventLoop::ExcludeSocketNotifiers)
++ return true;
++
+ for (int i = 0; i < src->pollfds.count(); ++i) {
+ GPollFDWithQSocketNotifier *p = src->pollfds.at(i);
+
+@@ -330,6 +337,7 @@ QEventDispatcherGlibPrivate::QEventDispa
+ reinterpret_cast<GSocketNotifierSource *>(g_source_new(&socketNotifierSourceFuncs,
+ sizeof(GSocketNotifierSource)));
+ (void) new (&socketNotifierSource->pollfds) QList<GPollFDWithQSocketNotifier *>();
++ socketNotifierSource->processEventsFlags = QEventLoop::AllEvents;
+ g_source_set_can_recurse(&socketNotifierSource->source, true);
+ g_source_attach(&socketNotifierSource->source, mainContext);
+
+@@ -415,6 +423,7 @@ bool QEventDispatcherGlib::processEvents
+ // tell postEventSourcePrepare() and timerSource about any new flags
+ QEventLoop::ProcessEventsFlags savedFlags = d->timerSource->processEventsFlags;
+ d->timerSource->processEventsFlags = flags;
++ d->socketNotifierSource->processEventsFlags = flags;
+
+ if (!(flags & QEventLoop::EventLoopExec)) {
+ // force timers to be sent at normal priority
+@@ -426,6 +435,7 @@ bool QEventDispatcherGlib::processEvents
+ result = g_main_context_iteration(d->mainContext, canWait);
+
+ d->timerSource->processEventsFlags = savedFlags;
++ d->socketNotifierSource->processEventsFlags = savedFlags;
+
+ if (canWait)
+ emit awake();
diff --git a/qt4/improve-cups-support.patch b/qt4/improve-cups-support.patch
new file mode 100644
index 00000000..e0305e11
--- /dev/null
+++ b/qt4/improve-cups-support.patch
@@ -0,0 +1,84 @@
+diff -ur qt-everywhere-opensource-src-4.6.2/src/gui/dialogs/qprintdialog_unix.cpp qt-everywhere-opensource-src-4.6.2-cups/src/gui/dialogs/qprintdialog_unix.cpp
+--- qt-everywhere-opensource-src-4.6.2/src/gui/dialogs/qprintdialog_unix.cpp 2010-02-11 16:55:22.000000000 +0100
++++ qt-everywhere-opensource-src-4.6.2-cups/src/gui/dialogs/qprintdialog_unix.cpp 2010-02-28 04:34:16.000000000 +0100
+@@ -569,6 +569,32 @@
+ void QPrintDialogPrivate::selectPrinter(QCUPSSupport *cups)
+ {
+ options.duplex->setEnabled(cups && cups->ppdOption("Duplex"));
++
++ if (cups) {
++ const ppd_option_t* duplex = cups->ppdOption("Duplex");
++ if (duplex) {
++ // copy default ppd duplex to qt dialog
++ if (qstrcmp(duplex->defchoice, "DuplexTumble") == 0)
++ options.duplexShort->setChecked(true);
++ else if (qstrcmp(duplex->defchoice, "DuplexNoTumble") == 0)
++ options.duplexLong->setChecked(true);
++ else
++ options.noDuplex->setChecked(true);
++ }
++
++ if (cups->currentPPD()) {
++ // set default color
++ if (cups->currentPPD()->color_device)
++ options.color->setChecked(true);
++ else
++ options.grayscale->setChecked(true);
++ }
++
++ // set collation
++ const ppd_option_t *collate = cups->ppdOption("Collate");
++ if (collate)
++ options.collate->setChecked(qstrcmp(collate->defchoice, "True")==0);
++ }
+ }
+ #endif
+
+diff -ur qt-everywhere-opensource-src-4.6.2/src/gui/painting/qprinter.cpp qt-everywhere-opensource-src-4.6.2-cups/src/gui/painting/qprinter.cpp
+--- qt-everywhere-opensource-src-4.6.2/src/gui/painting/qprinter.cpp 2010-02-11 16:55:22.000000000 +0100
++++ qt-everywhere-opensource-src-4.6.2-cups/src/gui/painting/qprinter.cpp 2010-02-28 04:55:15.000000000 +0100
+@@ -627,6 +627,44 @@
+ && d_ptr->paintEngine->type() != QPaintEngine::MacPrinter) {
+ setOutputFormat(QPrinter::PdfFormat);
+ }
++
++#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
++ // fill in defaults from ppd file
++ QCUPSSupport cups;
++
++ int printernum = -1;
++ for (int i = 0; i < cups.availablePrintersCount(); i++) {
++ if (printerName().toLocal8Bit() == cups.availablePrinters()[i].name)
++ printernum = i;
++ }
++ if (printernum >= 0) {
++ cups.setCurrentPrinter(printernum);
++
++ const ppd_option_t* duplex = cups.ppdOption("Duplex");
++ if (duplex) {
++ // copy default ppd duplex to qt dialog
++ if (qstrcmp(duplex->defchoice, "DuplexTumble") == 0)
++ setDuplex(DuplexShortSide);
++ else if (qstrcmp(duplex->defchoice, "DuplexNoTumble") == 0)
++ setDuplex(DuplexLongSide);
++ else
++ setDuplex(DuplexNone);
++ }
++
++ if (cups.currentPPD()) {
++ // set default color
++ if (cups.currentPPD()->color_device)
++ setColorMode(Color);
++ else
++ setColorMode(GrayScale);
++ }
++
++ // set collation
++ const ppd_option_t *collate = cups.ppdOption("Collate");
++ if (collate)
++ setCollateCopies(qstrcmp(collate->defchoice, "True")==0);
++ }
++#endif
+ }
+
+ /*!
diff --git a/qt4/kde4-settings.patch b/qt4/kde4-settings.patch
new file mode 100644
index 00000000..4af5424c
--- /dev/null
+++ b/qt4/kde4-settings.patch
@@ -0,0 +1,11 @@
+--- src/gui/kernel/qkde.cpp.orig 2015-05-27 11:42:02.507129332 +0200
++++ src/gui/kernel/qkde.cpp 2015-05-27 11:43:26.182875729 +0200
+@@ -63,7 +63,7 @@
+ kdeHomePath = QString::fromLocal8Bit(qgetenv("KDEHOME"));
+ if (kdeHomePath.isEmpty()) {
+ QDir homeDir(QDir::homePath());
+- QString kdeConfDir(QLatin1String("/.kde"));
++ QString kdeConfDir(QLatin1String("/.kde4"));
+ if (4 == X11->desktopVersion && homeDir.exists(QLatin1String(".kde4")))
+ kdeConfDir = QLatin1String("/.kde4");
+ kdeHomePath = QDir::homePath() + kdeConfDir;
diff --git a/qt4/kubuntu_14_systemtrayicon.diff b/qt4/kubuntu_14_systemtrayicon.diff
new file mode 100644
index 00000000..2466a16b
--- /dev/null
+++ b/qt4/kubuntu_14_systemtrayicon.diff
@@ -0,0 +1,1466 @@
+Description: Introduce a plugin system for QSystemTrayIcon.
+ Designed to be used with sni-qt (https://launchpad.net/sni-qt)
+Author: agateau@kde.org
+Forwarded: no
+
+Introduce a plugin system for QSystemTrayIcon. Designed to be used with sni-qt
+(https://launchpad.net/sni-qt)
+---
+ examples/desktop/systray/window.cpp | 40 ++
+ examples/desktop/systray/window.h | 6
+ src/gui/util/qabstractsystemtrayiconsys.cpp | 65 +++
+ src/gui/util/qabstractsystemtrayiconsys_p.h | 106 ++++++
+ src/gui/util/qsystemtrayicon.cpp | 6
+ src/gui/util/qsystemtrayicon_p.h | 85 ++---
+ src/gui/util/qsystemtrayicon_x11.cpp | 356 ++++-----------------
+ src/gui/util/qxembedsystemtrayicon_x11.cpp | 469 ++++++++++++++++++++++++++++
+ src/gui/util/qxembedsystemtrayicon_x11_p.h | 104 ++++++
+ src/gui/util/util.pri | 7
+ 10 files changed, 916 insertions(+), 328 deletions(-)
+
+--- a/examples/desktop/systray/window.cpp
++++ b/examples/desktop/systray/window.cpp
+@@ -158,15 +158,23 @@
+ iconComboBox->addItem(QIcon(":/images/bad.svg"), tr("Bad"));
+ iconComboBox->addItem(QIcon(":/images/heart.svg"), tr("Heart"));
+ iconComboBox->addItem(QIcon(":/images/trash.svg"), tr("Trash"));
++ iconComboBox->addItem(QIcon::fromTheme("system-file-manager"), tr("File Manager"));
+
+ showIconCheckBox = new QCheckBox(tr("Show icon"));
+ showIconCheckBox->setChecked(true);
+
++#if defined(Q_WS_X11)
++ jitToolTipCheckBox = new QCheckBox(tr("Just In Time Tooltip"));
++#endif
++
+ QHBoxLayout *iconLayout = new QHBoxLayout;
+ iconLayout->addWidget(iconLabel);
+ iconLayout->addWidget(iconComboBox);
+ iconLayout->addStretch();
+ iconLayout->addWidget(showIconCheckBox);
++#if defined(Q_WS_X11)
++ iconLayout->addWidget(jitToolTipCheckBox);
++#endif
+ iconGroupBox->setLayout(iconLayout);
+ }
+
+@@ -254,5 +262,37 @@
+ trayIconMenu->addAction(quitAction);
+
+ trayIcon = new QSystemTrayIcon(this);
++ QByteArray category = qgetenv("SNI_CATEGORY");
++ if (!category.isEmpty()) {
++ trayIcon->setProperty("_qt_sni_category", QString::fromLocal8Bit(category));
++ }
+ trayIcon->setContextMenu(trayIconMenu);
++
++#if defined(Q_WS_X11)
++ trayIcon->installEventFilter(this);
++#endif
++}
++
++#if defined(Q_WS_X11)
++bool Window::eventFilter(QObject *, QEvent *event)
++{
++ switch(event->type()) {
++ case QEvent::ToolTip:
++ if (jitToolTipCheckBox->isChecked()) {
++ QString timeString = QTime::currentTime().toString();
++ trayIcon->setToolTip(tr("Current Time: %1").arg(timeString));
++ }
++ break;
++ case QEvent::Wheel: {
++ QWheelEvent *wheelEvent = static_cast<QWheelEvent*>(event);
++ int delta = wheelEvent->delta() > 0 ? 1 : -1;
++ int index = (iconComboBox->currentIndex() + delta) % iconComboBox->count();
++ iconComboBox->setCurrentIndex(index);
++ break;
++ }
++ default:
++ break;
++ }
++ return false;
+ }
++#endif
+--- a/examples/desktop/systray/window.h
++++ b/examples/desktop/systray/window.h
+@@ -69,6 +69,9 @@
+
+ protected:
+ void closeEvent(QCloseEvent *event);
++#if defined(Q_WS_X11)
++ bool eventFilter(QObject *object, QEvent *event);
++#endif
+
+ private slots:
+ void setIcon(int index);
+@@ -86,6 +89,9 @@
+ QLabel *iconLabel;
+ QComboBox *iconComboBox;
+ QCheckBox *showIconCheckBox;
++#if defined(Q_WS_X11)
++ QCheckBox *jitToolTipCheckBox;
++#endif
+
+ QGroupBox *messageGroupBox;
+ QLabel *typeLabel;
+--- /dev/null
++++ b/src/gui/util/qabstractsystemtrayiconsys.cpp
+@@ -0,0 +1,65 @@
++/****************************************************************************
++**
++** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
++** All rights reserved.
++** Contact: Nokia Corporation (qt-info@nokia.com)
++**
++** This file is part of the QtGui module 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 QT_NO_SYSTEMTRAYICON
++
++#include "qabstractsystemtrayiconsys_p.h"
++
++
++QSystemTrayIconSysFactoryInterface::QSystemTrayIconSysFactoryInterface()
++{
++}
++
++/////////////////////////////////////////////////
++QAbstractSystemTrayIconSys::QAbstractSystemTrayIconSys(QSystemTrayIcon *icon)
++: trayIcon(icon)
++{
++}
++
++QAbstractSystemTrayIconSys::~QAbstractSystemTrayIconSys()
++{
++}
++
++void QAbstractSystemTrayIconSys::sendActivated(QSystemTrayIcon::ActivationReason reason)
++{
++ qtsystray_sendActivated(trayIcon, reason);
++}
++
++#endif
+--- /dev/null
++++ b/src/gui/util/qabstractsystemtrayiconsys_p.h
+@@ -0,0 +1,106 @@
++/****************************************************************************
++**
++** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
++** All rights reserved.
++** Contact: Nokia Corporation (qt-info@nokia.com)
++**
++** This file is part of the QtGui module 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 QABSTRACTSYSTEMTRAYICONSYS_P_H
++#define QABSTRACTSYSTEMTRAYICONSYS_P_H
++
++//
++// W A R N I N G
++// -------------
++//
++// This file is not part of the Qt API. It exists for the convenience
++// of a number of Qt sources files. This header file may change from
++// version to version without notice, or even be removed.
++//
++// We mean it.
++//
++
++#ifndef QT_NO_SYSTEMTRAYICON
++
++#include <qfactoryinterface.h>
++#include <qsystemtrayicon.h>
++
++class QAbstractSystemTrayIconSys;
++
++class Q_GUI_EXPORT QSystemTrayIconSysFactoryInterface : public QObject, public QFactoryInterface
++{
++ Q_OBJECT
++public:
++ QSystemTrayIconSysFactoryInterface();
++ virtual QAbstractSystemTrayIconSys * create(QSystemTrayIcon *) = 0;
++ virtual bool isAvailable() const = 0;
++
++ // \reimp
++ virtual QStringList keys() const { return QStringList() << QLatin1String("default"); }
++
++Q_SIGNALS:
++ void availableChanged(bool);
++};
++
++#define QSystemTrayIconSysFactoryInterface_iid "com.nokia.qt.QSystemTrayIconSysFactoryInterface"
++Q_DECLARE_INTERFACE(QSystemTrayIconSysFactoryInterface, QSystemTrayIconSysFactoryInterface_iid)
++
++class QRect;
++
++class Q_GUI_EXPORT QAbstractSystemTrayIconSys
++{
++public:
++ QAbstractSystemTrayIconSys(QSystemTrayIcon *icon);
++ virtual ~QAbstractSystemTrayIconSys();
++
++ virtual QRect geometry() const = 0;
++ virtual void updateVisibility() = 0;
++ virtual void updateIcon() = 0;
++ virtual void updateToolTip() = 0;
++ virtual void updateMenu() = 0;
++ virtual void showMessage(const QString &title, const QString &message,
++ QSystemTrayIcon::MessageIcon icon, int msecs) = 0;
++
++ void sendActivated(QSystemTrayIcon::ActivationReason);
++
++protected:
++ QSystemTrayIcon *trayIcon;
++};
++
++#endif // QT_NO_SYSTEMTRAYICON
++
++#endif // QABSTRACTSYSTEMTRAYICONSYS_P_H
++
+--- a/src/gui/util/qsystemtrayicon.cpp
++++ b/src/gui/util/qsystemtrayicon.cpp
+@@ -287,12 +287,6 @@
+ */
+ bool QSystemTrayIcon::event(QEvent *e)
+ {
+-#if defined(Q_WS_X11)
+- if (e->type() == QEvent::ToolTip) {
+- Q_D(QSystemTrayIcon);
+- return d->sys->deliverToolTipEvent(e);
+- }
+-#endif
+ return QObject::event(e);
+ }
+
+--- a/src/gui/util/qsystemtrayicon_p.h
++++ b/src/gui/util/qsystemtrayicon_p.h
+@@ -62,10 +62,17 @@
+ #include "QtGui/qpixmap.h"
+ #include "QtCore/qstring.h"
+ #include "QtCore/qpointer.h"
++#if defined(Q_WS_X11)
++#include "QtCore/qset.h"
++#endif
+
+ QT_BEGIN_NAMESPACE
+
++#if defined(Q_WS_X11)
++class QAbstractSystemTrayIconSys;
++#else
+ class QSystemTrayIconSys;
++#endif
+ class QToolButton;
+ class QLabel;
+
+@@ -75,6 +82,9 @@
+
+ public:
+ QSystemTrayIconPrivate() : sys(0), visible(false) { }
++ #if defined(Q_WS_X11)
++ ~QSystemTrayIconPrivate();
++ #endif
+
+ void install_sys();
+ void remove_sys();
+@@ -90,7 +100,11 @@
+ QPointer<QMenu> menu;
+ QIcon icon;
+ QString toolTip;
++ #if defined(Q_WS_X11)
++ QAbstractSystemTrayIconSys *sys;
++ #else
+ QSystemTrayIconSys *sys;
++ #endif
+ bool visible;
+ };
+
+@@ -123,60 +137,37 @@
+ };
+
+ #if defined(Q_WS_X11)
+-QT_BEGIN_INCLUDE_NAMESPACE
+-#include <QtCore/qcoreapplication.h>
+-#include <X11/Xlib.h>
+-#include <X11/Xatom.h>
+-#include <X11/Xutil.h>
+-QT_END_INCLUDE_NAMESPACE
++class QSystemTrayIconSysFactoryInterface;
+
+-class QSystemTrayIconSys : public QWidget
++/**
++ * This class acts as a composite QSystemTrayIconSysFactory: It can create
++ * instances of QAbstractSystemTrayIconSys* using either a plugin or the
++ * builtin factory and will cause QSystemTrayIconPrivate to recreate their
++ * 'sys' instances if the plugin availability changes.
++ */
++class QSystemTrayIconSysFactory : public QObject
+ {
+- friend class QSystemTrayIconPrivate;
+-
++ Q_OBJECT
+ public:
+- QSystemTrayIconSys(QSystemTrayIcon *q);
+- ~QSystemTrayIconSys();
+- enum {
+- SYSTEM_TRAY_REQUEST_DOCK = 0,
+- SYSTEM_TRAY_BEGIN_MESSAGE = 1,
+- SYSTEM_TRAY_CANCEL_MESSAGE =2
+- };
+-
+- void addToTray();
+- void updateIcon();
+- XVisualInfo* getSysTrayVisualInfo();
+-
+- // QObject::event is public but QWidget's ::event() re-implementation
+- // is protected ;(
+- inline bool deliverToolTipEvent(QEvent *e)
+- { return QWidget::event(e); }
+-
+- static Window sysTrayWindow;
+- static QList<QSystemTrayIconSys *> trayIcons;
+- static QCoreApplication::EventFilter oldEventFilter;
+- static bool sysTrayTracker(void *message, long *result);
+- static Window locateSystemTray();
+- static Atom sysTraySelection;
+- static XVisualInfo sysTrayVisual;
++ QSystemTrayIconSysFactory();
++ void registerSystemTrayIconPrivate(QSystemTrayIconPrivate *iconPrivate);
++ void unregisterSystemTrayIconPrivate(QSystemTrayIconPrivate *iconPrivate);
+
+-protected:
+- void paintEvent(QPaintEvent *pe);
+- void resizeEvent(QResizeEvent *re);
+- bool x11Event(XEvent *event);
+- void mousePressEvent(QMouseEvent *event);
+- void mouseDoubleClickEvent(QMouseEvent *event);
+-#ifndef QT_NO_WHEELEVENT
+- void wheelEvent(QWheelEvent *event);
+-#endif
+- bool event(QEvent *e);
++ QAbstractSystemTrayIconSys *create(QSystemTrayIcon *) const;
++
++ bool isAvailable() const;
++
++private Q_SLOTS:
++ void refreshTrayIconPrivates();
+
+ private:
+- QPixmap background;
+- QSystemTrayIcon *q;
+- Colormap colormap;
++ QSystemTrayIconSysFactoryInterface *factory() const;
++ void loadPluginFactory();
++
++ QSystemTrayIconSysFactoryInterface *pluginFactory;
++ QSet<QSystemTrayIconPrivate *> trayIconPrivates;
+ };
+-#endif // Q_WS_X11
++#endif
+
+ QT_END_NAMESPACE
+
+--- a/src/gui/util/qsystemtrayicon_x11.cpp
++++ b/src/gui/util/qsystemtrayicon_x11.cpp
+@@ -38,311 +38,122 @@
+ ** $QT_END_LICENSE$
+ **
+ ****************************************************************************/
++#ifndef QT_NO_SYSTEMTRAYICON
++
++#include <private/qfactoryloader_p.h>
+
+-#include "private/qt_x11_p.h"
+-#include "qlabel.h"
+-#include "qx11info_x11.h"
+-#include "qpainter.h"
+-#include "qpixmap.h"
+-#include "qbitmap.h"
+-#include "qevent.h"
+-#include "qapplication.h"
+-#include "qlist.h"
+-#include "qmenu.h"
+-#include "qtimer.h"
+ #include "qsystemtrayicon_p.h"
+-#include "qpaintengine.h"
++#include "qabstractsystemtrayiconsys_p.h"
++#include "qcoreapplication.h"
++#include "qxembedsystemtrayicon_x11_p.h"
+
+-#ifndef QT_NO_SYSTEMTRAYICON
+ QT_BEGIN_NAMESPACE
+
+-Window QSystemTrayIconSys::sysTrayWindow = XNone;
+-QList<QSystemTrayIconSys *> QSystemTrayIconSys::trayIcons;
+-QCoreApplication::EventFilter QSystemTrayIconSys::oldEventFilter = 0;
+-Atom QSystemTrayIconSys::sysTraySelection = XNone;
+-XVisualInfo QSystemTrayIconSys::sysTrayVisual = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+-
+-// Locate the system tray
+-Window QSystemTrayIconSys::locateSystemTray()
+-{
+- Display *display = QX11Info::display();
+- if (sysTraySelection == XNone) {
+- int screen = QX11Info::appScreen();
+- QString net_sys_tray = QString::fromLatin1("_NET_SYSTEM_TRAY_S%1").arg(screen);
+- sysTraySelection = XInternAtom(display, net_sys_tray.toLatin1(), False);
+- }
+-
+- return XGetSelectionOwner(QX11Info::display(), sysTraySelection);
+-}
++Q_GLOBAL_STATIC(QSystemTrayIconSysFactory, qt_guiSystemTrayIconSysFactory)
+
+-XVisualInfo* QSystemTrayIconSys::getSysTrayVisualInfo()
++QSystemTrayIconSysFactory::QSystemTrayIconSysFactory()
++: pluginFactory(0)
+ {
+- Display *display = QX11Info::display();
+-
+- if (!sysTrayVisual.visual) {
+- Window win = locateSystemTray();
+- if (win != XNone) {
+- Atom actual_type;
+- int actual_format;
+- ulong nitems, bytes_remaining;
+- uchar *data = 0;
+- int result = XGetWindowProperty(display, win, ATOM(_NET_SYSTEM_TRAY_VISUAL), 0, 1,
+- False, XA_VISUALID, &actual_type,
+- &actual_format, &nitems, &bytes_remaining, &data);
+- VisualID vid = 0;
+- if (result == Success && data && actual_type == XA_VISUALID && actual_format == 32 &&
+- nitems == 1 && bytes_remaining == 0)
+- vid = *(VisualID*)data;
+- if (data)
+- XFree(data);
+- if (vid == 0)
+- return 0;
+-
+- uint mask = VisualIDMask;
+- XVisualInfo *vi, rvi;
+- int count;
+- rvi.visualid = vid;
+- vi = XGetVisualInfo(display, mask, &rvi, &count);
+- if (vi) {
+- sysTrayVisual = vi[0];
+- XFree((char*)vi);
+- }
+- if (sysTrayVisual.depth != 32)
+- memset(&sysTrayVisual, 0, sizeof(sysTrayVisual));
+- }
+- }
+-
+- return sysTrayVisual.visual ? &sysTrayVisual : 0;
+ }
+
+-bool QSystemTrayIconSys::sysTrayTracker(void *message, long *result)
++void QSystemTrayIconSysFactory::loadPluginFactory()
+ {
+- bool retval = false;
+- if (QSystemTrayIconSys::oldEventFilter)
+- retval = QSystemTrayIconSys::oldEventFilter(message, result);
+-
+- if (trayIcons.isEmpty())
+- return retval;
+-
+- Display *display = QX11Info::display();
+- XEvent *ev = (XEvent *)message;
+- if (ev->type == DestroyNotify && ev->xany.window == sysTrayWindow) {
+- sysTrayWindow = locateSystemTray();
+- memset(&sysTrayVisual, 0, sizeof(sysTrayVisual));
+- for (int i = 0; i < trayIcons.count(); i++) {
+- if (sysTrayWindow == XNone) {
+- QBalloonTip::hideBalloon();
+- trayIcons[i]->hide(); // still no luck
+- trayIcons[i]->destroy();
+- trayIcons[i]->create();
+- } else
+- trayIcons[i]->addToTray(); // add it to the new tray
+- }
+- retval = true;
+- } else if (ev->type == ClientMessage && sysTrayWindow == XNone) {
+- static Atom manager_atom = XInternAtom(display, "MANAGER", False);
+- XClientMessageEvent *cm = (XClientMessageEvent *)message;
+- if ((cm->message_type == manager_atom) && ((Atom)cm->data.l[1] == sysTraySelection)) {
+- sysTrayWindow = cm->data.l[2];
+- memset(&sysTrayVisual, 0, sizeof(sysTrayVisual));
+- XSelectInput(display, sysTrayWindow, StructureNotifyMask);
+- for (int i = 0; i < trayIcons.count(); i++) {
+- trayIcons[i]->addToTray();
+- }
+- retval = true;
+- }
+- } else if (ev->type == PropertyNotify && ev->xproperty.atom == ATOM(_NET_SYSTEM_TRAY_VISUAL) &&
+- ev->xproperty.window == sysTrayWindow) {
+- memset(&sysTrayVisual, 0, sizeof(sysTrayVisual));
+- for (int i = 0; i < trayIcons.count(); i++) {
+- trayIcons[i]->addToTray();
+- }
+- }
+-
+- return retval;
+-}
+-
+-QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *q)
+- : QWidget(0, Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint),
+- q(q), colormap(0)
+-{
+- setAttribute(Qt::WA_AlwaysShowToolTips);
+- setAttribute(Qt::WA_QuitOnClose, false);
+- setAttribute(Qt::WA_NoSystemBackground, true);
+- setAttribute(Qt::WA_PaintOnScreen);
+-
+- static bool eventFilterAdded = false;
+- Display *display = QX11Info::display();
+- if (!eventFilterAdded) {
+- oldEventFilter = qApp->setEventFilter(sysTrayTracker);
+- eventFilterAdded = true;
+- Window root = QX11Info::appRootWindow();
+- XWindowAttributes attr;
+- XGetWindowAttributes(display, root, &attr);
+- if ((attr.your_event_mask & StructureNotifyMask) != StructureNotifyMask) {
+- (void) QApplication::desktop(); // lame trick to ensure our event mask is not overridden
+- XSelectInput(display, root, attr.your_event_mask | StructureNotifyMask); // for MANAGER selection
+- }
++ if (pluginFactory) {
++ return;
+ }
+- if (trayIcons.isEmpty()) {
+- sysTrayWindow = locateSystemTray();
+- if (sysTrayWindow != XNone)
+- XSelectInput(display, sysTrayWindow, StructureNotifyMask); // track tray events
++#ifndef QT_NO_LIBRARY
++ QFactoryLoader loader(QSystemTrayIconSysFactoryInterface_iid, QLatin1String("/systemtrayicon"));
++ pluginFactory = qobject_cast<QSystemTrayIconSysFactoryInterface *>(loader.instance(QLatin1String("default")));
++ if (pluginFactory) {
++ // Set parent to ensure factory destructor is called when application
++ // is closed
++ pluginFactory->setParent(QCoreApplication::instance());
++ connect(pluginFactory, SIGNAL(availableChanged(bool)), SLOT(refreshTrayIconPrivates()));
+ }
+- trayIcons.append(this);
+- setMouseTracking(true);
+-#ifndef QT_NO_TOOLTIP
+- setToolTip(q->toolTip());
+-#endif
+- if (sysTrayWindow != XNone)
+- addToTray();
++#endif // QT_NO_LIBRARY
+ }
+
+-QSystemTrayIconSys::~QSystemTrayIconSys()
++QSystemTrayIconSysFactoryInterface *QSystemTrayIconSysFactory::factory() const
+ {
+- trayIcons.removeAt(trayIcons.indexOf(this));
+- Display *display = QX11Info::display();
+- if (trayIcons.isEmpty()) {
+- if (sysTrayWindow == XNone)
+- return;
+- if (display)
+- XSelectInput(display, sysTrayWindow, 0); // stop tracking the tray
+- sysTrayWindow = XNone;
++ if (!pluginFactory) {
++ const_cast<QSystemTrayIconSysFactory*>(this)->loadPluginFactory();
+ }
+- if (colormap)
+- XFreeColormap(display, colormap);
++ if (pluginFactory && pluginFactory->isAvailable()) {
++ return pluginFactory;
++ }
++ static QXEmbedSystemTrayIconSysFactory def;
++ return def.isAvailable() ? &def : 0;
+ }
+
+-void QSystemTrayIconSys::addToTray()
++void QSystemTrayIconSysFactory::refreshTrayIconPrivates()
+ {
+- Q_ASSERT(sysTrayWindow != XNone);
+- Display *display = QX11Info::display();
+-
+- XVisualInfo *vi = getSysTrayVisualInfo();
+- if (vi && vi->visual) {
+- Window root = RootWindow(display, vi->screen);
+- Window p = root;
+- if (QWidget *pw = parentWidget())
+- p = pw->effectiveWinId();
+- colormap = XCreateColormap(display, root, vi->visual, AllocNone);
+- XSetWindowAttributes wsa;
+- wsa.background_pixmap = 0;
+- wsa.colormap = colormap;
+- wsa.background_pixel = 0;
+- wsa.border_pixel = 0;
+- Window wid = XCreateWindow(display, p, -1, -1, 1, 1,
+- 0, vi->depth, InputOutput, vi->visual,
+- CWBackPixmap|CWBackPixel|CWBorderPixel|CWColormap, &wsa);
+- create(wid);
+- } else {
+- XSetWindowBackgroundPixmap(display, winId(), ParentRelative);
+- }
+-
+- // GNOME, NET WM Specification
+- static Atom netwm_tray_atom = XInternAtom(display, "_NET_SYSTEM_TRAY_OPCODE", False);
+- long l[5] = { CurrentTime, SYSTEM_TRAY_REQUEST_DOCK, static_cast<long>(winId()), 0, 0 };
+- XEvent ev;
+- memset(&ev, 0, sizeof(ev));
+- ev.xclient.type = ClientMessage;
+- ev.xclient.window = sysTrayWindow;
+- ev.xclient.message_type = netwm_tray_atom;
+- ev.xclient.format = 32;
+- memcpy((char *)&ev.xclient.data, (const char *) l, sizeof(l));
+- XSendEvent(display, sysTrayWindow, False, 0, &ev);
+- setMinimumSize(22, 22); // required at least on GNOME
+-}
+-
+-void QSystemTrayIconSys::updateIcon()
+-{
+- update();
+-}
+-
+-void QSystemTrayIconSys::resizeEvent(QResizeEvent *re)
+-{
+- QWidget::resizeEvent(re);
+- updateIcon();
+-}
+-
+-void QSystemTrayIconSys::paintEvent(QPaintEvent*)
+-{
+- QPainter p(this);
+- if (!getSysTrayVisualInfo()) {
+- const QRegion oldSystemClip = p.paintEngine()->systemClip();
+- const QRect clearedRect = oldSystemClip.boundingRect();
+- XClearArea(QX11Info::display(), winId(), clearedRect.x(), clearedRect.y(),
+- clearedRect.width(), clearedRect.height(), False);
+- QPaintEngine *pe = p.paintEngine();
+- pe->setSystemClip(clearedRect);
+- q->icon().paint(&p, rect());
+- pe->setSystemClip(oldSystemClip);
+- } else {
+- p.setCompositionMode(QPainter::CompositionMode_Source);
+- p.fillRect(rect(), Qt::transparent);
+- p.setCompositionMode(QPainter::CompositionMode_SourceOver);
+- q->icon().paint(&p, rect());
++ Q_FOREACH(QSystemTrayIconPrivate *trayIconPrivate, trayIconPrivates) {
++ if (trayIconPrivate->sys) {
++ delete trayIconPrivate->sys;
++ trayIconPrivate->sys = 0;
++ }
++ // When visible is true, sys is usually not 0 but it can be 0 if the
++ // call to install_sys() failed.
++ if (trayIconPrivate->visible) {
++ trayIconPrivate->install_sys();
++ }
+ }
+ }
+
+-void QSystemTrayIconSys::mousePressEvent(QMouseEvent *ev)
++void QSystemTrayIconSysFactory::registerSystemTrayIconPrivate(QSystemTrayIconPrivate* trayIconPrivate)
+ {
+- QPoint globalPos = ev->globalPos();
+- if (ev->button() == Qt::RightButton && q->contextMenu())
+- q->contextMenu()->popup(globalPos);
+-
+- if (QBalloonTip::isBalloonVisible()) {
+- emit q->messageClicked();
+- QBalloonTip::hideBalloon();
+- }
+-
+- if (ev->button() == Qt::LeftButton)
+- emit q->activated(QSystemTrayIcon::Trigger);
+- else if (ev->button() == Qt::RightButton)
+- emit q->activated(QSystemTrayIcon::Context);
+- else if (ev->button() == Qt::MidButton)
+- emit q->activated(QSystemTrayIcon::MiddleClick);
++ trayIconPrivates.insert(trayIconPrivate);
+ }
+
+-void QSystemTrayIconSys::mouseDoubleClickEvent(QMouseEvent *ev)
++void QSystemTrayIconSysFactory::unregisterSystemTrayIconPrivate(QSystemTrayIconPrivate* trayIconPrivate)
+ {
+- if (ev->button() == Qt::LeftButton)
+- emit q->activated(QSystemTrayIcon::DoubleClick);
++ trayIconPrivates.remove(trayIconPrivate);
+ }
+
+-#ifndef QT_NO_WHEELEVENT
+-void QSystemTrayIconSys::wheelEvent(QWheelEvent *e)
++QAbstractSystemTrayIconSys *QSystemTrayIconSysFactory::create(QSystemTrayIcon *trayIcon) const
+ {
+- QApplication::sendEvent(q, e);
++ QSystemTrayIconSysFactoryInterface *f = factory();
++ if (!f) {
++ qWarning("No systemtrayicon available");
++ return 0;
++ }
++ return f->create(trayIcon);
+ }
+-#endif
+
+-bool QSystemTrayIconSys::event(QEvent *e)
++bool QSystemTrayIconSysFactory::isAvailable() const
+ {
+- if (e->type() == QEvent::ToolTip) {
+- return QApplication::sendEvent(q, e);
+- }
+- return QWidget::event(e);
++ return factory();
+ }
+
+-bool QSystemTrayIconSys::x11Event(XEvent *event)
++////////////////////////////////////////////////
++QSystemTrayIconPrivate::~QSystemTrayIconPrivate()
+ {
+- if (event->type == ReparentNotify)
+- show();
+- return QWidget::x11Event(event);
++ qt_guiSystemTrayIconSysFactory()->unregisterSystemTrayIconPrivate(this);
++ delete sys;
+ }
+
+-////////////////////////////////////////////////////////////////////////////
+ void QSystemTrayIconPrivate::install_sys()
+ {
+ Q_Q(QSystemTrayIcon);
+- if (!sys)
+- sys = new QSystemTrayIconSys(q);
++ if (!sys) {
++ // Register ourself even if create() fails: our "sys" will get created
++ // later by refreshTrayIconPrivates() if a systemtray becomes
++ // available. This situation can happen for applications which are
++ // started at login time, while the desktop itself is starting up.
++ qt_guiSystemTrayIconSysFactory()->registerSystemTrayIconPrivate(this);
++ sys = qt_guiSystemTrayIconSysFactory()->create(q);
++ if (!sys) {
++ return;
++ }
++ }
++ sys->updateVisibility();
+ }
+
+ QRect QSystemTrayIconPrivate::geometry_sys() const
+ {
+- if (!sys)
+- return QRect();
+- return QRect(sys->mapToGlobal(QPoint(0, 0)), sys->size());
++ if (!sys || !visible)
++ return QRect();
++ return sys->geometry();
+ }
+
+ void QSystemTrayIconPrivate::remove_sys()
+@@ -350,35 +161,35 @@
+ if (!sys)
+ return;
+ QBalloonTip::hideBalloon();
+- sys->hide(); // this should do the trick, but...
+- delete sys; // wm may resize system tray only for DestroyEvents
+- sys = 0;
++ sys->updateVisibility();
+ }
+
+ void QSystemTrayIconPrivate::updateIcon_sys()
+ {
+- if (!sys)
++ if (!sys || !visible)
+ return;
+ sys->updateIcon();
+ }
+
+ void QSystemTrayIconPrivate::updateMenu_sys()
+ {
+-
++ if (!sys || !visible)
++ return;
++ sys->updateMenu();
+ }
+
+ void QSystemTrayIconPrivate::updateToolTip_sys()
+ {
+- if (!sys)
++ if (!sys || !visible)
+ return;
+ #ifndef QT_NO_TOOLTIP
+- sys->setToolTip(toolTip);
++ sys->updateToolTip();
+ #endif
+ }
+
+ bool QSystemTrayIconPrivate::isSystemTrayAvailable_sys()
+ {
+- return QSystemTrayIconSys::locateSystemTray() != XNone;
++ return qt_guiSystemTrayIconSysFactory()->isAvailable();
+ }
+
+ bool QSystemTrayIconPrivate::supportsMessages_sys()
+@@ -389,12 +200,9 @@
+ void QSystemTrayIconPrivate::showMessage_sys(const QString &message, const QString &title,
+ QSystemTrayIcon::MessageIcon icon, int msecs)
+ {
+- if (!sys)
++ if (!sys || !visible)
+ return;
+- QPoint g = sys->mapToGlobal(QPoint(0, 0));
+- QBalloonTip::showBalloon(icon, message, title, sys->q,
+- QPoint(g.x() + sys->width()/2, g.y() + sys->height()/2),
+- msecs);
++ sys->showMessage(message, title, icon, msecs);
+ }
+
+ QT_END_NAMESPACE
+--- /dev/null
++++ b/src/gui/util/qxembedsystemtrayicon_x11.cpp
+@@ -0,0 +1,469 @@
++/****************************************************************************
++**
++** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
++** All rights reserved.
++** Contact: Nokia Corporation (qt-info@nokia.com)
++**
++** This file is part of the QtGui module 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 "qxembedsystemtrayicon_x11_p.h"
++
++#ifndef QT_NO_SYSTEMTRAYICON
++
++#include "private/qt_x11_p.h"
++#include "qapplication.h"
++#include "qevent.h"
++#include "qlist.h"
++#include "qmenu.h"
++#include "qpainter.h"
++#include "qpaintengine.h"
++#include "qsystemtrayicon_p.h"
++#include "qx11info_x11.h"
++
++QT_BEGIN_INCLUDE_NAMESPACE
++#include <QtCore/qcoreapplication.h>
++#include <X11/Xlib.h>
++#include <X11/Xatom.h>
++#include <X11/Xutil.h>
++QT_END_INCLUDE_NAMESPACE
++
++QT_BEGIN_NAMESPACE
++
++class QSystemTrayIconWidget : public QWidget
++{
++public:
++ QSystemTrayIconWidget(QSystemTrayIcon *q, QXEmbedSystemTrayIconSys *s);
++ ~QSystemTrayIconWidget();
++
++ static Window locateSystemTray();
++
++protected:
++ void paintEvent(QPaintEvent *pe);
++ void resizeEvent(QResizeEvent *re);
++ bool x11Event(XEvent *event);
++ void mousePressEvent(QMouseEvent *event);
++ void mouseDoubleClickEvent(QMouseEvent *event);
++#ifndef QT_NO_WHEELEVENT
++ void wheelEvent(QWheelEvent *event);
++#endif
++ bool event(QEvent *e);
++
++private:
++ enum {
++ SYSTEM_TRAY_REQUEST_DOCK = 0,
++ SYSTEM_TRAY_BEGIN_MESSAGE = 1,
++ SYSTEM_TRAY_CANCEL_MESSAGE =2
++ };
++
++ void addToTray();
++ static XVisualInfo* getSysTrayVisualInfo();
++
++ static Window sysTrayWindow;
++ static QList<QSystemTrayIconWidget *> trayIcons;
++ static QCoreApplication::EventFilter oldEventFilter;
++ static bool sysTrayTracker(void *message, long *result);
++ static Atom sysTraySelection;
++ static XVisualInfo sysTrayVisual;
++
++ QSystemTrayIcon *q;
++ QXEmbedSystemTrayIconSys *sys;
++ Colormap colormap;
++};
++
++Window QSystemTrayIconWidget::sysTrayWindow = XNone;
++QList<QSystemTrayIconWidget *> QSystemTrayIconWidget::trayIcons;
++QCoreApplication::EventFilter QSystemTrayIconWidget::oldEventFilter = 0;
++Atom QSystemTrayIconWidget::sysTraySelection = XNone;
++XVisualInfo QSystemTrayIconWidget::sysTrayVisual = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
++
++QSystemTrayIconWidget::QSystemTrayIconWidget(QSystemTrayIcon* q, QXEmbedSystemTrayIconSys* sys)
++: QWidget(0, Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint)
++, q(q)
++, sys(sys)
++, colormap(0)
++{
++ setAttribute(Qt::WA_AlwaysShowToolTips);
++ setAttribute(Qt::WA_QuitOnClose, false);
++ setAttribute(Qt::WA_NoSystemBackground, true);
++ setAttribute(Qt::WA_PaintOnScreen);
++ setMouseTracking(true);
++#ifndef QT_NO_TOOLTIP
++ setToolTip(q->toolTip());
++#endif
++
++ static bool eventFilterAdded = false;
++ Display *display = QX11Info::display();
++ if (!eventFilterAdded) {
++ oldEventFilter = qApp->setEventFilter(sysTrayTracker);
++ eventFilterAdded = true;
++ Window root = QX11Info::appRootWindow();
++ XWindowAttributes attr;
++ XGetWindowAttributes(display, root, &attr);
++ if ((attr.your_event_mask & StructureNotifyMask) != StructureNotifyMask) {
++ (void) QApplication::desktop(); // lame trick to ensure our event mask is not overridden
++ XSelectInput(display, root, attr.your_event_mask | StructureNotifyMask); // for MANAGER selection
++ }
++ }
++ if (trayIcons.isEmpty()) {
++ sysTrayWindow = locateSystemTray();
++ if (sysTrayWindow != XNone)
++ XSelectInput(display, sysTrayWindow, StructureNotifyMask); // track tray events
++ }
++ trayIcons.append(this);
++ if (sysTrayWindow != XNone)
++ addToTray();
++}
++
++QSystemTrayIconWidget::~QSystemTrayIconWidget()
++{
++ trayIcons.removeAt(trayIcons.indexOf(this));
++ Display *display = QX11Info::display();
++ if (trayIcons.isEmpty()) {
++ if (sysTrayWindow == XNone)
++ return;
++ if (display)
++ XSelectInput(display, sysTrayWindow, 0); // stop tracking the tray
++ sysTrayWindow = XNone;
++ }
++ if (colormap)
++ XFreeColormap(display, colormap);
++}
++
++void QSystemTrayIconWidget::resizeEvent(QResizeEvent *re)
++{
++ QWidget::resizeEvent(re);
++ update();
++}
++
++void QSystemTrayIconWidget::paintEvent(QPaintEvent*)
++{
++ QPainter p(this);
++ if (!getSysTrayVisualInfo()) {
++ const QRegion oldSystemClip = p.paintEngine()->systemClip();
++ const QRect clearedRect = oldSystemClip.boundingRect();
++ XClearArea(QX11Info::display(), winId(), clearedRect.x(), clearedRect.y(),
++ clearedRect.width(), clearedRect.height(), False);
++ QPaintEngine *pe = p.paintEngine();
++ pe->setSystemClip(clearedRect);
++ q->icon().paint(&p, rect());
++ pe->setSystemClip(oldSystemClip);
++ } else {
++ p.setCompositionMode(QPainter::CompositionMode_Source);
++ p.fillRect(rect(), Qt::transparent);
++ p.setCompositionMode(QPainter::CompositionMode_SourceOver);
++ q->icon().paint(&p, rect());
++ }
++}
++
++void QSystemTrayIconWidget::mousePressEvent(QMouseEvent *ev)
++{
++ QPoint globalPos = ev->globalPos();
++ if (ev->button() == Qt::RightButton && q->contextMenu())
++ q->contextMenu()->popup(globalPos);
++
++ if (QBalloonTip::isBalloonVisible()) {
++ QMetaObject::invokeMethod(q, "messageClicked");
++ QBalloonTip::hideBalloon();
++ }
++
++ if (ev->button() == Qt::LeftButton)
++ qtsystray_sendActivated(q, QSystemTrayIcon::Trigger);
++ else if (ev->button() == Qt::RightButton)
++ qtsystray_sendActivated(q, QSystemTrayIcon::Context);
++ else if (ev->button() == Qt::MidButton)
++ qtsystray_sendActivated(q, QSystemTrayIcon::MiddleClick);
++}
++
++void QSystemTrayIconWidget::mouseDoubleClickEvent(QMouseEvent *ev)
++{
++ if (ev->button() == Qt::LeftButton)
++ qtsystray_sendActivated(q, QSystemTrayIcon::DoubleClick);
++}
++
++#ifndef QT_NO_WHEELEVENT
++void QSystemTrayIconWidget::wheelEvent(QWheelEvent *e)
++{
++ sys->sendWheelEventToTrayIcon(e->delta(), e->orientation());
++}
++#endif
++
++bool QSystemTrayIconWidget::event(QEvent *e)
++{
++ if (e->type() == QEvent::ToolTip) {
++ sys->sendToolTipEventToTrayIcon();
++ }
++ return QWidget::event(e);
++}
++
++bool QSystemTrayIconWidget::x11Event(XEvent *event)
++{
++ if (event->type == ReparentNotify)
++ show();
++ return QWidget::x11Event(event);
++}
++
++// Locate the system tray
++Window QSystemTrayIconWidget::locateSystemTray()
++{
++ Display *display = QX11Info::display();
++ if (sysTraySelection == XNone) {
++ int screen = QX11Info::appScreen();
++ QString net_sys_tray = QString::fromLatin1("_NET_SYSTEM_TRAY_S%1").arg(screen);
++ sysTraySelection = XInternAtom(display, net_sys_tray.toLatin1(), False);
++ }
++
++ return XGetSelectionOwner(QX11Info::display(), sysTraySelection);
++}
++
++XVisualInfo* QSystemTrayIconWidget::getSysTrayVisualInfo()
++{
++ Display *display = QX11Info::display();
++
++ if (!sysTrayVisual.visual) {
++ Window win = locateSystemTray();
++ if (win != XNone) {
++ Atom actual_type;
++ int actual_format;
++ ulong nitems, bytes_remaining;
++ uchar *data = 0;
++ int result = XGetWindowProperty(display, win, ATOM(_NET_SYSTEM_TRAY_VISUAL), 0, 1,
++ False, XA_VISUALID, &actual_type,
++ &actual_format, &nitems, &bytes_remaining, &data);
++ VisualID vid = 0;
++ if (result == Success && data && actual_type == XA_VISUALID && actual_format == 32 &&
++ nitems == 1 && bytes_remaining == 0)
++ vid = *(VisualID*)data;
++ if (data)
++ XFree(data);
++ if (vid == 0)
++ return 0;
++
++ uint mask = VisualIDMask;
++ XVisualInfo *vi, rvi;
++ int count;
++ rvi.visualid = vid;
++ vi = XGetVisualInfo(display, mask, &rvi, &count);
++ if (vi) {
++ sysTrayVisual = vi[0];
++ XFree((char*)vi);
++ }
++ if (sysTrayVisual.depth != 32)
++ memset(&sysTrayVisual, 0, sizeof(sysTrayVisual));
++ }
++ }
++
++ return sysTrayVisual.visual ? &sysTrayVisual : 0;
++}
++
++bool QSystemTrayIconWidget::sysTrayTracker(void *message, long *result)
++{
++ bool retval = false;
++ if (QSystemTrayIconWidget::oldEventFilter)
++ retval = QSystemTrayIconWidget::oldEventFilter(message, result);
++
++ if (trayIcons.isEmpty())
++ return retval;
++
++ Display *display = QX11Info::display();
++ XEvent *ev = (XEvent *)message;
++ if (ev->type == DestroyNotify && ev->xany.window == sysTrayWindow) {
++ sysTrayWindow = locateSystemTray();
++ memset(&sysTrayVisual, 0, sizeof(sysTrayVisual));
++ for (int i = 0; i < trayIcons.count(); i++) {
++ if (sysTrayWindow == XNone) {
++ QBalloonTip::hideBalloon();
++ trayIcons[i]->hide(); // still no luck
++ trayIcons[i]->destroy();
++ trayIcons[i]->create();
++ } else
++ trayIcons[i]->addToTray(); // add it to the new tray
++ }
++ retval = true;
++ } else if (ev->type == ClientMessage && sysTrayWindow == XNone) {
++ static Atom manager_atom = XInternAtom(display, "MANAGER", False);
++ XClientMessageEvent *cm = (XClientMessageEvent *)message;
++ if ((cm->message_type == manager_atom) && ((Atom)cm->data.l[1] == sysTraySelection)) {
++ sysTrayWindow = cm->data.l[2];
++ memset(&sysTrayVisual, 0, sizeof(sysTrayVisual));
++ XSelectInput(display, sysTrayWindow, StructureNotifyMask);
++ for (int i = 0; i < trayIcons.count(); i++) {
++ trayIcons[i]->addToTray();
++ }
++ retval = true;
++ }
++ } else if (ev->type == PropertyNotify && ev->xproperty.atom == ATOM(_NET_SYSTEM_TRAY_VISUAL) &&
++ ev->xproperty.window == sysTrayWindow) {
++ memset(&sysTrayVisual, 0, sizeof(sysTrayVisual));
++ for (int i = 0; i < trayIcons.count(); i++) {
++ trayIcons[i]->addToTray();
++ }
++ }
++
++ return retval;
++}
++
++void QSystemTrayIconWidget::addToTray()
++{
++ Q_ASSERT(sysTrayWindow != XNone);
++ Display *display = QX11Info::display();
++
++ XVisualInfo *vi = getSysTrayVisualInfo();
++ if (vi && vi->visual) {
++ Window root = RootWindow(display, vi->screen);
++ Window p = root;
++ if (QWidget *pw = parentWidget())
++ p = pw->effectiveWinId();
++ colormap = XCreateColormap(display, root, vi->visual, AllocNone);
++ XSetWindowAttributes wsa;
++ wsa.background_pixmap = 0;
++ wsa.colormap = colormap;
++ wsa.background_pixel = 0;
++ wsa.border_pixel = 0;
++ Window wid = XCreateWindow(display, p, -1, -1, 1, 1,
++ 0, vi->depth, InputOutput, vi->visual,
++ CWBackPixmap|CWBackPixel|CWBorderPixel|CWColormap, &wsa);
++ create(wid);
++ } else {
++ XSetWindowBackgroundPixmap(display, winId(), ParentRelative);
++ }
++
++ // GNOME, NET WM Specification
++ static Atom netwm_tray_atom = XInternAtom(display, "_NET_SYSTEM_TRAY_OPCODE", False);
++ long l[5] = { CurrentTime, SYSTEM_TRAY_REQUEST_DOCK, static_cast<long>(winId()), 0, 0 };
++ XEvent ev;
++ memset(&ev, 0, sizeof(ev));
++ ev.xclient.type = ClientMessage;
++ ev.xclient.window = sysTrayWindow;
++ ev.xclient.message_type = netwm_tray_atom;
++ ev.xclient.format = 32;
++ memcpy((char *)&ev.xclient.data, (const char *) l, sizeof(l));
++ XSendEvent(display, sysTrayWindow, False, 0, &ev);
++ setMinimumSize(22, 22); // required at least on GNOME
++}
++
++////////////////////////////////////////////////////////////////////////////
++QXEmbedSystemTrayIconSys::QXEmbedSystemTrayIconSys(QSystemTrayIcon *q)
++: QAbstractSystemTrayIconSys(q)
++, widget(0)
++{
++}
++
++QXEmbedSystemTrayIconSys::~QXEmbedSystemTrayIconSys()
++{
++ delete widget;
++}
++
++QRect QXEmbedSystemTrayIconSys::geometry() const
++{
++ if (!widget)
++ return QRect();
++ return QRect(widget->mapToGlobal(QPoint(0, 0)), widget->size());
++}
++
++void QXEmbedSystemTrayIconSys::updateIcon()
++{
++ if (!widget)
++ return;
++ widget->update();
++}
++
++void QXEmbedSystemTrayIconSys::updateToolTip()
++{
++ if (!widget)
++ return;
++ widget->setToolTip(trayIcon->toolTip());
++}
++
++void QXEmbedSystemTrayIconSys::showMessage(const QString &message, const QString &title,
++ QSystemTrayIcon::MessageIcon icon, int msecs)
++{
++ if (!widget)
++ return;
++ QPoint point = geometry().center();
++ QBalloonTip::showBalloon(icon, message, title, trayIcon, point, msecs);
++}
++
++void QXEmbedSystemTrayIconSys::updateVisibility()
++{
++ bool visible = trayIcon->isVisible();
++ if (visible && !widget)
++ widget = new QSystemTrayIconWidget(trayIcon, this);
++ else if (!visible && widget) {
++ delete widget;
++ widget = 0;
++ }
++}
++
++void QXEmbedSystemTrayIconSys::sendToolTipEventToTrayIcon()
++{
++#ifndef QT_NO_TOOLTIP
++ // Pass the event through QSystemTrayIcon so that it gets a chance to
++ // update the tooltip, then asks widget to show the tooltip
++ Q_ASSERT(widget);
++ QPoint globalPos = QCursor::pos();
++ QPoint pos = widget->mapFromGlobal(globalPos);
++ QHelpEvent event(QEvent::ToolTip, pos, globalPos);
++ QApplication::sendEvent(trayIcon, &event);
++#endif
++}
++
++void QXEmbedSystemTrayIconSys::sendWheelEventToTrayIcon(int delta, Qt::Orientation orientation)
++{
++#ifndef QT_NO_WHEELEVENT
++ Q_ASSERT(widget);
++ QPoint globalPos = QCursor::pos();
++ QPoint pos = widget->mapFromGlobal(globalPos);
++ QWheelEvent event(pos, globalPos, delta, Qt::NoButton, Qt::NoModifier, orientation);
++ QApplication::sendEvent(trayIcon, &event);
++#endif
++}
++
++void QXEmbedSystemTrayIconSys::updateMenu()
++{
++}
++
++/////////////////////////////////////////////////////////////
++QAbstractSystemTrayIconSys * QXEmbedSystemTrayIconSysFactory::create(QSystemTrayIcon *icon)
++{
++ return new QXEmbedSystemTrayIconSys(icon);
++}
++
++bool QXEmbedSystemTrayIconSysFactory::isAvailable() const
++{
++ return QSystemTrayIconWidget::locateSystemTray() != XNone;
++}
++
++QT_END_NAMESPACE
++#endif //QT_NO_SYSTEMTRAYICON
+--- /dev/null
++++ b/src/gui/util/qxembedsystemtrayicon_x11_p.h
+@@ -0,0 +1,104 @@
++/****************************************************************************
++**
++** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
++** All rights reserved.
++** Contact: Nokia Corporation (qt-info@nokia.com)
++**
++** This file is part of the QtGui module 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 QXEMBEDSYSTEMTRAYICON_X11_P_H
++#define QXEMBEDSYSTEMTRAYICON_X11_P_H
++
++//
++// W A R N I N G
++// -------------
++//
++// This file is not part of the Qt API. It exists for the convenience
++// of a number of Qt sources files. This header file may change from
++// version to version without notice, or even be removed.
++//
++// We mean it.
++//
++
++#ifndef QT_NO_SYSTEMTRAYICON
++
++#include "qabstractsystemtrayiconsys_p.h"
++
++QT_BEGIN_NAMESPACE
++
++class QSystemTrayIconWidget;
++
++class QXEmbedSystemTrayIconSys : public QAbstractSystemTrayIconSys
++{
++public:
++ QXEmbedSystemTrayIconSys(QSystemTrayIcon *);
++ ~QXEmbedSystemTrayIconSys();
++
++ QRect geometry() const;
++
++ void updateVisibility();
++
++ void updateIcon();
++
++ void updateToolTip();
++
++ void updateMenu();
++
++ void showMessage(const QString &message, const QString &title,
++ QSystemTrayIcon::MessageIcon icon, int msecs);
++
++private:
++ friend class QSystemTrayIconWidget;
++ QSystemTrayIconWidget *widget;
++
++ void sendToolTipEventToTrayIcon();
++
++ void sendWheelEventToTrayIcon(int delta, Qt::Orientation orientation);
++};
++
++struct QXEmbedSystemTrayIconSysFactory : public QSystemTrayIconSysFactoryInterface
++{
++ QAbstractSystemTrayIconSys * create(QSystemTrayIcon *trayIcon);
++ bool isAvailable() const;
++};
++
++
++QT_END_NAMESPACE
++
++#endif // QT_NO_SYSTEMTRAYICON
++
++#endif // QXEMBEDSYSTEMTRAYICON_X11_P_H
++
+--- a/src/gui/util/util.pri
++++ b/src/gui/util/util.pri
+@@ -29,8 +29,13 @@
+ }
+
+ unix:x11 {
++ HEADERS += \
++ util/qabstractsystemtrayiconsys_p.h \
++ util/qxembedsystemtrayicon_x11_p.h
+ SOURCES += \
+- util/qsystemtrayicon_x11.cpp
++ util/qabstractsystemtrayiconsys.cpp \
++ util/qsystemtrayicon_x11.cpp \
++ util/qxembedsystemtrayicon_x11.cpp
+ }
+
+ embedded|qpa {
diff --git a/qt4/l-qclipboard_delay.patch b/qt4/l-qclipboard_delay.patch
new file mode 100644
index 00000000..22643e8d
--- /dev/null
+++ b/qt4/l-qclipboard_delay.patch
@@ -0,0 +1,12 @@
+--- src/gui/kernel/qclipboard_x11.cpp.sav 2014-04-25 09:52:03.855693228 +0200
++++ src/gui/kernel/qclipboard_x11.cpp 2014-04-25 09:51:58.038693777 +0200
+@@ -548,7 +548,8 @@ bool QX11Data::clipboardWaitForEvent(Win
+ return false;
+
+ XSync(X11->display, false);
+- usleep(50000);
++ if (!XPending(X11->display))
++ usleep(5000);
+
+ now.start();
+
diff --git a/qt4/l-qclipboard_fix_recursive.patch b/qt4/l-qclipboard_fix_recursive.patch
new file mode 100644
index 00000000..6d3bf2f2
--- /dev/null
+++ b/qt4/l-qclipboard_fix_recursive.patch
@@ -0,0 +1,94 @@
+--- src/corelib/kernel/qeventdispatcher_glib.cpp.sav 2014-03-28 15:26:37.000000000 +0100
++++ src/corelib/kernel/qeventdispatcher_glib.cpp 2014-04-24 09:44:09.358659204 +0200
+@@ -255,22 +255,30 @@ struct GPostEventSource
+ GSource source;
+ QAtomicInt serialNumber;
+ int lastSerialNumber;
++ QEventLoop::ProcessEventsFlags processEventsFlags;
+ QEventDispatcherGlibPrivate *d;
+ };
+
+ static gboolean postEventSourcePrepare(GSource *s, gint *timeout)
+ {
++ GPostEventSource *source = reinterpret_cast<GPostEventSource *>(s);
+ QThreadData *data = QThreadData::current();
+ if (!data)
+ return false;
+
++ QEventLoop::ProcessEventsFlags excludeAllFlags
++ = QEventLoop::ExcludeUserInputEvents
++ | QEventLoop::ExcludeSocketNotifiers
++ | QEventLoop::X11ExcludeTimers;
++ if ((source->processEventsFlags & excludeAllFlags) == excludeAllFlags)
++ return false;
++
+ gint dummy;
+ if (!timeout)
+ timeout = &dummy;
+ const bool canWait = data->canWaitLocked();
+ *timeout = canWait ? -1 : 0;
+
+- GPostEventSource *source = reinterpret_cast<GPostEventSource *>(s);
+ return (!canWait
+ || (source->serialNumber != source->lastSerialNumber));
+ }
+@@ -284,8 +292,14 @@ static gboolean postEventSourceDispatch(
+ {
+ GPostEventSource *source = reinterpret_cast<GPostEventSource *>(s);
+ source->lastSerialNumber = source->serialNumber;
+- QCoreApplication::sendPostedEvents();
+- source->d->runTimersOnceWithNormalPriority();
++ QEventLoop::ProcessEventsFlags excludeAllFlags
++ = QEventLoop::ExcludeUserInputEvents
++ | QEventLoop::ExcludeSocketNotifiers
++ | QEventLoop::X11ExcludeTimers;
++ if ((source->processEventsFlags & excludeAllFlags) != excludeAllFlags) {
++ QCoreApplication::sendPostedEvents();
++ source->d->runTimersOnceWithNormalPriority();
++ }
+ return true; // i dunno, george...
+ }
+
+@@ -329,6 +343,7 @@ QEventDispatcherGlibPrivate::QEventDispa
+ postEventSource = reinterpret_cast<GPostEventSource *>(g_source_new(&postEventSourceFuncs,
+ sizeof(GPostEventSource)));
+ postEventSource->serialNumber = 1;
++ postEventSource->processEventsFlags = QEventLoop::AllEvents;
+ postEventSource->d = this;
+ g_source_set_can_recurse(&postEventSource->source, true);
+ g_source_attach(&postEventSource->source, mainContext);
+@@ -423,6 +438,7 @@ bool QEventDispatcherGlib::processEvents
+
+ // tell postEventSourcePrepare() and timerSource about any new flags
+ QEventLoop::ProcessEventsFlags savedFlags = d->timerSource->processEventsFlags;
++ d->postEventSource->processEventsFlags = flags;
+ d->timerSource->processEventsFlags = flags;
+ d->socketNotifierSource->processEventsFlags = flags;
+
+@@ -435,6 +451,7 @@ bool QEventDispatcherGlib::processEvents
+ while (!result && canWait)
+ result = g_main_context_iteration(d->mainContext, canWait);
+
++ d->postEventSource->processEventsFlags = savedFlags;
+ d->timerSource->processEventsFlags = savedFlags;
+ d->socketNotifierSource->processEventsFlags = savedFlags;
+
+--- src/corelib/kernel/qeventdispatcher_unix.cpp.sav 2013-06-07 07:16:52.000000000 +0200
++++ src/corelib/kernel/qeventdispatcher_unix.cpp 2014-04-24 09:43:06.927589535 +0200
+@@ -905,7 +905,15 @@ bool QEventDispatcherUNIX::processEvents
+
+ // we are awake, broadcast it
+ emit awake();
+- QCoreApplicationPrivate::sendPostedEvents(0, 0, d->threadData);
++
++ QEventLoop::ProcessEventsFlags excludeAllFlags
++ = QEventLoop::ExcludeUserInputEvents
++ | QEventLoop::ExcludeSocketNotifiers
++ | QEventLoop::X11ExcludeTimers;
++ if ((flags & excludeAllFlags) == excludeAllFlags)
++ return false;
++ if(( flags & excludeAllFlags ) != excludeAllFlags )
++ QCoreApplicationPrivate::sendPostedEvents(0, 0, d->threadData);
+
+ int nevents = 0;
+ const bool canWait = (d->threadData->canWaitLocked()
diff --git a/qt4/linguist-qt4.desktop b/qt4/linguist-qt4.desktop
new file mode 100644
index 00000000..765c8827
--- /dev/null
+++ b/qt4/linguist-qt4.desktop
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Name=Qt4 Linguist
+Comment=Add translations to Qt4 applications
+Exec=linguist-qt4
+Icon=linguist-qt4
+MimeType=text/vnd.trolltech.linguist;application/x-linguist;
+Terminal=false
+Encoding=UTF-8
+Type=Application
+Categories=Qt;Development;
diff --git a/qt4/moc-boost-workaround.patch b/qt4/moc-boost-workaround.patch
new file mode 100644
index 00000000..027f8064
--- /dev/null
+++ b/qt4/moc-boost-workaround.patch
@@ -0,0 +1,12 @@
+diff -upr qt-everywhere-opensource-src-4.8.6.orig/src/tools/moc/main.cpp qt-everywhere-opensource-src-4.8.6/src/tools/moc/main.cpp
+--- qt-everywhere-opensource-src-4.8.6.orig/src/tools/moc/main.cpp 2014-04-10 21:37:12.000000000 +0300
++++ qt-everywhere-opensource-src-4.8.6/src/tools/moc/main.cpp 2014-11-06 02:24:44.287305916 +0200
+@@ -190,6 +190,8 @@ int runMoc(int _argc, char **_argv)
+
+ // Workaround a bug while parsing the boost/type_traits/has_operator.hpp header. See QTBUG-22829
+ pp.macros["BOOST_TT_HAS_OPERATOR_HPP_INCLUDED"];
++ pp.macros["BOOST_LEXICAL_CAST_INCLUDED"];
++ pp.macros["BOOST_NEXT_PRIOR_HPP_INCLUDED"];
+
+ QByteArray filename;
+ QByteArray output;
diff --git a/qt4/qdbusviewer-qt4.desktop b/qt4/qdbusviewer-qt4.desktop
new file mode 100644
index 00000000..2d4218c9
--- /dev/null
+++ b/qt4/qdbusviewer-qt4.desktop
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Name=Qt4 QDbusViewer
+GenericName=D-Bus Debugger
+Comment=Debug D-Bus applications
+Exec=qdbusviewer-qt4
+Icon=qdbusviewer-qt4
+Terminal=false
+Type=Application
+Categories=Qt;Development;Debugger;
+
diff --git a/qt4/qt4-gcc6.patch b/qt4/qt4-gcc6.patch
new file mode 100644
index 00000000..d65cd246
--- /dev/null
+++ b/qt4/qt4-gcc6.patch
@@ -0,0 +1,36 @@
+diff -up qt-everywhere-opensource-src-4.8.7/configure.gcc6 qt-everywhere-opensource-src-4.8.7/configure
+--- qt-everywhere-opensource-src-4.8.7/configure.gcc6 2016-04-15 07:04:19.430268222 -0500
++++ qt-everywhere-opensource-src-4.8.7/configure 2016-04-15 07:05:22.157568689 -0500
+@@ -7744,7 +7744,7 @@ case "$XPLATFORM" in
+ *-g++*)
+ # Check gcc's version
+ case "$(${QMAKE_CONF_COMPILER} -dumpversion)" in
+- 5*|4*|3.4*)
++ 8*|7*|6*|5*|4*|3.4*)
+ ;;
+ 3.3*)
+ canBuildWebKit="no"
+@@ -8060,7 +8060,7 @@ g++*)
+ 3.*)
+ COMPILER_VERSION="3.*"
+ ;;
+- 5*|4.*)
++ 8*|7*|6*|5*|4.*)
+ COMPILER_VERSION="4"
+ ;;
+ *)
+diff -up qt-everywhere-opensource-src-4.8.7/src/xmlpatterns/api/qcoloroutput_p.h.gcc6
+qt-everywhere-opensource-src-4.8.7/src/xmlpatterns/api/qcoloroutput_p.h
+--- qt-everywhere-opensource-src-4.8.7/src/xmlpatterns/api/qcoloroutput_p.h.gcc6 2015-05-07 09:14:48.000000000 -0500
++++ qt-everywhere-opensource-src-4.8.7/src/xmlpatterns/api/qcoloroutput_p.h 2016-04-15 07:04:19.431268227 -0500
+@@ -70,8 +70,8 @@ namespace QPatternist
+ ForegroundShift = 10,
+ BackgroundShift = 20,
+ SpecialShift = 20,
+- ForegroundMask = ((1 << ForegroundShift) - 1) << ForegroundShift,
+- BackgroundMask = ((1 << BackgroundShift) - 1) << BackgroundShift
++ ForegroundMask = 0x1f << ForegroundShift,
++ BackgroundMask = 0x7 << BackgroundShift
+ };
+
+ public:
diff --git a/qt4/qt4-gcc8.patch b/qt4/qt4-gcc8.patch
new file mode 100644
index 00000000..8ccb84df
--- /dev/null
+++ b/qt4/qt4-gcc8.patch
@@ -0,0 +1,314 @@
+--- src/3rdparty/javascriptcore/JavaScriptCore/jit/JITStubs.cpp 2015-05-07 17:14:48.000000000 +0300
++++ src/3rdparty/javascriptcore/JavaScriptCore/jit/JITStubs.cpp 2019-05-04 13:10:49.491856288 +0300
+@@ -114,11 +114,11 @@
+ COMPILE_ASSERT(offsetof(struct JITStackFrame, code) % 16 == 0x0, JITStackFrame_maintains_16byte_stack_alignment);
+ COMPILE_ASSERT(offsetof(struct JITStackFrame, savedEBX) == 0x3c, JITStackFrame_stub_argument_space_matches_ctiTrampoline);
+ COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x58, JITStackFrame_callFrame_offset_matches_ctiTrampoline);
+ COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x50, JITStackFrame_code_offset_matches_ctiTrampoline);
+
+-asm volatile (
++asm (
+ ".text\n"
+ ".globl " SYMBOL_STRING(ctiTrampoline) "\n"
+ HIDE_SYMBOL(ctiTrampoline) "\n"
+ SYMBOL_STRING(ctiTrampoline) ":" "\n"
+ "pushl %ebp" "\n"
+@@ -136,11 +136,11 @@
+ "popl %esi" "\n"
+ "popl %ebp" "\n"
+ "ret" "\n"
+ );
+
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
+ HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
+ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
+ #if !USE(JIT_STUB_ARGUMENT_VA_LIST)
+ "movl %esp, %ecx" "\n"
+@@ -152,11 +152,11 @@
+ "popl %esi" "\n"
+ "popl %ebp" "\n"
+ "ret" "\n"
+ );
+
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
+ HIDE_SYMBOL(ctiOpThrowNotCaught) "\n"
+ SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
+ "addl $0x3c, %esp" "\n"
+ "popl %ebx" "\n"
+@@ -177,11 +177,11 @@
+ COMPILE_ASSERT(offsetof(struct JITStackFrame, code) % 32 == 0x0, JITStackFrame_maintains_32byte_stack_alignment);
+ COMPILE_ASSERT(offsetof(struct JITStackFrame, savedRBX) == 0x48, JITStackFrame_stub_argument_space_matches_ctiTrampoline);
+ COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x90, JITStackFrame_callFrame_offset_matches_ctiTrampoline);
+ COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x80, JITStackFrame_code_offset_matches_ctiTrampoline);
+
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiTrampoline) "\n"
+ HIDE_SYMBOL(ctiTrampoline) "\n"
+ SYMBOL_STRING(ctiTrampoline) ":" "\n"
+ "pushq %rbp" "\n"
+ "movq %rsp, %rbp" "\n"
+@@ -204,11 +204,11 @@
+ "popq %r12" "\n"
+ "popq %rbp" "\n"
+ "ret" "\n"
+ );
+
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
+ HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
+ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
+ "movq %rsp, %rdi" "\n"
+ "call " SYMBOL_STRING_RELOCATION(cti_vm_throw) "\n"
+@@ -220,11 +220,11 @@
+ "popq %r12" "\n"
+ "popq %rbp" "\n"
+ "ret" "\n"
+ );
+
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
+ HIDE_SYMBOL(ctiOpThrowNotCaught) "\n"
+ SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
+ "addq $0x48, %rsp" "\n"
+ "popq %rbx" "\n"
+@@ -240,11 +240,11 @@
+
+ #if USE(JIT_STUB_ARGUMENT_VA_LIST)
+ #error "JIT_STUB_ARGUMENT_VA_LIST not supported on ARMv7."
+ #endif
+
+-asm volatile (
++asm (
+ ".text" "\n"
+ ".align 2" "\n"
+ ".globl " SYMBOL_STRING(ctiTrampoline) "\n"
+ HIDE_SYMBOL(ctiTrampoline) "\n"
+ ".thumb" "\n"
+@@ -267,11 +267,11 @@
+ "ldr lr, [sp, #0x20]" "\n"
+ "add sp, sp, #0x3c" "\n"
+ "bx lr" "\n"
+ );
+
+-asm volatile (
++asm (
+ ".text" "\n"
+ ".align 2" "\n"
+ ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
+ HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
+ ".thumb" "\n"
+@@ -285,11 +285,11 @@
+ "ldr lr, [sp, #0x20]" "\n"
+ "add sp, sp, #0x3c" "\n"
+ "bx lr" "\n"
+ );
+
+-asm volatile (
++asm (
+ ".text" "\n"
+ ".align 2" "\n"
+ ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
+ HIDE_SYMBOL(ctiOpThrowNotCaught) "\n"
+ ".thumb" "\n"
+@@ -303,11 +303,11 @@
+ "bx lr" "\n"
+ );
+
+ #elif COMPILER(GCC) && CPU(ARM_TRADITIONAL)
+
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiTrampoline) "\n"
+ HIDE_SYMBOL(ctiTrampoline) "\n"
+ SYMBOL_STRING(ctiTrampoline) ":" "\n"
+ "stmdb sp!, {r1-r3}" "\n"
+ "stmdb sp!, {r4-r8, lr}" "\n"
+@@ -321,11 +321,11 @@
+ "ldmia sp!, {r4-r8, lr}" "\n"
+ "add sp, sp, #12" "\n"
+ "mov pc, lr" "\n"
+ );
+
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
+ HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
+ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
+ "mov r0, sp" "\n"
+ "bl " SYMBOL_STRING(cti_vm_throw) "\n"
+@@ -416,11 +416,11 @@
+ // need to change the assembly trampolines below to match.
+ COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x38, JITStackFrame_callFrame_offset_matches_ctiTrampoline);
+ COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x30, JITStackFrame_code_offset_matches_ctiTrampoline);
+ COMPILE_ASSERT(offsetof(struct JITStackFrame, savedEBX) == 0x1c, JITStackFrame_stub_argument_space_matches_ctiTrampoline);
+
+-asm volatile (
++asm (
+ ".text\n"
+ ".globl " SYMBOL_STRING(ctiTrampoline) "\n"
+ HIDE_SYMBOL(ctiTrampoline) "\n"
+ SYMBOL_STRING(ctiTrampoline) ":" "\n"
+ "pushl %ebp" "\n"
+@@ -438,11 +438,11 @@
+ "popl %esi" "\n"
+ "popl %ebp" "\n"
+ "ret" "\n"
+ );
+
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
+ HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
+ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
+ #if !USE(JIT_STUB_ARGUMENT_VA_LIST)
+ "movl %esp, %ecx" "\n"
+@@ -454,11 +454,11 @@
+ "popl %esi" "\n"
+ "popl %ebp" "\n"
+ "ret" "\n"
+ );
+
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
+ HIDE_SYMBOL(ctiOpThrowNotCaught) "\n"
+ SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
+ "addl $0x1c, %esp" "\n"
+ "popl %ebx" "\n"
+@@ -478,11 +478,11 @@
+ // need to change the assembly trampolines below to match.
+ COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x58, JITStackFrame_callFrame_offset_matches_ctiTrampoline);
+ COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x48, JITStackFrame_code_offset_matches_ctiTrampoline);
+ COMPILE_ASSERT(offsetof(struct JITStackFrame, savedRBX) == 0x78, JITStackFrame_stub_argument_space_matches_ctiTrampoline);
+
+-asm volatile (
++asm (
+ ".text\n"
+ ".globl " SYMBOL_STRING(ctiTrampoline) "\n"
+ HIDE_SYMBOL(ctiTrampoline) "\n"
+ SYMBOL_STRING(ctiTrampoline) ":" "\n"
+ "pushq %rbp" "\n"
+@@ -513,11 +513,11 @@
+ "popq %r12" "\n"
+ "popq %rbp" "\n"
+ "ret" "\n"
+ );
+
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
+ HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
+ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
+ "movq %rsp, %rdi" "\n"
+ "call " SYMBOL_STRING_RELOCATION(cti_vm_throw) "\n"
+@@ -529,11 +529,11 @@
+ "popq %r12" "\n"
+ "popq %rbp" "\n"
+ "ret" "\n"
+ );
+
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
+ HIDE_SYMBOL(ctiOpThrowNotCaught) "\n"
+ SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
+ "addq $0x78, %rsp" "\n"
+ "popq %rbx" "\n"
+@@ -549,11 +549,11 @@
+
+ #if USE(JIT_STUB_ARGUMENT_VA_LIST)
+ #error "JIT_STUB_ARGUMENT_VA_LIST not supported on ARMv7."
+ #endif
+
+-asm volatile (
++asm (
+ ".text" "\n"
+ ".align 2" "\n"
+ ".globl " SYMBOL_STRING(ctiTrampoline) "\n"
+ HIDE_SYMBOL(ctiTrampoline) "\n"
+ ".thumb" "\n"
+@@ -576,11 +576,11 @@
+ "ldr lr, [sp, #0x20]" "\n"
+ "add sp, sp, #0x40" "\n"
+ "bx lr" "\n"
+ );
+
+-asm volatile (
++asm (
+ ".text" "\n"
+ ".align 2" "\n"
+ ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
+ HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
+ ".thumb" "\n"
+@@ -594,11 +594,11 @@
+ "ldr lr, [sp, #0x20]" "\n"
+ "add sp, sp, #0x40" "\n"
+ "bx lr" "\n"
+ );
+
+-asm volatile (
++asm (
+ ".text" "\n"
+ ".align 2" "\n"
+ ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
+ HIDE_SYMBOL(ctiOpThrowNotCaught) "\n"
+ ".thumb" "\n"
+@@ -612,11 +612,11 @@
+ "bx lr" "\n"
+ );
+
+ #elif COMPILER(GCC) && CPU(ARM_TRADITIONAL)
+
+-asm volatile (
++asm (
+ ".text\n"
+ ".globl " SYMBOL_STRING(ctiTrampoline) "\n"
+ HIDE_SYMBOL(ctiTrampoline) "\n"
+ SYMBOL_STRING(ctiTrampoline) ":" "\n"
+ "stmdb sp!, {r1-r3}" "\n"
+@@ -630,11 +630,11 @@
+ "ldmia sp!, {r4-r8, lr}" "\n"
+ "add sp, sp, #12" "\n"
+ "mov pc, lr" "\n"
+ );
+
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
+ HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
+ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
+ "mov r0, sp" "\n"
+ "bl " SYMBOL_STRING_RELOCATION(cti_vm_throw) "\n"
+@@ -1022,11 +1022,11 @@
+
+ #define DEFINE_STUB_FUNCTION(rtype, op) \
+ extern "C" { \
+ rtype JITStubThunked_##op(STUB_ARGS_DECLARATION); \
+ }; \
+- asm volatile ( \
++ asm ( \
+ ".text" "\n" \
+ ".align 2" "\n" \
+ ".globl " SYMBOL_STRING(cti_##op) "\n" \
+ HIDE_SYMBOL(cti_##op) "\n" \
+ ".thumb" "\n" \
+@@ -1051,11 +1051,11 @@
+
+ #define DEFINE_STUB_FUNCTION(rtype, op) \
+ extern "C" { \
+ rtype JITStubThunked_##op(STUB_ARGS_DECLARATION); \
+ }; \
+- asm volatile ( \
++ asm ( \
+ ".globl " SYMBOL_STRING(cti_##op) "\n" \
+ HIDE_SYMBOL(cti_##op) "\n" \
+ SYMBOL_STRING(cti_##op) ":" "\n" \
+ "str lr, [sp, #" STRINGIZE_VALUE_OF(THUNK_RETURN_ADDRESS_OFFSET) "]" "\n" \
+ "bl " SYMBOL_STRING(JITStubThunked_##op) "\n" \
diff --git a/qt4/qt4-gcc9.patch b/qt4/qt4-gcc9.patch
new file mode 100644
index 00000000..28bbcd2d
--- /dev/null
+++ b/qt4/qt4-gcc9.patch
@@ -0,0 +1,46 @@
+--- src/corelib/global/qglobal.h 2015-05-07 17:14:48.000000000 +0300
++++ src/corelib/global/qglobal.h 2019-05-28 20:04:15.689744432 +0300
+@@ -2480,26 +2480,35 @@
+ typedef uint Flags;
+ #define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
+
+ #endif /* Q_NO_TYPESAFE_FLAGS */
+
+-#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && !defined(Q_CC_RVCT)
++#if defined(Q_CC_GNU) && !defined(Q_CC_RVCT)
+ /* make use of typeof-extension */
+ template <typename T>
+ class QForeachContainer {
+ public:
+- inline QForeachContainer(const T& t) : c(t), brk(0), i(c.begin()), e(c.end()) { }
++ inline QForeachContainer(const T& t) : c(t), i(c.begin()), e(c.end()), control(1) { }
+ const T c;
+- int brk;
+ typename T::const_iterator i, e;
++ int control;
+ };
+
+-#define Q_FOREACH(variable, container) \
+-for (QForeachContainer<__typeof__(container)> _container_(container); \
+- !_container_.brk && _container_.i != _container_.e; \
+- __extension__ ({ ++_container_.brk; ++_container_.i; })) \
+- for (variable = *_container_.i;; __extension__ ({--_container_.brk; break;}))
++// Explanation of the control word:
++// - it's initialized to 1
++// - that means both the inner and outer loops start
++// - if there were no breaks, at the end of the inner loop, it's set to 0, which
++// causes it to exit (the inner loop is run exactly once)
++// - at the end of the outer loop, it's inverted, so it becomes 1 again, allowing
++// the outer loop to continue executing
++// - if there was a break inside the inner loop, it will exit with control still
++// set to 1; in that case, the outer loop will invert it to 0 and will exit too
++#define Q_FOREACH(variable, container) \
++for (QForeachContainer<__typeof__(container)> _container_(container); \
++ _container_.control && _container_.i != _container_.e; \
++ ++_container_.i, _container_.control ^= 1) \
++for (variable = *_container_.i; _container_.control; _container_.control = 0)
+
+ #else
+
+ struct QForeachContainerBase {};
+
diff --git a/qt4/qt4-glibc-2.25.patch b/qt4/qt4-glibc-2.25.patch
new file mode 100644
index 00000000..ca7b98bd
--- /dev/null
+++ b/qt4/qt4-glibc-2.25.patch
@@ -0,0 +1,30 @@
+diff -up qt-everywhere-opensource-src-4.8.7/src/corelib/global/qglobal.h.majmin
+qt-everywhere-opensource-src-4.8.7/src/corelib/global/qglobal.h
+--- qt-everywhere-opensource-src-4.8.7/src/corelib/global/qglobal.h.majmin 2015-05-07 09:14:48.000000000 -0500
++++ qt-everywhere-opensource-src-4.8.7/src/corelib/global/qglobal.h 2016-12-08 12:10:29.677359701 -0600
+@@ -52,7 +52,7 @@
+ /*
+ can be used like #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0))
+ */
+-#define QT_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch))
++#define QT_VERSION_CHECK(qt_version_check_major, qt_version_check_minor, qt_version_check_patch) ((qt_version_check_major<<16)|(qt_version_check_minor<<8)|(qt_version_check_patch))
+
+ #define QT_PACKAGEDATE_STR "2015-05-07"
+
+diff -up qt-everywhere-opensource-src-4.8.7/src/tools/moc/main.cpp.QTBUG-22829 qt-everywhere-opensource-src-4.8.7/src/tools/moc/main.cpp
+--- qt-everywhere-opensource-src-4.8.7/src/tools/moc/main.cpp.QTBUG-22829 2015-05-07 09:14:44.000000000 -0500
++++ qt-everywhere-opensource-src-4.8.7/src/tools/moc/main.cpp 2016-12-08 12:32:46.638962448 -0600
+@@ -188,10 +188,12 @@ int runMoc(int _argc, char **_argv)
+ pp.macros["Q_MOC_RUN"];
+ pp.macros["__cplusplus"];
+
+- // Workaround a bug while parsing the boost/type_traits/has_operator.hpp header. See QTBUG-22829
++ // Workaround a bugs while parsing some boost headers. See QTBUG-22829
+ pp.macros["BOOST_TT_HAS_OPERATOR_HPP_INCLUDED"];
+ pp.macros["BOOST_LEXICAL_CAST_INCLUDED"];
+ pp.macros["BOOST_NEXT_PRIOR_HPP_INCLUDED"];
++ pp.macros["BOOST_TYPE_TRAITS_HPP"];
++ pp.macros["_SYS_SYSMACROS_H_OUTER"];
+
+ QByteArray filename;
+ QByteArray output;
diff --git a/qt4/qt4-icu59.patch b/qt4/qt4-icu59.patch
new file mode 100644
index 00000000..ed6a8b52
--- /dev/null
+++ b/qt4/qt4-icu59.patch
@@ -0,0 +1,11 @@
+--- qt-everywhere-opensource-src-4.8.7/src/corelib/tools/qlocale_icu.cpp~ 2017-04-25 07:42:22.000000000 +0000
++++ qt-everywhere-opensource-src-4.8.7/src/corelib/tools/qlocale_icu.cpp 2017-04-25 07:44:34.675363008 +0000
+@@ -43,6 +43,8 @@
+ #include "qlibrary.h"
+ #include "qdebug.h"
+
++#define UCHAR_TYPE unsigned short
++
+ #include "unicode/uversion.h"
+ #include "unicode/ucol.h"
+
diff --git a/qt4/qt4-openssl-1.1.patch b/qt4/qt4-openssl-1.1.patch
new file mode 100644
index 00000000..87baef87
--- /dev/null
+++ b/qt4/qt4-openssl-1.1.patch
@@ -0,0 +1,409 @@
+Description: Compile with openssl-1.1.0
+ * Most changes are related to openssl structures are now opaque.
+ * The network/ssl threading setup has been disabled because the
+ old openssl threading model has been removed and is apparently
+ no longer needed.
+ * A number of new functions had to be imported (see changes to
+ src/network/ssl/qsslsocket_openssl_symbols.cpp)
+Author: Gert Wollny <gw.fossdev@gmail.com>
+Last-Update: 2016-06-28
+Bug-Debian: http://bugs.debian.org/828522
+
+--- a/src/network/ssl/qsslcertificate.cpp
++++ b/src/network/ssl/qsslcertificate.cpp
+@@ -259,10 +259,10 @@
+ QByteArray QSslCertificate::version() const
+ {
+ QMutexLocker lock(QMutexPool::globalInstanceGet(d.data()));
+- if (d->versionString.isEmpty() && d->x509)
++ if (d->versionString.isEmpty() && d->x509) {
+ d->versionString =
+- QByteArray::number(qlonglong(q_ASN1_INTEGER_get(d->x509->cert_info->version)) + 1);
+-
++ QByteArray::number(qlonglong(q_X509_get_version(d->x509)) + 1);
++ }
+ return d->versionString;
+ }
+
+@@ -276,7 +276,7 @@
+ {
+ QMutexLocker lock(QMutexPool::globalInstanceGet(d.data()));
+ if (d->serialNumberString.isEmpty() && d->x509) {
+- ASN1_INTEGER *serialNumber = d->x509->cert_info->serialNumber;
++ ASN1_INTEGER *serialNumber = q_X509_get_serialNumber(d->x509);
+ // if we cannot convert to a long, just output the hexadecimal number
+ if (serialNumber->length > 4) {
+ QByteArray hexString;
+@@ -489,24 +489,33 @@
+ QSslKey key;
+
+ key.d->type = QSsl::PublicKey;
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
+ X509_PUBKEY *xkey = d->x509->cert_info->key;
++#else
++ X509_PUBKEY *xkey = q_X509_get_X509_PUBKEY(d->x509);
++#endif
+ EVP_PKEY *pkey = q_X509_PUBKEY_get(xkey);
+ Q_ASSERT(pkey);
+
+- if (q_EVP_PKEY_type(pkey->type) == EVP_PKEY_RSA) {
++ int key_id;
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
++ key_id = q_EVP_PKEY_type(pkey->type);
++#else
++ key_id = q_EVP_PKEY_base_id(pkey);
++#endif
++ if (key_id == EVP_PKEY_RSA) {
+ key.d->rsa = q_EVP_PKEY_get1_RSA(pkey);
+ key.d->algorithm = QSsl::Rsa;
+ key.d->isNull = false;
+- } else if (q_EVP_PKEY_type(pkey->type) == EVP_PKEY_DSA) {
++ } else if (key_id == EVP_PKEY_DSA) {
+ key.d->dsa = q_EVP_PKEY_get1_DSA(pkey);
+ key.d->algorithm = QSsl::Dsa;
+ key.d->isNull = false;
+- } else if (q_EVP_PKEY_type(pkey->type) == EVP_PKEY_DH) {
++ } else if (key_id == EVP_PKEY_DH) {
+ // DH unsupported
+ } else {
+ // error?
+ }
+-
+ q_EVP_PKEY_free(pkey);
+ return key;
+ }
+--- a/src/network/ssl/qsslkey.cpp
++++ b/src/network/ssl/qsslkey.cpp
+@@ -321,8 +321,19 @@
+ {
+ if (d->isNull)
+ return -1;
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
+ return (d->algorithm == QSsl::Rsa)
+ ? q_BN_num_bits(d->rsa->n) : q_BN_num_bits(d->dsa->p);
++#else
++ if (d->algorithm == QSsl::Rsa) {
++ return q_RSA_bits(d->rsa);
++ }else{
++ BIGNUM *p = NULL;
++ q_DSA_get0_pqg(d->dsa, &p, NULL, NULL);
++ return q_BN_num_bits(p);
++ }
++#endif
++
+ }
+
+ /*!
+--- a/src/network/ssl/qsslsocket_openssl.cpp
++++ b/src/network/ssl/qsslsocket_openssl.cpp
+@@ -93,6 +93,7 @@
+ bool QSslSocketPrivate::s_loadedCiphersAndCerts = false;
+ bool QSslSocketPrivate::s_loadRootCertsOnDemand = false;
+
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
+ /* \internal
+
+ From OpenSSL's thread(3) manual page:
+@@ -174,6 +175,8 @@
+ }
+ } // extern "C"
+
++#endif //OPENSSL_VERSION_NUMBER >= 0x10100000L
++
+ QSslSocketBackendPrivate::QSslSocketBackendPrivate()
+ : ssl(0),
+ ctx(0),
+@@ -222,9 +225,12 @@
+ ciph.d->encryptionMethod = descriptionList.at(4).mid(4);
+ ciph.d->exportable = (descriptionList.size() > 6 && descriptionList.at(6) == QLatin1String("export"));
+
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
+ ciph.d->bits = cipher->strength_bits;
+ ciph.d->supportedBits = cipher->alg_bits;
+-
++#else
++ ciph.d->bits = q_SSL_CIPHER_get_bits(cipher, &ciph.d->supportedBits);
++#endif
+ }
+ return ciph;
+ }
+@@ -367,7 +373,7 @@
+ //
+ // See also: QSslContext::fromConfiguration()
+ if (caCertificate.expiryDate() >= QDateTime::currentDateTime()) {
+- q_X509_STORE_add_cert(ctx->cert_store, (X509 *)caCertificate.handle());
++ q_X509_STORE_add_cert(q_SSL_CTX_get_cert_store(ctx), (X509 *)caCertificate.handle());
+ }
+ }
+
+@@ -504,8 +510,10 @@
+ */
+ void QSslSocketPrivate::deinitialize()
+ {
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
+ q_CRYPTO_set_id_callback(0);
+ q_CRYPTO_set_locking_callback(0);
++#endif
+ }
+
+ /*!
+@@ -526,13 +534,17 @@
+ return false;
+
+ // Check if the library itself needs to be initialized.
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
+ QMutexLocker locker(openssl_locks()->initLock());
++#endif
+ if (!s_libraryLoaded) {
+ s_libraryLoaded = true;
+
+ // Initialize OpenSSL.
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
+ q_CRYPTO_set_id_callback(id_function);
+ q_CRYPTO_set_locking_callback(locking_function);
++#endif
+ if (q_SSL_library_init() != 1)
+ return false;
+ q_SSL_load_error_strings();
+@@ -571,7 +583,9 @@
+
+ void QSslSocketPrivate::ensureCiphersAndCertsLoaded()
+ {
+- QMutexLocker locker(openssl_locks()->initLock());
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
++ QMutexLocker locker(openssl_locks()->initLock());
++#endif
+ if (s_loadedCiphersAndCerts)
+ return;
+ s_loadedCiphersAndCerts = true;
+@@ -663,13 +677,18 @@
+ STACK_OF(SSL_CIPHER) *supportedCiphers = q_SSL_get_ciphers(mySsl);
+ for (int i = 0; i < q_sk_SSL_CIPHER_num(supportedCiphers); ++i) {
+ if (SSL_CIPHER *cipher = q_sk_SSL_CIPHER_value(supportedCiphers, i)) {
+- if (cipher->valid) {
++
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
++ if (cipher->valid) {
++#endif
+ QSslCipher ciph = QSslSocketBackendPrivate::QSslCipher_from_SSL_CIPHER(cipher);
+ if (!ciph.isNull()) {
+ if (!ciph.name().toLower().startsWith(QLatin1String("adh")))
+ ciphers << ciph;
+ }
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
+ }
++#endif
+ }
+ }
+
+--- a/src/network/ssl/qsslsocket_openssl_symbols_p.h
++++ b/src/network/ssl/qsslsocket_openssl_symbols_p.h
+@@ -399,7 +399,25 @@
+ PEM_ASN1_write_bio((int (*)(void*, unsigned char**))q_i2d_DSAPrivateKey,PEM_STRING_DSA,\
+ bp,(char *)x,enc,kstr,klen,cb,u)
+ #endif
++
++X509_STORE * q_SSL_CTX_get_cert_store(const SSL_CTX *ctx);
++ASN1_INTEGER * q_X509_get_serialNumber(X509 *x);
++
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
+ #define q_SSL_CTX_set_options(ctx,op) q_SSL_CTX_ctrl((ctx),SSL_CTRL_OPTIONS,(op),NULL)
++#define q_X509_get_version(x) X509_get_version(x)
++#else
++int q_EVP_PKEY_id(const EVP_PKEY *pkey);
++int q_EVP_PKEY_base_id(const EVP_PKEY *pkey);
++int q_SSL_CIPHER_get_bits(const SSL_CIPHER *cipher, int *alg_bits);
++long q_SSL_CTX_set_options(SSL_CTX *ctx, long options);
++long q_X509_get_version(X509 *x);
++X509_PUBKEY * q_X509_get_X509_PUBKEY(X509 *x);
++int q_RSA_bits(const RSA *rsa);
++int q_DSA_security_bits(const DSA *dsa);
++void q_DSA_get0_pqg(const DSA *d, BIGNUM **p, BIGNUM **q, BIGNUM **g);
++#endif
++
+ #define q_SKM_sk_num(type, st) ((int (*)(const STACK_OF(type) *))q_sk_num)(st)
+ #define q_SKM_sk_value(type, st,i) ((type * (*)(const STACK_OF(type) *, int))q_sk_value)(st, i)
+ #define q_sk_GENERAL_NAME_num(st) q_SKM_sk_num(GENERAL_NAME, (st))
+@@ -410,8 +428,15 @@
+ #define q_sk_SSL_CIPHER_value(st, i) q_SKM_sk_value(SSL_CIPHER, (st), (i))
+ #define q_SSL_CTX_add_extra_chain_cert(ctx,x509) \
+ q_SSL_CTX_ctrl(ctx,SSL_CTRL_EXTRA_CHAIN_CERT,0,(char *)x509)
++
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
+ #define q_X509_get_notAfter(x) X509_get_notAfter(x)
+ #define q_X509_get_notBefore(x) X509_get_notBefore(x)
++#else
++ASN1_TIME *q_X509_get_notAfter(X509 *x);
++ASN1_TIME *q_X509_get_notBefore(X509 *x);
++#endif
++
+ #define q_EVP_PKEY_assign_RSA(pkey,rsa) q_EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\
+ (char *)(rsa))
+ #define q_EVP_PKEY_assign_DSA(pkey,dsa) q_EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\
+--- a/src/network/ssl/qsslsocket_openssl_symbols.cpp
++++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp
+@@ -290,6 +290,22 @@
+ DEFINEFUNC(void, OPENSSL_add_all_algorithms_conf, void, DUMMYARG, return, DUMMYARG)
+ DEFINEFUNC3(int, SSL_CTX_load_verify_locations, SSL_CTX *ctx, ctx, const char *CAfile, CAfile, const char *CApath, CApath, return 0, return)
+ DEFINEFUNC(long, SSLeay, void, DUMMYARG, return 0, return)
++DEFINEFUNC(X509_STORE *, SSL_CTX_get_cert_store, const SSL_CTX *ctx, ctx, return 0, return)
++
++DEFINEFUNC(ASN1_INTEGER *, X509_get_serialNumber, X509 *x, x, return 0, return)
++#if OPENSSL_VERSION_NUMBER >= 0x10100000L
++DEFINEFUNC(int, EVP_PKEY_id, const EVP_PKEY *pkey, pkey, return 0, return)
++DEFINEFUNC(int, EVP_PKEY_base_id, const EVP_PKEY *pkey, pkey, return 0, return)
++DEFINEFUNC2(int, SSL_CIPHER_get_bits, const SSL_CIPHER *cipher, cipher, int *alg_bits, alg_bits, return 0, return)
++DEFINEFUNC2(long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, long options, options, return 0, return)
++DEFINEFUNC(long, X509_get_version, X509 *x, x, return 0, return)
++DEFINEFUNC(X509_PUBKEY *, X509_get_X509_PUBKEY, X509 *x, x, return 0, return)
++DEFINEFUNC(int, RSA_bits, const RSA *rsa, rsa, return 0, return)
++DEFINEFUNC(int, DSA_security_bits, const DSA *dsa, dsa, return 0, return)
++DEFINEFUNC(ASN1_TIME *, X509_get_notAfter, X509 *x, x, return 0, return)
++DEFINEFUNC(ASN1_TIME *, X509_get_notBefore, X509 *x, x, return 0, return)
++DEFINEFUNC4(void, DSA_get0_pqg, const DSA *d, d, BIGNUM **p, p, BIGNUM **q, q, BIGNUM **g, g, return, return)
++#endif
+
+ #ifdef Q_OS_SYMBIAN
+ #define RESOLVEFUNC(func, ordinal, lib) \
+@@ -801,6 +817,7 @@
+ RESOLVEFUNC(SSL_CTX_use_PrivateKey)
+ RESOLVEFUNC(SSL_CTX_use_RSAPrivateKey)
+ RESOLVEFUNC(SSL_CTX_use_PrivateKey_file)
++ RESOLVEFUNC(SSL_CTX_get_cert_store)
+ RESOLVEFUNC(SSL_accept)
+ RESOLVEFUNC(SSL_clear)
+ RESOLVEFUNC(SSL_connect)
+@@ -823,6 +840,23 @@
+ RESOLVEFUNC(SSL_set_connect_state)
+ RESOLVEFUNC(SSL_shutdown)
+ RESOLVEFUNC(SSL_write)
++
++ RESOLVEFUNC(X509_get_serialNumber)
++#if OPENSSL_VERSION_NUMBER >= 0x10100000L
++ RESOLVEFUNC(SSL_CTX_ctrl)
++ RESOLVEFUNC(EVP_PKEY_id)
++ RESOLVEFUNC(EVP_PKEY_base_id)
++ RESOLVEFUNC(SSL_CIPHER_get_bits)
++ RESOLVEFUNC(SSL_CTX_set_options)
++ RESOLVEFUNC(X509_get_version)
++ RESOLVEFUNC(X509_get_X509_PUBKEY)
++ RESOLVEFUNC(RSA_bits)
++ RESOLVEFUNC(DSA_security_bits)
++ RESOLVEFUNC(DSA_get0_pqg)
++ RESOLVEFUNC(X509_get_notAfter)
++ RESOLVEFUNC(X509_get_notBefore)
++#endif
++
+ #ifndef OPENSSL_NO_SSL2
+ RESOLVEFUNC(SSLv2_client_method)
+ #endif
+--- qt-everywhere-opensource-src-4.8.7/src/network/ssl/qsslkey.cpp.0131~ 2017-03-15 02:22:37.053244125 +0100
++++ qt-everywhere-opensource-src-4.8.7/src/network/ssl/qsslkey.cpp 2017-03-15 02:22:37.055244057 +0100
+@@ -328,7 +328,7 @@ int QSslKey::length() const
+ if (d->algorithm == QSsl::Rsa) {
+ return q_RSA_bits(d->rsa);
+ }else{
+- BIGNUM *p = NULL;
++ const BIGNUM *p = NULL;
+ q_DSA_get0_pqg(d->dsa, &p, NULL, NULL);
+ return q_BN_num_bits(p);
+ }
+--- qt-everywhere-opensource-src-4.8.7/src/network/ssl/qsslsocket_openssl_symbols.cpp.0131~ 2017-03-15 02:22:37.054244091 +0100
++++ qt-everywhere-opensource-src-4.8.7/src/network/ssl/qsslsocket_openssl_symbols.cpp 2017-03-15 02:29:41.155236836 +0100
+@@ -111,16 +111,16 @@ DEFINEFUNC(int, ASN1_STRING_length, ASN1
+ DEFINEFUNC2(int, ASN1_STRING_to_UTF8, unsigned char **a, a, ASN1_STRING *b, b, return 0, return);
+ DEFINEFUNC4(long, BIO_ctrl, BIO *a, a, int b, b, long c, c, void *d, d, return -1, return)
+ DEFINEFUNC(int, BIO_free, BIO *a, a, return 0, return)
+-DEFINEFUNC(BIO *, BIO_new, BIO_METHOD *a, a, return 0, return)
++DEFINEFUNC(BIO *, BIO_new, const BIO_METHOD *a, a, return 0, return)
+ DEFINEFUNC2(BIO *, BIO_new_mem_buf, void *a, a, int b, b, return 0, return)
+ DEFINEFUNC3(int, BIO_read, BIO *a, a, void *b, b, int c, c, return -1, return)
+-DEFINEFUNC(BIO_METHOD *, BIO_s_mem, void, DUMMYARG, return 0, return)
++DEFINEFUNC(const BIO_METHOD *, BIO_s_mem, void, DUMMYARG, return 0, return)
+ DEFINEFUNC3(int, BIO_write, BIO *a, a, const void *b, b, int c, c, return -1, return)
+ DEFINEFUNC(int, BN_num_bits, const BIGNUM *a, a, return 0, return)
+ DEFINEFUNC(int, CRYPTO_num_locks, DUMMYARG, DUMMYARG, return 0, return)
+ DEFINEFUNC(void, CRYPTO_set_locking_callback, void (*a)(int, int, const char *, int), a, return, DUMMYARG)
+ DEFINEFUNC(void, CRYPTO_set_id_callback, unsigned long (*a)(), a, return, DUMMYARG)
+-DEFINEFUNC(void, CRYPTO_free, void *a, a, return, DUMMYARG)
++DEFINEFUNC(void, OPENSSL_free, void *a, a, return, DUMMYARG)
+ DEFINEFUNC(void, DSA_free, DSA *a, a, return, DUMMYARG)
+ #if OPENSSL_VERSION_NUMBER < 0x00908000L
+ DEFINEFUNC3(X509 *, d2i_X509, X509 **a, a, unsigned char **b, b, long c, c, return 0, return)
+@@ -300,7 +300,7 @@ DEFINEFUNC(int, RSA_bits, const RSA *rs
+ DEFINEFUNC(int, DSA_security_bits, const DSA *dsa, dsa, return 0, return)
+ DEFINEFUNC(ASN1_TIME *, X509_get_notAfter, X509 *x, x, return 0, return)
+ DEFINEFUNC(ASN1_TIME *, X509_get_notBefore, X509 *x, x, return 0, return)
+-DEFINEFUNC4(void, DSA_get0_pqg, const DSA *d, d, BIGNUM **p, p, BIGNUM **q, q, BIGNUM **g, g, return, return)
++DEFINEFUNC4(void, DSA_get0_pqg, const DSA *d, d, const BIGNUM **p, p, const BIGNUM **q, q, const BIGNUM **g, g, return, return)
+ #endif
+
+ #ifdef Q_OS_SYMBIAN
+--- qt-everywhere-opensource-src-4.8.7/src/network/ssl/qsslsocket_openssl_symbols_p.h.0131~ 2017-03-15 02:22:37.054244091 +0100
++++ qt-everywhere-opensource-src-4.8.7/src/network/ssl/qsslsocket_openssl_symbols_p.h 2017-03-15 02:29:50.192986268 +0100
+@@ -59,6 +59,9 @@
+ QT_BEGIN_NAMESPACE
+
+ #define DUMMYARG
++#ifndef OPENSSL_NO_SSL2
++#define OPENSSL_NO_SSL2 1
++#endif
+
+ #if !defined QT_LINKED_OPENSSL
+ // **************** Shared declarations ******************
+@@ -207,16 +210,16 @@ int q_ASN1_STRING_length(ASN1_STRING *a)
+ int q_ASN1_STRING_to_UTF8(unsigned char **a, ASN1_STRING *b);
+ long q_BIO_ctrl(BIO *a, int b, long c, void *d);
+ int q_BIO_free(BIO *a);
+-BIO *q_BIO_new(BIO_METHOD *a);
++BIO *q_BIO_new(const BIO_METHOD *a);
+ BIO *q_BIO_new_mem_buf(void *a, int b);
+ int q_BIO_read(BIO *a, void *b, int c);
+-BIO_METHOD *q_BIO_s_mem();
++const BIO_METHOD *q_BIO_s_mem();
+ int q_BIO_write(BIO *a, const void *b, int c);
+ int q_BN_num_bits(const BIGNUM *a);
+ int q_CRYPTO_num_locks();
+ void q_CRYPTO_set_locking_callback(void (*a)(int, int, const char *, int));
+ void q_CRYPTO_set_id_callback(unsigned long (*a)());
+-void q_CRYPTO_free(void *a);
++void q_OPENSSL_free(void *a);
+ void q_DSA_free(DSA *a);
+ #if OPENSSL_VERSION_NUMBER >= 0x00908000L
+ // 0.9.8 broke SC and BC by changing this function's signature.
+@@ -326,7 +329,6 @@ void q_SSL_set_accept_state(SSL *a);
+ void q_SSL_set_connect_state(SSL *a);
+ int q_SSL_shutdown(SSL *a);
+ #if OPENSSL_VERSION_NUMBER >= 0x10000000L
+-const SSL_METHOD *q_SSLv2_client_method();
+ const SSL_METHOD *q_SSLv3_client_method();
+ const SSL_METHOD *q_SSLv23_client_method();
+ const SSL_METHOD *q_TLSv1_client_method();
+@@ -335,7 +337,6 @@ const SSL_METHOD *q_SSLv3_server_method(
+ const SSL_METHOD *q_SSLv23_server_method();
+ const SSL_METHOD *q_TLSv1_server_method();
+ #else
+-SSL_METHOD *q_SSLv2_client_method();
+ SSL_METHOD *q_SSLv3_client_method();
+ SSL_METHOD *q_SSLv23_client_method();
+ SSL_METHOD *q_TLSv1_client_method();
+@@ -415,7 +416,7 @@ long q_X509_get_version(X509 *x);
+ X509_PUBKEY * q_X509_get_X509_PUBKEY(X509 *x);
+ int q_RSA_bits(const RSA *rsa);
+ int q_DSA_security_bits(const DSA *dsa);
+-void q_DSA_get0_pqg(const DSA *d, BIGNUM **p, BIGNUM **q, BIGNUM **g);
++void q_DSA_get0_pqg(const DSA *d, const BIGNUM **p, const BIGNUM **q, const BIGNUM **g);
+ #endif
+
+ #define q_SKM_sk_num(type, st) ((int (*)(const STACK_OF(type) *))q_sk_num)(st)
+--- qt-everywhere-opensource-src-4.8.7/src/network/ssl/qsslcertificate.cpp.omv~ 2017-03-15 02:27:18.143322736 +0100
++++ qt-everywhere-opensource-src-4.8.7/src/network/ssl/qsslcertificate.cpp 2017-03-15 02:29:56.215819741 +0100
+@@ -696,7 +696,7 @@
+ unsigned char *data = 0;
+ int size = q_ASN1_STRING_to_UTF8(&data, q_X509_NAME_ENTRY_get_data(e));
+ info[QString::fromUtf8(obj)] = QString::fromUtf8((char*)data, size);
+- q_CRYPTO_free(data);
++ q_OPENSSL_free(data);
+ }
+ return info;
+ }
diff --git a/qt4/qtconfig-qt4.desktop b/qt4/qtconfig-qt4.desktop
new file mode 100644
index 00000000..57896312
--- /dev/null
+++ b/qt4/qtconfig-qt4.desktop
@@ -0,0 +1,9 @@
+[Desktop Entry]
+Name=Qt4 Config
+Comment=Configure Qt4 behavior, styles, fonts
+Exec=qtconfig-qt4
+Icon=qt4logo
+Terminal=false
+Type=Application
+Categories=Qt;Settings;
+NoDisplay=true