changeset 25046:a4c687fec320 stable

gui: set Qt Application and Desktop metadata for desktop integration (bug #53102) * main-window.cc (main_window::main_window): Initialize Qt application and desktop integration metadata. * org.octave.Octave.desktop.in (StartupWMClass): Use new WM_CLASS name set from QCoreApplication::applicationName under XCB/X11. * acinclude.m4 (OCTAVE_CHECK_FUNC_QGUIAPPLICATION_SETDESKTOPFILENAME): New macro. (OCTAVE_CHECK_QT_VERSION): Use it.
author Mike Miller <mtmiller@octave.org>
date Wed, 28 Mar 2018 14:38:43 -0700
parents b6aea95a7bf9
children 1fe6002f68a7
files etc/icons/org.octave.Octave.desktop.in libgui/src/main-window.cc m4/acinclude.m4
diffstat 3 files changed, 40 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/etc/icons/org.octave.Octave.desktop.in	Wed Mar 28 17:36:40 2018 -0400
+++ b/etc/icons/org.octave.Octave.desktop.in	Wed Mar 28 14:38:43 2018 -0700
@@ -9,6 +9,6 @@
 Type=Application
 Categories=Education;Science;Math;
 StartupNotify=false
-StartupWMClass=octave-gui
+StartupWMClass=GNU Octave
 MimeType=text/x-octave;text/x-matlab;
 Keywords=science;math;matrix;numerical computation;plotting;
--- a/libgui/src/main-window.cc	Wed Mar 28 17:36:40 2018 -0400
+++ b/libgui/src/main-window.cc	Wed Mar 28 14:38:43 2018 -0700
@@ -176,6 +176,14 @@
         m_workspace_window = new workspace_view (this);
       }
 
+    // Initialize global Qt application metadata
+    QCoreApplication::setApplicationName ("GNU Octave");
+    QCoreApplication::setApplicationVersion (OCTAVE_VERSION);
+#if defined (HAVE_QGUIAPPLICATION_SETDESKTOPFILENAME)
+    if (m_start_gui)
+      QGuiApplication::setDesktopFileName ("org.octave.Octave.desktop");
+#endif
+
     m_external_editor = new external_editor_interface (this);
     m_active_editor = m_editor_window;  // for connecting signals
     if (! m_editor_window)
--- a/m4/acinclude.m4	Wed Mar 28 17:36:40 2018 -0400
+++ b/m4/acinclude.m4	Wed Mar 28 14:38:43 2018 -0700
@@ -344,6 +344,36 @@
   fi
 ])
 dnl
+dnl Check whether the Qt QGuiApplication class has the setDesktopFileName
+dnl static member function.  This function was introduced in Qt 5.7.
+dnl
+dnl FIXME: Delete this entirely when we drop support for Qt 5.6 or older.
+dnl
+AC_DEFUN([OCTAVE_CHECK_FUNC_QGUIAPPLICATION_SETDESKTOPFILENAME], [
+  AC_CACHE_CHECK([for QGuiApplication::setDesktopFileName],
+    [octave_cv_func_qguiapplication_setdesktopfilename],
+    [AC_LANG_PUSH(C++)
+    ac_octave_save_CPPFLAGS="$CPPFLAGS"
+    ac_octave_save_CXXFLAGS="$CXXFLAGS"
+    CPPFLAGS="$QT_CPPFLAGS $CXXPICFLAG $CPPFLAGS"
+    CXXFLAGS="$CXXPICFLAG $CPPFLAGS"
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+        #include <QGuiApplication>
+        ]], [[
+        QGuiApplication::setDesktopFileName ("com.example.Example.desktop");
+        ]])],
+      octave_cv_func_qguiapplication_setdesktopfilename=yes,
+      octave_cv_func_qguiapplication_setdesktopfilename=no)
+    CPPFLAGS="$ac_octave_save_CPPFLAGS"
+    CXXFLAGS="$ac_octave_save_CXXFLAGS"
+    AC_LANG_POP(C++)
+  ])
+  if test $octave_cv_func_qguiapplication_setdesktopfilename = yes; then
+    AC_DEFINE(HAVE_QGUIAPPLICATION_SETDESKTOPFILENAME, 1,
+      [Define to 1 if you have the `QGuiApplication::setDesktopFileName' member function.])
+  fi
+])
+dnl
 dnl Check whether the Qt QHeaderView class has the setSectionResizeMode
 dnl function.  This function was introduced in Qt 5.
 dnl
@@ -2026,6 +2056,7 @@
     ## tests if they fail because we have already decided that the Qt
     ## version that we are testing now will be the one used.
 
+    OCTAVE_CHECK_FUNC_QGUIAPPLICATION_SETDESKTOPFILENAME
     OCTAVE_CHECK_FUNC_QHEADERVIEW_SETSECTIONRESIZEMODE
     OCTAVE_CHECK_FUNC_QHEADERVIEW_SETSECTIONSCLICKABLE
     OCTAVE_CHECK_FUNC_QHEADERVIEW_SETSECTIONSMOVABLE