Description: Switch to Qt5
  This patch switches the build of the tray monitor to Qt5 and works around the
  impossibility to use libtool in install mode with qmake in Qt >= 5.9.

  This can be dropped once 18.x hits Debian as upstream has switched to cmake
  and no longer relies on qmake.
Author: Jakob Haufe <sur5r@debian.org>
Bug-Debian: https://bugs.debian.org/874839
Last-Update: 2019-11-03

diff --git a/autoconf/configure.in b/autoconf/configure.in
index 28bb3ae51..a291f7f76 100644
--- a/autoconf/configure.in
+++ b/autoconf/configure.in
@@ -402,7 +402,7 @@ AC_ARG_ENABLE(traymonitor,
    AC_HELP_STRING([--enable-traymonitor], [enable build of traymonitor @<:@default=no@:>@]),
    [
        if test x$enableval = xyes; then
-          AC_DEFINE(HAVE_TRAYMONITOR, 1, [Define to 1 if tray-monitor Qt4 GUI support should be enabled])
+          AC_DEFINE(HAVE_TRAYMONITOR, 1, [Define to 1 if tray-monitor Qt5 GUI support should be enabled])
           support_traymonitor=yes
        fi
    ]
@@ -411,13 +411,13 @@ AC_ARG_ENABLE(traymonitor,
 TRAY_MONITOR_DIR=
 DEBIAN_CONTROL_TRAYMONITOR=/dev/null
 if test x$support_traymonitor = xyes; then
-   abc=`$PKGCONFIG --atleast-version=4.6 QtGui`
+   abc=`$PKGCONFIG --atleast-version=5.0 Qt5Gui`
    pkg=$?
    if test $pkg = 0; then
       TRAY_MONITOR_DIR=src/qt-tray-monitor
       DEBIAN_CONTROL_TRAYMONITOR=./debian/control.bareos-traymonitor
    else
-      AC_MSG_ERROR(Unable to find suitable Qt4 installation needed by tray-monitor)
+      AC_MSG_ERROR(Unable to find suitable Qt5 installation needed by tray-monitor)
    fi
 fi
 
diff --git a/src/qt-tray-monitor/tray-monitor.pro.in b/src/qt-tray-monitor/tray-monitor.pro.in
index c0351293a..9011bae49 100644
--- a/src/qt-tray-monitor/tray-monitor.pro.in
+++ b/src/qt-tray-monitor/tray-monitor.pro.in
@@ -15,9 +15,12 @@ CONFIG( debug, debug|release )  {
    CONFIG += release
 }
 
-QMAKE_LIBDIR += ../lib
+QMAKE_LIBDIR += ../lib/.libs/
 QMAKE_CXXFLAGS += @JANSSON_INC@
-LIBS         += -lbareoscfg -lbareos
+QMAKE_LFLAGS += '-Wl,-rpath,/usr/lib/bareos'
+LIBS         += -lbareoscfg -lbareos -ljansson
+
+QT += widgets
 
 bins.path            = /$(DESTDIR)@bindir@
 bins.files           = bareos-tray-monitor
@@ -43,10 +46,6 @@ TARGET       = bareos-tray-monitor
 DEPENDPATH  += .
 INCLUDEPATH += ../include .. .
 
-LIBTOOL_LINK = @QMAKE_LIBTOOL@ --silent --tag=CXX --mode=link
-LIBTOOL_INSTALL = @QMAKE_LIBTOOL@ --silent --mode=install
-QMAKE_LINK   = $${LIBTOOL_LINK} $(CXX)
-QMAKE_INSTALL_PROGRAM = $${LIBTOOL_INSTALL} install -m @SBINPERM@ -p
 QMAKE_CLEAN += .libs/* bareos-tray-monitor release/bareos-tray-monitor
 
 RESOURCES    = main.qrc
diff --git a/src/qt-tray-monitor/traymenu.cpp b/src/qt-tray-monitor/traymenu.cpp
index 9e2ef06f8..1f840f92b 100644
--- a/src/qt-tray-monitor/traymenu.cpp
+++ b/src/qt-tray-monitor/traymenu.cpp
@@ -47,7 +47,7 @@ void TrayMenu::createAction(QString objName, QString text, QWidget* mainWindow)
    const QString& translate = QApplication::translate("TrayMonitor",
                                                        text.toUtf8(),
                                                        0,
-                                                       QApplication::UnicodeUTF8);
+                                                       0);
 
    QAction *action = new QAction(translate, mainWindow);
 
