# HG changeset patch # User John W. Eaton # Date 1357154990 18000 # Node ID 7d300b85ee255f31fe8ba059ec922f02266a711a # Parent 1733bd181cb6e47fe8da91cdaf10dcf8e5fa7669 allow build to proceed if either Qt or QScintilla is missing * configure.ac: Instead of aborting the configure script, set build_gui to "no" if Qt is missing. Don't abort configure script if QScintilla is missing. If QScintilla is available, define HAVE_QSCINTILLA. * file-editor-tab.cc, file-editor.cc, find-dialog.cc, lexer-octave-gui.cc: Surround file contents with #ifdef HAVE_QSCINTILLA. * main-window.cc (main_window::~main_window): Skip deletion of _file_editor if HAVE_QSCINTILLA is not defined. (main_window::new_file, main_window::open_file, main_window::focus_editor): Do nothing if HAVE_QSCINTILLA is not defined. (main_window::handle_entered_debug_mode, main_window::handle_quit_debug_mode): Skip operation on _file_editor if HAVE_QSCINTILLA is not defined. (main_window::construct): Skip creation of _file_editor and operations on it if HAVE_QSCINTILLA is not defined. * main-window.h (main_window::_file_editor): Omit data member from class if HAVE_QSCINTILLA is not defined. diff -r 1733bd181cb6 -r 7d300b85ee25 configure.ac --- a/configure.ac Wed Jan 02 11:31:44 2013 -0500 +++ b/configure.ac Wed Jan 02 14:29:50 2013 -0500 @@ -2501,93 +2501,112 @@ QT_LDFLAGS= QT_LIBS= win32_terminal=no -build_gui=true +build_gui=yes GUIDIR=libgui AC_ARG_ENABLE([gui], [AS_HELP_STRING([--disable-gui], [don't build the GUI])], - [if test "$enableval" = no; then build_gui=false; fi], []) - -if test $build_gui = true; then + [if test "$enableval" = no; then build_gui=no; fi], []) + +if test $build_gui = yes; then ## Check for Qt libraries PKG_CHECK_MODULES(QT, [QtCore, QtGui, QtNetwork], [], - [AC_MSG_ERROR([Qt libraries are required to build the GUI])]) - - ## Retrieve Qt compilation and linker flags - QT_CPPFLAGS="`$PKG_CONFIG --cflags-only-I QtCore QtGui QtNetwork`" - QT_LDFLAGS="`$PKG_CONFIG --libs-only-L QtCore QtGui QtNetwork`" - QT_LIBS="`$PKG_CONFIG --libs-only-l QtCore QtGui QtNetwork`" - - ## Check for Qt4 - if ! `$PKG_CONFIG --atleast-version=4.0.0 QtCore`; then - AC_MSG_ERROR([Qt >= 4.0.0 is required to build the GUI]) + [AC_MSG_WARN([Qt libraries not found -- disabling GUI]) + build_gui=no]) + + if test $build_gui = yes; then + ## Retrieve Qt compilation and linker flags + QT_CPPFLAGS="`$PKG_CONFIG --cflags-only-I QtCore QtGui QtNetwork`" + QT_LDFLAGS="`$PKG_CONFIG --libs-only-L QtCore QtGui QtNetwork`" + QT_LIBS="`$PKG_CONFIG --libs-only-l QtCore QtGui QtNetwork`" + + ## Check for Qt4 + if ! `$PKG_CONFIG --atleast-version=4.0.0 QtCore`; then + AC_MSG_WARN([Qt >= 4.0.0 not found -- disabling GUI]) + build_gui=no + fi + fi + + if test $build_gui = yes; then + AC_CHECK_PROGS(MOC, [moc-qt5 moc-qt4 moc]) + AC_CHECK_PROGS(UIC, [uic-qt5 uic-qt4 uic]) + AC_CHECK_PROGS(RCC, [rcc]) + if test -n "$MOC" && test -n "$UIC" && test -n "$RCC"; then + AC_DEFINE(HAVE_QT, 1, + [Define to 1 if Qt is available (libraries, developer header files, utility programs (moc, uic, and rcc))]) + else + AC_MSG_WARN([Qt utility programs moc, uic, and rcc not found -- disabling GUI]) + build_gui=no + fi + fi + + if test $build_gui = yes; then + OCTAVE_CHECK_FUNC_SETPLACEHOLDERTEXT fi - AC_CHECK_PROGS(MOC, [moc-qt5 moc-qt4 moc]) - AC_CHECK_PROGS(UIC, [uic-qt5 uic-qt4 uic]) - AC_CHECK_PROGS(RCC, [rcc]) - if test -z "$MOC" || test -z "$UIC" || test -z "$RCC"; then - AC_MSG_ERROR([Qt utility programs moc, uic, and rcc are required to build the GUI]) - fi - - AC_DEFINE(HAVE_QT, 1, - [Define to 1 if Qt is available (libraries, developer header files, utility programs (moc, uic, and rcc))]) - - ## Check for Qscintilla library which is used in the GUI editor. - AC_CACHE_CHECK([whether Qscintilla library is installed], - [octave_cv_lib_qscintilla], - [save_CPPFLAGS="$CPPFLAGS" - save_LDFLAGS="$LDFLAGS" - save_LIBS="$LIBS" - CPPFLAGS="$QT_CPPFLAGS $CPPFLAGS" - LDFLAGS="$QT_LDFLAGS $LDFLAGS" - LIBS="$QT_LIBS -lqscintilla2" - AC_LANG_PUSH(C++) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[ - #include - ]], [[ - QsciLexerSQL sqlLexer(0); - ]])], - octave_cv_lib_qscintilla=yes, - octave_cv_lib_qscintilla=no) - CPPFLAGS="$save_CPPFLAGS" - LDFLAGS="$save_LDFLAGS" - LIBS="$save_LIBS" - AC_LANG_POP([C++]) - ]) - if test $octave_cv_lib_qscintilla = no; then - AC_MSG_ERROR([Qscintilla library is required to build the GUI]) + if test $build_gui = yes; then + ## Check for Qscintilla library which is used in the GUI editor. + AC_CACHE_CHECK([whether Qscintilla library is installed], + [octave_cv_lib_qscintilla], + [save_CPPFLAGS="$CPPFLAGS" + save_LDFLAGS="$LDFLAGS" + save_LIBS="$LIBS" + CPPFLAGS="$QT_CPPFLAGS $CPPFLAGS" + LDFLAGS="$QT_LDFLAGS $LDFLAGS" + LIBS="$QT_LIBS -lqscintilla2" + AC_LANG_PUSH(C++) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + #include + ]], [[ + QsciLexerSQL sqlLexer(0); + ]])], + octave_cv_lib_qscintilla=yes, + octave_cv_lib_qscintilla=no) + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" + AC_LANG_POP([C++]) + ]) + if test $octave_cv_lib_qscintilla = no; then + AC_MSG_WARN([Qscintilla library not found -- disabling built-in GUI editor]) + else + ## Let's assume Qscintilla library is at the same location as + ## other regular Qt libraries. + QT_LIBS="$QT_LIBS -lqscintilla2" + OCTAVE_CHECK_FUNC_FINDFIRST_MODERN + AC_DEFINE(HAVE_QSCINTILLA, 1, + [Define to 1 if the QScintilla library and header files are available]) + fi + + AC_CHECK_FUNCS([setlocale], [], + [AC_MSG_WARN([setlocale not found -- disabling GUI]) + build_gui=no]) + + if test $build_gui = yes; then + case $host_os in + mingw* | msdosmsvc*) + AC_CHECK_FUNCS([setvbuf], [win32_terminal=yes], + [AC_MSG_WARN([setvbuf not found -- disabling GUI]) + build_gui=no]) + ;; + *) + AC_CHECK_HEADERS([pty.h libutil.h util.h]) + AC_SEARCH_LIBS([openpty], [util], + [AC_DEFINE(HAVE_OPENPTY, [], [Define whether openpty exists])]) + AC_CHECK_FUNCS([chmod chown ftruncate mmap munmap], [], + [AC_MSG_ERROR([At least one of chmod, chown, ftruncate, mmap, and munmap not found -- disabling GUI]) + build_gui=no]) + ;; + esac + fi fi - ## Let's assume Qscintilla library is at the same location as - ## other regular Qt libraries. - QT_LIBS="$QT_LIBS -lqscintilla2" - - ## Check for Qt functions which have changed their API over time - OCTAVE_CHECK_FUNC_FINDFIRST_MODERN - OCTAVE_CHECK_FUNC_SETPLACEHOLDERTEXT - - AC_CHECK_FUNCS([setlocale], [], - [AC_MSG_ERROR([Missing function required to build GUI])]) - - case $host_os in - mingw* | msdosmsvc) - win32_terminal=yes - AC_CHECK_FUNCS([setvbuf], [], - [AC_MSG_ERROR([Missing function required to build GUI])]) - ;; - *) - AC_CHECK_HEADERS([pty.h libutil.h util.h]) - AC_SEARCH_LIBS([openpty], [util], - [AC_DEFINE(HAVE_OPENPTY, [], [Define whether openpty exists])]) - AC_CHECK_FUNCS([chmod chown ftruncate mmap munmap], [], - [AC_MSG_ERROR([Missing function required to build GUI])]) - ;; - esac -else +fi + +if test $build_gui = no; then ## GUI disabled. Eliminate building GUIDIR directory GUIDIR= fi -AM_CONDITIONAL([AMCOND_BUILD_GUI], [test $build_gui = true]) +AM_CONDITIONAL([AMCOND_BUILD_GUI], [test $build_gui = yes]) AM_CONDITIONAL([WIN32_TERMINAL], [test $win32_terminal = yes]) AC_SUBST(QT_CPPFLAGS) AC_SUBST(QT_LDFLAGS) diff -r 1733bd181cb6 -r 7d300b85ee25 libgui/src/m-editor/file-editor-tab.cc --- a/libgui/src/m-editor/file-editor-tab.cc Wed Jan 02 11:31:44 2013 -0500 +++ b/libgui/src/m-editor/file-editor-tab.cc Wed Jan 02 14:29:50 2013 -0500 @@ -24,6 +24,8 @@ #include #endif +#ifdef HAVE_QSCINTILLA + #include // Not available in the Debian repos yet! // #include @@ -1096,3 +1098,5 @@ _edit_area->markerAdd (line, debugger_position); } } + +#endif diff -r 1733bd181cb6 -r 7d300b85ee25 libgui/src/m-editor/file-editor.cc --- a/libgui/src/m-editor/file-editor.cc Wed Jan 02 11:31:44 2013 -0500 +++ b/libgui/src/m-editor/file-editor.cc Wed Jan 02 14:29:50 2013 -0500 @@ -24,6 +24,8 @@ #include #endif +#ifdef HAVE_QSCINTILLA + #include "file-editor.h" #include "resource-manager.h" #include @@ -817,3 +819,5 @@ _tab_widget->setCurrentWidget (f); } + +#endif diff -r 1733bd181cb6 -r 7d300b85ee25 libgui/src/m-editor/find-dialog.cc --- a/libgui/src/m-editor/find-dialog.cc Wed Jan 02 11:31:44 2013 -0500 +++ b/libgui/src/m-editor/find-dialog.cc Wed Jan 02 14:29:50 2013 -0500 @@ -43,6 +43,8 @@ #include #endif +#ifdef HAVE_QSCINTILLA + #include #include #include "find-dialog.h" @@ -199,3 +201,5 @@ } // TODO: Show number of replaced strings } + +#endif diff -r 1733bd181cb6 -r 7d300b85ee25 libgui/src/m-editor/lexer-octave-gui.cc --- a/libgui/src/m-editor/lexer-octave-gui.cc Wed Jan 02 11:31:44 2013 -0500 +++ b/libgui/src/m-editor/lexer-octave-gui.cc Wed Jan 02 14:29:50 2013 -0500 @@ -24,6 +24,8 @@ #include #endif +#ifdef HAVE_QSCINTILLA + #include "lexer-octave-gui.h" #include #include @@ -175,3 +177,4 @@ return 0; } +#endif diff -r 1733bd181cb6 -r 7d300b85ee25 libgui/src/main-window.cc --- a/libgui/src/main-window.cc Wed Jan 02 11:31:44 2013 -0500 +++ b/libgui/src/main-window.cc Wed Jan 02 14:29:50 2013 -0500 @@ -68,8 +68,10 @@ if (_octave_qt_event_listener) delete _octave_qt_event_listener; +#ifdef HAVE_QSCINTILLA if (_file_editor) delete _file_editor; +#endif if (_terminal_dock_widget) delete _terminal_dock_widget; @@ -96,22 +98,28 @@ void main_window::new_file () { +#ifdef HAVE_QSCINTILLA _file_editor->request_new_file (); focus_editor (); +#endif } void main_window::open_file () { +#ifdef HAVE_QSCINTILLA _file_editor->request_open_file (); focus_editor (); +#endif } void main_window::open_file (const QString& file_name) { +#ifdef HAVE_QSCINTILLA _file_editor->request_open_file (file_name); focus_editor (); +#endif } void @@ -362,6 +370,7 @@ void main_window::focus_editor () { +#ifdef HAVE_QSCINTILLA if (!_file_editor->isVisible ()) { _file_editor->setVisible (true); @@ -370,6 +379,7 @@ _file_editor->setFocus (); _file_editor->activateWindow (); _file_editor->raise (); +#endif } void @@ -394,7 +404,9 @@ _debug_step_over->setEnabled (true); _debug_step_out->setEnabled (true); _debug_quit->setEnabled (true); +#ifdef HAVE_QSCINTILLA _file_editor->handle_entered_debug_mode (); +#endif } void @@ -406,7 +418,9 @@ _debug_step_over->setEnabled (false); _debug_step_out->setEnabled (false); _debug_quit->setEnabled (false); +#ifdef HAVE_QSCINTILLA _file_editor->handle_quit_debug_mode (); +#endif } void @@ -576,7 +590,9 @@ dummyWidget->hide (); setCentralWidget (dummyWidget); +#ifdef HAVE_QSCINTILLA _file_editor = new file_editor (this); +#endif QMenu *file_menu = menuBar ()->addMenu (tr ("&File")); @@ -698,35 +714,47 @@ _debug_step_over = _debug_menu->addAction (QIcon (":/actions/icons/db_step.png"), tr ("Step")); _debug_step_over->setEnabled (false); +#ifdef HAVE_QSCINTILLA _file_editor->debug_menu ()->addAction (_debug_step_over); _file_editor->toolbar ()->addAction (_debug_step_over); +#endif _debug_step_over->setShortcut (Qt::Key_F10); _debug_step_into = _debug_menu->addAction (QIcon (":/actions/icons/db_step_in.png"), tr ("Step in")); _debug_step_into->setEnabled (false); +#ifdef HAVE_QSCINTILLA _file_editor->debug_menu ()->addAction (_debug_step_into); _file_editor->toolbar ()->addAction (_debug_step_into); +#endif _debug_step_into->setShortcut (Qt::Key_F11); _debug_step_out = _debug_menu->addAction (QIcon (":/actions/icons/db_step_out.png"), tr ("Step out")); _debug_step_out->setEnabled (false); +#ifdef HAVE_QSCINTILLA _file_editor->debug_menu ()->addAction (_debug_step_out); _file_editor->toolbar ()->addAction (_debug_step_out); +#endif _debug_step_out->setShortcut (Qt::ShiftModifier + Qt::Key_F11); _debug_continue = _debug_menu->addAction (QIcon (":/actions/icons/db_cont.png"), tr ("Continue")); _debug_continue->setEnabled (false); +#ifdef HAVE_QSCINTILLA _file_editor->debug_menu ()->addAction (_debug_continue); _file_editor->toolbar ()->addAction (_debug_continue); +#endif _debug_continue->setShortcut (Qt::Key_F5); _debug_menu->addSeparator (); +#ifdef HAVE_QSCINTILLA _file_editor->debug_menu ()->addSeparator (); +#endif _debug_quit = _debug_menu->addAction (QIcon (":/actions/icons/db_stop.png"), tr ("Exit Debug Mode")); _debug_quit->setEnabled (false); +#ifdef HAVE_QSCINTILLA _file_editor->debug_menu ()->addAction (_debug_quit); _file_editor->toolbar ()->addAction (_debug_quit); +#endif _debug_quit->setShortcut (Qt::ShiftModifier + Qt::Key_F5); //QMenu *parallelMenu = menuBar ()->addMenu (tr ("&Parallel")); @@ -866,10 +894,12 @@ _files_dock_widget, SLOT (setVisible (bool))); connect (_files_dock_widget, SIGNAL (active_changed (bool)), show_file_browser_action, SLOT (setChecked (bool))); +#ifdef HAVE_QSCINTILLA connect (show_editor_action, SIGNAL (toggled (bool)), _file_editor, SLOT (setVisible (bool))); connect (_file_editor, SIGNAL (active_changed (bool)), show_editor_action, SLOT (setChecked (bool))); +#endif connect (show_documentation_action, SIGNAL (toggled (bool)), _documentation_dock_widget, SLOT (setVisible (bool))); connect (_documentation_dock_widget, SIGNAL (active_changed (bool)), @@ -890,8 +920,10 @@ connect (reset_windows_action, SIGNAL (triggered ()), this, SLOT (reset_windows ())); +#ifdef HAVE_QSCINTILLA connect (this, SIGNAL (settings_changed ()), _file_editor, SLOT (notice_settings ())); +#endif connect (this, SIGNAL (settings_changed ()), _files_dock_widget, SLOT (notice_settings ())); connect (this, SIGNAL (settings_changed ()), @@ -941,7 +973,9 @@ addDockWidget (Qt::LeftDockWidgetArea, _workspace_view); addDockWidget (Qt::LeftDockWidgetArea, _history_dock_widget); addDockWidget (Qt::RightDockWidgetArea, _files_dock_widget); +#ifdef HAVE_QSCINTILLA addDockWidget (Qt::RightDockWidgetArea, _file_editor); +#endif addDockWidget (Qt::BottomDockWidgetArea, _terminal_dock_widget); addDockWidget (Qt::RightDockWidgetArea, _documentation_dock_widget); setStatusBar (_status_bar); diff -r 1733bd181cb6 -r 7d300b85ee25 libgui/src/main-window.h --- a/libgui/src/main-window.h Wed Jan 02 11:31:44 2013 -0500 +++ b/libgui/src/main-window.h Wed Jan 02 14:29:50 2013 -0500 @@ -148,7 +148,9 @@ void exit_callback (void); QTerminal * _terminal; +#ifdef HAVE_QSCINTILLA file_editor_interface * _file_editor; +#endif QMenu * _debug_menu; QAction * _debug_continue;