28 #include <QApplication>
31 #include <QHBoxLayout>
48 connect (
this, SIGNAL (visibilityChanged (
bool)),
51 connect (p, SIGNAL (settings_changed (
const QSettings*)),
57 QStyle *st = style ();
58 _icon_size = 0.75*st->pixelMetric (QStyle::PM_SmallIconSize);
60 #if defined (Q_OS_WIN32)
63 setFeatures (QDockWidget::DockWidgetMovable);
66 _dock_action =
new QAction
67 (QIcon (
":/actions/icons/widget-undock.png"),
"",
this);
68 _dock_action-> setToolTip (tr (
"Undock widget"));
69 connect (_dock_action, SIGNAL (triggered (
bool)),
71 _dock_button =
new QToolButton (
this);
72 _dock_button->setDefaultAction (_dock_action);
73 _dock_button->setFocusPolicy (Qt::NoFocus);
76 _close_action =
new QAction
77 (QIcon (
":/actions/icons/widget-close.png"),
"",
this);
78 _close_action-> setToolTip (tr (
"Hide widget"));
79 connect (_close_action, SIGNAL (triggered (
bool)),
81 _close_button =
new QToolButton (
this);
82 _close_button->setDefaultAction (_close_action);
83 _close_button->setFocusPolicy (Qt::NoFocus);
89 QHBoxLayout *h_layout =
new QHBoxLayout ();
90 h_layout->addStretch (100);
91 h_layout->addWidget (_dock_button);
92 h_layout->addWidget (_close_button);
93 h_layout->setSpacing (0);
94 h_layout->setContentsMargins (5,2,2,2);
97 _title_widget->setLayout (h_layout);
98 setTitleBarWidget (_title_widget);
103 setFeatures (QDockWidget::DockWidgetMovable |
104 QDockWidget::DockWidgetClosable |
105 QDockWidget::DockWidgetFloatable);
107 connect (
this, SIGNAL (topLevelChanged (
bool)),
116 connect (p, SIGNAL (copyClipboard_signal ()),
118 connect (p, SIGNAL (pasteClipboard_signal ()),
120 connect (p, SIGNAL (selectAll_signal ()),
123 connect (p, SIGNAL (undo_signal ()),
this, SLOT (
do_undo ()));
125 installEventFilter (
this);
132 QString name = objectName ();
135 settings->beginGroup (
"DockWidgets");
137 #if defined (Q_OS_WIN32)
139 settings->setValue (name+
"_floating_geometry", geometry ());
142 settings->setValue (name, saveGeometry ());
144 settings->setValue (name+
"Visible", isVisible ());
145 settings->setValue (name+
"Floating",
_floating);
146 settings->setValue (name+
"_minimized", isMinimized ());
148 settings->endGroup ();
156 connect (
this, SIGNAL (visibilityChanged (
bool)),
173 #if defined (Q_OS_WIN32)
174 QHBoxLayout* h_layout =
175 static_cast<QHBoxLayout *
> (titleBarWidget ()->layout ());
176 QLabel *label =
new QLabel (title);
177 label->setStyleSheet (
"background: transparent;");
178 h_layout->insertWidget (0,label);
180 setWindowTitle (title);
197 #if defined (Q_OS_WIN32)
205 settings->setValue (
"DockWidgets/" + objectName () +
"_dock_area",
206 _parent->dockWidgetArea (
this));
207 settings->setValue (
"DockWidgets/" + objectName (), saveGeometry ());
211 setParent (0, Qt::Window);
212 _dock_action->setIcon (QIcon (
":/actions/icons/widget-dock"+
_icon_color+
".png"));
213 _dock_action->setToolTip (tr (
"Dock widget"));
216 setGeometry (settings->value (
"DockWidgets/" + objectName ()
217 +
"_floating_geometry",QRect(50,100,480,480)).toRect ());
222 setWindowFlags (Qt::Window);
224 QString css = styleSheet ();
225 css.replace (
"widget-undock",
"widget-dock");
240 #if defined (Q_OS_WIN32)
248 settings->setValue (
"DockWidgets/" + objectName () +
"_floating_geometry",
255 int area = settings->value (
"DockWidgets/" + objectName () +
"_dock_area",
256 Qt::TopDockWidgetArea).toInt ();
257 _parent->addDockWidget (static_cast<Qt::DockWidgetArea> (area),
this);
261 restoreGeometry (settings->value
262 (
"DockWidgets/" + objectName ()).toByteArray ());
268 _dock_action->setIcon (QIcon (
":/actions/icons/widget-undock"+
_icon_color+
".png"));
269 _dock_action->setToolTip (tr (
"Undock widget"));
277 setWindowFlags (Qt::Widget);
279 QString css = styleSheet ();
280 css.replace (
"widget-dock",
"widget-undock");
313 QWidget *
w = QApplication::focusWidget ();
314 if (w && w->focusProxy ()) w = w->focusProxy ();
328 dock_icon =
"widget-dock";
330 dock_icon =
"widget-undock";
335 QColor bg_col, fg_col;
350 QColor bg_col_top, bg_col_bottom;
353 bg_col_top = bg_col.lighter (100 +
_title_3d);
354 bg_col_bottom = bg_col.darker (100 +
_title_3d);
358 bg_col_top = bg_col.darker (100 -
_title_3d);
359 bg_col_bottom = bg_col.lighter (100 -
_title_3d);
363 QString (
"background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
364 " stop: 0 %1, stop: 0.60 %2, stop: 0.95 %2 stop: 1.0 %3);").
365 arg (bg_col_top.name ()).
366 arg (bg_col.name ()).
367 arg (bg_col_bottom.name ());
369 #if defined (Q_OS_WIN32)
370 css = background + QString (
" color: %1 ;").arg (fg_col.name ());
372 css = QString (
"QDockWidget::title { " + background +
373 " text-align: center left;"
374 " padding: 0px 0px 0px 4px;}\n"
375 "QDockWidget { color: %1 ; "
376 " titlebar-close-icon: url(:/actions/icons/widget-close%2.png);"
377 " titlebar-normal-icon: url(:/actions/icons/"+dock_icon+
"%2); }"
378 "QDockWidget::close-button,"
379 "QDockWidget::float-button { border: 0px; icon-size: %3px; width: %3px}"
386 #if defined (Q_OS_WIN32)
389 css = QString (
"QDockWidget::title { text-align: center left;"
390 " padding: 0px 0px 0px 4px;}"
392 " titlebar-close-icon: url(:/actions/icons/widget-close.png);"
393 " titlebar-normal-icon: url(:/actions/icons/"+dock_icon+
"); }"
394 "QDockWidget::close-button,"
395 "QDockWidget::float-button { border: 0px; icon-size: %1px; width: %1px}"
400 #if defined (Q_OS_WIN32)
401 _title_widget->setStyleSheet (css);
402 css_button = QString (
"background: transparent; border: 0px;");
403 _dock_button->setStyleSheet (css_button);
404 _close_button->setStyleSheet (css_button);
405 _dock_action->setIcon (QIcon (
":/actions/icons/" + dock_icon + icon_col +
407 _close_action->setIcon (QIcon (
":/actions/icons/widget-close" + icon_col +
418 settings->value (
"DockWidgets/widget_title_custom_style",
false).toBool ();
421 settings->value (
"DockWidgets/widget_title_3d",50).toInt ();
423 QColor default_var = QColor (0,0,0);
424 _fg_color = settings->value (
"Dockwidgets/title_fg_color",
425 default_var).value<QColor> ();
426 default_var = QColor (0,0,0);
428 default_var).value<QColor> ();
430 default_var = QColor (255,255,255);
431 _bg_color = settings->value (
"Dockwidgets/title_bg_color",
432 default_var).value<QColor> ();
433 default_var = QColor (192,192,192);
435 default_var).value<QColor> ();
457 if (e->type () == QEvent::NonClientAreaMouseButtonDblClick)
463 return QDockWidget::eventFilter (obj,e);
487 if (objectName () !=
"FileEditor")
488 addActions (action_list);
497 QDockWidget::closeEvent (e);
std::complex< double > w(std::complex< double > z, double relerr=0)
static QSettings * get_settings(void)