Changeset View
Changeset View
Standalone View
Standalone View
kstyle/breezehelper.h
Show All 17 Lines | |||||
18 | * along with this program; if not, write to the * | 18 | * along with this program; if not, write to the * | ||
19 | * Free Software Foundation, Inc., * | 19 | * Free Software Foundation, Inc., * | ||
20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * | 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * | ||
21 | *************************************************************************/ | 21 | *************************************************************************/ | ||
22 | 22 | | |||
23 | 23 | | |||
24 | #include "breeze.h" | 24 | #include "breeze.h" | ||
25 | #include "breezeanimationdata.h" | 25 | #include "breezeanimationdata.h" | ||
26 | #include "breezesettings.h" | ||||
26 | #include "config-breeze.h" | 27 | #include "config-breeze.h" | ||
27 | 28 | | |||
28 | #include <KColorScheme> | 29 | #include <KColorScheme> | ||
29 | #include <KSharedConfig> | 30 | #include <KSharedConfig> | ||
31 | #include <KConfigWatcher> | ||||
30 | 32 | | |||
33 | #include <QToolBar> | ||||
31 | #include <QPainterPath> | 34 | #include <QPainterPath> | ||
32 | #include <QWidget> | 35 | #include <QWidget> | ||
33 | 36 | | |||
34 | namespace Breeze | 37 | namespace Breeze | ||
35 | { | 38 | { | ||
36 | 39 | | |||
37 | //* breeze style helper class. | 40 | //* breeze style helper class. | ||
38 | /** contains utility functions used at multiple places in both breeze style and breeze window decoration */ | 41 | /** contains utility functions used at multiple places in both breeze style and breeze window decoration */ | ||
39 | class Helper | 42 | class Helper : public QObject | ||
40 | { | 43 | { | ||
44 | Q_OBJECT | ||||
45 | | ||||
41 | public: | 46 | public: | ||
42 | 47 | | |||
43 | //* constructor | 48 | //* constructor | ||
44 | explicit Helper( KSharedConfig::Ptr ); | 49 | explicit Helper( KSharedConfig::Ptr, QObject *parent = nullptr ); | ||
45 | 50 | | |||
46 | //* destructor | 51 | //* destructor | ||
47 | virtual ~Helper() | 52 | virtual ~Helper() | ||
48 | {} | 53 | {} | ||
49 | 54 | | |||
50 | //* load configuration | 55 | //* load configuration | ||
51 | virtual void loadConfig(); | 56 | virtual void loadConfig(); | ||
52 | 57 | | |||
53 | //* pointer to shared config | 58 | //* pointer to shared config | ||
54 | KSharedConfig::Ptr config() const; | 59 | KSharedConfig::Ptr config() const; | ||
55 | 60 | | |||
61 | //* pointer to kdecoration config | ||||
62 | QSharedPointer<InternalSettings> decorationConfig() const; | ||||
63 | | ||||
56 | //*@name color utilities | 64 | //*@name color utilities | ||
57 | //@{ | 65 | //@{ | ||
58 | 66 | | |||
59 | //* add alpha channel multiplier to color | 67 | //* add alpha channel multiplier to color | ||
60 | QColor alphaColor( QColor color, qreal alpha ) const; | 68 | QColor alphaColor( QColor color, qreal alpha ) const; | ||
61 | 69 | | |||
62 | //* mouse over color | 70 | //* mouse over color | ||
63 | QColor hoverColor( const QPalette& palette ) const | 71 | QColor hoverColor( const QPalette& palette ) const | ||
▲ Show 20 Lines • Show All 194 Lines • ▼ Show 20 Line(s) | |||||
258 | static bool isWayland(); | 266 | static bool isWayland(); | ||
259 | 267 | | |||
260 | //* returns true if compositing is active | 268 | //* returns true if compositing is active | ||
261 | bool compositingActive() const; | 269 | bool compositingActive() const; | ||
262 | 270 | | |||
263 | //* returns true if a given widget supports alpha channel | 271 | //* returns true if a given widget supports alpha channel | ||
264 | bool hasAlphaChannel( const QWidget* ) const; | 272 | bool hasAlphaChannel( const QWidget* ) const; | ||
265 | 273 | | |||
274 | //* returns true if widget is in the tools area | ||||
275 | bool isInToolsArea( const QWidget* ) const; | ||||
276 | | ||||
277 | //* returns false if tools area is empty | ||||
278 | bool toolsAreaHasContents ( const QWidget* ) const; | ||||
279 | | ||||
280 | //* returns true if tools area has a toolbar | ||||
281 | bool toolsAreaHasToolBar ( const QWidget* ) const; | ||||
282 | | ||||
283 | //* returns true if the tools area should be drawn | ||||
284 | bool shouldDrawToolsArea ( const QWidget* ) const; | ||||
285 | | ||||
286 | //* returns the tools area border color | ||||
287 | QColor toolsAreaBorderColor ( const QWidget* ) const; | ||||
288 | | ||||
289 | //* returns the united rectangle of all toolbars in the tools area | ||||
290 | QRect toolsAreaToolbarsRect (const QWidget* widget) const; | ||||
291 | | ||||
292 | QToolBar* grabToolBarForToolsArea ( const QWidget* ) const; | ||||
293 | | ||||
294 | void setToolsAreaEnabled(bool enabled) | ||||
295 | { _toolsAreaEnabled = enabled; }; | ||||
296 | | ||||
266 | //@} | 297 | //@} | ||
267 | 298 | | |||
268 | //* return device pixel ratio for a given pixmap | 299 | //* return device pixel ratio for a given pixmap | ||
269 | virtual qreal devicePixelRatio( const QPixmap& ) const; | 300 | virtual qreal devicePixelRatio( const QPixmap& ) const; | ||
270 | 301 | | |||
271 | //* frame radius | 302 | //* frame radius | ||
272 | constexpr qreal frameRadius( const int penWidth = PenWidth::NoPen, const qreal bias = 0 ) const | 303 | constexpr qreal frameRadius( const int penWidth = PenWidth::NoPen, const qreal bias = 0 ) const | ||
273 | { return qMax( Metrics::Frame_FrameRadius - (0.5 * penWidth) + bias, 0.0 ); } | 304 | { return qMax( Metrics::Frame_FrameRadius - (0.5 * penWidth) + bias, 0.0 ); } | ||
Show All 13 Lines | |||||
287 | //* return rounded path in a given rect, with only selected corners rounded, and for a given radius | 318 | //* return rounded path in a given rect, with only selected corners rounded, and for a given radius | ||
288 | QPainterPath roundedPath( const QRectF&, Corners, qreal ) const; | 319 | QPainterPath roundedPath( const QRectF&, Corners, qreal ) const; | ||
289 | 320 | | |||
290 | private: | 321 | private: | ||
291 | 322 | | |||
292 | //* configuration | 323 | //* configuration | ||
293 | KSharedConfig::Ptr _config; | 324 | KSharedConfig::Ptr _config; | ||
294 | 325 | | |||
326 | //* KWin configuration | ||||
327 | KSharedConfig::Ptr _kwinConfig; | ||||
328 | | ||||
329 | //* decoration configuration | ||||
330 | QSharedPointer<InternalSettings> _decorationConfig; | ||||
331 | | ||||
295 | //*@name brushes | 332 | //*@name brushes | ||
296 | //@{ | 333 | //@{ | ||
297 | KStatefulBrush _viewFocusBrush; | 334 | KStatefulBrush _viewFocusBrush; | ||
298 | KStatefulBrush _viewHoverBrush; | 335 | KStatefulBrush _viewHoverBrush; | ||
299 | KStatefulBrush _viewNegativeTextBrush; | 336 | KStatefulBrush _viewNegativeTextBrush; | ||
300 | //@} | 337 | //@} | ||
301 | 338 | | |||
302 | //*@name windeco colors | 339 | //*@name windeco colors | ||
303 | //@{ | 340 | //@{ | ||
304 | QColor _activeTitleBarColor; | 341 | QColor _activeTitleBarColor; | ||
305 | QColor _activeTitleBarTextColor; | 342 | QColor _activeTitleBarTextColor; | ||
306 | QColor _inactiveTitleBarColor; | 343 | QColor _inactiveTitleBarColor; | ||
307 | QColor _inactiveTitleBarTextColor; | 344 | QColor _inactiveTitleBarTextColor; | ||
308 | //@} | 345 | //@} | ||
309 | 346 | | |||
347 | bool _toolsAreaEnabled; | ||||
348 | | ||||
349 | mutable QHash<QWindow*,QRect> _cachedRects; | ||||
350 | mutable bool _invalidateCachedRects; | ||||
351 | mutable bool _cachedAutoValid = false; | ||||
352 | | ||||
353 | friend class ToolsAreaManager; | ||||
354 | | ||||
310 | }; | 355 | }; | ||
311 | 356 | | |||
312 | } | 357 | } | ||
313 | 358 | | |||
314 | #endif | 359 | #endif |