Mercurial > hg > octave-nkf
changeset 19647:7934b56c8b7b
maint: Periodic merge of gui-release to default.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 30 Dec 2014 20:41:00 -0800 |
parents | 29b6d072b5e9 (current diff) 50aedabe6bfb (diff) |
children | e5a78897be9e bf27e21f0bfb |
files | libgui/src/m-editor/file-editor-interface.h libgui/src/m-editor/find-dialog.cc libgui/src/m-editor/octave-qscintilla.cc libgui/src/main-window.cc libgui/src/main-window.h libgui/src/octave-dock-widget.cc libgui/src/qtinfo/parser.cc libgui/src/settings-dialog.cc libgui/src/workspace-model.cc libinterp/corefcn/module.mk |
diffstat | 21 files changed, 542 insertions(+), 254 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp +++ b/libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp @@ -616,10 +616,12 @@ void QConsolePrivate::setScrollBufferSize (int value) { -// FIXME: not tested code follows -// CONSOLE_SCREEN_BUFFER_INFO sbi; -// GetConsoleScreenBufferInfo (m_stdOut, &sbi); -// m_bufferSize = QSize (sbi.dwSize.X, qMax (sbi.dwSize.Y, (SHORT)value)); + CONSOLE_SCREEN_BUFFER_INFO sbi; + GetConsoleScreenBufferInfo (m_stdOut, &sbi); + + m_bufferSize = QSize (sbi.dwSize.X, (SHORT)value); + + updateConsoleSize (true); } void QConsolePrivate::drawTextBackground (QPainter& p, int cx1, int cy1, @@ -1733,8 +1735,7 @@ void QWinTerminalImpl::setScrollBufferSize(int value) { -// FIXME: not tested code follows -// d->setScrollBufferSize (value); + d->setScrollBufferSize (value); }
--- a/libgui/src/documentation-dock-widget.cc +++ b/libgui/src/documentation-dock-widget.cc @@ -60,10 +60,9 @@ void documentation_dock_widget::showDoc (const QString &name) { - // show the doc pane + // show the doc pane without focus for carrying on typing in the console if (!isVisible ()) setVisible (true); - setFocus (); raise (); _webinfo->load_ref (name);
--- a/libgui/src/m-editor/file-editor-interface.h +++ b/libgui/src/m-editor/file-editor-interface.h @@ -60,7 +60,7 @@ virtual void handle_edit_file_request (const QString& file) = 0; - virtual void set_focus () = 0; + virtual bool check_closing (int closing_state) = 0; virtual void empty_script (bool, bool) = 0;
--- a/libgui/src/m-editor/file-editor-tab.cc +++ b/libgui/src/m-editor/file-editor-tab.cc @@ -69,7 +69,7 @@ { QString directory = directory_arg; _lexer_apis = 0; - _app_closing = false; + _app_closing = 0; // app is not closing _is_octave_file = true; _modal_dialog = false; @@ -169,9 +169,6 @@ connect (_edit_area, SIGNAL (copyAvailable (bool)), this, SLOT (handle_copy_available (bool))); - connect (_edit_area, SIGNAL (qsci_has_focus_signal (bool)), - this, SLOT (edit_area_has_focus (bool))); - connect (&_file_system_watcher, SIGNAL (fileChanged (const QString&)), this, SLOT (file_has_changed (const QString&))); @@ -1027,14 +1024,15 @@ _find_dialog->setWindowModality (Qt::NonModal); _find_dialog_geometry = _find_dialog->geometry (); } - - if (!_find_dialog->isVisible ()) + else if (!_find_dialog->isVisible ()) { _find_dialog->setGeometry (_find_dialog_geometry); - _find_dialog->show (); - _find_dialog_is_visible = true; + QPoint p = _find_dialog->pos (); + _find_dialog->move(p.x ()+10, p.y ()+10); } + _find_dialog->show (); + _find_dialog_is_visible = true; _find_dialog->activateWindow (); _find_dialog->init_search_text (); @@ -1243,13 +1241,24 @@ QMessageBox::Discard; QString available_actions; - if (_app_closing) - available_actions = tr ("Do you want to save or discard the changes?"); - else + switch (_app_closing) { - buttons = buttons | QMessageBox::Cancel; // cancel is allowed - available_actions - = tr ("Do you want to cancel closing, save or discard the changes?"); + case -1: // octave is exiting and so does the gui + available_actions = + tr ("Do you want to save or discard the changes?"); + break; + + case 1: // gui is exiting + available_actions = + tr ("Do you want to cancel exiting octave, save or discard the changes?"); + buttons = buttons | QMessageBox::Cancel; + break; + + case 0: // tab is closing + available_actions = + tr ("Do you want to cancel closing, save or discard the changes?"); + buttons = buttons | QMessageBox::Cancel; + break; } QString file; @@ -1896,6 +1905,10 @@ _edit_area->setTabWidth (settings->value ("editor/tab_width",2).toInt ()); + _edit_area->SendScintilla (QsciScintillaBase::SCI_SETHSCROLLBAR, + settings->value ("editor/show_hscroll_bar",true).toBool ()); + _edit_area->SendScintilla (QsciScintillaBase::SCI_SETSCROLLWIDTH,-1); + _long_title = settings->value ("editor/longWindowTitle", false).toBool (); update_window_title (_edit_area->isModified ()); @@ -1917,14 +1930,16 @@ _edit_area->setMarginWidth (2, "1"+QString::number (_edit_area->lines ())); } -void -file_editor_tab::conditional_close (const QWidget *ID, bool app_closing) +// the following close request was changed from a signal slot into a +// normal function because we need the return value from close whether +// the tab really was closed (for canceling exiting octave). +// When emitting a signal, only the return value from the last slot +// goes back to the sender +bool +file_editor_tab::conditional_close (int app_closing) { - if (ID != this) - return; - _app_closing = app_closing; - close (); + return close (); } void @@ -1947,6 +1962,8 @@ if (_find_dialog && _find_dialog_is_visible) { _find_dialog->setGeometry (_find_dialog_geometry); + QPoint p = _find_dialog->pos (); + _find_dialog->move(p.x ()+10, p.y ()+10); _find_dialog->show (); } @@ -2075,12 +2092,6 @@ emit create_context_menu_tab_signal (menu); } -void -file_editor_tab::edit_area_has_focus (bool focus) -{ - emit set_global_edit_shortcuts_signal (! focus); -} - QString file_editor_tab::get_function_name () {
--- a/libgui/src/m-editor/file-editor-tab.h +++ b/libgui/src/m-editor/file-editor-tab.h @@ -51,6 +51,10 @@ octave_qscintilla *qsci_edit_area () { return _edit_area; } + // Will initiate close if associated with the identifier tag. + bool conditional_close (int app_closing = 0); // default 0: close tab only + + public slots: void update_window_title (bool modified); @@ -61,9 +65,6 @@ // Tells the editor tab to react on changed settings. void notice_settings (const QSettings *settings); - // Will initiate close if associated with the identifier tag. - void conditional_close (const QWidget *ID, bool app_closing = false); - // Change to a different editor tab by identifier tag. void change_editor_state (const QWidget *ID); @@ -120,7 +121,6 @@ void file_has_changed (const QString& fileName); void execute_command_in_terminal (const QString& command); - void edit_area_has_focus (bool foucs); void create_context_menu (QMenu *); void handle_context_menu_edit (const QString&); @@ -232,7 +232,7 @@ bool _long_title; bool _copy_available; - bool _app_closing; + int _app_closing; // -1: octave exits, 1: exit request in gui, 0: no exit bool _is_octave_file; bool _modal_dialog; bool _always_reload_changed_files;
--- a/libgui/src/m-editor/file-editor.cc +++ b/libgui/src/m-editor/file-editor.cc @@ -63,6 +63,20 @@ file_editor::~file_editor (void) { + // Close open tabs, if existing. In this case app closing must be + // initiated by octave. All tabs will be definetly closed and the + // user can not cancel exiting (close state -1) + if (_tab_widget->count ()) + check_closing (-1); + + if (_mru_file_menu) + delete _mru_file_menu; +} + +bool +file_editor::check_closing (int closing_state) +{ + // Save open files for restoring in next session; this only is possible QSettings *settings = resource_manager::get_settings (); // Have all file editor tabs signal what their file names are. @@ -82,31 +96,29 @@ settings->setValue ("editor/savedSessionTabs", fetFileNames); settings->sync (); + // Close all tabs. If exit is requested by the gui (octave still running) + // check whether closing a tab is successful or whether user wnats to cancel + // exiting the program. Return false in the latter case. + file_editor_tab *editor_tab; + for (int index = _tab_widget->count ()-1; index >= 0; index--) { - // true: app closing - emit fetab_close_request (_tab_widget->widget (index), true); + editor_tab = static_cast <file_editor_tab *> (_tab_widget->widget (index)); + if ((! editor_tab->conditional_close (closing_state)) && closing_state == 1) + return false; } - if (_mru_file_menu) - delete _mru_file_menu; + // Here, we really want to exit and all tabs are closed + return true; } + void file_editor::focus (void) { - set_focus (); -} + octave_dock_widget::focus (); -// set focus to editor and its current tab -void -file_editor::set_focus (void) -{ - if (!isVisible ()) - setVisible (true); - setFocus (); - activateWindow (); - raise (); +// set focus to current tab QWidget *fileEditorTab = _tab_widget->currentWidget (); if (fileEditorTab) emit fetab_set_focus (fileEditorTab); @@ -153,7 +165,7 @@ { add_file_editor_tab (fileEditorTab, ""); // new tab with empty title fileEditorTab->new_file (commands); // title is updated here - set_focus (); // focus editor and new tab + focus (); // focus editor and new tab } } @@ -351,7 +363,7 @@ if (! ((breakpoint_marker || debug_pointer) && is_editor_console_tabbed ())) { emit fetab_set_focus (tab); - set_focus (); + focus (); } } else @@ -458,7 +470,7 @@ if (! ((breakpoint_marker || debug_pointer) && is_editor_console_tabbed ())) { // really show editor and the current editor tab - set_focus (); + focus (); emit file_loaded_signal (); } } @@ -919,26 +931,39 @@ void file_editor::request_close_file (bool) { - emit fetab_close_request (_tab_widget->currentWidget ()); + file_editor_tab *editor_tab = + static_cast <file_editor_tab *> (_tab_widget->currentWidget ()); + editor_tab->conditional_close (0); // 0: app is not closing, only tab } void file_editor::request_close_all_files (bool) { + file_editor_tab *editor_tab; + // loop over all tabs starting from last one otherwise deletion changes index for (int index = _tab_widget->count ()-1; index >= 0; index--) - emit fetab_close_request (_tab_widget->widget (index)); + { + editor_tab = static_cast <file_editor_tab *> (_tab_widget->widget (index)); + editor_tab->conditional_close (0); // 0: app is not closing, only tab + } } void file_editor::request_close_other_files (bool) { + file_editor_tab *editor_tab; QWidget *tabID = _tab_widget->currentWidget (); + // loop over all tabs starting from last one otherwise deletion changes index for (int index = _tab_widget->count ()-1; index >= 0; index--) { if (tabID != _tab_widget->widget (index)) - emit fetab_close_request (_tab_widget->widget (index)); + { + editor_tab = + static_cast <file_editor_tab *> (_tab_widget->widget (index)); + editor_tab->conditional_close (0); // 0: app is not closing, only tab + } } } @@ -946,12 +971,9 @@ void file_editor::handle_tab_close_request (int index) { - // Signal to the tabs a request to close whomever matches the identifying - // tag (i.e., unique widget pointer). The reason for this indirection is - // that it will enable a file editor widget to toss up a non-static - // dialog box and later signal that it wants to be removed. - QWidget *tabID = _tab_widget->widget (index); - emit fetab_close_request (tabID); + file_editor_tab *editor_tab = + static_cast <file_editor_tab *> (_tab_widget->widget (index)); + editor_tab->conditional_close (0); // 0: app is not closing, only tab } void @@ -1596,9 +1618,6 @@ connect (this, SIGNAL (fetab_settings_changed (const QSettings *)), f, SLOT (notice_settings (const QSettings *))); - connect (this, SIGNAL (fetab_close_request (const QWidget*,bool)), - f, SLOT (conditional_close (const QWidget*,bool))); - connect (this, SIGNAL (fetab_change_request (const QWidget*)), f, SLOT (change_editor_state (const QWidget*)));
--- a/libgui/src/m-editor/file-editor.h +++ b/libgui/src/m-editor/file-editor.h @@ -58,18 +58,15 @@ QToolBar *toolbar (void); void insert_new_open_actions (QAction*,QAction*,QAction*); - void set_focus (void); void handle_enter_debug_mode (void); void handle_exit_debug_mode (void); void check_actions (void); void empty_script (bool startup, bool visible); - void enable_menu_shortcuts (bool enable); signals: void fetab_settings_changed (const QSettings *settings); - void fetab_close_request (const QWidget* ID, bool app_closing = false); void fetab_change_request (const QWidget* ID); void fetab_file_name_query (const QWidget* ID); // Save is a ping-pong type of communication @@ -116,7 +113,10 @@ void file_loaded_signal (); public slots: + void focus (void); + void enable_menu_shortcuts (bool); + bool check_closing (int closing_state); void request_new_file (const QString& commands); void request_new_script (const QString& commands);
--- a/libgui/src/m-editor/find-dialog.cc +++ b/libgui/src/m-editor/find-dialog.cc @@ -175,14 +175,11 @@ _rep_active = false; // move dialog to side of the parent if there is room on the desktop to do so. - QWidget * desktop = QApplication::desktop (); - int xp = p->x () + p->frameGeometry ().width (); - int yp= p->y (); - if (desktop != 0 && sizeHint ().isValid ()) - { - if (xp + sizeHint ().width () > desktop->width ()) - xp = desktop->width () - sizeHint ().width (); - } + int xp = p->x () +20; + int yp = p->y () + p->frameGeometry ().height () - sizeHint ().height () -20; + + if (yp < 0) + yp = 0; move (xp, yp);
--- a/libgui/src/m-editor/octave-qscintilla.cc +++ b/libgui/src/m-editor/octave-qscintilla.cc @@ -279,20 +279,6 @@ } void -octave_qscintilla::focusInEvent (QFocusEvent *focusEvent) -{ - emit qsci_has_focus_signal (true); - QsciScintilla::focusInEvent(focusEvent); -} - -void -octave_qscintilla::focusOutEvent (QFocusEvent *focusEvent) -{ - emit qsci_has_focus_signal (false); - QsciScintilla::focusOutEvent(focusEvent); -} - -void octave_qscintilla::text_changed () { emit status_update (isUndoAvailable (), isRedoAvailable ());
--- a/libgui/src/m-editor/octave-qscintilla.h +++ b/libgui/src/m-editor/octave-qscintilla.h @@ -67,9 +67,6 @@ protected: - void focusInEvent (QFocusEvent *focusEvent); - void focusOutEvent (QFocusEvent *focusEvent); - private: QString _word_at_cursor;
--- a/libgui/src/main-window.cc +++ b/libgui/src/main-window.cc @@ -103,6 +103,7 @@ bool connect_to_web = true; QDateTime last_checked; int serial = 0; + _active_dock = 0; if (settings) { @@ -158,6 +159,46 @@ delete _cmd_queue; } +// catch focus changes and determine the active dock widget +void +main_window::focus_changed (QWidget *, QWidget *new_widget) +{ + octave_dock_widget* dock = 0; + QWidget *w_new = new_widget; // get a copy of new focus widget + QWidget *start = w_new; // Save it as start of our search + int count = 0; // fallback to prevent endless loop + + while (w_new && w_new != _main_tool_bar && count < 100) + { + dock = qobject_cast <octave_dock_widget *> (w_new); + if (dock) + break; // it is a QDockWidget ==> exit loop + + w_new = qobject_cast <QWidget *> (w_new->previousInFocusChain ()); + if (w_new == start) + break; // we have arrived where we began ==> exit loop + + count++; + } + + // if new dock has focus, emit signal and store active focus + if (dock != _active_dock) + { + // signal to all dock widgets for updating the style + emit active_dock_changed (_active_dock, dock); + + // if editor gets/loses focus, shortcuts and menus have to be updated + octave_dock_widget *edit_dock_widget = + static_cast <octave_dock_widget *> (editor_window); + if (edit_dock_widget == dock) + emit editor_focus_changed (true); + else if (edit_dock_widget == _active_dock) + emit editor_focus_changed (false); + + _active_dock = dock; + } +} + bool main_window::command_window_has_focus (void) const { @@ -1234,9 +1275,18 @@ connect (qApp, SIGNAL (aboutToQuit ()), this, SLOT (prepare_to_exit ())); + connect (qApp, SIGNAL (focusChanged (QWidget*, QWidget*)), + this, SLOT(focus_changed (QWidget*, QWidget*))); + connect (this, SIGNAL (settings_changed (const QSettings *)), this, SLOT (notice_settings (const QSettings *))); + connect (this, SIGNAL (editor_focus_changed (bool)), + this, SLOT (set_global_edit_shortcuts (bool))); + + connect (this, SIGNAL (editor_focus_changed (bool)), + editor_window, SLOT (enable_menu_shortcuts (bool))); + connect (file_browser_window, SIGNAL (load_file_signal (const QString&)), this, SLOT (handle_load_workspace_request (const QString&))); @@ -2268,30 +2318,27 @@ } void -main_window::set_global_edit_shortcuts (bool enable) +main_window::set_global_edit_shortcuts (bool editor_has_focus) { // this slot is called when editor gets/loses focus - if (enable) - { // editor loses focus, set the global shortcuts - // and disable the editor's menu - shortcut_manager::set_shortcut (_copy_action, "main_edit:copy"); - shortcut_manager::set_shortcut (_paste_action, "main_edit:paste"); - shortcut_manager::set_shortcut (_undo_action, "main_edit:undo"); - shortcut_manager::set_shortcut (_select_all_action, "main_edit:select_all"); - } - else + if (editor_has_focus) { // disable shortcuts that are also provided by the editor itself - // and enable editor's menu QKeySequence no_key = QKeySequence (); _copy_action->setShortcut (no_key); _paste_action->setShortcut (no_key); _undo_action->setShortcut (no_key); _select_all_action->setShortcut (no_key); } - - // enable/disable the main and the editor's menu shortcuts (alt-key) - editor_window->enable_menu_shortcuts (! enable); - enable_menu_shortcuts (enable); + else + { // editor loses focus, set the global shortcuts + shortcut_manager::set_shortcut (_copy_action, "main_edit:copy"); + shortcut_manager::set_shortcut (_paste_action, "main_edit:paste"); + shortcut_manager::set_shortcut (_undo_action, "main_edit:undo"); + shortcut_manager::set_shortcut (_select_all_action, "main_edit:select_all"); + } + + // dis-/enable global menu depending on editor's focus + enable_menu_shortcuts (! editor_has_focus); } void @@ -2461,9 +2508,12 @@ QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok); if (ans != QMessageBox::Ok) - closenow = false; + return false; } + + closenow = editor_window->check_closing (1); // 1: exit request from gui + return closenow; }
--- a/libgui/src/main-window.h +++ b/libgui/src/main-window.h @@ -80,6 +80,10 @@ void focus_command_window (void); signals: + + void active_dock_changed (octave_dock_widget *, octave_dock_widget *); + void editor_focus_changed (bool); + void settings_changed (const QSettings *); void init_terminal_size_signal (void); void new_file_signal (const QString&); @@ -98,6 +102,9 @@ public slots: + void focus_changed (QWidget *w_old, QWidget *w_new); + + void report_status_message (const QString& statusMessage); void handle_save_workspace_request (void); void handle_load_workspace_request (const QString& file = QString ()); @@ -311,6 +318,7 @@ list.append (static_cast<octave_dock_widget *> (workspace_window)); return list; } + octave_dock_widget *_active_dock; QString _release_notes_icon;
--- a/libgui/src/octave-dock-widget.cc +++ b/libgui/src/octave-dock-widget.cc @@ -49,6 +49,9 @@ connect (p, SIGNAL (settings_changed (const QSettings*)), this, SLOT (handle_settings (const QSettings*))); + connect (p, SIGNAL (active_dock_changed (octave_dock_widget*, octave_dock_widget*)), + this, SLOT (handle_active_dock_changed (octave_dock_widget*, octave_dock_widget*))); + #if defined (Q_OS_WIN32) // windows: add an extra title bar that persists when floating @@ -283,45 +286,45 @@ } void -octave_dock_widget::handle_settings (const QSettings *settings) +octave_dock_widget::set_style (bool active) { QString css; QString css_button; QString dock_icon; + QString icon_col = _icon_color; + if (_floating) dock_icon = "widget-dock"; else dock_icon = "widget-undock"; - if (settings->value ("DockWidgets/widget_title_custom_style",false).toBool ()) + if (_custom_style) { - QColor default_var = QColor (0,0,0); - QColor fg_color = settings->value ("Dockwidgets/title_fg_color", - default_var).value<QColor> (); - - default_var = QColor (255,255,255); - QColor bg_color = settings->value ("Dockwidgets/title_bg_color", - default_var).value<QColor> (); + QColor bg_col, fg_col; - int r, g, b; - QColor bg_color_light = bg_color.lighter (); - - bg_color.getRgb (&r, &g, &b); - if (r+g+b < 400) - _icon_color = "-light"; + if (active) + { + bg_col = _bg_color_active; + fg_col = _fg_color_active; + icon_col = _icon_color_active; + } else - _icon_color = ""; + { + bg_col = _bg_color; + fg_col = _fg_color; + icon_col = _icon_color; + } QString background = QString ("background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1," " stop: 0 %1, stop: 0.75 %2, stop: 0.9 %2, stop: 1.0 %1);"). - arg (bg_color_light.name ()). - arg (bg_color.name ()); + arg (bg_col.lighter ().name ()). + arg (bg_col.name ()); #if defined (Q_OS_WIN32) - css = background + QString (" color: %1 ;").arg (fg_color.name ()); + css = background + QString (" color: %1 ;").arg (fg_col.name ()); #else css = QString ("QDockWidget::title { " + background + " text-align: center left;" @@ -332,8 +335,8 @@ "QDockWidget::close-button," "QDockWidget::float-button { border: 0px;}" ). - arg (fg_color.name ()). - arg (_icon_color); + arg (fg_col.name ()). + arg (icon_col); #endif } else @@ -357,13 +360,49 @@ css_button = QString ("background: transparent; border: 0px;"); _dock_button->setStyleSheet (css_button); _close_button->setStyleSheet (css_button); - _dock_action->setIcon (QIcon (":/actions/icons/"+dock_icon+_icon_color+".png")); - _close_action->setIcon (QIcon (":/actions/icons/widget-close"+_icon_color+".png")); + _dock_action->setIcon (QIcon (":/actions/icons/" + dock_icon + icon_col + ".png")); + _close_action->setIcon (QIcon (":/actions/icons/widget-close" + dock_icon + icon_col + ".png")); #else setStyleSheet (css); #endif +} + +void +octave_dock_widget::handle_settings (const QSettings *settings) +{ + _custom_style = + settings->value ("DockWidgets/widget_title_custom_style",false).toBool (); + + QColor default_var = QColor (0,0,0); + _fg_color = settings->value ("Dockwidgets/title_fg_color", + default_var).value<QColor> (); + default_var = QColor (0,0,0); + _fg_color_active = settings->value ("Dockwidgets/title_fg_color_active", + default_var).value<QColor> (); + + default_var = QColor (255,255,255); + _bg_color = settings->value ("Dockwidgets/title_bg_color", + default_var).value<QColor> (); + default_var = QColor (192,192,192); + _bg_color_active = settings->value ("Dockwidgets/title_bg_color_active", + default_var).value<QColor> (); + + int r, g, b; + _bg_color.getRgb (&r, &g, &b); + if (r+g+b < 400) + _icon_color = "-light"; + else + _icon_color = ""; + + _bg_color_active.getRgb (&r, &g, &b); + if (r+g+b < 400) + _icon_color_active = "-light"; + else + _icon_color_active = ""; notice_settings (settings); // call individual handler + + set_style (false); } bool octave_dock_widget::eventFilter(QObject *obj, QEvent *e) @@ -376,3 +415,20 @@ return QDockWidget::eventFilter (obj,e); } + +void +octave_dock_widget::handle_active_dock_changed (octave_dock_widget *w_old, + octave_dock_widget *w_new) +{ + if (_custom_style && this == w_old) + { + set_style (false); + update (); + } + + if (_custom_style && this == w_new) + { + set_style (true); + update (); + } +} \ No newline at end of file
--- a/libgui/src/octave-dock-widget.h +++ b/libgui/src/octave-dock-widget.h @@ -84,6 +84,8 @@ } void handle_settings (const QSettings*); + void handle_active_dock_changed (octave_dock_widget*, octave_dock_widget*); + QMainWindow *main_win () { return _parent; } protected slots: @@ -115,9 +117,17 @@ private: + void set_style (bool active); + QMainWindow *_parent; // store the parent since we are reparenting to 0 bool _floating; + bool _custom_style; + QColor _bg_color; + QColor _bg_color_active; + QColor _fg_color; + QColor _fg_color_active; QString _icon_color; + QString _icon_color_active; #if defined (Q_OS_WIN32) QWidget *_title_widget;
--- a/libgui/src/qtinfo/parser.cc +++ b/libgui/src/qtinfo/parser.cc @@ -115,6 +115,10 @@ return ref.pos-_node_map [ref._node_name].pos; } + if (_node_map.contains (node)) + { + return 0; // node: show from the beginning + } return -1; } @@ -654,8 +658,25 @@ { // found ref, so return its name text = "XREF" + ref_name; + break; } } + + if (text.isEmpty ()) // try the statement-nodes + { + QHash<QString, node_map_item>::iterator itn; + for (itn=_node_map.begin (); itn!=_node_map.end (); ++itn) + { + QString k = itn.key (); + if (k == "The " + ref_name + " Statement") + { + // found ref, so return its name + text = k; + break; + } + } + } + return text; }
--- a/libgui/src/settings-dialog.cc +++ b/libgui/src/settings-dialog.cc @@ -106,6 +106,15 @@ connect (ui->cb_widget_custom_style, SIGNAL (toggled (bool)), _widget_title_bg_color, SLOT (setEnabled (bool))); + default_var = QColor (192,192,192); + QColor bg_color_active = settings->value ("Dockwidgets/title_bg_color_active", + default_var).value<QColor> (); + _widget_title_bg_color_active = new color_picker (bg_color_active); + _widget_title_bg_color_active->setEnabled (false); + ui->layout_widget_bgtitle_active->addWidget (_widget_title_bg_color_active,0); + connect (ui->cb_widget_custom_style, SIGNAL (toggled (bool)), + _widget_title_bg_color_active, SLOT (setEnabled (bool))); + default_var = QColor (0,0,0); QColor fg_color = settings->value ("Dockwidgets/title_fg_color", default_var).value<QColor> (); @@ -115,6 +124,15 @@ connect (ui->cb_widget_custom_style, SIGNAL (toggled (bool)), _widget_title_fg_color, SLOT (setEnabled (bool))); + default_var = QColor (0,0,0); + QColor fg_color_active = settings->value ("Dockwidgets/title_fg_color_active", + default_var).value<QColor> (); + _widget_title_fg_color_active = new color_picker (fg_color_active); + _widget_title_fg_color_active->setEnabled (false); + ui->layout_widget_fgtitle_active->addWidget (_widget_title_fg_color_active,0); + connect (ui->cb_widget_custom_style, SIGNAL (toggled (bool)), + _widget_title_fg_color_active, SLOT (setEnabled (bool))); + ui->cb_widget_custom_style->setChecked ( settings->value ("DockWidgets/widget_title_custom_style",false).toBool ()); @@ -188,6 +206,9 @@ settings->value ("editor/show_white_space_indent",false).toBool ()); ui->cb_show_eol->setChecked ( settings->value ("editor/show_eol_chars",false).toBool () ); + ui->cb_show_hscrollbar->setChecked ( + settings->value ("editor/show_hscroll_bar",true).toBool ()); + #ifdef HAVE_QSCINTILLA #if defined (Q_OS_WIN32) int eol_mode = QsciScintilla::EolWindows; @@ -600,8 +621,12 @@ ui->cb_widget_custom_style->isChecked ()); settings->setValue ("Dockwidgets/title_bg_color", _widget_title_bg_color->color ()); + settings->setValue ("Dockwidgets/title_bg_color_active", + _widget_title_bg_color_active->color ()); settings->setValue ("Dockwidgets/title_fg_color", _widget_title_fg_color->color ()); + settings->setValue ("Dockwidgets/title_fg_color_active", + _widget_title_fg_color_active->color ()); // icon size settings->setValue ("toolbar_icon_size", ui->toolbar_icon_size->value ()); @@ -657,6 +682,8 @@ ui->editor_ws_indent_checkbox->isChecked ()); settings->setValue ("editor/show_eol_chars", ui->cb_show_eol->isChecked ()); + settings->setValue ("editor/show_hscroll_bar", + ui->cb_show_hscrollbar->isChecked ()); settings->setValue ("editor/default_eol_mode", ui->combo_eol_mode->currentIndex ()); settings->setValue ("editor/auto_indent",
--- a/libgui/src/settings-dialog.h +++ b/libgui/src/settings-dialog.h @@ -75,7 +75,9 @@ void write_terminal_colors (QSettings *settings); color_picker *_widget_title_bg_color; + color_picker *_widget_title_bg_color_active; color_picker *_widget_title_fg_color; + color_picker *_widget_title_fg_color_active; color_picker *_editor_current_line_color; };
--- a/libgui/src/settings-dialog.ui +++ b/libgui/src/settings-dialog.ui @@ -70,6 +70,9 @@ <property name="text"> <string>Dock widget title bar</string> </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> </widget> </item> <item row="1" column="1"> @@ -101,6 +104,9 @@ <property name="text"> <string>Icon size</string> </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> </widget> </item> <item row="6" column="0"> @@ -110,88 +116,6 @@ </property> </widget> </item> - <item row="4" column="1"> - <layout class="QHBoxLayout" name="horizontalLayout_4"> - <item> - <widget class="QCheckBox" name="cb_widget_custom_style"> - <property name="text"> - <string>Custom style</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_22"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QLabel" name="label_bgtitle"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>Background color</string> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="layout_widget_bgtitle"/> - </item> - <item> - <spacer name="horizontalSpacer_23"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>12</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QLabel" name="label_fgtitle"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>Text color</string> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="layout_widget_fgtitle"/> - </item> - <item> - <spacer name="horizontalSpacer_21"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> <item row="2" column="1"> <layout class="QHBoxLayout" name="horizontalLayout_6"> <item> @@ -290,6 +214,130 @@ </property> </widget> </item> + <item row="4" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout_4"> + <item> + <layout class="QGridLayout" name="gridLayout_13"> + <item row="1" column="2"> + <widget class="QLabel" name="label_fgtitle"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Text inactive</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="1" column="9"> + <widget class="QLabel" name="label_fgtitle_active"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Active</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QCheckBox" name="cb_widget_custom_style"> + <property name="text"> + <string>Custom style</string> + </property> + </widget> + </item> + <item row="0" column="7"> + <spacer name="horizontalSpacer_23"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>12</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="0" column="1"> + <spacer name="horizontalSpacer_22"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="0" column="9"> + <widget class="QLabel" name="label_bgtitle_active"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Active</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="1" column="4"> + <layout class="QHBoxLayout" name="layout_widget_fgtitle"/> + </item> + <item row="0" column="4"> + <layout class="QHBoxLayout" name="layout_widget_bgtitle"/> + </item> + <item row="0" column="2"> + <widget class="QLabel" name="label_bgtitle"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Background inactive</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="0" column="10"> + <layout class="QHBoxLayout" name="layout_widget_bgtitle_active"/> + </item> + <item row="1" column="10"> + <layout class="QHBoxLayout" name="layout_widget_fgtitle_active"/> + </item> + </layout> + </item> + <item> + <spacer name="horizontalSpacer_21"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> </layout> </item> </layout> @@ -404,9 +452,9 @@ <property name="geometry"> <rect> <x>0</x> - <y>-256</y> + <y>0</y> <width>662</width> - <height>634</height> + <height>661</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_16"> @@ -734,6 +782,19 @@ </item> </layout> </item> + <item row="9" column="0"> + <widget class="QCheckBox" name="cb_show_hscrollbar"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>Show horizontal scroll bar</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> </layout> </item> <item> @@ -2723,5 +2784,37 @@ </hint> </hints> </connection> + <connection> + <sender>cb_widget_custom_style</sender> + <signal>toggled(bool)</signal> + <receiver>label_bgtitle_active</receiver> + <slot>setEnabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>260</x> + <y>190</y> + </hint> + <hint type="destinationlabel"> + <x>525</x> + <y>190</y> + </hint> + </hints> + </connection> + <connection> + <sender>cb_widget_custom_style</sender> + <signal>toggled(bool)</signal> + <receiver>label_fgtitle_active</receiver> + <slot>setEnabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>260</x> + <y>190</y> + </hint> + <hint type="destinationlabel"> + <x>533</x> + <y>214</y> + </hint> + </hints> + </connection> </connections> </ui>
--- a/libgui/src/workspace-model.cc +++ b/libgui/src/workspace-model.cc @@ -244,8 +244,6 @@ _complex_flags = complex_flags; update_table (); - - emit model_changed (); } void @@ -253,8 +251,6 @@ { clear_data (); update_table (); - - emit model_changed (); } void
--- a/libgui/src/workspace-view.cc +++ b/libgui/src/workspace-view.cc @@ -38,6 +38,7 @@ #include "workspace-view.h" #include "resource-manager.h" +#include "symtab.h" workspace_view::workspace_view (QWidget *p) : octave_dock_widget (p), view (new QTableView (this)) @@ -106,29 +107,38 @@ QDockWidget::closeEvent (e); } +QString +workspace_view::get_var_name (QModelIndex index) +{ + index = index.sibling (index.row (), 0); + QAbstractItemModel *m = view->model (); + QMap<int, QVariant> item_data = m->itemData (index); + + return item_data[0].toString (); +} + void workspace_view::contextmenu_requested (const QPoint& qpos) { QMenu menu (this); QModelIndex index = view->indexAt (qpos); - QAbstractItemModel *m = view->model (); // if it isnt Local, Glocal etc, allow the ctx menu if (index.isValid () && index.column () == 0) { - index = index.sibling (index.row (), 0); - - QMap<int, QVariant> item_data = m->itemData (index); + QString var_name = get_var_name (index); - QString var_name = item_data[0].toString (); + menu.addAction (tr ("Copy name"), this, + SLOT (handle_contextmenu_copy ())); - menu.addAction (tr ("Copy"), this, - SLOT (handle_contextmenu_copy ())); + menu.addAction (tr ("Copy value"), this, + SLOT (handle_contextmenu_copy_value ())); QAction *rename = menu.addAction (tr ("Rename"), this, SLOT (handle_contextmenu_rename ())); + QAbstractItemModel *m = view->model (); const workspace_model *wm = static_cast<const workspace_model *> (m); if (! wm->is_top_level ()) @@ -159,13 +169,7 @@ if (index.isValid ()) { - index = index.sibling (index.row (), 0); - - QAbstractItemModel *m = view->model (); - - QMap<int, QVariant> item_data = m->itemData (index); - - QString var_name = item_data[0].toString (); + QString var_name = get_var_name (index); QClipboard *clipboard = QApplication::clipboard (); @@ -174,19 +178,31 @@ } void +workspace_view::handle_contextmenu_copy_value (void) +{ + QModelIndex index = view->currentIndex (); + + if (index.isValid ()) + { + QString var_name = get_var_name (index); + + octave_value val = symbol_table::varval (var_name.toStdString ()); + std::ostringstream buf; + val.print_raw (buf, true); + + QClipboard *clipboard = QApplication::clipboard (); + clipboard->setText (QString::fromStdString (buf.str ())); + } +} + +void workspace_view::handle_contextmenu_rename (void) { QModelIndex index = view->currentIndex (); if (index.isValid ()) { - index = index.sibling (index.row (), 0); - - QAbstractItemModel *m = view->model (); - - QMap<int, QVariant> item_data = m->itemData (index); - - QString var_name = item_data[0].toString (); + QString var_name = get_var_name (index); QInputDialog* inputDialog = new QInputDialog (); @@ -199,7 +215,10 @@ QLineEdit::Normal, var_name, &ok); if (ok && ! new_name.isEmpty ()) - m->setData (index, new_name, Qt::EditRole); + { + QAbstractItemModel *m = view->model (); + m->setData (index, new_name, Qt::EditRole); + } } } @@ -228,13 +247,7 @@ if (index.isValid ()) { - index = index.sibling (index.row (), 0); - - QAbstractItemModel *m = view->model (); - - QMap<int, QVariant> item_data = m->itemData (index); - - QString var_name = item_data[0].toString (); + QString var_name = get_var_name (index); emit command_requested (cmdname + " (" + var_name + ");"); }
--- a/libgui/src/workspace-view.h +++ b/libgui/src/workspace-view.h @@ -62,6 +62,7 @@ // context menu slots void handle_contextmenu_copy (void); + void handle_contextmenu_copy_value (void); void handle_contextmenu_rename (void); void handle_contextmenu_disp (void); void handle_contextmenu_plot (void); @@ -76,6 +77,7 @@ void relay_contextmenu_command (const QString& cmdname); + QString get_var_name (QModelIndex index); QTableView *view; int view_previous_row_count; workspace_model *_model;