Mercurial > octave-libtiff
changeset 24865:5f7b9ee5b878
Add a QFrame to the variable editor panels and adjust tooltips (bug #53275)
* octave-dock-widget.cc (octave_dock_widget::make_window): Remove obsolete
FIXME comment. Add maximize control to the window-manager title bar
inherently enabling feature.
* variable-editor.cc (variable_dock_widget::variable_dock_widget): Define
DOCKED_FULLSCREEN_BUTTON_TOOLTIP and UNDOCKED_FULLSCREEN_BUTTON_TOOLTIP to
take the place of multiply used strings and place in the proper locations.
Also, undefine these after the last point used.
Use the resource_manager::icon() method for installing all icons. Create
new QFrame assigned to m_frame with the variable editor as parent but
otherwise not associated with a layout. Give the frame sunken appearance
and invisible to mouse cursor.
(variable_dock_widget::change_fullscreen): Set the full-screen action tooltip
to "Redock" when coming from undocked state. When coming from full-screen
state, either change tooltip to UNDOCKED_FULLSCREEN_BUTTON_TOOLTIP or restore
docked state and set tooltip to DOCKED_FULLSCREEN_BUTTON_TOOLTIP.
(variable_dock_widget::resizeEvent): Added. Re-implement virtual base
function by setting the size of the m_frame QFrame to that of the
variable_dock_widget.
* variable-editor.h (variable_dock_widget): Declare reimplemented virtual
resizeEvent(). Add new pointer m_frame.
author | Daniel J Sebald <daniel.sebald@ieee.org> |
---|---|
date | Sat, 10 Mar 2018 14:41:34 -0600 |
parents | 26d8b90c0cb2 |
children | 441b27c0fd5e |
files | libgui/src/octave-dock-widget.cc libgui/src/variable-editor.cc libgui/src/variable-editor.h |
diffstat | 3 files changed, 43 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/octave-dock-widget.cc Sat Mar 10 17:10:42 2018 -0800 +++ b/libgui/src/octave-dock-widget.cc Sat Mar 10 14:41:34 2018 -0600 @@ -154,7 +154,6 @@ QSettings *settings = resource_manager::get_settings (); // save the docking area and geometry for later redocking - // FIXME: dockWidgetArea always returns 2 settings->setValue ("DockWidgets/" + objectName () + "_dock_area", m_parent->dockWidgetArea (this)); settings->setValue ("DockWidgets/" + objectName (), saveGeometry ()); @@ -163,10 +162,10 @@ // remove parent and adjust the (un)dock icon setTitleBarWidget (0); setParent (0, Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint | - Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint); + Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); setTitleBarWidget (m_title_widget); setParent (0, Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint | - Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint); + Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); #if defined (Q_OS_UNIX) m_title_widget->setToolTip (
--- a/libgui/src/variable-editor.cc Sat Mar 10 17:10:42 2018 -0800 +++ b/libgui/src/variable-editor.cc Sat Mar 10 14:41:34 2018 -0600 @@ -107,6 +107,8 @@ this, SLOT (setVisible (bool))); #if defined (HAVE_QGUIAPPLICATION) +#define DOCKED_FULLSCREEN_BUTTON_TOOLTIP "Fullscreen undock" +#define UNDOCKED_FULLSCREEN_BUTTON_TOOLTIP "Fullscreen" // Add a fullscreen button m_fullscreen_action = nullptr; @@ -118,8 +120,8 @@ if (h_layout != nullptr && titleBarWidget () != nullptr) { m_fullscreen_action = new QAction - (QIcon::fromTheme ("view-fullscreen"), "", this); - m_fullscreen_action->setToolTip (tr ("Fullscreen undock")); + (resource_manager::icon ("view-fullscreen", false), "", this); + m_fullscreen_action->setToolTip (tr (DOCKED_FULLSCREEN_BUTTON_TOOLTIP)); QToolButton *fullscreen_button = new QToolButton (titleBarWidget ()); fullscreen_button->setDefaultAction (m_fullscreen_action); fullscreen_button->setFocusPolicy (Qt::NoFocus); @@ -137,6 +139,11 @@ h_layout->insertWidget (index, fullscreen_button); } #endif + + // Custom title bars cause loss of decorations, add a frame + m_frame = new QFrame (this); + m_frame->setFrameStyle (QFrame::Box | QFrame::Sunken); + m_frame->setAttribute (Qt::WA_TransparentForMouseEvents); } // slot for (un)dock action @@ -149,13 +156,13 @@ if (m_full_screen) { setGeometry (m_prev_geom); - m_fullscreen_action->setIcon (QIcon::fromTheme ("view-fullscreen")); + m_fullscreen_action->setIcon (resource_manager::icon ("view-fullscreen", false)); m_full_screen = false; } - m_fullscreen_action->setToolTip (tr ("Fullscreen undock")); + m_fullscreen_action->setToolTip (tr (DOCKED_FULLSCREEN_BUTTON_TOOLTIP)); } else - m_fullscreen_action->setToolTip (tr ("Fullscreen")); + m_fullscreen_action->setToolTip (tr (UNDOCKED_FULLSCREEN_BUTTON_TOOLTIP)); #endif setFloating (! isFloating ()); @@ -197,11 +204,14 @@ m_prev_floating = isFloating (); m_prev_geom = geometry (); - m_fullscreen_action->setIcon (QIcon::fromTheme ("view-restore")); + m_fullscreen_action->setIcon (resource_manager::icon ("view-restore", false)); if (m_prev_floating) m_fullscreen_action->setToolTip (tr ("Restore geometry")); else - setFloating (true); + { + m_fullscreen_action->setToolTip (tr ("Redock")); + setFloating (true); + } // showFullscreen() and setWindowState() only work for QWindow objects. QScreen *pscreen = QGuiApplication::primaryScreen (); @@ -213,15 +223,20 @@ } else { - m_fullscreen_action->setIcon (QIcon::fromTheme ("view-fullscreen")); + m_fullscreen_action->setIcon (resource_manager::icon ("view-fullscreen", false)); setGeometry (m_prev_geom); if (m_prev_floating) - m_fullscreen_action->setToolTip (tr ("Fullscreen")); + m_fullscreen_action->setToolTip (tr (UNDOCKED_FULLSCREEN_BUTTON_TOOLTIP)); else - setFloating (false); + { + setFloating (false); + m_fullscreen_action->setToolTip (tr (DOCKED_FULLSCREEN_BUTTON_TOOLTIP)); + } m_full_screen = false; } +#undef DOCKED_FULLSCREEN_BUTTON_TOOLTIP +#undef UNDOCKED_FULLSCREEN_BUTTON_TOOLTIP #endif } @@ -256,6 +271,12 @@ } } + void variable_dock_widget::resizeEvent (QResizeEvent *) + { + if (m_frame) + m_frame->resize (size ()); + } + // Variable editor stack
--- a/libgui/src/variable-editor.h Sat Mar 10 17:10:42 2018 -0800 +++ b/libgui/src/variable-editor.h Sat Mar 10 14:41:34 2018 -0600 @@ -62,6 +62,8 @@ virtual void closeEvent (QCloseEvent *e); + void resizeEvent (QResizeEvent *event); + public slots: void handle_focus_change (QWidget *old, QWidget *now); @@ -76,13 +78,20 @@ void change_fullscreen (void); + protected: + + QFrame *m_frame; + #if defined (HAVE_QGUIAPPLICATION) - protected: QAction *m_fullscreen_action; + bool m_full_screen; + bool m_prev_floating; + QRect m_prev_geom; + #endif };