aboutsummaryrefslogtreecommitdiff
path: root/academic/octave/patches/0348f3f57e3c.diff
blob: 1545797a6150d9b26b1de04b5588847d8237c63c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170

# HG changeset patch
# User John W. Eaton <jwe@octave.org>
# Date 1609785454 18000
# Node ID 0348f3f57e3ca6fa7c8e5112622c756d00dd7dab
# Parent  a3d92c4ad5502686daf2b34f062db6c950db30ef
avoid build errors with Qt4 (bug #59813)

* acinclude.m4 (OCTAVE_CHECK_FUNC_QFONTDATABASE_SYSTEMFONT,
OCTAVE_CHECK_QVARIANT_CANCONVERT_ACCEPTS_QMETATYPE_TYPE): New macros.
(OCTAVE_CHECK_QT_VERSION): Use them.

* resource-manager.cc (resource_manager::get_default_font_family):
Check availability of QFontDatabase::systemFont, fall back on
QFont::setStyleHint, then global_font_family.

* octave-dock-widget.cc (octave_dock_widget::handle_settings):
Check whether QVariant::canConvert accepts QMetatype::Type.  Use
QVariant::Type as fallback.
* variable-editor-model.cc (variable_editor_model::setData): Likewise.

diff --git a/libgui/src/octave-dock-widget.cc b/libgui/src/octave-dock-widget.cc
--- a/libgui/src/octave-dock-widget.cc
+++ b/libgui/src/octave-dock-widget.cc
@@ -507,7 +507,12 @@
     QVariant dock_geom
       = settings->value (dw_dock_geometry.key.arg (objectName ()),
                          default_dock_size);
-    if (dock_geom.canConvert (QMetaType::QRect))
+#if defined (QVARIANT_CANCONVERT_ACCEPTS_QMETATYPE_TYPE)
+    QMetaType::Type rect_type = QMetaType::QRect;
+#else
+    QVariant::Type rect_type = QVariant::Rect;
+#endif
+    if (dock_geom.canConvert (rect_type))
       m_recent_dock_geom = dock_geom.toRect ();
     else
       m_recent_dock_geom = dw_dock_geometry.def.toRect ();
diff --git a/libgui/src/resource-manager.cc b/libgui/src/resource-manager.cc
--- a/libgui/src/resource-manager.cc
+++ b/libgui/src/resource-manager.cc
@@ -241,9 +241,17 @@
   // if macOS default font is not available): use QFontDatabase
   if (default_family.isEmpty ())
     {
+#if defined (HAVE_QFONTDATABASE_SYSTEMFONT)
       // Get the system's default monospaced font
       QFont fixed_font = QFontDatabase::systemFont (QFontDatabase::FixedFont);
       default_family = fixed_font.defaultFamily ();
+#elif defined (HAVE_QFONT_MONOSPACE)
+      QFont fixed_font;
+      fixed_font.setStyleHint (QFont::Monospace);
+      default_family = fixed_font.defaultFamily ();
+#else
+      default_family = global_font_family;
+#endif
     }
 
     // Test env variable which has preference
diff --git a/libgui/src/variable-editor-model.cc b/libgui/src/variable-editor-model.cc
--- a/libgui/src/variable-editor-model.cc
+++ b/libgui/src/variable-editor-model.cc
@@ -987,7 +987,12 @@
   variable_editor_model::setData (const QModelIndex& idx,
                                   const QVariant& v_user_input, int role)
   {
-    if (role != Qt::EditRole || ! v_user_input.canConvert (QVariant::String)
+#if defined (QVARIANT_CANCONVERT_ACCEPTS_QMETATYPE_TYPE)
+    QMetaType::Type string_type = QMetaType::QString;
+#else
+    QVariant::Type string_type = QVariant::String;
+#endif
+    if (role != Qt::EditRole || ! v_user_input.canConvert (string_type)
         || ! idx.isValid ())
       return false;
 
diff --git a/m4/acinclude.m4 b/m4/acinclude.m4
--- a/m4/acinclude.m4
+++ b/m4/acinclude.m4
@@ -1091,6 +1091,35 @@
   fi
 ])
 dnl
+dnl Check whether the Qt class QFontDatabase has the systemFont member
+dnl function.  This function was introduced in Qt 5.2.
+dnl
+AC_DEFUN([OCTAVE_CHECK_FUNC_QFONTDATABASE_SYSTEMFONT], [
+  AC_CACHE_CHECK([for QFontDatabase::systemFont function],
+    [octave_cv_func_qfontdatabase_systemfont],
+    [AC_LANG_PUSH(C++)
+    ac_octave_save_CPPFLAGS="$CPPFLAGS"
+    ac_octave_save_CXXFLAGS="$CXXFLAGS"
+    CPPFLAGS="$QT_CPPFLAGS $CXXPICFLAG $CPPFLAGS"
+    CXXFLAGS="$CXXPICFLAG $CXXFLAGS"
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+        #include <QFontDatabase>
+        #include <QFont>
+        ]], [[
+        QFont font = QFontDatabase::systemFont (QFontDatabase::FixedFont);
+        ]])],
+      octave_cv_func_qfontdatabase_systemfont=yes,
+      octave_cv_func_qfontdatabase_systemfont=no)
+    CPPFLAGS="$ac_octave_save_CPPFLAGS"
+    CXXFLAGS="$ac_octave_save_CXXFLAGS"
+    AC_LANG_POP(C++)
+  ])
+  if test $octave_cv_func_qfontdatabase_systemfont = yes; then
+    AC_DEFINE(HAVE_QFONTDATABASE_SYSTEMFONT, 1,
+      [Define to 1 if you have the `QFontDatabase::systemFont' function.])
+  fi
+])
+dnl
 dnl Check whether the Qt class QList has a constructor that accepts
 dnl a pair of iterators.  This constructor was introduced in Qt 5.14.
 dnl
@@ -1967,6 +1996,37 @@
   fi
 ])
 dnl
+dnl Check whether QVariant::canConvert accepts a QMetaType::Type
+dnl enumeration value as an argument.
+dnl
+AC_DEFUN([OCTAVE_CHECK_QVARIANT_CANCONVERT_ACCEPTS_QMETATYPE_TYPE], [
+  AC_CACHE_CHECK([whether QVariant::canConvert accepts QMetaType::Type argument],
+    [octave_cv_qvariant_canconvert_accepts_qmetatype_type],
+    [AC_LANG_PUSH(C++)
+    ac_octave_save_CPPFLAGS="$CPPFLAGS"
+    ac_octave_save_CXXFLAGS="$CXXFLAGS"
+    CPPFLAGS="$QT_CPPFLAGS $CXXPICFLAG $CPPFLAGS"
+    CXXFLAGS="$CXXPICFLAG $CXXFLAGS"
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+        #include <QMetaType>
+        #include <QVariant>
+        ]], [[
+        QVariant var;
+        QMetaType::Type type = QMetaType::QString;
+        var.canConvert (type);
+        ]])],
+      octave_cv_qvariant_canconvert_accepts_qmetatype_type=yes,
+      octave_cv_qvariant_canconvert_accepts_qmetatype_type=no)
+    CPPFLAGS="$ac_octave_save_CPPFLAGS"
+    CXXFLAGS="$ac_octave_save_CXXFLAGS"
+    AC_LANG_POP(C++)
+  ])
+  if test $octave_cv_qvariant_canconvert_accepts_qmetatype_type = yes; then
+    AC_DEFINE(QVARIANT_CANCONVERT_ACCEPTS_QMETATYPE_TYPE, 1,
+      [Define to 1 if `QVariant::canConvert' accepts `QMetaType::Type' enumeration value as argument.])
+  fi
+])
+dnl
 dnl Check for the Qhull version.
 dnl
 AC_DEFUN([OCTAVE_CHECK_QHULL_VERSION], [
@@ -2518,6 +2578,7 @@
     ## version that we are testing now will be the one used.
 
     OCTAVE_CHECK_FUNC_QCOMBOBOX_SETCURRENTTEXT
+    OCTAVE_CHECK_FUNC_QFONTDATABASE_SYSTEMFONT
     OCTAVE_CHECK_FUNC_QFONTMETRICS_HORIZONTAL_ADVANCE
     OCTAVE_CHECK_FUNC_QGUIAPPLICATION_SETDESKTOPFILENAME
     OCTAVE_CHECK_FUNC_QHEADERVIEW_SETSECTIONRESIZEMODE
@@ -2539,6 +2600,7 @@
     OCTAVE_CHECK_FUNC_QWHEELEVENT_POSITION
     OCTAVE_CHECK_MEMBER_QFONT_FORCE_INTEGER_METRICS
     OCTAVE_CHECK_MEMBER_QFONT_MONOSPACE
+    OCTAVE_CHECK_QVARIANT_CANCONVERT_ACCEPTS_QMETATYPE_TYPE
     OCTAVE_HAVE_QGUIAPPLICATION
 
     OCTAVE_CHECK_QREGION_ITERATORS