Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plasma
Plasma Breeze visual style
Commits
32149dc0
Commit
32149dc0
authored
Apr 30, 2022
by
Alexander Lohnau
💬
Browse files
Run clang-format
plasma-workspace#9
parent
8b13e977
Changes
110
Expand all
Hide whitespace changes
Inline
Side-by-side
kdecoration/breeze.h
View file @
32149dc0
...
...
@@ -9,51 +9,49 @@
#include "breezesettings.h"
#include <QSharedPointer>
#include <QList>
#include <QSharedPointer>
namespace
Breeze
{
//* convenience typedefs
using
InternalSettingsPtr
=
QSharedPointer
<
InternalSettings
>
;
using
InternalSettingsList
=
QList
<
InternalSettingsPtr
>
;
using
InternalSettingsListIterator
=
QListIterator
<
InternalSettingsPtr
>
;
//* metrics
namespace
Metrics
{
//* corner radius, in units of small spacing
static
constexpr
qreal
Frame_FrameRadius
=
2
;
//* titlebar metrics, in units of small spacing
static
constexpr
int
TitleBar_TopMargin
=
2
;
static
constexpr
int
TitleBar_BottomMargin
=
2
;
static
constexpr
int
TitleBar_SideMargin
=
2
;
static
constexpr
int
TitleBar_ButtonSpacing
=
2
;
// shadow dimensions (pixels)
static
constexpr
int
Shadow_Overlap
=
3
;
}
//* standard pen widths
namespace
PenWidth
{
/* Using 1 instead of slightly more than 1 causes symbols drawn with
* pen strokes to look skewed. The exact amount added does not matter
* as long as it isn't too visible.
*/
// The standard pen stroke width for symbols.
static
constexpr
qreal
Symbol
=
1.01
;
}
//* exception
enum
ExceptionMask
{
None
=
0
,
BorderSize
=
1
<<
4
,
};
//* convenience typedefs
using
InternalSettingsPtr
=
QSharedPointer
<
InternalSettings
>
;
using
InternalSettingsList
=
QList
<
InternalSettingsPtr
>
;
using
InternalSettingsListIterator
=
QListIterator
<
InternalSettingsPtr
>
;
//* metrics
namespace
Metrics
{
//* corner radius, in units of small spacing
static
constexpr
qreal
Frame_FrameRadius
=
2
;
//* titlebar metrics, in units of small spacing
static
constexpr
int
TitleBar_TopMargin
=
2
;
static
constexpr
int
TitleBar_BottomMargin
=
2
;
static
constexpr
int
TitleBar_SideMargin
=
2
;
static
constexpr
int
TitleBar_ButtonSpacing
=
2
;
// shadow dimensions (pixels)
static
constexpr
int
Shadow_Overlap
=
3
;
}
//* standard pen widths
namespace
PenWidth
{
/* Using 1 instead of slightly more than 1 causes symbols drawn with
* pen strokes to look skewed. The exact amount added does not matter
* as long as it isn't too visible.
*/
// The standard pen stroke width for symbols.
static
constexpr
qreal
Symbol
=
1.01
;
}
//* exception
enum
ExceptionMask
{
None
=
0
,
BorderSize
=
1
<<
4
,
};
}
#endif
kdecoration/breezebutton.cpp
View file @
32149dc0
This diff is collapsed.
Click to expand it.
kdecoration/breezebutton.h
View file @
32149dc0
...
...
@@ -2,13 +2,13 @@
#define BREEZE_BUTTONS_H
/*
* SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
* SPDX-FileCopyrightText: 2014 Hugo Pereira Da Costa <hugo.pereira@free.fr>
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#include <KDecoration2/DecorationButton>
* SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
* SPDX-FileCopyrightText: 2014 Hugo Pereira Da Costa <hugo.pereira@free.fr>
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#include "breezedecoration.h"
#include <KDecoration2/DecorationButton>
#include <QHash>
#include <QImage>
...
...
@@ -17,107 +17,119 @@ class QVariantAnimation;
namespace
Breeze
{
class
Button
:
public
KDecoration2
::
DecorationButton
{
Q_OBJECT
class
Button
:
public
KDecoration2
::
DecorationButton
{
Q_OBJECT
public:
//* constructor
explicit
Button
(
QObject
*
parent
,
const
QVariantList
&
args
);
//* destructor
virtual
~
Button
()
=
default
;
public:
//* constructor
explicit
Button
(
QObject
*
parent
,
const
QVariantList
&
args
);
//*
button creation
static
Button
*
create
(
KDecoration2
::
DecorationButtonType
type
,
KDecoration2
::
Decoration
*
decoration
,
QObject
*
parent
)
;
//*
destructor
virtual
~
Button
()
=
default
;
//*
render
virtual
void
paint
(
QPainter
*
painter
,
const
QRect
&
repaintRegion
)
override
;
//*
button creation
static
Button
*
create
(
KDecoration2
::
DecorationButtonType
type
,
KDecoration2
::
Decoration
*
decoration
,
QObject
*
parent
)
;
//* flag
enum
Flag
{
FlagNone
,
FlagStandalone
,
FlagFirstInList
,
FlagLastInList
,
};
//* render
virtual
void
paint
(
QPainter
*
painter
,
const
QRect
&
repaintRegion
)
override
;
//* flag
void
setFlag
(
Flag
value
)
{
m_flag
=
value
;
}
//* flag
enum
Flag
{
FlagNone
,
FlagStandalone
,
FlagFirstInList
,
FlagLastInList
,
};
//* standalone buttons
bool
isStandAlone
()
const
{
return
m_flag
==
FlagStandalone
;
}
//* flag
void
setFlag
(
Flag
value
)
{
m_flag
=
value
;
}
//* offset
void
setOffset
(
const
QPointF
&
value
)
{
m_offset
=
value
;
}
//* standalone buttons
bool
isStandAlone
()
const
{
return
m_flag
==
FlagStandalone
;
}
//* horizontal offset, for rendering
void
setHorizontalOffset
(
qreal
value
)
{
m_offset
.
setX
(
value
);
}
//* offset
void
setOffset
(
const
QPointF
&
value
)
{
m_offset
=
value
;
}
//* vertical offset, for rendering
void
setVerticalOffset
(
qreal
value
)
{
m_offset
.
setY
(
value
);
}
//* horizontal offset, for rendering
void
setHorizontalOffset
(
qreal
value
)
{
m_offset
.
setX
(
value
);
}
//* set icon size
void
setIconSize
(
const
QSize
&
value
)
{
m_iconSize
=
value
;
}
//* vertical offset, for rendering
void
setVerticalOffset
(
qreal
value
)
{
m_offset
.
setY
(
value
);
}
//*@name active state change animation
//@{
void
setOpacity
(
qreal
value
)
{
if
(
m_opacity
==
value
)
return
;
m_opacity
=
value
;
update
();
}
//* set icon size
void
setIconSize
(
const
QSize
&
value
)
{
m_iconSize
=
value
;
}
qreal
opacity
()
const
{
return
m_opacity
;
}
//*@name active state change animation
//@{
void
setOpacity
(
qreal
value
)
{
if
(
m_opacity
==
value
)
return
;
m_opacity
=
value
;
update
();
}
//@}
qreal
opacity
()
const
{
return
m_opacity
;
}
private
Q_SLOTS
:
//@}
//* apply configuration changes
void
reconfigure
();
private
Q_SLOTS
:
//* a
nimation state
void
updateAnimationState
(
bool
);
//* a
pply configuration changes
void
reconfigure
(
);
private:
//* animation state
void
updateAnimationState
(
bool
);
//* private constructor
explicit
Button
(
KDecoration2
::
DecorationButtonType
type
,
Decoration
*
decoration
,
QObject
*
parent
=
nullptr
);
private:
//* private constructor
explicit
Button
(
KDecoration2
::
DecorationButtonType
type
,
Decoration
*
decoration
,
QObject
*
parent
=
nullptr
);
//* draw button icon
void
drawIcon
(
QPainter
*
)
const
;
//* draw button icon
void
drawIcon
(
QPainter
*
)
const
;
//*@name colors
//@{
QColor
foregroundColor
()
const
;
QColor
backgroundColor
()
const
;
//@}
//*@name colors
//@{
QColor
foregroundColor
()
const
;
QColor
backgroundColor
()
const
;
//@}
Flag
m_flag
=
FlagNone
;
Flag
m_flag
=
FlagNone
;
//* active state change animation
QVariantAnimation
*
m_animation
;
//* active state change animation
QVariantAnimation
*
m_animation
;
//* vertical offset (for rendering)
QPointF
m_offset
;
//* vertical offset (for rendering)
QPointF
m_offset
;
//* icon size
QSize
m_iconSize
;
//* icon size
QSize
m_iconSize
;
//* active state change opacity
qreal
m_opacity
=
0
;
};
//* active state change opacity
qreal
m_opacity
=
0
;
};
}
// namespace
...
...
kdecoration/breezedecoration.cpp
View file @
32149dc0
This diff is collapsed.
Click to expand it.
kdecoration/breezedecoration.h
View file @
32149dc0
...
...
@@ -11,8 +11,8 @@
#include "breeze.h"
#include "breezesettings.h"
#include <KDecoration2/Decoration>
#include <KDecoration2/DecoratedClient>
#include <KDecoration2/Decoration>
#include <KDecoration2/DecorationSettings>
#include <QPalette>
...
...
@@ -23,185 +23,204 @@ class QVariantAnimation;
namespace
KDecoration2
{
class
DecorationButton
;
class
DecorationButtonGroup
;
class
DecorationButton
;
class
DecorationButtonGroup
;
}
namespace
Breeze
{
class
SizeGrip
;
class
Decoration
:
public
KDecoration2
::
Decoration
{
Q_OBJECT
public:
//* constructor
explicit
Decoration
(
QObject
*
parent
=
nullptr
,
const
QVariantList
&
args
=
QVariantList
());
//* destructor
virtual
~
Decoration
();
//* paint
void
paint
(
QPainter
*
painter
,
const
QRect
&
repaintRegion
)
override
;
//* internal settings
InternalSettingsPtr
internalSettings
()
const
{
return
m_internalSettings
;
}
qreal
animationsDuration
()
const
{
return
m_animation
->
duration
();}
//* caption height
int
captionHeight
()
const
;
//* button height
int
buttonHeight
()
const
;
//*@name active state change animation
//@{
void
setOpacity
(
qreal
);
qreal
opacity
()
const
{
return
m_opacity
;
}
//@}
//*@name colors
//@{
QColor
titleBarColor
()
const
;
QColor
fontColor
()
const
;
//@}
//*@name maximization modes
//@{
inline
bool
isMaximized
()
const
;
inline
bool
isMaximizedHorizontally
()
const
;
inline
bool
isMaximizedVertically
()
const
;
inline
bool
isLeftEdge
()
const
;
inline
bool
isRightEdge
()
const
;
inline
bool
isTopEdge
()
const
;
inline
bool
isBottomEdge
()
const
;
inline
bool
hideTitleBar
()
const
;
//@}
public
Q_SLOTS
:
void
init
()
override
;
private
Q_SLOTS
:
void
reconfigure
();
void
recalculateBorders
();
void
updateButtonsGeometry
();
void
updateButtonsGeometryDelayed
();
void
updateTitleBar
();
void
updateAnimationState
();
void
updateSizeGripVisibility
();
void
onTabletModeChanged
(
bool
mode
);
private:
//* return the rect in which caption will be drawn
QPair
<
QRect
,
Qt
::
Alignment
>
captionRect
()
const
;
void
createButtons
();
void
paintTitleBar
(
QPainter
*
painter
,
const
QRect
&
repaintRegion
);
void
updateShadow
();
QSharedPointer
<
KDecoration2
::
DecorationShadow
>
createShadowObject
(
const
float
strengthScale
);
void
setScaledCornerRadius
();
//*@name border size
//@{
int
borderSize
(
bool
bottom
=
false
)
const
;
inline
bool
hasBorders
()
const
;
inline
bool
hasNoBorders
()
const
;
inline
bool
hasNoSideBorders
()
const
;
//@}
//*@name size grip
//@{
void
createSizeGrip
();
void
deleteSizeGrip
();
SizeGrip
*
sizeGrip
()
const
{
return
m_sizeGrip
;
}
//@}
InternalSettingsPtr
m_internalSettings
;
KDecoration2
::
DecorationButtonGroup
*
m_leftButtons
=
nullptr
;
KDecoration2
::
DecorationButtonGroup
*
m_rightButtons
=
nullptr
;
//* size grip widget
SizeGrip
*
m_sizeGrip
=
nullptr
;
//* active state change animation
QVariantAnimation
*
m_animation
;
QVariantAnimation
*
m_shadowAnimation
;
//* active state change opacity
qreal
m_opacity
=
0
;
qreal
m_shadowOpacity
=
0
;
//*frame corner radius, scaled according to DPI
qreal
m_scaledCornerRadius
=
3
;
bool
m_tabletMode
=
false
;
};
bool
Decoration
::
hasBorders
()
const
{
if
(
m_internalSettings
&&
m_internalSettings
->
mask
()
&
BorderSize
)
return
m_internalSettings
->
borderSize
()
>
InternalSettings
::
BorderNoSides
;
else
return
settings
()
->
borderSize
()
>
KDecoration2
::
BorderSize
::
NoSides
;
}
class
SizeGrip
;
class
Decoration
:
public
KDecoration2
::
Decoration
{
Q_OBJECT
public:
//* constructor
explicit
Decoration
(
QObject
*
parent
=
nullptr
,
const
QVariantList
&
args
=
QVariantList
());
bool
Decoration
::
hasNoBorders
()
const
//* destructor
virtual
~
Decoration
();
//* paint
void
paint
(
QPainter
*
painter
,
const
QRect
&
repaintRegion
)
override
;
//* internal settings
InternalSettingsPtr
internalSettings
()
const
{
if
(
m_internalSettings
&&
m_internalSettings
->
mask
()
&
BorderSize
)
return
m_internalSettings
->
borderSize
()
==
InternalSettings
::
BorderNone
;
else
return
settings
()
->
borderSize
()
==
KDecoration2
::
BorderSize
::
None
;
return
m_internalSettings
;
}
bool
Decoration
::
hasNoSideBorders
()
const
qreal
animationsDuration
()
const
{
if
(
m_internalSettings
&&
m_internalSettings
->
mask
()
&
BorderSize
)
return
m_internalSettings
->
borderSize
()
==
InternalSettings
::
BorderNoSides
;
else
return
settings
()
->
borderSize
()
==
KDecoration2
::
BorderSize
::
NoSides
;
return
m_animation
->
duration
();
}
bool
Decoration
::
isMaximized
()
cons
t
{
return
client
().
toStrongRef
()
->
isMaximized
()
&&
!
m_internalSettings
->
drawBorderOnMaximizedWindows
();
}
//* caption heigh
t
int
captionHeight
()
const
;
bool
Decoration
::
isMaximizedHorizontally
()
cons
t
{
return
client
().
toStrongRef
()
->
isMaximizedHorizontally
()
&&
!
m_internalSettings
->
drawBorderOnMaximizedWindows
();
}
//* button heigh
t
int
buttonHeight
()
const
;
bool
Decoration
::
isMaximizedVertically
()
const
{
return
client
().
toStrongRef
()
->
isMaximizedVertically
()
&&
!
m_internalSettings
->
drawBorderOnMaximizedWindows
();
}
//*@name active state change animation
//@{
void
setOpacity
(
qreal
);
bool
Decoration
::
isLeftEdge
()
const
qreal
opacity
()
const
{
const
auto
c
=
client
().
toStrongRef
();
return
(
c
->
isMaximizedHorizontally
()
||
c
->
adjacentScreenEdges
().
testFlag
(
Qt
::
LeftEdge
)
)
&&
!
m_internalSettings
->
drawBorderOnMaximizedWindows
();
return
m_opacity
;
}
bool
Decoration
::
isRightEdge
()
const
//@}
//*@name colors
//@{
QColor
titleBarColor
()
const
;
QColor
fontColor
()
const
;
//@}
//*@name maximization modes
//@{
inline
bool
isMaximized
()
const
;
inline
bool
isMaximizedHorizontally
()
const
;
inline
bool
isMaximizedVertically
()
const
;
inline
bool
isLeftEdge
()
const
;
inline
bool
isRightEdge
()
const
;
inline
bool
isTopEdge
()
const
;
inline
bool
isBottomEdge
()
const
;
inline
bool
hideTitleBar
()
const
;
//@}
public
Q_SLOTS
:
void
init
()
override
;
private
Q_SLOTS
:
void
reconfigure
();
void
recalculateBorders
();
void
updateButtonsGeometry
();
void
updateButtonsGeometryDelayed
();
void
updateTitleBar
();
void
updateAnimationState
();
void
updateSizeGripVisibility
();
void
onTabletModeChanged
(
bool
mode
);
private:
//* return the rect in which caption will be drawn
QPair
<
QRect
,
Qt
::
Alignment
>
captionRect
()
const
;
void
createButtons
();
void
paintTitleBar
(
QPainter
*
painter
,
const
QRect
&
repaintRegion
);
void
updateShadow
();
QSharedPointer
<
KDecoration2
::
DecorationShadow
>
createShadowObject
(
const
float
strengthScale
);
void
setScaledCornerRadius
();
//*@name border size
//@{
int
borderSize
(
bool
bottom
=
false
)
const
;
inline
bool
hasBorders
()
const
;
inline
bool
hasNoBorders
()
const
;
inline
bool
hasNoSideBorders
()
const
;
//@}
//*@name size grip
//@{
void
createSizeGrip
();
void
deleteSizeGrip
();
SizeGrip
*
sizeGrip
()
const
{
const
auto
c
=
client
().
toStrongRef
();
return
(
c
->
isMaximizedHorizontally
()
||
c
->
adjacentScreenEdges
().
testFlag
(
Qt
::
RightEdge
)
)
&&
!
m_internalSettings
->
drawBorderOnMaximizedWindows
();
return
m_sizeGrip
;
}
//@}
bool
Decoration
::
isTopEdge
()
const
{
const
auto
c
=
client
().
toStrongRef
();
return
(
c
->
isMaximizedVertically
()
||
c
->
adjacentScreenEdges
().
testFlag
(
Qt
::
TopEdge
)
)
&&
!
m_internalSettings
->
drawBorderOnMaximizedWindows
();
}
InternalSettingsPtr
m_internalSettings
;
KDecoration2
::
DecorationButtonGroup
*
m_leftButtons
=
nullptr
;
KDecoration2
::
DecorationButtonGroup
*
m_rightButtons
=
nullptr
;
bool
Decoration
::
isBottomEdge
()
const
{
const
auto
c
=
client
().
toStrongRef
();
return
(
c
->
isMaximizedVertically
()
||
c
->
adjacentScreenEdges
().
testFlag
(
Qt
::
BottomEdge
)
)
&&
!
m_internalSettings
->
drawBorderOnMaximizedWindows
();
}
//* size grip widget
SizeGrip
*
m_sizeGrip
=
nullptr
;
bool
Decoration
::
hideTitleBar
()
const
{
return
m_internalSettings
->
hideTitleBar
()
&&
!
client
().
toStrongRef
()
->
isShaded
();
}
//* active state change animation
QVariantAnimation
*
m_animation
;
QVariantAnimation
*
m_shadowAnimation
;
//* active state change opacity
qreal
m_opacity
=
0
;
qreal
m_shadowOpacity
=
0
;
//*frame corner radius, scaled according to DPI
qreal
m_scaledCornerRadius
=
3
;
bool
m_tabletMode
=
false
;
};
bool
Decoration
::
hasBorders
()
const
{
if
(
m_internalSettings
&&
m_internalSettings
->
mask
()
&
BorderSize
)
return
m_internalSettings
->
borderSize
()
>
InternalSettings
::
BorderNoSides
;
else