# HG changeset patch
# User Mike Miller <mtmiller@octave.org>
# Date 1504739977 25200
#      Wed Sep 06 16:19:37 2017 -0700
# Node ID a438b8ce0d775cc35fdd9be3954e677f8ea735f7
# Parent  61d45e0f7888a185e53881cc20a62928d69ad9a3
gnuplot: enable Qt terminal

* src/gnuplot.mk: Depend on qt5 and build with QT=1 QT_DIR=$(HOST_PREFIX)/qt QT_BIN_DIR=(BUILD_TOOLS_PREFIX)/bin,
  install gnuplot_qt.exe

* src/gnuplot-1-fixes.patch: add to patchto allow override of QT tools and paths

* installer-files/octave-firsttime.vbs: if have qt5 dir, set GNUTERM=qt5

* installer-files/octave.vbs: if have qt5 dir, set GNUTERM=qt5

diff -r 61d45e0f7888 -r a438b8ce0d77 installer-files/octave-firsttime.vbs
--- a/installer-files/octave-firsttime.vbs	Fri Sep 01 23:20:44 2017 -0700
+++ b/installer-files/octave-firsttime.vbs	Wed Sep 06 16:19:37 2017 -0700
@@ -32,6 +32,7 @@
 If objFSO.FolderExists(OctavePath & "\qt5\bin") Then
   wshSystemEnv("PATH") = OctavePath & "\qt5\bin;" & wshSystemEnv("PATH")
   wshSystemEnv("QT_PLUGIN_PATH") = OctavePath & "\qt5\plugins"
+  wshSystemEnv("GNUTERM") = "qt"
 Else
   wshSystemEnv("QT_PLUGIN_PATH") = OctavePath & "\plugins"
 End If
diff -r 61d45e0f7888 -r a438b8ce0d77 installer-files/octave.vbs
--- a/installer-files/octave.vbs	Fri Sep 01 23:20:44 2017 -0700
+++ b/installer-files/octave.vbs	Wed Sep 06 16:19:37 2017 -0700
@@ -32,6 +32,7 @@
 If objFSO.FolderExists(OctavePath & "\qt5\bin") Then
   wshSystemEnv("PATH") = OctavePath & "\qt5\bin;" & wshSystemEnv("PATH")
   wshSystemEnv("QT_PLUGIN_PATH") = OctavePath & "\qt5\plugins"
+  wshSystemEnv("GNUTERM") = "qt"
 Else
   wshSystemEnv("QT_PLUGIN_PATH") = OctavePath & "\plugins"
 End If
diff -r 61d45e0f7888 -r a438b8ce0d77 src/gnuplot-1-fixes.patch
--- a/src/gnuplot-1-fixes.patch	Fri Sep 01 23:20:44 2017 -0700
+++ b/src/gnuplot-1-fixes.patch	Wed Sep 06 16:19:37 2017 -0700
@@ -151,3 +151,22 @@
  #endif
  
  #ifdef HAVE_STRUCT_EXCEPTION_IN_MATH_H
+diff -ur gnuplot-5.0.7.orig/config/mingw/Makefile gnuplot-5.0.7/config/mingw/Makefile
+--- gnuplot-5.0.7.orig/config/mingw/Makefile	2017-09-07 17:47:19.588554741 -0400
++++ gnuplot-5.0.7/config/mingw/Makefile	2017-09-07 17:52:11.565785085 -0400
+@@ -468,10 +468,11 @@
+ 		moc_QtGnuplotWidget.o moc_QtGnuplotScene.o \
+ 		moc_QtGnuplotEvent.o qrc_QtGnuplotResource.o
+ #
+-	MOC = $(QT_DIR)/bin/moc
+-	UIC = $(QT_DIR)/bin/uic
+-	RCC = $(QT_DIR)/bin/rcc
+-	LRELEASE = $(QT_DIR)/bin/lrelease
++        QT_BIN_DIR ?= $(QT_DIR)/bin
++	MOC ?= $(QT_BIN_DIR)/moc
++	UIC ?= $(QT_BIN_DIR)/uic
++	RCC ?= $(QT_BIN_DIR)/rcc
++	LRELEASE ?= $(QT_BIN_DIR)/lrelease
+ 	QT_FILES_TARGETS  = qrc_QtGnuplotResource.cpp ui_QtGnuplotSettings.h moc_QtGnuplotWindow.cpp moc_QtGnuplotApplication.cpp 
+ 	QT_FILES_TARGETS += moc_QtGnuplotWidget.cpp moc_QtGnuplotScene.cpp moc_QtGnuplotEvent.cpp
+ 	QT_TRANSLATION = qtgnuplot_fr.qm qtgnuplot_ja.qm
diff -r 61d45e0f7888 -r a438b8ce0d77 src/gnuplot.mk
--- a/src/gnuplot.mk	Fri Sep 01 23:20:44 2017 -0700
+++ b/src/gnuplot.mk	Wed Sep 06 16:19:37 2017 -0700
@@ -18,10 +18,10 @@
     $(PKG)_EXTRAFLAGS += WXT=1 WX_CONFIG=$(MXE_TOOL_PREFIX)wx-config
 endif
 
-#ifeq ($(ENABLE_QT5),yes)
-#  $(PKG)_DEPS     += qt5
-#  $(PKG)_EXTRAFLAGS += QT=1 QT_DIR=$(HOST_PREFIX)/qt5
-#endif
+ifeq ($(ENABLE_QT5),yes)
+  $(PKG)_DEPS     += qt5
+  $(PKG)_EXTRAFLAGS += QT=1 QT_DIR="$(HOST_PREFIX)/qt5" QT_BIN_DIR="$(BUILD_TOOLS_PREFIX)/bin"
+endif
 
 ifeq ($(MXE_NATIVE_MINGW_BUILD),yes)
     $(PKG)_EXTRAFLAGS += ICONV_CFLAGS='-I$(HOST_INCDIR)' ICONV_LDFLAGS='-L$(HOST_LIBDIR)'
@@ -42,6 +42,11 @@
     $(INSTALL) -m755 '$(1)/config/mingw/wgnuplot.exe' '$(3)$(HOST_BINDIR)'
     $(INSTALL) -m644 '$(1)/src/win/wgnuplot.mnu' '$(3)$(HOST_BINDIR)'
 
+    if [ "$(ENABLE_QT5)" == "yes" ]; then \
+      make -C '$(1)/config/mingw' $($(PKG)_EXTRAFLAGS) CC='$(MXE_CC)' CXX='$(MXE_CXX) -std=gnu++11' RC='$(MXE_WINDRES)' -j '$(JOBS)' TARGET=gnuplot_qt.exe gnuplot_qt.exe; \
+      $(INSTALL) -m755 '$(1)/config/mingw/gnuplot_qt.exe' '$(3)$(HOST_BINDIR)'; \
+    fi
+
     # config files
     $(INSTALL) -d '$(3)$(HOST_PREFIX)/share'
     $(INSTALL) -m644 '$(1)/share/gnuplotrc' '$(3)$(HOST_PREFIX)/share/'
