annotate libgui/src/octave-dock-widget.cc @ 24812:ed9ba20d6ed3

Make the variable editor multi-panel via a QMainWindow layout (bug #53046) * main-window.h: Remove <QMdiArea> and <QMdiSubWindow> from header list. * octave-dock-widget.h (label_dock_widget): Added. New intermediate class that contains the features related only to the thin header for dock/undock and close. Namely m_icon_size, m_title_widget, m_dock_button, m_close_button, m_dock_action and m_close_action and member function set_title(). (octave_dock_widget): Removed some elements for label_dock_widget class and inherit that object. * octave-dock-widget.cc (label_dock_widget::label_dock_widget): Constructor of new class selecting a few initialization from octave_dock_widget related to thin header and no settings code and no connections at this level. Set the style sheet of the m_dock_button and m_close_button to transparent. (label_dock_widget::set_title): Moved from octave_dock_widget without modification. (octave_dock_widget::octave_dock_widget): Select code moved to label_dock_widget constructor. (octave_dock_widget::set_title): Moved to label_dock_widget class. * variable-editor-model.h: (variable_editor_model::edit_variable_signal): New signal for a model to launch a new variable_dock_widget if a sub-element needs it. (variable_editor_model::update_data): Changed from private to public. (variable_editor_model::update_data_cache): Ditto. (variable_editor_model::double_click): Moved here from variable_editor to make more modular. * variable-editor-model.cc (variable_editor_model::setData): Change the test on input variable for QString to be anything that can be converted to a QString, e.g., numbers. (variable_editor_model::update_data): Remove obsolete emitted signal maybe_resize_columns_signal(). (variable_editor_model::double_click): Moved from variable_editor. Remove the indirect reference to table then model. * variable-editor.h (var_editor_tab): Remove. A tab widget is no longer used. (variable_dock_widget): Added. A new class inherting label_dock_widget that is merely a container, holding the stack of editable (QTableView) and non-editable (QTextEdit) of variable views. (variable_dock_widget::variable_focused_signal): Added. New signal to let variable_editor know an object or its proxy has come into focus. (variable_dock_widget::handle_focus_change): Added. Slot to connect to QApplication::focusChanged(). (variable_dock_widget::closeEvent): Added. Override any intermediate class and go back to the base QDockWidget behavior. (variable_dock_widget::change_floating): Simple private routine changing the toggling the float state. (variable_dock_widget::change_existence): Simple private routine calling base routine close(). (variable_dock_widget::toplevel_change): Added. Private slot to respond to dock/undock signal. Changes the icon, restores focus, and also makes the first floated display magnified for fast viewing. (variable_editor_stack::variable_editor_stack): New class that holds and manages a variable_editor_model, variable_editor_view (QTableView) and a display view (QTextEdit). (variable_editor_stack::edit_view): Inline function that returns pointer to a variable_editor_view. (variable_editor_stack::disp_view): Inline function that returns pointer to a QTableView. (variable_editor_stack::set_editable): Moved here from var_editor_tab class. Set the view according to whether the variable can be put into table form. (variable_editor_stack::levelUp (void); Moved here from variable_editor class, where it was called up(). Open one higher level of octave value, e.g., cell array, structure. (variable_editor_stack::save (void): Moved here from variable_editor class. General save of variable not related to how it is viewed. (variable_editor_stack::make_disp_view): Moved here from variable_editor class. Only a few small configurations with no model input. (Done later.) (variable_edit_view::variable_edit_view): Added. New class derived from QTableView that holds the majority of functionality moved from the variable_editor class related to table copy, paste, etc. In the constructor is about half of what used to be in variable_editor::make_edit_view(). (variable_edit_view::setModel): Added. Override of the virtual function holding about half of what used to be in variable_editor::make_edit_view(). (variable_edit_view::command_signal): Added. Signal to connect to the variable_editor's mechanism for sending Octave command back to core. (variable_editor_view::range_selected): New method that provides a list of range values for the table used for constructing commands elsewhere. (variable_editor_view::selected_to_octave): Moved from variable_editor class and simplify by calling range_selected(). (variable_editor_view::selected_command_requested): Added. Like function command_requested(), but chooses just the selected data in the table. (variable_editor_view::delete_selected): Moved from variable_editor. Removes a level of indirection, but otherwise pretty much the same. (variable_editor_view::clearContent): Ditto. (variable_editor_view::cutClipboard): Ditto. (variable_editor_view::copyClipboard): Ditto. (variable_editor_view::pasteClipboard): Ditto. (variable_editor_view::pasteTableClipboard): Ditto. (variable_editor_view::handle_horizontal_scroll_action): Ditto. (variable_editor_view::handle_vertical_scroll_action): Ditto. (variable_editor_view::createContextMenu): Ditto. (variable_editor_view::createColumnMenu): Ditto. (variable_editor_view::createRowMenu): Ditto. (variable_editor_view::): Ditto. (variable_editor_view::): Ditto. (variable_editor_view::): Ditto. (variable_editor_view::): Ditto. (variable_editor_view::add_edit_actions): The similar portions of the various context menus that can be reused. (HoverToolButton): Very short class derived from QToolButton whose added feature is to capture the focused variable_dock_widget when the mouse is hovered over the button. (ReturnFocusToolButton): Similarly short class inherting HoverToolButton that adds the feature of restoring the focus before activating its associated action. (ReturnFocusMenu): Analogous to ReturnFocusToolButton, but based on QMenu. This is placed on a HoverToolButton. (variable_editor): Added QStrings m_current_focus_vname and m_hovered_focus_vname to keep track of variable that most recently focused. Removed m_close_action, m_close_others_action and m_close_all_action QActions since tab widget no longer used. Same for m_tab_widget, m_tab_bar. Change QWidget pointer m_container to QMainWindow pointer m_main. (variable_editor::has_focus): Removed. Using a proxy obviates this function. (variable_editor::edit_variable): Change from private to public. (variable_editor::variable_destroyed): New slot. Connect to variable_dock_widget to keep track of when to check if toolbar still valid. (variable_editor::variable_focused): New slot. Connect to variable_dock_widget() to keep track of most recent focused variable window. (variable_editor::record_hovered_focus_variable): New slot. Connect to variable_dock_widget toolbar's ReturnFocusToolButton and ReturnFocusMenu for when mouse cursor hovers. (variable_editor::restore_hovered_focus_variable): New slot. Connect to variable_dock_widget toolbar's ReturnFocusToolButton and ReturnFocusMenu for prior to acting in order to return to active window/focus when hovered. (variable_editor::request_close_tab): Removed. No longer needed. (variable_editor::request_close_other_tabs): Ditto. (variable_editor::request_close_all_tabs): Ditto. (variable_editor::close_tab): Ditto. (variable_editor::contextmenu_requested): Ditto. (variable_editor::columnmenu_requested): Ditto. (variable_editor::rowmenu_requested): Ditto. (variable_editor::double_click): Moved to variable_editor_model class. (variable_editor::up): Renamed levelUp and moved to variable_editor_view class. (variable_editor::clearContent): Moved to variable_dock_view class. (variable_editor::transposeContent): Ditto. (variable_editor::delete_selected): Ditto. (variable_editor::relay_command): Renamed to relay_selected_command() for clarity. (variable_editor::clear_content_signal): Added. New signal to broadcast to the variable_dock_widgets' associated slot. (variable_editor::copy_clipboard_signal): Ditto. (variable_editor::paste_clipboard_signal): Ditto. (variable_editor::paste_table_clipboard_signal): Ditto. (variable_editor::context_menu_signal): Ditto. (variable_editor::column_menu_signal): Ditto. (variable_editor::row_menu_signal): Ditto. (variable_editor::save_signal): Ditto. (variable_editor::delete_selected_signal): Ditto. (variable_editor::selected_command_signal): Ditto. (variable_editor::enable_actions): Removed. Too short of function otherwise. (variable_editor::octave_to_coords): Removed, no longer needed. (variable_editor::real_var_name): Removed, no more KDE problem in tab names because tab widget no longer used. Names stored in most QObject's objectName. (variable_editor::selected_to_octave): Moved to variable_editor_view class. (variable_editor::add_tool_bar_button): Convenience function for repetitive tool bar button construction. * variable-editor.cc: Add <QMdiArea> and <QScreen> to list of headers. Remove <QStackedWidget> from list. (make_plot_mapper): Added. Reusable, list-based convenience function. Adds a plot title that also uses the %1 argument. (variable_dock_widget::variable_dock_widget): Added. Constructor that sets a couple attributes and connects the header dock actions inherited from label_dock_widget to appropriate slots. (variable_dock_widget::handle_focus_change): Added. Connected to QApplication's focusChanged() to set/clear the blue background of the name label and keep track of most recent focused variable_dock_widget. (variable_dock_widget::change_floating): Added. New slot one line long. (variable_dock_widget::change_existence): Added. New slot that calls close() which is configurable by Qt::WA_DeleteOnClose parameter. For now, "close" means "hide". (variable_dock_widget::toplevel_change): Added. Changes the dock/undock icon, but also its tooltip. Also changes the focus to the new window. First time enlarged is very big to simulate "maximize", i.e., better temporary view of this variable. (variable_editor_stack::set_editable): Moved from var_editor_tab object and made more generic so that it can be put in any container. Ensure that the container has the active widget as its focus proxy. (variable_editor_view::closeEvent, etc.): See variable-editor.h for list of functions that are moved from variable_editor, often using findChild() or findChildren() for convenience rather than m_widget_stack or m_table_widget. (variable_editor::variable_editor): Call initializer QMainWindow() and QToolBar() similar to what it was once like. Also initialize m_current_focus_vname and m_hovered_focus_vname to "". Add toolbar to m_main. Use an MDI area for central widget of m_main. Remove all tab bar layout. Set the window's options to QMainWindow::AllowNestedDocks and QMainWindow::VerticalTabs. (variable_editor::edit_variable): Use findChild() to look for variable_dock_widget of requested name. If so, bring into focus and return. If continue, create new variable_dock_widget "page" and place in m_main. Set page's objectName to the variable name. Connect signals/slots to "page" for controlling the blue background of variable name. Remove extra layer of QVBoxLayout container, now replaced by creation of a variable_editor_stack object. Set stack widget's objectName to variable name. Get edit_view from variable_editor_stack's edit_view() method. Set edit_view's objectName to variable name. Make myriad connections to edit_view and variable_editor. Create a variable_edit_model and pass that on to variable_editor_view via setModel(). Make all the various connections amongst these objects. Supply a title to the label_dock_widget and set the text of that title to the variable's name. Use findChildren to enable the toolbar on the first variable, similar to the way it was previous. After creating variable_dock_widget, set its allowed areas to Qt::LeftDockWidgetArea and Qt::RightDockWidgetArea then place it in the main window's left dock area. (variable_editor::make_disp_view): Moved to variable_editor_stack class. (variable_editor::make_edit_view): Absorbed in variable_editor_view constructor and setModel() methods. (variable_editor::has_focus): Removed. Not needed, setting focus proxy appears to obviate this. (variable_editor::notice_settings): Took out shortcut_manager shortcuts because these tab actions no longer needed. Also, these shortcuts can possibly be handled via the QAction shortcut key. (variable_editor::add_tool_bar_button): Added. Mimic the m_tool_bar->addAction() construct used in construct_tool_bar(). (variable_editor::construct_tool_bar): Utilize make_plot_mapper(). Utilize add_tool_bar_button() to place ReturnFocusToolButton objects in the QToolbar. Give an example of adding a short-cut key to the Save QAction. Use a HoverToolButton with a ReturnFocusMenu object similar to existing construction. At the end, utilize findChildren() to loop through all the objects needing connections to slots rather than program individually.
author Daniel J Sebald <daniel.sebald@ieee.org>
date Mon, 19 Feb 2018 20:13:15 -0600
parents 344832a898ad
children 0f6a261ab144
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
1 /*
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
2
23219
3ac9f9ecfae5 maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents: 23083
diff changeset
3 Copyright (C) 2012-2017 Richard Crozier
22323
bac0d6f07a3e maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents: 22177
diff changeset
4 Copyright (C) 2013-2016 Torsten <ttl@justmail.de>
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
5
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
6 This file is part of Octave.
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
7
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24318
diff changeset
8 Octave is free software: you can redistribute it and/or modify it
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22599
diff changeset
9 under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24318
diff changeset
10 the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22599
diff changeset
11 (at your option) any later version.
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
12
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22599
diff changeset
13 Octave is distributed in the hope that it will be useful, but
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22599
diff changeset
14 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22599
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22599
diff changeset
16 GNU General Public License for more details.
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
17
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
19 along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24318
diff changeset
20 <https://www.gnu.org/licenses/>.
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
21
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
22 */
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
23
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
24 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21203
diff changeset
25 # include "config.h"
17923
b602014eeb54 * octave-dock-widget.cc: Include config.h.
John W. Eaton <jwe@octave.org>
parents: 17899
diff changeset
26 #endif
b602014eeb54 * octave-dock-widget.cc: Include config.h.
John W. Eaton <jwe@octave.org>
parents: 17899
diff changeset
27
16881
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16865
diff changeset
28 #include <QApplication>
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
29 #include <QToolBar>
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
30 #include <QAction>
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
31 #include <QHBoxLayout>
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
32 #include <QLabel>
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
33 #include <QSettings>
19918
66928b4546ab dock-/undock- and close-icons with variable size (bug #41938)
Torsten <ttl@justmail.de>
parents: 19913
diff changeset
34 #include <QStyle>
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
35
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
36 #include "resource-manager.h"
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
37 #include "octave-dock-widget.h"
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
38
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
39
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
40 label_dock_widget::label_dock_widget (QWidget *p)
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17686
diff changeset
41 : QDockWidget (p)
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
42 {
19918
66928b4546ab dock-/undock- and close-icons with variable size (bug #41938)
Torsten <ttl@justmail.de>
parents: 19913
diff changeset
43 QStyle *st = style ();
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
44 m_icon_size = 0.75*st->pixelMetric (QStyle::PM_SmallIconSize);
19918
66928b4546ab dock-/undock- and close-icons with variable size (bug #41938)
Torsten <ttl@justmail.de>
parents: 19913
diff changeset
45
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
46 // the custom (extra) title bar of the widget
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
47 m_dock_action = new QAction
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
48 (QIcon (":/actions/icons/widget-undock.png"), "", this);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
49 m_dock_action->setToolTip (tr ("Undock widget"));
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
50 m_dock_button = new QToolButton (this);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
51 m_dock_button->setDefaultAction (m_dock_action);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
52 m_dock_button->setFocusPolicy (Qt::NoFocus);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
53 m_dock_button->setIconSize (QSize (m_icon_size,m_icon_size));
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
54
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
55 m_close_action = new QAction
18678
6113e0c6920b maint: Clean up extra spaces before/after parentheses.
Rik <rik@octave.org>
parents: 18555
diff changeset
56 (QIcon (":/actions/icons/widget-close.png"), "", this);
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
57 m_close_action->setToolTip (tr ("Close widget"));
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
58 m_close_button = new QToolButton (this);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
59 m_close_button->setDefaultAction (m_close_action);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
60 m_close_button->setFocusPolicy (Qt::NoFocus);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
61 m_close_button->setIconSize (QSize (m_icon_size,m_icon_size));
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
62
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
63 QString css_button = QString ("QToolButton {background: transparent; border: 0px;}");
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
64 m_dock_button->setStyleSheet (css_button);
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
65 m_close_button->setStyleSheet (css_button);
18218
7952fb0435db improve title bar of dock widgets
Torsten <ttl@justmail.de>
parents: 18180
diff changeset
66
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
67 QHBoxLayout *h_layout = new QHBoxLayout ();
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
68 h_layout->addStretch (100);
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
69 h_layout->addWidget (m_dock_button);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
70 h_layout->addWidget (m_close_button);
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
71 h_layout->setSpacing (0);
18180
b3838cedfe04 redesign of dock widgets title bar with configurable colors
Torsten <ttl@justmail.de>
parents: 17929
diff changeset
72 h_layout->setContentsMargins (5,2,2,2);
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
73
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
74 m_title_widget = new QWidget ();
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
75 m_title_widget->setLayout (h_layout);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
76 setTitleBarWidget (m_title_widget);
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
77
16881
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16865
diff changeset
78 // copy & paste handling
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17686
diff changeset
79 connect (p, SIGNAL (copyClipboard_signal ()),
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17686
diff changeset
80 this, SLOT (copyClipboard ()));
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17686
diff changeset
81 connect (p, SIGNAL (pasteClipboard_signal ()),
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17686
diff changeset
82 this, SLOT (pasteClipboard ()));
18555
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18218
diff changeset
83 connect (p, SIGNAL (selectAll_signal ()),
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18218
diff changeset
84 this, SLOT (selectAll ()));
19945
f7a805f02723 link undo in main window to editor if the latter has focus (bug #44402)
Torsten <ttl@justmail.de>
parents: 19918
diff changeset
85 // undo handling
f7a805f02723 link undo in main window to editor if the latter has focus (bug #44402)
Torsten <ttl@justmail.de>
parents: 19918
diff changeset
86 connect (p, SIGNAL (undo_signal ()), this, SLOT (do_undo ()));
24812
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
87 }
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
88
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
89 // set the title in the dockwidgets title bar
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
90 void
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
91 label_dock_widget::set_title (const QString& title)
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
92 {
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
93 QHBoxLayout *h_layout
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
94 = static_cast<QHBoxLayout *> (titleBarWidget ()->layout ());
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
95 QLabel *label = new QLabel (title);
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
96 label->setStyleSheet ("background: transparent;");
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
97 h_layout->insertWidget (0,label);
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
98 setWindowTitle (title);
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
99 }
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
100
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
101
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
102 octave_dock_widget::octave_dock_widget (QWidget *p)
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
103 : label_dock_widget (p)
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
104 {
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
105 m_parent = static_cast<QMainWindow *> (p); // store main window
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
106 m_floating = false;
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
107 m_predecessor_widget = nullptr;
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
108
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
109 connect (this, SIGNAL (visibilityChanged (bool)),
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
110 this, SLOT (handle_visibility_changed (bool)));
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
111
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
112 connect (p, SIGNAL (settings_changed (const QSettings*)),
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
113 this, SLOT (handle_settings (const QSettings*)));
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
114
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
115 connect (p, SIGNAL (active_dock_changed (octave_dock_widget*,
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
116 octave_dock_widget*)),
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
117 this, SLOT (handle_active_dock_changed (octave_dock_widget*,
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
118 octave_dock_widget*)));
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
119
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
120 setFeatures (QDockWidget::DockWidgetMovable); // not floatable or closeable
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
121
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
122 connect (m_dock_action, SIGNAL (triggered (bool)),
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
123 this, SLOT (change_floating (bool)));
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
124 connect (m_close_action, SIGNAL (triggered (bool)),
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
125 this, SLOT (change_visibility (bool)));
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
126
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
127 m_close_action->setToolTip (tr ("Hide widget"));
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
128
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
129 m_icon_color = "";
ed9ba20d6ed3 Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24696
diff changeset
130 m_title_3d = 50;
19360
2f9d9663b6b0 fix double clicks into the borders of floating dock widgets (bug #43662)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
131
2f9d9663b6b0 fix double clicks into the borders of floating dock widgets (bug #43662)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
132 installEventFilter (this);
2f9d9663b6b0 fix double clicks into the borders of floating dock widgets (bug #43662)
Torsten <ttl@justmail.de>
parents: 18555
diff changeset
133
20630
802dc52d4d46 improve focus detection of gui (bug #45306)
Torsten <ttl@justmail.de>
parents: 20186
diff changeset
134 setFocusPolicy (Qt::StrongFocus);
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
135 }
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
136
16809
84505f200e05 fix checked state of window menu entries at startup (bug #39322)
Torsten <ttl@justmail.de>
parents: 16798
diff changeset
137 // connect signal visibility changed to related slot (called from main-window)
84505f200e05 fix checked state of window menu entries at startup (bug #39322)
Torsten <ttl@justmail.de>
parents: 16798
diff changeset
138 void
84505f200e05 fix checked state of window menu entries at startup (bug #39322)
Torsten <ttl@justmail.de>
parents: 16798
diff changeset
139 octave_dock_widget::connect_visibility_changed (void)
84505f200e05 fix checked state of window menu entries at startup (bug #39322)
Torsten <ttl@justmail.de>
parents: 16798
diff changeset
140 {
84505f200e05 fix checked state of window menu entries at startup (bug #39322)
Torsten <ttl@justmail.de>
parents: 16798
diff changeset
141 connect (this, SIGNAL (visibilityChanged (bool)),
84505f200e05 fix checked state of window menu entries at startup (bug #39322)
Torsten <ttl@justmail.de>
parents: 16798
diff changeset
142 this, SLOT (handle_visibility (bool)));
84505f200e05 fix checked state of window menu entries at startup (bug #39322)
Torsten <ttl@justmail.de>
parents: 16798
diff changeset
143 emit active_changed (isVisible ()); // emit once for init of window menu
84505f200e05 fix checked state of window menu entries at startup (bug #39322)
Torsten <ttl@justmail.de>
parents: 16798
diff changeset
144 }
84505f200e05 fix checked state of window menu entries at startup (bug #39322)
Torsten <ttl@justmail.de>
parents: 16798
diff changeset
145
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
146 // make the widget floating
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
147 void
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
148 octave_dock_widget::make_window (void)
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
149 {
24318
a17862b28f0d handle floating widgets on all platforms as done on windows (bug #52378)
Torsten <mttl@mailbox.org>
parents: 24290
diff changeset
150 // the widget has to be reparented (parent = 0)
17686
65544374c1cf restore (un)docking of widgets without reparenting on non-windows systems
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
151
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
152 QSettings *settings = resource_manager::get_settings ();
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
153
17899
14c427b5c5c1 Restore geometry of floating widgets after restart in windows (bug #40485)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
154 // save the docking area and geometry for later redocking
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
155 // FIXME: dockWidgetArea always returns 2
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
156 settings->setValue ("DockWidgets/" + objectName () + "_dock_area",
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
157 m_parent->dockWidgetArea (this));
17899
14c427b5c5c1 Restore geometry of floating widgets after restart in windows (bug #40485)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
158 settings->setValue ("DockWidgets/" + objectName (), saveGeometry ());
16819
94c19dfb4ab1 * octave-dock-widget.cc: add missing sync () after writing to settings
Torsten <ttl@justmail.de>
parents: 16818
diff changeset
159 settings->sync ();
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
160
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
161 // remove parent and adjust the (un)dock icon
24570
c9aab297130e make floating dock widgets resizable in KDE Oxygen (bug #52797)
Torsten <mttl@mailbox.org>
parents: 24534
diff changeset
162 setTitleBarWidget (0);
c9aab297130e make floating dock widgets resizable in KDE Oxygen (bug #52797)
Torsten <mttl@mailbox.org>
parents: 24534
diff changeset
163 setParent (0, Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint |
c9aab297130e make floating dock widgets resizable in KDE Oxygen (bug #52797)
Torsten <mttl@mailbox.org>
parents: 24534
diff changeset
164 Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint);
c9aab297130e make floating dock widgets resizable in KDE Oxygen (bug #52797)
Torsten <mttl@mailbox.org>
parents: 24534
diff changeset
165 setTitleBarWidget (m_title_widget);
c9aab297130e make floating dock widgets resizable in KDE Oxygen (bug #52797)
Torsten <mttl@mailbox.org>
parents: 24534
diff changeset
166 setParent (0, Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint |
c9aab297130e make floating dock widgets resizable in KDE Oxygen (bug #52797)
Torsten <mttl@mailbox.org>
parents: 24534
diff changeset
167 Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint);
c9aab297130e make floating dock widgets resizable in KDE Oxygen (bug #52797)
Torsten <mttl@mailbox.org>
parents: 24534
diff changeset
168
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
169 m_dock_action->setIcon (QIcon (":/actions/icons/widget-dock"
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
170 + m_icon_color + ".png"));
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
171 m_dock_action->setToolTip (tr ("Dock widget"));
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
172
18678
6113e0c6920b maint: Clean up extra spaces before/after parentheses.
Rik <rik@octave.org>
parents: 18555
diff changeset
173 // restore the last geometry when floating
17899
14c427b5c5c1 Restore geometry of floating widgets after restart in windows (bug #40485)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
174 setGeometry (settings->value ("DockWidgets/" + objectName ()
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
175 + "_floating_geometry",
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
176 QRect (50,100,480,480)).toRect ());
17686
65544374c1cf restore (un)docking of widgets without reparenting on non-windows systems
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
177
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
178 m_floating = true;
19983
643de08e524c save and restore previously active widget in a tabbed stack (bug #42980)
Torsten <ttl@justmail.de>
parents: 19945
diff changeset
179
643de08e524c save and restore previously active widget in a tabbed stack (bug #42980)
Torsten <ttl@justmail.de>
parents: 19945
diff changeset
180 set_focus_predecessor (); // set focus previously active widget if tabbed
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
181 }
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
182
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
183 // dock the widget
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
184 void
19431
bd27cd403d00 fix errors when building octave for windows (regression from d93293218966)
Torsten <ttl@justmail.de>
parents: 19423
diff changeset
185 octave_dock_widget::make_widget (bool dock)
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
186 {
24318
a17862b28f0d handle floating widgets on all platforms as done on windows (bug #52378)
Torsten <mttl@mailbox.org>
parents: 24290
diff changeset
187 // Since floating widget has no parent, we have to read it
17686
65544374c1cf restore (un)docking of widgets without reparenting on non-windows systems
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
188
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
189 QSettings *settings = resource_manager::get_settings ();
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
190
17899
14c427b5c5c1 Restore geometry of floating widgets after restart in windows (bug #40485)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
191 // save last floating geometry if widget really was floating
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
192 if (m_floating)
17899
14c427b5c5c1 Restore geometry of floating widgets after restart in windows (bug #40485)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
193 settings->setValue ("DockWidgets/" + objectName () + "_floating_geometry",
14c427b5c5c1 Restore geometry of floating widgets after restart in windows (bug #40485)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
194 geometry ());
16819
94c19dfb4ab1 * octave-dock-widget.cc: add missing sync () after writing to settings
Torsten <ttl@justmail.de>
parents: 16818
diff changeset
195 settings->sync ();
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
196
17090
1d544ac39369 show correct undock-button of widgets when window layout is resetted
Torsten <ttl@justmail.de>
parents: 16953
diff changeset
197 if (dock)
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17686
diff changeset
198 {
24275
e9fe31118542 improve re-docking of a floating widget under windows
Torsten <mttl@mailbox.org>
parents: 24226
diff changeset
199 settings->setValue ("MainWindow/windowState", m_parent->saveState ());
e9fe31118542 improve re-docking of a floating widget under windows
Torsten <mttl@mailbox.org>
parents: 24226
diff changeset
200 m_parent->addDockWidget (Qt::TopDockWidgetArea, this);
e9fe31118542 improve re-docking of a floating widget under windows
Torsten <mttl@mailbox.org>
parents: 24226
diff changeset
201 // recover old window states, hide and re-show new added widget
e9fe31118542 improve re-docking of a floating widget under windows
Torsten <mttl@mailbox.org>
parents: 24226
diff changeset
202 m_parent->restoreState (settings->value ("MainWindow/windowState").toByteArray ());
e9fe31118542 improve re-docking of a floating widget under windows
Torsten <mttl@mailbox.org>
parents: 24226
diff changeset
203 focus ();
e9fe31118542 improve re-docking of a floating widget under windows
Torsten <mttl@mailbox.org>
parents: 24226
diff changeset
204 QApplication::setActiveWindow (this);
17090
1d544ac39369 show correct undock-button of widgets when window layout is resetted
Torsten <ttl@justmail.de>
parents: 16953
diff changeset
205 }
1d544ac39369 show correct undock-button of widgets when window layout is resetted
Torsten <ttl@justmail.de>
parents: 16953
diff changeset
206 else // only reparent, no docking
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
207 setParent (m_parent);
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
208
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
209 // adjust the (un)dock icon
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
210 m_dock_action->setIcon (QIcon (":/actions/icons/widget-undock"
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
211 + m_icon_color + ".png"));
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
212 m_dock_action->setToolTip (tr ("Undock widget"));
17686
65544374c1cf restore (un)docking of widgets without reparenting on non-windows systems
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
213
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
214 m_floating = false;
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
215 }
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
216
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
217 // set the widget which previously had focus when tabified
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
218 void
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
219 octave_dock_widget::set_predecessor_widget (octave_dock_widget *prev_widget)
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
220 {
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
221 m_predecessor_widget = prev_widget;
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
222 }
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
223
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
224 // close event
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
225 void
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
226 octave_dock_widget::closeEvent (QCloseEvent *e)
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
227 {
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
228 emit active_changed (false);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
229 set_focus_predecessor ();
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
230 QDockWidget::closeEvent (e);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
231 }
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
232
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
233 // get focus widget
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
234 QWidget *
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
235 octave_dock_widget::focusWidget (void)
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
236 {
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
237 QWidget *w = QApplication::focusWidget ();
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
238 if (w && w->focusProxy ()) w = w->focusProxy ();
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
239 return w;
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
240 }
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
241
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
242 void
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
243 octave_dock_widget::handle_settings (const QSettings *settings)
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
244 {
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
245 m_custom_style
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
246 = settings->value ("DockWidgets/widget_title_custom_style",false).toBool ();
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
247
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
248 m_title_3d
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
249 = settings->value ("DockWidgets/widget_title_3d",50).toInt ();
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
250
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
251 QColor default_var = QColor (0,0,0);
24226
dc85329e6778 consistent case of settings keys in the settings file (important for qt5)
Torsten <mttl@mailbox.org>
parents: 24014
diff changeset
252 m_fg_color = settings->value ("DockWidgets/title_fg_color",
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
253 default_var).value<QColor> ();
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
254 default_var = QColor (0,0,0);
24226
dc85329e6778 consistent case of settings keys in the settings file (important for qt5)
Torsten <mttl@mailbox.org>
parents: 24014
diff changeset
255 m_fg_color_active = settings->value ("DockWidgets/title_fg_color_active",
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
256 default_var).value<QColor> ();
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
257
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
258 default_var = QColor (255,255,255);
24226
dc85329e6778 consistent case of settings keys in the settings file (important for qt5)
Torsten <mttl@mailbox.org>
parents: 24014
diff changeset
259 m_bg_color = settings->value ("DockWidgets/title_bg_color",
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
260 default_var).value<QColor> ();
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
261 default_var = QColor (192,192,192);
24226
dc85329e6778 consistent case of settings keys in the settings file (important for qt5)
Torsten <mttl@mailbox.org>
parents: 24014
diff changeset
262 m_bg_color_active = settings->value ("DockWidgets/title_bg_color_active",
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
263 default_var).value<QColor> ();
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
264
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
265 int r, g, b;
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
266 m_bg_color.getRgb (&r, &g, &b);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
267 if (r+g+b < 400)
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
268 m_icon_color = "-light";
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
269 else
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
270 m_icon_color = "";
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
271
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
272 m_bg_color_active.getRgb (&r, &g, &b);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
273 if (r+g+b < 400)
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
274 m_icon_color_active = "-light";
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
275 else
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
276 m_icon_color_active = "";
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
277
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
278 notice_settings (settings); // call individual handler
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
279
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
280 set_style (false);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
281 }
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
282
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
283 void
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
284 octave_dock_widget::handle_active_dock_changed (octave_dock_widget *w_old,
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
285 octave_dock_widget *w_new)
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
286 {
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
287 if (m_custom_style && this == w_old)
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
288 {
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
289 set_style (false);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
290 update ();
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
291 }
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
292
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
293 if (m_custom_style && this == w_new)
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
294 {
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
295 set_style (true);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
296 update ();
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
297 }
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
298 }
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
299
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
300 void
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
301 octave_dock_widget::save_settings (void)
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
302 {
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
303 // save state of this dock-widget
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
304 QString name = objectName ();
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
305 QSettings *settings = resource_manager::get_settings ();
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
306
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
307 if (! settings)
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
308 return;
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
309
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
310 settings->beginGroup ("DockWidgets");
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
311
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
312 if (m_floating) // widget is floating (windows), save actual floating geometry
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
313 settings->setValue (name+"_floating_geometry", geometry ());
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
314 else // not floating save docked (normal) geometry
24318
a17862b28f0d handle floating widgets on all platforms as done on windows (bug #52378)
Torsten <mttl@mailbox.org>
parents: 24290
diff changeset
315 settings->setValue (name, saveGeometry ());
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
316
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
317 settings->setValue (name+"Visible", isVisible ()); // store visibility
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
318 settings->setValue (name+"Floating", m_floating); // store visibility
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
319 settings->setValue (name+"_minimized", isMinimized ()); // store minimized
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
320
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
321 settings->endGroup ();
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
322 settings->sync ();
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
323 }
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
324
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
325 bool octave_dock_widget::eventFilter (QObject *obj, QEvent *e)
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
326 {
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
327 if (e->type () == QEvent::NonClientAreaMouseButtonDblClick)
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
328 {
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
329 e->ignore (); // ignore double clicks into window decoration elements
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
330 return true;
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
331 }
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
332
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
333 return QDockWidget::eventFilter (obj,e);
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
334 }
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
335
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
336 // slot for (un)dock action
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
337 void
17899
14c427b5c5c1 Restore geometry of floating widgets after restart in windows (bug #40485)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
338 octave_dock_widget::change_floating (bool)
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17686
diff changeset
339 {
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
340 if (m_floating)
17899
14c427b5c5c1 Restore geometry of floating widgets after restart in windows (bug #40485)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
341 make_widget ();
14c427b5c5c1 Restore geometry of floating widgets after restart in windows (bug #40485)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
342 else
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
343 {
16818
caf3d2a45da0 clean up some code for undocking and docking widgets
Torsten <ttl@justmail.de>
parents: 16809
diff changeset
344 make_window ();
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
345 focus ();
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
346 }
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
347 }
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
348
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
349 // slot for hiding the widget
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
350 void
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
351 octave_dock_widget::change_visibility (bool)
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
352 {
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
353 setVisible (false);
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
354 emit active_changed (false);
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
355 }
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents:
diff changeset
356
18180
b3838cedfe04 redesign of dock widgets title bar with configurable colors
Torsten <ttl@justmail.de>
parents: 17929
diff changeset
357 void
19423
d93293218966 custom style of dock widget title bars depending on focus (bug #43837)
Torsten <ttl@justmail.de>
parents: 19360
diff changeset
358 octave_dock_widget::set_style (bool active)
18180
b3838cedfe04 redesign of dock widgets title bar with configurable colors
Torsten <ttl@justmail.de>
parents: 17929
diff changeset
359 {
b3838cedfe04 redesign of dock widgets title bar with configurable colors
Torsten <ttl@justmail.de>
parents: 17929
diff changeset
360 QString css;
b3838cedfe04 redesign of dock widgets title bar with configurable colors
Torsten <ttl@justmail.de>
parents: 17929
diff changeset
361 QString css_button;
b3838cedfe04 redesign of dock widgets title bar with configurable colors
Torsten <ttl@justmail.de>
parents: 17929
diff changeset
362 QString dock_icon;
18218
7952fb0435db improve title bar of dock widgets
Torsten <ttl@justmail.de>
parents: 18180
diff changeset
363
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
364 QString icon_col = m_icon_color;
19431
bd27cd403d00 fix errors when building octave for windows (regression from d93293218966)
Torsten <ttl@justmail.de>
parents: 19423
diff changeset
365
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
366 if (m_floating)
18218
7952fb0435db improve title bar of dock widgets
Torsten <ttl@justmail.de>
parents: 18180
diff changeset
367 dock_icon = "widget-dock";
18180
b3838cedfe04 redesign of dock widgets title bar with configurable colors
Torsten <ttl@justmail.de>
parents: 17929
diff changeset
368 else
18218
7952fb0435db improve title bar of dock widgets
Torsten <ttl@justmail.de>
parents: 18180
diff changeset
369 dock_icon = "widget-undock";
18180
b3838cedfe04 redesign of dock widgets title bar with configurable colors
Torsten <ttl@justmail.de>
parents: 17929
diff changeset
370
20794
e870a68742a6 change alignment of dock widget titles for OSX (bug #46592)
Torsten <ttl@justmail.de>
parents: 20630
diff changeset
371 #if defined (Q_OS_MAC)
e870a68742a6 change alignment of dock widget titles for OSX (bug #46592)
Torsten <ttl@justmail.de>
parents: 20630
diff changeset
372 QString alignment = "center";
e870a68742a6 change alignment of dock widget titles for OSX (bug #46592)
Torsten <ttl@justmail.de>
parents: 20630
diff changeset
373 #else
e870a68742a6 change alignment of dock widget titles for OSX (bug #46592)
Torsten <ttl@justmail.de>
parents: 20630
diff changeset
374 QString alignment = "center left";
e870a68742a6 change alignment of dock widget titles for OSX (bug #46592)
Torsten <ttl@justmail.de>
parents: 20630
diff changeset
375 #endif
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
376 if (m_custom_style)
18180
b3838cedfe04 redesign of dock widgets title bar with configurable colors
Torsten <ttl@justmail.de>
parents: 17929
diff changeset
377 {
b3838cedfe04 redesign of dock widgets title bar with configurable colors
Torsten <ttl@justmail.de>
parents: 17929
diff changeset
378
19423
d93293218966 custom style of dock widget title bars depending on focus (bug #43837)
Torsten <ttl@justmail.de>
parents: 19360
diff changeset
379 QColor bg_col, fg_col;
18180
b3838cedfe04 redesign of dock widgets title bar with configurable colors
Torsten <ttl@justmail.de>
parents: 17929
diff changeset
380
19423
d93293218966 custom style of dock widget title bars depending on focus (bug #43837)
Torsten <ttl@justmail.de>
parents: 19360
diff changeset
381 if (active)
d93293218966 custom style of dock widget title bars depending on focus (bug #43837)
Torsten <ttl@justmail.de>
parents: 19360
diff changeset
382 {
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
383 bg_col = m_bg_color_active;
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
384 fg_col = m_fg_color_active;
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
385 icon_col = m_icon_color_active;
19423
d93293218966 custom style of dock widget title bars depending on focus (bug #43837)
Torsten <ttl@justmail.de>
parents: 19360
diff changeset
386 }
18218
7952fb0435db improve title bar of dock widgets
Torsten <ttl@justmail.de>
parents: 18180
diff changeset
387 else
19423
d93293218966 custom style of dock widget title bars depending on focus (bug #43837)
Torsten <ttl@justmail.de>
parents: 19360
diff changeset
388 {
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
389 bg_col = m_bg_color;
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
390 fg_col = m_fg_color;
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
391 icon_col = m_icon_color;
19423
d93293218966 custom style of dock widget title bars depending on focus (bug #43837)
Torsten <ttl@justmail.de>
parents: 19360
diff changeset
392 }
18218
7952fb0435db improve title bar of dock widgets
Torsten <ttl@justmail.de>
parents: 18180
diff changeset
393
19913
2a992bd19169 make color gradient of custom title bar adjustable (bug #44435)
Torsten <ttl@justmail.de>
parents: 19911
diff changeset
394 QColor bg_col_top, bg_col_bottom;
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
395 if (m_title_3d > 0)
19913
2a992bd19169 make color gradient of custom title bar adjustable (bug #44435)
Torsten <ttl@justmail.de>
parents: 19911
diff changeset
396 {
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
397 bg_col_top = bg_col.lighter (100 + m_title_3d);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
398 bg_col_bottom = bg_col.darker (100 + m_title_3d);
19913
2a992bd19169 make color gradient of custom title bar adjustable (bug #44435)
Torsten <ttl@justmail.de>
parents: 19911
diff changeset
399 }
2a992bd19169 make color gradient of custom title bar adjustable (bug #44435)
Torsten <ttl@justmail.de>
parents: 19911
diff changeset
400 else
2a992bd19169 make color gradient of custom title bar adjustable (bug #44435)
Torsten <ttl@justmail.de>
parents: 19911
diff changeset
401 {
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
402 bg_col_top = bg_col.darker (100 - m_title_3d);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
403 bg_col_bottom = bg_col.lighter (100 - m_title_3d);
19913
2a992bd19169 make color gradient of custom title bar adjustable (bug #44435)
Torsten <ttl@justmail.de>
parents: 19911
diff changeset
404 }
2a992bd19169 make color gradient of custom title bar adjustable (bug #44435)
Torsten <ttl@justmail.de>
parents: 19911
diff changeset
405
18218
7952fb0435db improve title bar of dock widgets
Torsten <ttl@justmail.de>
parents: 18180
diff changeset
406 QString background =
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
407 QString ("background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
19913
2a992bd19169 make color gradient of custom title bar adjustable (bug #44435)
Torsten <ttl@justmail.de>
parents: 19911
diff changeset
408 " stop: 0 %1, stop: 0.60 %2, stop: 0.95 %2 stop: 1.0 %3);").
2a992bd19169 make color gradient of custom title bar adjustable (bug #44435)
Torsten <ttl@justmail.de>
parents: 19911
diff changeset
409 arg (bg_col_top.name ()).
2a992bd19169 make color gradient of custom title bar adjustable (bug #44435)
Torsten <ttl@justmail.de>
parents: 19911
diff changeset
410 arg (bg_col.name ()).
2a992bd19169 make color gradient of custom title bar adjustable (bug #44435)
Torsten <ttl@justmail.de>
parents: 19911
diff changeset
411 arg (bg_col_bottom.name ());
18180
b3838cedfe04 redesign of dock widgets title bar with configurable colors
Torsten <ttl@justmail.de>
parents: 17929
diff changeset
412
19423
d93293218966 custom style of dock widget title bars depending on focus (bug #43837)
Torsten <ttl@justmail.de>
parents: 19360
diff changeset
413 css = background + QString (" color: %1 ;").arg (fg_col.name ());
18180
b3838cedfe04 redesign of dock widgets title bar with configurable colors
Torsten <ttl@justmail.de>
parents: 17929
diff changeset
414 }
b3838cedfe04 redesign of dock widgets title bar with configurable colors
Torsten <ttl@justmail.de>
parents: 17929
diff changeset
415 else
b3838cedfe04 redesign of dock widgets title bar with configurable colors
Torsten <ttl@justmail.de>
parents: 17929
diff changeset
416 {
b3838cedfe04 redesign of dock widgets title bar with configurable colors
Torsten <ttl@justmail.de>
parents: 17929
diff changeset
417 css = QString ("");
b3838cedfe04 redesign of dock widgets title bar with configurable colors
Torsten <ttl@justmail.de>
parents: 17929
diff changeset
418 }
b3838cedfe04 redesign of dock widgets title bar with configurable colors
Torsten <ttl@justmail.de>
parents: 17929
diff changeset
419
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
420 m_title_widget->setStyleSheet (css);
24696
344832a898ad Use proper stylesheet syntax to avoid tooltip black background (bug #44554).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 24570
diff changeset
421 css_button = QString ("QToolButton {background: transparent; border: 0px;}");
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
422 m_dock_button->setStyleSheet (css_button);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
423 m_close_button->setStyleSheet (css_button);
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
424 m_dock_action->setIcon (QIcon (":/actions/icons/" + dock_icon + icon_col +
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
425 ".png"));
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
426 m_close_action->setIcon (QIcon (":/actions/icons/widget-close" + icon_col +
19911
2b5cbea8f442 fix missing close icon of dock widgets in windows (bug #44441)
Torsten <ttl@justmail.de>
parents: 19861
diff changeset
427 ".png"));
19423
d93293218966 custom style of dock widget title bars depending on focus (bug #43837)
Torsten <ttl@justmail.de>
parents: 19360
diff changeset
428 }
d93293218966 custom style of dock widget title bars depending on focus (bug #43837)
Torsten <ttl@justmail.de>
parents: 19360
diff changeset
429
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
430 // set focus to previously active widget in tabbed widget stack
19423
d93293218966 custom style of dock widget title bars depending on focus (bug #43837)
Torsten <ttl@justmail.de>
parents: 19360
diff changeset
431 void
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
432 octave_dock_widget::set_focus_predecessor (void)
19423
d93293218966 custom style of dock widget title bars depending on focus (bug #43837)
Torsten <ttl@justmail.de>
parents: 19360
diff changeset
433 {
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
434 if (m_predecessor_widget) // only != 0 if widget was tabbed
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
435 m_predecessor_widget->focus ();
19423
d93293218966 custom style of dock widget title bars depending on focus (bug #43837)
Torsten <ttl@justmail.de>
parents: 19360
diff changeset
436
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
437 m_predecessor_widget = nullptr;
24290
8612ab9fc564 maint: merge of stable to default.
Rik <rik@octave.org>
parents: 24275 24282
diff changeset
438 // FIXME: Until cset bda0c5b38bda, the wrong keys "Dockwidget/..." were used
8612ab9fc564 maint: merge of stable to default.
Rik <rik@octave.org>
parents: 24275 24282
diff changeset
439 // here. This had no effect in Qt4, but does in Qt5. In the following, the
8612ab9fc564 maint: merge of stable to default.
Rik <rik@octave.org>
parents: 24275 24282
diff changeset
440 // four incorrect keys are updated if still present in the settings files.
8612ab9fc564 maint: merge of stable to default.
Rik <rik@octave.org>
parents: 24275 24282
diff changeset
441 // The keys are also used in the settings dialog, but
8612ab9fc564 maint: merge of stable to default.
Rik <rik@octave.org>
parents: 24275 24282
diff changeset
442 // octave_dock_widget::handle_settings is already called at program start.
8612ab9fc564 maint: merge of stable to default.
Rik <rik@octave.org>
parents: 24275 24282
diff changeset
443 // These tests can be removed in a future version of Octave (version 4.8).
24282
a669809df612 update wrong setting keys accidentally introduced into the settings file
Torsten <mttl@mailbox.org>
parents: 24280
diff changeset
444 resource_manager::update_settings_key ("Dockwidgets/title_bg_color",
a669809df612 update wrong setting keys accidentally introduced into the settings file
Torsten <mttl@mailbox.org>
parents: 24280
diff changeset
445 "DockWidgets/title_bg_color");
a669809df612 update wrong setting keys accidentally introduced into the settings file
Torsten <mttl@mailbox.org>
parents: 24280
diff changeset
446 resource_manager::update_settings_key ("Dockwidgets/title_bg_color_active",
a669809df612 update wrong setting keys accidentally introduced into the settings file
Torsten <mttl@mailbox.org>
parents: 24280
diff changeset
447 "DockWidgets/title_bg_color_active");
a669809df612 update wrong setting keys accidentally introduced into the settings file
Torsten <mttl@mailbox.org>
parents: 24280
diff changeset
448 resource_manager::update_settings_key ("Dockwidgets/title_fg_color",
a669809df612 update wrong setting keys accidentally introduced into the settings file
Torsten <mttl@mailbox.org>
parents: 24280
diff changeset
449 "DockWidgets/title_fg_color");
a669809df612 update wrong setting keys accidentally introduced into the settings file
Torsten <mttl@mailbox.org>
parents: 24280
diff changeset
450 resource_manager::update_settings_key ("Dockwidgets/title_fg_color_active",
a669809df612 update wrong setting keys accidentally introduced into the settings file
Torsten <mttl@mailbox.org>
parents: 24280
diff changeset
451 "DockWidgets/title_fg_color_active");
18180
b3838cedfe04 redesign of dock widgets title bar with configurable colors
Torsten <ttl@justmail.de>
parents: 17929
diff changeset
452 }