28 #include <QApplication>
30 #include <QToolButton>
32 #include <QHBoxLayout>
47 connect (
this, SIGNAL (visibilityChanged (
bool)),
50 connect (p, SIGNAL (settings_changed (
const QSettings*)),
53 #if defined (Q_OS_WIN32)
56 setFeatures (QDockWidget::DockWidgetMovable);
60 (QIcon (
":/actions/icons/widget-undock.png"),
"",
this);
64 QToolButton *dock_button =
new QToolButton (
this);
66 dock_button->setFocusPolicy (Qt::NoFocus);
67 dock_button->setIconSize (QSize (12,12));
69 QAction *close_action =
new QAction
70 (QIcon (
":/actions/icons/widget-close.png"),
"",
this );
71 close_action-> setToolTip (tr (
"Hide widget"));
72 connect (close_action, SIGNAL (triggered (
bool)),
74 QToolButton *close_button =
new QToolButton (
this);
75 close_button->setDefaultAction (close_action);
76 close_button->setFocusPolicy (Qt::NoFocus);
77 close_button->setIconSize (QSize (12,12));
79 QHBoxLayout *h_layout =
new QHBoxLayout ();
80 h_layout->addStretch (100);
81 h_layout->addWidget (dock_button);
82 h_layout->addWidget (close_button);
83 h_layout->setSpacing (0);
84 h_layout->setContentsMargins (6,0,0,0);
87 title_widget->setLayout (h_layout);
88 setTitleBarWidget (title_widget);
93 setFeatures (QDockWidget::DockWidgetMovable |
94 QDockWidget::DockWidgetClosable |
95 QDockWidget::DockWidgetFloatable);
97 connect (
this, SIGNAL (topLevelChanged (
bool)),
103 connect (p, SIGNAL (copyClipboard_signal ()),
105 connect (p, SIGNAL (pasteClipboard_signal ()),
112 QString name = objectName ();
115 settings->beginGroup (
"DockWidgets");
117 #if defined (Q_OS_WIN32)
119 settings->setValue (name+
"_floating_geometry", geometry ());
122 settings->setValue (name, saveGeometry ());
124 settings->setValue (name+
"Visible", isVisible ());
125 settings->setValue (name+
"Floating",
_floating);
126 settings->setValue (name+
"_minimized", isMinimized ());
128 settings->endGroup ();
136 connect (
this, SIGNAL (visibilityChanged (
bool)),
146 #if defined (Q_OS_WIN32)
147 QHBoxLayout* h_layout =
148 static_cast<QHBoxLayout *
> (titleBarWidget ()->layout ());
149 QLabel *label =
new QLabel (title);
150 h_layout->insertWidget (0,label);
152 setWindowTitle (title);
159 #if defined (Q_OS_WIN32)
167 settings->setValue (
"DockWidgets/" + objectName () +
"_dock_area",
168 _parent->dockWidgetArea (
this));
169 settings->setValue (
"DockWidgets/" + objectName (), saveGeometry ());
173 setParent (0, Qt::Window);
174 _dock_action->setIcon (QIcon (
":/actions/icons/widget-dock.png"));
178 setGeometry (settings->value (
"DockWidgets/" + objectName ()
179 +
"_floating_geometry",QRect(50,100,480,480)).toRect ());
184 setWindowFlags (Qt::Window);
195 #if defined (Q_OS_WIN32)
203 settings->setValue (
"DockWidgets/" + objectName () +
"_floating_geometry",
210 int area = settings->value (
"DockWidgets/" + objectName () +
"_dock_area",
211 Qt::TopDockWidgetArea).toInt ();
212 _parent->addDockWidget (static_cast<Qt::DockWidgetArea> (area),
this);
216 restoreGeometry (settings->value
217 (
"DockWidgets/" + objectName ()).toByteArray ());
223 _dock_action->setIcon (QIcon (
":/actions/icons/widget-undock.png"));
229 setWindowFlags (Qt::Widget);
262 if (w && w->focusProxy ()) w = w->focusProxy ();