Changeset View
Changeset View
Standalone View
Standalone View
kstyle/breezetoolsareamanager.cpp
1 | #include "breezetoolsareamanager.h" | 1 | #include "breezetoolsareamanager.h" | ||
---|---|---|---|---|---|
2 | #include <QObject> | 2 | #include <QObject> | ||
3 | #include <QWidget> | 3 | #include <QWidget> | ||
4 | #include <QToolBar> | 4 | #include <QToolBar> | ||
5 | #include <QWindow> | 5 | #include <QWindow> | ||
6 | #include <QMainWindow> | 6 | #include <QMainWindow> | ||
7 | #include <QMoveEvent> | ||||
7 | #include <QDebug> | 8 | #include <QDebug> | ||
8 | 9 | | |||
9 | namespace Breeze { | 10 | namespace Breeze { | ||
10 | ToolsAreaManager::ToolsAreaManager(Helper *helper, QObject *parent) : QObject(parent), _helper(helper) {} | 11 | ToolsAreaManager::ToolsAreaManager(Helper *helper, QObject *parent) : QObject(parent), _helper(helper) {} | ||
11 | 12 | | |||
12 | ToolsAreaManager::~ToolsAreaManager() {} | 13 | ToolsAreaManager::~ToolsAreaManager() {} | ||
13 | 14 | | |||
14 | void ToolsAreaManager::updateAnimations() { | 15 | void ToolsAreaManager::updateAnimations() { | ||
▲ Show 20 Lines • Show All 113 Lines • ▼ Show 20 Line(s) | 125 | if (!_registeredWindows.contains(window)) { | |||
128 | }; | 129 | }; | ||
129 | connect(window, &QWindow::widthChanged, geoUpdate); | 130 | connect(window, &QWindow::widthChanged, geoUpdate); | ||
130 | connect(window, &QWindow::heightChanged, geoUpdate); | 131 | connect(window, &QWindow::heightChanged, geoUpdate); | ||
131 | connect(window, &QWindow::destroyed, geoUpdate); | 132 | connect(window, &QWindow::destroyed, geoUpdate); | ||
132 | _registeredWindows << window; | 133 | _registeredWindows << window; | ||
133 | } | 134 | } | ||
134 | } | 135 | } | ||
135 | 136 | | |||
137 | bool ToolsAreaManager::eventFilter(QObject *watched, QEvent *event) | ||||
138 | { | ||||
139 | if (event->type() == QEvent::Move) { | ||||
140 | auto moveEvent = static_cast<QMoveEvent*>(event); | ||||
141 | if (moveEvent->oldPos() != moveEvent->pos()) { | ||||
142 | Q_EMIT toolbarUpdated(); | ||||
143 | } | ||||
144 | } | ||||
145 | return false; | ||||
146 | } | ||||
147 | | ||||
136 | void ToolsAreaManager::registerWidget(QWidget *widget) | 148 | void ToolsAreaManager::registerWidget(QWidget *widget) | ||
137 | { | 149 | { | ||
138 | auto win = widget->window(); | 150 | auto win = widget->window(); | ||
139 | if (win) { | 151 | if (win) { | ||
140 | auto handle = win->windowHandle(); | 152 | auto handle = win->windowHandle(); | ||
141 | if (handle) { | 153 | if (handle) { | ||
142 | registerWindow(handle); | 154 | registerWindow(handle); | ||
143 | } | 155 | } | ||
Show All 12 Lines | |||||
156 | connect(this, &ToolsAreaManager::toolbarUpdated, | 168 | connect(this, &ToolsAreaManager::toolbarUpdated, | ||
157 | widget, [widget, this]() { | 169 | widget, [widget, this]() { | ||
158 | widget->update(); | 170 | widget->update(); | ||
159 | auto win = widget->window(); | 171 | auto win = widget->window(); | ||
160 | if (win) { | 172 | if (win) { | ||
161 | auto handle = win->windowHandle(); | 173 | auto handle = win->windowHandle(); | ||
162 | if (handle) { | 174 | if (handle) { | ||
163 | _helper->_cachedRects.remove(handle); | 175 | _helper->_cachedRects.remove(handle); | ||
176 | widget->repaint(); | ||||
164 | } | 177 | } | ||
165 | } | 178 | } | ||
166 | }); | 179 | }); | ||
167 | auto toolbar = qobject_cast<QToolBar*>(widget); | 180 | auto toolbar = qobject_cast<QToolBar*>(widget); | ||
168 | if (toolbar) { | 181 | if (toolbar) { | ||
169 | connect(this, &ToolsAreaManager::toolbarUpdated, | 182 | connect(this, &ToolsAreaManager::toolbarUpdated, | ||
170 | widget, [=]() { | 183 | widget, [=]() { | ||
171 | const auto rect = _helper->toolsAreaToolbarsRect(widget); | 184 | const auto rect = _helper->toolsAreaToolbarsRect(widget); | ||
Show All 10 Lines | |||||
182 | connect(toolbar, &QToolBar::orientationChanged, | 195 | connect(toolbar, &QToolBar::orientationChanged, | ||
183 | this, [this]() { | 196 | this, [this]() { | ||
184 | emit toolbarUpdated(); | 197 | emit toolbarUpdated(); | ||
185 | }); | 198 | }); | ||
186 | connect(toolbar, &QToolBar::topLevelChanged, | 199 | connect(toolbar, &QToolBar::topLevelChanged, | ||
187 | this, [this]() { | 200 | this, [this]() { | ||
188 | emit toolbarUpdated(); | 201 | emit toolbarUpdated(); | ||
189 | }); | 202 | }); | ||
190 | <<<<<<< HEAD | | |||
191 | toolbar->installEventFilter(this); | 203 | toolbar->installEventFilter(this); | ||
192 | ======= | | |||
193 | >>>>>>> c2487fc1... [kstyle] Tools area | | |||
194 | } | 204 | } | ||
195 | connect(widget, &QObject::destroyed, | 205 | connect(widget, &QObject::destroyed, | ||
196 | this, [this, widget]() { | 206 | this, [this, widget]() { | ||
197 | unregisterWidget(widget); | 207 | unregisterWidget(widget); | ||
198 | }); | 208 | }); | ||
199 | registerAnimation(widget); | 209 | registerAnimation(widget); | ||
200 | _registeredWidgets << widget; | 210 | _registeredWidgets << widget; | ||
201 | emit toolbarUpdated(); | 211 | emit toolbarUpdated(); | ||
202 | } | 212 | } | ||
203 | 213 | | |||
204 | bool ToolsAreaManager::widgetHasCorrectPaletteSet(const QWidget *widget) | 214 | bool ToolsAreaManager::widgetHasCorrectPaletteSet(const QWidget *widget) | ||
205 | { | 215 | { | ||
206 | if (animationRunning(widget)) return true; | 216 | if (animationRunning(widget)) return true; | ||
207 | return ( | 217 | return ( | ||
208 | widget->palette().color(QPalette::Window) == background(widget) | 218 | widget->palette().color(QPalette::Window) == background(widget) | ||
209 | && | 219 | && | ||
210 | widget->palette().color(QPalette::WindowText) == foreground(widget) | 220 | widget->palette().color(QPalette::WindowText) == foreground(widget) | ||
211 | ); | 221 | ); | ||
212 | } | 222 | } | ||
213 | 223 | | |||
214 | void ToolsAreaManager::unregisterWidget(QWidget *widget) | 224 | void ToolsAreaManager::unregisterWidget(QWidget *widget) | ||
215 | { | 225 | { | ||
216 | <<<<<<< HEAD | | |||
217 | if (qobject_cast<QToolBar*>(widget)) { | 226 | if (qobject_cast<QToolBar*>(widget)) { | ||
218 | widget->setContentsMargins(0,0,0,0); | 227 | widget->setContentsMargins(0,0,0,0); | ||
219 | widget->removeEventFilter(this); | 228 | widget->removeEventFilter(this); | ||
220 | } | 229 | } | ||
221 | ======= | | |||
222 | if (qobject_cast<QToolBar*>(widget)) widget->setContentsMargins(0,0,0,0); | | |||
223 | >>>>>>> c2487fc1... [kstyle] Tools area | | |||
224 | _registeredWidgets.remove(widget); | 230 | _registeredWidgets.remove(widget); | ||
225 | QList<QWindow*> toRemove; | 231 | QList<QWindow*> toRemove; | ||
226 | for (auto window : animationMap.keys()) { | 232 | for (auto window : animationMap.keys()) { | ||
227 | if (std::none_of(_registeredWidgets.begin(), _registeredWidgets.end(), [window](QWidget *widget) { | 233 | if (std::none_of(_registeredWidgets.begin(), _registeredWidgets.end(), [window](QWidget *widget) { | ||
228 | return window == widget->window()->windowHandle(); | 234 | return window == widget->window()->windowHandle(); | ||
229 | })) { | 235 | })) { | ||
230 | delete animationMap[window].foregroundColorAnimation; | 236 | delete animationMap[window].foregroundColorAnimation; | ||
231 | delete animationMap[window].backgroundColorAnimation; | 237 | delete animationMap[window].backgroundColorAnimation; | ||
Show All 9 Lines |