26 #if defined (HAVE_CONFIG_H)
31 #include <QApplication>
32 #include <QDesktopWidget>
33 #include <QHBoxLayout>
51 m_default_float_button (nullptr), m_default_close_button (nullptr)
53 QStyle *st = style ();
54 m_icon_size = 0.75*st->pixelMetric (QStyle::PM_SmallIconSize);
59 if (buttonlist.size () == 2)
61 if (buttonlist.at (0)->x () < buttonlist.at (1)->x ())
77 (QIcon (
":/actions/icons/widget-undock.png"),
"",
this);
85 (QIcon (
":/actions/icons/widget-close.png"),
"",
this);
92 QString css_button = QString (
"QToolButton {background: transparent; border: 0px;}");
96 QHBoxLayout *h_layout =
new QHBoxLayout ();
97 h_layout->addStretch (100);
100 h_layout->setSpacing (10);
101 h_layout->setContentsMargins (5,2,2,2);
106 connect (p, SIGNAL (copyClipboard_signal ()),
108 connect (p, SIGNAL (pasteClipboard_signal ()),
110 connect (p, SIGNAL (selectAll_signal ()),
114 connect (p, SIGNAL (undo_signal ()),
this, SLOT (
do_undo ()));
121 QHBoxLayout *h_layout
124 label->setStyleSheet (
"background-color: transparent;");
125 h_layout->insertWidget (0,label);
127 setWindowTitle (title);
133 const QString& float_icon,
const QString& float_tooltip,
134 int icon_size,
const QString& titlebar_foreground,
135 const QString& titlebar_background)
137 return QString (
"QDockWidget\n"
141 " titlebar-close-icon: url(%1);\n"
142 " titlebar-normal-icon: url(%2);\n"
145 "QDockWidget::close-button, QDockWidget::float-button\n"
148 " icon-size: %3px;\n"
151 "QAbstractButton#qt_dockwidget_closebutton\n"
153 " qproperty-toolTip: \"%4\";\n"
156 "QAbstractButton#qt_dockwidget_floatbutton\n"
158 " qproperty-toolTip: \"%5\";\n"
161 "QDockWidget::title {\n"
162 " text-align: left;\n"
164 " padding-left: 1px;\n"
167 "QDockWidget::close-button\n"
173 "QDockWidget::float-button\n"
178 ).arg (close_icon).arg (float_icon).arg (icon_size)
179 .arg (close_tooltip).arg (float_tooltip)
180 .arg (titlebar_foreground).arg (titlebar_background)
181 .arg ((icon_size*2)/3).arg((icon_size*7)/3);
187 m_recent_dock_geom (), m_waiting_for_mouse_button_release (false)
189 setObjectName (obj_name);
194 connect (
this, SIGNAL (topLevelChanged (
bool)),
196 connect (
this, SIGNAL (visibilityChanged (
bool)),
199 connect (p, SIGNAL (settings_changed (
const gui_settings *)),
214 this, SLOT (
make_window (
bool)), Qt::QueuedConnection);
216 this, SLOT (
make_widget ()), Qt::QueuedConnection);
220 m_dock_action->setShortcutContext (Qt::WidgetWithChildrenShortcut);
226 m_close_action->setShortcutContext (Qt::WidgetWithChildrenShortcut);
242 setStyleSheet (
qdockwidget_css (QString (
":/actions/icons/widget-close.png"),
243 QString (
"Close widget"),
244 QString (
":/actions/icons/widget-undock.png"),
245 QString (
"Undock widget"),
250 widget ()->setToolTip (QString (
""));
255 installEventFilter (
this);
257 setFocusPolicy (Qt::StrongFocus);
259 setFeatures (QDockWidget::AllDockWidgetFeatures);
269 connect (
this, SIGNAL (visibilityChanged (
bool)),
278 bool vis = isVisible ();
286 QRect geom = geometry ();
299 setParent (0, Qt::CustomizeWindowHint | Qt::WindowTitleHint |
300 Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint | Qt::Window);
304 if (! widget_was_dragged)
315 if (titleBarWidget ())
338 emit topLevelChanged (
true);
345 bool vis = isVisible ();
355 m_parent->addDockWidget (Qt::BottomDockWidgetArea,
this);
367 if (titleBarWidget ())
369 m_dock_action->setIcon (QIcon (
":/actions/icons/widget-undock"
381 QApplication::setActiveWindow (
this);
413 QDockWidget::closeEvent (e);
420 QWidget *
w = QApplication::focusWidget ();
421 if (
w &&
w->focusProxy ())
w =
w->focusProxy ();
430 if ( (
event->type () == QEvent::MouseButtonDblClick && ! isFloating ())
431 || (
event->type () == QEvent::ActivationChange
435 if (isFloating () && parent () != 0)
443 return QDockWidget::event (
event);
470 bcol = QWidget::palette ().color (
m_title_widget->backgroundRole ());
475 bcol.getRgb (&
r, &g, &b);
481 bcola.getRgb (&
r, &g, &b);
487 QRect available_size = QApplication::desktop ()->availableGeometry (
m_parent);
489 available_size.getRect (&
x, &y, &
w, &h);
490 QRect default_floating_size = QRect (
x+16, y+32,
w/3, h/2);
491 m_parent->geometry ().getRect (&
x, &y, &
w, &h);
492 QRect default_dock_size = QRect (
x+16, y+32,
w/3, h/3);
496 default_floating_size).toRect ();
501 if (QApplication::desktop ()->screenNumber (&dummy) == -1)
510 #if defined (QVARIANT_CANCONVERT_ACCEPTS_QMETATYPE_TYPE)
511 QMetaType::Type rect_type = QMetaType::QRect;
513 QVariant::Type rect_type = QVariant::Rect;
515 if (dock_geom.canConvert (rect_type))
525 QToolBar* toolbar = findChild <QToolBar *> ();
529 QMenuBar* menubar = findChild <QMenuBar *> ();
556 QString
name = objectName ();
580 if (e->type () == QEvent::NonClientAreaMouseButtonDblClick)
586 return QDockWidget::eventFilter (obj,e);
608 QDockWidget::moveEvent (
event);
616 QDockWidget::resizeEvent (
event);
639 if (visible && ! isFloating ())
649 if (titleBarWidget ())
652 docksig = SIGNAL (triggered (
bool));
657 docksig = SIGNAL (clicked (
bool));
665 connect (dockobj, docksig,
this, SLOT (
default_dock (
bool)));
687 QString css_foreground;
688 QString css_background;
694 QString close_tooltip =
"Close widget";
695 QString dock_tooltip;
699 dock_icon =
"widget-dock";
700 dock_tooltip =
"Dock widget";
704 dock_icon =
"widget-undock";
705 dock_tooltip =
"Undock widget";
708 #if defined (Q_OS_MAC)
709 QString alignment =
"center";
711 QString alignment =
"center left";
716 QColor bg_col, fg_col;
731 QColor bg_col_top, bg_col_bottom;
734 bg_col_top = bg_col.lighter (100 +
m_title_3d);
735 bg_col_bottom = bg_col.darker (100 +
m_title_3d);
739 bg_col_top = bg_col.darker (100 -
m_title_3d);
740 bg_col_bottom = bg_col.lighter (100 -
m_title_3d);
743 css_foreground = QString (
" color: %1;\n").arg (fg_col.name ());
746 QString (
" background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
747 " stop: 0 %1, stop: 0.60 %2, stop: 0.95 %2 stop: 1.0 %3);\n").
748 arg (bg_col_top.name ()).
749 arg (bg_col.name ()).
750 arg (bg_col_bottom.name ());
754 css_foreground = QString (
"");
755 css_background = QString (
"");
758 QString full_dock_icon =
":/actions/icons/" + dock_icon + icon_col +
".png";
759 QString full_close_icon =
":/actions/icons/widget-close" + icon_col +
".png";
760 if (titleBarWidget ())
762 titleBarWidget ()->setStyleSheet (css_foreground + css_background);
763 css_button = QString (
"QToolButton {background: transparent; border: 0px;}");
Base class for Octave interfaces that use Qt.
resource_manager & get_resource_manager(void)
shortcut_manager & get_shortcut_manager(void)
gui_settings * get_settings(void) const
bool update_settings_key(const QString &new_key, const QString &old_key)
void set_shortcut(QAction *action, const sc_pref &scpref)
const gui_pref dw_title_bg_color("DockWidgets/title_bg_color", QVariant(QColor(255, 255, 255)))
const gui_pref dw_title_fg_color("DockWidgets/title_fg_color", QVariant(QColor(0, 0, 0)))
const gui_pref dw_title_3d("DockWidgets/widget_title_3d", QVariant(50))
const gui_pref dw_title_fg_color_active("DockWidgets/title_fg_color_active", QVariant(QColor(0, 0, 0)))
const gui_pref dw_is_floating("DockWidgets/%1Floating", QVariant(false))
const gui_pref dw_dock_geometry("DockWidgets/%1", QVariant(QRect(10, 10, 240, 320)))
const gui_pref dw_is_visible("DockWidgets/%1Visible", QVariant(true))
const gui_pref dw_is_minimized("DockWidgets/%1_minimized", QVariant(false))
const gui_pref dw_title_bg_color_active("DockWidgets/title_bg_color_active", QVariant(QColor(192, 192, 192)))
const gui_pref dw_title_custom_style("DockWidgets/widget_title_custom_style", QVariant(false))
const gui_pref dw_float_geometry("DockWidgets/%1_floating_geometry", QVariant(QRect(50, 50, 480, 640)))
const QString global_toolbar_style("QToolBar {" "spacing-top: 0px;" "spacing-bottom: 0px;" "margin-top: 0px;" "margin-bottom: 0px;" "padding-top: 0px;" "padding-bottom: 0px;" "border-top: 0px;" "border-bottom: 0px;" "}")
const QString global_menubar_style("QMenuBar {" "spacing-top: 0px;" "spacing-bottom: 0px;" "margin-top: 0px;" "margin-bottom: 0px;" "padding-top: 0px;" "padding-bottom: 0px;" "}")
const gui_pref mw_state("MainWindow/windowState", QVariant(QByteArray()))
const sc_pref sc_dock_widget_dock(sc_dock_widget+":dock", CTRL_ALT+Qt::Key_D)
const sc_pref sc_dock_widget_close(sc_dock_widget+":close", CTRL_ALT+Qt::Key_C)
F77_RET_T const F77_DBLE * x
std::complex< double > w(std::complex< double > z, double relerr=0)
static QString qdockwidget_css(const QString &close_icon, const QString &close_tooltip, const QString &float_icon, const QString &float_tooltip, int icon_size, const QString &titlebar_foreground, const QString &titlebar_background)
std::function< void(octave::interpreter &)> meth_callback
std::function< void(void)> fcn_callback
octave_value::octave_value(const Array< char > &chm, char type) return retval