# HG changeset patch # User Rik # Date 1398354090 25200 # Node ID 78fac67300e86817e46e296a23739313dce28072 # Parent cf3db95a75f0a99f973cfb26e35282e9ba0b3802# Parent 8b566ad1f88afeefdebf80232c01e4593bff9450 maint: Periodic merge of gui-release to default. diff -r cf3db95a75f0 -r 78fac67300e8 libgui/qterminal/libqterminal/unix/TerminalView.cpp --- a/libgui/qterminal/libqterminal/unix/TerminalView.cpp Thu Apr 24 07:13:37 2014 -0700 +++ b/libgui/qterminal/libqterminal/unix/TerminalView.cpp Thu Apr 24 08:41:30 2014 -0700 @@ -212,6 +212,9 @@ // Disabling kerning saves some computation when rendering text. // font.setKerning(false); + font.setStyleStrategy ( QFont::StyleStrategy(font.styleStrategy() + | QFont::ForceIntegerMetrics) ); + QWidget::setFont(font); fontChange(font); } @@ -2620,6 +2623,17 @@ // KUrl::List urls = KUrl::List::fromMimeData(event->mimeData()); QString dropText; + + if (event->mimeData ()->hasUrls ()) + { + foreach (QUrl url, event->mimeData ()->urls ()) + { + if(dropText.length () > 0) + dropText += "\n"; + dropText += url.toLocalFile (); + } + } + /* if (!urls.isEmpty()) { for ( int i = 0 ; i < urls.count() ; i++ ) diff -r cf3db95a75f0 -r 78fac67300e8 libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp --- a/libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp Thu Apr 24 07:13:37 2014 -0700 +++ b/libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp Thu Apr 24 08:41:30 2014 -0700 @@ -35,6 +35,9 @@ #include #include #include +#include +#include +#include #include #include @@ -184,6 +187,8 @@ void sendConsoleText (const QString& s); QRect cursorRect (void); void selectAll(); + void selectWord(const QPoint& cellPos); + void selectLine(const QPoint& cellPos); void log (const char* fmt, ...); @@ -675,6 +680,67 @@ updateSelection(); } +void QConsolePrivate::selectWord (const QPoint & cellpos) +{ + QPoint begin = cellpos; + QPoint end = cellpos; + + int scrollOffset = m_consoleRect.top (); + int stride = m_consoleRect.width (); + + // get begin, end in buffer offsets + begin.ry () -= scrollOffset; + end.ry () -= scrollOffset; + + // loog at current clicked on char to determinate ig getting space chunk or nonspace chunk + if (QChar(m_buffer[begin.y ()*stride + begin.x ()].Char.UnicodeChar).isSpace () == false) + { + // from current char, go back and fwd to find start and end of block + while(begin.x () > 0 && + QChar(m_buffer[begin.y ()*stride + begin.x () -1].Char.UnicodeChar).isSpace() == false) + { + begin.rx () --; + } + + while(end.x () < m_consoleRect.width () && + QChar(m_buffer[end.y ()*stride + end.x () +1].Char.UnicodeChar).isSpace() == false) + { + end.rx () ++; + } + } + else + { + while(begin.x () > 0 && + QChar(m_buffer[begin.y ()*stride + begin.x () -1].Char.UnicodeChar).isSpace()) + { + begin.rx () --; + } + + while(end.x () < m_consoleRect.width () && + QChar(m_buffer[end.y ()*stride + end.x () +1].Char.UnicodeChar).isSpace ()) + { + end.rx () ++; + } + } + + // convert console offsets to absolute cell positions + begin.ry () += scrollOffset; + end.ry () += scrollOffset; + + m_beginSelection = begin; + m_endSelection = end; + + updateSelection (); +} + +void QConsolePrivate::selectLine (const QPoint & cellpos) +{ + m_beginSelection = QPoint (0, cellpos.y ()); + m_endSelection = QPoint (m_bufferSize.width ()-1, cellpos.y ()); + updateSelection (); +} + + void QConsolePrivate::drawSelection (QPainter& p, int cx1, int cy1, int cx2, int cy2, int cw, int ch) { @@ -1259,12 +1325,15 @@ ////////////////////////////////////////////////////////////////////////////// QWinTerminalImpl::QWinTerminalImpl (QWidget* parent) - : QTerminal (parent), d (new QConsolePrivate (this)) + : QTerminal (parent), d (new QConsolePrivate (this)), + allowTripleClick (false) { installEventFilter (this); connect (this, SIGNAL (set_global_shortcuts_signal (bool)), parent, SLOT (set_global_shortcuts (bool))); + + setAcceptDrops (true); } ////////////////////////////////////////////////////////////////////////////// @@ -1293,7 +1362,11 @@ void QWinTerminalImpl::mousePressEvent (QMouseEvent *event) { - if (event->button () == Qt::LeftButton) + if (allowTripleClick) + { + mouseTripleClickEvent (event); + } + else if (event->button () == Qt::LeftButton) { d->m_settingSelection = true; @@ -1303,7 +1376,7 @@ void QWinTerminalImpl::mouseReleaseEvent (QMouseEvent *event) { - if (event->button () == Qt::LeftButton) + if (event->button () == Qt::LeftButton && d->m_settingSelection) { d->m_endSelection = d->posToCell (event->pos ()); @@ -1313,6 +1386,36 @@ } } +void QWinTerminalImpl::mouseDoubleClickEvent (QMouseEvent *event) +{ + if (event->button () == Qt::LeftButton) + { + // doubleclick - select word + d->m_settingSelection = false; + + d->selectWord (d->posToCell (event->pos ())); + + allowTripleClick = true; + + QTimer::singleShot (QApplication::doubleClickInterval (),this, + SLOT (tripleClickTimeout ())); + + } +} + +void QWinTerminalImpl::mouseTripleClickEvent (QMouseEvent *event) +{ + if (event->button () == Qt::LeftButton) + { + d->selectLine (d->posToCell (event->pos ())); + } +} + +void QWinTerminalImpl::tripleClickTimeout () +{ + allowTripleClick = false; +} + ////////////////////////////////////////////////////////////////////////////// void QWinTerminalImpl::viewResizeEvent (QConsoleView*, QResizeEvent*) @@ -1595,3 +1698,32 @@ QString selection = d->getSelection (); return selection; } + +////////////////////////////////////////////////////////////////////////////// + +void QWinTerminalImpl::dragEnterEvent (QDragEnterEvent *event) +{ + if (event->mimeData ()->hasUrls ()) + { + event->acceptProposedAction(); + } +} + +////////////////////////////////////////////////////////////////////////////// + +void QWinTerminalImpl::dropEvent (QDropEvent *event) +{ + QString dropText; + + if (event->mimeData ()->hasUrls ()) + { + foreach (QUrl url, event->mimeData ()->urls ()) + { + if(dropText.length () > 0) + dropText += "\n"; + dropText += url.toLocalFile (); + } + sendText (dropText); + } +} + diff -r cf3db95a75f0 -r 78fac67300e8 libgui/qterminal/libqterminal/win32/QWinTerminalImpl.h --- a/libgui/qterminal/libqterminal/win32/QWinTerminalImpl.h Thu Apr 24 07:13:37 2014 -0700 +++ b/libgui/qterminal/libqterminal/win32/QWinTerminalImpl.h Thu Apr 24 08:41:30 2014 -0700 @@ -32,6 +32,8 @@ class QResizeEvent; class QWheelEvent; class QPoint; +class QDragEnterEvent; +class QDropEvent; class QConsolePrivate; class QConsoleThread; @@ -88,16 +90,23 @@ void mouseMoveEvent (QMouseEvent *event); void mousePressEvent (QMouseEvent *event); void mouseReleaseEvent (QMouseEvent *event); + void mouseDoubleClickEvent (QMouseEvent* event); + void mouseTripleClickEvent (QMouseEvent* event); bool eventFilter(QObject *obj, QEvent *ev); + void dragEnterEvent(QDragEnterEvent *event); + void dropEvent(QDropEvent *event); + private slots: void scrollValueChanged (int value); void monitorConsole (void); void updateSelection (void); + void tripleClickTimeout (void); private: QConsolePrivate* d; + bool allowTripleClick; }; ////////////////////////////////////////////////////////////////////////////// diff -r cf3db95a75f0 -r 78fac67300e8 libgui/src/m-editor/file-editor-interface.h --- a/libgui/src/m-editor/file-editor-interface.h Thu Apr 24 07:13:37 2014 -0700 +++ b/libgui/src/m-editor/file-editor-interface.h Thu Apr 24 08:41:30 2014 -0700 @@ -44,6 +44,7 @@ virtual QMenu *debug_menu () = 0; virtual QToolBar *toolbar () = 0; + virtual void insert_new_open_actions (QAction*,QAction*,QAction*) = 0; virtual void handle_enter_debug_mode (void) = 0; virtual void handle_exit_debug_mode (void) = 0; diff -r cf3db95a75f0 -r 78fac67300e8 libgui/src/m-editor/file-editor-tab.cc --- a/libgui/src/m-editor/file-editor-tab.cc Thu Apr 24 07:13:37 2014 -0700 +++ b/libgui/src/m-editor/file-editor-tab.cc Thu Apr 24 08:41:30 2014 -0700 @@ -739,6 +739,15 @@ } void +file_editor_tab::scintilla_command (const QWidget *ID, unsigned int sci_msg) +{ + if (ID != this) + return; + + _edit_area->SendScintilla (sci_msg); +} + +void file_editor_tab::comment_selected_text (const QWidget *ID) { if (ID != this) diff -r cf3db95a75f0 -r 78fac67300e8 libgui/src/m-editor/file-editor-tab.h --- a/libgui/src/m-editor/file-editor-tab.h Thu Apr 24 07:13:37 2014 -0700 +++ b/libgui/src/m-editor/file-editor-tab.h Thu Apr 24 08:41:30 2014 -0700 @@ -92,6 +92,8 @@ void previous_breakpoint (const QWidget *ID); void remove_all_breakpoints (const QWidget *ID); + void scintilla_command (const QWidget *, unsigned int); + void comment_selected_text (const QWidget *ID); void uncomment_selected_text (const QWidget *ID); diff -r cf3db95a75f0 -r 78fac67300e8 libgui/src/m-editor/file-editor.cc --- a/libgui/src/m-editor/file-editor.cc Thu Apr 24 07:13:37 2014 -0700 +++ b/libgui/src/m-editor/file-editor.cc Thu Apr 24 08:41:30 2014 -0700 @@ -41,6 +41,7 @@ #include #include #include +#include #include "octave-link.h" #include "utils.h" @@ -56,6 +57,8 @@ construct (); setVisible (false); + + setAcceptDrops(true); } file_editor::~file_editor (void) @@ -567,37 +570,37 @@ } void -file_editor::request_undo (void) +file_editor::request_undo (bool) { emit fetab_undo (_tab_widget->currentWidget ()); } void -file_editor::request_redo (void) +file_editor::request_redo (bool) { emit fetab_redo (_tab_widget->currentWidget ()); } void -file_editor::request_copy (void) +file_editor::request_copy (bool) { emit fetab_copy (_tab_widget->currentWidget ()); } void -file_editor::request_cut (void) +file_editor::request_cut (bool) { emit fetab_cut (_tab_widget->currentWidget ()); } void -file_editor::request_paste (void) +file_editor::request_paste (bool) { emit fetab_paste (_tab_widget->currentWidget ()); } void -file_editor::request_selectall (void) +file_editor::request_selectall (bool) { emit fetab_selectall (_tab_widget->currentWidget ()); } @@ -621,26 +624,26 @@ } void -file_editor::request_save_file (void) +file_editor::request_save_file (bool) { emit fetab_save_file (_tab_widget->currentWidget ()); } void -file_editor::request_save_file_as (void) +file_editor::request_save_file_as (bool) { emit fetab_save_file_as (_tab_widget->currentWidget ()); } void -file_editor::request_print_file (void) +file_editor::request_print_file (bool) { emit fetab_print_file (_tab_widget->currentWidget ()); } void -file_editor::request_run_file (void) +file_editor::request_run_file (bool) { emit fetab_run_file (_tab_widget->currentWidget ()); } @@ -652,93 +655,160 @@ } void -file_editor::request_toggle_bookmark (void) +file_editor::request_toggle_bookmark (bool) { emit fetab_toggle_bookmark (_tab_widget->currentWidget ()); } void -file_editor::request_next_bookmark (void) +file_editor::request_next_bookmark (bool) { emit fetab_next_bookmark (_tab_widget->currentWidget ()); } void -file_editor::request_previous_bookmark (void) +file_editor::request_previous_bookmark (bool) { emit fetab_previous_bookmark (_tab_widget->currentWidget ()); } void -file_editor::request_remove_bookmark (void) +file_editor::request_remove_bookmark (bool) { emit fetab_remove_bookmark (_tab_widget->currentWidget ()); } void -file_editor::request_toggle_breakpoint (void) +file_editor::request_toggle_breakpoint (bool) { emit fetab_toggle_breakpoint (_tab_widget->currentWidget ()); } void -file_editor::request_next_breakpoint (void) +file_editor::request_next_breakpoint (bool) { emit fetab_next_breakpoint (_tab_widget->currentWidget ()); } void -file_editor::request_previous_breakpoint (void) +file_editor::request_previous_breakpoint (bool) { emit fetab_previous_breakpoint (_tab_widget->currentWidget ()); } void -file_editor::request_remove_breakpoint (void) +file_editor::request_remove_breakpoint (bool) { emit fetab_remove_all_breakpoints (_tab_widget->currentWidget ()); } +// slots for Edit->Commands actions void -file_editor::request_comment_selected_text (void) +file_editor::request_delete_start_word (bool) +{ + emit fetab_scintilla_command (_tab_widget->currentWidget (), + QsciCommand::DeleteWordLeft); +} +void +file_editor::request_delete_end_word (bool) +{ + emit fetab_scintilla_command (_tab_widget->currentWidget (), + QsciCommand::DeleteWordRight); +} +void +file_editor::request_delete_start_line (bool) +{ + emit fetab_scintilla_command (_tab_widget->currentWidget (), + QsciCommand::DeleteLineLeft); +} +void +file_editor::request_delete_end_line (bool) +{ + emit fetab_scintilla_command (_tab_widget->currentWidget (), + QsciCommand::DeleteLineRight); +} +void +file_editor::request_delete_line (bool) +{ + emit fetab_scintilla_command (_tab_widget->currentWidget (), + QsciCommand::LineDelete); +} +void +file_editor::request_copy_line (bool) +{ + emit fetab_scintilla_command (_tab_widget->currentWidget (), + QsciCommand::LineCopy); +} +void +file_editor::request_cut_line (bool) +{ + emit fetab_scintilla_command (_tab_widget->currentWidget (), + QsciCommand::LineCut); +} +void +file_editor::request_duplicate_selection (bool) +{ + emit fetab_scintilla_command (_tab_widget->currentWidget (), + QsciCommand::SelectionDuplicate); +} +void +file_editor::request_transpose_line (bool) +{ + emit fetab_scintilla_command (_tab_widget->currentWidget (), + QsciCommand::LineTranspose); +} +void +file_editor::request_comment_selected_text (bool) { emit fetab_comment_selected_text (_tab_widget->currentWidget ()); } - void -file_editor::request_uncomment_selected_text (void) +file_editor::request_uncomment_selected_text (bool) { emit fetab_uncomment_selected_text (_tab_widget->currentWidget ()); } +// slots for Edit->Format actions void -file_editor::request_indent_selected_text (void) +file_editor::request_upper_case (bool) +{ + emit fetab_scintilla_command (_tab_widget->currentWidget (), + QsciCommand::SelectionUpperCase); +} +void +file_editor::request_lower_case (bool) +{ + emit fetab_scintilla_command (_tab_widget->currentWidget (), + QsciCommand::SelectionLowerCase); +} +void +file_editor::request_indent_selected_text (bool) { emit fetab_indent_selected_text (_tab_widget->currentWidget ()); } void -file_editor::request_unindent_selected_text (void) +file_editor::request_unindent_selected_text (bool) { emit fetab_unindent_selected_text (_tab_widget->currentWidget ()); } void -file_editor::request_find (void) +file_editor::request_find (bool) { emit fetab_find (_tab_widget->currentWidget ()); } void -file_editor::request_goto_line (void) +file_editor::request_goto_line (bool) { emit fetab_goto_line (_tab_widget->currentWidget ()); } void -file_editor::request_completion (void) +file_editor::request_completion (bool) { emit fetab_completion (_tab_widget->currentWidget ()); } @@ -899,7 +969,7 @@ { _copy_action->setEnabled (copy_available); _cut_action->setEnabled (copy_available); - _context_run_action->setEnabled (copy_available); + _run_selection_action->setEnabled (copy_available); if (!file_name.isEmpty ()) { @@ -944,6 +1014,8 @@ _tab_widget->setUsesScrollButtons (true); _tab_widget->setStyleSheet (style_sheet); + set_shortcuts (); + // Relay signal to file editor tabs. emit fetab_settings_changed (settings); } @@ -961,6 +1033,28 @@ } void +file_editor::insert_new_open_actions (QAction *new_action, + QAction *new_fcn_action, + QAction *open_action) +{ + _fileMenu->insertAction (_mru_file_menu->menuAction (), open_action); + _fileMenu->insertAction (open_action, new_fcn_action); + _fileMenu->insertAction (new_fcn_action, new_action); + _tool_bar->insertAction (_save_action, open_action); + _tool_bar->insertAction (open_action, new_action); +} + +QAction* +file_editor::add_action (QMenu *menu, const QIcon &icon, const QString &text, + const char *member) +{ + QAction *a = menu->addAction (icon, text, this, member); + addAction (a); // important for shortcut context + a->setShortcutContext (Qt::WidgetWithChildrenShortcut); + return a; +} + +void file_editor::construct (void) { QWidget *editor_widget = new QWidget (this); @@ -979,84 +1073,6 @@ _tab_widget->setMovable (true); #endif - QAction *new_action = new QAction (QIcon (":/actions/icons/filenew.png"), - tr ("&New Script"), _tool_bar); - - QAction *open_action = new QAction (QIcon (":/actions/icons/folder_documents.png"), - tr ("&Open File..."), _tool_bar); - - _save_action = new QAction (QIcon (":/actions/icons/filesave.png"), - tr ("&Save File"), _tool_bar); - - _save_as_action = new QAction (QIcon (":/actions/icons/filesaveas.png"), - tr ("Save File &As..."), _tool_bar); - - _print_action = new QAction ( QIcon (":/actions/icons/fileprint.png"), - tr ("Print..."), _tool_bar); - - _undo_action = new QAction (QIcon (":/actions/icons/undo.png"), - tr ("&Undo"), _tool_bar); - - _redo_action = new QAction (QIcon (":/actions/icons/redo.png"), - tr ("&Redo"), _tool_bar); - - _copy_action = new QAction (QIcon (":/actions/icons/editcopy.png"), - tr ("&Copy"), _tool_bar); - _copy_action->setEnabled (false); - - _cut_action = new QAction (QIcon (":/actions/icons/editcut.png"), - tr ("Cu&t"), _tool_bar); - _cut_action->setEnabled (false); - - _paste_action - = new QAction (QIcon (":/actions/icons/editpaste.png"), - tr ("Paste"), _tool_bar); - - _next_bookmark_action = new QAction (tr ("&Next Bookmark"), _tool_bar); - - _previous_bookmark_action = new QAction (tr ("Pre&vious Bookmark"), - _tool_bar); - - _toggle_bookmark_action = new QAction (tr ("Toggle &Bookmark"), _tool_bar); - - _remove_bookmark_action - = new QAction (tr ("&Remove All Bookmarks"), _tool_bar); - - QAction *next_breakpoint_action - = new QAction (QIcon (":/actions/icons/bp_next.png"), - tr ("&Next Breakpoint"), _tool_bar); - QAction *previous_breakpoint_action - = new QAction (QIcon (":/actions/icons/bp_prev.png"), - tr ("Pre&vious Breakpoint"), _tool_bar); - QAction *toggle_breakpoint_action - = new QAction (QIcon (":/actions/icons/bp_toggle.png"), - tr ("Toggle &Breakpoint"), _tool_bar); - QAction *remove_all_breakpoints_action - = new QAction (QIcon (":/actions/icons/bp_rm_all.png"), - tr ("&Remove All Breakpoints"), _tool_bar); - - _selectall_action - = new QAction (tr ("Select All"), _tool_bar); - - _comment_selection_action - = new QAction (tr ("&Comment"), _tool_bar); - _uncomment_selection_action - = new QAction (tr ("&Uncomment"), _tool_bar); - - _indent_selection_action - = new QAction (tr ("&Indent"), _tool_bar); - _unindent_selection_action - = new QAction (tr ("&Unindent"), _tool_bar); - - _find_action = new QAction (QIcon (":/actions/icons/find.png"), - tr ("&Find and Replace..."), _tool_bar); - - _run_action = new QAction (QIcon (":/actions/icons/artsbuilderexecute.png"), - tr ("Save File and Run"), _tool_bar); - - _goto_line_action = new QAction (tr ("Go &to Line..."), _tool_bar); - - _completion_action = new QAction (tr ("&Show Completion List"), _tool_bar); // the mru-list and an empty array of actions QSettings *settings = resource_manager::get_settings (); @@ -1067,30 +1083,217 @@ _mru_file_actions[i]->setVisible (false); } - // some actions are disabled from the beginning - _copy_action->setEnabled (false); - _cut_action->setEnabled (false); + // menu bar + + // file menu + + _fileMenu = new QMenu (tr ("&File"), _menu_bar); + + // new and open menus are inserted later by the main window + _mru_file_menu = new QMenu (tr ("&Recent Editor Files"), _fileMenu); + for (int i = 0; i < MaxMRUFiles; ++i) + _mru_file_menu->addAction (_mru_file_actions[i]); + _fileMenu->addMenu (_mru_file_menu); + + _fileMenu->addSeparator (); + + _edit_function_action = add_action (_fileMenu, QIcon (), + tr ("&Edit Function"), SLOT (request_context_edit (bool))); + + _fileMenu->addSeparator (); + + _save_action = add_action (_fileMenu, QIcon (":/actions/icons/filesave.png"), + tr ("&Save File"), SLOT (request_save_file (bool))); + _save_as_action = add_action (_fileMenu, QIcon (":/actions/icons/filesaveas.png"), + tr ("Save File &As..."), SLOT (request_save_file_as (bool))); + + _fileMenu->addSeparator (); + + _close_action = add_action (_fileMenu, + QIcon::fromTheme("window-close",QIcon (":/actions/icons/fileclose.png")), + tr ("&Close"), SLOT (request_close_file (bool))); + _close_all_action = add_action (_fileMenu, + QIcon::fromTheme("window-close", QIcon (":/actions/icons/fileclose.png")), + tr ("Close All"), SLOT (request_close_all_files (bool))); + _close_others_action = add_action (_fileMenu, + QIcon::fromTheme("window-close", QIcon (":/actions/icons/fileclose.png")), + tr ("Close Other Files"), SLOT (request_close_other_files (bool))); + + _fileMenu->addSeparator (); + + _print_action = add_action (_fileMenu, QIcon (":/actions/icons/fileprint.png"), + tr ("Print..."), SLOT (request_print_file (bool))); + + _menu_bar->addMenu (_fileMenu); + + // edit menu + + QMenu *editMenu = new QMenu (tr ("&Edit"), _menu_bar); + + _undo_action = add_action (editMenu, QIcon (":/actions/icons/undo.png"), + tr ("&Undo"), SLOT (request_undo (bool))); + _redo_action = add_action (editMenu, QIcon (":/actions/icons/redo.png"), + tr ("&Redo"), SLOT (request_redo (bool))); - _run_action->setShortcutContext (Qt::WindowShortcut); - _save_action->setShortcutContext (Qt::WindowShortcut); - _save_as_action->setShortcutContext (Qt::WindowShortcut); + editMenu->addSeparator (); + + _copy_action = add_action (editMenu, QIcon (":/actions/icons/editcopy.png"), + tr ("&Copy"), SLOT (request_copy (bool))); + _copy_action->setEnabled (false); + _cut_action = add_action (editMenu, QIcon (":/actions/icons/editcut.png"), + tr ("Cu&t"), SLOT (request_cut (bool))); + _cut_action->setEnabled (false); + _paste_action = add_action (editMenu, QIcon (":/actions/icons/editpaste.png"), + tr ("Paste"), SLOT (request_paste (bool))); + + editMenu->addSeparator (); + + _selectall_action = add_action (editMenu, QIcon (), tr ("Select All"), + SLOT (request_selectall (bool))); + + editMenu->addSeparator (); + + _find_action = add_action (editMenu, QIcon (":/actions/icons/find.png"), + tr ("&Find and Replace..."), SLOT (request_find (bool))); + + editMenu->addSeparator (); + + _edit_cmd_menu = editMenu->addMenu (tr ("&Commands")); - _print_action->setShortcutContext (Qt::WindowShortcut); + _delete_line_action = add_action (_edit_cmd_menu, QIcon (), + tr ("Delete Line"), SLOT (request_delete_line (bool))); + _copy_line_action = add_action (_edit_cmd_menu, QIcon (), + tr ("Copy Line"), SLOT (request_copy_line (bool))); + _cut_line_action = add_action (_edit_cmd_menu, QIcon (), + tr ("Cut Line"), SLOT (request_cut_line (bool))); + + _edit_cmd_menu->addSeparator (); + + _delete_start_word_action = add_action (_edit_cmd_menu, QIcon (), + tr ("Delete to Start of Word"), SLOT (request_delete_start_word (bool))); + _delete_end_word_action = add_action (_edit_cmd_menu, QIcon (), + tr ("Delete to End of Word"), SLOT (request_delete_end_word (bool))); + _delete_start_line_action = add_action (_edit_cmd_menu, QIcon (), + tr ("Delete to Start of Line"), SLOT (request_delete_start_line (bool))); + _delete_end_line_action = add_action (_edit_cmd_menu, QIcon (), + tr ("Delete to End of Line"), SLOT (request_delete_end_line (bool))); + + _edit_cmd_menu->addSeparator (); + + _duplicate_selection_action = add_action (_edit_cmd_menu, QIcon (), + tr ("Duplicate Selection/Line"), SLOT (request_duplicate_selection (bool))); + _transpose_line_action = add_action (_edit_cmd_menu, QIcon (), + tr ("Transpose Line"), SLOT (request_transpose_line (bool))); + + _edit_cmd_menu->addSeparator (); - _next_bookmark_action->setShortcutContext (Qt::WindowShortcut); - _previous_bookmark_action->setShortcutContext (Qt::WindowShortcut); - _toggle_bookmark_action->setShortcutContext (Qt::WindowShortcut); - _comment_selection_action->setShortcutContext (Qt::WindowShortcut); - _uncomment_selection_action->setShortcutContext (Qt::WindowShortcut); - _indent_selection_action->setShortcutContext (Qt::WindowShortcut); - _unindent_selection_action->setShortcutContext (Qt::WindowShortcut); - _find_action->setShortcutContext (Qt::WindowShortcut); - _goto_line_action->setShortcutContext (Qt::WindowShortcut); - _completion_action->setShortcutContext (Qt::WindowShortcut); + _completion_action = add_action (_edit_cmd_menu, QIcon (), + tr ("&Show Completion List"), SLOT (request_completion (bool))); + + _edit_fmt_menu = editMenu->addMenu (tr ("&Format")); + + _upper_case_action = add_action (_edit_fmt_menu, QIcon (), + tr ("&Uppercase Selection"), SLOT (request_upper_case (bool))); + _lower_case_action = add_action (_edit_fmt_menu, QIcon (), + tr ("&Lowercase Selection"), SLOT (request_lower_case (bool))); + _comment_selection_action = add_action (_edit_fmt_menu, QIcon (), + tr ("&Comment"), SLOT (request_comment_selected_text (bool))); + _uncomment_selection_action = add_action (_edit_fmt_menu, QIcon (), + tr ("&Uncomment"), SLOT (request_uncomment_selected_text (bool))); + _indent_selection_action = add_action (_edit_fmt_menu, QIcon (), + tr ("&Indent"), SLOT (request_indent_selected_text (bool))); + _unindent_selection_action = add_action (_edit_fmt_menu, QIcon (), + tr ("&Unindent"), SLOT (request_unindent_selected_text (bool))); + + _edit_nav_menu = editMenu->addMenu (tr ("Navi&gation")); + + _goto_line_action = add_action (_edit_nav_menu, QIcon (), + tr ("Go &to Line..."), SLOT (request_goto_line (bool))); + + _edit_nav_menu->addSeparator (); + + _next_bookmark_action = add_action (_edit_nav_menu, QIcon (), + tr ("&Next Bookmark"), SLOT (request_next_bookmark (bool))); + _previous_bookmark_action = add_action (_edit_nav_menu, QIcon (), + tr ("Pre&vious Bookmark"), SLOT (request_previous_bookmark (bool))); + _toggle_bookmark_action = add_action (_edit_nav_menu, QIcon (), + tr ("Toggle &Bookmark"), SLOT (request_toggle_bookmark (bool))); + _remove_bookmark_action = add_action (_edit_nav_menu, QIcon (), + tr ("&Remove All Bookmarks"), SLOT (request_remove_bookmark (bool))); + + editMenu->addSeparator (); + + _preferences_action = add_action (editMenu, + QIcon (":/actions/icons/configure.png"), + tr ("&Preferences..."), SLOT (request_preferences (bool))); + _styles_preferences_action = add_action (editMenu, + QIcon (":/actions/icons/configure.png"), + tr ("&Styles Preferences..."), SLOT (request_styles_preferences (bool))); + + _menu_bar->addMenu (editMenu); + + // view menu + + QMenu *view_menu = new QMenu (tr ("&View"), _menu_bar); + + _zoom_in_action = add_action (view_menu, QIcon (), + tr ("Zoom &In"), SLOT (zoom_in (bool))); + _zoom_out_action = add_action (view_menu, QIcon (), + tr ("Zoom &Out"), SLOT (zoom_out (bool))); + _zoom_normal_action = add_action (view_menu, QIcon (), + tr ("&Normal Size"), SLOT (zoom_normal (bool))); + + _menu_bar->addMenu (view_menu); + + // debug menu + + _debug_menu = new QMenu (tr ("&Debug"), _menu_bar); + + _toggle_breakpoint_action = add_action (_debug_menu, + QIcon (":/actions/icons/bp_toggle.png"), tr ("Toggle &Breakpoint"), + SLOT (request_toggle_breakpoint (bool))); + _next_breakpoint_action = add_action (_debug_menu, + QIcon (":/actions/icons/bp_next.png"), tr ("&Next Breakpoint"), + SLOT (request_next_breakpoint (bool))); + _previous_breakpoint_action = add_action (_debug_menu, + QIcon (":/actions/icons/bp_prev.png"), tr ("Pre&vious Breakpoint"), + SLOT (request_previous_breakpoint (bool))); + _remove_all_breakpoints_action = add_action (_debug_menu, + QIcon (":/actions/icons/bp_rm_all.png"), tr ("&Remove All Breakpoints"), + SLOT (request_remove_breakpoint (bool))); + + _debug_menu->addSeparator (); + + // The other debug actions will be added by the main window. + + _menu_bar->addMenu (_debug_menu); + + // run menu + + QMenu *_run_menu = new QMenu (tr ("&Run"), _menu_bar); + + _run_action = add_action (_run_menu, QIcon (":/actions/icons/artsbuilderexecute.png"), + tr ("Save File and Run"), SLOT (request_run_file (bool))); + _run_selection_action = add_action (_run_menu, QIcon (), + tr ("Run &Selection"), SLOT (request_context_run (bool))); + _run_selection_action->setEnabled (false); + + _menu_bar->addMenu (_run_menu); + + // help menu + + QMenu *_help_menu = new QMenu (tr ("&Help"), _menu_bar); + + _context_help_action = add_action (_help_menu, QIcon (), + tr ("&Help on Keyword"), SLOT (request_context_help (bool))); + _context_doc_action = add_action (_help_menu, QIcon (), + tr ("&Documentation on Keyword"), SLOT (request_context_doc (bool))); + + _menu_bar->addMenu (_help_menu); // toolbar - _tool_bar->addAction (new_action); - _tool_bar->addAction (open_action); + + // new and open actions are inserted later from main window _tool_bar->addAction (_save_action); _tool_bar->addAction (_save_as_action); _tool_bar->addSeparator (); @@ -1105,126 +1308,10 @@ _tool_bar->addAction (_find_action); _tool_bar->addAction (_run_action); _tool_bar->addSeparator (); - _tool_bar->addAction (toggle_breakpoint_action); - _tool_bar->addAction (next_breakpoint_action); - _tool_bar->addAction (previous_breakpoint_action); - _tool_bar->addAction (remove_all_breakpoints_action); - - // menu bar - QMenu *fileMenu = new QMenu (tr ("&File"), _menu_bar); - - _mru_file_menu = new QMenu (tr ("&Recent Editor Files"), fileMenu); - for (int i = 0; i < MaxMRUFiles; ++i) - _mru_file_menu->addAction (_mru_file_actions[i]); - - fileMenu->addAction (new_action); - fileMenu->addAction (QIcon (), tr ("New &Function..."), - this, SLOT (request_new_function (bool))); - fileMenu->addAction (open_action); - fileMenu->addMenu (_mru_file_menu); - fileMenu->addSeparator (); - _context_edit_action = - fileMenu->addAction (QIcon (), tr ("&Edit Function"), - this, SLOT (request_context_edit (bool))); - fileMenu->addSeparator (); - fileMenu->addAction (_save_action); - fileMenu->addAction (_save_as_action); - - fileMenu->addSeparator (); - _close_action = - fileMenu->addAction (QIcon::fromTheme("window-close", - QIcon (":/actions/icons/fileclose.png")), - tr ("&Close"), this, SLOT (request_close_file (bool))); - _close_all_action = - fileMenu->addAction (QIcon::fromTheme("window-close", - QIcon (":/actions/icons/fileclose.png")), - tr ("Close All"), - this, SLOT (request_close_all_files (bool))); - _close_others_action = - fileMenu->addAction (QIcon::fromTheme("window-close", - QIcon (":/actions/icons/fileclose.png")), - tr ("Close Other Files"), - this, SLOT (request_close_other_files (bool))); - - fileMenu->addSeparator (); - fileMenu->addAction (_print_action); - - _menu_bar->addMenu (fileMenu); - - - QMenu *editMenu = new QMenu (tr ("&Edit"), _menu_bar); - editMenu->addAction (_undo_action); - editMenu->addAction (_redo_action); - editMenu->addSeparator (); - editMenu->addAction (_copy_action); - editMenu->addAction (_cut_action); - editMenu->addAction (_paste_action); - editMenu->addSeparator (); - editMenu->addAction (_selectall_action); - editMenu->addSeparator (); - editMenu->addAction (_find_action); - editMenu->addSeparator (); - editMenu->addAction (_comment_selection_action); - editMenu->addAction (_uncomment_selection_action); - editMenu->addAction (_indent_selection_action); - editMenu->addAction (_unindent_selection_action); - editMenu->addSeparator (); - editMenu->addAction (_completion_action); - editMenu->addSeparator (); - editMenu->addAction (_toggle_bookmark_action); - editMenu->addAction (_next_bookmark_action); - editMenu->addAction (_previous_bookmark_action); - editMenu->addAction (_remove_bookmark_action); - editMenu->addSeparator (); - editMenu->addAction (_goto_line_action); - editMenu->addSeparator (); - _preferences_action = - editMenu->addAction (QIcon (":/actions/icons/configure.png"), - tr ("&Preferences..."), - this, SLOT (request_preferences (bool))); - _styles_preferences_action = - editMenu->addAction (QIcon (":/actions/icons/configure.png"), - tr ("&Styles Preferences..."), - this, SLOT (request_styles_preferences (bool))); - _menu_bar->addMenu (editMenu); - - QMenu *view_menu = new QMenu (tr ("&View"), _menu_bar); - _zoom_in_action = view_menu->addAction (QIcon (), tr ("Zoom &In"), - this, SLOT (zoom_in (bool))); - _zoom_out_action = view_menu->addAction (QIcon (), tr ("Zoom &Out"), - this, SLOT (zoom_out (bool))); - _zoom_normal_action = view_menu->addAction (QIcon (), tr ("&Normal Size"), - this, SLOT (zoom_normal (bool))); - _menu_bar->addMenu (view_menu); - - _debug_menu = new QMenu (tr ("&Debug"), _menu_bar); - _debug_menu->addAction (toggle_breakpoint_action); - _debug_menu->addAction (next_breakpoint_action); - _debug_menu->addAction (previous_breakpoint_action); - _debug_menu->addAction (remove_all_breakpoints_action); - _debug_menu->addSeparator (); - // The other debug actions will be added by the main window. - _menu_bar->addMenu (_debug_menu); - - QMenu *_run_menu = new QMenu (tr ("&Run"), _menu_bar); - _run_menu->addAction (_run_action); - _context_run_action = - _run_menu->addAction (QIcon (), tr ("Run &Selection"), - this, SLOT (request_context_run (bool))); - _context_run_action->setEnabled (false); - _menu_bar->addMenu (_run_menu); - - QMenu *_help_menu = new QMenu (tr ("&Help"), _menu_bar); - _context_help_action = - _help_menu->addAction (QIcon (), tr ("&Help on Keyword"), - this, SLOT (request_context_help (bool))); - _context_doc_action = - _help_menu->addAction (QIcon (), tr ("&Documentation on Keyword"), - this, SLOT (request_context_doc (bool))); - _menu_bar->addMenu (_help_menu); - - // shortcuts - set_shortcuts (true); + _tool_bar->addAction (_toggle_breakpoint_action); + _tool_bar->addAction (_next_breakpoint_action); + _tool_bar->addAction (_previous_breakpoint_action); + _tool_bar->addAction (_remove_all_breakpoints_action); // layout QVBoxLayout *vbox_layout = new QVBoxLayout (); @@ -1246,87 +1333,6 @@ connect (main_win (), SIGNAL (open_file_signal (const QString&)), this, SLOT (request_open_file (const QString&))); - connect (new_action, SIGNAL (triggered ()), - this, SLOT (request_new_file ())); - - connect (open_action, SIGNAL (triggered ()), - this, SLOT (request_open_file ())); - - connect (_undo_action, SIGNAL (triggered ()), - this, SLOT (request_undo ())); - - connect (_redo_action, SIGNAL (triggered ()), - this, SLOT (request_redo ())); - - connect (_copy_action, SIGNAL (triggered ()), - this, SLOT (request_copy ())); - - connect (_cut_action, SIGNAL (triggered ()), - this, SLOT (request_cut ())); - - connect (_paste_action, SIGNAL (triggered ()), - this, SLOT (request_paste ())); - - connect (_selectall_action, SIGNAL (triggered ()), - this, SLOT (request_selectall ())); - - connect (_save_action, SIGNAL (triggered ()), - this, SLOT (request_save_file ())); - - connect (_save_as_action, SIGNAL (triggered ()), - this, SLOT (request_save_file_as ())); - - connect (_print_action, SIGNAL (triggered ()), - this, SLOT (request_print_file ())); - - connect (_run_action, SIGNAL (triggered ()), - this, SLOT (request_run_file ())); - - connect (_toggle_bookmark_action, SIGNAL (triggered ()), - this, SLOT (request_toggle_bookmark ())); - - connect (_next_bookmark_action, SIGNAL (triggered ()), - this, SLOT (request_next_bookmark ())); - - connect (_previous_bookmark_action, SIGNAL (triggered ()), - this, SLOT (request_previous_bookmark ())); - - connect (_remove_bookmark_action, SIGNAL (triggered ()), - this, SLOT (request_remove_bookmark ())); - - connect (toggle_breakpoint_action, SIGNAL (triggered ()), - this, SLOT (request_toggle_breakpoint ())); - - connect (next_breakpoint_action, SIGNAL (triggered ()), - this, SLOT (request_next_breakpoint ())); - - connect (previous_breakpoint_action, SIGNAL (triggered ()), - this, SLOT (request_previous_breakpoint ())); - - connect (remove_all_breakpoints_action, SIGNAL (triggered ()), - this, SLOT (request_remove_breakpoint ())); - - connect (_comment_selection_action, SIGNAL (triggered ()), - this, SLOT (request_comment_selected_text ())); - - connect (_uncomment_selection_action, SIGNAL (triggered ()), - this, SLOT (request_uncomment_selected_text ())); - - connect (_indent_selection_action, SIGNAL (triggered ()), - this, SLOT (request_indent_selected_text ())); - - connect (_unindent_selection_action, SIGNAL (triggered ()), - this, SLOT (request_unindent_selected_text ())); - - connect (_find_action, SIGNAL (triggered ()), - this, SLOT (request_find ())); - - connect (_goto_line_action, SIGNAL (triggered ()), - this, SLOT (request_goto_line ())); - - connect (_completion_action, SIGNAL (triggered ()), - this, SLOT (request_completion ())); - connect (_mru_file_menu, SIGNAL (triggered (QAction *)), this, SLOT (request_mru_open_file (QAction *))); @@ -1478,6 +1484,9 @@ connect (this, SIGNAL (fetab_remove_all_breakpoints (const QWidget*)), f, SLOT (remove_all_breakpoints (const QWidget*))); + connect (this, SIGNAL (fetab_scintilla_command (const QWidget *, unsigned int)), + f, SLOT (scintilla_command (const QWidget *, unsigned int))); + connect (this, SIGNAL (fetab_comment_selected_text (const QWidget*)), f, SLOT (comment_selected_text (const QWidget*))); @@ -1524,7 +1533,7 @@ if (foc_w && foc_w->inherits ("octave_qscintilla")) { - request_copy (); + request_copy (true); } } void @@ -1534,7 +1543,7 @@ if (foc_w && foc_w->inherits ("octave_qscintilla")) { - request_paste (); + request_paste (true); } } void @@ -1544,110 +1553,76 @@ if (foc_w && foc_w->inherits ("octave_qscintilla")) { - request_selectall (); + request_selectall (true); } } void -file_editor::set_shortcuts (bool set) +file_editor::set_shortcuts () { - if (set) - { - - // File menu - shortcut_manager::set_shortcut (_context_edit_action, "editor_file:edit_function"); - shortcut_manager::set_shortcut (_save_action, "editor_file:save"); - shortcut_manager::set_shortcut (_save_as_action, "editor_file:save_as"); - shortcut_manager::set_shortcut (_close_action, "editor_file:close"); - shortcut_manager::set_shortcut (_close_all_action, "editor_file:close_all"); - shortcut_manager::set_shortcut (_close_others_action, "editor_file:close_other"); - shortcut_manager::set_shortcut (_print_action, "editor_file:print"); + // File menu + shortcut_manager::set_shortcut (_edit_function_action, "editor_file:edit_function"); + shortcut_manager::set_shortcut (_save_action, "editor_file:save"); + shortcut_manager::set_shortcut (_save_as_action, "editor_file:save_as"); + shortcut_manager::set_shortcut (_close_action, "editor_file:close"); + shortcut_manager::set_shortcut (_close_all_action, "editor_file:close_all"); + shortcut_manager::set_shortcut (_close_others_action, "editor_file:close_other"); + shortcut_manager::set_shortcut (_print_action, "editor_file:print"); - // Edit menu - shortcut_manager::set_shortcut (_undo_action, "editor_edit:undo"); - shortcut_manager::set_shortcut (_redo_action, "editor_edit:redo"); - shortcut_manager::set_shortcut (_copy_action, "editor_edit:copy"); - shortcut_manager::set_shortcut (_cut_action, "editor_edit:cut"); - shortcut_manager::set_shortcut (_paste_action, "editor_edit:paste"); - shortcut_manager::set_shortcut (_selectall_action, "editor_edit:select_all"); - shortcut_manager::set_shortcut (_find_action, "editor_edit:find_replace"); - shortcut_manager::set_shortcut (_comment_selection_action, "editor_edit:comment_selection"); - shortcut_manager::set_shortcut (_uncomment_selection_action, "editor_edit:uncomment_selection"); - shortcut_manager::set_shortcut (_indent_selection_action, "editor_edit:indent_selection"); - shortcut_manager::set_shortcut (_unindent_selection_action, "editor_edit:unindent_selection"); - shortcut_manager::set_shortcut (_completion_action, "editor_edit:completion_list"); - shortcut_manager::set_shortcut (_toggle_bookmark_action, "editor_edit:toggle_bookmark"); - shortcut_manager::set_shortcut (_next_bookmark_action, "editor_edit:next_bookmark"); - shortcut_manager::set_shortcut (_previous_bookmark_action, "editor_edit:previous_bookmark"); - shortcut_manager::set_shortcut (_remove_bookmark_action, "editor_edit:remove_bookmark"); - shortcut_manager::set_shortcut (_goto_line_action, "editor_edit:goto_line"); - shortcut_manager::set_shortcut (_preferences_action, "editor_edit:preferences"); - shortcut_manager::set_shortcut (_styles_preferences_action, "editor_edit:styles_preferences"); + // Edit menu + shortcut_manager::set_shortcut (_undo_action, "editor_edit:undo"); + shortcut_manager::set_shortcut (_redo_action, "editor_edit:redo"); + shortcut_manager::set_shortcut (_copy_action, "editor_edit:copy"); + shortcut_manager::set_shortcut (_cut_action, "editor_edit:cut"); + shortcut_manager::set_shortcut (_paste_action, "editor_edit:paste"); + shortcut_manager::set_shortcut (_selectall_action, "editor_edit:select_all"); + shortcut_manager::set_shortcut (_find_action, "editor_edit:find_replace"); - - _context_help_action->setShortcut (QKeySequence::HelpContents); - _context_doc_action->setShortcut (Qt::SHIFT + Qt::Key_F1); - - _zoom_in_action->setShortcuts (QKeySequence::ZoomIn); - _zoom_out_action->setShortcuts (QKeySequence::ZoomOut); - _zoom_normal_action->setShortcut (Qt::ControlModifier + Qt::Key_Slash); - - - - _run_action->setShortcut (Qt::Key_F5); - _context_run_action->setShortcut (Qt::Key_F9); - + shortcut_manager::set_shortcut (_delete_start_word_action, "editor_edit:delete_start_word"); + shortcut_manager::set_shortcut (_delete_end_word_action, "editor_edit:delete_end_word"); + shortcut_manager::set_shortcut (_delete_start_line_action, "editor_edit:delete_start_line"); + shortcut_manager::set_shortcut (_delete_end_line_action, "editor_edit:delete_end_line"); + shortcut_manager::set_shortcut (_delete_line_action, "editor_edit:delete_line"); + shortcut_manager::set_shortcut (_copy_line_action, "editor_edit:copy_line"); + shortcut_manager::set_shortcut (_cut_line_action, "editor_edit:cut_line"); + shortcut_manager::set_shortcut (_duplicate_selection_action, "editor_edit:duplicate_selection"); + shortcut_manager::set_shortcut (_transpose_line_action, "editor_edit:transpose_line"); + shortcut_manager::set_shortcut (_comment_selection_action, "editor_edit:comment_selection"); + shortcut_manager::set_shortcut (_uncomment_selection_action, "editor_edit:uncomment_selection"); - - } - else - { - QKeySequence no_key = QKeySequence (); - - // File menu - _context_edit_action->setShortcut (no_key); - _save_action->setShortcut (no_key); - _save_as_action->setShortcut (no_key); - _close_action->setShortcut (no_key); - _close_all_action->setShortcut (no_key); - _close_others_action->setShortcut (no_key); - _print_action->setShortcut (no_key); + shortcut_manager::set_shortcut (_upper_case_action, "editor_edit:upper_case"); + shortcut_manager::set_shortcut (_lower_case_action, "editor_edit:lower_case"); + shortcut_manager::set_shortcut (_indent_selection_action, "editor_edit:indent_selection"); + shortcut_manager::set_shortcut (_unindent_selection_action, "editor_edit:unindent_selection"); + shortcut_manager::set_shortcut (_completion_action, "editor_edit:completion_list"); + shortcut_manager::set_shortcut (_goto_line_action, "editor_edit:goto_line"); + shortcut_manager::set_shortcut (_toggle_bookmark_action, "editor_edit:toggle_bookmark"); + shortcut_manager::set_shortcut (_next_bookmark_action, "editor_edit:next_bookmark"); + shortcut_manager::set_shortcut (_previous_bookmark_action, "editor_edit:previous_bookmark"); + shortcut_manager::set_shortcut (_remove_bookmark_action, "editor_edit:remove_bookmark"); + shortcut_manager::set_shortcut (_preferences_action, "editor_edit:preferences"); + shortcut_manager::set_shortcut (_styles_preferences_action, "editor_edit:styles_preferences"); - // Edit menu - _redo_action->setShortcut (no_key); - _undo_action->setShortcut (no_key); - _copy_action->setShortcut (no_key); - _cut_action->setShortcut (no_key); - _paste_action->setShortcut (no_key); - _selectall_action->setShortcut (no_key); - _find_action->setShortcut (no_key); - _comment_selection_action->setShortcut (no_key); - _uncomment_selection_action->setShortcut (no_key); - _indent_selection_action->setShortcut (no_key); - _unindent_selection_action->setShortcut (no_key); - _completion_action->setShortcut (no_key); - _toggle_bookmark_action->setShortcut (no_key); - _next_bookmark_action->setShortcut (no_key); - _previous_bookmark_action->setShortcut (no_key); - _remove_bookmark_action->setShortcut (no_key); - _goto_line_action->setShortcut (no_key); - _preferences_action->setShortcut (no_key); - _styles_preferences_action->setShortcut (no_key); + // View menu + shortcut_manager::set_shortcut (_zoom_in_action, "edit_edit:zoom_in"); + shortcut_manager::set_shortcut (_zoom_out_action, "edit_edit:zoom_out"); + shortcut_manager::set_shortcut (_zoom_normal_action, "edit_edit:zoom_normal"); - - _context_help_action->setShortcut (no_key); - - _zoom_in_action->setShortcut (no_key); - _zoom_out_action->setShortcut (no_key); - _zoom_normal_action->setShortcut (no_key); + // Debug menu + shortcut_manager::set_shortcut (_toggle_breakpoint_action, "editor_debug:toggle_breakpoint"); + shortcut_manager::set_shortcut (_next_breakpoint_action, "editor_debug:next_breakpoint"); + shortcut_manager::set_shortcut (_previous_bookmark_action, "editor_debug:previous_breakpoint"); + shortcut_manager::set_shortcut (_remove_all_breakpoints_action, "editor_debug:remove_breakpoints"); - + // Run menu + shortcut_manager::set_shortcut (_run_action, "editor_run:run_file"); + shortcut_manager::set_shortcut (_run_selection_action, "editor_run:run_selection"); - _run_action->setShortcut (no_key); - _context_run_action->setShortcut (no_key); + // Help menu + shortcut_manager::set_shortcut (_context_help_action, "editor_help:help_keyword"); + shortcut_manager::set_shortcut (_context_doc_action, "editor_help:doc_keyword"); - } } void @@ -1655,9 +1630,12 @@ { bool have_tabs = _tab_widget->count () > 0; + _edit_cmd_menu->setEnabled (have_tabs); + _edit_fmt_menu->setEnabled (have_tabs); + _edit_nav_menu->setEnabled (have_tabs); + _comment_selection_action->setEnabled (have_tabs); _uncomment_selection_action->setEnabled (have_tabs); - _indent_selection_action->setEnabled (have_tabs); _unindent_selection_action->setEnabled (have_tabs); @@ -1670,18 +1648,10 @@ _zoom_normal_action->setEnabled (have_tabs); _find_action->setEnabled (have_tabs); - _goto_line_action->setEnabled (have_tabs); - _completion_action->setEnabled (have_tabs); - - _next_bookmark_action->setEnabled (have_tabs); - _previous_bookmark_action->setEnabled (have_tabs); - _toggle_bookmark_action->setEnabled (have_tabs); - _remove_bookmark_action->setEnabled (have_tabs); - _print_action->setEnabled (have_tabs); _run_action->setEnabled (have_tabs); - _context_edit_action->setEnabled (have_tabs); + _edit_function_action->setEnabled (have_tabs); _save_action->setEnabled (have_tabs); _save_as_action->setEnabled (have_tabs); _close_action->setEnabled (have_tabs); @@ -1690,6 +1660,7 @@ _undo_action->setEnabled (have_tabs); _redo_action->setEnabled (have_tabs); + _selectall_action->setEnabled (have_tabs); } // empty_script determines whether we have to create an empty script @@ -1755,4 +1726,25 @@ focus (); } +void +file_editor::dragEnterEvent (QDragEnterEvent *event) + { + if (event->mimeData ()->hasUrls ()) + { + event->acceptProposedAction(); + } + } + +void +file_editor::dropEvent (QDropEvent *event) + { + if (event->mimeData ()->hasUrls ()) + { + foreach (QUrl url, event->mimeData ()->urls ()) + { + request_open_file (url.toLocalFile ()); + } + } + } + #endif diff -r cf3db95a75f0 -r 78fac67300e8 libgui/src/m-editor/file-editor.h --- a/libgui/src/m-editor/file-editor.h Thu Apr 24 07:13:37 2014 -0700 +++ b/libgui/src/m-editor/file-editor.h Thu Apr 24 08:41:30 2014 -0700 @@ -29,6 +29,10 @@ #include #include #include +#include + +#include +#include #include @@ -52,6 +56,7 @@ QMenu *get_mru_menu (void) { return _mru_file_menu; } QMenu *debug_menu (void); QToolBar *toolbar (void); + void insert_new_open_actions (QAction*,QAction*,QAction*); void set_focus (void); void handle_enter_debug_mode (void); @@ -104,6 +109,7 @@ void fetab_do_breakpoint_marker (bool insert, const QWidget* ID, int line = -1); void fetab_set_focus (const QWidget* ID); + void fetab_scintilla_command (const QWidget* ID, unsigned int sci_msg); void fetab_zoom_in (const QWidget* ID); void fetab_zoom_out (const QWidget* ID); @@ -124,41 +130,53 @@ void request_close_all_files (bool); void request_close_other_files (bool); void request_mru_open_file (QAction *action); - void request_print_file (void); + void request_print_file (bool); - void request_undo (void); - void request_redo (void); - void request_copy (void); - void request_cut (void); - void request_paste (void); - void request_selectall (void); + void request_undo (bool); + void request_redo (bool); + void request_copy (bool); + void request_cut (bool); + void request_paste (bool); + void request_selectall (bool); void request_context_help (bool); void request_context_doc (bool); void request_context_edit (bool); - void request_save_file (void); - void request_save_file_as (void); - void request_run_file (void); + void request_save_file (bool); + void request_save_file_as (bool); + void request_run_file (bool); void request_context_run (bool); - void request_toggle_bookmark (void); - void request_next_bookmark (void); - void request_previous_bookmark (void); - void request_remove_bookmark (void); + void request_toggle_bookmark (bool); + void request_next_bookmark (bool); + void request_previous_bookmark (bool); + void request_remove_bookmark (bool); + + void request_toggle_breakpoint (bool); + void request_next_breakpoint (bool); + void request_previous_breakpoint (bool); + void request_remove_breakpoint (bool); - void request_toggle_breakpoint (void); - void request_next_breakpoint (void); - void request_previous_breakpoint (void); - void request_remove_breakpoint (void); - - void request_comment_selected_text (void); - void request_uncomment_selected_text (void); + void request_delete_start_word (bool); + void request_delete_end_word (bool); + void request_delete_start_line (bool); + void request_delete_end_line (bool); + void request_delete_line (bool); + void request_copy_line (bool); + void request_cut_line (bool); + void request_duplicate_selection (bool); + void request_transpose_line (bool); - void request_indent_selected_text (void); - void request_unindent_selected_text (void); + void request_comment_selected_text (bool); + void request_uncomment_selected_text (bool); - void request_find (void); + void request_upper_case (bool); + void request_lower_case (bool); + void request_indent_selected_text (bool); + void request_unindent_selected_text (bool); - void request_goto_line (void); - void request_completion (void); + void request_find (bool); + + void request_goto_line (bool); + void request_completion (bool); void handle_file_name_changed (const QString& fileName, const QString& toolTip); @@ -180,8 +198,7 @@ // Tells the editor to react on changed settings. void notice_settings (const QSettings *settings); - // Tells the ditor to dis- or enable some shortcuts - void set_shortcuts (bool set_shortcuts); + void set_shortcuts (); void handle_visibility (bool visible); @@ -205,6 +222,11 @@ void zoom_out (bool); void zoom_normal (bool); +protected: + + void dragEnterEvent(QDragEnterEvent *event); + void dropEvent(QDropEvent *event); + private: bool is_editor_console_tabbed (); @@ -215,6 +237,8 @@ bool call_custom_editor (const QString& file_name = QString (), int line = -1); QWidget *find_tab_widget (const QString& openFileName) const; + QAction *add_action (QMenu *menu, const QIcon &icon, const QString &text, + const char *member); std::map editor_tab_map; @@ -224,9 +248,14 @@ QToolBar *_tool_bar; QMenu *_debug_menu; + QAction *_new_action; + QAction *_new_function_action; + QAction *_open_action; + + QAction *_upper_case_action; + QAction *_lower_case_action; QAction *_comment_selection_action; QAction *_uncomment_selection_action; - QAction *_indent_selection_action; QAction *_unindent_selection_action; @@ -241,6 +270,16 @@ QAction *_zoom_out_action; QAction *_zoom_normal_action; + QAction *_delete_start_word_action; + QAction *_delete_end_word_action; + QAction *_delete_start_line_action; + QAction *_delete_end_line_action; + QAction *_delete_line_action; + QAction *_copy_line_action; + QAction *_cut_line_action; + QAction *_duplicate_selection_action; + QAction *_transpose_line_action; + QAction *_find_action; QAction *_goto_line_action; QAction *_completion_action; @@ -252,9 +291,9 @@ QAction *_print_action; QAction *_run_action; - QAction *_context_run_action; + QAction *_run_selection_action; - QAction *_context_edit_action; + QAction *_edit_function_action; QAction *_save_action; QAction *_save_as_action; QAction *_close_action; @@ -267,6 +306,16 @@ QAction *_preferences_action; QAction *_styles_preferences_action; + QAction *_toggle_breakpoint_action; + QAction *_next_breakpoint_action; + QAction *_previous_breakpoint_action; + QAction *_remove_all_breakpoints_action; + + QMenu *_edit_cmd_menu; + QMenu *_edit_fmt_menu; + QMenu *_edit_nav_menu; + QMenu *_fileMenu; + QTabWidget *_tab_widget; int _marker_breakpoint; diff -r cf3db95a75f0 -r 78fac67300e8 libgui/src/m-editor/octave-qscintilla.cc --- a/libgui/src/m-editor/octave-qscintilla.cc Thu Apr 24 07:13:37 2014 -0700 +++ b/libgui/src/m-editor/octave-qscintilla.cc Thu Apr 24 08:41:30 2014 -0700 @@ -29,18 +29,33 @@ #ifdef HAVE_QSCINTILLA #include +#include #include #include "octave-qscintilla.h" #include "file-editor-tab.h" +#include "shortcut-manager.h" octave_qscintilla::octave_qscintilla (QWidget *p) : QsciScintilla (p) { - // disable zoom-in/out shortcuts, these are handled by octave - SendScintilla (QsciScintillaBase::SCI_CLEARCMDKEY, '+' + (QsciScintillaBase::SCMOD_CTRL << 16) ); - SendScintilla (QsciScintillaBase::SCI_CLEARCMDKEY, '-' + (QsciScintillaBase::SCMOD_CTRL << 16) ); - SendScintilla (QsciScintillaBase::SCI_CLEARCMDKEY, '/' + (QsciScintillaBase::SCMOD_CTRL << 16) ); + // clear scintilla edit shortcuts that are handled by the editor + QsciCommandSet *cmd_set = standardCommands (); + cmd_set->find (QsciCommand::SelectionDuplicate)->setKey (0); + cmd_set->find (QsciCommand::LineTranspose)->setKey (0); + cmd_set->find (QsciCommand::Undo)->setKey (0); + cmd_set->find (QsciCommand::Redo)->setKey (0); + cmd_set->find (QsciCommand::SelectionUpperCase)->setKey (0); + cmd_set->find (QsciCommand::SelectionLowerCase)->setKey (0); + cmd_set->find (QsciCommand::ZoomIn)->setKey (0); + cmd_set->find (QsciCommand::ZoomOut)->setKey (0); + cmd_set->find (QsciCommand::DeleteWordLeft)->setKey (0); + cmd_set->find (QsciCommand::DeleteWordRight)->setKey (0); + cmd_set->find (QsciCommand::DeleteLineLeft)->setKey (0); + cmd_set->find (QsciCommand::DeleteLineRight)->setKey (0); + cmd_set->find (QsciCommand::LineDelete)->setKey (0); + cmd_set->find (QsciCommand::LineCut)->setKey (0); + cmd_set->find (QsciCommand::LineCopy)->setKey (0); } octave_qscintilla::~octave_qscintilla () @@ -50,11 +65,11 @@ octave_qscintilla::get_global_textcursor_pos (QPoint *global_pos, QPoint *local_pos) { - long position = SendScintilla (QsciScintillaBase::SCI_GETCURRENTPOS); + long position = SendScintilla (SCI_GETCURRENTPOS); long point_x = SendScintilla - (QsciScintillaBase::SCI_POINTXFROMPOSITION,0,position); + (SCI_POINTXFROMPOSITION,0,position); long point_y = SendScintilla - (QsciScintillaBase::SCI_POINTYFROMPOSITION,0,position); + (SCI_POINTYFROMPOSITION,0,position); *local_pos = QPoint (point_x,point_y); // local cursor position *global_pos = mapToGlobal (*local_pos); // global position of cursor } diff -r cf3db95a75f0 -r 78fac67300e8 libgui/src/main-window.cc --- a/libgui/src/main-window.cc Thu Apr 24 07:13:37 2014 -0700 +++ b/libgui/src/main-window.cc Thu Apr 24 08:41:30 2014 -0700 @@ -894,7 +894,8 @@ main_window::closeEvent (QCloseEvent *e) { e->ignore (); - octave_link::post_event (this, &main_window::exit_callback); + if (confirm_exit_octave()) + octave_link::post_event (this, &main_window::exit_callback); } void @@ -1218,9 +1219,6 @@ connect (file_browser_window, SIGNAL (find_files_signal (const QString&)), this, SLOT (find_files (const QString&))); - connect (this, SIGNAL (set_widget_shortcuts_signal (bool)), - editor_window, SLOT (set_shortcuts (bool))); - connect_uiwidget_links (); setWindowTitle ("Octave"); @@ -1439,6 +1437,9 @@ tr ("Open...")); _open_action->setShortcutContext (Qt::ApplicationShortcut); + editor_window->insert_new_open_actions (_new_script_action, + _new_function_action, + _open_action); #ifdef HAVE_QSCINTILLA file_menu->addMenu (editor_window->get_mru_menu ()); @@ -2332,7 +2333,6 @@ } - emit set_widget_shortcuts_signal (set_shortcuts); } void @@ -2365,3 +2365,25 @@ { _clipboard->clear (QClipboard::Clipboard); } + +bool +main_window::confirm_exit_octave () +{ + bool closenow = true; + + QSettings *settings = resource_manager::get_settings (); + + if (settings->value ("prompt_to_exit", false ).toBool()) + { + int ans = QMessageBox::question (this, tr ("Octave"), + tr ("Are you sure you want to exit Octave?"), + QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok); + + if (ans != QMessageBox::Ok) + closenow = false; + + } + return closenow; +} + + diff -r cf3db95a75f0 -r 78fac67300e8 libgui/src/main-window.h --- a/libgui/src/main-window.h Thu Apr 24 07:13:37 2014 -0700 +++ b/libgui/src/main-window.h Thu Apr 24 08:41:30 2014 -0700 @@ -94,9 +94,8 @@ void pasteClipboard_signal (void); void selectAll_signal (void); - void set_widget_shortcuts_signal (bool); +public slots: -public slots: void report_status_message (const QString& statusMessage); void handle_save_workspace_request (void); void handle_load_workspace_request (const QString& file = QString ()); @@ -271,6 +270,8 @@ void execute_debug_callback (); + bool confirm_exit_octave (); + workspace_model *_workspace_model; // Toolbars. diff -r cf3db95a75f0 -r 78fac67300e8 libgui/src/settings-dialog.cc --- a/libgui/src/settings-dialog.cc Thu Apr 24 07:13:37 2014 -0700 +++ b/libgui/src/settings-dialog.cc Thu Apr 24 08:41:30 2014 -0700 @@ -118,6 +118,10 @@ ui->cb_widget_custom_style->setChecked ( settings->value ("DockWidgets/widget_title_custom_style",false).toBool ()); + // prompt on exit + ui->cb_prompt_to_exit->setChecked ( + settings->value ("prompt_to_exit",false).toBool ()); + // Octave startup ui->cb_restore_octave_dir->setChecked ( settings->value ("restore_octave_dir",false).toBool ()); @@ -538,6 +542,9 @@ // icon size settings->setValue ("toolbar_icon_size", ui->toolbar_icon_size->value ()); + // promp to exit + settings->setValue ( "prompt_to_exit", ui->cb_prompt_to_exit->isChecked ()); + // Octave startup settings->setValue ("restore_octave_dir", ui->cb_restore_octave_dir->isChecked ()); diff -r cf3db95a75f0 -r 78fac67300e8 libgui/src/settings-dialog.ui --- a/libgui/src/settings-dialog.ui Thu Apr 24 07:13:37 2014 -0700 +++ b/libgui/src/settings-dialog.ui Thu Apr 24 08:41:30 2014 -0700 @@ -103,6 +103,13 @@ + + + + Confirm before exiting + + + diff -r cf3db95a75f0 -r 78fac67300e8 libgui/src/shortcut-manager.cc --- a/libgui/src/shortcut-manager.cc Thu Apr 24 07:13:37 2014 -0700 +++ b/libgui/src/shortcut-manager.cc Thu Apr 24 08:41:30 2014 -0700 @@ -45,6 +45,8 @@ shortcut_manager::shortcut_manager () { setObjectName ("Shortcut_Manager"); + + _settings = resource_manager::get_settings (); } shortcut_manager::~shortcut_manager () @@ -78,6 +80,8 @@ shortcut_manager::do_init_data () { // actions of the main window + + // file init (tr ("New File"), "main_file:new_file", QKeySequence::New ); init (tr ("New Function"), "main_file:new_function", QKeySequence ("Ctrl+Shift+N") ); init (tr ("New Figure"), "main_file:new_figure", QKeySequence () ); @@ -87,6 +91,7 @@ init (tr ("Preferences"), "main_file:preferences", QKeySequence () ); init (tr ("Exit Octave"), "main_file:exit", QKeySequence::Quit ); + // edit init (tr ("Copy"), "main_edit:copy", QKeySequence::Copy); init (tr ("Paste"), "main_edit:paste", QKeySequence::Paste); init (tr ("Undo"), "main_edit:undo", QKeySequence::Undo); @@ -98,6 +103,8 @@ init (tr ("Clear Workspace"), "main_edit:clear_workspace", QKeySequence () ); // actions of the editor + + // file init (tr ("Edit Function"), "editor_file:edit_function", QKeySequence (Qt::ControlModifier + Qt::Key_E) ); init (tr ("Save File"), "editor_file:save", QKeySequence::Save ); init (tr ("Save File As"), "editor_file:save_as", QKeySequence::SaveAs ); @@ -106,6 +113,7 @@ init (tr ("Close Other"), "editor_file:close_other", QKeySequence () ); init (tr ("Print"), "editor_file:print", QKeySequence::Print ); + // edit init (tr ("Undo"), "editor_edit:undo", QKeySequence::Undo ); init (tr ("Redo"), "editor_edit:redo", QKeySequence::Redo ); init (tr ("Copy"), "editor_edit:copy", QKeySequence::Copy ); @@ -113,27 +121,58 @@ init (tr ("Paste"), "editor_edit:paste", QKeySequence::Paste ); init (tr ("Select All"), "editor_edit:select_all", QKeySequence::SelectAll ); init (tr ("Find and Replace"), "editor_edit:find_replace", QKeySequence::Find ); + + init (tr ("Delete to Start of Word"), "editor_edit:delete_start_word", QKeySequence::DeleteStartOfWord ); + init (tr ("Delete to End of Word"), "editor_edit:delete_end_word", QKeySequence::DeleteEndOfWord ); + init (tr ("Delete to Start of Line"), "editor_edit:delete_start_line", QKeySequence (Qt::ControlModifier + Qt::SHIFT + Qt::Key_Backspace) ); + init (tr ("Delete to End of Line"), "editor_edit:delete_end_line", QKeySequence (Qt::ControlModifier + Qt::SHIFT + Qt::Key_Delete) ); + init (tr ("Delete Line"), "editor_edit:delete_line", QKeySequence (Qt::ControlModifier + Qt::SHIFT + Qt::Key_L) ); + init (tr ("Copy Line"), "editor_edit:copy_line", QKeySequence (Qt::ControlModifier + Qt::SHIFT + Qt::Key_C) ); + init (tr ("Cut Line"), "editor_edit:cut_line", QKeySequence (Qt::ControlModifier + Qt::SHIFT + Qt::Key_X) ); + init (tr ("Duplicate Selection/Line"), "editor_edit:duplicate_selection", QKeySequence (Qt::ControlModifier + Qt::Key_D) ); + init (tr ("Transpose Line"), "editor_edit:transpose_line", QKeySequence (Qt::ControlModifier + Qt::Key_T) ); + init (tr ("Completion List"), "editor_edit:completion_list", QKeySequence (Qt::ControlModifier + Qt::Key_Space) ); + init (tr ("Comment Selection"), "editor_edit:comment_selection", QKeySequence (Qt::ControlModifier + Qt::Key_R) ); init (tr ("Uncomment Selection"), "editor_edit:uncomment_selection", QKeySequence (Qt::SHIFT + Qt::ControlModifier + Qt::Key_R) ); + init (tr ("Uppercase Selection"), "editor_edit:upper_case", QKeySequence (Qt::ControlModifier + Qt::Key_U) ); + init (tr ("Lowercase Selection"), "editor_edit:lower_case", QKeySequence (Qt::ControlModifier + Qt::AltModifier + Qt::Key_U) ); init (tr ("Indent Selection"), "editor_edit:indent_selection", QKeySequence (Qt::ControlModifier + Qt::Key_Tab) ); init (tr ("Unindent Selection"), "editor_edit:unindent_selection", QKeySequence (Qt::SHIFT + Qt::ControlModifier + Qt::Key_Tab) ); - init (tr ("Completion List"), "editor_edit:completion_list", QKeySequence (Qt::ControlModifier + Qt::Key_Space) ); + + init (tr ("Goto Line"), "editor_edit:goto_line", QKeySequence (Qt::ControlModifier+ Qt::Key_G) ); init (tr ("Toggle Bookmark"), "editor_edit:toggle_bookmark", QKeySequence (Qt::Key_F7) ); init (tr ("Next Bookmark"), "editor_edit:next_bookmark", QKeySequence (Qt::Key_F2) ); init (tr ("Previous Bookmark"), "editor_edit:previous_bookmark", QKeySequence (Qt::SHIFT + Qt::Key_F2) ); init (tr ("Remove All Bookmark"), "editor_edit:remove_bookmark", QKeySequence () ); - init (tr ("Goto Line"), "editor_edit:goto_line", QKeySequence (Qt::ControlModifier+ Qt::Key_G) ); + init (tr ("Preferences"), "editor_edit:preferences", QKeySequence () ); init (tr ("Styles Preferences"), "editor_edit:styles_preferences", QKeySequence () ); + // view + init (tr ("Zoom In"), "editor_view:zoom_in", QKeySequence::ZoomIn ); + init (tr ("Zoom Out"), "editor_view:zoom_out", QKeySequence::ZoomOut ); + init (tr ("Zoom Normal"), "editor_view:zoom_normal", QKeySequence (Qt::ControlModifier + Qt::Key_Slash) ); + + // debug + init (tr ("Toggle Breakpoint"), "editor_debug:toggle_breakpoint", QKeySequence () ); + init (tr ("Next Breakpoint"), "editor_debug:next_breakpoint", QKeySequence () ); + init (tr ("Previous Breakpoint"), "editor_debug:previous_breakpoint", QKeySequence () ); + init (tr ("Remove All Breakpoints"), "editor_debug:remove_breakpoints", QKeySequence () ); + + // run + init (tr ("Run File"), "editor_run:run_file", QKeySequence (Qt::Key_F5) ); + init (tr ("Run Selection"), "editor_run:run_selection", QKeySequence (Qt::Key_F9) ); + + // help + init (tr ("Help on Keyword"), "editor_help:help_keyword", QKeySequence::HelpContents ); + init (tr ("Document on Keyword"), "editor_help:doc_keyword", QKeySequence (Qt::SHIFT + Qt::Key_F1) ); } void shortcut_manager::init (QString description, QString key, QKeySequence def_sc) { - QSettings *settings = resource_manager::get_settings (); - - QKeySequence actual = QKeySequence (settings->value ("shortcuts/"+key, def_sc).toString ()); + QKeySequence actual = QKeySequence (_settings->value ("shortcuts/"+key, def_sc).toString ()); // append the new shortcut to the list shortcut_t shortcut_info; @@ -209,31 +248,28 @@ for (int i = 0; i < _sc.count (); i++) { - shortcut_t shortcut_info = _sc.at (i); + shortcut_t sc = _sc.at (i); - QTreeWidgetItem* section = _level_hash[shortcut_info.settings_key.section(':',0,0)]; + QTreeWidgetItem* section = _level_hash[sc.settings_key.section(':',0,0)]; QTreeWidgetItem* tree_item = new QTreeWidgetItem (section); - tree_item->setText (0, shortcut_info.description); - tree_item->setText (1, shortcut_info.default_sc); - tree_item->setText (2, shortcut_info.actual_sc); + tree_item->setText (0, sc.description); + tree_item->setText (1, sc.default_sc); + tree_item->setText (2, sc.actual_sc); _item_index_hash[tree_item] = i + 1; // index+1 to avoid 0 _index_item_hash[i] = tree_item; } + } void shortcut_manager::do_write_shortcuts () { - QSettings *settings = resource_manager::get_settings (); + for (int i = 0; i < _sc.count (); i++) + _settings->setValue("shortcuts/"+_sc.at (i).settings_key, _sc.at (i).actual_sc.toString ()); - settings->beginGroup ("shortcuts"); - for (int i = 0; i < _sc.count (); i++) - settings->setValue(_sc.at (i).settings_key, _sc.at (i).actual_sc.toString ()); - settings->endGroup (); - - settings->sync (); + _settings->sync (); delete _dialog; } @@ -241,12 +277,11 @@ void shortcut_manager::do_set_shortcut (QAction* action, const QString& key) { - QSettings *settings = resource_manager::get_settings (); + int index = _action_hash[key] - 1; - int index = _action_hash[key] - 1; if (index > -1 && index < _sc.count ()) - action->setShortcut ( - settings->value ("shortcuts/" + key, _sc.at (index).default_sc).toString ()); + action->setShortcut ( QKeySequence ( + _settings->value ("shortcuts/" + key, _sc.at (index).default_sc).toString ())); else qDebug () << "Key: " << key << " not found in _action_hash"; } @@ -359,7 +394,7 @@ shortcut_t double_shortcut = _sc.at (double_index); double_shortcut.actual_sc = QKeySequence (); _sc.replace (double_index, double_shortcut); - _index_item_hash[double_index]->setText (1, QKeySequence ()); + _index_item_hash[double_index]->setText (2, QKeySequence ()); } else return; diff -r cf3db95a75f0 -r 78fac67300e8 libgui/src/shortcut-manager.h --- a/libgui/src/shortcut-manager.h Thu Apr 24 07:13:37 2014 -0700 +++ b/libgui/src/shortcut-manager.h Thu Apr 24 08:41:30 2014 -0700 @@ -28,7 +28,7 @@ #include #include #include - +#include class enter_shortcut : public QLineEdit { @@ -133,6 +133,8 @@ QLabel *_label_default; int _handled_index; + QSettings *_settings; + }; diff -r cf3db95a75f0 -r 78fac67300e8 libinterp/corefcn/dot.cc --- a/libinterp/corefcn/dot.cc Thu Apr 24 07:13:37 2014 -0700 +++ b/libinterp/corefcn/dot.cc Thu Apr 24 08:41:30 2014 -0700 @@ -144,7 +144,7 @@ argx = argx.reshape (dimx); dimy = dimy.redim (1); argy = argy.reshape (dimy); - match = ! error_state; + match = ! error_state && (dimx == dimy); } if (match) @@ -264,6 +264,16 @@ %! assert (dot (x, y, 2), [17; 53]); %! assert (dot (x, y, 3), [5 12; 21 32]); +%% Test input validation +%!error dot () +%!error dot (1) +%!error dot (1,2,3,4) +%!error dot ({1,2}, [3,4]) +%!error dot ([1,2], {3,4}) +%!error dot ([1 2], [1 2 3]) +%!error dot ([1 2]', [1 2 3]') +%!error dot (ones (2,2), ones (2,3)) +%!error dot ([1 2], [1 2], 0) */ DEFUN (blkmm, args, , diff -r cf3db95a75f0 -r 78fac67300e8 libinterp/corefcn/gl2ps-renderer.cc --- a/libinterp/corefcn/gl2ps-renderer.cc Thu Apr 24 07:13:37 2014 -0700 +++ b/libinterp/corefcn/gl2ps-renderer.cc Thu Apr 24 08:41:30 2014 -0700 @@ -193,13 +193,14 @@ template static void -draw_pixels (GLsizei w, GLsizei h, GLenum format, const T *data) +draw_pixels (GLsizei w, GLsizei h, GLenum format, const T *data, float maxval) { OCTAVE_LOCAL_BUFFER (GLfloat, a, 3*w*h); - for (int i = 0; i < 3*w*h; i++) - a[i] = data[i]; - + // Convert to GL_FLOAT as it is the only type gl2ps accepts. + for (unsigned int i = 0; i < 3*w*h; i++) + a[i] = data[i] / maxval; + gl2psDrawPixels (w, h, 0, 0, format, GL_FLOAT, a); } @@ -207,10 +208,12 @@ glps_renderer::draw_pixels (GLsizei w, GLsizei h, GLenum format, GLenum type, const GLvoid *data) { - if (type == GL_UNSIGNED_SHORT) - ::draw_pixels (w, h, format, static_cast (data)); - else if (type == GL_UNSIGNED_BYTE) - ::draw_pixels (w, h, format, static_cast (data)); + // gl2psDrawPixels only supports the GL_FLOAT type. + // Other formats, such as uint8, must be converted first. + if (type == GL_UNSIGNED_BYTE) + ::draw_pixels (w, h, format, static_cast (data), 255.0f); + else if (type == GL_UNSIGNED_SHORT) + ::draw_pixels (w, h, format, static_cast (data), 65535.0f); else gl2psDrawPixels (w, h, 0, 0, format, type, data); } diff -r cf3db95a75f0 -r 78fac67300e8 scripts/plot/appearance/axis.m --- a/scripts/plot/appearance/axis.m Thu Apr 24 07:13:37 2014 -0700 +++ b/scripts/plot/appearance/axis.m Thu Apr 24 08:41:30 2014 -0700 @@ -343,7 +343,7 @@ ## Extend image data one pixel idx = strcmp (types, "image"); - if (! isempty (idx) && (ax == "x" || ax == "y")) + if (any (idx) && (ax == "x" || ax == "y")) imdata = data(idx); px = arrayfun (@__image_pixel_size__, kids(idx), "uniformoutput", false); ipx = ifelse (ax == "x", 1, 2);