26 #if defined (HAVE_CONFIG_H)
31 #include <QApplication>
32 #include <QHBoxLayout>
54 m_default_float_button (
nullptr), m_default_close_button (
nullptr)
56 QStyle *st = style ();
57 m_icon_size = 0.75*st->pixelMetric (QStyle::PM_SmallIconSize);
62 if (buttonlist.size () == 2)
64 if (buttonlist.at (0)->x () < buttonlist.at (1)->x ())
66 m_default_float_button = buttonlist.at (0);
67 m_default_close_button = buttonlist.at (1);
71 m_default_float_button = buttonlist.at (1);
72 m_default_close_button = buttonlist.at (0);
79 m_title_widget =
new QWidget ();
81 m_dock_action =
new QAction
82 (rmgr.
icon (
"widget-undock",
true),
"",
this);
83 m_dock_action->setToolTip (tr (
"Undock widget"));
85 m_dock_button->setDefaultAction (m_dock_action);
86 m_dock_button->setFocusPolicy (Qt::NoFocus);
87 m_dock_button->setIconSize (QSize (m_icon_size, m_icon_size));
89 m_close_action =
new QAction
90 (rmgr.
icon (
"widget-close",
true),
"",
this);
91 m_close_action->setToolTip (tr (
"Close widget"));
93 m_close_button->setDefaultAction (m_close_action);
94 m_close_button->setFocusPolicy (Qt::NoFocus);
95 m_close_button->setIconSize (QSize (m_icon_size, m_icon_size));
97 QString css_button = QString (
"QToolButton {background: transparent; border: 0px;}");
98 m_dock_button->setStyleSheet (css_button);
99 m_close_button->setStyleSheet (css_button);
101 QHBoxLayout *h_layout =
new QHBoxLayout ();
102 h_layout->addStretch (100);
103 h_layout->addWidget (m_dock_button);
104 h_layout->addWidget (m_close_button);
105 h_layout->setSpacing (10);
106 h_layout->setContentsMargins (5, 2, 2, 2);
108 m_title_widget->setLayout (h_layout);
114 connect (p, SIGNAL (copyClipboard_signal ()),
115 this, SLOT (copyClipboard ()));
116 connect (p, SIGNAL (pasteClipboard_signal ()),
117 this, SLOT (pasteClipboard ()));
118 connect (p, SIGNAL (selectAll_signal ()),
119 this, SLOT (selectAll ()));
122 connect (p, SIGNAL (undo_signal ()),
this, SLOT (do_undo ()));
130 QHBoxLayout *h_layout
133 label->setStyleSheet (
"background-color: transparent;");
134 h_layout->insertWidget (0, label);
136 setWindowTitle (title);
141 const QString& float_icon,
const QString& float_tooltip,
142 int icon_size,
const QString& titlebar_foreground,
143 const QString& titlebar_background)
145 return QString (
"QDockWidget\n"
149 " titlebar-close-icon: url(%1);\n"
150 " titlebar-normal-icon: url(%2);\n"
153 "QDockWidget::close-button, QDockWidget::float-button\n"
156 " icon-size: %3px;\n"
159 "QAbstractButton#qt_dockwidget_closebutton\n"
161 " qproperty-toolTip: \"%4\";\n"
164 "QAbstractButton#qt_dockwidget_floatbutton\n"
166 " qproperty-toolTip: \"%5\";\n"
169 "QDockWidget::title {\n"
170 " text-align: left;\n"
172 " padding-left: 1px;\n"
175 "QDockWidget::close-button\n"
181 "QDockWidget::float-button\n"
186 ).arg (close_icon).arg (float_icon).arg (icon_size)
187 .arg (close_tooltip).arg (float_tooltip)
188 .arg (titlebar_foreground).arg (titlebar_background)
189 .arg ((icon_size*2)/3).arg((icon_size*7)/3);
195 m_custom_style (false), m_focus_follows_mouse (false),
196 m_recent_float_geom (), m_recent_dock_geom (),
197 m_waiting_for_mouse_button_release (false)
199 setObjectName (obj_name);
206 connect (
this, &octave_dock_widget::topLevelChanged,
208 connect (
this, &octave_dock_widget::visibilityChanged,
220 this, [=] () {
make_widget (); }, Qt::QueuedConnection);
224 m_dock_action->setShortcutContext (Qt::WidgetWithChildrenShortcut);
230 m_close_action->setShortcutContext (Qt::WidgetWithChildrenShortcut);
239 QString (
"Close widget"),
241 QString (
"Undock widget"),
247 widget ()->setToolTip (QString (
""));
252 installEventFilter (
this);
254 setFocusPolicy (Qt::StrongFocus);
256 setFeatures (QDockWidget::DockWidgetClosable
257 | QDockWidget::DockWidgetMovable
258 | QDockWidget::DockWidgetFloatable);
274 bool vis = isVisible ();
282 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 ();
359 m_main_window->addDockWidget (Qt::BottomDockWidgetArea,
this);
374 if (titleBarWidget ())
387 QApplication::setActiveWindow (
this);
440 QDockWidget::closeEvent (e);
447 QWidget *
w = QApplication::focusWidget ();
448 if (
w &&
w->focusProxy ())
w =
w->focusProxy ();
457 if ( (
event->type () == QEvent::MouseButtonDblClick && ! isFloating ())
458 || (
event->type () == QEvent::ActivationChange
461 bool retval = QDockWidget::event (
event);
462 if (isFloating () && parent () != 0)
470 return QDockWidget::event (
event);
502 bcol = QWidget::palette ().color (
m_title_widget->backgroundRole ());
507 bcol.getRgb (&
r, &g, &b);
513 bcola.getRgb (&
r, &g, &b);
520 QGuiApplication::primaryScreen ()->availableGeometry ().getRect (&
x, &y, &
w, &h);
521 QRect default_floating_size = QRect (
x+16, y+32,
w/3, h/2);
523 QRect default_dock_size;
528 default_dock_size = QRect (
x+16, y+32,
w/3, h/3);
533 default_dock_size = QRect (0, 0,
w/10, h/10);
538 default_floating_size).toRect ();
548 if (dock_geom.canConvert (QMetaType::QRect))
558 QToolBar *toolbar = findChild <QToolBar *> ();
562 QMenuBar *menubar = findChild <QMenuBar *> ();
589 QString name = objectName ();
614 if (e->type () == QEvent::NonClientAreaMouseButtonDblClick)
626 return QDockWidget::eventFilter (obj, e);
648 QDockWidget::moveEvent (
event);
656 QDockWidget::resizeEvent (
event);
693 if (titleBarWidget ())
696 docksig = SIGNAL (triggered (
bool));
701 docksig = SIGNAL (clicked (
bool));
709 connect (dockobj, docksig,
this, SLOT (
default_dock (
bool)));
731 QString css_foreground;
732 QString css_background;
738 QString close_tooltip =
"Close widget";
739 QString dock_tooltip;
743 dock_icon =
"widget-dock";
744 dock_tooltip =
"Dock widget";
748 dock_icon =
"widget-undock";
749 dock_tooltip =
"Undock widget";
752 #if defined (Q_OS_MAC)
753 QString alignment =
"center";
755 QString alignment =
"center left";
760 QColor bg_col, fg_col;
775 QColor bg_col_top, bg_col_bottom;
778 bg_col_top = bg_col.lighter (100 +
m_title_3d);
779 bg_col_bottom = bg_col.darker (100 +
m_title_3d);
783 bg_col_top = bg_col.darker (100 -
m_title_3d);
784 bg_col_bottom = bg_col.lighter (100 -
m_title_3d);
787 css_foreground = QString (
" color: %1;\n").arg (fg_col.name ());
790 QString (
" background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
791 " stop: 0 %1, stop: 0.60 %2, stop: 0.95 %2 stop: 1.0 %3);\n").
792 arg (bg_col_top.name ()).
793 arg (bg_col.name ()).
794 arg (bg_col_bottom.name ());
798 css_foreground = QString (
"");
799 css_background = QString (
"");
802 QString full_dock_icon = dock_icon + icon_col;
803 QString full_close_icon =
"widget-close" + icon_col;
804 if (titleBarWidget ())
807 titleBarWidget ()->setStyleSheet (css_foreground + css_background);
808 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)
Represents the main window.
void pasteClipboard_signal(void)
void copyClipboard_signal(void)
void selectAll_signal(void)
bool update_settings_key(const QString &new_key, const QString &old_key)
gui_settings * get_settings(void) const
QIcon icon(const QString &icon_name, bool octave_only=false, const QString &icon_alt_name=QString())
void set_shortcut(QAction *action, const sc_pref &scpref, bool enable=true)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
const gui_pref dw_title_3d("DockWidgets/widget_title_3d", QVariant(20))
const gui_pref dw_title_fg_color("DockWidgets/title_fg_color", QVariant(QColor(0, 0, 0)))
const gui_pref dw_is_floating("DockWidgets/%1Floating", QVariant(false))
const gui_pref dw_title_fg_color_active("DockWidgets/title_fg_color_active", QVariant(QColor(255, 255, 255)))
const gui_pref dw_title_custom_style("DockWidgets/widget_title_custom_style", QVariant(true))
const gui_pref dw_focus_follows_mouse("DockWidgets/focus_follows_mouse", QVariant(false))
const gui_pref dw_title_bg_color_active("DockWidgets/title_bg_color_active", QVariant(QColor(128, 128, 128)))
const gui_pref dw_dock_geometry("DockWidgets/%1", QVariant(QRect(10, 10, 240, 320)))
const gui_pref dw_title_bg_color("DockWidgets/title_bg_color", QVariant(QColor(192, 192, 192)))
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_float_geometry("DockWidgets/%1_floating_geometry", QVariant(QRect(50, 50, 480, 640)))
const QString global_menubar_style("QMenuBar {" "margin-top: 0px;" "margin-bottom: 0px;" "padding-top: 0px;" "padding-bottom: 0px;" "}")
const QString gui_obj_name_main_window
const QStringList global_icon_paths
const QString global_toolbar_style("QToolBar {" "margin-top: 0px;" "margin-bottom: 0px;" "padding-top: 0px;" "padding-bottom: 0px;" "border-top: 0px;" "border-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)
OCTGUI_API void adjust_to_screen(QRect &actual_geometry, const QRect &default_geometry)
F77_RET_T const F77_DBLE * x
std::complex< double > w(std::complex< double > z, double relerr=0)