comparison libgui/src/variable-editor.cc @ 31621:0645ea65ca6b

handle icons and themes in gui_settings class, not resource_manager * resource-manager.h, resource-manager.cc (resource_manager::config_icon_theme, resource_manager::icon): Move funtcions to gui-settings.h and gui-settings.cc. * Canvas.cc, QTerminal.cc, documentation-bookmarks.cc, documentation.cc, dw-main-window.cc, files-dock-widget.cc, find-files-dialog.cc, gui-settings.cc, gui-settings.h, history-dock-widget.cc, file-editor.cc, main-window.cc, octave-dock-widget.cc, octave-qobject.cc, qt-interpreter-events.cc, resource-manager.cc, resource-manager.h, variable-editor.cc: Change all uses.
author John W. Eaton <jwe@octave.org>
date Fri, 02 Dec 2022 18:43:12 -0500
parents ad014fc78bd6
children 431f80aba37a
comparison
equal deleted inserted replaced
31620:6dfaaf8ecf3b 31621:0645ea65ca6b
112 m_full_screen = false; 112 m_full_screen = false;
113 m_prev_floating = false; 113 m_prev_floating = false;
114 m_prev_geom = QRect (0, 0, 0, 0); 114 m_prev_geom = QRect (0, 0, 0, 0);
115 115
116 QHBoxLayout *h_layout = m_title_widget->findChild<QHBoxLayout *> (); 116 QHBoxLayout *h_layout = m_title_widget->findChild<QHBoxLayout *> ();
117 resource_manager& rmgr = m_octave_qobj.get_resource_manager (); 117
118 gui_settings settings;
118 m_fullscreen_action 119 m_fullscreen_action
119 = new QAction (rmgr.icon ("view-fullscreen", false), "", this); 120 = new QAction (settings.icon ("view-fullscreen", false), "", this);
120 m_fullscreen_action->setToolTip (tr (DOCKED_FULLSCREEN_BUTTON_TOOLTIP)); 121 m_fullscreen_action->setToolTip (tr (DOCKED_FULLSCREEN_BUTTON_TOOLTIP));
121 QToolButton *fullscreen_button = new QToolButton (m_title_widget); 122 QToolButton *fullscreen_button = new QToolButton (m_title_widget);
122 fullscreen_button->setDefaultAction (m_fullscreen_action); 123 fullscreen_button->setDefaultAction (m_fullscreen_action);
123 fullscreen_button->setFocusPolicy (Qt::NoFocus); 124 fullscreen_button->setFocusPolicy (Qt::NoFocus);
124 fullscreen_button->setIconSize (QSize (m_icon_size, m_icon_size)); 125 fullscreen_button->setIconSize (QSize (m_icon_size, m_icon_size));
147 if (isFloating ()) 148 if (isFloating ())
148 { 149 {
149 if (m_full_screen) 150 if (m_full_screen)
150 { 151 {
151 setGeometry (m_prev_geom); 152 setGeometry (m_prev_geom);
152 resource_manager& rmgr = m_octave_qobj.get_resource_manager (); 153 gui_settings settings;
153 m_fullscreen_action->setIcon (rmgr.icon ("view-fullscreen", false)); 154 m_fullscreen_action->setIcon (settings.icon ("view-fullscreen", false));
154 m_full_screen = false; 155 m_full_screen = false;
155 } 156 }
156 m_fullscreen_action->setToolTip (tr (DOCKED_FULLSCREEN_BUTTON_TOOLTIP)); 157 m_fullscreen_action->setToolTip (tr (DOCKED_FULLSCREEN_BUTTON_TOOLTIP));
157 } 158 }
158 else 159 else
206 } 207 }
207 208
208 void 209 void
209 variable_dock_widget::change_fullscreen (void) 210 variable_dock_widget::change_fullscreen (void)
210 { 211 {
211 resource_manager& rmgr = m_octave_qobj.get_resource_manager (); 212 gui_settings settings;
212 213
213 if (! m_full_screen) 214 if (! m_full_screen)
214 { 215 {
215 m_prev_floating = isFloating (); 216 m_prev_floating = isFloating ();
216 m_fullscreen_action->setIcon (rmgr.icon ("view-restore", false)); 217 m_fullscreen_action->setIcon (settings.icon ("view-restore", false));
217 if (m_prev_floating) 218 if (m_prev_floating)
218 m_fullscreen_action->setToolTip (tr ("Restore geometry")); 219 m_fullscreen_action->setToolTip (tr ("Restore geometry"));
219 else 220 else
220 { 221 {
221 m_fullscreen_action->setToolTip (tr ("Redock")); 222 m_fullscreen_action->setToolTip (tr ("Redock"));
231 232
232 m_full_screen = true; 233 m_full_screen = true;
233 } 234 }
234 else 235 else
235 { 236 {
236 m_fullscreen_action->setIcon (rmgr.icon ("view-fullscreen", false)); 237 m_fullscreen_action->setIcon (settings.icon ("view-fullscreen", false));
237 setGeometry (m_prev_geom); 238 setGeometry (m_prev_geom);
238 if (m_prev_floating) 239 if (m_prev_floating)
239 m_fullscreen_action->setToolTip (tr (UNDOCKED_FULLSCREEN_BUTTON_TOOLTIP)); 240 m_fullscreen_action->setToolTip (tr (UNDOCKED_FULLSCREEN_BUTTON_TOOLTIP));
240 else 241 else
241 { 242 {
642 643
643 void 644 void
644 variable_editor_view::add_edit_actions (QMenu *menu, 645 variable_editor_view::add_edit_actions (QMenu *menu,
645 const QString& qualifier_string) 646 const QString& qualifier_string)
646 { 647 {
647 resource_manager& rmgr = m_octave_qobj.get_resource_manager (); 648 gui_settings settings;
648 649
649 menu->addAction (rmgr.icon ("edit-cut"), 650 menu->addAction (settings.icon ("edit-cut"),
650 tr ("Cut") + qualifier_string, 651 tr ("Cut") + qualifier_string,
651 this, &variable_editor_view::cutClipboard); 652 this, &variable_editor_view::cutClipboard);
652 653
653 menu->addAction (rmgr.icon ("edit-copy"), 654 menu->addAction (settings.icon ("edit-copy"),
654 tr ("Copy") + qualifier_string, 655 tr ("Copy") + qualifier_string,
655 this, &variable_editor_view::copyClipboard); 656 this, &variable_editor_view::copyClipboard);
656 657
657 menu->addAction (rmgr.icon ("edit-paste"), 658 menu->addAction (settings.icon ("edit-paste"),
658 tr ("Paste"), 659 tr ("Paste"),
659 this, &variable_editor_view::pasteClipboard); 660 this, &variable_editor_view::pasteClipboard);
660 661
661 menu->addSeparator (); 662 menu->addSeparator ();
662 663
663 menu->addAction (rmgr.icon ("edit-delete"), 664 menu->addAction (settings.icon ("edit-delete"),
664 tr ("Clear") + qualifier_string, 665 tr ("Clear") + qualifier_string,
665 this, &variable_editor_view::clearContent); 666 this, &variable_editor_view::clearContent);
666 667
667 menu->addAction (rmgr.icon ("edit-delete"), 668 menu->addAction (settings.icon ("edit-delete"),
668 tr ("Delete") + qualifier_string, 669 tr ("Delete") + qualifier_string,
669 this, &variable_editor_view::delete_selected); 670 this, &variable_editor_view::delete_selected);
670 671
671 menu->addAction (rmgr.icon ("document-new"), 672 menu->addAction (settings.icon ("document-new"),
672 tr ("Variable from Selection"), 673 tr ("Variable from Selection"),
673 this, &variable_editor_view::createVariable); 674 this, &variable_editor_view::createVariable);
674 } 675 }
675 676
676 void 677 void
1661 1662
1662 m_tool_bar->setObjectName ("VariableEditorToolBar"); 1663 m_tool_bar->setObjectName ("VariableEditorToolBar");
1663 1664
1664 m_tool_bar->setWindowTitle (tr ("Variable Editor Toolbar")); 1665 m_tool_bar->setWindowTitle (tr ("Variable Editor Toolbar"));
1665 1666
1666 resource_manager& rmgr = m_octave_qobj.get_resource_manager (); 1667 gui_settings settings;
1667 1668
1668 m_save_action = add_tool_bar_button (rmgr.icon ("document-save"), tr ("Save"), 1669 m_save_action = add_tool_bar_button (settings.icon ("document-save"),
1669 this, SLOT (save ())); 1670 tr ("Save"), this, SLOT (save ()));
1670 addAction (m_save_action); 1671 addAction (m_save_action);
1671 m_save_action->setShortcutContext (Qt::WidgetWithChildrenShortcut); 1672 m_save_action->setShortcutContext (Qt::WidgetWithChildrenShortcut);
1672 m_save_action->setStatusTip(tr("Save variable to a file")); 1673 m_save_action->setStatusTip(tr("Save variable to a file"));
1673 1674
1674 QAction *action = new QAction (rmgr.icon ("document-save-as"), tr ("Save in format ..."), m_tool_bar); 1675 QAction *action = new QAction (settings.icon ("document-save-as"),
1676 tr ("Save in format ..."), m_tool_bar);
1675 1677
1676 QToolButton *save_tool_button = new HoverToolButton (m_tool_bar); 1678 QToolButton *save_tool_button = new HoverToolButton (m_tool_bar);
1677 save_tool_button->setDefaultAction (action); 1679 save_tool_button->setDefaultAction (action);
1678 1680
1679 save_tool_button->setText (tr ("Save in format ...")); 1681 save_tool_button->setText (tr ("Save in format ..."));
1680 save_tool_button->setToolTip (tr("Save variable to a file in different format")); 1682 save_tool_button->setToolTip (tr("Save variable to a file in different format"));
1681 save_tool_button->setIcon (rmgr.icon ("document-save-as")); 1683 save_tool_button->setIcon (settings.icon ("document-save-as"));
1682 save_tool_button->setPopupMode (QToolButton::InstantPopup); 1684 save_tool_button->setPopupMode (QToolButton::InstantPopup);
1683 1685
1684 QMenu *save_menu = new ReturnFocusMenu (save_tool_button); 1686 QMenu *save_menu = new ReturnFocusMenu (save_tool_button);
1685 save_menu->setTitle (tr ("Save in format ...")); 1687 save_menu->setTitle (tr ("Save in format ..."));
1686 save_menu->setSeparatorsCollapsible (false); 1688 save_menu->setSeparatorsCollapsible (false);
1695 save_tool_button->setMenu (save_menu); 1697 save_tool_button->setMenu (save_menu);
1696 m_tool_bar->addWidget (save_tool_button); 1698 m_tool_bar->addWidget (save_tool_button);
1697 1699
1698 m_tool_bar->addSeparator (); 1700 m_tool_bar->addSeparator ();
1699 1701
1700 action = add_tool_bar_button (rmgr.icon ("edit-cut"), tr ("Cut"), 1702 action = add_tool_bar_button (settings.icon ("edit-cut"), tr ("Cut"),
1701 this, SLOT (cutClipboard ())); 1703 this, SLOT (cutClipboard ()));
1702 action->setStatusTip(tr("Cut data to clipboard")); 1704 action->setStatusTip(tr("Cut data to clipboard"));
1703 1705
1704 action = add_tool_bar_button (rmgr.icon ("edit-copy"), tr ("Copy"), 1706 action = add_tool_bar_button (settings.icon ("edit-copy"), tr ("Copy"),
1705 this, SLOT (copyClipboard ())); 1707 this, SLOT (copyClipboard ()));
1706 action->setStatusTip(tr("Copy data to clipboard")); 1708 action->setStatusTip(tr("Copy data to clipboard"));
1707 1709
1708 action = add_tool_bar_button (rmgr.icon ("edit-paste"), tr ("Paste"), 1710 action = add_tool_bar_button (settings.icon ("edit-paste"), tr ("Paste"),
1709 this, SLOT (pasteClipboard ())); 1711 this, SLOT (pasteClipboard ()));
1710 action->setStatusTip(tr("Paste clipboard into variable data")); 1712 action->setStatusTip(tr("Paste clipboard into variable data"));
1711 1713
1712 m_tool_bar->addSeparator (); 1714 m_tool_bar->addSeparator ();
1713 1715
1714 // FIXME: Add a print item? 1716 // FIXME: Add a print item?
1715 // QAction *print_action; /icons/fileprint.png 1717 // QAction *print_action; /icons/fileprint.png
1716 // m_tool_bar->addSeparator (); 1718 // m_tool_bar->addSeparator ();
1717 1719
1718 action = new QAction (rmgr.icon ("plot-xy-curve"), tr ("Plot"), m_tool_bar); 1720 action = new QAction (settings.icon ("plot-xy-curve"), tr ("Plot"),
1721 m_tool_bar);
1719 action->setToolTip (tr ("Plot Selected Data")); 1722 action->setToolTip (tr ("Plot Selected Data"));
1720 QToolButton *plot_tool_button = new HoverToolButton (m_tool_bar); 1723 QToolButton *plot_tool_button = new HoverToolButton (m_tool_bar);
1721 plot_tool_button->setDefaultAction (action); 1724 plot_tool_button->setDefaultAction (action);
1722 1725
1723 plot_tool_button->setText (tr ("Plot")); 1726 plot_tool_button->setText (tr ("Plot"));
1724 plot_tool_button->setToolTip (tr ("Plot selected data")); 1727 plot_tool_button->setToolTip (tr ("Plot selected data"));
1725 plot_tool_button->setIcon (rmgr.icon ("plot-xy-curve")); 1728 plot_tool_button->setIcon (settings.icon ("plot-xy-curve"));
1726 1729
1727 plot_tool_button->setPopupMode (QToolButton::InstantPopup); 1730 plot_tool_button->setPopupMode (QToolButton::InstantPopup);
1728 1731
1729 QMenu *plot_menu = new ReturnFocusMenu (plot_tool_button); 1732 QMenu *plot_menu = new ReturnFocusMenu (plot_tool_button);
1730 plot_menu->setTitle (tr ("Plot")); 1733 plot_menu->setTitle (tr ("Plot"));
1736 1739
1737 m_tool_bar->addWidget (plot_tool_button); 1740 m_tool_bar->addWidget (plot_tool_button);
1738 1741
1739 m_tool_bar->addSeparator (); 1742 m_tool_bar->addSeparator ();
1740 1743
1741 action = add_tool_bar_button (rmgr.icon ("go-up"), tr ("Up"), this, 1744 action = add_tool_bar_button (settings.icon ("go-up"), tr ("Up"), this,
1742 SLOT (levelUp ())); 1745 SLOT (levelUp ()));
1743 action->setStatusTip(tr("Go one level up in variable hierarchy")); 1746 action->setStatusTip(tr("Go one level up in variable hierarchy"));
1744 1747
1745 // The QToolButton mouse-clicks change active window, so connect all 1748 // The QToolButton mouse-clicks change active window, so connect all
1746 // HoverToolButton and ReturnFocusToolButton objects to the mechanism 1749 // HoverToolButton and ReturnFocusToolButton objects to the mechanism